@defra/forms-engine-plugin 5.0.0-alpha.3 → 5.0.0-alpha.31

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 (406) hide show
  1. package/.public/37c964ca545c240f010a.mjs +2 -0
  2. package/.public/37c964ca545c240f010a.mjs.LICENSE.txt +4 -0
  3. package/.public/assets-manifest.json +3 -0
  4. package/.public/javascripts/application.min.js +1 -1
  5. package/.public/javascripts/application.min.js.LICENSE.txt +7 -0
  6. package/.public/javascripts/application.min.js.map +1 -1
  7. package/.public/javascripts/shared.min.js +1 -1
  8. package/.public/javascripts/shared.min.js.LICENSE.txt +9 -0
  9. package/.public/javascripts/shared.min.js.map +1 -1
  10. package/.public/javascripts/vendor/@defra.min.js +1 -1
  11. package/.public/javascripts/vendor/@defra.min.js.map +1 -1
  12. package/.public/javascripts/vendor/maplibre-gl.min.js +1 -1
  13. package/.public/javascripts/vendor/maplibre-gl.min.js.LICENSE.txt +3 -3
  14. package/.public/javascripts/vendor/maplibre-gl.min.js.map +1 -1
  15. package/.public/stylesheets/application.min.css +1 -1
  16. package/.public/stylesheets/application.min.css.map +1 -1
  17. package/.server/client/javascripts/file-upload.js +6 -3
  18. package/.server/client/javascripts/file-upload.js.map +1 -1
  19. package/.server/client/javascripts/geospatial-map.d.ts +159 -5
  20. package/.server/client/javascripts/geospatial-map.js +161 -81
  21. package/.server/client/javascripts/geospatial-map.js.map +1 -1
  22. package/.server/client/javascripts/geospatial-map.test.js +152 -0
  23. package/.server/client/javascripts/geospatial-map.test.js.map +1 -0
  24. package/.server/client/javascripts/govuk.js +2 -1
  25. package/.server/client/javascripts/govuk.js.map +1 -1
  26. package/.server/client/javascripts/location-map.d.ts +44 -0
  27. package/.server/client/javascripts/location-map.js +55 -6
  28. package/.server/client/javascripts/location-map.js.map +1 -1
  29. package/.server/client/javascripts/map-constants.d.ts +3 -0
  30. package/.server/client/javascripts/map-constants.js +4 -0
  31. package/.server/client/javascripts/map-constants.js.map +1 -0
  32. package/.server/client/javascripts/map.d.ts +17 -4
  33. package/.server/client/javascripts/map.js +59 -6
  34. package/.server/client/javascripts/map.js.map +1 -1
  35. package/.server/client/javascripts/maps.d.ts +5 -0
  36. package/.server/client/javascripts/maps.js +6 -0
  37. package/.server/client/javascripts/maps.js.map +1 -0
  38. package/.server/client/javascripts/shared.d.ts +1 -4
  39. package/.server/client/javascripts/shared.js +1 -4
  40. package/.server/client/javascripts/shared.js.map +1 -1
  41. package/.server/client/javascripts/sssi-dataset.d.ts +18 -20
  42. package/.server/client/javascripts/sssi-dataset.js +37 -39
  43. package/.server/client/javascripts/sssi-dataset.js.map +1 -1
  44. package/.server/client/stylesheets/maps.scss +4 -0
  45. package/.server/client/stylesheets/shared.scss +1 -5
  46. package/.server/server/constants.d.ts +2 -0
  47. package/.server/server/constants.js +2 -0
  48. package/.server/server/constants.js.map +1 -1
  49. package/.server/server/forms/components.json +8 -0
  50. package/.server/server/forms/register-as-a-unicorn-breeder.yaml +4 -0
  51. package/.server/server/plugins/engine/__stubs__/definitions.d.ts +29 -0
  52. package/.server/server/plugins/engine/__stubs__/definitions.js +125 -0
  53. package/.server/server/plugins/engine/__stubs__/definitions.js.map +1 -0
  54. package/.server/server/plugins/engine/components/AutocompleteField.d.ts +8 -3
  55. package/.server/server/plugins/engine/components/AutocompleteField.js +17 -0
  56. package/.server/server/plugins/engine/components/AutocompleteField.js.map +1 -1
  57. package/.server/server/plugins/engine/components/CheckboxesField.d.ts +23 -2
  58. package/.server/server/plugins/engine/components/CheckboxesField.js +30 -5
  59. package/.server/server/plugins/engine/components/CheckboxesField.js.map +1 -1
  60. package/.server/server/plugins/engine/components/ComponentBase.d.ts +2 -1
  61. package/.server/server/plugins/engine/components/ComponentBase.js +2 -0
  62. package/.server/server/plugins/engine/components/ComponentBase.js.map +1 -1
  63. package/.server/server/plugins/engine/components/ComponentCollection.js +12 -7
  64. package/.server/server/plugins/engine/components/ComponentCollection.js.map +1 -1
  65. package/.server/server/plugins/engine/components/DatePartsField.d.ts +6 -3
  66. package/.server/server/plugins/engine/components/DatePartsField.js +12 -7
  67. package/.server/server/plugins/engine/components/DatePartsField.js.map +1 -1
  68. package/.server/server/plugins/engine/components/DeclarationField.d.ts +6 -3
  69. package/.server/server/plugins/engine/components/DeclarationField.js +6 -4
  70. package/.server/server/plugins/engine/components/DeclarationField.js.map +1 -1
  71. package/.server/server/plugins/engine/components/Details.d.ts +1 -0
  72. package/.server/server/plugins/engine/components/EastingNorthingField.d.ts +33 -2
  73. package/.server/server/plugins/engine/components/EastingNorthingField.js +110 -54
  74. package/.server/server/plugins/engine/components/EastingNorthingField.js.map +1 -1
  75. package/.server/server/plugins/engine/components/EmailAddressField.d.ts +4 -1
  76. package/.server/server/plugins/engine/components/EmailAddressField.js +2 -1
  77. package/.server/server/plugins/engine/components/EmailAddressField.js.map +1 -1
  78. package/.server/server/plugins/engine/components/FileUploadField.d.ts +23 -2
  79. package/.server/server/plugins/engine/components/FileUploadField.js +35 -3
  80. package/.server/server/plugins/engine/components/FileUploadField.js.map +1 -1
  81. package/.server/server/plugins/engine/components/FormComponent.d.ts +5 -1
  82. package/.server/server/plugins/engine/components/FormComponent.js +5 -2
  83. package/.server/server/plugins/engine/components/FormComponent.js.map +1 -1
  84. package/.server/server/plugins/engine/components/GeospatialField.d.ts +23 -0
  85. package/.server/server/plugins/engine/components/GeospatialField.js +33 -9
  86. package/.server/server/plugins/engine/components/GeospatialField.js.map +1 -1
  87. package/.server/server/plugins/engine/components/Html.d.ts +1 -0
  88. package/.server/server/plugins/engine/components/InsetText.d.ts +1 -0
  89. package/.server/server/plugins/engine/components/LatLongField.d.ts +32 -2
  90. package/.server/server/plugins/engine/components/LatLongField.js +85 -48
  91. package/.server/server/plugins/engine/components/LatLongField.js.map +1 -1
  92. package/.server/server/plugins/engine/components/List.d.ts +1 -0
  93. package/.server/server/plugins/engine/components/ListFormComponent.d.ts +3 -2
  94. package/.server/server/plugins/engine/components/ListFormComponent.js.map +1 -1
  95. package/.server/server/plugins/engine/components/LocationFieldBase.d.ts +8 -2
  96. package/.server/server/plugins/engine/components/LocationFieldBase.js +31 -7
  97. package/.server/server/plugins/engine/components/LocationFieldBase.js.map +1 -1
  98. package/.server/server/plugins/engine/components/LocationFieldHelpers.d.ts +12 -3
  99. package/.server/server/plugins/engine/components/LocationFieldHelpers.js +21 -13
  100. package/.server/server/plugins/engine/components/LocationFieldHelpers.js.map +1 -1
  101. package/.server/server/plugins/engine/components/Markdown.d.ts +1 -0
  102. package/.server/server/plugins/engine/components/Markdown.js +1 -1
  103. package/.server/server/plugins/engine/components/Markdown.js.map +1 -1
  104. package/.server/server/plugins/engine/components/MonthYearField.d.ts +5 -2
  105. package/.server/server/plugins/engine/components/MonthYearField.js +13 -9
  106. package/.server/server/plugins/engine/components/MonthYearField.js.map +1 -1
  107. package/.server/server/plugins/engine/components/MultilineTextField.d.ts +1 -0
  108. package/.server/server/plugins/engine/components/NationalGridFieldNumberField.d.ts +2 -1
  109. package/.server/server/plugins/engine/components/NationalGridFieldNumberField.js +4 -3
  110. package/.server/server/plugins/engine/components/NationalGridFieldNumberField.js.map +1 -1
  111. package/.server/server/plugins/engine/components/NotificationBanner.d.ts +1 -0
  112. package/.server/server/plugins/engine/components/NumberField.d.ts +5 -0
  113. package/.server/server/plugins/engine/components/NumberField.js +22 -0
  114. package/.server/server/plugins/engine/components/NumberField.js.map +1 -1
  115. package/.server/server/plugins/engine/components/OsGridRefField.d.ts +103 -1
  116. package/.server/server/plugins/engine/components/OsGridRefField.js +13 -3
  117. package/.server/server/plugins/engine/components/OsGridRefField.js.map +1 -1
  118. package/.server/server/plugins/engine/components/PaymentField.d.ts +2 -0
  119. package/.server/server/plugins/engine/components/PaymentField.js +9 -5
  120. package/.server/server/plugins/engine/components/PaymentField.js.map +1 -1
  121. package/.server/server/plugins/engine/components/SelectField.d.ts +1 -0
  122. package/.server/server/plugins/engine/components/SelectionControlField.d.ts +1 -0
  123. package/.server/server/plugins/engine/components/TelephoneNumberField.d.ts +1 -0
  124. package/.server/server/plugins/engine/components/TrackingField.d.ts +21 -0
  125. package/.server/server/plugins/engine/components/TrackingField.js +46 -0
  126. package/.server/server/plugins/engine/components/TrackingField.js.map +1 -0
  127. package/.server/server/plugins/engine/components/UkAddressField.d.ts +1 -0
  128. package/.server/server/plugins/engine/components/UkAddressField.js +23 -8
  129. package/.server/server/plugins/engine/components/UkAddressField.js.map +1 -1
  130. package/.server/server/plugins/engine/components/YesNoField.d.ts +3 -2
  131. package/.server/server/plugins/engine/components/YesNoField.js +22 -8
  132. package/.server/server/plugins/engine/components/YesNoField.js.map +1 -1
  133. package/.server/server/plugins/engine/components/helpers/components.d.ts +1 -1
  134. package/.server/server/plugins/engine/components/helpers/components.js +6 -3
  135. package/.server/server/plugins/engine/components/helpers/components.js.map +1 -1
  136. package/.server/server/plugins/engine/components/helpers/geospatial.d.ts +8 -1
  137. package/.server/server/plugins/engine/components/helpers/geospatial.js +58 -17
  138. package/.server/server/plugins/engine/components/helpers/geospatial.js.map +1 -1
  139. package/.server/server/plugins/engine/components/helpers/index.d.ts +21 -1
  140. package/.server/server/plugins/engine/components/helpers/index.js +45 -1
  141. package/.server/server/plugins/engine/components/helpers/index.js.map +1 -1
  142. package/.server/server/plugins/engine/components/index.d.ts +1 -0
  143. package/.server/server/plugins/engine/components/index.js +1 -0
  144. package/.server/server/plugins/engine/components/index.js.map +1 -1
  145. package/.server/server/plugins/engine/components/types.d.ts +1 -0
  146. package/.server/server/plugins/engine/components/types.js.map +1 -1
  147. package/.server/server/plugins/engine/errors.d.ts +49 -0
  148. package/.server/server/plugins/engine/errors.js +75 -0
  149. package/.server/server/plugins/engine/errors.js.map +1 -0
  150. package/.server/server/plugins/engine/form-availability.d.ts +3 -2
  151. package/.server/server/plugins/engine/form-availability.js +3 -2
  152. package/.server/server/plugins/engine/form-availability.js.map +1 -1
  153. package/.server/server/plugins/engine/form-context.js +2 -2
  154. package/.server/server/plugins/engine/form-context.js.map +1 -1
  155. package/.server/server/plugins/engine/helpers.d.ts +23 -2
  156. package/.server/server/plugins/engine/helpers.js +44 -5
  157. package/.server/server/plugins/engine/helpers.js.map +1 -1
  158. package/.server/server/plugins/engine/i18n/buildValidationMessages.d.ts +4 -1
  159. package/.server/server/plugins/engine/i18n/buildValidationMessages.js +31 -7
  160. package/.server/server/plugins/engine/i18n/buildValidationMessages.js.map +1 -1
  161. package/.server/server/plugins/engine/i18n/createFormTranslator.d.ts +4 -4
  162. package/.server/server/plugins/engine/i18n/createFormTranslator.js +27 -5
  163. package/.server/server/plugins/engine/i18n/createFormTranslator.js.map +1 -1
  164. package/.server/server/plugins/engine/i18n/extractBaseTranslations.d.ts +1 -1
  165. package/.server/server/plugins/engine/i18n/extractBaseTranslations.js +9 -0
  166. package/.server/server/plugins/engine/i18n/extractBaseTranslations.js.map +1 -1
  167. package/.server/server/plugins/engine/i18n/form.d.ts +13 -0
  168. package/.server/server/plugins/engine/i18n/form.js +35 -0
  169. package/.server/server/plugins/engine/i18n/form.js.map +1 -0
  170. package/.server/server/plugins/engine/i18n/languages.d.ts +10 -0
  171. package/.server/server/plugins/engine/i18n/languages.js +19 -0
  172. package/.server/server/plugins/engine/i18n/languages.js.map +1 -0
  173. package/.server/server/plugins/engine/i18n/translations/cy.json +176 -7
  174. package/.server/server/plugins/engine/i18n/translations/en-GB.json +110 -6
  175. package/.server/server/plugins/engine/i18n/types.d.ts +2 -0
  176. package/.server/server/plugins/engine/i18n/types.js.map +1 -1
  177. package/.server/server/plugins/engine/index.d.ts +4 -0
  178. package/.server/server/plugins/engine/index.js +4 -0
  179. package/.server/server/plugins/engine/index.js.map +1 -1
  180. package/.server/server/plugins/engine/models/FormModel.d.ts +0 -4
  181. package/.server/server/plugins/engine/models/FormModel.js +35 -23
  182. package/.server/server/plugins/engine/models/FormModel.js.map +1 -1
  183. package/.server/server/plugins/engine/models/SummaryViewModel.js +9 -4
  184. package/.server/server/plugins/engine/models/SummaryViewModel.js.map +1 -1
  185. package/.server/server/plugins/engine/models/types.d.ts +28 -1
  186. package/.server/server/plugins/engine/models/types.js.map +1 -1
  187. package/.server/server/plugins/engine/models/unavailable-view-model.d.ts +11 -2
  188. package/.server/server/plugins/engine/models/unavailable-view-model.js +23 -4
  189. package/.server/server/plugins/engine/models/unavailable-view-model.js.map +1 -1
  190. package/.server/server/plugins/engine/options.js +2 -1
  191. package/.server/server/plugins/engine/options.js.map +1 -1
  192. package/.server/server/plugins/engine/outputFormatters/adapter/v1.js +14 -6
  193. package/.server/server/plugins/engine/outputFormatters/adapter/v1.js.map +1 -1
  194. package/.server/server/plugins/engine/outputFormatters/human/v1.js +2 -1
  195. package/.server/server/plugins/engine/outputFormatters/human/v1.js.map +1 -1
  196. package/.server/server/plugins/engine/outputFormatters/machine/v2.d.ts +2 -0
  197. package/.server/server/plugins/engine/outputFormatters/machine/v2.js +2 -0
  198. package/.server/server/plugins/engine/outputFormatters/machine/v2.js.map +1 -1
  199. package/.server/server/plugins/engine/pageControllers/FileUploadPageController.d.ts +7 -1
  200. package/.server/server/plugins/engine/pageControllers/FileUploadPageController.js +56 -10
  201. package/.server/server/plugins/engine/pageControllers/FileUploadPageController.js.map +1 -1
  202. package/.server/server/plugins/engine/pageControllers/QuestionPageController.d.ts +1 -1
  203. package/.server/server/plugins/engine/pageControllers/QuestionPageController.js +2 -2
  204. package/.server/server/plugins/engine/pageControllers/QuestionPageController.js.map +1 -1
  205. package/.server/server/plugins/engine/pageControllers/RepeatPageController.js +3 -4
  206. package/.server/server/plugins/engine/pageControllers/RepeatPageController.js.map +1 -1
  207. package/.server/server/plugins/engine/pageControllers/SummaryPageController.js +10 -4
  208. package/.server/server/plugins/engine/pageControllers/SummaryPageController.js.map +1 -1
  209. package/.server/server/plugins/engine/pageControllers/helpers/pages.js +2 -1
  210. package/.server/server/plugins/engine/pageControllers/helpers/pages.js.map +1 -1
  211. package/.server/server/plugins/engine/pageControllers/helpers/submission.d.ts +35 -2
  212. package/.server/server/plugins/engine/pageControllers/helpers/submission.js +100 -3
  213. package/.server/server/plugins/engine/pageControllers/helpers/submission.js.map +1 -1
  214. package/.server/server/plugins/engine/pageControllers/validationOptions.d.ts +1 -1
  215. package/.server/server/plugins/engine/pageControllers/validationOptions.js +24 -3
  216. package/.server/server/plugins/engine/pageControllers/validationOptions.js.map +1 -1
  217. package/.server/server/plugins/engine/plugin.js +3 -0
  218. package/.server/server/plugins/engine/plugin.js.map +1 -1
  219. package/.server/server/plugins/engine/referenceNumbers.d.ts +1 -0
  220. package/.server/server/plugins/engine/referenceNumbers.js +1 -0
  221. package/.server/server/plugins/engine/referenceNumbers.js.map +1 -1
  222. package/.server/server/plugins/engine/routes/index.js +9 -4
  223. package/.server/server/plugins/engine/routes/index.js.map +1 -1
  224. package/.server/server/plugins/engine/types/enums.d.ts +3 -3
  225. package/.server/server/plugins/engine/types/enums.js +5 -4
  226. package/.server/server/plugins/engine/types/enums.js.map +1 -1
  227. package/.server/server/plugins/engine/types/schema.js +15 -4
  228. package/.server/server/plugins/engine/types/schema.js.map +1 -1
  229. package/.server/server/plugins/engine/types.d.ts +24 -2
  230. package/.server/server/plugins/engine/types.js.map +1 -1
  231. package/.server/server/plugins/engine/unavailable-response.js +5 -2
  232. package/.server/server/plugins/engine/unavailable-response.js.map +1 -1
  233. package/.server/server/plugins/engine/views/components/_location-field-base.html +4 -2
  234. package/.server/server/plugins/engine/views/components/fileuploadfield.html +1 -1
  235. package/.server/server/plugins/engine/views/components/geospatialfield.html +1 -0
  236. package/.server/server/plugins/engine/views/components/osgridreffield.html +4 -1
  237. package/.server/server/plugins/engine/views/components/trackingfield.html +3 -0
  238. package/.server/server/plugins/engine/views/components/ukaddressfield.html +1 -1
  239. package/.server/server/plugins/engine/views/file-upload.html +1 -1
  240. package/.server/server/plugins/engine/views/summary.html +1 -0
  241. package/.server/server/plugins/engine/views/unavailable.html +14 -11
  242. package/.server/server/plugins/map/routes/index.d.ts +4 -0
  243. package/.server/server/plugins/map/routes/index.js +12 -4
  244. package/.server/server/plugins/map/routes/index.js.map +1 -1
  245. package/.server/server/plugins/map/routes/index.test.js +7 -0
  246. package/.server/server/plugins/map/routes/index.test.js.map +1 -0
  247. package/.server/server/plugins/map/routes/vts/README.md +38 -0
  248. package/.server/server/plugins/map/routes/vts/countries-5dp.geojson +4 -0
  249. package/.server/server/plugins/map/routes/vts/countries.geojson +10 -39283
  250. package/.server/server/plugins/map/types.d.ts +24 -2
  251. package/.server/server/plugins/map/types.js +9 -2
  252. package/.server/server/plugins/map/types.js.map +1 -1
  253. package/.server/server/plugins/nunjucks/enviroment.test.js +11 -4
  254. package/.server/server/plugins/nunjucks/enviroment.test.js.map +1 -1
  255. package/.server/server/plugins/nunjucks/filters/applyUrlParam.d.ts +9 -0
  256. package/.server/server/plugins/nunjucks/filters/applyUrlParam.js +17 -0
  257. package/.server/server/plugins/nunjucks/filters/applyUrlParam.js.map +1 -0
  258. package/.server/server/plugins/nunjucks/filters/applyUrlParam.test.js +17 -0
  259. package/.server/server/plugins/nunjucks/filters/applyUrlParam.test.js.map +1 -0
  260. package/.server/server/plugins/nunjucks/filters/field.d.ts +1 -1
  261. package/.server/server/plugins/nunjucks/filters/index.d.ts +1 -0
  262. package/.server/server/plugins/nunjucks/filters/index.js +1 -0
  263. package/.server/server/plugins/nunjucks/filters/index.js.map +1 -1
  264. package/.server/server/plugins/payment/helper.d.ts +11 -1
  265. package/.server/server/plugins/payment/helper.js +18 -2
  266. package/.server/server/plugins/payment/helper.js.map +1 -1
  267. package/.server/server/plugins/payment/helper.test.js +2 -1
  268. package/.server/server/plugins/payment/helper.test.js.map +1 -1
  269. package/.server/server/plugins/payment/service.d.ts +2 -1
  270. package/.server/server/plugins/payment/service.js +5 -2
  271. package/.server/server/plugins/payment/service.js.map +1 -1
  272. package/.server/server/plugins/payment/service.test.js +7 -3
  273. package/.server/server/plugins/payment/service.test.js.map +1 -1
  274. package/.server/server/plugins/payment/types.d.ts +4 -0
  275. package/.server/server/plugins/payment/types.js +1 -0
  276. package/.server/server/plugins/payment/types.js.map +1 -1
  277. package/.server/server/plugins/postcode-lookup/models/index.d.ts +249 -3
  278. package/.server/server/plugins/postcode-lookup/models/index.js +103 -36
  279. package/.server/server/plugins/postcode-lookup/models/index.js.map +1 -1
  280. package/.server/server/plugins/postcode-lookup/routes/index.d.ts +15 -1
  281. package/.server/server/plugins/postcode-lookup/routes/index.js +64 -18
  282. package/.server/server/plugins/postcode-lookup/routes/index.js.map +1 -1
  283. package/.server/server/plugins/postcode-lookup/routes/index.test.js +84 -0
  284. package/.server/server/plugins/postcode-lookup/routes/index.test.js.map +1 -0
  285. package/.server/server/plugins/postcode-lookup/types.d.ts +12 -0
  286. package/.server/server/plugins/postcode-lookup/types.js +6 -1
  287. package/.server/server/plugins/postcode-lookup/types.js.map +1 -1
  288. package/.server/server/plugins/postcode-lookup/views/postcode-lookup-details.html +3 -3
  289. package/.server/server/utils/type-utils.d.ts +1 -2
  290. package/.server/server/utils/type-utils.js +0 -3
  291. package/.server/server/utils/type-utils.js.map +1 -1
  292. package/.server/server/utils/utils.d.ts +6 -0
  293. package/.server/server/utils/utils.js +18 -1
  294. package/.server/server/utils/utils.js.map +1 -1
  295. package/.server/server/utils/utils.test.js +21 -1
  296. package/.server/server/utils/utils.test.js.map +1 -1
  297. package/.server/typings/geodesy/index.d.js +2 -0
  298. package/.server/typings/geodesy/index.d.js.map +1 -0
  299. package/.server/typings/hapi/index.d.js.map +1 -1
  300. package/package.json +24 -9
  301. package/src/client/javascripts/file-upload.js +11 -3
  302. package/src/client/javascripts/geospatial-map.js +181 -86
  303. package/src/client/javascripts/govuk.js +2 -0
  304. package/src/client/javascripts/location-map.js +62 -6
  305. package/src/client/javascripts/map-constants.js +3 -0
  306. package/src/client/javascripts/map.js +66 -9
  307. package/src/client/javascripts/maps.js +5 -0
  308. package/src/client/javascripts/shared.js +1 -4
  309. package/src/client/javascripts/sssi-dataset.js +39 -41
  310. package/src/client/stylesheets/maps.scss +4 -0
  311. package/src/client/stylesheets/shared.scss +1 -5
  312. package/src/server/constants.js +2 -0
  313. package/src/server/forms/components.json +8 -0
  314. package/src/server/forms/register-as-a-unicorn-breeder.yaml +4 -0
  315. package/src/server/plugins/engine/__stubs__/definitions.ts +155 -0
  316. package/src/server/plugins/engine/components/AutocompleteField.ts +20 -0
  317. package/src/server/plugins/engine/components/CheckboxesField.ts +41 -8
  318. package/src/server/plugins/engine/components/ComponentBase.ts +6 -4
  319. package/src/server/plugins/engine/components/ComponentCollection.ts +17 -15
  320. package/src/server/plugins/engine/components/DatePartsField.ts +20 -9
  321. package/src/server/plugins/engine/components/DeclarationField.ts +10 -10
  322. package/src/server/plugins/engine/components/EastingNorthingField.ts +185 -89
  323. package/src/server/plugins/engine/components/EmailAddressField.ts +2 -1
  324. package/src/server/plugins/engine/components/FileUploadField.ts +46 -5
  325. package/src/server/plugins/engine/components/FormComponent.ts +6 -5
  326. package/src/server/plugins/engine/components/GeospatialField.ts +47 -9
  327. package/src/server/plugins/engine/components/LatLongField.ts +128 -58
  328. package/src/server/plugins/engine/components/ListFormComponent.ts +4 -4
  329. package/src/server/plugins/engine/components/LocationFieldBase.ts +41 -8
  330. package/src/server/plugins/engine/components/LocationFieldHelpers.ts +28 -14
  331. package/src/server/plugins/engine/components/Markdown.ts +2 -3
  332. package/src/server/plugins/engine/components/MonthYearField.ts +20 -15
  333. package/src/server/plugins/engine/components/NationalGridFieldNumberField.ts +9 -3
  334. package/src/server/plugins/engine/components/NumberField.ts +24 -0
  335. package/src/server/plugins/engine/components/OsGridRefField.ts +22 -3
  336. package/src/server/plugins/engine/components/PaymentField.ts +9 -4
  337. package/src/server/plugins/engine/components/TrackingField.ts +64 -0
  338. package/src/server/plugins/engine/components/UkAddressField.ts +30 -7
  339. package/src/server/plugins/engine/components/YesNoField.ts +27 -9
  340. package/src/server/plugins/engine/components/helpers/components.ts +8 -3
  341. package/src/server/plugins/engine/components/helpers/geospatial.ts +87 -24
  342. package/src/server/plugins/engine/components/helpers/index.ts +64 -1
  343. package/src/server/plugins/engine/components/index.ts +1 -0
  344. package/src/server/plugins/engine/components/types.ts +1 -0
  345. package/src/server/plugins/engine/errors.ts +78 -0
  346. package/src/server/plugins/engine/form-availability.ts +8 -2
  347. package/src/server/plugins/engine/form-context.ts +4 -2
  348. package/src/server/plugins/engine/helpers.ts +52 -5
  349. package/src/server/plugins/engine/i18n/buildValidationMessages.ts +16 -8
  350. package/src/server/plugins/engine/i18n/createFormTranslator.ts +43 -12
  351. package/src/server/plugins/engine/i18n/extractBaseTranslations.ts +7 -1
  352. package/src/server/plugins/engine/i18n/form.ts +54 -0
  353. package/src/server/plugins/engine/i18n/languages.ts +19 -0
  354. package/src/server/plugins/engine/i18n/translations/cy.json +176 -7
  355. package/src/server/plugins/engine/i18n/translations/en-GB.json +110 -6
  356. package/src/server/plugins/engine/i18n/types.ts +2 -0
  357. package/src/server/plugins/engine/index.ts +7 -0
  358. package/src/server/plugins/engine/models/FormModel.ts +46 -23
  359. package/src/server/plugins/engine/models/SummaryViewModel.ts +6 -5
  360. package/src/server/plugins/engine/models/types.ts +31 -0
  361. package/src/server/plugins/engine/models/unavailable-view-model.ts +26 -5
  362. package/src/server/plugins/engine/options.js +2 -1
  363. package/src/server/plugins/engine/outputFormatters/adapter/v1.ts +18 -7
  364. package/src/server/plugins/engine/outputFormatters/human/v1.ts +2 -1
  365. package/src/server/plugins/engine/outputFormatters/machine/v2.ts +3 -0
  366. package/src/server/plugins/engine/pageControllers/FileUploadPageController.ts +60 -9
  367. package/src/server/plugins/engine/pageControllers/QuestionPageController.ts +2 -2
  368. package/src/server/plugins/engine/pageControllers/RepeatPageController.ts +2 -2
  369. package/src/server/plugins/engine/pageControllers/SummaryPageController.ts +15 -4
  370. package/src/server/plugins/engine/pageControllers/helpers/pages.ts +2 -1
  371. package/src/server/plugins/engine/pageControllers/helpers/submission.ts +143 -4
  372. package/src/server/plugins/engine/pageControllers/validationOptions.ts +29 -4
  373. package/src/server/plugins/engine/plugin.ts +6 -0
  374. package/src/server/plugins/engine/referenceNumbers.ts +2 -0
  375. package/src/server/plugins/engine/routes/index.ts +9 -3
  376. package/src/server/plugins/engine/types/enums.ts +4 -3
  377. package/src/server/plugins/engine/types/schema.ts +22 -5
  378. package/src/server/plugins/engine/types.ts +28 -1
  379. package/src/server/plugins/engine/unavailable-response.ts +6 -2
  380. package/src/server/plugins/engine/views/components/_location-field-base.html +4 -2
  381. package/src/server/plugins/engine/views/components/fileuploadfield.html +1 -1
  382. package/src/server/plugins/engine/views/components/geospatialfield.html +1 -0
  383. package/src/server/plugins/engine/views/components/osgridreffield.html +4 -1
  384. package/src/server/plugins/engine/views/components/trackingfield.html +3 -0
  385. package/src/server/plugins/engine/views/components/ukaddressfield.html +1 -1
  386. package/src/server/plugins/engine/views/file-upload.html +1 -1
  387. package/src/server/plugins/engine/views/summary.html +1 -0
  388. package/src/server/plugins/engine/views/unavailable.html +14 -11
  389. package/src/server/plugins/map/routes/index.js +29 -4
  390. package/src/server/plugins/map/routes/vts/README.md +38 -0
  391. package/src/server/plugins/map/routes/vts/countries-5dp.geojson +4 -0
  392. package/src/server/plugins/map/routes/vts/countries.geojson +10 -39283
  393. package/src/server/plugins/map/types.js +9 -2
  394. package/src/server/plugins/nunjucks/filters/applyUrlParam.js +17 -0
  395. package/src/server/plugins/nunjucks/filters/index.js +1 -0
  396. package/src/server/plugins/payment/helper.js +22 -2
  397. package/src/server/plugins/payment/service.js +6 -2
  398. package/src/server/plugins/payment/types.js +1 -0
  399. package/src/server/plugins/postcode-lookup/models/index.js +91 -46
  400. package/src/server/plugins/postcode-lookup/routes/index.js +96 -24
  401. package/src/server/plugins/postcode-lookup/types.js +6 -1
  402. package/src/server/plugins/postcode-lookup/views/postcode-lookup-details.html +3 -3
  403. package/src/server/utils/type-utils.ts +1 -11
  404. package/src/server/utils/utils.js +19 -1
  405. package/src/typings/geodesy/index.d.ts +18 -0
  406. package/src/typings/hapi/index.d.ts +2 -0
@@ -1,2 +1,2 @@
1
- (self.webpackChunk=self.webpackChunk||[]).push([[402],{967:(e,t,r)=>{r.r(t),r.d(t,{initialiseApp:()=>Pn});var n=r(585),o=r(505),i=r(321),a=r(818),s=r(196),l=r(452),c=r(247),u=(0,l.q6)(null);function d(){return(0,l.NT)(u)}function p(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={};return Object.keys(e).forEach(o=>{var i,a=e[o][t];null!==(i=null==a?void 0:a.open)&&void 0!==i&&i&&(n[o]=r[o]||{props:{}})}),n}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}var f=(e,t)=>{var r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},e);for(var o in t)"object"!=typeof t[o]||Array.isArray(t[o])||null===t[o]?r[o]=t[o]:r[o]=f(e[o]||{},t[o]);return r};function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var y=(e,t)=>v(v({},e),t),m=(e,t,r)=>{var n=f(pe,r);return v(v({},e),{},{[t]:n})};function b(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var O=(e,t)=>P(P({},e),t),S=(e,t,r)=>{var n=f(he,r);return P(P({},e),{},{[t]:P(P({},n),{},{html:n.html,render:n.render})})},w=(e,t)=>{var{[t]:r}=e;return(0,o.A)(e,[t].map(b))};function _(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var x=(e,t)=>M(M({},e),t),I=(e,t,r)=>{var n=f(fe,r);return M(M({},e),{},{[t]:M({id:t},n)})};function A(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function C(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?T(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function L(e,t,r,n,o){var i,a=e.panelConfig||e.panelRegistry.getPanelConfig(),s=null===(i=a[t])||void 0===i?void 0:i[r],l=!!s.exclusive&&!s.modal,c=!!s.modal,u=Object.fromEntries(Object.entries(e.openPanels).filter(e=>{var t,[n]=e;return!(null!==(t=a[n])&&void 0!==t&&null!==(t=t[r])&&void 0!==t&&t.exclusive)}));return C(C(C({},l?{}:u),c?e.openPanels:{}),{},{[t]:C({props:n},void 0!==o&&{focusOnOpen:o})})}var D={SET_BREAKPOINT:(e,t)=>{var r,{behaviour:n,hybridWidth:o,maxMobileWidth:i}=t,a=Object.keys(e.openPanels),l=a[a.length-1],c="hybrid"===n?e.isFullscreen:(0,s.g)({behaviour:n,hybridWidth:o,maxMobileWidth:i}),u=l?L(e,l,t.breakpoint,(null===(r=e.openPanels[l])||void 0===r?void 0:r.props)||{}):{},d=e.panelConfig||e.panelRegistry.getPanelConfig(),p=Object.fromEntries(Object.entries(d).filter(e=>{var[r,n]=e,o=n[t.breakpoint];return!0===(null==o?void 0:o.open)&&!1===(null==o?void 0:o.dismissible)&&!u[r]}).map(t=>{var[r]=t;return[r,e.openPanels[r]||{props:{}}]}));return C(C({},e),{},{breakpoint:t.breakpoint,isFullscreen:c,previousOpenPanels:e.openPanels,openPanels:C(C({},u),p)})},SET_MEDIA:(e,t)=>C(C({},e),t),SET_HYBRID_FULLSCREEN:(e,t)=>C(C({},e),{},{isFullscreen:t}),SET_INTERFACE_TYPE:(e,t)=>e.interfaceType===t?e:C(C({},e),{},{interfaceType:t}),SET_MODE:(e,t)=>{var r=e.panelConfig||e.panelRegistry.getPanelConfig();return C(C({},e),{},{mode:t,previousMode:e.mode,openPanels:p(r,e.breakpoint,e.openPanels)})},PLUGINS_EVALUATED:e=>e.arePluginsEvaluated?e:C(C({},e),{},{arePluginsEvaluated:!0}),CLEAR_PLUGINS_EVALUATED:e=>e.arePluginsEvaluated?C(C({},e),{},{arePluginsEvaluated:!1}):e,SET_LISTBOX_ACTIVE:e=>e.listboxIsActive?e:C(C({},e),{},{listboxIsActive:!0}),SET_SAFE_ZONE_INSET:(e,t)=>{var{safeZoneInset:r,syncMapPadding:n=!0}=t;return((e,t)=>{if(e===t)return!0;if(!e||!t||"object"!=typeof e||"object"!=typeof t)return!1;var r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every(r=>Object.is(e[r],t[r]))})(e.safeZoneInset,r)?e:C(C({},e),{},{safeZoneInset:r,syncMapPadding:n,isLayoutReady:!0})},REVERT_MODE:e=>{var t=e.panelConfig||e.panelRegistry.getPanelConfig();return C(C({},e),{},{mode:e.previousMode,previousMode:e.mode,openPanels:p(t,e.breakpoint,e.openPanels)})},OPEN_PANEL:(e,t)=>{var{panelId:r,props:n={},focusOnOpen:o}=t;return C(C({},e),{},{previousOpenPanels:e.openPanels,openPanels:L(e,r,e.breakpoint,n,o)})},CLOSE_PANEL:(e,t)=>{var r=e.openPanels,{[t]:n}=r,i=(0,o.A)(r,[t].map(A));return C(C({},e),{},{previousOpenPanels:e.openPanels,openPanels:i})},CLOSE_ALL_PANELS:e=>C(C({},e),{},{previousOpenPanels:e.openPanels,openPanels:{}}),RESTORE_PREVIOUS_PANELS:e=>C(C({},e),{},{openPanels:e.previousOpenPanels||{},previousOpenPanels:e.openPanels}),TOGGLE_APP_VISIBLE:(e,t)=>C(C({},e),{},{appVisible:t}),TOGGLE_HAS_EXCLUSIVE_CONTROL:(e,t)=>C(C({},e),{},{hasExclusiveControl:t}),TOGGLE_BUTTON_DISABLED:(e,t)=>{var{id:r,isDisabled:n}=t,o=new Set(e.disabledButtons);return n?o.add(r):o.delete(r),C(C({},e),{},{disabledButtons:o})},TOGGLE_BUTTON_HIDDEN:(e,t)=>{var{id:r,isHidden:n}=t,o=new Set(e.hiddenButtons);return n?o.add(r):o.delete(r),C(C({},e),{},{hiddenButtons:o})},TOGGLE_BUTTON_PRESSED:(e,t)=>{var{id:r,isPressed:n}=t,o=new Set(e.pressedButtons);return n?o.add(r):o.delete(r),C(C({},e),{},{pressedButtons:o})},TOGGLE_BUTTON_EXPANDED:(e,t)=>{var{id:r,isExpanded:n}=t,o=new Set(e.expandedButtons);return n?o.add(r):o.delete(r),C(C({},e),{},{expandedButtons:o})},REGISTER_BUTTON:(e,t)=>C(C({},e),{},{buttonConfig:y(e.buttonConfig,t)}),ADD_BUTTON:(e,t)=>{var r,{id:n,config:o}=t,i=m(e.buttonConfig,n,o),a=new Set(e.hiddenButtons);o.isHidden&&a.add(n);var s=new Set(e.disabledButtons);o.isDisabled&&s.add(n);var l=new Set(e.pressedButtons);o.isPressed&&l.add(n);var c=new Set(e.expandedButtons);return o.isExpanded&&c.add(n),null!==(r=e.buttonRegistry)&&void 0!==r&&r.addButton&&e.buttonRegistry.addButton(n,o),C(C({},e),{},{buttonConfig:i,hiddenButtons:a,disabledButtons:s,pressedButtons:l,expandedButtons:c})},REGISTER_PANEL:(e,t)=>C(C({},e),{},{panelConfig:O(e.panelConfig,t)}),ADD_PANEL:(e,t)=>{var r,{id:n,config:o}=t,i=S(e.panelConfig,n,o),a=i[n];null!==(r=e.panelRegistry)&&void 0!==r&&r.addPanel&&e.panelRegistry.addPanel(n,o);var s=null==a?void 0:a[e.breakpoint],l=null==s?void 0:s.open;return C(C({},e),{},{panelConfig:i,openPanels:l?L(C(C({},e),{},{panelConfig:i}),n,e.breakpoint,{}):e.openPanels})},REMOVE_PANEL:(e,t)=>{var r,n=t,i=e.openPanels,{[n]:a}=i,s=(0,o.A)(i,[n].map(A));return null!==(r=e.panelRegistry)&&void 0!==r&&r.removePanel&&e.panelRegistry.removePanel(n),C(C({},e),{},{panelConfig:w(e.panelConfig,n),openPanels:s})},REGISTER_CONTROL:(e,t)=>C(C({},e),{},{controlConfig:x(e.controlConfig,t)}),ADD_CONTROL:(e,t)=>{var r,{id:n,config:o}=t,i=I(e.controlConfig,n,o);return null!==(r=e.controlRegistry)&&void 0!==r&&r.addControl&&e.controlRegistry.addControl(n,o),C(C({},e),{},{controlConfig:i})}};function k(){return{preferredColorScheme:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",prefersReducedMotion:window.matchMedia("(prefers-reduced-motion: reduce)").matches}}var j=(e,t)=>{var{type:r,payload:n}=t,o=D[r];return o?o(e,n):e},R=Object.freeze({SIDE:"side",BANNER:"banner",TOP_LEFT:"top-left",TOP_MIDDLE:"top-middle",TOP_RIGHT:"top-right",LEFT_TOP:"left-top",LEFT_BOTTOM:"left-bottom",MIDDLE:"middle",RIGHT_TOP:"right-top",RIGHT_BOTTOM:"right-bottom",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",DRAWER:"drawer",ACTIONS:"actions",MODAL:"modal"}),N=Object.freeze({control:[R.BANNER,R.TOP_LEFT,R.TOP_RIGHT,R.MIDDLE,R.RIGHT_BOTTOM,R.BOTTOM_RIGHT,R.DRAWER,R.ACTIONS],panel:[R.SIDE,R.BANNER,R.LEFT_TOP,R.LEFT_BOTTOM,R.MIDDLE,R.RIGHT_TOP,R.RIGHT_BOTTOM,R.DRAWER,R.MODAL],button:[R.TOP_LEFT,R.TOP_MIDDLE,R.TOP_RIGHT,R.LEFT_TOP,R.LEFT_BOTTOM,R.RIGHT_TOP,R.RIGHT_BOTTOM,R.BOTTOM_LEFT,R.BOTTOM_RIGHT,R.ACTIONS]}),F=["mobile","tablet","desktop"];function B(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?B(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var U,Y,G=(0,l.q6)(null),H=e=>{var{options:t,children:r}=e,{pluginRegistry:n,buttonRegistry:o,panelRegistry:i,controlRegistry:a,eventBus:d,breakpointDetector:h}=t,g={appContainerRef:(0,l.li)(null),sideRef:(0,l.li)(null),mainRef:(0,l.li)(null),topRef:(0,l.li)(null),topLeftColRef:(0,l.li)(null),topRightColRef:(0,l.li)(null),leftRef:(0,l.li)(null),leftTopRef:(0,l.li)(null),leftBottomRef:(0,l.li)(null),middleRef:(0,l.li)(null),rightRef:(0,l.li)(null),rightTopRef:(0,l.li)(null),rightBottomRef:(0,l.li)(null),drawerRef:(0,l.li)(null),bottomRef:(0,l.li)(null),bottomRightRef:(0,l.li)(null),attributionsRef:(0,l.li)(null),actionsRef:(0,l.li)(null),bannerRef:(0,l.li)(null),modalRef:(0,l.li)(null),viewportRef:(0,l.li)(null)},v=(0,l.li)({}),[y,m]=(0,l.WO)(j,(e=>{var t,{initialBreakpoint:r,initialInterfaceType:n,appColorScheme:o,autoColorScheme:i,pluginRegistry:a,buttonRegistry:l,panelRegistry:c,controlRegistry:u,mode:d}=e,{preferredColorScheme:h,prefersReducedMotion:f}=k(),g=(0,s.g)(e),v=p(c.getPanelConfig(),r);return{appVisible:null,isLayoutReady:!1,arePluginsEvaluated:!1,breakpoint:r,interfaceType:n,preferredColorScheme:i?h:o,prefersReducedMotion:f,isFullscreen:g,mode:d||null,previousMode:null,safeZoneInset:null,disabledButtons:null!==(t=e.backAndContinue)&&void 0!==t&&t.continueLabel?new Set(["journeyContinue"]):new Set,hiddenButtons:new Set,pressedButtons:new Set,expandedButtons:new Set,hasExclusiveControl:!1,openPanels:v,previousOpenPanels:{},listboxIsActive:!1,syncMapPadding:!0,pluginRegistry:a,buttonRegistry:l,panelRegistry:c,controlRegistry:u,buttonConfig:l.getButtonConfig(),panelConfig:c.getPanelConfig(),controlConfig:u.getControlConfig()}})(t)),b=(0,l.hb)(e=>{var r=y.panelConfig||t.panelRegistry.getPanelConfig(),n=y;m(e),function(e,t,r,n){var{type:o,payload:i}=e;if("CLOSE_PANEL"===o&&queueMicrotask(()=>{n.emit(s.E.APP_PANEL_CLOSED,{panelId:i})}),"CLOSE_ALL_PANELS"===o&&queueMicrotask(()=>{Object.keys(t.openPanels).forEach(e=>{n.emit(s.E.APP_PANEL_CLOSED,{panelId:e})})}),"OPEN_PANEL"===o){var{panelId:a,props:l}=i,c=function(e,t,r,n){var o,i=null===(o=n[e])||void 0===o?void 0:o[r],a=!(null==i||!i.exclusive||null!=i&&i.modal),s=!(null==i||!i.modal),l=[];if(s)return l;var c=Object.keys(t);return a?c.forEach(e=>{var t,o=null===(t=n[e])||void 0===t?void 0:t[r];null!=o&&o.exclusive||l.push(e)}):c.forEach(e=>{var t,o=null===(t=n[e])||void 0===t?void 0:t[r];null==o||!o.exclusive||null!=o&&o.modal||l.push(e)}),l}(a,t.openPanels,t.breakpoint,r);queueMicrotask(()=>{c.forEach(e=>{n.emit(s.E.APP_PANEL_CLOSED,{panelId:e})}),n.emit(s.E.APP_PANEL_OPENED,{panelId:a,props:l})})}if("ADD_BUTTON"===o){var{id:u,config:d}=i,p=f(pe,d);F.forEach(e=>{var t,r=null===(t=p[e])||void 0===t?void 0:t.slot;r&&!N.button.includes(r)&&s.l.warn('button "'.concat(u,'" has invalid slot "').concat(r,'" at breakpoint "').concat(e,'". Allowed slots: ').concat(N.button.join(", "),"."))})}if("ADD_CONTROL"===o){var{id:h,config:g}=i,v=f(fe,g);F.forEach(e=>{var t,r=null===(t=v[e])||void 0===t?void 0:t.slot;r&&!N.control.includes(r)&&s.l.warn('control "'.concat(h,'" has invalid slot "').concat(r,'" at breakpoint "').concat(e,'". Allowed slots: ').concat(N.control.join(", "),"."))})}if("ADD_PANEL"===o){var{id:y,config:m}=i,b=f(he,m);F.forEach(e=>{var t,r=null===(t=b[e])||void 0===t?void 0:t.slot;!r||N.panel.includes(r)||r.endsWith("-button")||s.l.warn('panel "'.concat(y,'" has invalid slot "').concat(r,'" at breakpoint "').concat(e,'". Allowed slots: ').concat(N.panel.join(", "),"."))});var E=b[t.breakpoint];null!=E&&E.open&&queueMicrotask(()=>{var e=E.slot,{visibleGeometry:t}=b,r={panelId:y,slot:e};t&&(r.visibleGeometry=t),n.emit(s.E.APP_PANEL_OPENED,r)})}}(e,n,r,d)},[y,t,d]);!function(e,t){var{appColorScheme:r,autoColorScheme:n,behaviour:o,hybridWidth:i,maxMobileWidth:a}=t;(0,l.vJ)(()=>{var t=[window.matchMedia("(prefers-color-scheme: dark)"),window.matchMedia("(prefers-reduced-motion: reduce)")];function s(){var{preferredColorScheme:t,prefersReducedMotion:o}=k();e({type:"SET_MEDIA",payload:{preferredColorScheme:n?t:r,prefersReducedMotion:o}})}t.forEach(e=>e.addEventListener("change",s));var l=null,c=null;if("hybrid"===o){var u=null!=i?i:a;l=window.matchMedia("(max-width: ".concat(u,"px)")),c=t=>{e({type:"SET_HYBRID_FULLSCREEN",payload:t.matches})},l.addEventListener("change",c)}return()=>{t.forEach(e=>e.removeEventListener("change",s)),l&&c&&l.removeEventListener("change",c)}},[e,o,i,a])}(m,t);var E=e=>{b({type:"SET_MODE",payload:e})},P=()=>{b({type:"REVERT_MODE"})};(0,l.vJ)(()=>{d.on(s.E.APP_SET_MODE,E),d.on(s.E.APP_REVERT_MODE,P);var e=h.subscribe(e=>{b({type:"SET_BREAKPOINT",payload:{behaviour:t.behaviour,breakpoint:e,hybridWidth:t.hybridWidth,maxMobileWidth:t.maxMobileWidth}})}),r=(0,s.s)(e=>{b({type:"SET_INTERFACE_TYPE",payload:e})});return()=>{d.off(s.E.APP_SET_MODE,E),d.off(s.E.APP_REVERT_MODE,P),e(),r()}},[]);var O=(0,l.Kr)(()=>V(V({},y),{},{dispatch:b,layoutRefs:g,buttonRefs:v,pluginRegistry:n,buttonRegistry:o,panelRegistry:i,controlRegistry:a}),[y,b]);return(0,c.Y)(u.Provider,{value:t,children:(0,c.Y)(G.Provider,{value:O,children:r})})};function z(){return(0,l.NT)(G)}var W=/mac/i.test(null!==(U=null===(Y=navigator.userAgentData)||void 0===Y?void 0:Y.platform)&&void 0!==U?U:navigator.platform)?"<kbd>Option</kbd>":"<kbd>Alt</kbd>",J=[{id:"showKeyboardHelp",title:"Show keyboard help",command:"<kbd>Shift</kbd> + <kbd>?</kbd>",context:"global",enabled:!0},{id:"moveLarge",title:"Move in large steps",command:"<kbd>←</kbd>, <kbd>↑</kbd>, <kbd>→</kbd> or <kbd>↓</kbd>",enabled:!0},{id:"nudgeMap",title:"Nudge map",command:"<kbd>Shift</kbd> + <kbd>←</kbd>, <kbd>↑</kbd>, <kbd>→</kbd> or <kbd>↓</kbd>",enabled:!1},{id:"zoomLarge",title:"Zoom in large steps",command:"<kbd>+</kbd> or <kbd>-</kbd>",enabled:!0},{id:"nudgeZoom",title:"Nudge zoom",command:"<kbd>Shift</kbd> + <kbd>+</kbd> or <kbd>-</kbd>",enabled:!1},{id:"highlightLabelAtCenter",title:"Highlight label at centre",command:"".concat(W," + <kbd>Enter</kbd>"),enabled:!1,requiredConfig:["readMapText"]},{id:"highlightNextLabel",title:"Highlight nearby label",command:"".concat(W," + <kbd>→</kbd>, <kbd>←</kbd>, <kbd>↑</kbd> or <kbd>↓</kbd>"),enabled:!1,requiredConfig:["readMapText"]}],K=[],q=new Set,Z=new Set,X=e=>"im-c-tabs-tab-".concat(e.toLowerCase().replaceAll(/\s+/g,"-")),$=e=>"im-c-tabs-panel-".concat(e.toLowerCase().replaceAll(/\s+/g,"-")),Q=e=>{var t,{tabs:r,defaultTab:n}=e,o=r.map(e=>e.name),[i,a]=(0,l.J0)(null!=n?n:o[0]),s=(0,l.hb)(e=>{var t;a(e),null===(t=document.getElementById(X(e)))||void 0===t||t.focus()},[]),u=(0,l.hb)(e=>{var t=o.indexOf(i);"ArrowRight"===e.key?(e.preventDefault(),s(o[(t+1)%o.length])):"ArrowLeft"===e.key?(e.preventDefault(),s(o[(t-1+o.length)%o.length])):"Home"===e.key?(e.preventDefault(),s(o[0])):"End"===e.key&&(e.preventDefault(),s(o.at(-1)))},[o,i,s]),d=null===(t=r.find(e=>e.name===i))||void 0===t?void 0:t.content;return(0,c.FD)("div",{className:"im-c-tabs",children:[(0,c.Y)("div",{role:"tablist",className:"im-c-tabs__list",children:r.map(e=>{var{name:t}=e;return(0,c.Y)("button",{id:X(t),role:"tab","aria-selected":i===t,"aria-controls":$(t),tabIndex:i===t?0:-1,className:"im-c-tabs__tab",onClick:()=>s(t),onKeyDown:u,children:(0,c.Y)("span",{className:"im-c-tabs__label",children:t})},t)})}),(0,c.Y)("div",{id:$(i),role:"tabpanel","aria-labelledby":X(i),tabIndex:-1,className:"im-c-tabs__panel",children:d})]})},ee=e=>{var{items:t}=e;return(0,c.Y)("dl",{className:"im-c-keyboard-help__list",children:t.map(e=>(0,c.FD)("div",{className:"im-c-keyboard-help__item",children:[(0,c.Y)("dt",{className:"im-c-keyboard-help__title",children:e.title}),(0,c.Y)("dd",{className:"im-c-keyboard-help__description",dangerouslySetInnerHTML:{__html:e.command}})]},e.id))})},te=(e,t)=>{var r,n=e.find(e=>{var[,r]=e;return r.some(e=>{var r;return(null!==(r=e.context)&&void 0!==r?r:"viewport")===t})});if(n)return n[0];var o=e.find(e=>{var[,t]=e;return t.some(e=>"global"===e.context)});return null!==(r=null==o?void 0:o[0])&&void 0!==r?r:e[0][0]},re=e=>{var{context:t="viewport"}=e,r=d(),{listboxIsActive:n}=z(),o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[...J.filter(t=>!!Z.has(t.id)&&(!t.requiredConfig||t.requiredConfig.every(t=>e[t]))),...K]}(r),i=n?o:o.filter(e=>!e.group&&"listbox"!==e.context),a=(e=>e.reduce((e,t)=>{var r=t.group||"Navigate";return e[r]||(e[r]=[]),e[r].push(t),e},{}))(i),s=Object.entries(a);if(s.length<=1)return(0,c.Y)("div",{className:"im-c-keyboard-help",children:(0,c.Y)(ee,{items:i})});var l=s.map(e=>{var[t,r]=e;return{name:t,content:(0,c.Y)(ee,{items:r})}});return(0,c.Y)("div",{className:"im-c-keyboard-help",children:(0,c.Y)(Q,{tabs:l,defaultTab:te(s,t)})})};function ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function oe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ne(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ie={slot:"middle",open:!1,dismissible:!0,modal:!0},ae={slot:"right-top",showLabel:!1},se={slot:"top-left",showLabel:!1},le={slot:"actions",showLabel:!0},ce={slot:"actions",showLabel:!0,order:10},ue={buttons:[{id:"journeyBack",label:e=>{var t,{appConfig:r}=e;return null===(t=r.backAndContinue)||void 0===t?void 0:t.backLabel},variant:"tertiary",onClick:(e,t)=>{var{appConfig:r,services:n}=t;return"mapOnly"===r.behaviour?globalThis.history.back():n.closeApp()},excludeWhen:e=>{var t,{appConfig:r,appState:n}=e;return!(null!==(t=r.backAndContinue)&&void 0!==t&&t.backLabel)||!n.isFullscreen||"mapOnly"===r.behaviour&&globalThis.history.length<=1},mobile:le,tablet:le,desktop:le},{id:"journeyContinue",label:e=>{var t,{appConfig:r}=e;return null===(t=r.backAndContinue)||void 0===t?void 0:t.continueLabel},variant:"primary",onClick:(e,t)=>{var{services:r,pluginStates:n,mapState:o}=t;return r.eventBus.emit("app:continue",{pluginStates:n,mapState:o})},excludeWhen:e=>{var t,{appConfig:r,appState:n}=e;return!(null!==(t=r.backAndContinue)&&void 0!==t&&t.continueLabel&&n.isFullscreen)},mobile:ce,tablet:ce,desktop:ce},{id:"exit",label:"Exit",iconId:"close",onClick:(e,t)=>{var{services:r}=t;return r.closeApp()},excludeWhen:e=>{var{appConfig:t,appState:r}=e;return!t.hasExitButton||!r.isFullscreen},mobile:se,tablet:se,desktop:se},{id:"fullscreen",label:()=>"".concat(document.fullscreenElement?"Exit":"Enter"," fullscreen"),iconId:()=>document.fullscreenElement?"minimise":"maximise",onClick:(e,t)=>{var{appState:r}=t,n=r.layoutRefs.appContainerRef.current;document.fullscreenElement?document.exitFullscreen():n.requestFullscreen()},excludeWhen:e=>{var{appState:t,appConfig:r}=e;return!r.enableFullscreen||t.isFullscreen},mobile:ae,tablet:ae,desktop:ae},{id:"zoomIn",group:{name:"zoom",label:"Zoom controls",order:0},label:"Zoom in",iconId:"plus",keepFocus:!0,onClick:(e,t)=>{var{mapProvider:r,appConfig:n}=t;return r.zoomIn(n.zoomDelta)},excludeWhen:e=>{var{appState:t,appConfig:r}=e;return!r.enableZoomControls||"touch"===t.interfaceType},enableWhen:e=>{var{mapState:t}=e;return!t.isAtMaxZoom},mobile:ae,tablet:ae,desktop:ae},{id:"zoomOut",group:{name:"zoom",label:"Zoom controls",order:0},label:"Zoom out",iconId:"minus",keepFocus:!0,onClick:(e,t)=>{var{mapProvider:r,appConfig:n}=t;return r.zoomOut(n.zoomDelta)},excludeWhen:e=>{var{appState:t,appConfig:r}=e;return!r.enableZoomControls||"touch"===t.interfaceType},enableWhen:e=>{var{mapState:t}=e;return!t.isAtMinZoom},mobile:ae,tablet:ae,desktop:ae}],panels:[{id:"keyboardHelp",label:"Keyboard shortcuts",mobile:oe({},ie),tablet:oe(oe({},ie),{},{width:"500px"}),desktop:oe(oe({},ie),{},{width:"500px"}),render:e=>(0,c.Y)(re,{context:null==e?void 0:e.context})}],icons:[{id:"maximise",svgContent:'<path d="M15 3h6v6"/><path d="m21 3-7 7"/><path d="m3 21 7-7"/><path d="M9 21H3v-6"/>'},{id:"minimise",svgContent:'<path d="m14 10 7-7"/><path d="M20 10h-6V4"/><path d="m3 21 7-7"/><path d="M4 14h6v6"/>'},{id:"plus",svgContent:'<path d="M5 12h14"/><path d="M12 5v14"/>'},{id:"minus",svgContent:'<path d="M5 12h14"/>'},{id:"chevron",svgContent:'<path d="m6 9 6 6 6-6"/>'}]},de={slot:"right-top",showLabel:!0},pe={label:"Button",mobile:de,tablet:de,desktop:de},he={label:"Panel",focus:!0,mobile:{slot:"drawer",open:!0,dismissible:!0,modal:!1,showLabel:!0},tablet:{slot:"left-top",open:!0,dismissible:!0,modal:!1,showLabel:!0},desktop:{slot:"left-top",open:!0,dismissible:!0,modal:!1,showLabel:!0},render:null,html:null},fe={label:"Control",mobile:{slot:"drawer"},tablet:{slot:"top-left"},desktop:{slot:"top-left"}},ge={small:1,medium:1.5,large:2};function ve(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ye(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ve(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var me={close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>'},be=()=>me;function Ee(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Pe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ee(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ee(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Oe=e=>Array.isArray(e)?e:[e],Se=["mobile","tablet","desktop"];function we(e,t){var r=N[t];Se.forEach(n=>{var o,i=null===(o=e[n])||void 0===o?void 0:o.slot;!i||r.includes(i)||"panel"===t&&i.endsWith("-button")||s.l.warn("".concat(t,' "').concat(e.id,'" has invalid slot "').concat(i,'" at breakpoint "').concat(n,'". Allowed slots: ').concat(r.join(", "),"."))})}function _e(e){var{registerButton:t,registerPanel:r,registerControl:n}=e,o=[];return{registeredPlugins:o,registerPlugin:function(e){var i,a,{manifest:s}=e,l={pluginId:e.id,includeModes:null===(i=e.config)||void 0===i?void 0:i.includeModes,excludeModes:null===(a=e.config)||void 0===a?void 0:a.excludeModes};s.buttons&&Oe(s.buttons).forEach(e=>{var r;we(e,"button"),t({[e.id]:Pe(Pe({},l),e)}),null==e||null===(r=e.menuItems)||void 0===r||r.forEach(e=>{t({[e.id]:Pe(Pe(Pe({},l),e),{},{isMenuItem:!0})})})}),s.panels&&Oe(s.panels).forEach(e=>{we(e,"panel"),r({[e.id]:Pe(Pe({},l),e)})}),s.controls&&Oe(s.controls).forEach(e=>{we(e,"control"),n({[e.id]:Pe(Pe({},l),e)})}),s.icons&&Oe(s.icons).forEach(e=>(e=>{me=ye(ye({},me),e)})({[e.id]:e.svgContent})),s.keyboardShortcuts&&Oe(s.keyboardShortcuts).forEach(e=>(e=>{var{shortcut:t}=e;q.has(t.id)?K[K.findIndex(e=>e.id===t.id)]=t:(q.add(t.id),K.push(t))})(Pe(Pe({},l),{},{shortcut:e}))),o.push(e)},clear:function(){o.length=0}}}function Me(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function xe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Me(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Me(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ie(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];Array.isArray(e)||(e=[]),Array.isArray(t)||(t=[]);var r=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>{null!=e&&e.id&&(r.has(e.id)?r.set(e.id,xe(xe({},r.get(e.id)),e)):r.set(e.id,e))}),Array.from(r.values())},n=xe(xe({},e),t);return(e.buttons||t.buttons)&&(n.buttons=r(e.buttons,t.buttons)),(e.panels||t.panels)&&(n.panels=r(e.panels,t.panels)),(e.controls||t.controls)&&(n.controls=r(e.controls,t.controls)),(e.icons||t.icons)&&(n.icons=r(e.icons,t.icons)),n}function Ae(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Te(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ae(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ae(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Ce=(e,t)=>Te(Te({},e),t),Le={SET_MAP_READY:e=>Te(Te({},e),{},{isMapReady:!0}),MAP_MOVE:Ce,MAP_MOVE_END:Ce,MAP_FIRST_IDLE:Ce,SET_MAP_STYLE:(e,t)=>Te(Te({},e),{},{mapStyle:t}),SET_MAP_SIZE:(e,t)=>Te(Te({},e),{},{mapSize:t}),UPDATE_CROSS_HAIR:(e,t)=>Te(Te({},e),{},{crossHair:Te(Te({},e.crossHair),t)}),UPSERT_LOCATION_MARKER:(e,t)=>{var r=new Map(e.markers.items.map(e=>[e.id,e])),n=r.get(t.id)||{};r.set(t.id,Te(Te({},n),t));var o=Array.from(r.values());return Te(Te({},e),{},{markers:Te(Te({},e.markers),{},{items:o})})},REMOVE_LOCATION_MARKER:(e,t)=>{var r=e.markers.items.filter(e=>e.id!==t);return Te(Te({},e),{},{markers:Te(Te({},e.markers),{},{items:r})})}},De=(e,t)=>{var{type:r,payload:n}=t,o=Le[r];return o?o(e,n):e};function ke(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function je(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ke(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ke(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Re=(0,l.q6)(null),Ne=e=>{var{options:t,children:r}=e,[n,o]=(0,l.WO)(De,(e=>{var{center:t,zoom:r,bounds:n,extent:o,mapStyle:i,mapSize:a,markers:s}=e,{registeredPlugins:l}=e.pluginRegistry;return{isMapReady:!1,mapProvider:null,mapStyle:null!=l&&l.find(e=>{var t;return null===(t=e.config)||void 0===t?void 0:t.handlesMapStyle})?null:i,mapSize:a,center:t,zoom:r,bounds:n||o,resolution:null,isAtMaxZoom:null,isAtMinZoom:null,crossHair:{isVisible:!1,isPinnedToMap:!1,state:"active"},markers:{items:s||[]}}})(t)),{eventBus:i}=t,a=(0,l.li)(!1),u=()=>{o({type:"SET_MAP_READY"})},d=e=>{var r=localStorage.getItem("".concat(t.id,":mapStyleId")),n=e.find(e=>e.id===r)||e[0],i=localStorage.getItem("".concat(t.id,":mapSize"))||t.mapSize;o({type:"SET_MAP_STYLE",payload:n}),o({type:"SET_MAP_SIZE",payload:i})},p=e=>{o({type:"SET_MAP_STYLE",payload:e})},h=e=>{o({type:"SET_MAP_SIZE",payload:e})};(0,l.vJ)(()=>(i.on(s.E.MAP_READY,u),i.on(s.E.MAP_INIT_MAP_STYLES,d),i.on(s.E.MAP_SET_STYLE,p),i.on(s.E.MAP_SET_SIZE,h),()=>{i.off(s.E.MAP_READY,u),i.off(s.E.MAP_INIT_MAP_STYLES,d),i.off(s.E.MAP_SET_STYLE,p),i.off(s.E.MAP_SET_SIZE,h)}),[]),(0,l.vJ)(()=>{n.mapSize&&(a.current?i.emit(s.E.MAP_SIZE_CHANGE,{mapSize:n.mapSize}):a.current=!0)},[n.mapSize]),(0,l.vJ)(()=>{n.mapStyle&&n.mapSize&&(localStorage.setItem("".concat(t.id,":mapStyleId"),n.mapStyle.id),localStorage.setItem("".concat(t.id,":mapSize"),n.mapSize))},[n.mapStyle,n.mapSize]);var f=(0,l.Kr)(()=>je(je({},n),{},{dispatch:o}),[n]);return(0,c.Y)(Re.Provider,{value:f,children:r})},Fe=(e,t)=>{if(!e)return null;if("string"==typeof e)return e.trim();if("object"==typeof e){if(t&&e[t])return e[t];var r=Object.values(e)[0];return null!=r?r:null}return null},Be={symbol:"pin",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},Ve={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},Ue={id:"pin",viewBox:"0 0 44 44",anchor:[.5,.9],graphic:Ve.dot,svg:'<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},Ye={id:"circle",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:Ve.dot,svg:'<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},Ge={id:"square",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:Ve.dot,svg:'<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},He=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),ze=e=>!(!e.label||e.symbol||e.symbolSvgContent||null!==e.symbol&&null!==e.symbolSvgContent),We=e=>{if(!(e=>!(!e.symbol&&!e.symbolSvgContent))(e))return{};var t={};return He.forEach(r=>{if(null!=e[r]){var n=r.charAt(6).toLowerCase()+r.slice(7);t[n]=e[r]}}),t},Je={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}},Ke=e=>{var{haloColor:t,selectedColor:r,activeColor:n,foregroundColor:o}=(e=>{var t,r,n,o,i,a=null!==(t=Je[null==e?void 0:e.mapColorScheme])&&void 0!==t?t:Je.light;return{haloColor:null!==(r=null==e?void 0:e.haloColor)&&void 0!==r?r:a.haloColor,selectedColor:null!==(n=null==e?void 0:e.selectedColor)&&void 0!==n?n:a.selectedColor,activeColor:null!==(o=null==e?void 0:e.activeColor)&&void 0!==o?o:a.activeColor,foregroundColor:null!==(i=null==e?void 0:e.foregroundColor)&&void 0!==i?i:a.foregroundColor}})(e);return{"--map-overlay-halo-color":t,"--map-overlay-selected-color":r,"--map-overlay-active-color":n,"--map-overlay-foreground-color":o}};function qe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ze(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?qe(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qe(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Xe=new Map,$e=new Map,Qe={},et=e=>{var t=0;for(var r of e)t=Math.trunc((t<<5)-t+r.codePointAt(0));return Math.abs(t).toString(36)},tt=new Set(["id","svg","viewBox","anchor","symbol","symbolSvgContent"]);function rt(e,t,r){var n,o,i,a,s=null==r?void 0:r.id,l=Object.fromEntries(Object.entries(e||{}).filter(e=>{var[t]=e;return!tt.has(t)})),c=Object.fromEntries(Object.entries(Qe).filter(e=>{var[t]=e;return!tt.has(t)})),u=Object.fromEntries(Object.entries(t).filter(e=>{var[,t]=e;return null!=t})),d=Ze(Ze(Ze(Ze({},Be),c),l),u),p=null!==(n=Je[null==r?void 0:r.mapColorScheme])&&void 0!==n?n:Je.light;return d.haloColor=null!==(o=null==r?void 0:r.haloColor)&&void 0!==o?o:p.haloColor,d.selectedColor=null!==(i=null==r?void 0:r.selectedColor)&&void 0!==i?i:p.selectedColor,d.activeColor=null!==(a=null==r?void 0:r.activeColor)&&void 0!==a?a:p.activeColor,"string"==typeof d.graphic&&Ve[d.graphic]&&(d.graphic=Ve[d.graphic]),Object.fromEntries(Object.entries(d).map(e=>{var[t,r]=e;return[t,Fe(r,s)||""]}))}function nt(e,t){return Object.entries(t).reduce((e,t)=>{var[r,n]=t;return e.replaceAll("{{".concat(r,"}}"),n)},e)}var ot={setDefaults(e){Qe=e||{}},getDefaults:()=>Ze(Ze({},Be),Qe),register(e){Xe.set(e.id,e)},get:e=>Xe.get(e),list:()=>[...Xe.values()],clear(){Xe.clear()},initialise(){this.register(Ue),this.register(Ye),this.register(Ge)},resolve(e,t,r){var n=rt(e,t||{},r);return e?(n.selectedColor="none",n.activeColor="none",nt(e.svg,n)):""},resolveActive(e,t,r){var n=rt(e,t||{},r);return e?nt(e.svg,n):""},resolveSelected(e,t,r){var n=rt(e,t||{},r);return e?(n.activeColor="none",nt(e.svg,n)):""},getSymbolImageId(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,o=this.getSymbolDef(e);if(!o)return null;var i=We(e),a=r?this.resolveActive(o,i,t):this.resolve(o,i,t);return"symbol-".concat(r?"act-":"").concat(et(a),"-").concat(n,"x")},getSymbolDef(e){return e.symbolSvgContent?{svg:e.symbolSvgContent}:e.symbol?this.get(e.symbol):void 0},rasteriseSymbolImage(e,t,r,n){var o=this;return(0,i.A)(function*(){var i=o.getSymbolDef(e);if(!i)return null;var a,s,l=We(e);"active"===r?(a=o.resolveActive(i,l,t),s="act-"):"selected"===r?(a=o.resolveSelected(i,l,t),s="sel-"):(a=o.resolve(i,l,t),s="");var c="symbol-".concat(s).concat(et(a),"-").concat(n,"x"),u=$e.get(c);if(!u){var d=((e,t)=>{var r;return e.symbolViewBox?e.symbolViewBox:null!==(r=null==t?void 0:t.viewBox)&&void 0!==r?r:"0 0 38 38"})(e,i),[,,p,h]=d.split(" ").map(Number),f='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(p*n,'" height="').concat(h*n,'" viewBox="').concat(d,'">').concat(a,"</svg>");u=yield((e,t,r)=>new Promise((n,o)=>{var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(e)),a=new Image(t,r);a.onload=()=>{var e=document.createElement("canvas");e.width=t,e.height=r;var o=e.getContext("2d");o.drawImage(a,0,0,t,r),n(o.getImageData(0,0,t,r))},a.onerror=()=>{o(new Error("Failed to rasterise SVG: ".concat(e.slice(0,80))))},a.src=i}))(f,p*n,h*n),$e.set(c,u)}return{imageId:c,imageData:u}})()}};ot.initialise();var it={"cross-hatch":'<path d="M0 4.486V3.485h3.5V.001h1v3.484h7.002V.001h1v3.484h3.5v1.001h-3.5v7h3.5v.999h-3.5v3.516h-1v-3.516H4.499v3.516h-1v-3.516H0v-.999h3.5v-7H0zm11.501 0H4.499v7h7.002v-7z" fill="{{foregroundColor}}"/>',"diagonal-cross-hatch":'<path d="M0 8.707V7.293L7.293 0h1.414L16 7.293v1.414L8.707 16H7.293L0 8.707zM.707 8L8 15.293 15.293 8 8 .707.707 8z" fill="{{foregroundColor}}"/>',"forward-diagonal-hatch":'<path d="M16 8.707V7.293L7.293 16h1.414L16 8.707zm-16 0L8.707 0H7.293L0 7.293v1.414z" fill="{{foregroundColor}}"/>',"backward-diagonal-hatch":'<path d="M0 8.707V7.293L8.707 16H7.293L0 8.707zm16 0L7.293 0h1.414L16 7.293v1.414z" fill="{{foregroundColor}}"/>',"horizontal-hatch":'<path d="M0 4.5V3.499h15.999V4.5H0zm0 7h15.999V12.5H0v-1.001z" fill="{{foregroundColor}}"/>',"vertical-hatch":'<path d="M3.501 16.001V0h1v16.001h-1zm7.998 0V0h1v16.001h-1z" fill="{{foregroundColor}}"/>',dot:'<path d="M3.999 2A2 2 0 0 1 6 3.999C6 5.103 5.103 6 3.999 6a2 2 0 0 1-1.999-2.001A2 2 0 0 1 3.999 2zm0 7.999C5.103 10 6 10.897 6 12.001A2 2 0 0 1 3.999 14a2 2 0 0 1-1.999-1.999A2 2 0 0 1 3.999 10zM11.999 2A2 2 0 0 1 14 3.999C14 5.103 13.103 6 11.999 6S10 5.103 10 3.999A2 2 0 0 1 11.999 2zm0 7.999c1.104 0 2.001.897 2.001 2.001A2 2 0 0 1 11.999 14 2 2 0 0 1 10 12.001c0-1.104.897-2.001 1.999-2.001z" fill="{{foregroundColor}}"/>',diamond:'<path d="M4 .465L7.535 4 4 7.535.465 4 4 .465zm0 7.999l3.535 3.535L4 15.535.465 11.999 4 8.464zm8-8l3.535 3.535-3.536 3.536L8.464 4 12 .464zm0 8.001L15.536 12 12 15.536 8.465 12 12 8.465z" fill="{{foregroundColor}}"/>'},at=(e,t,r)=>e.replace(/\{\{foregroundColor\}\}/g,t||"black").replace(/\{\{backgroundColor\}\}/g,r),st=new Map,lt={register(e,t){st.set(e,{id:e,svgContent:t})},get:e=>st.get(e),list:()=>[...st.values()],clear(){st.clear()},initialise(){Object.entries(it).forEach(e=>{var[t,r]=e;this.register(t,r)})},getPatternInnerContent(e){return e.fillPatternSvgContent?e.fillPatternSvgContent:e.fillPattern&&null!==(t=null===(r=this.get(e.fillPattern))||void 0===r?void 0:r.svgContent)&&void 0!==t?t:null;var t,r},getKeyPatternPaths(e,t){var r=this.getPatternInnerContent(e);if(!r)return null;var n=Fe(e.fillPatternForegroundColor,t)||"black",o=Fe(e.fillPatternBackgroundColor,t)||"transparent",i=Fe(e.stroke,t)||n;return{border:at('<path d="M19 2.862v14.275c0 1.028-.835 1.862-1.862 1.862H2.863c-1.028 0-1.862-.835-1.862-1.862V2.862C1.001 1.834 1.836 1 2.863 1h14.275C18.166 1 19 1.835 19 2.862z" fill="{{backgroundColor}}" stroke="{{foregroundColor}}" stroke-width="2"/>',i,o),content:at(r,n,o)}},getPatternImageId(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=this.getPatternInnerContent(e);if(!n)return null;var o=Fe(e.fillPatternForegroundColor,t)||"black",i=Fe(e.fillPatternBackgroundColor,t)||"transparent",a=(e=>Math.max(2,2*e))(r);return"pattern-".concat((e=>{var t=0;for(var r of e)t=Math.trunc((t<<5)-t+r.codePointAt(0));return Math.abs(t).toString(36)})(n+o+i),"-").concat(a,"x")}};lt.initialise();var ct=(0,l.q6)(null),ut=e=>{var{eventBus:t,children:r}=e,{id:n,handleExitClick:o,symbolDefaults:i}=d(),a=(0,l.li)(null),u=(0,l.Kr)(()=>function(e){var t,r,n,o=!1,i=t=>{null!=e&&e.current&&t&&(e.current.textContent="",setTimeout(()=>{e.current&&(e.current.textContent=t)},100))},a=(t=i,r=null,n=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(()=>{t(...n)},500)},n.cancel=()=>{r&&(clearTimeout(r),r=null)},n);return function(e){if(e)return"plugin"===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"core")?(o=!0,void i(e)):void(o?o=!1:a(e))}}(a),[]),p=(0,l.Kr)(()=>function(e){var t=new Set,r=null,n=null,o=()=>t.forEach(e=>e(r)),i=()=>{n&&(clearTimeout(n),n=null)},a=()=>{i(),r=null,o()};return{show:function(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{duration:l=4e3,announce:c}=s;i(),r={html:t},o(),e(null!=c?c:(e=>e.replace(/<[^<>]*>/g,""))(t),"plugin"),l>0&&(n=setTimeout(a,l))},dismiss:a,subscribe:e=>(t.add(e),()=>t.delete(e))}}(u),[u]);ot.setDefaults(i||{});var h=(0,l.Kr)(()=>({announce:u,hints:p,reverseGeocode:(e,t)=>(0,s.r)(e,t),eventBus:t,mapStatusRef:a,closeApp:()=>function(e,t){t()}(0,o),symbolRegistry:ot,patternRegistry:lt}),[u,p]);return(0,c.Y)(ct.Provider,{value:h,children:r})};function dt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function pt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?dt(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ht=(0,l.q6)(null),ft=e=>{var{children:t}=e,{pluginRegistry:r}=d(),n={},o={},i=(0,l.li)({});r.registeredPlugins.forEach(e=>{var t=e.reducer;if(t){var{initialState:r,actions:a}=t;n[e.id]=function(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,n=null==e?void 0:e[null==r?void 0:r.type];return n?n(t,r.payload):t}}(a),o[e.id]=r}i.current[e.id]||(i.current[e.id]={})});var[a,s]=(0,l.WO)((e,t)=>{var{pluginId:r}=t;return r&&n[r]?pt(pt({},e),{},{[r]:n[r](e[r],t)}):e},o),u=(e,t)=>(i.current[e]||(i.current[e]={}),i.current[e][t]||(i.current[e][t]=l.Ay.createRef()),i.current[e][t]),p=(0,l.Kr)(()=>({state:a,dispatch:s,refs:i,getPluginRef:u}),[a,s]);return(0,c.Y)(ht.Provider,{value:p,children:t})},gt=e=>{var t=(0,l.NT)(ht);if(!t)throw new Error("usePlugin must be used within PluginProvider");var{state:r,dispatch:n,refs:o,getPluginRef:i}=t;return o.current[e]||(o.current[e]={}),pt(pt({},r[e]),{},{dispatch:t=>n(pt(pt({},t),{},{pluginId:e})),refs:o.current[e],useRef:t=>i(e,t)})};function vt(){return(0,l.NT)(Re)}function yt(){return(0,l.NT)(ct)}function mt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function bt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?mt(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Et=new Map;function Pt(e,t){var{pluginId:r,pluginConfig:n}=t,o=e;return Et.has(o)||Et.set(o,function(t){var o=d(),i=z(),a=vt(),s=yt(),u=gt(r);return(0,c.Y)(e,bt(bt({},t),{},{pluginConfig:n,pluginState:u,appConfig:o,appState:i,mapState:a,services:s,mapProvider:o.mapProvider,iconRegistry:be(),buttonConfig:(0,l.Kr)(()=>Object.fromEntries(Object.entries(i.buttonConfig).filter(e=>{var[t,n]=e;return n.pluginId===r})),[i.buttonConfig])}))}),Et.get(o)}function Ot(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function St(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ot(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ot(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function wt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _t(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Mt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function xt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Mt(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Mt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function It(){var e=d(),t=z(),r=vt(),n=yt(),o=(0,l.NT)(ht),i={appConfig:e,appState:t,mapState:r,services:n,mapProvider:null==e?void 0:e.mapProvider,iconRegistry:be()};function a(t,r){var n=xt(xt({},i),function(t){var r,n,i;if(!t)return{pluginStates:null!==(i=null==o?void 0:o.state)&&void 0!==i?i:{}};var a,s,l=e.pluginRegistry.registeredPlugins.find(e=>e.id===t),c=l?xt({pluginId:l.id},l.config):{};return Object.hasOwn(null!==(r=null==o?void 0:o.state)&&void 0!==r?r:{},t)?{pluginConfig:c,pluginState:xt(xt({},null!==(a=null==o||null===(s=o.state)||void 0===s?void 0:s[t])&&void 0!==a?a:{}),{},{dispatch:null==o?void 0:o.dispatch})}:{pluginConfig:c,pluginStates:null!==(n=null==o?void 0:o.state)&&void 0!==n?n:{}}}(r));return"function"==typeof t?t(n):t}return a.ctx=i,a}var At=["api"],Tt=e=>{var t,r,{plugin:n,mode:i}=e,a=function(e){var t=(0,l.li)(null),r=d(),n=z(),o=vt(),i=yt(),a=gt(e);return(0,l.vJ)(()=>{t.current={appConfig:r,appState:n,mapState:o,services:i,mapProvider:r.mapProvider,pluginState:a}}),t}(n.id);(0,l.vJ)(()=>{n.api&&n._originalPlugin&&Object.entries(n.api).forEach(e=>{var[t,r]=e;n._originalPlugin[t]=function(e,t){var{pluginId:r,pluginConfig:n,stateRef:o}=t;return function(){var t=o.current;if(!t)throw new Error('Plugin API "'.concat(r,'" called before state is initialized'));for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];return e(St(St({},t),{},{pluginConfig:n,pluginId:r}),...a)}}(r,{pluginId:n.id,pluginConfig:(null==n?void 0:n.config)||{},stateRef:a})})},[n,a]);var{InitComponent:s}=n,u=(null==n?void 0:n.config)||{},{api:p}=u,h=(0,o.A)(u,At),{includeModes:f,excludeModes:g}=n.config||{},v=null===(t=null==f?void 0:f.includes(i))||void 0===t||t,y=null!==(r=null==g?void 0:g.includes(i))&&void 0!==r&&r;if(!v||y||!s)return null;var m=Pt(s,{pluginId:n.id,pluginConfig:h});return(0,c.Y)(m,{})},Ct=()=>{var{mode:e}=z(),{pluginRegistry:t}=d();(()=>{var{dispatch:e,hiddenButtons:t,disabledButtons:r,pressedButtons:n,expandedButtons:o}=z(),{eventBus:i}=yt(),a=(0,l.li)(e),c=(0,l.li)({hiddenButtons:t,disabledButtons:r,pressedButtons:n,expandedButtons:o});a.current=e,c.current={hiddenButtons:t,disabledButtons:r,pressedButtons:n,expandedButtons:o},(0,l.vJ)(()=>{var e=e=>{var{id:t,config:r}=e;a.current({type:"ADD_BUTTON",payload:{id:t,config:r}}),Array.isArray(r.menuItems)&&r.menuItems.forEach(e=>{a.current({type:"ADD_BUTTON",payload:{id:e.id,config:_t(_t({},e),{},{isMenuItem:!0})}})})},t=e=>{var{id:t,prop:r,value:n}=e,{hiddenButtons:o,disabledButtons:i,pressedButtons:s,expandedButtons:l}=c.current;switch(r){case"hidden":var u="boolean"==typeof n?n:!o.has(t);a.current({type:"TOGGLE_BUTTON_HIDDEN",payload:{id:t,isHidden:u}});break;case"disabled":var d="boolean"==typeof n?n:!i.has(t);a.current({type:"TOGGLE_BUTTON_DISABLED",payload:{id:t,isDisabled:d}});break;case"pressed":var p="boolean"==typeof n?n:!s.has(t);a.current({type:"TOGGLE_BUTTON_PRESSED",payload:{id:t,isPressed:p}});break;case"expanded":var h="boolean"==typeof n?n:!l.has(t);a.current({type:"TOGGLE_BUTTON_EXPANDED",payload:{id:t,isExpanded:h}})}},r=()=>a.current({type:"TOGGLE_APP_VISIBLE",payload:!0}),n=()=>a.current({type:"TOGGLE_APP_VISIBLE",payload:!1}),o=e=>{var{id:t,config:r}=e;return a.current({type:"ADD_PANEL",payload:{id:t,config:r}})},l=e=>a.current({type:"REMOVE_PANEL",payload:e}),u=e=>{var{id:t,focus:r=!0}=e;return a.current({type:"OPEN_PANEL",payload:{panelId:t,focusOnOpen:r}})},d=e=>a.current({type:"CLOSE_PANEL",payload:e}),p=e=>{var{id:t,config:r}=e;return a.current({type:"ADD_CONTROL",payload:{id:t,config:r}})};return i.on(s.E.APP_OPENED,r),i.on(s.E.APP_CLOSED,n),i.on(s.E.APP_ADD_BUTTON,e),i.on(s.E.APP_TOGGLE_BUTTON_STATE,t),i.on(s.E.APP_ADD_PANEL,o),i.on(s.E.APP_REMOVE_PANEL,l),i.on(s.E.APP_SHOW_PANEL,u),i.on(s.E.APP_HIDE_PANEL,d),i.on(s.E.APP_ADD_CONTROL,p),()=>{i.off(s.E.APP_OPENED,r),i.off(s.E.APP_CLOSED,n),i.off(s.E.APP_ADD_BUTTON,e),i.off(s.E.APP_TOGGLE_BUTTON_STATE,t),i.off(s.E.APP_ADD_PANEL,o),i.off(s.E.APP_REMOVE_PANEL,l),i.off(s.E.APP_SHOW_PANEL,u),i.off(s.E.APP_HIDE_PANEL,d),i.off(s.E.APP_ADD_CONTROL,p)}},[i])})();var r=It();return function(e){var t=z(),{pluginRegistry:r}=d(),n=(0,l.NT)(ht);(0,l.Nf)(()=>{if(null!=t&&t.dispatch&&n){var{dispatch:o}=t,i=0,a=e=>{i++,o(e)};r.registeredPlugins.forEach(r=>{var n,o;(null!==(n=null==r||null===(o=r.manifest)||void 0===o?void 0:o.buttons)&&void 0!==n?n:[]).flatMap(e=>{var t;return[e,...null!==(t=e.menuItems)&&void 0!==t?t:[]]}).forEach(n=>function(e){var{btn:t,pluginId:r,appState:n,dispatch:o,evaluateProp:i}=e;[{prop:"enableWhen",state:n.disabledButtons,action:"TOGGLE_BUTTON_DISABLED",invert:!0,key:"isDisabled"},{prop:"hiddenWhen",state:n.hiddenButtons,action:"TOGGLE_BUTTON_HIDDEN",key:"isHidden"},{prop:"pressedWhen",state:n.pressedButtons,action:"TOGGLE_BUTTON_PRESSED",key:"isPressed"},{prop:"expandedWhen",state:n.expandedButtons,action:"TOGGLE_BUTTON_EXPANDED",key:"isExpanded"}].forEach(e=>{var{prop:n,state:a,action:s,key:l,invert:c}=e;if("function"==typeof t[n])try{var u=i(t[n],r),d=c?!u:u;a.has(t.id)!==d&&o({type:s,payload:{id:t.id,[l]:d}})}catch(e){console.warn("".concat(n," error for button ").concat(t.id,":"),e)}})}({btn:n,pluginId:r.id,appState:t,dispatch:a,evaluateProp:e}))}),0!==i||t.arePluginsEvaluated||o({type:"PLUGINS_EVALUATED"})}},[t,n,e])}(r),function(){var e,t=null===(e=d())||void 0===e?void 0:e.backAndContinue,{dispatch:r}=z(),n=vt(),o=(0,l.NT)(ht),i=(0,l.li)(!0);(0,l.Nf)(()=>{if("function"==typeof(null==t?void 0:t.continueEnabledWhen)){var e=!1;try{var a;e=t.continueEnabledWhen({pluginStates:null!==(a=null==o?void 0:o.state)&&void 0!==a?a:{},mapState:n})}catch(e){console.warn("continueEnabledWhen error:",e)}var s=!e;i.current!==s&&(i.current=s,r({type:"TOGGLE_BUTTON_DISABLED",payload:{id:"journeyContinue",isDisabled:s}}))}},[t,o,n,r])}(),(0,c.Y)(c.FK,{children:t.registeredPlugins.map((t,n)=>(0,c.Y)(Tt,{plugin:t,mode:e,evaluateProp:r},"init-".concat(t.id,"-").concat(n)))})},Lt=(e,t,r)=>{var n=e.find(e=>r.includes(e.id));return n?n.id:t&&e.some(e=>e.id===t)?t:e[0].id};function Dt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function kt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Dt(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Dt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var jt=e=>{if(null==e||!e.current)return{offsetWidth:0,offsetHeight:0};var t=e.current.firstElementChild;return null!=t&&t.classList.contains("im-c-panel")&&0!==t.offsetWidth&&0!==t.offsetHeight?{offsetWidth:t.offsetWidth,offsetHeight:t.offsetHeight}:{offsetWidth:0,offsetHeight:0}},Rt=e=>{var t,r=null==e||null===(t=e.current)||void 0===t?void 0:t.querySelector(".im-c-button-group");return r?r.offsetWidth:0},Nt=(e,t,r,n)=>{var o=t/n,i=e/r;return o>=.5&&i>=.5?o>=i?{colH:t,colW:e,rowW:0,rowH:0}:{colH:0,colW:0,rowW:e,rowH:t}:{colH:t,colW:e,rowW:e,rowH:t}},Ft=(e,t,r,n,o,i,a)=>{var s=Nt(e.offsetWidth,e.offsetHeight,r,n),l=Nt(t.offsetWidth,t.offsetHeight,r,n),c=0===t.offsetHeight&&0===s.colH,u=0===e.offsetHeight&&0===l.colH,d=e.offsetHeight+t.offsetHeight+(e.offsetHeight>0&&t.offsetHeight>0?a:0)>o&&!c&&!u;return{panelInset:d?i+Math.max(e.offsetWidth,t.offsetWidth)+a:0,rowA:d?{w:0,h:0}:{w:s.rowW,h:s.rowH},rowB:d?{w:0,h:0}:{w:l.rowW,h:l.rowH}}},Bt=(e,t,r,n,o,i,a)=>e+t>o?i+Math.max(r,n)+a:0,Vt=e=>{var{mainRef:t,leftRef:r,rightRef:n,actionsRef:o,bottomRef:i,leftTopRef:a,leftBottomRef:s,rightTopRef:l,rightBottomRef:c}=e;if(![t,r,n,o,i].some(e=>!(null!=e&&e.current))){var u=t.current,d=r.current,p=o.current,h=i.current,f=Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue("--divider-gap"),10),g=jt(a),v=jt(s),y=jt(l),m=jt(c),b=Math.max(Rt(r),Rt(n)),E=u.offsetLeft+d.offsetLeft+b+f,P=d.offsetLeft+b+f,O=d.offsetTop,S=u.offsetHeight-h.offsetTop-h.offsetHeight,w=Math.max(S,u.offsetHeight-h.offsetTop+f),_=Math.max(u.offsetHeight-p.offsetTop+f,w),M=u.offsetHeight-O-_,x=u.offsetWidth-(E-u.offsetLeft)-P,I=Ft(g,v,x,M,M/2,u.offsetLeft+d.offsetLeft,f),A=Ft(y,m,x,M,M/2,d.offsetLeft,f),T=I.panelInset,C=A.panelInset,L=Bt(I.rowA.w,A.rowA.w,I.rowA.h,A.rowA.h,x/2,O,f),D=Bt(I.rowB.w,A.rowB.w,I.rowB.h,A.rowB.h,x/2,w,f),k=u.offsetWidth-2*f,j=u.offsetHeight-2*f,R=u.offsetLeft+2*k/3,N=2*k/3,F=2*j/3;return{left:Math.max(E,Math.min(T,R)),right:Math.max(P,Math.min(C,N)),top:Math.max(O,Math.min(L,F)),bottom:Math.max(_,Math.min(D,F))}}},Ut=(e,t)=>Object.entries(e).reduce((e,r)=>{var[n,o]=r;return e[n]=Math.round(o/t),e},{}),Yt=e=>"Feature"===e.type?Yt(e.geometry):"Point"===e.type?e.coordinates:"MultiPoint"===e.type?e.coordinates[0]:null;function Gt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ht(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Gt(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Gt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var zt=e=>{var{mapContainerRef:t}=e,r=d(),{id:n,mapProvider:o}=r,{safeZoneInset:i,breakpoint:a,isLayoutReady:c,syncMapPadding:u}=z(),{isMapReady:p,mapStyle:h,mapSize:f,center:g,zoom:v,bounds:y}=vt(),m=(0,l.li)(!1),b=function(e){var{id:t,center:r,zoom:n,bounds:o,urlPosition:i="sync"}=e,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.search,s="none"===i?null:((e,t)=>{var r=new URLSearchParams(t),n=r.get("".concat(e,":center")),o=r.get("".concat(e,":zoom"));if(!n||!o)return null;var[i,a]=n.split(",").map(Number);return{center:[i,a],zoom:Number(o)}})(t,a);return s?{center:s.center,zoom:s.zoom}:o?{bounds:o}:{center:r,zoom:n}}({id:n,center:g,zoom:v,bounds:y,urlPosition:r.urlPosition});return(0,l.vJ)(()=>{if(i&&c&&h&&f&&!m.current)return requestAnimationFrame(()=>{o.initMap(Ht(Ht({},r),{},{pixelRatio:window.devicePixelRatio*ge[f],container:t.current,padding:i,center:b.center,zoom:b.zoom,bounds:b.bounds,mapStyle:h,mapSize:f}))}),m.current=!0,()=>{}},[i,c,h,f]),function(){var{mapProvider:e}=d(),{dispatch:t}=vt(),{eventBus:r}=yt(),n=(0,l.li)(null),o=(0,l.li)(!1);(0,l.vJ)(()=>{if(e){var i=e=>{t({type:"MAP_MOVE",payload:e})},a=e=>{t({type:"MAP_MOVE_END",payload:e}),r.emit(s.E.MAP_STATE_UPDATED,{previous:n.current,current:e}),n.current=e},l=r=>{o.current||(n.current={center:e.getCenter(),zoom:e.getZoom()},o.current=!0),t({type:"MAP_FIRST_IDLE",payload:r})};return r.on(s.E.MAP_MOVE,i),r.on(s.E.MAP_MOVE_END,a),r.on(s.E.MAP_FIRST_IDLE,l),()=>{r.off(s.E.MAP_MOVE,i),r.off(s.E.MAP_MOVE_END,a),r.off(s.E.MAP_FIRST_IDLE,l)}}},[e,t])}(),function(){var{id:e,urlPosition:t}=d(),{eventBus:r}=yt();(0,l.vJ)(()=>{if(e&&"sync"===t){var n=t=>{var{current:r}=t;!function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window.location.href,n=new URL(r||"http://localhost"),o=new Set,i=[];if(t.center){var a="".concat(e,":center");o.add(a),i.push("".concat(a,"=").concat(t.center[0],",").concat(t.center[1]))}if(null!=t.zoom){var s="".concat(e,":zoom");o.add(s),i.push("".concat(s,"=").concat(t.zoom))}var l=[];n.searchParams.forEach((e,t)=>{o.has(t)||l.push("".concat(t,"=").concat(e))});var c=[...l,...i].join("&"),u=c?"?"+c:"",d="".concat(n.origin).concat(n.pathname).concat(u).concat(n.hash);window.history.replaceState(window.history.state,"",d)}(e,{center:r.center,zoom:r.zoom})};return r.on(s.E.MAP_STATE_UPDATED,n),()=>r.off(s.E.MAP_STATE_UPDATED,n)}},[e,t])}(),function(){var{mapProvider:e}=d(),{eventBus:t,announce:r}=yt();(0,l.vJ)(()=>{var n=t=>{var{previous:n,current:o}=t;if(null!=n&&n.center&&null!=o&&o.center){var i=((e,t,r)=>{var n=e.zoom!==t.zoom,o=e.center[0]!==t.center[0]||e.center[1]!==t.center[1],i=r.getAreaDimensions();return o&&!n?(e=>{var{direction:t}=e;return"Map moved ".concat(t,".")})({direction:r.getCardinalMove(e.center,t.center),areaDimensions:i}):!o&&n?(e=>{var{from:t,to:r,areaDimensions:n,isAtMaxZoom:o,isAtMinZoom:i}=e;return"Map zoomed ".concat(r>t?"in":"out").concat(o?" (Maximum zoom)":"").concat(i?" (Minimum zoom)":"",". New area approximately ").concat(n,".")})(kt(kt({},t),{},{from:e.zoom,to:t.zoom,areaDimensions:i})):o||n?(e=>{var{areaDimensions:t,isAtMaxZoom:r,isAtMinZoom:n}=e;return"New area approximately ".concat(t).concat(r?" (Maximum zoom)":"").concat(n?" (Minimum zoom)":"",".")})(kt(kt({},t),{},{areaDimensions:i})):(e=>{var{isAtMaxZoom:t,isAtMinZoom:r}=e;return"No change, ".concat(t?"maximum zoom reached":"").concat(r?"minimum zoom reached":"",".")})(kt({},t))})(n,o,e);i&&r(i,"core")}};return t.on(s.E.MAP_STATE_UPDATED,n),()=>{t.off(s.E.MAP_STATE_UPDATED,n)}},[e,r])}(),(()=>{var{mapProvider:e,eventBus:t}=d(),{dispatch:r,layoutRefs:n}=z(),{mapSize:o}=vt(),i=(0,l.li)(o);i.current=o;var a=()=>{var t=Vt(n),o=Ut(t,ge[i.current]);"function"==typeof r&&r({type:"SET_SAFE_ZONE_INSET",payload:{safeZoneInset:t,syncMapPadding:!1}}),"function"==typeof e.setPadding&&e.setPadding(o)};(0,l.vJ)(()=>{if(e){var t=e.fitToBounds;e.fitToBounds=function(r){if(r)return arguments.length>1&&void 0!==arguments[1]&&arguments[1]||a(),t.call(e,r)};var r=e.setView;return e.setView=t=>{var{center:n,zoom:o}=t;if(n)return a(),r.call(e,{center:n,zoom:o})},()=>{e.fitToBounds=t,e.setView=r}}},[e,r,n,o]),(0,l.vJ)(()=>{if(e&&t){var r=t=>e.fitToBounds(t),n=t=>e.setView(t);return t.on(s.E.MAP_FIT_TO_BOUNDS,r),t.on(s.E.MAP_SET_VIEW,n),()=>{t.off(s.E.MAP_FIT_TO_BOUNDS,r),t.off(s.E.MAP_SET_VIEW,n)}}},[e,t])})(),(()=>{var{id:e,mapProvider:t,eventBus:r}=d(),{layoutRefs:n,panelConfig:o,panelRegistry:i,breakpoint:a}=z(),c=(0,l.li)({layoutRefs:n,panelConfig:o,panelRegistry:i,breakpoint:a});c.current={layoutRefs:n,panelConfig:o,panelRegistry:i,breakpoint:a},(0,l.vJ)(()=>{if(t&&r){var o=r=>{var o,i,a,{panelId:s,visibleGeometry:l}=r,{panelConfig:u,panelRegistry:d}=c.current,p=null!=u&&u[s]?u:null!==(o=null==d?void 0:d.getPanelConfig())&&void 0!==o?o:u,h=null!=l?l:null==p||null===(i=p[s])||void 0===i?void 0:i.visibleGeometry,f=null===(a=n.appContainerRef.current)||void 0===a?void 0:a.querySelector("#".concat(e,"-panel-").concat(s));if(h&&"function"==typeof t.isGeometryObscured){var g=()=>{if(f){var e,r=f.getBoundingClientRect();if(r&&0!==r.width&&0!==r.height){if(t.isGeometryObscured(h,r))if("Point"===(e=(o=h)?"Feature"===o.type?null===(i=o.geometry)||void 0===i?void 0:i.type:o.type:null)||"MultiPoint"===e){var n=Yt(h);n&&t.setView({center:n})}else t.fitToBounds(h)}else requestAnimationFrame(g)}var o,i};requestAnimationFrame(g)}};return r.on(s.E.APP_PANEL_OPENED,o),()=>{r.off(s.E.APP_PANEL_OPENED,o)}}},[t,r])})(),(0,l.vJ)(()=>{p&&u&&o.setPadding(Ut(i,ge[f]))},[p,f,a,i]),null},Wt={keydown:{ArrowUp:"panUp",ArrowDown:"panDown",ArrowLeft:"panLeft",ArrowRight:"panRight","+":"zoomIn","=":"zoomIn","-":"zoomOut",_:"zoomOut"},keyup:{"?":"showKeyboardControls","Alt+ArrowRight":"highlightNextLabel","Alt+ArrowLeft":"highlightNextLabel","Alt+ArrowUp":"highlightNextLabel","Alt+ArrowDown":"highlightNextLabel","Alt+Enter":"highlightLabelAtCenter","Alt+i":"getInfo","Alt+I":"getInfo",Escape:"clearSelection"}},Jt=(e,t,r)=>{var n,{containerRef:o,dispatch:a,panDelta:l,nudgePanDelta:c,zoomDelta:u,nudgeZoomDelta:d,readMapText:p}=r,h=e=>e?c:l,f=e=>e?d:u;return{showKeyboardControls:e=>{var t=e.target===o.current?"viewport":"listbox";a({type:"OPEN_PANEL",payload:{panelId:"keyboardHelp",props:{triggeringElement:e.target,context:t}}})},panUp:t=>e.panBy([0,-h(t.shiftKey)]),panDown:t=>e.panBy([0,h(t.shiftKey)]),panLeft:t=>e.panBy([-h(t.shiftKey),0]),panRight:t=>e.panBy([h(t.shiftKey),0]),zoomIn:t=>e.zoomIn(f(t.shiftKey)),zoomOut:t=>e.zoomOut(f(t.shiftKey)),getInfo:(n=(0,i.A)(function*(r){var n;if((0,s.h)()){var o=e.getCenter(),i=yield(0,s.r)(e.getZoom(),o),a=null===(n=e.getAreaDimensions)||void 0===n?void 0:n.call(e),l=a?"".concat(i,". Covering ").concat(a,"."):"".concat(i,".");t(l,"core")}else s.l.warn("Alt+I pressed but reverseGeocode has not been configured")}),function(e){return n.apply(this,arguments)}),highlightNextLabel:r=>{if(p&&e.highlightNextLabel){var n=e.highlightNextLabel(r.key);t(n,"core")}},highlightLabelAtCenter:()=>{if(p&&e.highlightLabelAtCenter){var r=e.highlightLabelAtCenter();t(r,"core")}},clearSelection:()=>{var t;return null==e||null===(t=e.clearHighlightedLabel)||void 0===t?void 0:t.call(e)}}},Kt=()=>{var{mapStatusRef:e}=yt();return(0,c.Y)("div",{ref:e,role:"status",className:"im-c-viewport__status"})},qt={active:"M5.035 20H1v-2h4.035C5.525 11.069 11.069 5.525 18 5.035V1h2v4.035c6.931.49 12.475 6.034 12.965 12.965H37v2h-4.035c-.49 6.931-6.034 12.475-12.965 12.965V37h-2v-4.035C11.069 32.475 5.525 26.931 5.035 20zM19 7c-6.581.005-11.995 5.419-12 12 .005 6.581 5.419 11.995 12 12 6.581-.005 11.995-5.419 12-12-.005-6.581-5.419-11.995-12-12zm0 10a2.01 2.01 0 0 1 2 2 2.01 2.01 0 0 1-2 2 2.01 2.01 0 0 1-2-2 2.01 2.01 0 0 1 2-2z",inactive:"M5.035 20H1v-2h4.035a13.98 13.98 0 0 1 .246-1.8l1.96.399C7.083 17.375 7 18.178 7 19s.083 1.625.241 2.401l-1.96.399a13.98 13.98 0 0 1-.246-1.8zM20 5.035a13.98 13.98 0 0 1 1.8.246l-.399 1.96C20.625 7.083 19.822 7 19 7s-1.625.083-2.401.241l-.399-1.96a13.98 13.98 0 0 1 1.8-.246V1h2v4.035zm-2 27.93a13.98 13.98 0 0 1-1.8-.246l.399-1.96c.776.158 1.579.241 2.401.241s1.625-.083 2.401-.241l.399 1.96a13.98 13.98 0 0 1-1.8.246V37h-2v-4.035zM32.965 20a13.98 13.98 0 0 1-.246 1.8l-1.96-.399c.158-.776.241-1.579.241-2.401s-.083-1.625-.241-2.401l1.96-.399a13.98 13.98 0 0 1 .246 1.8H37v2h-4.035zM19 17a2.01 2.01 0 0 1 2 2 2.01 2.01 0 0 1-2 2 2.01 2.01 0 0 1-2-2 2.01 2.01 0 0 1 2-2zm3.8-9.385l.634-1.897c1.789.598 3.438 1.553 4.848 2.805l-1.327 1.496c-1.196-1.06-2.605-1.886-4.155-2.404zm5.181 3.43l1.496-1.327c1.252 1.41 2.207 3.059 2.805 4.848l-1.897.634c-.518-1.55-1.344-2.959-2.404-4.155zM30.385 22.8l1.897.634c-.598 1.789-1.553 3.438-2.805 4.848l-1.496-1.327c1.06-1.196 1.886-2.605 2.404-4.155zm-3.43 5.181l1.327 1.496c-1.41 1.252-3.059 2.207-4.848 2.805l-.634-1.897c1.55-.518 2.959-1.344 4.155-2.404zM15.2 30.385l-.634 1.897c-1.789-.598-3.438-1.553-4.848-2.805l1.327-1.496c1.196 1.06 2.605 1.886 4.155 2.404zm-5.181-3.43l-1.496 1.327c-1.252-1.41-2.207-3.059-2.805-4.848l1.897-.634c.518 1.55 1.344 2.959 2.404 4.155zM7.615 15.2l-1.897-.634c.598-1.789 1.553-3.438 2.805-4.848l1.496 1.327c-1.06 1.196-1.886 2.605-2.404 4.155zm3.43-5.181L9.718 8.523c1.41-1.252 3.059-2.207 4.848-2.805l.634 1.897c-1.55.518-2.959 1.344-4.155 2.404z"},Zt=()=>{var{id:e}=d(),{crossHairRef:t,crossHair:r}=(()=>{var{mapProvider:e}=d(),{safeZoneInset:t}=z(),{eventBus:r}=yt(),{crossHair:n,dispatch:o,mapSize:i}=vt(),a=(e,r,n)=>{if(t){var o=r*ge[i],a=n*ge[i];e.style.transform="translate(".concat(o-t.left,"px, ").concat(a-t.top,"px)"),e.style.left="0",e.style.top="0",e.style.display="block"}},c=(0,l.hb)(t=>{if(t){((e,t,r,n,o)=>{e.pinToMap=(i,a)=>{var{x:s,y:l}=r.mapToScreen(i);e.coords=i,n({type:"UPDATE_CROSS_HAIR",payload:{isPinnedToMap:!0,isVisible:!0,coords:i,state:a}}),o(t,s,l)},e.fixAtCenter=()=>{t.style.left="50%",t.style.top="50%",t.style.transform="translate(0,0)",t.style.display="block",n({type:"UPDATE_CROSS_HAIR",payload:{isPinnedToMap:!1,isVisible:!0}})},e.remove=()=>{t.style.display="none",n({type:"UPDATE_CROSS_HAIR",payload:{isPinnedToMap:!1,isVisible:!1}})},e.show=()=>{t.style.display="block",n({type:"UPDATE_CROSS_HAIR",payload:{isVisible:!0}})},e.hide=()=>{t.style.display="none",n({type:"UPDATE_CROSS_HAIR",payload:{isVisible:!1}})},e.setStyle=e=>{n({type:"UPDATE_CROSS_HAIR",payload:{state:e}})},e.getDetail=()=>{var t=e.isPinnedToMap?e.coords:r.getCenter();return{state:e.state,point:r.mapToScreen(t),zoom:r.getZoom(),coords:t}}})(n,t,e,o,a);var i=()=>{if(n.coords&&n.isPinnedToMap){var{x:r,y:o}=e.mapToScreen(n.coords);a(t,r,o)}};return r.on(s.E.MAP_RENDER,i),()=>{r.off(s.E.MAP_RENDER,i)}}},[n,e,i,o,t]);return(0,l.vJ)(()=>{n.coords&&n.isPinnedToMap&&n.pinToMap(n.coords,n.state)},[i]),{crossHair:n,crossHairRef:c}})(),{isVisible:n,isPinnedToMap:o,state:i}=r;return(0,c.Y)("svg",{id:"".concat(e,"-cross-hair"),ref:t,className:"im-c-cross-hair",width:"38",height:"38",viewBox:"0 0 38 38",fillRule:"evenodd",fill:"currentColor",style:{position:"absolute",left:o?0:"50%",top:o?0:"50%",pointerEvents:"none",display:n?"block":"none"},children:(0,c.Y)("path",{d:qt[i||"active"]})})},Xt=(0,l.Rf)((e,t)=>{var{activeFeatureId:r,selectedIds:n=[],multiselectable:o=!1,items:i=[],onFocus:a,onBlur:s}=e,{id:l}=d(),u=i.length>0;return(0,c.Y)("ul",{id:"".concat(l,"-features"),ref:t,role:"listbox",tabIndex:u?"0":"-1","aria-hidden":!u||void 0,"aria-label":"Map features","aria-describedby":"".concat(l,"-keyboard-desc"),"aria-multiselectable":o||void 0,"aria-activedescendant":r?"".concat(l,"-feature-").concat(r):void 0,className:"im-c-features",onFocus:a,onBlur:s,children:i.map(e=>(0,c.Y)("li",{id:"".concat(l,"-feature-").concat(e.id),role:"option","data-id":e.id,"aria-selected":n.includes(e.id),children:e.label},e.id))})});Xt.displayName="Features";var $t=["coords"];function Qt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function er(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Qt(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Qt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var tr=(e,t,r,n)=>{if(!t||!n)return{x:0,y:0};var{x:o,y:i}=t.mapToScreen(e);return{x:o*ge[r],y:i*ge[r]}},rr=(e,t,r,n,o)=>{e.forEach(e=>{var i=t.get(e.id);if(i&&e.coords){var{x:a,y:s}=tr(e.coords,r,n,o);i.style.transform="translate(".concat(a,"px, ").concat(s,"px)"),i.style.display="block"}})},nr=e=>{var{marker:t,mapId:r,markerRef:n}=e;return(0,c.Y)("div",{ref:n(t.id),id:"".concat(r,"-marker-").concat(t.id),className:"im-c-marker-wrapper im-c-marker-wrapper--label",style:{display:t.isVisible?"block":"none"},children:(0,c.Y)("div",{role:"note",className:"im-c-marker__label im-c-marker__label--standalone",children:t.label})})};function or(e){return null==e?void 0:e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}var ir=e=>{var{marker:t,mapId:r,markerRef:n,isSelected:o,symbolProps:i}=e,{resolvedSvg:a,viewBox:s,anchor:l,shapeId:u,scaledWidth:d,scaledHeight:p}=i;return(0,c.FD)("div",{ref:n(t.id),id:"".concat(r,"-marker-").concat(t.id),className:["im-c-marker-wrapper","im-c-marker-wrapper--".concat(or(u)),o&&"im-c-marker-wrapper--selected"].filter(Boolean).join(" "),style:{display:t.isVisible?"block":"none",marginLeft:"".concat(-l[0]*d,"px"),marginTop:"".concat(-l[1]*p,"px"),width:"".concat(d,"px"),height:"".concat(p,"px")},children:[(0,c.Y)("svg",{className:["im-c-marker__svg","im-c-marker--".concat(or(u)),o&&"im-c-marker--selected"].filter(Boolean).join(" "),width:d,height:p,viewBox:s,overflow:"visible","aria-hidden":"true",children:(0,c.Y)("g",{dangerouslySetInnerHTML:{__html:a}})}),(0,c.Y)("div",{role:"note",className:"im-c-marker__label",children:t.label})]})},ar=e=>{var{marker:t,mapId:r,markerRef:n,isSelected:o,symbolProps:i}=e,{resolvedSvg:a,viewBox:s,anchor:l,shapeId:u,scaledWidth:d,scaledHeight:p}=i;return(0,c.Y)("svg",{ref:n(t.id),id:"".concat(r,"-marker-").concat(t.id),className:["im-c-marker","im-c-marker--".concat(or(u)),o&&"im-c-marker--selected"].filter(Boolean).join(" "),width:d,height:p,viewBox:s,overflow:"visible",role:"img","aria-label":t.label||"Map marker",style:{display:t.isVisible?"block":"none",marginLeft:"".concat(-l[0]*d,"px"),marginTop:"".concat(-l[1]*p,"px")},children:(0,c.Y)("g",{dangerouslySetInnerHTML:{__html:a}})})},sr=new Set(["id","coords","x","y","isVisible","symbol","symbolSvgContent","viewBox","anchor","selectedColor","label","showLabel"]),lr=()=>{var{id:e}=d(),{mapStyle:t,mapSize:r}=vt(),{markers:n,markerRef:i}=(()=>{var{mapProvider:e}=d(),{eventBus:t}=yt(),{markers:r,dispatch:n,mapSize:i,isMapReady:a}=vt(),c=(0,l.li)(new Map),u=(0,l.li)(r);(0,l.Nf)(()=>{e&&(u.current=r,r.markerRefs=c.current,r.add=(t,r,o)=>{var{x:s,y:l}=tr(r,e,i,a);n({type:"UPSERT_LOCATION_MARKER",payload:er(er({id:t,coords:r},o),{},{x:s,y:l,isVisible:!0})})},r.update=function(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=r.items.find(e=>e.id===t);if(l){var{coords:c}=s,u=(0,o.A)(s,$t),d=null!=c?c:l.coords,{x:p,y:h}=tr(d,e,i,a);n({type:"UPSERT_LOCATION_MARKER",payload:er(er({id:t,coords:d},u),{},{x:p,y:h})})}},r.remove=e=>{n({type:"REMOVE_LOCATION_MARKER",payload:e})},r.getMarker=e=>r.items.find(t=>t.id===e))},[e,r,n,i]);var p=(0,l.hb)(n=>o=>{if(o){c.current.set(n,o);var l=()=>{a&&e&&rr(r.items,c.current,e,i,a)};return t.on(s.E.MAP_RENDER,l),()=>{t.off(s.E.MAP_RENDER,l)}}c.current.delete(n)},[r,e,a,i]);return(0,l.vJ)(()=>{a&&e&&rr(r.items,c.current,e,i,a)},[i,r.items,e,a]),((e,t)=>{(0,l.vJ)(()=>{var r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(null!=e&&e.id&&null!=e&&e.coords){var{id:r,coords:n,options:o}=e;t.current.add(r,n,o)}};e.on(s.E.APP_ADD_MARKER,r);var n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(null!=e&&e.id){var{id:r,options:n}=e;t.current.update(r,n)}};e.on(s.E.APP_UPDATE_MARKER,n);var o=e=>{e&&t.current.remove(e)};return e.on(s.E.APP_REMOVE_MARKER,o),()=>{e.off(s.E.APP_ADD_MARKER,r),e.off(s.E.APP_UPDATE_MARKER,n),e.off(s.E.APP_REMOVE_MARKER,o)}},[])})(t,u),{markers:r,markerRef:p}})(),{symbolRegistry:a,eventBus:u}=yt(),[p,h]=(0,l.J0)(!1),[f,g]=(0,l.J0)([]),[v,y]=(0,l.J0)(null),m=(0,l.li)(null);if((0,l.vJ)(()=>{var e=e=>{var{active:t,interactionModes:r=[]}=e;return h(t&&r.includes("selectMarker"))},t=e=>{var{selectedMarkers:t=[]}=e;return g(t)},r=e=>{var{id:t}=e;return y(t)};return u.on("interact:active",e),u.on("interact:selectionchange",t),u.on(s.E.MAP_SET_ACTIVE_FEATURE,r),()=>{u.off("interact:active",e),u.off("interact:selectionchange",t),u.off(s.E.MAP_SET_ACTIVE_FEATURE,r)}},[u]),(0,l.vJ)(()=>{m.current=document.querySelector(".im-c-viewport")},[]),((e,t,r)=>{(0,l.vJ)(()=>{if(t){var n=r.current;if(n){var o=t=>{var r=e.items.some(r=>{var n;if(ze(r))return!1;var o=null===(n=e.markerRefs)||void 0===n?void 0:n.get(r.id);if(!o)return!1;var{left:i,top:a,right:s,bottom:l}=o.getBoundingClientRect();return t.clientX>=i&&t.clientX<=s&&t.clientY>=a&&t.clientY<=l});n.style.cursor=r?"pointer":""};return n.addEventListener("mousemove",o),()=>{n.removeEventListener("mousemove",o),n.style.cursor=""}}}},[e,t,r])})(n,p,m),t){var b=a.getDefaults();return(0,c.Y)(c.FK,{children:n.items.map(n=>{var o=f.includes(n.id),s=n.id===v;if(ze(n))return(0,c.Y)(nr,{marker:n,mapId:e,markerRef:i},n.id);var l=((e,t,r,n,o,i,a)=>{var s,l,c=((e,t,r)=>{var n=e.symbolSvgContent||t.symbolSvgContent;return n?{svg:n}:r.get(e.symbol||t.symbol)})(e,t,r),u=Object.fromEntries(Object.entries(e).filter(e=>{var[t]=e;return!sr.has(t)}));l=a?r.resolveActive(c,u,n):i?r.resolveSelected(c,u,n):r.resolve(c,u,n);var d=((e,t,r)=>e.viewBox||t.viewBox||(null==r?void 0:r.viewBox)||"0 0 44 44")(e,t,c),[,,p,h]=d.split(" ").map(Number),f=((e,t,r)=>{var n,o,i;return null!==(n=null!==(o=null!==(i=e.anchor)&&void 0!==i?i:t.anchor)&&void 0!==o?o:null==r?void 0:r.anchor)&&void 0!==n?n:[.5,.5]})(e,t,c),g=e.symbol||t.symbol,v=null!==(s=ge[o])&&void 0!==s?s:1;return{resolvedSvg:l,viewBox:d,anchor:f,shapeId:g,scaledWidth:p*v,scaledHeight:h*v}})(n,b,a,t,r,o,s);return n.showLabel&&n.label?(0,c.Y)(ir,{marker:n,mapId:e,markerRef:i,isSelected:o,symbolProps:l},n.id):(0,c.Y)(ar,{marker:n,mapId:e,markerRef:i,isSelected:o,symbolProps:l},n.id)})})}},cr=()=>{var{id:e,mapProvider:t,mapLabel:r,keyboardHintText:n}=d(),{mode:o,previousMode:i,layoutRefs:a,safeZoneInset:u,dispatch:p}=z(),{mapSize:h}=vt(),{eventBus:f,hints:g}=yt(),v=(0,l.li)(null),y=(0,l.li)(null),{items:m,multiselectable:b}=function(e){var[t,r]=(0,l.J0)([]),[n,o]=(0,l.J0)(!1);return(0,l.vJ)(()=>{if(e){var t=e=>{var{items:t=[],multiselectable:n=!1}=e;r(t),o(n)};return e.on("map:setfeatures",t),()=>{e.off("map:setfeatures",t)}}},[e]),{items:t,multiselectable:n}}(f),{activeFeatureId:E,selectedIds:P,onFocus:O,onBlur:S}=function(e){var{viewportRef:t,featuresRef:r,items:n=[],eventBus:o,hints:i}=e,[a,c]=(0,l.J0)(null),[u,d]=(0,l.J0)([]),p=(0,l.li)(!1),h=(0,l.li)(null),f=(0,l.li)(null),g=(0,l.li)([]),v=(0,l.li)(null);return(0,l.vJ)(()=>i.subscribe(e=>{v.current=e}),[i]),(0,l.vJ)(()=>{f.current=a},[a]),(0,l.vJ)(()=>{g.current=u},[u]),function(e){var{eventBus:t,lastActiveIdRef:r,setActiveFeatureId:n,setSelectedIds:o}=e;(0,l.vJ)(()=>{if(t){var e=e=>{var{id:t}=e;null!==t&&(r.current=t),n(t)},i=e=>{var{selectedFeatures:t=[],selectedMarkers:r=[]}=e;o([...t.map(e=>String(e.featureId)),...r])};return t.on(s.E.MAP_SET_ACTIVE_FEATURE,e),t.on("interact:selectionchange",i),()=>{t.off(s.E.MAP_SET_ACTIVE_FEATURE,e),t.off("interact:selectionchange",i)}}},[t])}({eventBus:o,lastActiveIdRef:h,setActiveFeatureId:c,setSelectedIds:d}),function(e){var{items:t,eventBus:r,isFocusedRef:n,lastActiveIdRef:o,activeFeatureIdRef:i,selectedIdsRef:a,setActiveFeatureId:c}=e;(0,l.vJ)(()=>{if(n.current){if(!t.length)return c(null),void(null==r||r.emit(s.E.MAP_SET_ACTIVE_FEATURE,{id:null}));if(!t.some(e=>e.id===i.current)){var e=Lt(t,o.current,a.current);o.current=e,c(e),null==r||r.emit(s.E.MAP_SET_ACTIVE_FEATURE,{id:e})}}},[t])}({items:n,eventBus:o,isFocusedRef:p,lastActiveIdRef:h,activeFeatureIdRef:f,selectedIdsRef:g,setActiveFeatureId:c}),function(e){var{featuresRef:t,viewportRef:r,items:n,eventBus:o,activeFeatureIdRef:i,lastActiveIdRef:a,setActiveFeatureId:c,hints:u,currentHintRef:d}=e;(0,l.vJ)(()=>{var e=t.current;if(e){var l=e=>{var t;if("Escape"===e.key)e.preventDefault(),e.stopPropagation(),d.current?u.dismiss():null===(t=r.current)||void 0===t||t.focus();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();var l=((e,t,r)=>{if(!r.length)return e;var n=r.findIndex(t=>t.id===e);return"ArrowDown"===t?-1===n?r[0].id:r[Math.min(n+1,r.length-1)].id:-1===n?r[r.length-1].id:r[Math.max(n-1,0)].id})(i.current,e.key,n);a.current=l,c(l),null==o||o.emit(s.E.MAP_SET_ACTIVE_FEATURE,{id:l})}else"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),null==o||o.emit(s.E.MAP_SELECT_FEATURE))};return e.addEventListener("keydown",l),()=>{e.removeEventListener("keydown",l)}}},[r,t,n,o])}({featuresRef:r,viewportRef:t,items:n,eventBus:o,activeFeatureIdRef:f,lastActiveIdRef:h,setActiveFeatureId:c,hints:i,currentHintRef:v}),function(e){var{viewportRef:t,featuresRef:r,isFocusedRef:n}=e;(0,l.vJ)(()=>{var e=t.current;if(e){var o=e=>{var o,i;!n.current||null!==(o=r.current)&&void 0!==o&&o.contains(e.target)||null===(i=t.current)||void 0===i||i.focus()};return e.addEventListener("pointerdown",o),()=>{e.removeEventListener("pointerdown",o)}}},[t,r])}({viewportRef:t,featuresRef:r,isFocusedRef:p}),{activeFeatureId:a,selectedIds:u,onFocus:()=>{if(p.current=!0,n.length){var e=Lt(n,h.current,u);h.current=e,c(e),null==o||o.emit(s.E.MAP_SET_ACTIVE_FEATURE,{id:e})}},onBlur:()=>{p.current=!1,c(null),null==o||o.emit(s.E.MAP_SET_ACTIVE_FEATURE,{id:null})}}}({viewportRef:a.viewportRef,featuresRef:y,items:m,eventBus:f,hints:g});(0,l.vJ)(()=>{var e=()=>p({type:"SET_LISTBOX_ACTIVE"});return f.on("interact:listboxcapable",e),()=>f.off("interact:listboxcapable",e)},[f]),function(e){var{mapProvider:t,panDelta:r,nudgePanDelta:n,zoomDelta:o,nudgeZoomDelta:i,readMapText:a}=d(),{dispatch:s,layoutRefs:c}=z(),{announce:u}=yt();(0,l.vJ)(()=>{var l,d=e.current,p=null===(l=c.appContainerRef)||void 0===l?void 0:l.current;if(d&&p){var h=Jt(t,u,{containerRef:e,dispatch:s,panDelta:r,nudgePanDelta:n,zoomDelta:o,nudgeZoomDelta:i,readMapText:a}),f=e=>t=>{var r=Wt[e][(e=>{var t;return"Add"===(t=/^Key[A-Z]$/.test(e.code)?e.code.slice(3):e.key)||"NumpadAdd"===t?t="+":"Subtract"!==t&&"NumpadSubtract"!==t||(t="-"),e.altKey?"Alt+".concat(t):t})(t)];r&&h[r]&&(h[r](t),t.preventDefault())},g=f("keydown"),v=f("keyup");return d.addEventListener("keydown",g),p.addEventListener("keyup",v),()=>{d.removeEventListener("keydown",g),p.removeEventListener("keyup",v)}}},[e,t,r,n,o,i])}(a.viewportRef),function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{mapProvider:t}=d(),{eventBus:r}=yt();(0,l.vJ)(()=>{if(t){var n={};return Object.entries(e).forEach(e=>{var[t,o]=e,i=e=>o(e);n[t]=i,r.on(t,i)}),()=>{Object.entries(n).forEach(e=>{var[t,n]=e;r.off(t,n)})}}},[t,e])}({[s.E.MAP_CLICK]:()=>{var e;return null==t||null===(e=t.clearHighlightedLabel)||void 0===e?void 0:e.call(t)}});var{handleFocus:w,handleBlur:_}=function(e){var{containerRef:t,onViewportFocusChange:r}=e;return(0,l.vJ)(()=>{var e=t.current;if(e){var n=e=>{"Escape"===e.key&&r(!1)};return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}}},[t,r]),{handleFocus:()=>{"keyboard"===(0,s.a)()&&r(!0)},handleBlur:()=>{r(!1)}}}({containerRef:a.viewportRef,onViewportFocusChange:e=>{e?g.show(n,{duration:0}):g.dismiss()}});return(0,l.vJ)(()=>{var e;o&&i&&o!==i&&(null===(e=a.viewportRef)||void 0===e||e.current.focus())},[o]),(0,c.FD)(c.FK,{children:[(0,c.Y)(zt,{mapContainerRef:v}),(0,c.FD)("div",{id:"".concat(e,"-viewport"),className:"im-c-viewport im-c-viewport--".concat(h),"aria-label":r,role:"application",tabIndex:"0",onFocus:w,onBlur:_,ref:a.viewportRef,"aria-describedby":"".concat(e,"-keyboard-desc"),"aria-controls":"".concat(e,"-features"),children:[(0,c.Y)("div",{className:"im-c-viewport__map-container",ref:v,"aria-hidden":"true"}),(0,c.Y)(Kt,{}),(0,c.Y)("div",{className:"im-c-viewport__safezone",style:u,ref:a.safeZoneRef,"aria-hidden":"true",children:(0,c.Y)(Zt,{})}),(0,c.Y)("div",{className:"im-c-viewport__markers","aria-hidden":"true",children:(0,c.Y)(lr,{})})]}),(0,c.Y)(Xt,{ref:y,activeFeatureId:E,selectedIds:P,multiselectable:b,items:m,onFocus:()=>{O(),g.show(n,{duration:0})},onBlur:()=>{S(),g.dismiss()}})]})};function ur(e,t){var r=(0,l.li)(),n=(0,l.li)(new WeakMap),o=(0,l.li)(t);return o.current=t,(0,l.vJ)(()=>{var i=(Array.isArray(e)?e:[e]).map(e=>null==e?void 0:e.current).filter(Boolean);if(i.length&&t){var a=new window.ResizeObserver(e=>{var t=[];for(var i of e){var{width:a,height:s}=i.contentRect,l=n.current.get(i.target)||{};l.width===a&&l.height===s||(n.current.set(i.target,{width:a,height:s}),t.push(i))}t.length&&(cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{for(var e of t)o.current(e)}))});return i.forEach(e=>a.observe(e)),()=>{a.disconnect(),r.current&&cancelAnimationFrame(r.current)}}},[e]),{frameRef:r}}var dr=e=>{var t,r;return null!==(t=null==e||null===(r=e.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==t?t:0},pr=(e,t,r)=>e-(t?t+r:0);function hr(e){var t,r,n,{appContainerRef:o,mainRef:i,topRef:a,topLeftColRef:s,topRightColRef:l,bottomRef:c,attributionsRef:u,bottomRightRef:d,leftTopRef:p,leftBottomRef:h,rightTopRef:f,rightBottomRef:g,actionsRef:v}=e,y=o.current,m=i.current,b=a.current,E=s.current,P=l.current,O=c.current,S=u.current;if(![m,b,O].some(e=>!e)){var w,_,M=document.documentElement,x=Number.parseInt(getComputedStyle(M).getPropertyValue("--divider-gap"),10);y.style.setProperty("--top-col-width","".concat((w=E.offsetWidth,_=P.offsetWidth,w||_?Math.max(w,_):0),"px"));var I=E.offsetHeight+b.offsetTop,A=O.offsetTop-I-x;y.style.setProperty("--left-offset-top","".concat(I,"px")),y.style.setProperty("--left-offset-bottom","".concat(m.offsetHeight-O.offsetTop+x,"px")),y.style.setProperty("--left-top-max-height","".concat(A,"px"));var T=null!==(t=null==d||null===(r=d.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==t?t:0,C=m.offsetHeight-O.offsetTop-O.offsetHeight,L=P.offsetHeight+b.offsetTop,D=O.offsetTop+O.offsetHeight-T-L-x,k=C+(T>0?T+x:S.offsetHeight);y.style.setProperty("--right-offset-top","".concat(L,"px")),y.style.setProperty("--right-offset-bottom","".concat(k,"px")),y.style.setProperty("--right-top-max-height","".concat(D,"px"));var j=null==v?void 0:v.current,R=null!==(n=null==j?void 0:j.offsetHeight)&&void 0!==n?n:0,N=m.offsetHeight-O.offsetTop-O.offsetHeight,F=R>0?m.offsetHeight-j.offsetTop:0;y.style.setProperty("--hint-bottom","".concat(Math.max(N,F+x),"px")),y.style.setProperty("--left-top-panel-max-height","".concat(pr(A,dr(h),x),"px")),y.style.setProperty("--left-bottom-panel-max-height","".concat(pr(A,dr(p),x),"px")),y.style.setProperty("--right-top-panel-max-height","".concat(pr(D,dr(g),x),"px")),y.style.setProperty("--right-bottom-panel-max-height","".concat(pr(D,dr(f),x),"px"))}}var fr=()=>{var{mapStyle:e}=vt();if(null!=e&&e.logo)return(0,c.Y)("img",{className:"im-c-logo",src:e.logo,alt:e.logoAltText})},gr=()=>{var{breakpoint:e}=z(),{mapStyle:t}=vt();return t?"mobile"!==e&&(0,c.Y)("div",{className:"im-c-attributions",dangerouslySetInnerHTML:{__html:t.attribution}}):null},vr=(e,t)=>e.modal?"modal":"drawer"===e.slot&&["tablet","desktop"].includes(t)?"left-top":e.slot,yr=(e,t)=>{var r;return!(e.includeModes&&!e.includeModes.includes(t)||null!==(r=e.excludeModes)&&void 0!==r&&r.includes(t))},mr=e=>"string"==typeof e.html&&!e.pluginId,br={"left-top":{inset:"var(--left-offset-top) auto auto var(--primary-gap)",maxHeight:"var(--left-top-max-height)"},"left-bottom":{inset:"auto auto var(--left-offset-bottom) var(--primary-gap)",maxHeight:"var(--left-top-max-height)"},"right-top":{inset:"var(--right-offset-top) var(--primary-gap) auto auto",maxHeight:"var(--right-top-max-height)"},"right-bottom":{inset:"auto var(--primary-gap) var(--right-offset-bottom) auto",maxHeight:"var(--right-top-max-height)"}},Er="--modal-inset",Pr="--modal-max-height";var Or=e=>{var{id:t,svgContent:r,isMenu:n}=e,o=n?be().chevron:be()[t]||r;return(0,c.Y)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:o},className:"im-c-icon".concat(n?" im-c-icon--narrow":"")})};function Sr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function wr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Sr(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Sr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var _r=(e,t)=>e?"dialog":t?"complementary":"region",Mr=e=>{var t,r,n,{panelId:o,panelConfig:i,props:a,focusOnOpen:u,WrappedChild:p,label:h,html:f,children:g,isOpen:v=!0,rootRef:y}=e,{id:m}=d(),{dispatch:b,breakpoint:E,layoutRefs:P,interfaceType:O}=z(),S=document.getElementById("".concat(m,"-im-app")),w=i[E],_="".concat(m,"-panel-").concat(or(o)),{isDialog:M,isModal:x,isDismissible:I,shouldFocus:A,buttonContainerEl:T}=((e,t,r,n)=>{var o="side"===e.slot&&e.open&&!e.modal,i=!o&&e.dismissible,a=!0===e.modal;return{isAside:o,isDialog:i,isModal:a,isDismissible:!1!==e.dismissible,shouldFocus:a||!0===n||!1!==n&&!1!==r&&(!0===r||Boolean(t)),buttonContainerEl:e.slot.endsWith("button")?null==t?void 0:t.parentNode:void 0}})(w,null==a?void 0:a.triggeringElement,i.focus,u),C=x&&v,L=P.mainRef,D=(0,l.li)(null),k=(0,l.li)(null),j=(0,l.li)(v),R=function(e){var[t,r]=(0,l.J0)(!1),n=(0,l.hb)(()=>{var t=null==e?void 0:e.current;t&&r(t.scrollHeight>t.clientHeight)},[e]);return ur(e,n),t}(k),N=y||D,F=()=>{requestAnimationFrame(()=>{var e,t;null===(e=(t=(null==a?void 0:a.triggeringElement)||P.viewportRef.current).focus)||void 0===e||e.call(t,{preventScroll:"keyboard"!==O})}),b({type:"CLOSE_PANEL",payload:o})};(function(e){var{mainRef:t,panelRef:r,isModal:n,rootEl:o,buttonContainerEl:i,handleClose:a}=e,{layoutRefs:c}=z();((e,t,r)=>{(0,l.vJ)(()=>{if(t){var n=t=>{"Escape"===t.key&&(t.stopPropagation(),t.preventDefault(),r()),"Tab"===t.key&&e.current&&function(e,t){if("Tab"===t.key){var r=Array.from(e.querySelectorAll(['a[href]:not([disabled]):not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','*[tabindex="0"]:not([disabled])'].join(",")));if(0!==(r=r.filter(e=>!!e.offsetParent)).length){var n=r[0],o=r[r.length-1];!t.shiftKey||document.activeElement!==e&&document.activeElement!==n||(o.focus(),t.preventDefault()),t.shiftKey||document.activeElement!==o||(n.focus(),t.preventDefault())}}}(e.current,t)},o=e.current;return null==o||o.addEventListener("keydown",n),()=>{null==o||o.removeEventListener("keydown",n)}}},[t,e,r])})(r,n,a),ur([t],()=>{if(n&&t.current){var e=document.documentElement,o=getComputedStyle(e),a=Number.parseInt(o.getPropertyValue("--divider-gap"),10),s=Number.parseInt(o.getPropertyValue("--primary-gap"),10),l=r.current.dataset.slot;if(null!=l&&l.endsWith("-button")){var u,d,p,h=null===(u=r.current)||void 0===u?void 0:u.id,f=h?document.querySelector('[aria-controls="'.concat(h,'"]')):null,g=null!==(d=null!==(p=null==f?void 0:f.parentElement)&&void 0!==p?p:null!=i&&i.isConnected?i:null)&&void 0!==d?d:document.querySelector('[data-button-slot="'.concat(l,'"]'));if(!g)return;((e,t,r)=>{var n=document.documentElement,o=t.current.getBoundingClientRect(),i=e.getBoundingClientRect(),a=!!e.closest(".im-o-app__left-bottom, .im-o-app__right-bottom"),s=!!e.closest(".im-o-app__left-top, .im-o-app__left-bottom"),l=a?"auto":"".concat(Math.round(i.top-o.top),"px"),c=a?"".concat(Math.round(o.bottom-i.bottom),"px"):"auto",u=s?"auto":"".concat(Math.round(o.right-i.left+r),"px"),d=s?"".concat(Math.round(i.right-o.left+r),"px"):"auto",p=a?Math.round(o.bottom-i.bottom):Math.round(i.top-o.top);n.style.setProperty(Er,"".concat(l," ").concat(u," ").concat(c," ").concat(d)),n.style.setProperty(Pr,"".concat(o.height-p-r,"px"))})(g,t,a)}else((e,t,r)=>{var n,o,i=document.documentElement,a=br[e];if(a)return i.style.setProperty(Er,a.inset),void i.style.setProperty(Pr,a.maxHeight);var s=null===(n=t["".concat(e[0].toLowerCase()+e.slice(1),"Ref")])||void 0===n?void 0:n.current,l=null===(o=t.mainRef)||void 0===o?void 0:o.current;if(s&&l){var c=s.getBoundingClientRect(),u=l.getBoundingClientRect(),d=c.left-u.left,p=c.top-u.top;i.style.setProperty(Er,"".concat(p,"px auto auto ").concat(d,"px")),i.style.setProperty(Pr,"".concat(u.height-p-r,"px"))}})(l,c,s)}}),(0,l.vJ)(()=>{if(n){var e=e=>{var t=e.target.closest(".im-o-app__modal-backdrop");o&&t&&o.contains(t)&&a()};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}}},[n,o,a]),(0,l.vJ)(()=>{if(n&&r.current&&o)return(0,s.t)({containerEl:r.current,isFullscreen:!0,boundaryEl:o}),()=>{(0,s.t)({containerEl:r.current,isFullscreen:!1,boundaryEl:o})}},[n,r,o]),((e,t,r)=>{(0,l.vJ)(()=>{if(e){var n=e=>{var n=e.target,o=t.current;if(n&&o&&r){var i=r.contains(n),a=o.contains(n);i&&!a&&o.focus()}};return document.addEventListener("focusin",n),()=>{document.removeEventListener("focusin",n)}}},[e,t,r])})(n,r,o)})({mainRef:L,panelRef:N,isModal:C,rootEl:S,buttonContainerEl:T,handleClose:F}),(0,l.vJ)(()=>{var e,t=v&&!j.current;j.current=v,A&&(t||v)&&(null===(e=N.current)||void 0===e||e.focus())},[v]);var B,V,U=(B=w.slot,V=null===(t=w.showLabel)||void 0===t||t,["im-c-panel","im-c-panel--".concat(B),!V&&"im-c-panel--no-heading"].filter(Boolean).join(" ")),Y=((e,t)=>["im-c-panel__body",!e&&t&&"im-c-panel__body--offset"].filter(Boolean).join(" "))(null===(r=w.showLabel)||void 0===r||r,I),G=(0,l.Kr)(()=>f?{__html:f}:null,[f]),H=(e=>{var{elementId:t,shouldFocus:r,isDialog:n,isDismissible:o,isModal:i,width:a,panelClass:s,slot:l}=e;return{id:t,"aria-labelledby":"".concat(t,"-label"),tabIndex:r?-1:void 0,role:_r(n,o),"aria-modal":n&&i?"true":void 0,style:a?{width:a}:void 0,className:s,"data-slot":l}})({elementId:_,shouldFocus:A,isDialog:M,isDismissible:I,isModal:x,width:w.width,panelClass:U,slot:w.slot}),W=(e=>{var{bodyRef:t,panelBodyClass:r,isBodyScrollable:n,elementId:o}=e;return{ref:t,className:r,tabIndex:n?0:void 0,role:n?"region":void 0,"aria-labelledby":n?"".concat(o,"-label"):void 0}})({bodyRef:k,panelBodyClass:Y,isBodyScrollable:R,elementId:_});return(0,c.FD)("div",wr(wr({ref:N},H),{},{children:[(0,c.Y)("h2",{id:"".concat(_,"-label"),className:null===(n=w.showLabel)||void 0===n||n?"im-c-panel__heading im-e-heading-m":"im-u-visually-hidden",children:h}),I&&(0,c.Y)("button",{"aria-label":"Close ".concat(h),className:"im-c-panel__close",onClick:F,children:(0,c.Y)(Or,{id:"close"})}),G?(0,c.Y)("div",wr(wr({},W),{},{dangerouslySetInnerHTML:G})):(0,c.FD)("div",wr(wr({},W),{},{children:[" ",p?(0,c.Y)(p,wr({},a)):g]}))]}))};function xr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ir(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?xr(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ar(e){var{slot:t,appState:r,evaluateProp:n}=e,{breakpoint:o,pluginRegistry:i,panelConfig:a,mode:s,openPanels:l}=r,u=Object.entries(l),d=u.filter(e=>{var t,[r]=e,n=null===(t=a[r])||void 0===t?void 0:t[o];return null==n?void 0:n.modal}),p=d.length>0?d[d.length-1][0]:null;return u.map(e=>{var l,[u,{props:d,focusOnOpen:h}]=e,f=a[u];if(!f)return null;if(mr(f))return null;var g=f[o];if(!g)return null;var v=vr(g,o);if(!((e,t,r,n)=>{var{targetSlot:o,slot:i,mode:a,isFullscreen:s,allowedModalPanelId:l}=n,c=o.endsWith("-button");return!(!N.panel.includes(o)&&!c||!yr(t,a)||!1===t.inline&&!s||o!==i||r.modal&&e!==l)})(u,f,g,{targetSlot:v,slot:t,mode:s,isFullscreen:r.isFullscreen,allowedModalPanelId:p}))return null;var y=i.registeredPlugins.find(e=>e.id===f.pluginId),m=null==y?void 0:y.id,b=f.render?Pt(f.render,Ir(Ir({},d),{},{pluginId:m,pluginConfig:null==y?void 0:y.config})):null;return{id:u,type:"panel",order:null!==(l=g.order)&&void 0!==l?l:0,element:(0,c.Y)(Mr,{panelId:u,panelConfig:f,props:d,focusOnOpen:h,WrappedChild:b,label:n(f.label,m),html:m?n(f.html,m):f.html},u)}}).filter(Boolean)}var Tr=0,Cr=e=>{var{children:t,content:r}=e,{interfaceType:n}=z(),o=(0,l.li)(null),i=(0,l.li)(null),[a,s]=(0,l.J0)(!1),[u,d]=(0,l.J0)(!1),[p,h]=(0,l.J0)(null),[f]=(0,l.J0)(()=>"tooltip-".concat(Tr+=1)),g=(0,l.li)(null),v=(0,l.li)(null),y=()=>{clearTimeout(g.current),s(!1)},m=()=>{clearTimeout(v.current),g.current=setTimeout(()=>s(!0),500)},b=()=>{clearTimeout(g.current),v.current=setTimeout(()=>s(!1),0)};(0,l.vJ)(()=>{var e=e=>{"Escape"===e.key&&(clearTimeout(g.current),clearTimeout(v.current),s(!1))};if(window.addEventListener("keydown",e),a){var t=function(e,t){if(!e)return"bottom";t||(t=e.closest(".im-o-app__main"));var r=e.getBoundingClientRect(),n=t.getBoundingClientRect(),o={top:r.top-n.top,bottom:n.bottom-r.bottom,left:r.left-n.left,right:n.right-r.right},i=Object.entries(o);i.sort((e,t)=>{var[,r]=e,[,n]=t;return r-n});var[a,s]=i[0];if("top"===a||"bottom"===a)for(var[l,c]of i)if(("left"===l||"right"===l)&&Math.abs(c-s)<=50)return"left"===l?"right":"left";return{top:"bottom",bottom:"top",left:"right",right:"left"}[a]}(o.current);h(t)}return()=>{window.removeEventListener("keydown",e),clearTimeout(g.current),clearTimeout(v.current)}},[a]);var E=(0,l.Ob)(t,{ref:e=>{var r;o.current=e;var n=null===(r=t.props)||void 0===r?void 0:r.ref;"function"==typeof n?n(e):n&&"object"==typeof n&&(n.current=e)},onMouseEnter:m,onMouseLeave:b,onMouseDown:y,onKeyDown:y,onFocus:()=>{"keyboard"===n&&m(),d(!0)},onBlur:()=>{b(),d(!1)},"aria-labelledby":f});return(0,c.FD)("div",{className:"im-c-tooltip-wrapper".concat(u?" im-c-tooltip-wrapper--has-focus":""),children:[E,(0,c.Y)("div",{id:f,ref:i,className:"im-c-tooltip im-c-tooltip--".concat(p||"hidden"," ").concat(a?"im-c-tooltip--is-visible":""),role:"tooltip","aria-hidden":!a,children:r})]})};function Lr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Dr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Lr(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var kr=(e,t,r)=>{var{buttonConfig:n,evaluateProp:o,pluginId:i,id:a}=r,s=n[t.id];if("function"==typeof(null==s?void 0:s.onClick)?s.onClick(e,o(e=>e,i)):"function"==typeof t.onClick&&t.onClick(e.nativeEvent),e.nativeEvent instanceof KeyboardEvent){var l=document.getElementById("".concat(a,"-").concat(or(t.id)));if(l){var c=new MouseEvent("click",{bubbles:!0,cancelable:!0});c._fromKeyboardActivation=!0,l.dispatchEvent(c)}}},jr=(e,t)=>{var r,n,o,i;return{panelId:null!==(r=null===(n=t[e.id])||void 0===n?void 0:n.panelId)&&void 0!==r?r:e.panelId,keepFocus:null!==(o=null===(i=t[e.id])||void 0===i?void 0:i.keepFocus)&&void 0!==o?o:e.keepFocus}},Rr=(e,t)=>{var r;e?e.focus():null===(r=t.current)||void 0===r||r.focus()},Nr=e=>{var{item:t,isSelected:r,hiddenButtons:n,disabledButtons:o,pressedButtons:i,id:a,onItemClick:s}=e;return(0,c.FD)("li",{id:"".concat(a,"-").concat(or(t.id)),className:"im-c-popup-menu__item".concat(r?" im-c-popup-menu__item--selected":""),role:void 0!==t.isPressed||t.pressedWhen?"menuitemcheckbox":"menuitem","aria-disabled":o.has(t.id)||void 0,"aria-checked":void 0!==t.isPressed||t.pressedWhen?i.has(t.id):void 0,style:n.has(t.id)?{display:"none"}:void 0,onClick:e=>s(e,t),children:[(t.iconId||t.iconSvgContent)&&(0,c.Y)(Or,{id:t.iconId,svgContent:t.iconSvgContent}),(0,c.Y)("span",{className:"im-c-popup-menu__item-label",children:t.label})]})},Fr=e=>{var t,r,{popupMenuId:n,buttonId:o,instigatorId:i,pluginId:a,startPos:s,startIndex:u,menuRef:p,items:h,setIsOpen:f,buttonRect:g}=e,{id:v}=d(),{buttonRefs:y,buttonConfig:m,hiddenButtons:b,disabledButtons:E,pressedButtons:P,layoutRefs:O}=z(),S=null!=o?o:i,w=y.current[S],_=It(),{index:M,handleMenuKeyDown:x,handleItemClick:I,menuStyle:A,menuDirection:T,menuHAlign:C}=(e=>{var{items:t,hiddenButtons:r,startIndex:n,startPos:o,instigator:i,instigatorKey:a,buttonRefs:s,buttonConfig:c,disabledButtons:u,pluginId:d,evaluateProp:p,id:h,menuRef:f,setIsOpen:g,buttonRect:v}=e,{dispatch:y,layoutRefs:m}=z(),b=m.viewportRef,E=(0,l.Kr)(()=>{var e=[];return t.forEach((t,n)=>{r.has(t.id)||e.push(n)}),e},[t,r]),[P,O]=(0,l.J0)(()=>((e,t,r)=>{return"number"==typeof e?e:"first"===t?null!==(n=r[0])&&void 0!==n?n:-1:"last"===t&&null!==(o=r[r.length-1])&&void 0!==o?o:-1;var n,o})(n,o,E)),S={buttonConfig:c,evaluateProp:p,pluginId:d,id:h},w=(e=>{var{items:t,visibleIndices:r,index:n,setIndex:o,disabledButtons:i,instigator:a,setIsOpen:s,activateCtx:l,dispatch:c,viewportRef:u}=e,d={items:t,index:n,disabledButtons:i,activateCtx:l,instigator:a,dispatch:c,viewportRef:u,setIsOpen:s};return e=>{if(!["Escape","Esc"].includes(e.key))return"Tab"===e.key?(e.preventDefault(),((e,t,r)=>{var n,o,i=null!=e?e:r,a=function(e){var{el:t,direction:r,root:n=document}=e,o=n.querySelectorAll("input, button, select, textarea, a[href]"),i=Array.prototype.filter.call(o,e=>e.tabIndex>=0&&!!e.offsetParent),a=i.indexOf(t);return i["next"===r?a+1:a-1]||i[0]}({el:i,direction:t?"prev":"next",root:null!==(n=null===(o=i.closest)||void 0===o?void 0:o.call(i,'[role="dialog"][aria-modal="true"]'))&&void 0!==n?n:document});null==a||a.focus()})(a,e.shiftKey,e.currentTarget),void s(!1)):void(["ArrowDown","ArrowUp"].includes(e.key)?(e=>{e.preventDefault();var t=r.length;if(0!==t){var i,a=r.indexOf(n);i="ArrowDown"===e.key?-1===a?0:(a+1)%t:-1===a?t-1:(a-1+t)%t,o(r[i])}})(e):"Home"===e.key&&r.length?o(r[0]):"End"===e.key&&r.length?o(r[r.length-1]):("Enter"===e.key&&((e,t)=>{var{items:r,index:n,disabledButtons:o,activateCtx:i,instigator:a,dispatch:s,viewportRef:l,setIsOpen:c}=t;e.preventDefault();var u=r[n];if(u&&!o.has(u.id)){var{panelId:d,keepFocus:p}=jr(u,i.buttonConfig);if(d)return s({type:"OPEN_PANEL",payload:Dr({panelId:d,props:{triggeringElement:a}},p&&{focusOnOpen:!1})}),void c(!1);if(kr(e,u,i),p)return Rr(a,l),void c(!1)}requestAnimationFrame(()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.focus()}),c(!1)})(e,d)," "===e.key&&((e,t)=>{var{items:r,index:n,disabledButtons:o,activateCtx:i,instigator:a,dispatch:s,viewportRef:l,setIsOpen:c}=t;e.preventDefault();var u=r[n];if(u&&!o.has(u.id)){var{panelId:d,keepFocus:p}=jr(u,i.buttonConfig);if(d)return s({type:"OPEN_PANEL",payload:Dr({panelId:d,props:{triggeringElement:a}},p&&{focusOnOpen:!1})}),void c(!1);kr(e,u,i),void 0!==u.isPressed||u.pressedWhen||(p?Rr(a,l):requestAnimationFrame(()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.focus()}),c(!1))}})(e,d)));(e=>{e.preventDefault(),Rr(a,u),s(!1)})(e)}})({items:t,visibleIndices:E,index:P,setIndex:O,disabledButtons:u,instigator:i,setIsOpen:g,activateCtx:S,dispatch:y,viewportRef:b}),_=e=>{var t,r;null!==(t=f.current)&&void 0!==t&&t.contains(e.target)||null!==(r=s.current[a])&&void 0!==r&&r.contains(e.target)||g(!1)};(0,l.vJ)(()=>{var e,t;if(null===(e=f.current)||void 0===e||e.focus(),"first"===o)O(null!==(t=E[0])&&void 0!==t?t:-1);else if("last"===o){var r;O(null!==(r=E[E.length-1])&&void 0!==r?r:-1)}var n=()=>g(!1);return document.addEventListener("focusin",_),document.addEventListener("pointerdown",_),window.addEventListener("resize",n),()=>{document.removeEventListener("focusin",_),document.removeEventListener("pointerdown",_),window.removeEventListener("resize",n)}},[]);var{style:M,direction:x,halign:I}=(e=>{if(!e)return{style:{},direction:"below"};var t,r={};e.top>=window.innerHeight/2?(r.bottom="".concat(window.innerHeight-e.top,"px"),t="above"):(r.top="".concat(e.bottom,"px"),t="below");var n,o=(e.left+e.right)/2;return o>2*window.innerWidth/3?(r.right="".concat(window.innerWidth-e.right,"px"),n="right"):o<window.innerWidth/3?(r.left="".concat(e.left,"px"),n="left"):(r.left="".concat(o,"px"),n="center"),{style:r,direction:t,halign:n}})(v);return{index:P,handleMenuKeyDown:w,handleItemClick:(e,t)=>{if(!e.nativeEvent._fromKeyboardActivation&&!u.has(t.id)){var r,{panelId:n,keepFocus:o}=jr(t,c);if(n)return y({type:"OPEN_PANEL",payload:Dr({panelId:n,props:{triggeringElement:i}},o&&{focusOnOpen:!1})}),void g(!1);g(!1),kr(e,t,S),o?Rr(i,b):null===(r=b.current)||void 0===r||r.focus()}},menuStyle:M,menuDirection:x,menuHAlign:I}})({items:h,hiddenButtons:b,startIndex:u,startPos:s,instigator:w,instigatorKey:S,buttonRefs:y,buttonConfig:m,disabledButtons:E,pluginId:a,evaluateProp:_,id:v,menuRef:p,setIsOpen:f,buttonRect:g});return(0,l.d5)((0,c.Y)("ul",{ref:p,id:n,className:"im-c-popup-menu","data-direction":T,"data-halign":C,style:A,role:"menu",tabIndex:"-1","aria-labelledby":S,"aria-activedescendant":M>=0?"".concat(v,"-").concat(or(h[M].id)):void 0,onKeyDown:x,children:h.map((e,t)=>(0,c.Y)(Nr,{item:e,isSelected:M===t,hiddenButtons:b,disabledButtons:E,pressedButtons:P,id:v,onItemClick:I},e.id))}),null!==(t=null==O||null===(r=O.appContainerRef)||void 0===r?void 0:r.current)&&void 0!==t?t:document.body)};function Br(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Vr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Br(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Br(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Ur=(e,t,r)=>["im-c-map-button",e&&"im-c-map-button--".concat(or(e)),t&&"im-c-map-button--".concat(t),r&&"im-c-map-button--with-label"].filter(Boolean).join(" "),Yr=(e,t)=>["im-c-button-wrapper",e&&"im-c-button-wrapper--".concat(or(e)),t&&"im-c-button-wrapper--wide"].filter(Boolean).join(" "),Gr=e=>{" "!==e.key&&"Spacebar"!==e.key||(e.preventDefault(),e.currentTarget.click())},Hr=(e,t,r)=>{var n=e.current[t];n&&r(n.getBoundingClientRect().toJSON())},zr=e=>{var{buttonId:t,iconId:r,iconSvgContent:n,label:o,showLabel:i,isDisabled:a,isPressed:s,isExpanded:u,isHidden:p,isPanelOpen:h,variant:f,onClick:g,panelId:v,menuItems:y,idPrefix:m,href:b}=e,{id:E}=d(),{buttonRefs:P}=z(),[O,S]=(0,l.J0)(!1),[w,_]=(0,l.J0)(null),[M,x]=(0,l.J0)(null),I=(0,l.li)(null),A=(0,l.hb)(e=>{P.current&&t&&(P.current[t]=e)},[P,t]),T=b?"a":"button",C=(null==y?void 0:y.length)>=1,L=r||n||C,D=((e,t)=>e?"".concat(or(t),"-button"):void 0)(v,t),k=(e=>{var{idPrefix:t,panelId:r,buttonId:n,hasMenu:o}=e;return r?{id:"".concat(t,"-panel-").concat(or(r)),type:"panel"}:o?{id:"".concat(t,"-popup-").concat(or(n)),type:"popup"}:null})({idPrefix:m,panelId:v,buttonId:t,hasMenu:C}),j=((e,t,r,n,o,i)=>a=>{e&&["ArrowDown","ArrowUp"].includes(a.key)&&(n("ArrowUp"===a.key?"last":"first"),Hr(t,r,o),i(!0))})(C,P,t,_,x,S),R=(e=>t=>{e&&["ArrowDown","ArrowUp"].includes(t.key)&&t.preventDefault()})(C),N=(e=>{var t,{appId:r,buttonId:n,className:o,onClick:i,onKeyUp:a,onKeyDown:s,setButtonRef:l,isDisabled:c,isPressed:u,isExpanded:d,isPanelOpen:p,isPopupOpen:h,controlledElement:f,href:g}=e;return"panel"===(null==f?void 0:f.type)?t=String(p):"popup"===(null==f?void 0:f.type)?t=h:"boolean"==typeof d&&(t=d),Vr({id:"".concat(r,"-").concat(or(n)),className:o,onClick:i,onKeyUp:a,onKeyDown:s,ref:l,"aria-disabled":c||void 0,"aria-expanded":t,"aria-pressed":"boolean"==typeof u?u:void 0,"aria-controls":null==f?void 0:f.id,"aria-haspopup":"popup"===(null==f?void 0:f.type)?"menu":void 0},g?{href:g,target:"_blank",onKeyUp:Gr,role:"button"}:{type:"button"})})({appId:E,buttonId:t,className:Ur(t,f,i),onClick:e=>{if(!a){if("popup"===(null==k?void 0:k.type)){var r=""===e.nativeEvent.pointerType;_(r?"first":null),O||Hr(P,t,x),S(e=>!e)}g&&g(e)}},onKeyUp:j,onKeyDown:R,setButtonRef:A,isDisabled:a,isPressed:s,isExpanded:u,isPanelOpen:h,isPopupOpen:O,controlledElement:k,href:b}),F=(0,c.FD)(T,Vr(Vr({},N),{},{children:[L&&(0,c.Y)(Or,{id:r,svgContent:n,isMenu:C}),i&&(0,c.Y)("span",{children:o})]}));return(0,c.FD)("div",{className:Yr(t,i),"data-button-slot":D,style:p?{display:"none"}:void 0,children:[i?F:(0,c.Y)(Cr,{content:o,children:F}),D&&(0,c.Y)(en,{slot:D}),O&&(0,c.Y)(Fr,{popupMenuId:k.id,buttonId:t,startPos:w,menuRef:I,items:y,setIsOpen:S,buttonRect:M})]})};function Wr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Jr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Wr(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Wr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Kr(e){var t,r,{btn:n,appState:o,appConfig:i,evaluateProp:a}=e,[s,l]=n,u=null!==(t=l[o.breakpoint])&&void 0!==t?t:{},d=function(e,t,r){var[,n]=e,o=!(!n.panelId||!t.openPanels[n.panelId]),i=void 0!==n.isPressed||!!n.pressedWhen;return e=>{if("function"==typeof n.onClick)return n.onClick(e,r(e=>e,n.pluginId)),void(i||n.keepFocus||requestAnimationFrame(()=>{var e;return null===(e=t.layoutRefs.viewportRef.current)||void 0===e?void 0:e.focus()}));if(n.panelId){var a=e.currentTarget;t.dispatch({type:o?"CLOSE_PANEL":"OPEN_PANEL",payload:o?n.panelId:Jr({panelId:n.panelId,props:{triggeringElement:a}},n.keepFocus&&{focusOnOpen:!1})})}}}(n,o,a),p=!(!l.panelId||!o.openPanels[l.panelId]);return(0,c.Y)(zr,{buttonId:s,iconId:a(l.iconId,l.pluginId),iconSvgContent:a(l.iconSvgContent,l.pluginId),variant:l.variant,label:a(l.label,l.pluginId),href:a(l.href,l.pluginId),showLabel:null===(r=u.showLabel)||void 0===r||r,isDisabled:o.disabledButtons.has(s),isHidden:o.hiddenButtons.has(s),isPressed:void 0!==l.isPressed||l.pressedWhen?o.pressedButtons.has(s):void 0,isExpanded:void 0!==l.isExpanded||l.expandedWhen?o.expandedButtons.has(s):void 0,isPanelOpen:p,onClick:d,panelId:l.panelId,menuItems:l.menuItems,idPrefix:i.id},s)}function qr(e){var{slot:t,appState:r,appConfig:n,evaluateProp:o}=e,{buttonConfig:i,breakpoint:a}=r,l=function(e){var{appState:t,buttonConfig:r,slot:n,evaluateProp:o}=e,{breakpoint:i,mode:a}=t;return r?Object.entries(r).filter(e=>{var r,s,[l,c]=e,u=c[i];if(c.isMenuItem)return!1;if("function"==typeof c.excludeWhen&&o(c.excludeWhen,c.pluginId))return!1;if(c.includeModes&&(null===(r=c.includeModes)||void 0===r||!r.includes(a)))return!1;if(null!==(s=c.excludeModes)&&void 0!==s&&s.includes(a))return!1;if(!1===c.inline&&!t.isFullscreen)return!1;if(c.panelId){var d,p=null===(d=t.panelConfig)||void 0===d||null===(d=d[c.panelId])||void 0===d?void 0:d[i];if(!0===(null==p?void 0:p.open)&&!1===(null==p?void 0:p.dismissible))return!1}return!((null==u?void 0:u.slot)!==n||!N.button.includes(u.slot))}):[]}({appState:r,buttonConfig:i,slot:t,evaluateProp:o}),u=function(e,t){var r=null;for(var[n,o]of e)if(o.exclusiveSlot&&!t.hiddenButtons.has(n)&&o.pluginId){if(null!==r&&r!==o.pluginId)return s.l.warn("Slot exclusivity conflict: plugins [".concat(r,", ").concat(o.pluginId,"] are both claiming exclusive slot ownership. Showing all buttons.")),e;r=o.pluginId}return null===r?e:e.filter(e=>{var[t,n]=e;return n.pluginId===r})}(l,r);if(!u.length)return[];var d=new Map,p=[];u.forEach(e=>{var[t,r]=e,{group:n}=r;if(null!=n){var o=function(e){var t;return null==e?null:"string"==typeof e?e:null!==(t=e.name)&&void 0!==t?t:null}(n),i=function(e){var t,r;return e?"string"==typeof e?e:null!==(t=null!==(r=e.label)&&void 0!==r?r:e.name)&&void 0!==t?t:"":""}(n),a=function(e){var t;return e&&"string"!=typeof e&&null!==(t=e.order)&&void 0!==t?t:0}(n);d.has(o)?d.get(o):d.set(o,{label:i,order:a,members:[]}),d.get(o).members.push([t,r])}else p.push([t,r])});var h=[];for(var f of p){var g,v,[y,m]=f,b=null!==(g=null===(v=m[a])||void 0===v?void 0:v.order)&&void 0!==g?g:0;h.push({id:y,type:"button",order:b,element:Kr({btn:f,appState:r,appConfig:n,evaluateProp:o})})}for(var[E,{label:P,order:O,members:S}]of d)if(S.length<2){var w,_=S[0],[M,x]=_,I=O||(null===(w=x[a])||void 0===w?void 0:w.order)||0;h.push({id:M,type:"button",order:I,element:Kr({btn:_,appState:r,appConfig:n,evaluateProp:o})})}else{var A=[...S].sort((e,t)=>{var r,n,o,i;return(null!==(r=null===(n=e[1][a])||void 0===n?void 0:n.order)&&void 0!==r?r:0)-(null!==(o=null===(i=t[1][a])||void 0===i?void 0:i.order)&&void 0!==o?o:0)});h.push({id:"group-".concat(E),type:"group",order:O,element:(0,c.Y)("div",{role:"group","aria-label":P,className:"im-c-button-group",children:A.map(e=>Kr({btn:e,appState:r,appConfig:n,evaluateProp:o}))},"group-".concat(E))})}return h}var Zr=["evaluateProp"];function Xr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function $r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Xr(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Qr=e=>{var{children:t}=e,{openPanels:r,panelConfig:n,breakpoint:o}=z(),i=["im-c-panel","im-c-actions",!l.Ay.Children.toArray(t).find(e=>{var t,r;return!1===(null===(t=e.props)||void 0===t?void 0:t.isHidden)&&"touch"!==(null===(r=e.props)||void 0===r?void 0:r.variant)})&&"im-c-actions--hidden",Object.keys(r).some(e=>{var t;return"mobile"===o&&"drawer"===(null===(t=n[e])||void 0===t||null===(t=t[o])||void 0===t?void 0:t.slot)})&&"im-c-actions--border-top"].filter(Boolean).join(" ");return(0,c.Y)("div",{className:i,children:t})},en=e=>{var{slot:t}=e,r=function(e){var{evaluateProp:t}=e,r=(0,o.A)(e,Zr),n=function(e){var{slot:t,appState:r,evaluateProp:n}=e,{breakpoint:o,mode:i,pluginRegistry:a,controlConfig:s}=r;return Object.values(s).filter(e=>{var n,a,s,l;if(mr(e))return!1;var c=e[o];if(!c)return!1;var u=N.control.includes(c.slot),d=null===(n=null===(a=e.includeModes)||void 0===a?void 0:a.includes(i))||void 0===n||n,p=null!==(s=null===(l=e.excludeModes)||void 0===l?void 0:l.includes(i))&&void 0!==s&&s;return!(!1===e.inline&&!r.isFullscreen)&&d&&!p&&c.slot===t&&u}).map(e=>{var t,r,i,s=a.registeredPlugins.find(t=>{var r;return null===(r=t.manifest)||void 0===r||null===(r=r.controls)||void 0===r?void 0:r.some(t=>t.id===e.id)}),l=null==s?void 0:s.id;if(e.html)i=(0,c.Y)("div",{className:"im-c-control",dangerouslySetInnerHTML:{__html:n(e.html,l)}},e.id);else{var u=Pt(e.render,{pluginId:l,pluginConfig:null==s?void 0:s.config});i=(0,c.Y)(u,{},e.id)}return{id:e.id,type:"control",order:null!==(t=null===(r=e[o])||void 0===r?void 0:r.order)&&void 0!==t?t:0,element:i}})}($r({evaluateProp:t},r)),i=[...n,...Ar($r({evaluateProp:t},r)),...qr($r({evaluateProp:t},r))],a=i.filter(e=>null==e.order||0===e.order),s=i.filter(e=>null!=e.order&&0!==e.order);s.sort((e,t)=>e.order-t.order);var l=[...a];for(var u of s){var d=Math.min(Math.max(u.order-1,0),l.length);l.splice(d,0,u)}return l}({slot:t,appConfig:d(),appState:z(),evaluateProp:It()});return r.length?(0,c.Y)(c.FK,{children:"actions"===t?(0,c.Y)(Qr,{slot:"actions",children:r.map(e=>e.element)}):(0,c.Y)(c.FK,{children:r.map(e=>e.element)})}):null},tn=(e,t,r,n,o)=>{var i=(0,l.li)(n);i.current=n,(0,l.Nf)(()=>{var n=e.current;if(r){var o=((e,t)=>{var r={side:t.sideRef,banner:t.bannerRef,"top-left":t.topLeftColRef,"top-right":t.topRightColRef,"left-top":t.leftTopRef,"left-bottom":t.leftBottomRef,middle:t.middleRef,"right-top":t.rightTopRef,"right-bottom":t.rightBottomRef,"bottom-right":t.bottomRightRef,drawer:t.drawerRef,actions:t.actionsRef,modal:t.modalRef};if(null!=e&&e.endsWith("-button")){var n=document.querySelector('[data-button-slot="'.concat(e,'"]'));return n?{current:n}:null}return r[e]||null})(t,i.current);if(null!=o&&o.current){var a=o.current.querySelector(":scope > .im-o-app__modal-backdrop");a?o.current.insertBefore(n,a):o.current.appendChild(n),n.style.display=""}}else{var s,l;n.parentElement===(null===(s=i.current.modalRef)||void 0===s?void 0:s.current)&&(null===(l=i.current.appContainerRef)||void 0===l||null===(l=l.current)||void 0===l||l.appendChild(n)),n.style.display="none"}return()=>{n.style.display="none"}},[r,t,o,e])},rn=e=>{var{panelId:t,config:r,isOpen:n,openPanelProps:o,focusOnOpen:i,allowedModalPanelId:a,appState:s}=e,u=(0,l.li)(null),{breakpoint:d,mode:p,isFullscreen:h,layoutRefs:f}=s,g=r[d],v=g?vr(g,d):null,y=(()=>{if(!n||!g||!v)return!1;var e=v.endsWith("-button");if(!N.panel.includes(v)&&!e)return!1;var o=g.modal&&t!==a,i=!1===r.inline&&!h,s=!yr(r,p);return!(o||i||s)})();return tn(u,v,y,f,d),(0,c.Y)(Mr,{panelId:t,panelConfig:r,props:o,focusOnOpen:i,html:r.html,label:r.label,isOpen:n,rootRef:u})},nn=e=>{var{control:t,appState:r}=e,n=(0,l.li)(null),{breakpoint:o,mode:i,isFullscreen:a,layoutRefs:s}=r,u=t[o],d=((e,t)=>{var{breakpoint:r,mode:n,isFullscreen:o}=t,i=e[r];return!(!i||!N.control.includes(i.slot)||!yr(e,n)||!1===e.inline&&!o)})(t,{breakpoint:o,mode:i,isFullscreen:a}),p=(null==u?void 0:u.slot)||null;tn(n,p,d,s,o);var h=(0,l.Kr)(()=>({__html:t.html}),[t.html]);return(0,c.Y)("div",{ref:n,className:"im-c-control",style:{display:"none"},dangerouslySetInnerHTML:h})},on=()=>{var e=z(),{panelConfig:t={},controlConfig:r={},openPanels:n={},breakpoint:o}=e,i=(0,l.Kr)(()=>Object.entries(t).filter(e=>{var[t,r]=e;return mr(r)}),[t]),a=(0,l.Kr)(()=>Object.values(r).filter(e=>mr(e)),[r]),s=(0,l.Kr)(()=>{var e=Object.entries(n).filter(e=>{var r,[n]=e,i=null===(r=t[n])||void 0===r?void 0:r[o];return null==i?void 0:i.modal});return e.length>0?e[e.length-1][0]:null},[n,t,o]);return i.length||a.length?(0,c.FD)(c.FK,{children:[i.map(t=>{var r,o,[i,a]=t;return(0,c.Y)(rn,{panelId:i,config:a,isOpen:!!n[i],openPanelProps:null===(r=n[i])||void 0===r?void 0:r.props,focusOnOpen:null===(o=n[i])||void 0===o?void 0:o.focusOnOpen,allowedModalPanelId:s,appState:e},i)}),a.map(t=>(0,c.Y)(nn,{control:t,appState:e},t.id))]}):null},an=()=>{var e,t,{id:r,keyboardHintText:n}=d(),{hints:o}=yt(),{layoutRefs:i}=z(),[a,s]=(0,l.J0)(null),[u,p]=(0,l.J0)(!1);return(0,l.vJ)(()=>(p(!0),o.subscribe(s)),[o]),u&&null!==(e=i.mainRef)&&void 0!==e&&e.current?(0,l.d5)((0,c.FD)("div",{className:"im-o-hints",children:[(0,c.Y)("div",{id:"".concat(r,"-hints"),className:"im-c-hints",children:a&&(0,c.Y)("div",{className:"im-c-hints__hint",dangerouslySetInnerHTML:{__html:a.html}})}),(0,c.Y)("div",{id:"".concat(r,"-keyboard-desc"),className:"im-u-visually-hidden",dangerouslySetInnerHTML:{__html:(t=n,(new DOMParser).parseFromString(t,"text/html").body.textContent.replace(/\s{2,}/g," ").trim())}})]}),i.mainRef.current):null};function sn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ln(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sn(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var cn=()=>{var{id:e}=d(),{breakpoint:t,interfaceType:r,preferredColorScheme:n,layoutRefs:o,isLayoutReady:i,hasExclusiveControl:a,isFullscreen:u}=z(),{mapStyle:p}=vt();return function(){var{dispatch:e,breakpoint:t,layoutRefs:r,arePluginsEvaluated:n,appVisible:o,isFullscreen:i}=z(),{mapSize:a,isMapReady:s}=vt(),{bannerRef:c,mainRef:u,topRef:d,topLeftColRef:p,topRightColRef:h,bottomRef:f,bottomRightRef:g,leftTopRef:v,leftBottomRef:y,rightTopRef:m,rightBottomRef:b,drawerRef:E,actionsRef:P}=r;(0,l.Nf)(()=>{e({type:"CLEAR_PLUGINS_EVALUATED"})},[t,a,s,o,i]),(0,l.Nf)(()=>{n&&requestAnimationFrame(()=>{hr(r);var t=Vt(r);t&&e({type:"SET_SAFE_ZONE_INSET",payload:{safeZoneInset:t}})})},[n]),ur((0,l.Kr)(()=>[c,u,d,p,h,P,f,g,v,y,m,b,E],[]),()=>{hr(r)})}(),function(){var{layoutRefs:e}=z();(0,l.vJ)(()=>{if(e.appContainerRef.current)return document.addEventListener("focusin",t),document.addEventListener("focusout",r),document.addEventListener("pointerdown",n),()=>{document.removeEventListener("focusin",t),document.removeEventListener("focusout",r),document.removeEventListener("pointerdown",n)};function t(e){e.target.dataset.focusVisible="keyboard"===(0,s.a)()}function r(e){delete e.target.dataset.focusVisible}function n(){delete document.activeElement.dataset.focusVisible}},[e.appContainerRef])}(),(0,c.FD)("div",{id:"".concat(e,"-im-app"),className:["im-o-app","im-o-app--".concat(t),"im-o-app--".concat(r),"im-o-app--".concat(u?"fullscreen":"inline"),"im-o-app--".concat((null==p?void 0:p.appColorScheme)||n,"-app"),a&&"im-o-app--exclusive-control"].filter(Boolean).join(" "),style:ln({backgroundColor:(null==p?void 0:p.backgroundColor)||void 0},Ke(p)),ref:o.appContainerRef,children:[(0,c.Y)(cr,{}),(0,c.FD)("div",{className:"im-o-app__overlay".concat(i?"":" im-o-app__overlay--not-ready"),children:[(0,c.Y)("div",{className:"im-o-app__side",ref:o.sideRef,children:(0,c.Y)(en,{slot:R.SIDE})}),(0,c.FD)("div",{className:"im-o-app__main",ref:o.mainRef,children:[["mobile","tablet"].includes(t)&&(0,c.Y)("div",{className:"im-o-app__banner",ref:o.bannerRef,children:(0,c.Y)(en,{slot:R.BANNER})}),(0,c.FD)("div",{className:"im-o-app__top",ref:o.topRef,children:[(0,c.Y)("div",{className:"im-o-app__top-col",ref:o.topLeftColRef,children:(0,c.Y)(en,{slot:R.TOP_LEFT})}),(0,c.FD)("div",{className:"im-o-app__top-col",children:[(0,c.Y)(en,{slot:R.TOP_MIDDLE}),["desktop"].includes(t)&&(0,c.Y)("div",{className:"im-o-app__banner",ref:o.bannerRef,children:(0,c.Y)(en,{slot:R.BANNER})})]}),(0,c.Y)("div",{className:"im-o-app__top-col",ref:o.topRightColRef,children:(0,c.Y)(en,{slot:R.TOP_RIGHT})})]}),(0,c.FD)("div",{className:"im-o-app__left",ref:o.leftRef,children:[(0,c.Y)("div",{className:"im-o-app__left-top",ref:o.leftTopRef,children:(0,c.Y)(en,{slot:R.LEFT_TOP})}),(0,c.Y)("div",{className:"im-o-app__left-bottom",ref:o.leftBottomRef,children:(0,c.Y)(en,{slot:R.LEFT_BOTTOM})})]}),(0,c.Y)("div",{className:"im-o-app__middle",ref:o.middleRef,children:(0,c.Y)(en,{slot:R.MIDDLE})}),(0,c.FD)("div",{className:"im-o-app__right",ref:o.rightRef,children:[(0,c.Y)("div",{className:"im-o-app__right-top",ref:o.rightTopRef,children:(0,c.Y)(en,{slot:R.RIGHT_TOP})}),(0,c.Y)("div",{className:"im-o-app__right-bottom",ref:o.rightBottomRef,children:(0,c.Y)(en,{slot:R.RIGHT_BOTTOM})})]}),(0,c.FD)("div",{className:"im-o-app__bottom",ref:o.bottomRef,children:[(0,c.FD)("div",{className:"im-o-app__bottom-col",children:[(0,c.Y)(fr,{}),(0,c.Y)("div",{className:"im-o-app__bottom-left",children:(0,c.Y)(en,{slot:R.BOTTOM_LEFT})})]}),(0,c.FD)("div",{className:"im-o-app__bottom-col",children:[(0,c.Y)("div",{className:"im-o-app__bottom-right",ref:o.bottomRightRef,children:(0,c.Y)(en,{slot:R.BOTTOM_RIGHT})}),(0,c.Y)("div",{className:"im-o-app__attributions",ref:o.attributionsRef,children:(0,c.Y)(gr,{})})]})]}),(0,c.Y)("div",{className:"im-o-app__drawer",ref:o.drawerRef,children:(0,c.Y)(en,{slot:R.DRAWER})}),(0,c.Y)("div",{className:"im-o-app__actions",ref:o.actionsRef,children:(0,c.Y)(en,{slot:R.ACTIONS})}),(0,c.FD)("div",{className:"im-o-app__modal",ref:o.modalRef,children:[(0,c.Y)(en,{slot:R.MODAL}),(0,c.Y)("div",{className:"im-o-app__modal-backdrop"})]})]})]}),(0,c.Y)(an,{}),(0,c.Y)(on,{})]})},un=e=>((0,l.vJ)(()=>{(0,s.b)(),e.eventBus.emit(s.E.APP_READY)},[]),(0,c.Y)(H,{options:e,children:(0,c.Y)(Ne,{options:e,children:(0,c.Y)(ut,{eventBus:e.eventBus,children:(0,c.FD)(ft,{children:[(0,c.Y)(Ct,{}),(0,c.Y)(cn,{})]})})})})),dn=["id","load","manifest"],pn=["InitComponent","api","reducer"],hn=["MapProvider","mapProviderConfig","mapFramework","plugins"];function fn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function gn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fn(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var vn,yn=new WeakMap,mn=new WeakMap,bn=new WeakMap,En=(vn=(0,i.A)(function*(e,t){for(var r of e)if("function"==typeof r.load){var n=yield r.load(),{id:i,load:a,manifest:s}=r,l=(0,o.A)(r,dn),{InitComponent:c,api:u,reducer:d}=n;t({id:i,InitComponent:c,api:u,reducer:d,config:l,manifest:Ie((0,o.A)(n,pn),s),_originalPlugin:r})}}),function(e,t){return vn.apply(this,arguments)});function Pn(e,t){return On.apply(this,arguments)}function On(){return On=(0,i.A)(function*(e,t){var r,{MapProvider:n,mapProviderConfig:i,mapFramework:l,plugins:u=[]}=t,d=(0,o.A)(t,hn),{eventBus:p}=d,h=mn.get(e);h||(h=new n({mapFramework:l,mapProviderConfig:i,events:s.E,eventBus:p}),mn.set(e,h)),null!==(r=h.capabilities)&&void 0!==r&&r.supportedShortcuts&&function(){Z=new Set(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[])}(h.capabilities.supportedShortcuts);var{buttonRegistry:f,panelRegistry:g,controlRegistry:v,pluginRegistry:b}=(e=>{var t,r,n=bn.get(e);if(!n){var o=function(){var e={};return{registerButton:t=>{e=y(e,t)},addButton:(t,r)=>(e=m(e,t,r),t),getButtonConfig:t=>((e,t)=>t?Object.fromEntries(Object.entries(e).filter(e=>{var[r,n]=e;return n.pluginId===t})):e)(e,t),clear:()=>{e={}}}}(),i=(r={},{registerPanel:e=>{r=O(r,e)},addPanel:(e,t)=>(r=S(r,e,t))[e],removePanel:e=>{r=w(r,e)},getPanelConfig:()=>r,clear:()=>{r={}}}),a=(t={},{registerControl:e=>{t=x(t,e)},addControl:(e,r)=>(t=I(t,e,r))[e],getControlConfig:()=>t,clear:()=>{t={}}});n={buttonRegistry:o,panelRegistry:i,controlRegistry:a,pluginRegistry:_e({registerButton:o.registerButton,registerPanel:i.registerPanel,registerControl:a.registerControl})},bn.set(e,n)}return n})(e),{registerPlugin:E}=b;b.clear(),E({id:"appConfig",manifest:ue});var P=yn.get(e);P||(P=(0,a.Hr)(e),yn.set(e,P));var _={_root:P,on:p.on,off:p.off,emit:p.emit,unmount(){var t,r;P.unmount(),yn.delete(e),null===(t=(r=h).destroyMap)||void 0===t||t.call(r),mn.delete(e),b.clear()}};return yield En(u,E),P.render((0,c.Y)(un,gn(gn({},d),{},{buttonRegistry:f,panelRegistry:g,controlRegistry:v,pluginRegistry:b,mapProvider:h}))),_}),On.apply(this,arguments)}},235:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var n=r(321),o=r(585),i=r(407);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}r(452),r(247);var s=(e,t,r)=>{var{hasStroke:n,strokeLayerId:s}=t;if(n&&!e.getLayer(s)){var l=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){(0,o.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({"line-color":(0,i.a)(t.style.stroke,r),"line-width":t.style.strokeWidth||1,"line-opacity":t.opacity},t.style.strokeDashArray?{"line-dasharray":t.style.strokeDashArray}:{}),c=t.getStrokeSource(l);e.addLayer(c)}},l=(e,t,r,n,o,a)=>{var c,{sourceId:u,source:d}=t;d&&!e.getSource(u)&&e.addSource(u,d);var p=r.id;return((e,t,r,n,o)=>{var{hasSymbol:a,symbolLayerId:s}=t;if(a&&n&&s&&!e.getLayer(s)){var l=n.getSymbolDef(t.style);if(l){var c=n.getSymbolImageId(t.style,r,!1,o);if(c){var u=(0,i.g)(t.style,l);e.addLayer(t.getSymbolSource(c,u,l))}}}})(e,t,r,n,a),function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,{hasFill:a,fillLayerId:s}=t;if(a&&s&&!e.getLayer(s)){var l=n.getPatternImageId(t.style,r,o),c=l?{"fill-pattern":l,"fill-opacity":t.opacity}:{"fill-color":(0,i.a)(t.style.fill,r),"fill-opacity":t.opacity};e.addLayer(t.getFillSource(c))}}(e,t,p,o,a),s(e,t,p),null!==(c=t.sublayers)&&void 0!==c&&c.length?(t.sublayers.forEach(t=>{l(e,t,r,n,o,a)}),u):t.isSublayer?void 0:u},c=e=>{var[t,r]=e,n=(e=>e<=.25?"left":e>=.75?"right":"")(t),o=(e=>e<=.25?"top":e>=.75?"bottom":"")(r);return o+(n&&o?"-":"")+n||"center"};function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach(function(t){(0,o.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class p extends i.D{get visibility(){return this.visible?"visible":"none"}get fillLayerId(){return this.hasSublayers||this.hasSymbol?null:this.hasFill?this.id:null}get strokeLayerId(){return this.hasSublayers||this.hasSymbol?null:this.hasStroke?this.hasFill?"".concat(this.id,"-stroke"):this.id:null}get symbolLayerId(){return this.hasSublayers?null:this.hasSymbol?this.id:null}get layerIds(){return this.hasSublayers?this.sublayers.flatMap(e=>e.layerIds).filter(Boolean):[this.symbolLayerId,this.fillLayerId,this.strokeLayerId].filter(Boolean)}getLayersWithValue(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=[];if(!1===t||this[t]){var n=[this.symbolLayerId,this.fillLayerId,this.strokeLayerId].filter(Boolean);if(n.length){var o=this[e];r.push({layerIds:n,[e]:o})}}return this.hasSublayers&&this.sublayers.forEach(n=>{(!1===t||n[t])&&r.push(n.getLayersWithValue(e)[0])}),r}getLayersWithVisibility(){return this.getLayersWithValue("visibility")}getLayersWithOpacity(){return this.getLayersWithValue("opacity")}getLayersWithFilters(){return this.getLayersWithValue("filter","hasHiddenFeatures")}get sourceId(){if(this.isSublayer)return this.parent.sourceId;if(this.hasDynamicGeoJSON)return this.dynamicGeoJSON.sourceId;if(this.tiles){var e=Array.isArray(this.tiles)?this.tiles.join(","):this.tiles;return"tiles-".concat((0,i.h)(e))}return this.geojson?"string"==typeof this.geojson?"geojson-".concat((0,i.h)(this.geojson)):"geojson-".concat(this.id):"source-".concat(this.id)}_geojsonIdStrategy(){var e;return this.idProperty?{promoteId:this.idProperty}:this.generateIds?{generateId:!0}:(null!==(e=this.geojson)&&void 0!==e&&null!==(e=e.features)&&void 0!==e&&e.some(e=>"string"==typeof e.id)&&i.l.warn('Dataset "'.concat(this.id,'" has GeoJSON features with string native IDs. MapLibre only surfaces integer native feature IDs through queryRenderedFeatures. Use idProperty to promote a string property instead.')),{})}get source(){if(this.hasDynamicGeoJSON)return this.dynamicGeoJSON.source;if(this.tiles){var e={type:"vector",tiles:this.tiles,minzoom:this.minZoom||0,maxzoom:this.maxZoom||22};return this.idProperty&&this.sourceLayer&&(e.promoteId={[this.sourceLayer]:this.idProperty}),e}return this.geojson?d({type:"geojson",data:this.geojson},this._geojsonIdStrategy()):null}getSymbolSource(e,t,r){return d({id:this.symbolLayerId,type:"symbol",source:this.sourceId,"source-layer":this.sourceLayer,minzoom:this.minZoom,maxzoom:this.maxZoom,layout:{visibility:this.visibility,"icon-image":e,"icon-anchor":c(t||(null==r?void 0:r.anchor)||[.5,.5]),"icon-allow-overlap":!0}},this.filter?{filter:this.filter}:{})}getFillSource(e){return d({id:this.fillLayerId,type:"fill",source:this.sourceId,"source-layer":this.sourceLayer,minzoom:this.minZoom,maxzoom:this.maxZoom,layout:{visibility:this.visibility},paint:e},this.filter?{filter:this.filter}:{})}getStrokeSource(e){return d({id:this.strokeLayerId,type:"line",source:this.sourceId,"source-layer":this.sourceLayer,minzoom:this.minZoom,maxzoom:this.maxZoom,layout:{visibility:this.visibility},paint:e},this.filter?{filter:this.filter}:{})}get _hiddenFeaturesIdExpression(){return this.hasDynamicGeoJSON?this.dynamicGeoJSON.hiddenFeaturesIdExpression:this.idProperty?["to-string",["get",this.idProperty]]:["to-string",["id"]]}get _hiddenFeaturesFilter(){var e,t=null===(e=this.hiddenFeatures)||void 0===e?void 0:e.filter(e=>-1!==e);return null!=t&&t.length?["!",["in",this._hiddenFeaturesIdExpression,["literal",t.map(String)]]]:null}get filter(){var e,t=["all"];null!==(e=this.parent)&&void 0!==e&&e.filter&&t.push(this.parent.filter),this._datasetDefinition.filter&&t.push(this._datasetDefinition.filter);var r=this._hiddenFeaturesFilter;return r&&t.push(r),1===t.length?null:t.length>2?t:t[1]}}class h{constructor(e,t,r){this._mapProvider=e,this._map=e.map,this._symbolRegistry=t,this._patternRegistry=r,this._datasetSourceMap=new Map,window._datasetSourceMap=this._datasetSourceMap,this._symbolLayerIds=new Set}createDataset(e){return new p(e)}init(e){var t=this;return(0,n.A)(function*(){var{patternConfigs:r,symbolConfigs:n}=i.d.getPatternAndSymbolConfigs();yield t.addPatternsAndSymbolsToMap(r,n,e),t._symbolLayerIds.clear(),i.d.forEachDataset(r=>t._addLayers(r,e)),yield new Promise(e=>t._map.once("idle",e))})()}removeLayer(e){this._map.getLayer(e)&&this._map.removeLayer(e),this._symbolLayerIds.delete(e)}addPatternsAndSymbolsToMap(e,t,r){var o=this;return(0,n.A)(function*(){var n=r.id;return Promise.all([o._mapProvider.addPatternsToMap(e,n,o._patternRegistry),o._mapProvider.addSymbolsToMap(t,r,o._symbolRegistry)])})()}destroy(){var e=new Set;i.d.forEachDataset(t=>{var r=t.sourceId;this._getLayersUsingSource(r).forEach(e=>this.removeLayer(e)),!e.has(r)&&this._map.getSource(r)&&(this._map.removeSource(r),e.add(r))}),this._datasetSourceMap.clear()}onMapStyleChange(e,t){var r=this;return(0,n.A)(function*(){yield new Promise(e=>r._map.once("idle",e));var{patternConfigs:n,symbolConfigs:o}=i.d.getPatternAndSymbolConfigs();yield r.addPatternsAndSymbolsToMap(n,o,e),r._symbolLayerIds.clear(),i.d.forEachDataset(t=>{r._addLayers(t,e),r._applyFeatureFilter(t)}),t.forEach(e=>e.reapply())})()}onMapSizeChange(e){var t=this;return(0,n.A)(function*(){var{patternConfigs:r,symbolConfigs:n}=i.d.getPatternAndSymbolConfigs();yield t.addPatternsAndSymbolsToMap(r,n,e),i.d.forEach(r=>{var{fillLayerId:n,symbolLayerId:o}=r;if(o&&t._symbolLayerIds.has(o)&&t._map.getLayer(o)){var i=t._symbolRegistry.getSymbolImageId(r.style,e,!1,t._pixelRatio);i&&t._map.setLayoutProperty(o,"icon-image",i)}else if(n&&t._map.getLayer(n)){var a=t._patternRegistry.getPatternImageId(r.style,e.id,t._pixelRatio);a&&t._map.setPaintProperty(n,"fill-pattern",a)}})})()}addDataset(e,t){var r=this;return(0,n.A)(function*(){var n=i.d.getDataset(e);yield r.addPatternsAndSymbolsToMap(n.patternConfigs,n.symbolConfigs,t),r._addLayers(n,t)})()}removeDataset(e){var t=i.d.getDataset(e);if(t){var{sourceId:r,layerIds:n}=t;n.forEach(e=>this.removeLayer(e));var o=i.d.topLevelDatasets().filter(t=>t.id!==e&&t.sourceId===r).length>0;!o&&this._map.getSource(r)&&this._map.removeSource(r),this._datasetSourceMap.delete(e)}}applyFeatureFilter(e){var t=i.d.getDataset(e);t&&this._applyFeatureFilter(t)}applyStyle(e,t){var r=this;return(0,n.A)(function*(){var n=i.d.getDataset(e);n.layerIds.forEach(e=>r.removeLayer(e)),yield r.addPatternsAndSymbolsToMap(n.patternConfigs,n.symbolConfigs,t),r._addLayers(n,t)})()}applyDatasetOpacity(e){var t=i.d.getDataset(e);t&&this._applyRegistryDatasetOpacity(t)}_applyRegistryDatasetOpacity(e){e.getLayersWithOpacity().forEach(e=>{var{layerIds:t,opacity:r}=e;t.forEach(e=>this._setPaintOpacity(e,r))})}applyGlobalOpacity(){i.d.forEachDataset(e=>this._applyRegistryDatasetOpacity(e))}setData(e,t){var r=this._datasetSourceMap.get(e);if(r){var n=this._map.getSource(r);n&&"function"==typeof n.setData&&n.setData(t)}}get _pixelRatio(){return this._mapProvider.map.getPixelRatio()}_addLayers(e,t){var r=l(this._map,e,t,this._symbolRegistry,this._patternRegistry,this._pixelRatio);this._datasetSourceMap.set(e.id,r),this._maintainSymbolOrdering(e)}_getFirstSymbolLayerId(){var e,t=this._map.getStyle();if(null==t||!t.layers)return null;var r=t.layers.find(e=>this._symbolLayerIds.has(e.id));return null!==(e=null==r?void 0:r.id)&&void 0!==e?e:null}_maintainSymbolOrdering(e){var t=(e=e.isSublayer?e.parent:e).layerIds.filter(e=>e&&this._map.getLayer(e));t.forEach(e=>{var t;"symbol"===(null===(t=this._map.getLayer(e))||void 0===t?void 0:t.type)?this._symbolLayerIds.add(e):this._symbolLayerIds.delete(e)});var r=this._getFirstSymbolLayerId();r&&t.forEach(e=>{this._symbolLayerIds.has(e)||this._map.moveLayer(e,r)})}applyDatasetVisibility(e){var t=i.d.getDataset(e);t&&this._applyRegistryDatasetVisibility(t)}_applyRegistryDatasetVisibility(e){e.getLayersWithVisibility().forEach(e=>{var{layerIds:t,visibility:r}=e;t.forEach(e=>{this._map.getLayer(e)&&this._map.setLayoutProperty(e,"visibility",r)})})}applyGlobalVisibility(){i.d.forEachDataset(e=>this._applyRegistryDatasetVisibility(e))}_applyFeatureFilter(e){e.getLayersWithFilters().forEach(e=>{var{layerIds:t,filter:r}=e;t.forEach(e=>{this._map.getLayer(e)&&this._map.setFilter(e,r)})})}_setPaintOpacity(e,t){var r=this._map.getLayer(e);if(r){var n={line:"line-opacity",symbol:"icon-opacity"}[r.type]||"fill-opacity";this._map.setPaintProperty(e,n,t)}}_getLayersUsingSource(e){var t=this._map.getStyle();return null!=t&&t.layers?t.layers.filter(t=>t.source===e).map(e=>e.id):[]}}},407:(e,t,r)=>{r.d(t,{D:()=>Y,a:()=>re,d:()=>W,g:()=>pe,h:()=>j,l:()=>O,m:()=>Me});var n=r(452),o=r(247),i=r(585),a=r(321);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var c=e=>{var{datasets:t=[]}=e,r=[],n=t.filter(e=>{var t;return e.showInMenu||(null===(t=e.sublayers)||void 0===t?void 0:t.some(e=>e.showInMenu))}),o=new Map;return n.forEach(e=>{var t;if(null!==(t=e.sublayers)&&void 0!==t&&t.length){var n=e.sublayers.filter(t=>e.showInMenu?!1!==t.showInMenu:t.showInMenu);if(!n.length)return;r.push({id:e.id,groupLabel:e.label,visibleWhen:!0,type:"checkbox",items:n.map(t=>({id:"".concat(e.id,"-").concat(t.id),label:t.label}))})}else if(e.groupLabel){var i=o.has(e.groupLabel)?o.get(e.groupLabel):{id:e.groupLabel,groupLabel:e.groupLabel,visibleWhen:!0,type:"checkbox",items:[]};o.has(e.groupLabel)||(o.set(e.groupLabel,i),r.push(i)),i.items.push({id:e.id,label:e.label})}else r.push({visibleWhen:!0,type:"checkbox",id:e.id,items:[{id:e.id,label:e.label}]})}),r},u=(e,t)=>e.reduce((e,r)=>{var n=r.items.filter(e=>!t.includes(e.id));return n.length&&e.push(l(l({},r),{},{items:n})),e},[]);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var h={minZoom:6,maxZoom:24,showInKey:!1,showInMenu:!1,visible:!0,style:{stroke:"#d4351c",strokeWidth:2,fill:"transparent",symbolDescription:"red outline"}},f=["stroke","strokeWidth","strokeDashArray","fill","fillPattern","fillPatternSvgContent","fillPatternForegroundColor","fillPatternBackgroundColor","opacity","symbolDescription","keySymbolShape","symbol","symbolSvgContent","symbolViewBox","symbolAnchor","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"],g=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"],v=e=>g.some(t=>t in e);function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var b=(e,t)=>{var r,{id:n}=t,o=(e=>{!0!==e.visible&&!1!==e.visible&&(e.visible="hidden"!==e.visibility);var t=p(p(p({},h),e),{},{style:p(p({},h.style),e.style)}),r=e.style||{};return!("symbolDescription"in r)&&v(r)&&delete t.style.symbolDescription,f.forEach(e=>delete t[e]),t})(t);t.parentId&&("showInKey"in t||delete o.showInKey,"showInMenu"in t||delete o.showInMenu),e[n]=o;var{orderedDatasets:i}=e;i.push(n);var a=null===(r=t.sublayers)||void 0===r?void 0:r.map(e=>((e,t)=>{var r="".concat(e,"-").concat(t.id),n=t.id;return"hidden"!==t.visibility&&(t.visibility="visible"),m(m({},t),{},{id:r,parentId:e,sublayerId:n})})(n,e));if(null!=a&&a.length){var s=null==a?void 0:a.map(e=>e.id),l=null==a?void 0:a.reduce(b,{orderedDatasets:i});return e[n].sublayerIds=s,delete e[n].sublayers,m(m(m({},e),l),{},{orderedDatasets:i})}return m(m({},e),{},{orderedDatasets:i})},E=e=>{var t=(e.datasets||[]).reduce(b,{orderedDatasets:[]}),{orderedDatasets:r}=t;return delete t.orderedDatasets,m(m({},e),{},{mappedDatasets:t,orderedDatasets:r})},P="[interactive-map]",O={warn:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return console.warn(P,...t)},error:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return console.error(P,...t)}};function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function w(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?S(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var _,M=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"not found";return!!e.mappedDatasets[t]||(O.error("".concat(r,": Dataset with id '").concat(t,"' ").concat(n)),!1)},x=0,I=(e,t,r)=>(x=r.actionsArray.length?x+1:0,w(w({},r),{},{actionsArray:[...r.actionsArray,{method:e,parameters:t,actionId:x}]})),A={SET_DATASETS:(e,t)=>{var{datasets:r,mappedDatasets:n,orderedDatasets:o}=t,i=t.menu||c({datasets:r});return w(w({},e),{},{mappedDatasets:n,orderedDatasets:o,menu:i})},ADD_DATASET:(e,t)=>{var{dataset:r,mapStyle:n}=t;if(e.mappedDatasets[r.id])return O.error("addDataset: Dataset with id '".concat(r.id,"' already exists")),e;var{mappedDatasets:o,orderedDatasets:i}=E({datasets:[r]}),a=((e,t)=>{var r=[...e.menu],n=c({datasets:[t]}),o=r.find(e=>e.groupLabel===n[0].groupLabel);return o?o.items.push(...n[0].items):r.push(...n),r})(e,r);return I("addDataset",[r.id,n],w(w({},e),{},{mappedDatasets:w(w({},e.mappedDatasets),o),orderedDatasets:[...e.orderedDatasets,...i],menu:a}))},REMOVE_DATASET:(e,t)=>{var r,{id:n}=t;if(!M(e,n,"removeDataset"))return e;var o=w({},e.mappedDatasets),i=[n,...(null===(r=o[n])||void 0===r?void 0:r.sublayerIds)||[]];i.forEach(e=>delete o[e]);var a=e.orderedDatasets.filter(e=>!i.includes(e));return w(w({},e),{},{mappedDatasets:o,orderedDatasets:a,menu:u(e.menu,i)})},SET_DATASET_VISIBILITY:(e,t)=>{var{datasetId:r,visible:n}=t;return M(e,r,"setDatasetVisibility")?I("applyDatasetVisibility",[r,n],w(w({},e),{},{mappedDatasets:w(w({},e.mappedDatasets),{},{[r]:w(w({},e.mappedDatasets[r]),{},{visible:n})})})):e},SET_GLOBAL_VISIBILITY:(e,t)=>{var{visible:r}=t;return I("applyGlobalVisibility",[r],w(w({},e),{},{globals:w(w({},e.globals),{},{visible:r})}))},SET_DATASET_STYLE:(e,t)=>{var{datasetId:r,styleChanges:n,mapStyle:o}=t;if(!M(e,r,"setDatasetStyle"))return e;var i=w(w({},e.mappedDatasets[r].style),n),a=w(w(w({},e.mappedDatasets[r]),n),{},{style:i});return I("applyStyle",[r,o],w(w({},e),{},{mappedDatasets:w(w({},e.mappedDatasets),{},{[r]:a})}))},SET_OPACITY:(e,t)=>{var{datasetId:r,opacity:n}=t;if(!M(e,r,"setOpacity"))return e;var o=w(w({},e.mappedDatasets[r].style),{},{opacity:n}),i=w(w({},e.mappedDatasets[r]),{},{style:o});return I("applyDatasetOpacity",[r],w(w({},e),{},{mappedDatasets:w(w({},e.mappedDatasets),{},{[r]:i})}))},SET_GLOBAL_OPACITY:(e,t)=>{var{opacity:r}=t;return I("applyGlobalOpacity",[],w(w({},e),{},{globals:w(w({},e.globals),{},{opacity:r})}))},HIDE_FEATURES:(e,t)=>{var{datasetId:r,featureIds:n}=t;if(!M(e,r,"setFeatureVisibility - hideFeatures"))return e;var o=w({},e.mappedDatasets[r]),i=o.hiddenFeatures||[],a=Array.from(new Set([...i,...n]));return o.hiddenFeatures=a,I("applyFeatureFilter",[r],w(w({},e),{},{mappedDatasets:w(w({},e.mappedDatasets),{},{[r]:o})}))},SHOW_FEATURES:(e,t)=>{var{datasetId:r,featureIds:n}=t;if(!M(e,r,"setFeatureVisibility - showFeatures"))return e;var o=w({},e.mappedDatasets[r]),i=(o.hiddenFeatures||[]).filter(e=>!n.includes(e));return o.hiddenFeatures=i.length?i:[-1],I("applyFeatureFilter",[r],w(w({},e),{},{mappedDatasets:w(w({},e.mappedDatasets),{},{[r]:o})}))},REMOVE_ADAPTER_ACTIONS:(e,t)=>null!=t&&t.length?w(w({},e),{},{actionsArray:e.actionsArray.filter(e=>!t.includes(e))}):e,SET_GLOBAL_STATE:(e,t)=>I("applyGlobalOpacity",[],w(w({},e),{},{globals:w(w({},e.globals),t)}))},T={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_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"},C=(_=(0,a.A)(function*(e,t,r,n){var o=r(e,t),i="string"==typeof o?{url:o}:o,{url:a,headers:s={}}=i,l=yield fetch(a,{headers:s,signal:n});if(!l.ok)throw new Error("Failed to fetch GeoJSON: ".concat(l.status," ").concat(l.statusText));var c=yield l.json();if("FeatureCollection"===c.type)return c;if("Feature"===c.type)return{type:"FeatureCollection",features:[c]};if(Array.isArray(c))return{type:"FeatureCollection",features:c};throw new Error("Invalid GeoJSON response")}),function(e,t,r,n){return _.apply(this,arguments)}),L=(e,t)=>!(!e||!t||e[2]<t[0]||e[0]>t[2]||e[3]<t[1]||e[1]>t[3]),D=e=>{var t=1/0,r=1/0,n=-1/0,o=-1/0,i=(e,a)=>{var s;0===a?(s=e,t=Math.min(t,s[0]),r=Math.min(r,s[1]),n=Math.max(n,s[0]),o=Math.max(o,s[1])):e.forEach(e=>i(e,a-1))};switch(e.type){case"Point":i(e.coordinates,0);break;case"LineString":case"MultiPoint":i(e.coordinates,1);break;case"Polygon":case"MultiLineString":i(e.coordinates,2);break;case"MultiPolygon":i(e.coordinates,3);break;case"GeometryCollection":e.geometries.forEach(e=>{var i=D(e);t=Math.min(t,i[0]),r=Math.min(r,i[1]),n=Math.max(n,i[2]),o=Math.max(o,i[3])});break;default:throw new Error("Unsupported geometry type: ".concat(e.type))}return[t,r,n,o]},k=e=>{var t,r,n,{dynamicGeoJSON:o,map:i,onUpdate:s}=e,{url:l,idProperty:c,transformRequest:u,maxFeatures:d,minZoom:p=0}=o,h=new Map,f=null,g=null,v=()=>({type:"FeatureCollection",features:Array.from(h.values()).map(e=>e.feature)}),y=function(){var e=(0,a.A)(function*(){var e=i.getZoom();if(!(e<p)){var t=(e=>{var t=e.getBounds();return[t.getWest(),t.getSouth(),t.getEast(),t.getNorth()]})(i);if(!(f&&(r=f,n=t,r&&n&&n[0]>=r[0]&&n[1]>=r[1]&&n[2]<=r[2]&&n[3]<=r[3]))){var r,n,a,y;g&&g.abort(),g=new AbortController;try{var m={bbox:t,zoom:e},b=yield C(l,m,u,g.signal),E=Date.now();b.features.forEach(e=>{var t=(e=>{var t,r;return c&&null!==(t=null===(r=e.properties)||void 0===r?void 0:r[c])&&void 0!==t?t:e.id})(e);null!=t?h.set(t,{feature:e,bbox:D(e.geometry),lastSeenAt:E}):console.warn("Feature missing ID, skipping:",e)}),y=t,f=(a=f)?[Math.min(a[0],y[0]),Math.min(a[1],y[1]),Math.max(a[2],y[2]),Math.max(a[3],y[3])]:[...y];var P=h.size;(e=>{if(d&&!(h.size<=1.2*d)){var t=d,r=[],n=[];for(var[o,i]of h)L(i.bbox,e)?r.push(o):n.push({id:o,lastSeenAt:i.lastSeenAt});n.sort((e,t)=>e.lastSeenAt-t.lastSeenAt);for(var a=h.size-t,s=0;s<a&&s<n.length;s++)h.delete(n[s].id);if(h.size>t)for(var l=h.size-t,c=r.map(e=>({id:e,lastSeenAt:h.get(e).lastSeenAt})).sort((e,t)=>e.lastSeenAt-t.lastSeenAt),u=0;u<l&&u<c.length;u++)h.delete(c[u].id)}})(t),h.size<P&&(f=t),s(o.id,v())}catch(e){if("AbortError"===e.name)return;console.error("Failed to fetch dynamic GeoJSON for ".concat(o.id,":"),e)}}}});return function(){return e.apply(this,arguments)}}(),m=(t=y,(n=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(()=>t(...n),200)}).cancel=()=>{clearTimeout(r),r=null},n),b=()=>{m()};return i.on("moveend",b),y(),{destroy(){i.off("moveend",b),m.cancel(),g&&g.abort()},clear(){h.clear(),f=null,s(o.id,{type:"FeatureCollection",features:[]})},refresh(){h.clear(),f=null,y()},getFeatureCount:()=>h.size,reapply(){h.size>0&&s(o.id,v())}}},j=e=>{var t=0;for(var r of e)t=Math.trunc((t<<5)-t+r.codePointAt(0));return Math.abs(t).toString(36)};function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}class N{constructor(e){this.id=e.id,this.url=e.url,this.transformRequest=e.transformRequest,this.maxFeatures=e.maxFeatures,this.minZoom=e.minZoom,this.idProperty=e.idProperty,this.hiddenFeaturesIdExpression=["to-string",["get",this.idProperty]],this.sourceId="geojson-dynamic-".concat(this.id),this.source=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({type:"geojson",data:{type:"FeatureCollection",features:[]}},this.idProperty?{promoteId:this.idProperty}:{generateId:!0})}}var F={};window.getGlobalState=()=>Object.freeze(F);var B=()=>F.visible;function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Y{constructor(e){this._datasetDefinition=e}get id(){return this._datasetDefinition.id}get label(){return this._datasetDefinition.label}get hasSymbol(){var e;return!this.hasSublayers&&Boolean(null===(e=this.style)||void 0===e?void 0:e.symbol)}get hasPattern(){return!(this.hasSublayers||this.hasSymbol||(e=this.style,!e.fillPattern&&!e.fillPatternSvgContent));var e}get hasFill(){var e,t;return!this.hasSublayers&&!this.hasSymbol&&(this.hasPattern||(null===(e=this.style)||void 0===e?void 0:e.fill)&&"transparent"!==(null===(t=this.style)||void 0===t?void 0:t.fill))}get hasStroke(){var e;return!this.hasSublayers&&!this.hasSymbol&&Boolean(null===(e=this.style)||void 0===e?void 0:e.stroke)}get tiles(){return this._datasetDefinition.tiles}get geojson(){return this._datasetDefinition.geojson}get idProperty(){return this._datasetDefinition.idProperty}get generateIds(){return this._datasetDefinition.generateIds}get parentId(){return this._datasetDefinition.parentId}get minZoom(){var e;return this._datasetDefinition.minZoom||(null===(e=this.parent)||void 0===e?void 0:e.minZoom)}get maxZoom(){var e;return this._datasetDefinition.maxZoom||(null===(e=this.parent)||void 0===e?void 0:e.maxZoom)}get showInKey(){var e,t,r=this._datasetDefinition.showInKey;return void 0!==r?r:null!==(e=null===(t=this.parent)||void 0===t?void 0:t.showInKey)&&void 0!==e&&e}get groupLabel(){return this._datasetDefinition.groupLabel}get opacity(){var e,t;return((e,t)=>{switch(F.opacityMode){case"global":return F.opacity;case"multiply":return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Math.round(100*(e*t*F.opacity+Number.EPSILON))/100}(e,t);default:return((e,t)=>void 0===e?void 0===t?F.opacity:t:e)(e,t)}})(null===(e=this.style)||void 0===e?void 0:e.opacity,null===(t=this.parent)||void 0===t||null===(t=t.style)||void 0===t?void 0:t.opacity)}get hasDynamicGeoJSON(){return Boolean(this._datasetDefinition.dynamicGeoJSON)}get dynamicGeoJSON(){return new N(U(U({},this._datasetDefinition.dynamicGeoJSON),{},{id:this.id,minZoom:this.minZoom}))}get hiddenFeatures(){return this._datasetDefinition.hiddenFeatures}get hasHiddenFeatures(){var e,t;return Boolean((null===(e=this.hiddenFeatures)||void 0===e?void 0:e.length)>0||(null===(t=this.parent)||void 0===t?void 0:t.hasHiddenFeatures))}get filter(){return null}get isHiddenByInheritance(){var e;return this.isSublayer?!(null!==(e=this.parent)&&void 0!==e&&e.visible):!B()}get isLocallyVisible(){return!!this.isVisible||this._datasetDefinition.visible}get visible(){var e;return this.isSublayer?this._datasetDefinition.visible&&(null===(e=this.parent)||void 0===e?void 0:e.visible):this._datasetDefinition.visible&&B()}get symbolAnchor(){var e,t;return null!==(e=this.style)&&void 0!==e&&e.symbolAnchor?this.style.symbolAnchor:null===(t=this.parent)||void 0===t?void 0:t.symbolAnchor}get sourceLayer(){return this.isSublayer?this.parent.sourceLayer:this.tiles?this._datasetDefinition.sourceLayer:void 0}get isSublayer(){return Boolean(this._datasetDefinition.parentId)}get hasSublayers(){var e;return(null===(e=this._datasetDefinition.sublayerIds)||void 0===e?void 0:e.length)>0}get sublayerIds(){return this._datasetDefinition.sublayerIds}get sublayers(){var{sublayerIds:e}=this;if(e)return e.map(e=>W.getDataset(e))}get parent(){if(this._datasetDefinition.parentId)return W.getDataset(this._datasetDefinition.parentId)}get style(){var e,t=null===(e=this.parent)||void 0===e?void 0:e.style;return t?U(U(U({},t),{},{opacity:void 0},this._datasetDefinition.style),{},{symbolDescription:this.symbolDescription}):this._datasetDefinition.style||{}}get hasCustomVisualStyle(){return v(this._datasetDefinition.style||{})}get symbolDescription(){var e,t;return null!==(e=this._datasetDefinition.style)&&void 0!==e&&e.symbolDescription?this._datasetDefinition.style.symbolDescription:this.hasCustomVisualStyle||null===(t=this.parent)||void 0===t?void 0:t.symbolDescription}get patternConfigs(){var e=this.hasPattern?[this.style]:[];return this.hasSublayers?[...e,...this.sublayers.flatMap(e=>e.patternConfigs)]:e}get symbolConfigs(){var e=this.hasSymbol?[this.style]:[];return this.hasSublayers?[...e,...this.sublayers.flatMap(e=>e.symbolConfigs)]:e}}class G{constructor(){this.idToDefinitionMap=new Map,this.definitionToInstanceMap=new Map}add(e){this.idToDefinitionMap.set(e.id,e._datasetDefinition),this.definitionToInstanceMap.set(e._datasetDefinition,e)}invalidateDataset(e){var t=this.idToDefinitionMap.get(e.id);[t.id,...(null==t?void 0:t.sublayerIds)||[]].forEach(e=>{var t=this.idToDefinitionMap.get(e);this.definitionToInstanceMap.delete(t),this.idToDefinitionMap.delete(e)})}invalidateChangedDatasets(e){e.forEach(e=>{var t=this.idToDefinitionMap.get(e.id);if(t&&t!==e){var r=this.definitionToInstanceMap.get(t);this.invalidateDataset(r.isSublayer&&r.parent?r.parent:r)}})}getByDefinition(e){return this.definitionToInstanceMap.get(e)}}function H(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function z(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var W={attach(e,t){this._datasets=e,this._orderedDatasets=t,this._invalidateChangedDatasets()},_definitionCache:new G,_invalidateCache(){this._definitionCache=new G},_invalidateChangedDatasets(){this._datasets?this._definitionCache.invalidateChangedDatasets(Object.values(this._datasets)):this._invalidateCache()},attachCreateDataset(e){this._createDataset=e},_createDataset:e=>(e=>new Y(e))(e),getDataset(e){var t=this.datasets[e];if(t){var r=this._definitionCache.getByDefinition(t);if(r)return r;var n=this._createDataset(t);return this._definitionCache.add(n),n.isSublayer&&this.getDataset(n.parentId),n}},forEach(e){this._orderedDatasets.forEach(t=>e(this.getDataset(t)))},forEachDataset(e){Object.values(this.datasets).filter(e=>!e.parentId).forEach(t=>e(this.getDataset(t.id)))},topLevelDatasets(){return Object.values(this.datasets).filter(e=>!e.parentId).map(e=>this.getDataset(e.id))},getPatternAndSymbolConfigs(){return this.topLevelDatasets().reduce((e,t)=>z(z({},e),{},{patternConfigs:[...e.patternConfigs,...t.patternConfigs],symbolConfigs:[...e.symbolConfigs,...t.symbolConfigs]}),{patternConfigs:[],symbolConfigs:[]})},_lastKeyItems:{},keyItems(){if(this.datasets===this._lastKeyItemsDatasets)return this._lastKeyItems;this._lastKeyItemsDatasets=this.datasets;var e=[],t=new Set,r=!1;return this.forEachDataset(n=>{if(n.showInKey&&n.visible)if(n.hasSublayers){var o=n.sublayers.filter(e=>e.visible);o.length&&(r=!0,e.push({type:"sublayers",dataset:n,sublayers:o}))}else if(n.groupLabel){if(t.has(n.groupLabel))return;t.add(n.groupLabel),r=!0,e.push({type:"group",groupLabel:n.groupLabel,datasets:this.topLevelDatasets().filter(e=>e.groupLabel===n.groupLabel&&!e.hasSublayers&&e.showInKey)})}else e.push({type:"flat",dataset:n})}),this._lastKeyItems={items:e,hasGroups:r},this._lastKeyItems}};Object.defineProperty(W,"datasets",{get:()=>W._datasets}),window.datasetRegistry=W;var J,K=e=>{var{adapter:t,pluginConfig:r,mapStyle:n,mapProvider:o,events:i,dispatch:a,eventBus:s}=e,{datasets:l}=r,c=new Map;r.globals&&a({type:"SET_GLOBAL_STATE",payload:r.globals});var u=l.map(e=>((e,t)=>{var r=e.style||{},n=p(p({},t.style),r);!("symbolDescription"in r)&&v(r)&&delete n.symbolDescription;var o=p({},e);delete o.style,f.forEach(e=>delete o[e]);var i=p({},t);return delete i.style,p(p(p({},i),o),n)})(e,h)),{mappedDatasets:d,orderedDatasets:g}=E({datasets:l});t.createDataset&&W.attachCreateDataset(t.createDataset),W.attach(d),t.init(n).then(()=>{W.forEachDataset(e=>{if(e.hasDynamicGeoJSON){var{dynamicGeoJSON:r}=e,n=k({dynamicGeoJSON:r,map:o.map,onUpdate:(e,r)=>t.setData(e,r)});c.set(e.id,n)}}),a({type:"SET_DATASETS",payload:{datasets:u,mappedDatasets:d,orderedDatasets:g}}),s.emit("datasets:ready")});var y=n,m=e=>{y=e,t.onMapStyleChange(e,c)},b=()=>{t.onMapSizeChange(y)};return s.on(i.MAP_SET_STYLE,m),s.on(i.MAP_SIZE_CHANGE,b),{remove(){s.off(i.MAP_SET_STYLE,m),s.off(i.MAP_SIZE_CHANGE,b),c.forEach(e=>e.destroy()),c.clear(),t.destroy()},refreshDataset(e){var t;null===(t=c.get(e))||void 0===t||t.refresh()},clearDatasetCache(e){var t;null===(t=c.get(e))||void 0===t||t.clear()},getFeatureCount(e){var t,r;return null!==(t=null===(r=c.get(e))||void 0===r?void 0:r.getFeatureCount())&&void 0!==t?t:null}}},q=function(){var e=(0,a.A)(function*(e){if("MapLibreProvider"===e.name){var{default:t}=yield r.e(402).then(r.bind(r,235));return t}throw new Error("No layer adapter available for map provider ".concat(e.name,". Please provide a compatible layer adapter."))});return function(t){return e.apply(this,arguments)}}(),Z={},X=function(){var e=(0,a.A)(function*(e,t,r){var n=yield q(e);return J=new n(e,t,r),Z.removeDataset=J.removeDataset.bind(J),Z.setData=J.setData.bind(J),Z.applyStyle=J.applyStyle.bind(J),Z.applyDatasetVisibility=J.applyDatasetVisibility.bind(J),Z.applyGlobalVisibility=J.applyGlobalVisibility.bind(J),Z.applyDatasetOpacity=J.applyDatasetOpacity.bind(J),Z.applyGlobalOpacity=J.applyGlobalOpacity.bind(J),Z.addDataset=J.addDataset.bind(J),Z.applyFeatureFilter=J.applyFeatureFilter.bind(J),J});return function(t,r,n){return e.apply(this,arguments)}}(),$=function(e,t){var{pluginState:{dispatch:r}}=e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{datasetId:o,sublayerId:i}=n,a=i?"".concat(o,"-").concat(i):o;r(a?{type:"SET_DATASET_VISIBILITY",payload:{datasetId:a,visible:t}}:{type:"SET_GLOBAL_VISIBILITY",payload:{visible:t}})},Q=e=>{var{menuGroupItem:t,onChange:r}=e,n=W.getDataset(t.id);if(!n)return null;var i=n.isSublayer?n.parentId:n.id,a=n.isSublayer?n.id:void 0,s="im-c-datasets-layers__item govuk-checkboxes govuk-checkboxes--small".concat(n.visible?"":" im-c-datasets-layers__item--checked");return(0,o.Y)("div",{className:s,"data-module":"govuk-checkboxes",children:(0,o.FD)("div",{className:"govuk-checkboxes__item",children:[(0,o.Y)("input",{className:"govuk-checkboxes__input",id:n.id,"data-dataset-id":i,"data-sublayer-id":a,name:"layers",type:"checkbox",value:n.id,checked:n.isLocallyVisible,onChange:r}),(0,o.Y)("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:n.id,children:n.label})]})},n.id)},ee=e=>{var{menuGroup:t,children:r}=e;return t.groupLabel?(0,o.Y)("div",{className:"govuk-form-group im-c-datasets-layers-group",children:(0,o.FD)("fieldset",{className:"im-c-datasets-layers-group__fieldset",children:[(0,o.Y)("legend",{className:"im-c-datasets-layers-group__legend",children:t.groupLabel}),r]})},t.id):(0,o.Y)(o.FK,{children:r})},te=e=>{var{text:t}=e;return(0,o.Y)("div",{className:"im-c-datasets-key",children:(0,o.Y)("p",{className:"im-c-datasets-key__empty-message",children:t})})},re=(e,t)=>{if(!e)return null;if("string"==typeof e)return e.trim();if("object"==typeof e){if(t&&e[t])return e[t];var r=Object.values(e)[0];return null!=r?r:null}return null};function ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function oe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ne(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ie=20,ae={xmlns:"http://www.w3.org/2000/svg",width:ie,height:ie,viewBox:"0 0 ".concat(ie," ").concat(ie),className:"am-c-datasets-key-symbol","aria-hidden":"true",focusable:"false"},se=oe(oe({},ae),{},{width:44,height:44,className:"am-c-datasets-key-symbol am-c-datasets-key-symbol--point"});function le(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ce(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?le(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):le(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ue=e=>{var{patternRegistry:t,registryDataset:r,mapStyle:n}=e,{style:i}=r,a=t.getKeyPatternPaths(i,n.id);return(0,o.FD)("svg",ce(ce({},ae),{},{children:[(0,o.Y)("g",{dangerouslySetInnerHTML:{__html:a.border}}),(0,o.Y)("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:a.content}})]}))},de=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),pe=(e,t)=>{var r;return e.symbolAnchor?e.symbolAnchor:null!==(r=null==t?void 0:t.anchor)&&void 0!==r?r:[.5,.5]};function he(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function fe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?he(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):he(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ge=e=>{var t,{symbolRegistry:r,registryDataset:n,mapStyle:i,symbolDef:a}=e,{style:s}=n,l=null!==(t=null==i?void 0:i.appColorScheme)&&void 0!==t?t:"light",c=fe(fe({},i),{},{mapColorScheme:l}),u=r.resolve(a,(e=>{if(!(e=>!(!e.symbol&&!e.symbolSvgContent))(e))return{};var t={};return de.forEach(r=>{if(null!=e[r]){var n=r.charAt(6).toLowerCase()+r.slice(7);t[n]=e[r]}}),t})(s),c),d=((e,t)=>{var r;return e.symbolViewBox?e.symbolViewBox:null!==(r=null==t?void 0:t.viewBox)&&void 0!==r?r:"0 0 38 38"})(s,a);return(0,o.Y)("svg",fe(fe({},se),{},{viewBox:d,children:(0,o.Y)("g",{dangerouslySetInnerHTML:{__html:u}})}))};function ve(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ye(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ve(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var me=e=>{var{mapStyle:t,registryDataset:r}=e,{style:n}=r;return(0,o.Y)("svg",ye(ye({},ae),{},{children:(0,o.Y)("line",{x1:n.strokeWidth/2,y1:10,x2:ie-n.strokeWidth/2,y2:10,stroke:re(n.stroke,t.id),strokeWidth:n.strokeWidth,strokeLinecap:"round"})}))};function be(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ee(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?be(Object(r),!0).forEach(function(t){(0,i.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):be(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Pe=e=>{var{mapStyle:t,registryDataset:r}=e,{style:n}=r;return(0,o.Y)("svg",Ee(Ee({},ae),{},{children:(0,o.Y)("rect",{x:n.strokeWidth/2,y:n.strokeWidth/2,width:ie-n.strokeWidth,height:ie-n.strokeWidth,rx:n.strokeWidth,ry:n.strokeWidth,fill:re(n.fill,t.id),stroke:re(n.stroke,t.id),strokeWidth:n.strokeWidth,strokeLinejoin:"round"})}))},Oe=e=>{var{symbolRegistry:t,registryDataset:r,mapStyle:n,patternRegistry:i}=e,{hasSymbol:a,hasPattern:s,style:l}=r,c=a&&t.getSymbolDef(l);return c?(0,o.Y)(ge,{mapStyle:n,registryDataset:r,symbolRegistry:t,symbolDef:c}):s?(0,o.Y)(ue,{mapStyle:n,registryDataset:r,patternRegistry:i}):"line"===l.keySymbolShape?(0,o.Y)(me,{mapStyle:n,registryDataset:r}):(0,o.Y)(Pe,{mapStyle:n,registryDataset:r})},Se=e=>{var{registryDataset:t,symbolRegistry:r,patternRegistry:n,mapStyle:i}=e;return(0,o.FD)("dl",{className:"im-c-datasets-key__item",children:[(0,o.Y)("dt",{className:"im-c-datasets-key__item-symbol",children:(0,o.Y)(Oe,{registryDataset:t,symbolRegistry:r,patternRegistry:n,mapStyle:i})}),(0,o.FD)("dd",{className:"im-c-datasets-key__item-label",children:[t.label,t.symbolDescription&&(0,o.FD)("span",{className:"govuk-visually-hidden",children:["(",re(t.symbolDescription,i.id),")"]})]})]})},we=e=>{var{headingId:t,label:r,datasets:n,symbolRegistry:i,patternRegistry:a,mapStyle:s}=e;return(0,o.FD)("section",{className:"im-c-datasets-key__group","aria-labelledby":t,children:[(0,o.Y)("h3",{id:t,className:"im-c-datasets-key__group-heading",children:r}),n.map(e=>(0,o.Y)(Se,{registryDataset:e,symbolRegistry:i,patternRegistry:a,mapStyle:s},"".concat(e.id)))]})},_e={InitComponent:function(e){var t,{pluginConfig:r,pluginState:o,appState:i,mapState:s,mapProvider:l,services:c}=e,{dispatch:u}=o,{eventBus:d,symbolRegistry:p,patternRegistry:h}=c,f=!(null===(t=l.map)||void 0===t||!t.getStyle());(0,n.li)(o).current=o;var g=(0,n.li)(null);return(0,n.vJ)(()=>{var e,t,n,o,c=null===(e=null===(t=r.includeModes)||void 0===t?void 0:t.includes(i.mode))||void 0===e||e,v=null!==(n=null===(o=r.excludeModes)||void 0===o?void 0:o.includes(i.mode))&&void 0!==n&&n;if(f&&c&&!v&&!g.current){var y=function(){var e=(0,a.A)(function*(){var e=yield X(l,p,h);g.current=K({adapter:e,pluginConfig:r,mapStyle:s.mapStyle,mapProvider:l,events:T,dispatch:u,eventBus:d})});return function(){return e.apply(this,arguments)}}();y()}},[f,i.mode]),(0,n.vJ)(()=>W.attach(o.mappedDatasets,o.orderedDatasets),[o.mappedDatasets,o.orderedDatasets]),(0,n.vJ)(()=>{return e=o.globals,void(F=e);var e},[o.globals]),(0,n.vJ)(()=>{var{actionsArray:e}=o;e.length&&(e.forEach(e=>{var{method:t,parameters:r}=e;return Z[t](...r)}),u({type:"REMOVE_ADAPTER_ACTIONS",payload:e}))},[o.actionsArray]),(0,n.vJ)(()=>()=>{g.current&&(g.current.remove(),g.current=null)},[]),null},reducer:{initialState:{globals:{visible:!0,opacity:1,opacityMode:"dataset"},key:{items:[],hasGroups:!1},actionsArray:[]},actions:A},panels:[{id:"datasetsLayers",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:e=>{var{pluginState:t}=e,{menu:r=[]}=t,n=e=>{var{value:r,checked:n}=e.target;$({pluginState:t},n,{datasetId:r})},i=r.some(e=>e.groupLabel),a="im-c-datasets-layers".concat(i?" im-c-datasets-layers--has-groups":"");return(0,o.Y)("div",{className:a,children:r.map(e=>(0,o.Y)(ee,{menuGroup:e,children:e.items.map(e=>(0,o.Y)(Q,{menuGroupItem:e,onChange:n},e.id))},e.id))})}},{id:"datasetsKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:e=>{var{pluginConfig:{noKeyItemText:t},mapState:{mapStyle:r},pluginState:{mappedDatasets:n},services:{symbolRegistry:i,patternRegistry:a}}=e,{items:s,hasGroups:l}=W.keyItems();if(null==s||!s.length)return(0,o.Y)(te,{text:t});var c="im-c-datasets-key".concat(l?" im-c-datasets-key--has-groups":"");return(0,o.Y)("div",{className:c,children:s.map(e=>{var t="group"===e.type?e.groupLabel.toLowerCase().replaceAll(/\s+/g,"-"):e.dataset.id;if("sublayers"===e.type||"group"===e.type){var n="sublayers"===e.type?e.sublayers:e.datasets,s="sublayers"===e.type?e.dataset.label:e.groupLabel;return(0,o.Y)(we,{headingId:"key-heading-".concat(t),label:s,datasets:n,symbolRegistry:i,patternRegistry:a,mapStyle:r},t)}return(0,o.Y)(Se,{registryDataset:e.dataset,symbolRegistry:i,patternRegistry:a,mapStyle:r},t)})})}}],buttons:[{id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",iconId:"layers",excludeWhen:e=>{var{pluginConfig:t}=e;return!t.datasets.some(e=>{var t;return e.showInMenu||(null===(t=e.sublayers)||void 0===t?void 0:t.some(e=>e.showInMenu))})},mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}},{id:"datasetsKey",label:"Key",panelId:"datasetsKey",iconId:"key",excludeWhen:e=>{var{pluginConfig:t}=e;return!t.datasets.some(e=>e.showInKey)},mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"layers",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addDataset:(e,t)=>{var{pluginState:{dispatch:r},mapState:n}=e;r({type:"ADD_DATASET",payload:{dataset:t,mapStyle:n.mapStyle}})},removeDataset:(e,t)=>{var{pluginState:{dispatch:r}}=e;Z.removeDataset(t),r({type:"REMOVE_DATASET",payload:{id:t}})},setDatasetVisibility:$,setFeatureVisibility:function(e,t,r){var{pluginState:{dispatch:n}}=e,{datasetId:o=null}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(o){var i=W.getDataset(o);!i||i.idProperty||i.generateIds||O.warn('setFeatureVisibility: Dataset "'.concat(o,'" has no idProperty or generateIds configured. Features may not be matched correctly. Add idProperty to match by a feature property, or add generateIds: true to use auto-generated IDs.'))}n({type:t?"SHOW_FEATURES":"HIDE_FEATURES",payload:{datasetId:o,featureIds:r}})},setStyle:function(e,t){var{pluginState:{dispatch:r},mapState:n}=e,{datasetId:o,sublayerId:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r({type:"SET_DATASET_STYLE",payload:{datasetId:o=i?"".concat(o,"-").concat(i):o,styleChanges:t,mapStyle:n.mapStyle}})},getStyle:function(e){var{pluginState:t}=e,{datasetId:r,sublayerId:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r=n?"".concat(r,"-").concat(n):r;var o=W.getDataset(r);return o?o.style:(O.warn("getStyle: Dataset with id ".concat(r," not found")),null)},setOpacity:function(e,t){var{pluginState:{dispatch:r}}=e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{datasetId:o,sublayerId:i}=n,a=i?"".concat(o,"-").concat(i):o;r(a?{type:"SET_OPACITY",payload:{datasetId:a,opacity:t}}:{type:"SET_GLOBAL_OPACITY",payload:{opacity:t}})},getOpacity:function(e){var t,{pluginState:{globals:r}}=e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{datasetId:o,sublayerId:i}=n,a=i?"".concat(o,"-").concat(i):o;if(a){var s,l=W.getDataset(a);return l?null!==(s=l.opacity)&&void 0!==s?s:null:(O.warn("getOpacity: Dataset with id ".concat(a," not found")),null)}return null!==(t=r.opacity)&&void 0!==t?t:null},setData:(e,t,r)=>{var{pluginState:n}=e,{datasetId:o}=r,i=W.getDataset(o);i?null!=i&&i.tiles?O.warn('setData called on vector tile dataset "'.concat(o,'" — has no effect')):Z.setData(o,t):O.warn("setData: Dataset with id ".concat(o," not found"))},setGlobals:(e,t)=>{var{pluginState:{dispatch:r}}=e,{opacityMode:n}=t,o={},i=!1;n&&(["dataset","global","multiply"].includes(n)?(i=!0,o.opacityMode=n):O.warn("Ignoring invalid opacityMode: ".concat(n,". Must be one of 'dataset', 'global' or 'multiply'."))),i?r({type:"SET_GLOBAL_STATE",payload:o}):O.warn("setGlobals: requires a valid value for opacityMode to be set")}}},Me=Object.freeze({__proto__:null,manifest:_e})},327:(e,t,r)=>{r.r(t),r.d(t,{manifest:()=>ji});var n=r(585),o=r(452),i=r(505);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var l=new Set(["draw_polygon","draw_line"]),c={SET_MODE:(e,t)=>s(s({},e),{},{mode:t,numVertecies:l.has(t)?0:e.numVertecies}),SET_ACTION:(e,t)=>s(s({},e),{},{action:t.name,actionValid:t.isValid}),SET_FEATURE:(e,t)=>s(s({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature}),SET_SELECTED_VERTEX_INDEX:(e,t)=>s(s({},e),{},{selectedVertexIndex:t.index,numVertecies:t.numVertecies}),TOGGLE_SNAP:e=>s(s({},e),{},{snap:!e.snap}),SET_SNAP:(e,t)=>s(s({},e),{},{snap:!!t}),SET_HAS_SNAP_LAYERS:(e,t)=>s(s({},e),{},{hasSnapLayers:!!t}),SET_UNDO_STACK_LENGTH:(e,t)=>s(s({},e),{},{undoStackLength:t})},u={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_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 d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function h(e){var t;return null!==(t=null==e?void 0:e._snapInstance)&&void 0!==t?t:null}function f(e){var t;return!!(null!=e&&e.status&&null!=e&&e.snapStatus&&(null===(t=e.snapCoords)||void 0===t?void 0:t.length)>=2)}function g(e){return f(e)?{lng:e.snapCoords[0],lat:e.snapCoords[1]}:null}function v(e,t,r){if(!e||!t||!e.status)return!1;var n=t.unproject(r);return e.snapToClosestPoint({point:r,lngLat:n}),!0}function y(e,t){var r,n,o;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(r=e.snappedFeatures)&&void 0!==r&&r.length&&(e.snappedFeatures.length=0),null!==(n=e.closeFeatures)&&void 0!==n&&n.length&&(e.closeFeatures.length=0),null!==(o=e.lines)&&void 0!==o&&o.length&&(e.lines.length=0)),null!=t&&t.getLayer("snap-helper-circle")&&t.setLayoutProperty("snap-helper-circle","visibility","none")}function m(e){var t,r,n;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(t=e.snappedFeatures)&&void 0!==t&&t.length&&(e.snappedFeatures.length=0),null!==(r=e.closeFeatures)&&void 0!==r&&r.length&&(e.closeFeatures.length=0),null!==(n=e.lines)&&void 0!==n&&n.length&&(e.lines.length=0))}function b(e){return"function"==typeof(null==e?void 0:e.getSnapEnabled)&&!0===e.getSnapEnabled()}const E={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},P={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},O={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},S={POLYGON:"polygon",LINE:"line_string",POINT:"point"},w={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},_={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},M={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},x={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},I={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},A={ACTIVE:"true",INACTIVE:"false"},T=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"];var C=Object.freeze({__proto__:null,LAT_MAX:90,LAT_MIN:-90,LAT_RENDERED_MAX:85,LAT_RENDERED_MIN:-85,LNG_MAX:270,LNG_MIN:-270,activeStates:A,classes:E,cursors:O,events:M,geojsonTypes:w,interactions:T,meta:I,modes:_,sources:P,types:S,updateActions:x});function L(e){return function(t){const r=t.featureTarget;return!!r&&!!r.properties&&r.properties.meta===e}}function D(e){return!!e.originalEvent&&!!e.originalEvent.shiftKey&&0===e.originalEvent.button}function k(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===A.ACTIVE&&e.featureTarget.properties.meta===I.FEATURE}function j(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===A.INACTIVE&&e.featureTarget.properties.meta===I.FEATURE}function R(e){return void 0===e.featureTarget}function N(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.meta===I.FEATURE}function F(e){const t=e.featureTarget;return!!t&&!!t.properties&&t.properties.meta===I.VERTEX}function B(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function V(e){return"Escape"===e.key||27===e.keyCode}function U(e){return"Enter"===e.key||13===e.keyCode}function Y(e){return"Backspace"===e.key||8===e.keyCode}function G(e){return"Delete"===e.key||46===e.keyCode}function H(e){return"1"===e.key||49===e.keyCode}function z(e){return"2"===e.key||50===e.keyCode}function W(e){return"3"===e.key||51===e.keyCode}function J(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}var K=Object.freeze({__proto__:null,isActiveFeature:k,isBackspaceKey:Y,isDeleteKey:G,isDigit1Key:H,isDigit2Key:z,isDigit3Key:W,isDigitKey:J,isEnterKey:U,isEscapeKey:V,isFeature:N,isInactiveFeature:j,isOfMetaType:L,isShiftDown:B,isShiftMousedown:D,isTrue:function(){return!0},isVertex:F,noTarget:R});function q(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z,X,$={},Q={},ee=function(){if(X)return $;X=1;var e=(Z||(Z=1,Q.RADIUS=6378137,Q.FLATTENING=1/298.257223563,Q.POLAR_RADIUS=6356752.3142),Q);function t(e){var t=0;if(e&&e.length>0){t+=Math.abs(r(e[0]));for(var n=1;n<e.length;n++)t-=Math.abs(r(e[n]))}return t}function r(t){var r,o,i,a,s,l,c=0,u=t.length;if(u>2){for(l=0;l<u;l++)l===u-2?(i=u-2,a=u-1,s=0):l===u-1?(i=u-1,a=0,s=1):(i=l,a=l+1,s=l+2),r=t[i],o=t[a],c+=(n(t[s][0])-n(r[0]))*Math.sin(n(o[1]));c=c*e.RADIUS*e.RADIUS/2}return c}function n(e){return e*Math.PI/180}return $.geometry=function e(r){var n,o=0;switch(r.type){case"Polygon":return t(r.coordinates);case"MultiPolygon":for(n=0;n<r.coordinates.length;n++)o+=t(r.coordinates[n]);return o;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(n=0;n<r.geometries.length;n++)o+=e(r.geometries[n]);return o}},$.ring=r,$}(),te=q(ee);const re={Point:0,LineString:1,MultiLineString:1,Polygon:2};function ne(e,t){const r=re[e.geometry.type]-re[t.geometry.type];return 0===r&&e.geometry.type===w.POLYGON?e.area-t.area:r}function oe(e){return e.map(e=>(e.geometry.type===w.POLYGON&&(e.area=te.geometry({type:w.FEATURE,property:{},geometry:e.geometry})),e)).sort(ne).map(e=>(delete e.area,e))}function ie(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]}function ae(e){if(this._items={},this._nums={},this._length=e?e.length:0,e)for(let t=0,r=e.length;t<r;t++)this.add(e[t]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}ae.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},ae.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},ae.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},ae.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((e,t)=>e.v-t.v).map(e=>e.k)},ae.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const se=[I.FEATURE,I.MIDPOINT,I.VERTEX];var le={click:function(e,t,r){return ce(e,t,r,r.options.clickBuffer)},touch:function(e,t,r){return ce(e,t,r,r.options.touchBuffer)}};function ce(e,t,r,n){if(null===r.map)return[];const o=e?ie(e,n):t,i={};r.options.styles&&(i.layers=r.options.styles.map(e=>e.id).filter(e=>null!=r.map.getLayer(e)));const a=r.map.queryRenderedFeatures(o,i).filter(e=>-1!==se.indexOf(e.properties.meta)),s=new ae,l=[];return a.forEach(e=>{const t=e.properties.id;s.has(t)||(s.add(t),l.push(e))}),oe(l)}function ue(e,t){const r=le.click(e,null,t),n={mouse:O.NONE};return r[0]&&(n.mouse=r[0].properties.active===A.ACTIVE?O.MOVE:O.POINTER,n.feature=r[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(n.mouse=O.ADD),t.ui.queueMapClasses(n),t.ui.updateMapClasses(),r[0]}function de(e,t){const r=e.x-t.x,n=e.y-t.y;return Math.sqrt(r*r+n*n)}function pe(e,t,r={}){const n=null!=r.fineTolerance?r.fineTolerance:4,o=null!=r.grossTolerance?r.grossTolerance:12,i=null!=r.interval?r.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;const a=de(e.point,t.point);return a<n||a<o&&t.time-e.time<i}function he(e,t,r={}){const n=null!=r.tolerance?r.tolerance:25,o=null!=r.interval?r.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,de(e.point,t.point)<n&&t.time-e.time<o}const fe=function(e,t){const r={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},n={on(e,t,n){if(void 0===r[e])throw new Error(`Invalid event type: ${e}`);r[e].push({selector:t,fn:n})},render(e){t.store.featureChanged(e)}},o=function(e,o){const i=r[e];let a=i.length;for(;a--;){const e=i[a];if(e.selector(o)){e.fn.call(n,o)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(n),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(e){o("drag",e)},click(e){o("click",e)},mousemove(e){o("mousemove",e)},mousedown(e){o("mousedown",e)},mouseup(e){o("mouseup",e)},mouseout(e){o("mouseout",e)},keydown(e){o("keydown",e)},keyup(e){o("keyup",e)},touchstart(e){o("touchstart",e)},touchmove(e){o("touchmove",e)},touchend(e){o("touchend",e)},tap(e){o("tap",e)}}},ge=((e,t=21)=>(r=t)=>{let n="",o=0|r;for(;o--;)n+=e[Math.random()*e.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function ve(){return ge()}const ye=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||ve(),this.type=t.geometry.type};ye.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},ye.prototype.incomingCoords=function(e){this.setCoordinates(e)},ye.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},ye.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},ye.prototype.setProperty=function(e,t){this.properties[e]=t},ye.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:w.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},ye.prototype.internal=function(e){const t={id:this.id,meta:I.FEATURE,"meta:type":this.type,active:A.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const r in this.properties)t[`user_${r}`]=this.properties[r];return{type:w.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const me=function(e,t){ye.call(this,e,t)};(me.prototype=Object.create(ye.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},me.prototype.updateCoordinate=function(e,t,r){this.coordinates=3===arguments.length?[t,r]:[e,t],this.changed()},me.prototype.getCoordinate=function(){return this.getCoordinates()};const be=function(e,t){ye.call(this,e,t)};(be.prototype=Object.create(ye.prototype)).isValid=function(){return this.coordinates.length>1},be.prototype.addCoordinate=function(e,t,r){this.changed();const n=parseInt(e,10);this.coordinates.splice(n,0,[t,r])},be.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},be.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},be.prototype.updateCoordinate=function(e,t,r){const n=parseInt(e,10);this.coordinates[n]=[t,r],this.changed()};const Ee=function(e,t){ye.call(this,e,t),this.coordinates=this.coordinates.map(e=>e.slice(0,-1))};(Ee.prototype=Object.create(ye.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},Ee.prototype.incomingCoords=function(e){this.coordinates=e.map(e=>e.slice(0,-1)),this.changed()},Ee.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},Ee.prototype.addCoordinate=function(e,t,r){this.changed();const n=e.split(".").map(e=>parseInt(e,10));this.coordinates[n[0]].splice(n[1],0,[t,r])},Ee.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];r&&(r.splice(t[1],1),r.length<3&&this.coordinates.splice(t[0],1))},Ee.prototype.getCoordinate=function(e){const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];return JSON.parse(JSON.stringify(r[t[1]]))},Ee.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},Ee.prototype.updateCoordinate=function(e,t,r){this.changed();const n=e.split("."),o=parseInt(n[0],10),i=parseInt(n[1],10);void 0===this.coordinates[o]&&(this.coordinates[o]=[]),this.coordinates[o][i]=[t,r]};const Pe={MultiPoint:me,MultiLineString:be,MultiPolygon:Ee},Oe=(e,t,r,n,o)=>{const i=r.split("."),a=parseInt(i[0],10),s=i[1]?i.slice(1).join("."):null;return e[a][t](s,n,o)},Se=function(e,t){if(ye.call(this,e,t),delete this.coordinates,this.model=Pe[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};function we(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}(Se.prototype=Object.create(ye.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(e=>new t(this.ctx,{id:ve(),type:w.FEATURE,properties:{},geometry:{coordinates:e,type:this.type.replace("Multi","")}}))},Se.prototype.isValid=function(){return this.features.every(e=>e.isValid())},Se.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},Se.prototype.getCoordinate=function(e){return Oe(this.features,"getCoordinate",e)},Se.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===w.POLYGON?e.getCoordinates():e.coordinates)))},Se.prototype.updateCoordinate=function(e,t,r){Oe(this.features,"updateCoordinate",e,t,r),this.changed()},Se.prototype.addCoordinate=function(e,t,r){Oe(this.features,"addCoordinate",e,t,r),this.changed()},Se.prototype.removeCoordinate=function(e){Oe(this.features,"removeCoordinate",e),this.changed()},Se.prototype.getFeatures=function(){return this.features},we.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},we.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((e,t)=>(void 0===e[t.feature_id]&&(e[t.feature_id]=!0,this._ctx.store.get(t.feature_id).changed()),e),{})},we.prototype.getSelected=function(){return this._ctx.store.getSelected()},we.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},we.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},we.prototype.getFeature=function(e){return this._ctx.store.get(e)},we.prototype.select=function(e){return this._ctx.store.select(e)},we.prototype.deselect=function(e){return this._ctx.store.deselect(e)},we.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},we.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},we.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},we.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},we.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)},we.prototype.changeMode=function(e,t={},r={}){return this._ctx.events.changeMode(e,t,r)},we.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},we.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},we.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},we.prototype.featuresAt=function(e,t,r="click"){if("click"!==r&&"touch"!==r)throw new Error("invalid buffer type");return le[r](e,t,this._ctx)},we.prototype.newFeature=function(e){const t=e.geometry.type;return t===w.POINT?new me(this._ctx,e):t===w.LINE_STRING?new be(this._ctx,e):t===w.POLYGON?new Ee(this._ctx,e):new Se(this._ctx,e)},we.prototype.isInstanceOf=function(e,t){if(e===w.POINT)return t instanceof me;if(e===w.LINE_STRING)return t instanceof be;if(e===w.POLYGON)return t instanceof Ee;if("MultiFeature"===e)return t instanceof Se;throw new Error(`Unknown feature class: ${e}`)},we.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)},we.prototype.onSetup=function(){},we.prototype.onDrag=function(){},we.prototype.onClick=function(){},we.prototype.onMouseMove=function(){},we.prototype.onMouseDown=function(){},we.prototype.onMouseUp=function(){},we.prototype.onMouseOut=function(){},we.prototype.onKeyUp=function(){},we.prototype.onKeyDown=function(){},we.prototype.onTouchStart=function(){},we.prototype.onTouchMove=function(){},we.prototype.onTouchEnd=function(){},we.prototype.onTap=function(){},we.prototype.onStop=function(){},we.prototype.onTrash=function(){},we.prototype.onCombineFeature=function(){},we.prototype.onUncombineFeature=function(){},we.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const _e={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},Me=Object.keys(_e);function xe(e){return[].concat(e).filter(e=>void 0!==e)}function Ie(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(P.HOT))return s();const t=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:t});let r=[],n=[];e.isDirty?n=e.getAllIds():(r=e.getChangedIds().filter(t=>void 0!==e.get(t)),n=e.sources.hot.filter(t=>t.properties.id&&-1===r.indexOf(t.properties.id)&&void 0!==e.get(t.properties.id)).map(e=>e.properties.id)),e.sources.hot=[];const o=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(e=>{const t=e.properties.id||e.properties.parent;return-1===r.indexOf(t)});const i=o!==e.sources.cold.length||n.length>0;function a(r,n){const o=e.get(r).internal(t);e.ctx.events.currentModeRender(o,r=>{r.properties.mode=t,e.sources[n].push(r)})}function s(){e.isDirty=!1,e.clearChangedIds()}r.forEach(e=>a(e,"hot")),n.forEach(e=>a(e,"cold")),i&&e.ctx.map.getSource(P.COLD).setData({type:w.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(P.HOT).setData({type:w.FEATURE_COLLECTION,features:e.sources.hot}),s()}function Ae(e){let t;this._features={},this._featureIds=new ae,this._selectedFeatureIds=new ae,this._selectedCoordinates=[],this._changedFeatureIds=new ae,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,Ie.call(this),this._emitSelectionChange&&(this.ctx.events.fire(M.SELECTION_CHANGE,{features:this.getSelected().map(e=>e.toGeoJSON()),points:this.getSelectedCoordinates().map(e=>({type:w.FEATURE,properties:{},geometry:{type:w.POINT,coordinates:e.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(M.RENDER,{})}))},this.isDirty=!1}function Te(e,t={}){const r=e._selectedCoordinates.filter(t=>e._selectedFeatureIds.has(t.feature_id));e._selectedCoordinates.length===r.length||t.silent||(e._emitSelectionChange=!0),e._selectedCoordinates=r}Ae.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},Ae.prototype.setDirty=function(){return this.isDirty=!0,this},Ae.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const t=this.get(e);this.ctx.events.fire(M.CREATE,{features:[t.toGeoJSON()]})}return this},Ae.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(M.UPDATE,{action:t.action?t.action:x.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},Ae.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Ae.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Ae.prototype.getAllIds=function(){return this._featureIds.values()},Ae.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},Ae.prototype.delete=function(e,t={}){const r=[];return xe(e).forEach(e=>{this._featureIds.has(e)&&(this._featureIds.delete(e),this._selectedFeatureIds.delete(e),t.silent||-1===r.indexOf(this._features[e])&&r.push(this._features[e].toGeoJSON()),delete this._features[e],this.isDirty=!0)}),r.length&&this.ctx.events.fire(M.DELETE,{features:r}),Te(this,t),this},Ae.prototype.get=function(e){return this._features[e]},Ae.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},Ae.prototype.select=function(e,t={}){return xe(e).forEach(e=>{this._selectedFeatureIds.has(e)||(this._selectedFeatureIds.add(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),this},Ae.prototype.deselect=function(e,t={}){return xe(e).forEach(e=>{this._selectedFeatureIds.has(e)&&(this._selectedFeatureIds.delete(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),Te(this,t),this},Ae.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},Ae.prototype.setSelected=function(e,t={}){return e=xe(e),this.deselect(this._selectedFeatureIds.values().filter(t=>-1===e.indexOf(t)),{silent:t.silent}),this.select(e.filter(e=>!this._selectedFeatureIds.has(e)),{silent:t.silent}),this},Ae.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},Ae.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Ae.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Ae.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},Ae.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)}))},Ae.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},Ae.prototype.setFeatureProperty=function(e,t,r,n={}){this.get(e).setProperty(t,r),this.featureChanged(e,{silent:n.silent,action:x.CHANGE_PROPERTIES})},Ae.prototype.storeMapConfig=function(){T.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},Ae.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},Ae.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const Ce=["mode","feature","mouse"];const Le="#3bb2d0",De="#fbb03b",ke="#fff";var je=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],De,Le],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],De,Le],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":ke}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],De,Le]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":ke}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":De}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":De}}];function Re(e,t){this.x=e,this.y=t}function Ne(e,t){const r=t.getBoundingClientRect();return new Re(e.clientX-r.left-(t.clientLeft||0),e.clientY-r.top-(t.clientTop||0))}function Fe(e,t,r,n){return{type:w.FEATURE,properties:{meta:I.VERTEX,parent:e,coord_path:r,active:n?A.ACTIVE:A.INACTIVE},geometry:{type:w.POINT,coordinates:t}}}Re.prototype={clone(){return new Re(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[0]*this.x+e[1]*this.y,r=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=r,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),r=Math.sin(e),n=t*this.x-r*this.y,o=r*this.x+t*this.y;return this.x=n,this.y=o,this},_rotateAround(e,t){const r=Math.cos(e),n=Math.sin(e),o=t.x+r*(this.x-t.x)-n*(this.y-t.y),i=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=o,this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Re},Re.convert=function(e){if(e instanceof Re)return e;if(Array.isArray(e))return new Re(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Re(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var Be=6371008.8,Ve={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*Be,kilometers:6371.0088,kilometres:6371.0088,meters:Be,metres:Be,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:Be/1852,radians:1,yards:6967335.223679999};function Ue(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function Ye(e,t,r={}){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(!Xe(e[0])||!Xe(e[1]))throw new Error("coordinates must contain numbers");return Ue({type:"Point",coordinates:e},t,r)}function Ge(e,t,r={}){for(const n of e){if(n.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(n[n.length-1].length!==n[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<n[n.length-1].length;e++)if(n[n.length-1][e]!==n[0][e])throw new Error("First and last Position are not equivalent.")}return Ue({type:"Polygon",coordinates:e},t,r)}function He(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Ue({type:"LineString",coordinates:e},t,r)}function ze(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function We(e,t,r={}){return Ue({type:"MultiLineString",coordinates:e},t,r)}function Je(e,t="kilometers"){const r=Ve[t];if(!r)throw new Error(t+" units is invalid");return e*r}function Ke(e,t="kilometers"){const r=Ve[t];if(!r)throw new Error(t+" units is invalid");return e/r}function qe(e){return e%(2*Math.PI)*180/Math.PI}function Ze(e){return e%360*Math.PI/180}function Xe(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function $e(e,t,r){if(null!==e)for(var n,o,i,a,s,l,c,u,d=0,p=0,h=e.type,f="FeatureCollection"===h,g="Feature"===h,v=f?e.features.length:1,y=0;y<v;y++){s=(u=!!(c=f?e.features[y].geometry:g?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var m=0;m<s;m++){var b=0,E=0;if(null!==(a=u?c.geometries[m]:c)){l=a.coordinates;var P=a.type;switch(d=0,P){case null:break;case"Point":if(!1===t(l,p,y,b,E))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<l.length;n++){if(!1===t(l[n],p,y,b,E))return!1;p++,"MultiPoint"===P&&b++}"LineString"===P&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<l.length;n++){for(o=0;o<l[n].length-d;o++){if(!1===t(l[n][o],p,y,b,E))return!1;p++}"MultiLineString"===P&&b++,"Polygon"===P&&E++}"Polygon"===P&&b++;break;case"MultiPolygon":for(n=0;n<l.length;n++){for(E=0,o=0;o<l[n].length;o++){for(i=0;i<l[n][o].length-d;i++){if(!1===t(l[n][o][i],p,y,b,E))return!1;p++}E++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===$e(a.geometries[n],t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Qe(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function et(e,t){var r,n,o,i,a,s,l,c,u,d,p=0,h="FeatureCollection"===e.type,f="Feature"===e.type,g=h?e.features.length:1;for(r=0;r<g;r++){for(s=h?e.features[r].geometry:f?e.geometry:e,c=h?e.features[r].properties:f?e.properties:{},u=h?e.features[r].bbox:f?e.bbox:void 0,d=h?e.features[r].id:f?e.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=l?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,u,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,u,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,u,d))return!1;p++}}function tt(e,t){et(e,function(e,r,n,o,i){var a,s=null===e?null:e.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==t(Ue(e,n,{bbox:o,id:i}),r,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var l=0;l<e.coordinates.length;l++){var c=e.coordinates[l];if(!1===t(Ue({type:a,coordinates:c},n),r,l))return!1}})}function rt(e){const t={type:"Feature"};return Object.keys(e).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:t[r]=e[r]}}),t.properties=nt(e.properties),null==e.geometry?t.geometry=null:t.geometry=ot(e.geometry),t}function nt(e){const t={};return e?(Object.keys(e).forEach(r=>{const n=e[r];"object"==typeof n?null===n?t[r]=null:Array.isArray(n)?t[r]=n.map(e=>e):t[r]=nt(n):t[r]=n}),t):t}function ot(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(e=>ot(e)),t):(t.coordinates=it(e.coordinates),t)}function it(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(e=>it(e))}function at(e,t={}){return st(e,"mercator",t)}function st(e,t,r={}){var n=(r=r||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&Xe(e[0])?e="mercator"===t?lt(e):ct(e):(!0!==n&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return rt(e);case"FeatureCollection":return function(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(r=>{switch(r){case"type":case"features":return;default:t[r]=e[r]}}),t.features=e.features.map(e=>rt(e)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return ot(e);default:throw new Error("unknown GeoJSON type")}}(e)),$e(e,function(e){var r="mercator"===t?lt(e):ct(e);e[0]=r[0],e[1]=r[1]})),e}function lt(e){var t,r=Math.PI/180,n=6378137,o=20037508.342789244,i=[n*(Math.abs(e[0])<=180?e[0]:e[0]-360*((t=e[0])<0?-1:t>0?1:0))*r,n*Math.log(Math.tan(.25*Math.PI+.5*e[1]*r))];return i[0]>o&&(i[0]=o),i[0]<-o&&(i[0]=-o),i[1]>o&&(i[1]=o),i[1]<-o&&(i[1]=-o),i}function ct(e){var t=180/Math.PI,r=6378137;return[e[0]*t/r,(.5*Math.PI-2*Math.atan(Math.exp(-e[1]/r)))*t]}function ut(e,t,r){const n=t.geometry.coordinates,o=r.geometry.coordinates;if(n[1]>85||n[1]<-85||o[1]>85||o[1]<-85)return null;const i=at(n),a=at(o),s=e=>Number(e.toFixed(8)),l=(e,t)=>(e+t)/2,c=function(e,t={}){return st(e,"wgs84",t)}([l(i[0],a[0]),l(i[1],a[1])]),u=[s(c[0]),s(c[1])];return{type:w.FEATURE,properties:{meta:I.MIDPOINT,parent:e,lng:u[0],lat:u[1],coord_path:r.properties.coord_path},geometry:{type:w.POINT,coordinates:u}}}function dt(e,t={},r=null){const{type:n,coordinates:o}=e.geometry,i=e.properties&&e.properties.id;let a=[];function s(e,r){let n="",o=null;e.forEach((e,s)=>{const c=null!=r?`${r}.${s}`:String(s),u=Fe(i,e,c,l(c));if(t.midpoints&&o){const e=ut(i,o,u);e&&a.push(e)}o=u;const d=JSON.stringify(e);n!==d&&a.push(u),0===s&&(n=d)})}function l(e){return!!t.selectedPaths&&-1!==t.selectedPaths.indexOf(e)}return n===w.POINT?a.push(Fe(i,o,r,l(r))):n===w.POLYGON?o.forEach((e,t)=>{s(e,null!==r?`${r}.${t}`:String(t))}):n===w.LINE_STRING?s(o,r):0===n.indexOf(w.MULTI_PREFIX)&&function(){const r=n.replace(w.MULTI_PREFIX,"");o.forEach((n,o)=>{const i={type:w.FEATURE,properties:e.properties,geometry:{type:r,coordinates:n}};a=a.concat(dt(i,t,o))})}(),a}var pt={enable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e._ctx&&e._ctx.store&&e._ctx.store.getInitialConfigValue&&e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e.map.doubleClickZoom.disable()},0)}};const{LAT_MIN:ht,LAT_MAX:ft,LAT_RENDERED_MIN:gt,LAT_RENDERED_MAX:vt,LNG_MIN:yt,LNG_MAX:mt}=C;function bt(e,t){let r=ht,n=ft,o=ht,i=ft,a=mt,s=yt;e.forEach(e=>{const t=function(e){const t={Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type],r=[e.geometry.coordinates].flat(t),n=r.map(e=>e[0]),o=r.map(e=>e[1]),i=e=>Math.min.apply(null,e),a=e=>Math.max.apply(null,e);return[i(n),i(o),a(n),a(o)]}(e),l=t[1],c=t[3],u=t[0],d=t[2];l>r&&(r=l),c<n&&(n=c),c>o&&(o=c),l<i&&(i=l),u<a&&(a=u),d>s&&(s=d)});const l=t;return r+l.lat>vt&&(l.lat=vt-r),o+l.lat>ft&&(l.lat=ft-o),n+l.lat<gt&&(l.lat=gt-n),i+l.lat<ht&&(l.lat=ht-i),a+l.lng<=yt&&(l.lng+=360*Math.ceil(Math.abs(l.lng)/360)),s+l.lng>=mt&&(l.lng-=360*Math.ceil(Math.abs(l.lng)/360)),l}function Et(e,t){const r=bt(e.map(e=>e.toGeoJSON()),t);e.forEach(e=>{const t=e.getCoordinates(),n=e=>{const t={lng:e[0]+r.lng,lat:e[1]+r.lat};return[t.lng,t.lat]},o=e=>e.map(e=>n(e));let i;e.type===w.POINT?i=n(t):e.type===w.LINE_STRING||e.type===w.MULTI_POINT?i=t.map(n):e.type===w.POLYGON||e.type===w.MULTI_LINE_STRING?i=t.map(o):e.type===w.MULTI_POLYGON&&(i=t.map(e=>e.map(e=>o(e)))),e.incomingCoords(i)})}const Pt={onSetup:function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(e=>void 0!==this.getFeature(e))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(M.UPDATE,{action:x.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(){const e=this.getSelected(),t=e.filter(e=>this.isInstanceOf("MultiFeature",e));let r=!1;if(e.length>1){r=!0;const t=e[0].type.replace("Multi","");e.forEach(e=>{e.type.replace("Multi","")!==t&&(r=!1)})}const n=t.length>0,o=e.length>0;this.setActionableState({combineFeatures:r,uncombineFeatures:n,trash:o})},getUniqueIds:function(e){return e.length?e.map(e=>e.properties.id).filter(e=>void 0!==e).reduce((e,t)=>(e.add(t),e),new ae).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){pt.enable(this)},onMouseMove:function(e,t){return N(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};Pt.onTap=Pt.onClick=function(e,t){return R(t)?this.clickAnywhere(e,t):L(I.VERTEX)(t)?this.clickOnVertex(e,t):N(t)?this.clickOnFeature(e,t):void 0},Pt.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(e=>this.doRender(e))),pt.enable(this),this.stopExtendedInteractions(e)},Pt.clickOnVertex=function(e,t){this.changeMode(_.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:O.MOVE})},Pt.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},Pt.clickOnFeature=function(e,t){pt.disable(this),this.stopExtendedInteractions(e);const r=B(t),n=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!r&&i&&this.getFeature(o).type!==w.POINT)return this.changeMode(_.DIRECT_SELECT,{featureId:o});i&&r?(this.deselect(o),this.updateUIClasses({mouse:O.POINTER}),1===n.length&&pt.enable(this)):!i&&r?(this.select(o),this.updateUIClasses({mouse:O.MOVE})):i||r||(n.forEach(e=>this.doRender(e)),this.setSelected(o),this.updateUIClasses({mouse:O.MOVE})),this.doRender(o)},Pt.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),k(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&D(t)?this.startBoxSelect(e,t):void 0},Pt.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ne(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},Pt.onTouchStart=function(e,t){if(k(t))return this.startOnActiveFeature(e,t)},Pt.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},Pt.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:O.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(E.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const r=Ne(t.originalEvent,this.map.getContainer()),n=Math.min(e.boxSelectStartLocation.x,r.x),o=Math.max(e.boxSelectStartLocation.x,r.x),i=Math.min(e.boxSelectStartLocation.y,r.y),a=Math.max(e.boxSelectStartLocation.y,r.y),s=`translate(${n}px, ${i}px)`;e.boxSelectElement.style.transform=s,e.boxSelectElement.style.WebkitTransform=s,e.boxSelectElement.style.width=o-n+"px",e.boxSelectElement.style.height=a-i+"px"},Pt.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};Et(this.getSelected(),r),e.dragMoveLocation=t.lngLat},Pt.onTouchEnd=Pt.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const r=[e.boxSelectStartLocation,Ne(t.originalEvent,this.map.getContainer())],n=this.featuresAt(null,r,"click"),o=this.getUniqueIds(n).filter(e=>!this.isSelected(e));o.length&&(this.select(o),o.forEach(e=>this.doRender(e)),this.updateUIClasses({mouse:O.MOVE}))}this.stopExtendedInteractions(e)},Pt.toDisplayFeatures=function(e,t,r){t.properties.active=this.isSelected(t.properties.id)?A.ACTIVE:A.INACTIVE,r(t),this.fireActionable(),t.properties.active===A.ACTIVE&&t.geometry.type!==w.POINT&&dt(t).forEach(r)},Pt.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Pt.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],r=[],n=e[0].type.replace("Multi","");for(let o=0;o<e.length;o++){const i=e[o];if(i.type.replace("Multi","")!==n)return;i.type.includes("Multi")?i.getCoordinates().forEach(e=>{t.push(e)}):t.push(i.getCoordinates()),r.push(i.toGeoJSON())}if(r.length>1){const e=this.newFeature({type:w.FEATURE,properties:r[0].properties,geometry:{type:`Multi${n}`,coordinates:t}});this.addFeature(e),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([e.id]),this.fire(M.COMBINE_FEATURES,{createdFeatures:[e.toGeoJSON()],deletedFeatures:r})}this.fireActionable()},Pt.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],r=[];for(let n=0;n<e.length;n++){const o=e[n];this.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach(e=>{this.addFeature(e),e.properties=o.properties,t.push(e.toGeoJSON()),this.select([e.id])}),this.deleteFeature(o.id,{silent:!0}),r.push(o.toGeoJSON()))}t.length>1&&this.fire(M.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:r}),this.fireActionable()};const Ot=L(I.VERTEX),St=L(I.MIDPOINT),wt={fireUpdate:function(){this.fire(M.UPDATE,{action:x.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){null==e.initialDragPanState&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties,n=e.selectedCoordPaths.indexOf(r.coord_path);B(t)||-1!==n?B(t)&&-1===n&&e.selectedCoordPaths.push(r.coord_path):e.selectedCoordPaths=[r.coord_path];const o=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(o)},onMidpoint:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties;e.feature.addCoordinate(r.coord_path,r.lng,r.lat),this.fireUpdate(),e.selectedCoordPaths=[r.coord_path]},pathsToCoordinates:function(e,t){return t.map(t=>({feature_id:e,coord_path:t}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,r){Et(this.getSelected(),r),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,r){const n=e.selectedCoordPaths.map(t=>e.feature.getCoordinate(t)),o=bt(n.map(e=>({type:w.FEATURE,properties:{},geometry:{type:w.POINT,coordinates:e}})),r);for(let i=0;i<n.length;i++){const t=n[i];e.feature.updateCoordinate(e.selectedCoordPaths[i],t[0]+o.lng,t[1]+o.lat)}},clickNoTarget:function(){this.changeMode(_.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(_.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},onSetup:function(e){const t=e.featureId,r=this.getFeature(t);if(!r)throw new Error("You must provide a featureId to enter direct_select mode");if(r.type===w.POINT)throw new TypeError("direct_select mode doesn't handle point features");const n={featureId:t,feature:r,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,n.selectedCoordPaths)),this.setSelected(t),pt.disable(this),this.setActionableState({trash:!0}),n},onStop:function(){pt.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,r){e.featureId===t.properties.id?(t.properties.active=A.ACTIVE,r(t),dt(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(r)):(t.properties.active=A.INACTIVE,r(t)),this.fireActionable(e)},onTrash:function(e){e.selectedCoordPaths.sort((e,t)=>t.localeCompare(e,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(_.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const r=k(t),n=Ot(t),o=St(t),i=0===e.selectedCoordPaths.length;return r&&i||n&&!i?this.updateUIClasses({mouse:O.MOVE}):this.updateUIClasses({mouse:O.NONE}),(n||r||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};wt.onTouchStart=wt.onMouseDown=function(e,t){return Ot(t)?this.onVertex(e,t):k(t)?this.onFeature(e,t):St(t)?this.onMidpoint(e,t):void 0},wt.onDrag=function(e,t){if(!0!==e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,r):this.dragFeature(e,t,r),e.dragMoveLocation=t.lngLat},wt.onClick=function(e,t){return R(t)?this.clickNoTarget(e,t):k(t)?this.clickActiveFeature(e,t):j(t)?this.clickInactive(e,t):void this.stopDragging(e)},wt.onTap=function(e,t){return R(t)?this.clickNoTarget(e,t):k(t)?this.clickActiveFeature(e,t):j(t)?this.clickInactive(e,t):void 0},wt.onTouchEnd=wt.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const _t={};function Mt(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]}_t.onSetup=function(){const e=this.newFeature({type:w.FEATURE,properties:{},geometry:{type:w.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:O.ADD}),this.activateUIButton(S.POINT),this.setActionableState({trash:!0}),{point:e}},_t.stopDrawingAndRemove=function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(_.SIMPLE_SELECT)},_t.onTap=_t.onClick=function(e,t){this.updateUIClasses({mouse:O.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(M.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(_.SIMPLE_SELECT,{featureIds:[e.point.id]})},_t.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},_t.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.point.id;if(t.properties.active=n?A.ACTIVE:A.INACTIVE,!n)return r(t)},_t.onTrash=_t.stopDrawingAndRemove,_t.onKeyUp=function(e,t){if(V(t)||U(t))return this.stopDrawingAndRemove(e,t)};const xt={onSetup:function(){const e=this.newFeature({type:w.FEATURE,properties:{},geometry:{type:w.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),pt.disable(this),this.updateUIClasses({mouse:O.ADD}),this.activateUIButton(S.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Mt(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(_.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:O.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(_.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),F(t)&&this.updateUIClasses({mouse:O.POINTER})}};xt.onTap=xt.onClick=function(e,t){return F(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},xt.onKeyUp=function(e,t){V(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(_.SIMPLE_SELECT)):U(t)&&this.changeMode(_.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},xt.onStop=function(e){this.updateUIClasses({mouse:O.NONE}),pt.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(M.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(_.SIMPLE_SELECT,{},{silent:!0})))},xt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.polygon.id;if(t.properties.active=n?A.ACTIVE:A.INACTIVE,!n)return r(t);if(0===t.geometry.coordinates.length)return;const o=t.geometry.coordinates[0].length;if(!(o<3)){if(t.properties.meta=I.FEATURE,r(Fe(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const n=t.geometry.coordinates[0].length-3;r(Fe(e.polygon.id,t.geometry.coordinates[0][n],`0.${n}`,!1))}if(o<=4){const e=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(r({type:w.FEATURE,properties:t.properties,geometry:{coordinates:e,type:w.LINE_STRING}}),3===o)return}return r(t)}},xt.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(_.SIMPLE_SELECT)};const It={onSetup:function(e){const t=(e=e||{}).featureId;let r,n,o="forward";if(t){if(r=this.getFeature(t),!r)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const a=r.coordinates.length-1;if(r.coordinates[a][0]===i[0]&&r.coordinates[a][1]===i[1])n=a+1,r.addCoordinate(n,...r.coordinates[a]);else{if(r.coordinates[0][0]!==i[0]||r.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");o="backwards",n=0,r.addCoordinate(n,...r.coordinates[0])}}else r=this.newFeature({type:w.FEATURE,properties:{},geometry:{type:w.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(r);return this.clearSelectedFeatures(),pt.disable(this),this.updateUIClasses({mouse:O.ADD}),this.activateUIButton(S.LINE),this.setActionableState({trash:!0}),{line:r,currentVertexPosition:n,direction:o}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Mt(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&Mt(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(_.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:O.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(_.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),F(t)&&this.updateUIClasses({mouse:O.POINTER})}};It.onTap=It.onClick=function(e,t){if(F(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},It.onKeyUp=function(e,t){U(t)?this.changeMode(_.SIMPLE_SELECT,{featureIds:[e.line.id]}):V(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(_.SIMPLE_SELECT))},It.onStop=function(e){pt.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(M.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(_.SIMPLE_SELECT,{},{silent:!0})))},It.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(_.SIMPLE_SELECT)},It.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.line.id;if(t.properties.active=n?A.ACTIVE:A.INACTIVE,!n)return r(t);t.geometry.coordinates.length<2||(t.properties.meta=I.FEATURE,r(Fe(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),r(t))};var At={simple_select:Pt,direct_select:wt,draw_point:_t,draw_polygon:xt,draw_line_string:It};const Tt={defaultMode:_.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:je,modes:At,controls:{},userProperties:!1,suppressAPIEvents:!0},Ct={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Lt={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function Dt(e,t){return e.map(e=>e.source?e:Object.assign({},e,{id:`${e.id}.${t}`,source:"hot"===t?P.HOT:P.COLD}))}var kt,jt,Rt,Nt,Ft=(jt||(jt=1,kt=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,o,i;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(o=n;0!==o--;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(i=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(o=n;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=n;0!==o--;){var a=i[o];if(!e(t[a],r[a]))return!1}return!0}return t!=t&&r!=r}),kt),Bt=q(Ft),Vt=q(function(){if(Nt)return Rt;Nt=1,Rt=function(t){if(!t||!t.type)return null;var r=e[t.type];return r?"geometry"===r?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:t}]}:"feature"===r?{type:"FeatureCollection",features:[t]}:"featurecollection"===r?t:void 0:null};var e={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};return Rt}());function Ut(e,t){return e.length===t.length&&JSON.stringify(e.map(e=>e).sort())===JSON.stringify(t.map(e=>e).sort())}const Yt={Polygon:Ee,LineString:be,Point:me,MultiPolygon:Se,MultiLineString:Se,MultiPoint:Se};var Gt=Object.freeze({__proto__:null,CommonSelectors:K,ModeHandler:fe,StringSet:ae,constrainFeatureMovement:bt,createMidPoint:ut,createSupplementaryPoints:dt,createVertex:Fe,doubleClickZoom:pt,euclideanDistance:de,featuresAt:le,getFeatureAtAndSetCursors:ue,isClick:pe,isEventAtCoordinates:Mt,isTap:he,mapEventToBoundingBox:ie,moveFeatures:Et,sortFeatures:oe,stringSetsAreEqual:Ut,theme:je,toDenseArray:xe});function Ht(e){!function(e,t){const r={options:e=function(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),!1===e.displayControlsDefault?t.controls=Object.assign({},Lt,e.controls):t.controls=Object.assign({},Ct,e.controls),t=Object.assign({},Tt,t),t.styles=Dt(t.styles,"cold").concat(Dt(t.styles,"hot")),t}(e)};t=function(e,t){t.modes=_;const r=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(t){return le.click({point:t},null,e).map(e=>e.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:w.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(t=>e.store.get(t)).map(e=>e.toGeoJSON())}},t.getSelectedPoints=function(){return{type:w.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(e=>({type:w.FEATURE,properties:{},geometry:{type:w.POINT,coordinates:e.coordinates}}))}},t.set=function(r){if(void 0===r.type||r.type!==w.FEATURE_COLLECTION||!Array.isArray(r.features))throw new Error("Invalid FeatureCollection");const n=e.store.createRenderBatch();let o=e.store.getAllIds().slice();const i=t.add(r),a=new ae(i);return o=o.filter(e=>!a.has(e)),o.length&&t.delete(o),n(),i},t.add=function(t){const n=JSON.parse(JSON.stringify(Vt(t))).features.map(t=>{if(t.id=t.id||ve(),null===t.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(t.id)||e.store.get(t.id).type!==t.geometry.type){const n=Yt[t.geometry.type];if(void 0===n)throw new Error(`Invalid geometry type: ${t.geometry.type}.`);const o=new n(e,t);e.store.add(o,{silent:r})}else{const n=e.store.get(t.id),o=n.properties;n.properties=t.properties,Bt(o,t.properties)||e.store.featureChanged(n.id,{silent:r}),Bt(n.getCoordinates(),t.geometry.coordinates)||n.incomingCoords(t.geometry.coordinates)}return t.id});return e.store.render(),n},t.get=function(t){const r=e.store.get(t);if(r)return r.toGeoJSON()},t.getAll=function(){return{type:w.FEATURE_COLLECTION,features:e.store.getAll().map(e=>e.toGeoJSON())}},t.delete=function(n){return e.store.delete(n,{silent:r}),t.getMode()!==_.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(_.SIMPLE_SELECT,void 0,{silent:r}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:r}),t.getMode()===_.DIRECT_SELECT?e.events.changeMode(_.SIMPLE_SELECT,void 0,{silent:r}):e.store.render(),t},t.changeMode=function(n,o={}){return n===_.SIMPLE_SELECT&&t.getMode()===_.SIMPLE_SELECT?(Ut(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:r}),e.store.render()),t):(n===_.DIRECT_SELECT&&t.getMode()===_.DIRECT_SELECT&&o.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(n,o,{silent:r}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:r}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:r}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:r}),t},t.setFeatureProperty=function(n,o,i){return e.store.setFeatureProperty(n,o,i,{silent:r}),t},t}(r,t),r.api=t;const n=function(e){let t=null,r=null;const n={onRemove(){return e.map.off("load",n.connect),clearInterval(r),n.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",n.connect),clearInterval(r),n.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(o){if(e.map=o,e.events=function(e){const t=Object.keys(e.options.modes).reduce((t,r)=>(t[r]=function(e){const t=Object.keys(e);return function(r,n={}){let o={};const i=t.reduce((t,r)=>(t[r]=e[r],t),new we(r));return{start(){o=i.onSetup(n),Me.forEach(t=>{const r=_e[t];let n=()=>!1;var a;e[r]&&(n=()=>!0),this.on(t,n,(a=r,e=>i[a](o,e)))})},stop(){i.onStop(o)},trash(){i.onTrash(o)},combineFeatures(){i.onCombineFeatures(o)},uncombineFeatures(){i.onUncombineFeatures(o)},render(e,t){i.toDisplayFeatures(o,e,t)}}}}(e.options.modes[r]),t),{});let r={},n={};const o={};let i=null,a=null;o.drag=function(t,r){r({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:O.DRAG}),a.drag(t)):t.originalEvent.stopPropagation()},o.mousedrag=function(e){o.drag(e,e=>!pe(r,e))},o.touchdrag=function(e){o.drag(e,e=>!he(n,e))},o.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return o.mousedrag(t);const r=ue(t,e);t.featureTarget=r,a.mousemove(t)},o.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};const n=ue(t,e);t.featureTarget=n,a.mousedown(t)},o.mouseup=function(t){const n=ue(t,e);t.featureTarget=n,pe(r,{point:t.point,time:(new Date).getTime()})?a.click(t):a.mouseup(t)},o.mouseout=function(e){a.mouseout(e)},o.touchstart=function(t){if(!e.options.touchEnabled)return;n={time:(new Date).getTime(),point:t.point};const r=le.touch(t,null,e)[0];t.featureTarget=r,a.touchstart(t)},o.touchmove=function(t){if(e.options.touchEnabled)return a.touchmove(t),o.touchdrag(t)},o.touchend=function(t){if(t.originalEvent.preventDefault(),!e.options.touchEnabled)return;const r=le.touch(t,null,e)[0];t.featureTarget=r,he(n,{time:(new Date).getTime(),point:t.point})?a.tap(t):a.touchend(t)};const s=e=>{const t=Y(e),r=G(e),n=J(e);return!(t||r||n)};function l(r,n,o={}){a.stop();const s=t[r];if(void 0===s)throw new Error(`${r} is not valid`);i=r;const l=s(e,n);a=fe(l,e),o.silent||e.map.fire(M.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains(E.CANVAS)&&((Y(t)||G(t))&&e.options.controls.trash?(t.preventDefault(),a.trash()):s(t)?a.keydown(t):H(t)&&e.options.controls.point?l(_.DRAW_POINT):z(t)&&e.options.controls.line_string?l(_.DRAW_LINE_STRING):W(t)&&e.options.controls.polygon&&l(_.DRAW_POLYGON))},o.keyup=function(e){s(e)&&a.keyup(e)},o.zoomend=function(){e.store.changeZoom()},o.data=function(t){if("style"===t.dataType){const{setup:t,map:r,options:n,store:o}=e;n.styles.some(e=>r.getLayer(e.id))||(t.addLayers(),o.setDirty(),o.render())}};const c={trash:!1,combineFeatures:!1,uncombineFeatures:!1},u={start(){i=e.options.defaultMode,a=fe(t[i](e),e)},changeMode:l,actionable:function(t){let r=!1;Object.keys(t).forEach(e=>{if(void 0===c[e])throw new Error("Invalid action type");c[e]!==t[e]&&(r=!0),c[e]=t[e]}),r&&e.map.fire(M.ACTIONABLE,{actions:c})},currentModeName:()=>i,currentModeRender:(e,t)=>a.render(e,t),fire(t,r){e.map&&e.map.fire(t,r)},addEventListeners(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash(e){a.trash(e)},combineFeatures(){a.combineFeatures()},uncombineFeatures(){a.uncombineFeatures()},getMode:()=>i};return u}(e),e.ui=function(e){const t={};let r=null,n={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function i(e){o=Object.assign(o,e)}function a(){if(!e.container)return;const t=[],r=[];Ce.forEach(e=>{o[e]!==n[e]&&(t.push(`${e}-${n[e]}`),null!==o[e]&&r.push(`${e}-${o[e]}`))}),t.length>0&&e.container.classList.remove(...t),r.length>0&&e.container.classList.add(...r),n=Object.assign(n,o)}function s(e,t={}){const n=document.createElement("button");return n.className=`${E.CONTROL_BUTTON} ${t.className}`,n.setAttribute("title",t.title),t.container.appendChild(n),n.addEventListener("click",n=>{if(n.preventDefault(),n.stopPropagation(),n.target===r)return l(),void t.onDeactivate();c(e),t.onActivate()},!0),n}function l(){r&&(r.classList.remove(E.ACTIVE_BUTTON),r=null)}function c(e){l();const n=t[e];n&&n&&"trash"!==e&&(n.classList.add(E.ACTIVE_BUTTON),r=n)}return{setActiveButton:c,queueMapClasses:i,updateMapClasses:a,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),a()},addButtons:function(){const r=e.options.controls,n=document.createElement("div");return n.className=`${E.CONTROL_GROUP} ${E.CONTROL_BASE}`,r?(r[S.POINT]&&(t[S.POINT]=s(S.POINT,{container:n,className:E.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(_.DRAW_POINT),onDeactivate:()=>e.events.trash()})),r[S.LINE]&&(t[S.LINE]=s(S.LINE,{container:n,className:E.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(_.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),r[S.POLYGON]&&(t[S.POLYGON]=s(S.POLYGON,{container:n,className:E.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(_.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),r.trash&&(t.trash=s("trash",{container:n,className:E.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),r.combine_features&&(t.combine_features=s("combineFeatures",{container:n,className:E.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),r.uncombine_features&&(t.uncombine_features=s("uncombineFeatures",{container:n,className:E.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}})),n):n},removeButtons:function(){Object.keys(t).forEach(e=>{const r=t[e];r.parentNode&&r.parentNode.removeChild(r),delete t[e]})}}}(e),e.container=o.getContainer(),e.store=new Ae(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=o.boxZoom.isEnabled(),o.boxZoom.disable();const t=o.dragPan.isEnabled();o.dragPan.disable(),o.dragPan.enable(),t||o.dragPan.disable()}return o.loaded()?n.connect():(o.on("load",n.connect),r=setInterval(()=>{o.loaded()&&n.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(P.COLD,{data:{type:w.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(P.HOT,{data:{type:w.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(t=>{e.map.addLayer(t)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(t=>{e.map.getLayer(t.id)&&e.map.removeLayer(t.id)}),e.map.getSource(P.COLD)&&e.map.removeSource(P.COLD),e.map.getSource(P.HOT)&&e.map.removeSource(P.HOT)}};return e.setup=n,n}(r);t.onAdd=n.onAdd,t.onRemove=n.onRemove,t.types=S,t.options=e}(e,this)}Ht.modes=At,Ht.constants=C,Ht.lib=Gt;var zt={onSetup:()=>({}),onClick:()=>!1,onKeyUp:()=>!1,onDrag:()=>!1,toDisplayFeatures(e,t,r){t.properties.active="false",r(t)}},Wt=e=>{if(null==e||!e.coordinates)return[];switch(e.type){case"LineString":return e.coordinates;case"Polygon":case"MultiLineString":return e.coordinates.flat(1);case"MultiPolygon":return e.coordinates.flat(2);default:return[]}},Jt=e=>{if(null==e||!e.coordinates)return[];var t=[],r=0;switch(e.type){case"LineString":t.push({start:0,length:e.coordinates.length,path:[],closed:!1});break;case"Polygon":e.coordinates.forEach((e,n)=>{t.push({start:r,length:e.length,path:[n],closed:!0}),r+=e.length});break;case"MultiLineString":e.coordinates.forEach((e,n)=>{t.push({start:r,length:e.length,path:[n],closed:!1}),r+=e.length});break;case"MultiPolygon":e.coordinates.forEach((e,n)=>{e.forEach((e,o)=>{t.push({start:r,length:e.length,path:[n,o],closed:!0}),r+=e.length})})}return t},Kt=(e,t)=>{for(var r of e)if(t>=r.start&&t<r.start+r.length)return{segment:r,localIdx:t-r.start};return null},qt=(e,t)=>{var r=e.geometry.coordinates;for(var n of t)r=r[n];return r},Zt=(e,t)=>{var r=t.split(".").map(Number),n=Jt(e);for(var o of n)if(o.path.every((e,t)=>e===r[t])&&r.length===o.path.length+1){var i=r[r.length-1];return o.start+i}return r[r.length-1]},Xt=(e,t)=>({x:e.x*t,y:e.y*t}),$t=e=>e instanceof window.SVGElement||e.ownerSVGElement,Qt={fireGeometryChange(e){var t=this.getFeature(e.featureId);t&&this.map.fire("draw.update",{features:[t.toGeoJSON()],action:"change_coordinates"})},pushUndo(e){var t=this.map._undoStack;t&&t.push(e)},handleUndo(e){var t=this.map._undoStack;if(t&&0!==t.length){var r=t.pop();"move_vertex"===r.type?this.undoMoveVertex(e,r):"insert_vertex"===r.type?this.undoInsertVertex(e,r):"delete_vertex"===r.type&&this.undoDeleteVertex(e,r)}},undoMoveVertex(e,t){var{vertexIndex:r,previousPosition:n,featureId:o}=t,i=this.getFeature(o);if(i){var a=i.toGeoJSON(),s=Jt(i),l=Kt(s,r);if(l){qt(a,l.segment.path)[l.localIdx]=n,this._applyUndoAndSync(e,a,o);var c=e.vertecies[e.selectedVertexIndex];c&&this.updateTouchVertexTarget(e,Xt(this.map.project(c),e.scale))}}},undoInsertVertex(e,t){var{vertexIndex:r,featureId:n}=t,o=this.getFeature(n);if(o){var i=o.toGeoJSON(),a=Jt(o),s=Kt(a,r);s&&(qt(i,s.segment.path).splice(s.localIdx,1),this._applyUndoAndSync(e,i,n),this.clearSelectedCoordinates(),this.hideTouchVertexIndicator(e),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null}))}},undoDeleteVertex(e,t){var{vertexIndex:r,position:n,featureId:o}=t,i=this.getFeature(o);if(i){var a=i.toGeoJSON(),s=Jt(i),l=Kt(s,r);if(!l)for(var c of s)if(r===c.start+c.length){l={segment:c,localIdx:c.length};break}if(l){qt(a,l.segment.path).splice(l.localIdx,0,n),this._applyUndoAndSync(e,a,o);var u=e.vertecies[r];u&&this.updateTouchVertexTarget(e,Xt(this.map.project(u),e.scale)),this.changeMode(e,{selectedVertexIndex:r,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,r)})}}},_applyUndoAndSync(e,t,r){this._ctx.api.add(t),e.vertecies=this.getVerticies(r),e.midpoints=this.getMidpoints(r),this._ctx.store.render(),this.fireGeometryChange(e)}};function er(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function tr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?er(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):er(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var rr=(e,t)=>{if(e){var r="dark"===(null==t?void 0:t.mapColorScheme);e.style.setProperty("--touch-fill",r?"#ffffff":"#000000"),e.style.setProperty("--touch-gfx",r?"#000000":"#ffffff")}},nr={addTouchVertexTarget(e){var t=e.container.querySelector("[data-touch-vertex-target]");t||(e.container.insertAdjacentHTML("beforeend","\n <svg width='48' height='48' viewBox='0 0 48 48' fill-rule='evenodd' style='display:none;position:absolute;top:50%;left:50%;margin:24px 0 0 -24px' class='touch-vertex-target' data-touch-vertex-target>\n <circle cx='24' cy='24' r='24' fill='var(--touch-fill, #000)'/>\n <path d=\"M37.543 25H34a1 1 0 1 1 0-2h3.629l-.836-.837a1 1 0 0 1 1.414-1.414l2.5 2.501A1 1 0 0 1 41 24a1 1 0 0 1-.487.858l-2.306 2.306a1 1 0 0 1-1.414-1.414l.75-.75zM23 10.414l-.793.793a1 1 0 0 1-1.414-1.414l2.5-2.5C23.481 7.105 23.734 7 24 7s.519.105.707.293l2.5 2.5a1 1 0 0 1-1.414 1.414L25 10.414V14a1 1 0 1 1-2 0v-3.586zM7 24a1 1 0 0 1 .293-.75l2.5-2.501a1 1 0 0 1 1.414 1.414l-.836.837H14a1 1 0 1 1 0 2h-3.543l.75.75a1 1 0 0 1-1.414 1.414l-2.306-2.306A1 1 0 0 1 7 24zm16.293 16.707l-2.5-2.5a1 1 0 0 1 1.414-1.414l.793.793V34a1 1 0 1 1 2 0v3.586l.793-.793a1 1 0 0 1 1.414 1.414l-2.5 2.5c-.188.188-.441.293-.707.293s-.519-.105-.707-.293zM24 20c2.208 0 4 1.792 4 4s-1.792 4-4 4-4-1.792-4-4 1.792-4 4-4z\" fill='var(--touch-gfx, #fff)'/>\n </svg>\n"),t=e.container.querySelector("[data-touch-vertex-target]")),e.touchVertexTarget=t,rr(t,this.map._drawCurrentMapStyle)},updateTouchVertexTarget(e,t){t&&"touch"===e.interfaceType&&e.selectedVertexIndex>=0?Object.assign(e.touchVertexTarget.style,{display:"block",top:"".concat(t.y,"px"),left:"".concat(t.x,"px")}):e.touchVertexTarget.style.display="none"},hideTouchVertexIndicator(e){e.touchVertexTarget.style.display="none"},onPointerevent(e,t){e.interfaceType="touch"===t.pointerType?"touch":"mouse",e.isPanEnabled=!0,"touch"!==t.pointerType||"pointermove"!==t.type||$t(t.target.parentNode)||e._ignorePointermoveDeselect||this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,coordPath:null})},onTouchStart(){},onTouchMove(){},onTouchEnd(){},onTouchend(e){m(h(this.map)),null!=e&&e.featureId&&(this.syncVertices(e),e._touchMoved&&e._moveStartPosition&&void 0!==e._moveStartIndex&&this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,e._moveStartIndex=void 0,e._touchMoved=!1)},onTap(e,t){var r,n,o=h(this.map);o&&y(o,this.map);var i=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,a=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if("vertex"===i){var s=this.getFeature(e.featureId),l=Zt(s,a);this.changeMode(e,{selectedVertexIndex:l,selectedVertexType:"vertex",coordPath:a})}else"midpoint"===i?this.insertVertex(tr(tr({},e),{},{selectedVertexIndex:this.getVertexIndexFromMidpoint(e,a),selectedVertexType:"midpoint"})):this.clickNoTarget(e)},onTouchstart(e,t){var r;m(h(this.map));var n=null===(r=e.vertecies)||void 0===r?void 0:r[e.selectedVertexIndex];if(n&&$t(t.target.parentNode)){e._moveStartPosition=[...n],e._moveStartIndex=e.selectedVertexIndex,e._touchMoved=!1;var o=t.touches[0].clientX,i=t.touches[0].clientY,a=window.getComputedStyle(e.touchVertexTarget);e.deltaTarget={x:o-Number.parseFloat(a.left),y:i-Number.parseFloat(a.top)};var s=this.map.project(n);e.deltaVertex={x:o/e.scale-s.x,y:i/e.scale-s.y}}},onTouchmove(e,t){if(!(e.selectedVertexIndex<0)&&$t(t.target.parentNode)){e._touchMoved=!0;var r=t.touches[0].clientX,n=t.touches[0].clientY,o={x:r/e.scale-e.deltaVertex.x,y:n/e.scale-e.deltaVertex.y},i=this.map.unproject(o);if(b(e)){var a=h(this.map);v(a,this.map,o),i=g(a)||i}this.moveVertex(e,i),this.updateTouchVertexTarget(e,{x:r-e.deltaTarget.x,y:n-e.deltaTarget.y})}}};function or(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}var ir={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},ar={updateMidpoint(e){setTimeout(()=>{this.map.getSource("mapbox-gl-draw-hot").setData({type:"Feature",properties:{meta:"midpoint",active:"true",id:"active-midpoint"},geometry:{type:"Point",coordinates:e}})},0)},updateVertex(e,t){var[r,o]=this.getVertexOrMidpoint(e,t);r<0||!o||this.changeMode(e,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?or(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):or(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({selectedVertexIndex:r,selectedVertexType:o},"vertex"===o&&{coordPath:this.getCoordPath(e,r)}))},getOffset(e,t){var r=this.map.project(e),n=null!=t&&t.shiftKey?1:5,[o,i]=t?ir[t.key].map(e=>e*n):[0,0];return this.map.unproject({x:r.x+o,y:r.y+i})},getNewCoord(e,t){return this.getOffset(Wt(this.getFeature(e.featureId))[e.selectedVertexIndex],t)},insertVertex(e,t){var r=e.selectedVertexIndex-e.vertecies.length,n=this.getOffset(e.midpoints[r],t),o=this.getFeature(e.featureId),i=o.toGeoJSON(),a=Jt(o),s=r+1,l=null,c=0,u=0;for(var d of a){var p=d.closed?d.length:d.length-1;if(r<u+p){l=d,c=r-u+1,s=d.start+c;break}u+=p}l&&(qt(i,l.path).splice(c,0,[n.lng,n.lat]),this._ctx.api.add(i),this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:s}),this.changeMode(e,{selectedVertexIndex:s,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,s)}))},moveVertex(e,t){if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).checkSnap&&!1!==e.enableSnap){var r,n=this.map._snapInstance;null!=n&&n.snapStatus&&(null===(r=n.snapCoords)||void 0===r?void 0:r.length)>=2&&(t={lng:n.snapCoords[0],lat:n.snapCoords[1]})}var o=this.getFeature(e.featureId),i=o.toGeoJSON(),a=Jt(o),s=Kt(a,e.selectedVertexIndex);s&&(qt(i,s.segment.path)[s.localIdx]=[t.lng,t.lat],this._ctx.api.add(i),e.vertecies=this.getVerticies(e.featureId),this.map.fire("draw.geometrychange",e.feature))},deleteVertex(e){var t=this.getFeature(e.featureId);if(t){var r=Jt(t),n=Kt(r,e.selectedVertexIndex);if(n){var{segment:o}=n,i=o.closed?3:2;if(!(o.length<=i)){var a=[...e.vertecies[e.selectedVertexIndex]],s=e.selectedVertexIndex,l=[...n.segment.path,n.localIdx].join(".");t.removeCoordinate(l),this.fireUpdate(),this.clearSelectedCoordinates(),t.changed(),this._ctx.store.render(),this.pushUndo({type:"delete_vertex",featureId:e.featureId,vertexIndex:s,position:a}),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null})}}}}};function sr(e){var t={type:"Feature"};return Object.keys(e).forEach(function(r){switch(r){case"type":case"properties":case"geometry":return;default:t[r]=e[r]}}),t.properties=lr(e.properties),t.geometry=cr(e.geometry),t}function lr(e){var t={};return e?(Object.keys(e).forEach(function(r){var n=e[r];"object"==typeof n?null===n?t[r]=null:Array.isArray(n)?t[r]=n.map(function(e){return e}):t[r]=lr(n):t[r]=n}),t):t}function cr(e){var t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(function(e){return cr(e)}),t):(t.coordinates=ur(e.coordinates),t)}function ur(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map(function(e){return ur(e)})}function dr(e){for(var t,r,n=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),o=0,i=1;i<n.length;)t=r||n[0],o+=((r=n[i])[0]-t[0])*(r[1]+t[1]),i++;return o>0}function pr(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 hr(e,t){switch("Feature"===e.type?e.geometry.type:e.type){case"GeometryCollection":return et(e,function(e){hr(e,t)}),e;case"LineString":return fr(pr(e),t),e;case"Polygon":return gr(pr(e),t),e;case"MultiLineString":return pr(e).forEach(function(e){fr(e,t)}),e;case"MultiPolygon":return pr(e).forEach(function(e){gr(e,t)}),e;case"Point":case"MultiPoint":return e}}function fr(e,t){dr(e)===t&&e.reverse()}function gr(e,t){dr(e[0])!==t&&e[0].reverse();for(var r=1;r<e.length;r++)dr(e[r])===t&&e[r].reverse()}const vr=11102230246251565e-32,yr=134217729,mr=(3+8*vr)*vr;function br(e,t,r,n,o){let i,a,s,l,c=t[0],u=n[0],d=0,p=0;u>c==u>-c?(i=c,c=t[++d]):(i=u,u=n[++p]);let h=0;if(d<e&&p<r)for(u>c==u>-c?(a=c+i,s=i-(a-c),c=t[++d]):(a=u+i,s=i-(a-u),u=n[++p]),i=a,0!==s&&(o[h++]=s);d<e&&p<r;)u>c==u>-c?(a=i+c,l=a-i,s=i-(a-l)+(c-l),c=t[++d]):(a=i+u,l=a-i,s=i-(a-l)+(u-l),u=n[++p]),i=a,0!==s&&(o[h++]=s);for(;d<e;)a=i+c,l=a-i,s=i-(a-l)+(c-l),c=t[++d],i=a,0!==s&&(o[h++]=s);for(;p<r;)a=i+u,l=a-i,s=i-(a-l)+(u-l),u=n[++p],i=a,0!==s&&(o[h++]=s);return 0===i&&0!==h||(o[h++]=i),h}function Er(e){return new Float64Array(e)}const Pr=Er(4),Or=Er(8),Sr=Er(12),wr=Er(16),_r=Er(4);function Mr(e,t,r,n,o,i){const a=(t-i)*(r-o),s=(e-o)*(n-i),l=a-s,c=Math.abs(a+s);return Math.abs(l)>=33306690738754716e-32*c?l:-function(e,t,r,n,o,i,a){let s,l,c,u,d,p,h,f,g,v,y,m,b,E,P,O,S,w;const _=e-o,M=r-o,x=t-i,I=n-i;E=_*I,p=yr*_,h=p-(p-_),f=_-h,p=yr*I,g=p-(p-I),v=I-g,P=f*v-(E-h*g-f*g-h*v),O=x*M,p=yr*x,h=p-(p-x),f=x-h,p=yr*M,g=p-(p-M),v=M-g,S=f*v-(O-h*g-f*g-h*v),y=P-S,d=P-y,Pr[0]=P-(y+d)+(d-S),m=E+y,d=m-E,b=E-(m-d)+(y-d),y=b-O,d=b-y,Pr[1]=b-(y+d)+(d-O),w=m+y,d=w-m,Pr[2]=m-(w-d)+(y-d),Pr[3]=w;let A=function(e,t){let r=t[0];for(let n=1;n<4;n++)r+=t[n];return r}(0,Pr),T=22204460492503146e-32*a;if(A>=T||-A>=T)return A;if(d=e-_,s=e-(_+d)+(d-o),d=r-M,c=r-(M+d)+(d-o),d=t-x,l=t-(x+d)+(d-i),d=n-I,u=n-(I+d)+(d-i),0===s&&0===l&&0===c&&0===u)return A;if(T=11093356479670487e-47*a+mr*Math.abs(A),A+=_*u+I*s-(x*c+M*l),A>=T||-A>=T)return A;E=s*I,p=yr*s,h=p-(p-s),f=s-h,p=yr*I,g=p-(p-I),v=I-g,P=f*v-(E-h*g-f*g-h*v),O=l*M,p=yr*l,h=p-(p-l),f=l-h,p=yr*M,g=p-(p-M),v=M-g,S=f*v-(O-h*g-f*g-h*v),y=P-S,d=P-y,_r[0]=P-(y+d)+(d-S),m=E+y,d=m-E,b=E-(m-d)+(y-d),y=b-O,d=b-y,_r[1]=b-(y+d)+(d-O),w=m+y,d=w-m,_r[2]=m-(w-d)+(y-d),_r[3]=w;const C=br(4,Pr,4,_r,Or);E=_*u,p=yr*_,h=p-(p-_),f=_-h,p=yr*u,g=p-(p-u),v=u-g,P=f*v-(E-h*g-f*g-h*v),O=x*c,p=yr*x,h=p-(p-x),f=x-h,p=yr*c,g=p-(p-c),v=c-g,S=f*v-(O-h*g-f*g-h*v),y=P-S,d=P-y,_r[0]=P-(y+d)+(d-S),m=E+y,d=m-E,b=E-(m-d)+(y-d),y=b-O,d=b-y,_r[1]=b-(y+d)+(d-O),w=m+y,d=w-m,_r[2]=m-(w-d)+(y-d),_r[3]=w;const L=br(C,Or,4,_r,Sr);E=s*u,p=yr*s,h=p-(p-s),f=s-h,p=yr*u,g=p-(p-u),v=u-g,P=f*v-(E-h*g-f*g-h*v),O=l*c,p=yr*l,h=p-(p-l),f=l-h,p=yr*c,g=p-(p-c),v=c-g,S=f*v-(O-h*g-f*g-h*v),y=P-S,d=P-y,_r[0]=P-(y+d)+(d-S),m=E+y,d=m-E,b=E-(m-d)+(y-d),y=b-O,d=b-y,_r[1]=b-(y+d)+(d-O),w=m+y,d=w-m,_r[2]=m-(w-d)+(y-d),_r[3]=w;const D=br(L,Sr,4,_r,wr);return wr[D-1]}(e,t,r,n,o,i,c)}function xr(e,t){var r,n,o,i,a,s,l,c,u,d=0,p=e[0],h=e[1],f=t.length;for(r=0;r<f;r++){n=0;var g=t[r],v=g.length-1;if((c=g[0])[0]!==g[v][0]&&c[1]!==g[v][1])throw new Error("First and last coordinates in a ring must be the same");for(i=c[0]-p,a=c[1]-h;n<v;n++){if(s=(u=g[n+1])[0]-p,l=u[1]-h,0===a&&0===l){if(s<=0&&i>=0||i<=0&&s>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(0===(o=Mr(i,s,a,l,0,0)))return 0;(o>0&&l>0&&a<=0||o<0&&l<=0&&a>0)&&d++}c=u,a=l,i=s}}return d%2!=0}var Ir=function(e,t,r,n,o){this.p1=e,this.p2=t,this.edgeType=r,this.originalIndex=n,this.polygonContourId=o,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},Ar=function(e){this.p=e},Tr=function(e,t){this.id=e,this.rawCoords=t};function Cr(e,t){return!(e.maxX<t[0]||e.minX>t[2]||e.maxY<t[1]||e.minY>t[3])}var Lr=function(e,t,r,n){this.p=e,this.polylineEdge=t,this.polygonEdge=r,this.isHeadingIn=n,this.distanceFromPolylineEdgeStart=Dr(this.polylineEdge.p1.p,this.p),this.distanceFromPolygonEdgeStart=Dr(this.polygonEdge.p1.p,this.p),this.polygonEdge.intersectionPoints.push(this),this.polylineEdge.intersectionPoints.push(this),this.visitCount=0};function Dr(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*=r,n*=n,Math.sqrt(r+n)}function kr(e,t){return e[0]*t[1]-e[1]*t[0]}function jr(e,t){return e[0]*t[0]+e[1]*t[1]}function Rr(e,t,r){return[e[0]+t*r[0],e[1]+t*r[1]]}function Nr(e,t,r){var n=[e.p2.p[0]-e.p1.p[0],e.p2.p[1]-e.p1.p[1]],o=[t.p2.p[0]-t.p1.p[0],t.p2.p[1]-t.p1.p[1]],i=[t.p1.p[0]-e.p1.p[0],t.p1.p[1]-e.p1.p[1]],a=kr(n,o),s=a*a,l=jr(n,n);if(s>0){var c=kr(i,o)/a;if(c<0||c>1)return null;var u=kr(i,n)/a;return u<0||u>1?null:0===c||1===c?[Rr(e.p1.p,c,n)]:0===u||1===u?[Rr(t.p1.p,u,o)]:[Rr(e.p1.p,c,n)]}var d=jr(i,i);if((s=(a=kr(i,n))*a)>1e-9*l*d)return null;var p=jr(n,i)/l,h=p+jr(n,o)/l,f=Math.min(p,h),g=Math.max(p,h);return f<=1&&g>=0?1===f?[Rr(e.p1.p,f>0?f:0,n)]:0===g?[Rr(e.p1.p,g<1?g:1,n)]:[Rr(e.p1.p,f>0?f:0,n),Rr(e.p1.p,g<1?g:1,n)]:null}function Fr(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n.polygonContourId===t)return n}}function Br(e,t){return t.find(function(t){return t.id===e.polygonContourId}).rawCoords}function Vr(e,t){for(var r=0;r<t.length;r++){var n=t[r];if(xr(e[0],[n[0]]))return void n.push(e)}t.push([e])}function Ur(e,t){var r=e.polygonEdge;if(r.intersectionPoints.length>1&&r.intersectionPoints[r.intersectionPoints.length-1]!==e){var n=Yr(e,r.intersectionPoints),o=r.intersectionPoints[n+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(r.p2.p),null===(r=r.nextEdge))return e;r.intersectionPoints.length>0&&(i=!1)}return r.intersectionPoints[0].incrementVisitCount(),t.push(r.intersectionPoints[0].p),r.intersectionPoints[0]}function Yr(e,t){for(var r=0;r<t.length;r++)if(t[r]===e)return r;return null}function Gr(e,t){var r=e.polylineEdge;if(2===r.intersectionPoints.length){var n=r.intersectionPoints[r.intersectionPoints.length-1];if(n===e){var o=r.intersectionPoints[0];return t.push(o.p),o.incrementVisitCount(),o}return t.push(n.p),n.incrementVisitCount(),n}if(r.intersectionPoints.length>2&&r.intersectionPoints[0]!==e){var i=Yr(e,r.intersectionPoints),a=r.intersectionPoints[i-1];return t.push(a.p),a.incrementVisitCount(),a}for(var s=!0;s;){if(t.push(r.p1.p),void 0===(r=r.prevEdge).originalIndex)return e;r.intersectionPoints.length>0&&(s=!1)}if(void 0===r.originalIndex)return e;var l=r.intersectionPoints[r.intersectionPoints.length-1];return l.incrementVisitCount(),t.push(l.p),l}function Hr(e,t){var r=e.polylineEdge;if(r.intersectionPoints.length>1&&r.intersectionPoints[r.intersectionPoints.length-1]!==e){var n=Yr(e,r.intersectionPoints),o=r.intersectionPoints[n+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(r.p2.p),null===(r=r.nextEdge))return e;r.intersectionPoints.length>0&&(i=!1)}if(void 0===r)return e;var a=r.intersectionPoints[0];return a.incrementVisitCount(),t.push(a.p),a}function zr(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Wr(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 Jr(e){return"Feature"===e.type?e.geometry:e}Lr.prototype.incrementVisitCount=function(){this.visitCount=this.visitCount+1};var Kr=function e(t,r,n={}){if(!0===n.final)return function(t,r){let n=e(r,t);return n=(n+180)%360,n}(t,r);const o=zr(t),i=zr(r),a=Ze(o[0]),s=Ze(i[0]),l=Ze(o[1]),c=Ze(i[1]),u=Math.sin(s-a)*Math.cos(c),d=Math.cos(l)*Math.sin(c)-Math.sin(l)*Math.cos(c)*Math.cos(s-a);return qe(Math.atan2(u,d))};function qr(e,t,r,n={}){const o=zr(e),i=Ze(o[0]),a=Ze(o[1]),s=Ze(r),l=Ke(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(l)+Math.cos(a)*Math.sin(l)*Math.cos(s)),u=qe(i+Math.atan2(Math.sin(s)*Math.sin(l)*Math.cos(a),Math.cos(l)-Math.sin(a)*Math.sin(c))),d=qe(c);return void 0!==o[2]?Ye([u,d,o[2]],n.properties):Ye([u,d],n.properties)}var Zr=qr;function Xr(e,t,r={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=zr(e),o=Jr(t),i=o.type,a=t.bbox;let s=o.coordinates;if(a&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(n,a))return!1;"Polygon"===i&&(s=[s]);let l=!1;for(var c=0;c<s.length;++c){const e=xr(n,s[c]);if(0===e)return!r.ignoreBoundary;e&&(l=!0)}return l}class $r{constructor(e=[],t=Qr){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const o=e-1>>1,i=t[o];if(r(n,i)>=0)break;t[e]=i,e=o}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,o=t[e];for(;e<n;){let n=1+(e<<1),i=t[n];const a=n+1;if(a<this.length&&r(t[a],i)<0&&(n=a,i=t[a]),r(i,o)>=0)break;t[e]=i,e=n}t[e]=o}}function Qr(e,t){return e<t?-1:e>t?1:0}function en(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function tn(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class rn{constructor(e,t,r,n){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=n,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}let nn=0,on=0,an=0;function sn(e,t){const r="Feature"===e.type?e.geometry:e;let n=r.coordinates;"Polygon"!==r.type&&"MultiLineString"!==r.type||(n=[n]),"LineString"===r.type&&(n=[[n]]);for(let o=0;o<n.length;o++)for(let e=0;e<n[o].length;e++){let r=n[o][e][0],i=null;on+=1;for(let a=0;a<n[o][e].length-1;a++){i=n[o][e][a+1];const s=new rn(r,nn,on,an),l=new rn(i,nn,on,an+1);s.otherEvent=l,l.otherEvent=s,en(s,l)>0?(l.isLeftEndpoint=!0,s.isLeftEndpoint=!1):(s.isLeftEndpoint=!0,l.isLeftEndpoint=!1),t.push(s),t.push(l),r=i,an+=1}}nn+=1}class ln{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function cn(e,t){if(null===e||null===t)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const r=e.leftSweepEvent.p.x,n=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,i=e.rightSweepEvent.p.y,a=t.leftSweepEvent.p.x,s=t.leftSweepEvent.p.y,l=t.rightSweepEvent.p.x,c=t.rightSweepEvent.p.y,u=(c-s)*(o-r)-(l-a)*(i-n);if(0===u)return!1;const d=((l-a)*(n-s)-(c-s)*(r-a))/u,p=((o-r)*(n-s)-(i-n)*(r-a))/u;return d>=0&&d<=1&&p>=0&&p<=1&&[r+d*(o-r),n+d*(i-n)]}function un(e,t,r={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:o=!0}=r;let i=[];"FeatureCollection"===e.type?i=i.concat(e.features):"Feature"===e.type?i.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||i.push(Ue(e)),"FeatureCollection"===t.type?i=i.concat(t.features):"Feature"===t.type?i.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||i.push(Ue(t));const a=function(e,t){const r=new $r([],en);return function(e,t){if("FeatureCollection"===e.type){const r=e.features;for(let e=0;e<r.length;e++)sn(r[e],t)}else sn(e,t)}(e,r),function(e,t){t=t||!1;const r=[],n=new $r([],tn);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const e=new ln(o);for(let i=0;i<n.data.length;i++){const a=n.data[i];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const s=cn(e,a);!1!==s&&r.push(s)}n.push(e)}else!1===o.isLeftEndpoint&&n.pop()}return r}(r,t)}(ze(i),o);let s=[];if(n){const e={};a.forEach(t=>{const r=t.join(",");e[r]||(e[r]=!0,s.push(t))})}else s=a;return ze(s.map(e=>Ye(e)))}function dn(e,t={}){const r=Jr(e);switch(t.properties||"Feature"!==e.type||(t.properties=e.properties),r.type){case"Polygon":return function(e,t={}){return pn(Jr(e).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}(r,t);case"MultiPolygon":return function(e,t={}){const r=Jr(e).coordinates,n=t.properties?t.properties:"Feature"===e.type?e.properties:{},o=[];return r.forEach(e=>{o.push(pn(e,n))}),ze(o)}(r,t);default:throw new Error("invalid poly")}}function pn(e,t){return e.length>1?We(e,t):He(e[0],t)}function hn(e,t,{ignoreSelfIntersections:r=!0}={ignoreSelfIntersections:!0}){let n=!0;return tt(e,e=>{tt(t,t=>{if(!1===n)return!1;n=function(e,t,r){switch(e.type){case"Point":switch(t.type){case"Point":return n=e.coordinates,o=t.coordinates,!(n[0]===o[0]&&n[1]===o[1]);case"LineString":return!fn(t,e);case"Polygon":return!Xr(e,t)}break;case"LineString":switch(t.type){case"Point":return!fn(e,t);case"LineString":return!function(e,t,r){return un(e,t,{ignoreSelfIntersections:r}).features.length>0}(e,t,r);case"Polygon":return!gn(t,e,r)}break;case"Polygon":switch(t.type){case"Point":return!Xr(t,e);case"LineString":return!gn(e,t,r);case"Polygon":return!function(e,t,r){for(const n of e.coordinates[0])if(Xr(n,t))return!0;for(const n of t.coordinates[0])if(Xr(n,e))return!0;return un(dn(e),dn(t),{ignoreSelfIntersections:r}).features.length>0}(t,e,r)}}var n,o;return!1}(e.geometry,t.geometry,r)})}),n}function fn(e,t){for(let r=0;r<e.coordinates.length-1;r++)if(vn(e.coordinates[r],e.coordinates[r+1],t.coordinates))return!0;return!1}function gn(e,t,r){for(const n of t.coordinates)if(Xr(n,e))return!0;return un(t,dn(e),{ignoreSelfIntersections:r}).features.length>0}function vn(e,t,r){const n=r[0]-e[0],o=r[1]-e[1],i=t[0]-e[0],a=t[1]-e[1];return 0===n*a-o*i&&(Math.abs(i)>=Math.abs(a)?i>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:a>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1])}var yn=Object.defineProperty,mn=(e,t)=>yn(e,"name",{value:t,configurable:!0}),bn=class{constructor(e){var t,r,n;this.direction=!1,this.compareProperties=!0,this.precision=10**-(null!=(t=null==e?void 0:e.precision)?t:17),this.direction=null!=(r=null==e?void 0:e.direction)&&r,this.compareProperties=null==(n=null==e?void 0:e.compareProperties)||n}compare(e,t){if(e.type!==t.type)return!1;if(!Pn(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates);case"Polygon":return this.comparePolygon(e,t);case"GeometryCollection":return this.compareGeometryCollection(e,t);case"Feature":return this.compareFeature(e,t);case"FeatureCollection":return this.compareFeatureCollection(e,t);default:if(e.type.startsWith("Multi")){const r=On(e),n=On(t);return r.every(e=>n.some(t=>this.compare(e,t)))}}return!1}compareCoord(e,t){return e.length===t.length&&e.every((e,r)=>Math.abs(e-t[r])<this.precision)}compareLine(e,t,r=0,n=!1){if(!Pn(e,t))return!1;const o=e;let i=t;if(n&&!this.compareCoord(o[0],i[0])){const e=this.fixStartIndex(i,o);if(!e)return!1;i=e}const a=this.compareCoord(o[r],i[r]);return this.direction||a?this.comparePath(o,i):!!this.compareCoord(o[r],i[i.length-(1+r)])&&this.comparePath(o.slice().reverse(),i)}fixStartIndex(e,t){let r,n=-1;for(let o=0;o<e.length;o++)if(this.compareCoord(e[o],t[0])){n=o;break}return n>=0&&(r=[].concat(e.slice(n,e.length),e.slice(1,n+1))),r}comparePath(e,t){return e.every((e,r)=>this.compareCoord(e,t[r]))}comparePolygon(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){const r=e.coordinates.slice(1,e.coordinates.length),n=t.coordinates.slice(1,t.coordinates.length);return r.every(e=>n.some(t=>this.compareLine(e,t,1,!0)))}return!1}compareGeometryCollection(e,t){return Pn(e.geometries,t.geometries)&&this.compareBBox(e,t)&&e.geometries.every((e,r)=>this.compare(e,t.geometries[r]))}compareFeature(e,t){return e.id===t.id&&(!this.compareProperties||wn(e.properties,t.properties))&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return Pn(e.features,t.features)&&this.compareBBox(e,t)&&e.features.every((e,r)=>this.compare(e,t.features[r]))}compareBBox(e,t){return Boolean(!e.bbox&&!t.bbox)||!(!e.bbox||!t.bbox)&&this.compareCoord(e.bbox,t.bbox)}};mn(bn,"GeojsonEquality");var En=bn;function Pn(e,t){return e.coordinates?e.coordinates.length===t.coordinates.length:e.length===t.length}function On(e){return e.coordinates.map(t=>({type:e.type.replace("Multi",""),coordinates:t}))}function Sn(e,t,r){return new En(r).compare(e,t)}function wn(e,t){if(null===e&&null===t)return!0;if(null===e||null===t)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o of r){const r=e[o],n=t[o],i=_n(r)&&_n(n);if(i&&!wn(r,n)||!i&&r!==n)return!1}return!0}mn(Pn,"sameLength"),mn(On,"explode"),mn(Sn,"geojsonEquality"),mn(wn,"equal");var _n=mn(e=>null!=e&&"object"==typeof e,"isObject");function Mn(e,t,r={}){const n=zr(e),o=Wr(t);for(let i=0;i<o.length-1;i++){let e=!1;if(r.ignoreEndVertices&&(0===i&&(e="start"),i===o.length-2&&(e="end"),0===i&&i+1===o.length-1&&(e="both")),xn(o[i],o[i+1],n,e,void 0===r.epsilon?null:r.epsilon))return!0}return!1}function xn(e,t,r,n,o){const i=r[0],a=r[1],s=e[0],l=e[1],c=t[0],u=t[1],d=c-s,p=u-l,h=(r[0]-s)*p-(r[1]-l)*d;if(null!==o){if(Math.abs(h)>o)return!1}else if(0!==h)return!1;return Math.abs(d)===Math.abs(p)&&0===Math.abs(d)?!n&&r[0]===e[0]&&r[1]===e[1]:n?"start"===n?Math.abs(d)>=Math.abs(p)?d>0?s<i&&i<=c:c<=i&&i<s:p>0?l<a&&a<=u:u<=a&&a<l:"end"===n?Math.abs(d)>=Math.abs(p)?d>0?s<=i&&i<c:c<i&&i<=s:p>0?l<=a&&a<u:u<a&&a<=l:"both"===n&&(Math.abs(d)>=Math.abs(p)?d>0?s<i&&i<c:c<i&&i<s:p>0?l<a&&a<u:u<a&&a<l):Math.abs(d)>=Math.abs(p)?d>0?s<=i&&i<=c:c<=i&&i<=s:p>0?l<=a&&a<=u:u<=a&&a<=l}function In(e,t={}){var r="object"==typeof t?t.mutate:t;if(!e)throw new Error("geojson is required");var n=function(e){return"FeatureCollection"===e.type?"FeatureCollection":"GeometryCollection"===e.type?"GeometryCollection":"Feature"===e.type&&null!==e.geometry?e.geometry.type:e.type}(e),o=[];switch(n){case"LineString":o=An(e,n);break;case"MultiLineString":case"Polygon":Wr(e).forEach(function(e){o.push(An(e,n))});break;case"MultiPolygon":Wr(e).forEach(function(e){var t=[];e.forEach(function(e){t.push(An(e,n))}),o.push(t)});break;case"Point":return e;case"MultiPoint":var i={};Wr(e).forEach(function(e){var t=e.join("-");Object.prototype.hasOwnProperty.call(i,t)||(o.push(e),i[t]=!0)});break;default:throw new Error(n+" geometry not supported")}return e.coordinates?!0===r?(e.coordinates=o,e):{type:n,coordinates:o}:!0===r?(e.geometry.coordinates=o,e):Ue({type:n,coordinates:o},e.properties,{bbox:e.bbox,id:e.id})}function An(e,t){const r=Wr(e);if(2===r.length&&!Tn(r[0],r[1]))return r;const n=[];let o=0,i=1,a=2;for(n.push(r[o]);a<r.length;)Mn(r[i],He([r[o],r[a]]))?i=a:(n.push(r[i]),o=i,i++,a=i),a++;if(n.push(r[i]),"Polygon"===t||"MultiPolygon"===t){if(Mn(n[0],He([n[1],n[n.length-2]]))&&(n.shift(),n.pop(),n.push(n[0])),n.length<4)throw new Error("invalid polygon, fewer than 4 points");if(!Tn(n[0],n[n.length-1]))throw new Error("invalid polygon, first and last points not equal")}return n}function Tn(e,t){return e[0]===t[0]&&e[1]===t[1]}function Cn(e,t,r={}){let n=r.precision;if(n=null==n||isNaN(n)?6:n,"number"!=typeof n||!(n>=0))throw new Error("precision must be a positive number");return Jr(e).type===Jr(t).type&&Sn(In(e),In(t),{precision:n})}function Ln(e,t){var r=Jr(e),n=Jr(t),o=r.type,i=n.type;switch(o){case"MultiPoint":switch(i){case"LineString":return Dn(r,n);case"Polygon":return jn(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"LineString":switch(i){case"MultiPoint":return Dn(n,r);case"LineString":return function(e,t){const r=un(e,t);if(0===r.features.length)return!1;for(const n of r.features)if(!(Cn(n.geometry,Ye(e.coordinates[0]))||Cn(n.geometry,Ye(e.coordinates[e.coordinates.length-1]))||Cn(n.geometry,Ye(t.coordinates[0]))||Cn(n.geometry,Ye(t.coordinates[t.coordinates.length-1]))))return!0;return!1}(r,n);case"Polygon":return kn(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"Polygon":switch(i){case"MultiPoint":return jn(n,r);case"LineString":return kn(n,r);default:throw new Error("feature2 "+i+" geometry not supported")}default:throw new Error("feature1 "+o+" geometry not supported")}}function Dn(e,t){for(var r=!1,n=!1,o=e.coordinates.length,i=0;i<o&&!r&&!n;){for(var a=0;a<t.coordinates.length-1;a++){var s=!0;0!==a&&a!==t.coordinates.length-2||(s=!1),Rn(t.coordinates[a],t.coordinates[a+1],e.coordinates[i],s)?r=!0:n=!0}i++}return r&&n}function kn(e,t){return un(e,dn(t)).features.length>0}function jn(e,t){var r=!1,n=!1,o=e.coordinates.length;for(let i=0;i<o&&(!r||!n);i++)Xr(Ye(e.coordinates[i]),t)?r=!0:n=!0;return n&&r}function Rn(e,t,r,n){var o=r[0]-e[0],i=r[1]-e[1],a=t[0]-e[0],s=t[1]-e[1];return 0===o*s-i*a&&(n?Math.abs(a)>=Math.abs(s)?a>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:s>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1]:Math.abs(a)>=Math.abs(s)?a>0?e[0]<r[0]&&r[0]<t[0]:t[0]<r[0]&&r[0]<e[0]:s>0?e[1]<r[1]&&r[1]<t[1]:t[1]<r[1]&&r[1]<e[1])}function Nn(e){return e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]}function Fn(e){for(var t=0;t<e.length-1;t++)for(var r=e[t],n=t+1;n<e.length-2;n++)if(Mn(r,He([e[n],e[n+1]])))return!0;return!1}function Bn(e,t,r){for(var n=Ge(e),o=r+1;o<t.length;o++)if(!hn(n,Ge(t[o]))&&Ln(n,He(t[o][0])))return!1;return!0}function Vn(e){let t=0;if(e&&e.length>0){t+=Math.abs(Gn(e[0]));for(let r=1;r<e.length;r++)t-=Math.abs(Gn(e[r]))}return t}var Un=20294876564838.72,Yn=Math.PI/180;function Gn(e){const t=e.length-1;if(t<=2)return 0;let r=0,n=0;for(;n<t;){const o=e[n],i=e[n+1===t?0:n+1],a=e[n+2>=t?(n+2)%t:n+2],s=o[0]*Yn,l=i[1]*Yn;r+=(a[0]*Yn-s)*Math.sin(l),n++}return r*Un}function Hn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function zn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Hn(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Hn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Wn=(e,t)=>{var r,n,o,i,a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"meters",n=e.geometry.coordinates,o=[],i=Kr(n[1],n[0]),a=Zr(n[0],t,i,{units:r});o.push(a.geometry.coordinates);for(var s=0;s<n.length;s++){if(s>0&&s<n.length-1){var l=Kr(n[s-1],n[s]),c=Zr(n[s],t,l,{units:r});o.push(c.geometry.coordinates)}o.push(n[s])}var u=Kr(n[n.length-2],n[n.length-1]),d=Zr(n[n.length-1],t,u,{units:r});return o.push(d.geometry.coordinates),He(o)}(t);try{i=function(e,t){var r=[],n=[],o=[],i=function(e,t,r,n,o){for(var i=0,a=[],s="Feature"===t.type?t.geometry:t,l="LineString"===s.type?[s.coordinates]:s.coordinates,c=0,u=0;u<l.length;u++){for(var d=l[u].length-1,p=new Ar(l[u][0]),h=null,f={nextEdge:null},g=0;g<d;g++){h=new Ar(l[u][g+1]),p.nextPoint=h,h.prevPoint=p;var v=new Ir(p,h,"polyline",c,null);n.push(v),f.nextEdge=v,v.prevEdge=f,o[0]=Math.min(o[0],p.p[0]),o[1]=Math.min(o[1],p.p[1]),o[2]=Math.max(o[2],p.p[0]),o[3]=Math.max(o[3],p.p[1]),p=h,c+=1,f=v}o[0]=Math.min(o[0],l[u][d][0]),o[1]=Math.min(o[1],l[u][d][1]),o[2]=Math.max(o[2],l[u][d][0]),o[3]=Math.max(o[3],l[u][d][1])}for(var y="Feature"===e.type?e.geometry:e,m="Polygon"===y.type?[y.coordinates]:y.coordinates,b=m.length,E=0;E<b;E++)for(var P=m[E].length,O=0;O<P;O++){i+=1;var S=m[E][O],w=S.length;a.push(new Tr(i,S));for(var _=new Ar(S[0]),M=_,x=void 0,I=null,A={nextEdge:null,prevEdge:null},T=null,C=1;C<w;C++)x=new Ar(S[C]),M.nextPoint=x,x.prevPoint=M,I=new Ir(M,x,"polygon",c,i),A.nextEdge=I,I.prevEdge=A,1===C&&(T=I),O>0&&(I.interiorRing=!0),I.intersectPolylineBbox=Cr(I,o),r.push(I),M=x,c+=1,A=I;I.nextEdge=T,T.prevEdge=I,x.nextPoint=_.nextPoint,_.prevPoint=x.prevPoint}return a}(function(e,t){if(null===(r=t=t||{})||"object"!=typeof r||Array.isArray(r))throw new Error("options is invalid");var r,n=t.reverse||!1,o=t.mutate||!1;if(!e)throw new Error("<geojson> is required");if("boolean"!=typeof n)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof o)throw new Error("<mutate> must be a boolean");!1===o&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return sr(e);case"FeatureCollection":return function(e){var t={type:"FeatureCollection"};return Object.keys(e).forEach(function(r){switch(r){case"type":case"features":return;default:t[r]=e[r]}}),t.features=e.features.map(function(e){return sr(e)}),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return cr(e);default:throw new Error("unknown GeoJSON type")}}(e));var i=[];switch(e.type){case"GeometryCollection":return et(e,function(e){hr(e,n)}),e;case"FeatureCollection":return Qe(e,function(e){Qe(hr(e,n),function(e){i.push(e)})}),ze(i)}return hr(e,n)}(e),t,n,o,[1/0,1/0,1/0,1/0]);if(function(e,t,r){var n,o,i,a=t.length,s=e.length;for(n=0;n<a;n++){var l=t[n];for(o=0;o<s;o++){var c=e[o];if(c.intersectPolylineBbox&&!(c.maxX<l.minX||c.minX>l.maxX||c.maxY<l.minY||c.minY>l.maxY)){var u=Nr(l,c);if(null!==u)for(i=0;i<u.length;i++){var d=Mr(c.p1.p[0],c.p1.p[1],c.p2.p[0],c.p2.p[1],l.p1.p[0],l.p1.p[1]),p=new Lr(u[i],l,c,d>0);r.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})})}(n,o,r),0===r.length)return e;var a={};i.forEach(function(e){return a[e.id]=0}),r.forEach(function(e){var t=e.polygonEdge.polygonContourId;a[t]=a[t]+1});for(var s=0,l=[],c=null,u=0;u<o.length;u++){var d=o[u];if(d.intersectionPoints.length>0){c=d.intersectionPoints[0];break}}for(var p=c,h={visitCount:1};c!==h&&!(s>2*r.length);){if(s=s++,h.visitCount>=2){for(var f=!1,g=0;g<r.length;g++){var v=r[g];if(v.visitCount<2){p=v,f=!0;break}}if(!f)break}p.visitCount=p.visitCount+1;var y=[];l.push(y),y.push(p.p),p.visitCount=p.visitCount+1;var m=Ur(p,y),b=!1;if(m===(h=m)&&2===r.length)for(var E=0;E<r.length;E++)r[E].visitCount<2&&(b=!0);for(;m!==p||b;)(m=(m.isHeadingIn?Hr:Gr)(m,y))!==p&&(m=Ur(m,y)),b=!1;if(h.visitCount>=2){for(var P=!1,O=0;O<r.length;O++){var S=r[O];if(S.visitCount<2){p=S,P=!0;break}}P&&(h=p)}p=h}for(var w=l.map(function(e){return[e]}),_=Object.keys(a),M=0;M<_.length;M++){var x=_[M];0===a[x]&&Vr(Br(Fr(n,parseInt(x)),i),w)}return{type:"Feature",properties:{},geometry:{type:"MultiPolygon",coordinates:w}}}(e,a)}catch(e){return null}var s=[];if("MultiPolygon"!==i.geometry.type)return null;if(2!==i.geometry.coordinates.length)return null;s=i.geometry.coordinates.map(t=>Ge(t,e.properties));var l=null!==(r=null!==(n=e.id)&&void 0!==n?n:null===(o=e.properties)||void 0===o?void 0:o.id)&&void 0!==r?r:"poly";return ze(s.map((t,r)=>Ge(t.geometry.coordinates,zn(zn({},e.properties),{},{id:l}),{id:"".concat(l,"-").concat(r+1)})))},Jn=(e,t)=>{var[r,n]=e,[o,i]=t,a=e=>e*Math.PI/180,s=a(i-n),l=a(o-r),c=Math.sin(s/2)**2+Math.cos(a(n))*Math.cos(a(i))*Math.sin(l/2)**2;return 12742e3*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))},Kn=e=>{if(e[0].length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e[0].length<=1)return!0;if(e[0].length<=3)for(var r=0;r<e[0].length;r++)for(var n=r+1;n<e[0].length;n++)if(Jn(e[0][r],e[0][n])<t)return!1;return!0}(e))return!0;if(!Array.isArray(e)||e.length<4)return!1;var t=e[0],r=e[e.length-1];if(t[0]!==r[0]||t[1]!==r[1])return!1;var n=Ge([e]);return!(!function(e){if(!e.type)return!1;const t=Jr(e),r=t.type,n=t.coordinates;switch(r){case"Point":return n.length>1;case"MultiPoint":for(var o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"LineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"MultiLineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"Polygon":for(o=0;o<t.coordinates.length;o++){if(n[o].length<4)return!1;if(!Nn(n[o]))return!1;if(Fn(n[o]))return!1;if(o>0&&un(Ge([n[0]]),Ge([n[o]])).features.length>1)return!1}return!0;case"MultiPolygon":for(o=0;o<t.coordinates.length;o++)for(var i=t.coordinates[o],a=0;a<i.length;a++){if(i[a].length<4)return!1;if(!Nn(i[a]))return!1;if(Fn(i[a]))return!1;if(0===a&&!Bn(i,t.coordinates,o))return!1;if(a>0&&un(Ge([i[0]]),Ge([i[a]])).features.length>1)return!1}return!0;default:return!1}}(n)||function(e){return function(e){var t=0;return et(e,function(e,r,n,o,i){t=((e,t)=>e+function(e){let t,r=0;switch(e.type){case"Polygon":return Vn(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)r+=Vn(e.coordinates[t]);return r;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(t))(t,e)}),t}(e)}(n)<=0)},qn={findVertexIndex(e,t,r){var n=[];return e.forEach((e,r)=>{e[0]===t[0]&&e[1]===t[1]&&n.push(r)}),0===n.length?-1:1===n.length?n[0]:r>=0?n.reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e):n[0]},getCoordPath(e,t){var r=this.getFeature(e.featureId);if(!r)return"0";var n=Jt(r),o=Kt(n,t);if(!o)return"0";var{segment:i,localIdx:a}=o;return[...i.path,a].join(".")},syncVertices(e){e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)},getVerticies(e){return Wt(this.getFeature(e))||[]},getMidpoints(e){var t=this.getFeature(e),r=Wt(t),n=Jt(t);if(null==r||!r.length||!n.length)return[];var o=[];for(var i of n)for(var a=i.closed?i.length:i.length-1,s=0;s<a;s++){var l=i.start+s,c=i.start+(s+1)%i.length,[u,d]=r[l],[p,h]=r[c];o.push([(u+p)/2,(d+h)/2])}return o},getVertexOrMidpoint(e,t){var r,n;if(null!==(r=e.vertecies)&&void 0!==r&&r.length||(e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),null===(n=e.vertecies)||void 0===n||!n.length)return[-1,null];var o=e=>e?Object.values(this.map.project(e)):null,i=[...e.vertecies.map(o),...e.midpoints.map(o)].filter(Boolean);if(!i.length)return[-1,null];var a=((e,t,r)=>{var n=t.filter((t,n)=>{var o=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);return("ArrowUp"===r?t[1]<=e[1]&&i>=o:"ArrowDown"===r?t[1]>e[1]&&i>=o:"ArrowLeft"===r?t[0]<=e[0]&&i<o:"ArrowRight"!==r||t[0]>e[0]&&i<o)&&JSON.stringify(t)!==JSON.stringify(e)});n.length||n.push(e);var o=n.map(t=>{return r=Math.abs(e[0]-t[0]),n=Math.abs(e[1]-t[1]),Math.sqrt(Math.pow(r,2)+Math.pow(n,2));var r,n}),i=n[o.indexOf(Math.min(...o))];return t.findIndex(e=>JSON.stringify(e)===JSON.stringify(i))})(i[e.selectedVertexIndex]||Object.values(this.map.project(this.map.getCenter())),i,t);return[a,a<e.vertecies.length?"vertex":"midpoint"]},getVertexIndexFromMidpoint(e,t){var r=this.getFeature(e.featureId),n=Jt(r),o=t.split(".").map(Number),i=0;for(var a of n){if(a.path.every((e,t)=>e===o[t])&&o.length===a.path.length+1){var s=o[o.length-1],l=s>0?s-1:a.length-2;return e.vertecies.length+i+l}i+=a.closed?a.length:a.length-1}return e.vertecies.length}};function Zn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Xn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Zn(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Zn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var $n=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),Qn={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},eo=Xn(Xn(Xn(Xn(Xn(Xn({},wt),Qt),nr),ar),qn),{},{onSetup(e){var t,r,n=wt.onSetup.call(this,e);Object.assign(n,{container:e.container,interfaceType:e.interfaceType,deleteVertexButtonId:e.deleteVertexButtonId,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,featureId:n.featureId||e.featureId,selectedVertexIndex:null!==(t=e.selectedVertexIndex)&&void 0!==t?t:-1,selectedVertexType:e.selectedVertexType,coordPath:e.coordPath,scale:null!==(r=e.scale)&&void 0!==r?r:1});var o=this.getFeature(n.featureId);n.featureType=null==o?void 0:o.type,n.vertecies=this.getVerticies(n.featureId),n.midpoints=this.getMidpoints(n.featureId),this.setupEventListeners(n),this.applyVertexSelection(n,e),this.map._drawEditContainer=e.container,this.addTouchVertexTarget(n);var i=h(this.map);if(i&&y(i,this.map),"touch"===n.interfaceType&&n.selectedVertexIndex>=0&&"vertex"===n.selectedVertexType){var a=n.vertecies[n.selectedVertexIndex];a&&setTimeout(()=>{this.updateTouchVertexTarget(n,Xt(this.map.project(a),n.scale))},0)}return n._ignorePointermoveDeselect=!0,setTimeout(()=>{n._ignorePointermoveDeselect=!1},100),n},setupEventListeners(e){var t=t=>r=>t.call(this,e,r),r=this.handlers={keydown:t(this.onKeydown),keyup:t(this.onKeyup),pointerdown:t(this.onPointerevent),pointermove:t(this.onPointerevent),pointerup:t(this.onPointerevent),click:t(this.onButtonClick),touchstart:t(this.onTouchstart),touchmove:t(this.onTouchmove),touchend:t(this.onTouchend),selectionchange:t(this.onSelectionChange),scalechange:t(this.onScaleChange),update:t(this.onUpdate),move:t(this.onMove),interfacetypechange:t(this.onInterfaceTypeChange)};window.addEventListener("keydown",r.keydown,{capture:!0}),window.addEventListener("keyup",r.keyup,{capture:!0}),window.addEventListener("click",r.click),e.container.addEventListener("pointerdown",r.pointerdown),e.container.addEventListener("pointermove",r.pointermove),e.container.addEventListener("pointerup",r.pointerup),e.container.addEventListener("touchstart",r.touchstart,{passive:!1}),e.container.addEventListener("touchmove",r.touchmove,{passive:!1}),e.container.addEventListener("touchend",r.touchend,{passive:!1}),this.map.on("draw.selectionchange",r.selectionchange),this.map.on("draw.scalechange",r.scalechange),this.map.on("draw.update",r.update),this.map.on("move",r.move),this.map.on("draw.interfacetypechange",r.interfacetypechange)},applyVertexSelection(e,t){if("midpoint"===t.selectedVertexType)return e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature&&e.feature.changed(),this._ctx.store.render(),void this.updateMidpoint(e.midpoints[t.selectedVertexIndex-e.vertecies.length]);-1===t.selectedVertexIndex&&(e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature&&e.feature.changed(),this._ctx.store.render())},onSelectionChange(e,t){var r,n;this.syncVertices(e);var o=null===(r=t.points[t.points.length-1])||void 0===r?void 0:r.geometry.coordinates;if("keyboard"!==e.interfaceType&&o&&!e.coordPath){var i,a=null===(i=t.features[0])||void 0===i?void 0:i.geometry,s=Wt(a);e.selectedVertexIndex=this.findVertexIndex(s,o,e.selectedVertexIndex)}null!==(n=e.selectedVertexType)&&void 0!==n||(e.selectedVertexType=e.selectedVertexIndex>=0?"vertex":null),this.map.fire("draw.vertexselection",{index:"vertex"===e.selectedVertexType?e.selectedVertexIndex:-1,numVertecies:e.vertecies.length});var l=o||(e.selectedVertexIndex>=0?e.vertecies[e.selectedVertexIndex]:null);this.updateTouchVertexTarget(e,l?Xt(this.map.project(l),e.scale):null)},onScaleChange(e,t){e.scale=t.scale},onInterfaceTypeChange(e,t){e.interfaceType=t.interfaceType;var r=e.selectedVertexIndex>=0?e.vertecies[e.selectedVertexIndex]:null;this.updateTouchVertexTarget(e,r?Xt(this.map.project(r),e.scale):null)},onUpdate(e){var t,r=new Set(e.vertecies.map(e=>JSON.stringify(e)));r.size!==e.vertecies.length&&(e.selectedVertexIndex=e.vertecies.findIndex(e=>!r.has(JSON.stringify(e))),null!==(t=e.selectedVertexType)&&void 0!==t||(e.selectedVertexType=e.selectedVertexIndex>=0?"vertex":null))},onKeydown(e,t){if(e.container.contains(document.activeElement)){if(e.interfaceType="keyboard",this.hideTouchVertexIndicator(e)," "===t.key&&t.preventDefault()," "===t.key&&e.selectedVertexIndex<0){var r,n,o=h(this.map);if(o&&y(o,this.map),null!==(r=e.vertecies)&&void 0!==r&&r.length||(e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),null===(n=e.vertecies)||void 0===n||!n.length)return;return e.isPanEnabled=!1,this.updateVertex(e)}if(!t.altKey&&$n.has(t.key)&&e.selectedVertexIndex>=0){if(t.preventDefault(),t.stopPropagation(),"midpoint"===e.selectedVertexType)return this.insertVertex(e,t);var i=h(this.map),a=this.getFeature(e.featureId);if(!a)return;var s=Wt(a),l=null==s?void 0:s[e.selectedVertexIndex];if(!l)return;if(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=[...l],e._keyboardMoveStartIndex=e.selectedVertexIndex),b(e)&&e._isSnapped&&i){var c=function(e){var t,r;return null!==(t=null==e||null===(r=e.options)||void 0===r?void 0:r.radius)&&void 0!==t?t:15}(i)+1,u=this.map.project(l),[d,p]=Qn[t.key].map(e=>e*c);return e._isSnapped=!1,y(i,this.map),this.moveVertex(e,this.map.unproject({x:u.x+d,y:u.y+p}))}var m=this.getNewCoord(e,t);return b(e)&&i&&(v(i,this.map,this.map.project(m)),f(i))?(e._isSnapped=!0,this.moveVertex(e,g(i))):(e._isSnapped=!1,this.moveVertex(e,m))}if(t.altKey&&$n.has(t.key)&&e.selectedVertexIndex>=0)return t.preventDefault(),t.stopPropagation(),this.updateVertex(e,t.key);if("Escape"===t.key&&this.changeMode(e,{isPanEnabled:!0,selectedVertexIndex:-1,selectedVertexType:null}),"z"===t.key&&(t.metaKey||t.ctrlKey)&&!t.shiftKey){var E,P=null===(E=document.activeElement)||void 0===E?void 0:E.tagName;if("INPUT"===P||"TEXTAREA"===P)return;return t.preventDefault(),t.stopPropagation(),this.handleUndo(e)}}},onKeyup(e,t){e.container.contains(document.activeElement)&&(e.interfaceType="keyboard",$n.has(t.key)&&e.selectedVertexIndex>=0&&(t.stopPropagation(),e._keyboardMoveStartPosition&&void 0!==e._keyboardMoveStartIndex&&(this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._keyboardMoveStartIndex,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null,e._keyboardMoveStartIndex=void 0)),"Delete"===t.key&&this.deleteVertex(e))},onMouseDown(e,t){var r,n;m(h(this.map));var o=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,i=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if(["vertex","midpoint"].includes(o)&&(e.dragMoveLocation=t.lngLat,e.dragMoving=!1,wt.onMouseDown.call(this,e,t),"vertex"===o&&i)){var a,s=this.getFeature(e.featureId),l=Zt(s,i);e.selectedVertexIndex=l,e.selectedVertexType="vertex",e.coordPath=i;var c=null===(a=e.vertecies)||void 0===a?void 0:a[l];c&&(e._moveStartPosition=[...c],e._moveStartIndex=l)}if("midpoint"===o){var u=this.getFeature(e.featureId),d=Zt(u,i);e._insertedVertexIndex=d,e._isInsertingVertex=!0,e.selectedVertexIndex=this.getVertexIndexFromMidpoint(e,i),e.selectedVertexType="vertex",e.coordPath=null,this.map.fire("draw.vertexselection",{index:e.selectedVertexIndex,numVertecies:e.vertecies.length})}},onClick(e,t){if(e._isInsertingVertex&&void 0!==e._insertedVertexIndex){var r=e._insertedVertexIndex;return this.syncVertices(e),this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:r}),e.selectedVertexIndex=r,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=void 0,void this.map.fire("draw.vertexselection",{index:r,numVertecies:e.vertecies.length})}wt.onClick.call(this,e,t)},onMouseUp(e,t){m(h(this.map));var r=!1;if(e._moveStartPosition&&void 0!==e._moveStartIndex){var n=this.getFeature(e.featureId);if(n){var o,i=null===(o=Wt(n))||void 0===o?void 0:o[e._moveStartIndex];i&&(r=i[0]!==e._moveStartPosition[0]||i[1]!==e._moveStartPosition[1])}}var a=e._isInsertingVertex&&void 0!==e._insertedVertexIndex;if(e.dragMoving||r||a)if(this.syncVertices(e),a){var s=e._insertedVertexIndex;this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:s}),e.selectedVertexIndex=s,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=void 0,this.map.fire("draw.vertexselection",{index:s,numVertecies:e.vertecies.length})}else r&&e._moveStartPosition&&void 0!==e._moveStartIndex&&this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition});e._moveStartPosition=null,e._moveStartIndex=null,wt.onMouseUp.call(this,e,t)},onDrag(e,t){var r;if("touch"!==e.interfaceType){this.map.fire("draw.geometrychange",e.feature);var n=h(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),b(e)&&null!=n&&n.status){if(null!==(r=e.selectedCoordPaths)&&void 0!==r&&r.length&&e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation(),v(n,this.map,t.point);var o=g(n)||t.lngLat;e.feature.updateCoordinate(e.selectedCoordPaths[0],o.lng,o.lat),e.dragMoveLocation=t.lngLat}}else wt.onDrag.call(this,e,t)}},onMove(e){var t=e.vertecies[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,Xt(this.map.project(t),e.scale))},onButtonClick(e,t){t.target.closest("#".concat(e.deleteVertexButtonId))&&"vertex"===e.selectedVertexType&&this.deleteVertex(e),t.target.closest("#".concat(e.undoButtonId))&&this.handleUndo(e)},clickNoTarget(e){this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,isPanEnabled:!0})},changeMode(e,t){e.featureId&&this._ctx.api.changeMode("edit_vertex",Xn(Xn({},e),t))},onStop(e){this.map._drawEditContainer=null;var t=this.handlers;e.container.removeEventListener("pointerdown",t.pointerdown),e.container.removeEventListener("pointermove",t.pointermove),e.container.removeEventListener("pointerup",t.pointerup),e.container.removeEventListener("touchstart",t.touchstart),e.container.removeEventListener("touchmove",t.touchmove),e.container.removeEventListener("touchend",t.touchend),this.map.off("draw.selectionchange",t.selectionchange),this.map.off("draw.scalechange",t.scalechange),this.map.off("draw.update",t.update),this.map.off("move",t.move),this.map.off("draw.interfacetypechange",t.interfacetypechange),this.map.dragPan.enable(),window.removeEventListener("click",t.click),window.removeEventListener("keydown",t.keydown,{capture:!0}),window.removeEventListener("keyup",t.keyup,{capture:!0}),this.hideTouchVertexIndicator(e)}});function to(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ro(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?to(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):to(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var no=(e,t)=>{var{featureProp:r,geometryType:n,getCoords:o,validateClick:i,createVertices:a,excludeFeatureIdFromSetup:s=!1,finishOnInvalidClick:l=!1}=t,c=e=>e[r];return ro(ro({},e),{},{onSetup(t){var{map:n}=this,o=s?ro(ro({},t),{},{featureId:null}):t,i=ro(ro({},e.onSetup.call(this,o)),t);i[r].properties=t.properties;var{container:a,vertexMarkerId:l,getInterfaceType:c}=i,u=c?c():i.interfaceType;i.interfaceType=u;var d=a.querySelector("#".concat(l));i.vertexMarker=d,["touch","keyboard"].includes(u)?this._showCrossHair(i):this._hideCrossHair(i);var p=(e,t)=>this[e]=t.bind(this,i),h={keydownHandler:this.onKeydown,keyupHandler:this.onKeyup,blurHandler:this.onBlur,createHandler:this.onCreate,moveHandler:this.onMove,pointerdownHandler:this.onPointerdown,pointermoveHandler:this.onPointermove,pointerupHandler:this.onPointerup,vertexButtonClickHandler:this.onVertexButtonClick,undoHandler:this.onUndo};return Object.entries(h).forEach(e=>{var[t,r]=e;return p(t,r)}),this._listeners=[[window,"keydown",this.keydownHandler],[window,"keyup",this.keyupHandler],[window,"click",this.vertexButtonClickHandler],[a,"blur",this.blurHandler],[a,"pointermove",this.pointermoveHandler],[a,"pointerup",this.pointerupHandler],[n,"pointerdown",this.pointerdownHandler],[n,"draw.create",this.createHandler],[n,"move",this.moveHandler],[n,"draw.undo",this.undoHandler]],this._listeners.forEach(e=>{var[t,r,n]=e;return t.addEventListener?t.addEventListener(r,n):t.on(r,n)}),i},onClick(t,r){if(!(r.originalEvent.button>0||this.map._undoInProgress||r.originalEvent.target!==this.map.getCanvas())){var n=h(this.map);if(b(t)&&f(n))r=function(e,t){var r=g(t);return r?p(p({},e),{},{lngLat:r}):e}(r,n);else{var a=o(c(t));if(a.length>0&&(a[a.length-1]=[r.lngLat.lng,r.lngLat.lat]),!l&&!i(c(t)))return}var s=o(c(t)).length;e.onClick.call(this,t,r),o(c(t)).length>s&&(this.pushDrawUndo(t),this.dispatchVertexChange(o(c(t))))}},onTap(){},doClick(t){if(!this.map._undoInProgress){var r=c(t),n=o(r);if(this.dispatchVertexChange(n),i(r)){var a=h(this.map),s=b(t)&&function(e,t){var r=g(t);if(!r)return null;var n=e.project([r.lng,r.lat]);return{lngLat:r,point:n,originalEvent:new MouseEvent("click",{clientX:n.x,clientY:n.y,bubbles:!0,cancelable:!0})}}(this.map,a),u=n.length;s?(e.onClick.call(this,t,s),this._ctx.store.render()):this._simulateMouse("click",e.onClick,t);var d=o(c(t));d.length>u&&(this.pushDrawUndo(t),this.dispatchVertexChange(d))}else l&&n.length>1&&(n.pop(),this.map.fire("draw.create",{features:[r.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[r.id]}))}},dispatchVertexChange(e){this.map.fire("draw.vertexchange",{numVertecies:Math.max(0,e.length-1)})},pushDrawUndo(e){var t=this.map._undoStack;t&&!this.map._undoInProgress&&t.push({type:"draw_vertex",geometryType:n,featureId:c(e).id})},undoVertex(e){var t=c(e),r=o(t);return!(r.length<2)&&(2===r.length?this._reinitializeFeature(e,t):(this._removeLastVertex(e,t,r),!0))},_reinitializeFeature(t,o){var i=o.id;if(this._ctx.store.delete([i]),"LineString"===n){var a=this.map._undoStack;return a&&a.clear(),this._ctx.api.changeMode("draw_line",{featureId:i,container:t.container,interfaceType:t.interfaceType,crossHair:t.crossHair,vertexMarkerId:t.vertexMarkerId,addVertexButtonId:t.addVertexButtonId,getSnapEnabled:t.getSnapEnabled,properties:t.properties}),!0}var s=this.map.getCenter(),l=[[s.lng,s.lat],[s.lng,s.lat]],c=this.newFeature({type:"Feature",properties:t.properties||{},geometry:{type:n,coordinates:[l]}});return c.id=i,this._ctx.store.add(c),t[r]=c,t.currentVertexPosition=0,this._ctx.store.render(),this._simulateMouse("mousemove",e.onMouseMove,t),this._ctx.store.render(),this.dispatchVertexChange(l),!0},_removeLastVertex(e,t,r){var i="Polygon"===n?t.coordinates[0]:r;i.splice(-2,1);var a=i[i.length-2];a&&(i[i.length-1]=[...a]),e.currentVertexPosition=Math.max(1,e.currentVertexPosition-1),this._ctx.store.render(),this._updateRubberBand(e,o(t))},_updateRubberBand(t,r){if(["touch","keyboard"].includes(t.interfaceType))this._simulateMouse("mousemove",e.onMouseMove,t),this._ctx.store.render();else{var o=r["Polygon"===n?r.length-2:r.length-1];if(o){var i={lng:o[0],lat:o[1]},a=this.map.project(i);e.onMouseMove.call(this,t,{lngLat:i,point:a,originalEvent:new MouseEvent("mousemove",{clientX:a.x,clientY:a.y})}),this._ctx.store.render()}}this.dispatchVertexChange(r)},onUndo(e,t){var r;"draw_vertex"===(null===(r=t.operation)||void 0===r?void 0:r.type)&&this.undoVertex(e)},_simulateMouse(e,t,r){var{map:n}=this,o=n.getCenter(),i=n.project(o);t.call(this,r,{lngLat:o,point:i,originalEvent:new MouseEvent(e,{clientX:i.x,clientY:i.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",r.polygon||r.line)},_showCrossHair(e){e.crossHair?e.crossHair.show():e.vertexMarker.style.display="block"},_hideCrossHair(e){e.crossHair?e.crossHair.hide():e.vertexMarker.style.display="none"},_setInterface(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e.interfaceType=t,r&&this._showCrossHair(e)},onCreate(e,t){var r=this._ctx.api,n=t.features[0];r.delete(n.id),n.id=e.featureId,r.add(n,{userProperties:!0})},onVertexButtonClick(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest("#".concat(e.addVertexButtonId))&&this.doClick(e)},onTouchStart(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onTouchEnd(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},_handleUndoKeydown(e,t){var r,n=null===(r=document.activeElement)||void 0===r?void 0:r.tagName;if("INPUT"!==n&&"TEXTAREA"!==n){t.preventDefault(),t.stopPropagation();var o=this.map._undoStack;if(o&&o.length>0){var i=o.pop();"draw_vertex"===(null==i?void 0:i.type)&&(this.map._undoInProgress=!0,setTimeout(()=>{this.map._undoInProgress=!1},100),this.undoVertex(e))}}},onKeydown(e,t){"z"!==t.key||!t.metaKey&&!t.ctrlKey||t.shiftKey?document.activeElement===e.container&&("Escape"!==t.key?("Enter"===t.key&&(e.isActive=!0),this._setInterface(e,"keyboard"),this.onMove(e,t)):t.preventDefault()):this._handleUndoKeydown(e,t)},onKeyup(e,t){"Escape"!==t.key?document.activeElement===e.container&&(this._setInterface(e,"keyboard"),this.onMove(e,t),"Enter"===t.key&&e.isActive&&this.doClick(e)):"keyboard"!==e.interfaceType&&this.map.fire("draw.cancel")},onKeyUp(t,r){var n=document.activeElement;if(!n||n===t.container||!t.container.contains(n))if("Escape"!==r.key)n!==t.container&&e.onKeyUp.call(this,t,r);else if("keyboard"===t.interfaceType){var o=this.map._undoStack;o&&o.clear(),this._reinitializeFeature(t,c(t))}},onBlur(e,t){t.target!==e.container&&this._hideCrossHair(e)},onMouseMove(t,r){if(b(t)){var n=h(this.map);v(n,this.map,r.point);var o=g(n);o&&(r=ro(ro({},r),{},{lngLat:o}))}this.map.fire("draw.geometrychange",t.polygon||t.line),e.onMouseMove.call(this,t,r)},onMove(t){if(["touch","keyboard"].includes(t.interfaceType)){b(t)&&function(e,t){if(!e||!t||!e.status)return!1;var r=t.getCenter(),n=t.project(r);e.snapToClosestPoint({point:n,lngLat:r})}(h(this.map),this.map);var r=h(this.map),n=b(t)&&g(r);if(n){var o=this.map.project([n.lng,n.lat]);e.onMouseMove.call(this,t,{lngLat:n,point:o,originalEvent:new MouseEvent("mousemove",{clientX:o.x,clientY:o.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render()}else this._simulateMouse("mousemove",e.onMouseMove,t)}},onPointerdown(e,t){"touch"!==t.pointerType&&this._setInterface(e,"mouse",!1)},onPointermove(e,t){"touch"!==t.pointerType&&this._hideCrossHair(e)},onPointerup(e){this.dispatchVertexChange(o(c(e)))},toDisplayFeatures(t,r,o){e.toDisplayFeatures.call(this,t,r,o);var i=c(t);r.geometry.type===n&&r.id===i.id&&a(r,o,Fe)},onStop(t){e.onStop.call(this,t),this._listeners.forEach(e=>{var[t,r,n]=e;return t.removeEventListener?t.removeEventListener(r,n):t.off(r,n)}),this._hideCrossHair(t)}})},oo=no(xt,{featureProp:"polygon",geometryType:"Polygon",getCoords:e=>e.coordinates[0],validateClick:e=>Kn(e.coordinates),createVertices:(e,t,r)=>{for(var n=e.geometry.coordinates[0],o=1;o<n.length-2;o++)t(r(e.id,n[o],"0.".concat(o)))}}),io=no(It,{featureProp:"line",geometryType:"LineString",getCoords:e=>e.coordinates,validateClick:e=>(e=>e.length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e.length<=1)return!0;if(e.length>=2){var r=e[e.length-1],n=e[e.length-2];if(Jn(r,n)<t)return!1}return!0}(e))(e.coordinates),excludeFeatureIdFromSetup:!0,finishOnInvalidClick:!0,createVertices:(e,t,r)=>{for(var n=e.geometry.coordinates,o=1;o<n.length-1;o++)t(r(e.id,n[o],"".concat(o)))}}),ao={editStroke:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editVertex:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editMidpoint:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editHalo:{light:"#ffffff",dark:"rgba(11,12,12,1)"},editActive:{light:"rgba(11,12,12,1)",dark:"#ffffff"},splitInvalid:{light:"rgba(29,112,184,1)",dark:"rgba(29,112,184,1)"},splitValid:{light:"rgba(29,112,184,1)",dark:"rgba(29,112,184,1)"},shapeStroke:"rgba(212,53,28,1)",shapeFill:"rgba(212,53,28,0.1)",strokeWidth:2,snapVertex:"rgba(212,53,28,1)",snapMidpoint:"rgba(40,161,151,1)",snapEdge:"rgba(29,112,184,1)",snapRadius:10,snapLayers:[]},so=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;return["coalesce",["get","user_".concat(t).concat(e.id.charAt(0).toUpperCase()+e.id.slice(1))],["get","user_".concat(t)],ao[r]]},lo=e=>({id:"fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","false"]],paint:{"fill-color":so(e,"fill","shapeFill")}}),co=e=>({id:"stroke-inactive",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","false"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":so(e,"stroke","shapeStroke"),"line-width":so(e,"strokeWidth")}}),uo=e=>({id:"fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":e,"fill-opacity":.1}}),po=e=>({id:"stroke-active",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-opacity":1}}),ho=e=>({id:"stroke-invalid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","invalid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}),fo=e=>({id:"stroke-valid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","valid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-opacity":1}}),go=e=>({id:"stroke-preview-line",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}),vo=e=>({id:"vertex",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"]],paint:{"circle-radius":6,"circle-color":e}}),yo=(e,t)=>({id:"vertex-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":8,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}),mo=e=>({id:"vertex-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":e}}),bo=e=>({id:"midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":4,"circle-color":e}}),Eo=(e,t)=>({id:"midpoint-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}),Po=e=>({id:"midpoint-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":4,"circle-color":e}}),Oo=e=>({id:"circle",type:"line",filter:["==","id","circle"],paint:{"line-color":e,"line-width":2,"line-opacity":.8}}),So=e=>{var t=(e=>{var t;return null!==(t=e.mapColorScheme)&&void 0!==t?t:"light"})(e),r=ao.editStroke[t],n=ao.editVertex[t],o=ao.editMidpoint[t],i=ao.editHalo[t],a=ao.editActive[t],s=ao.splitInvalid[t],l=ao.splitValid[t];return[lo(e),uo(r),po(r),co(e),ho(s),fo(l),go(r),bo(o),Eo(i,a),Po(o),vo(n),yo(i,a),mo(n),Oo(r),{id:"touch-vertex-indicator",type:"circle",filter:["all",["==","$type","Point"],["==","meta","touch-vertex-indicator"]],paint:{"circle-radius":30,"circle-color":"#3bb2d0","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":.9}}]};function wo(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function _o(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 Mo(e,t,r){void 0===r&&(r={});var n=wo(e),o=wo(t),i=Ze(o[1]-n[1]),a=Ze(o[0]-n[0]),s=Ze(n[1]),l=Ze(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(l);return Je(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)}function xo(e,t){var r;return void 0===t&&(t={}),function(e,t){return e.length>1?We(e,t):He(e[0],t)}(("Feature"===(r=e).type?r.geometry:r).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}function Io(e,t,r,n){void 0===n&&(n={});var o=wo(e),i=Ze(o[0]),a=Ze(o[1]),s=Ze(r),l=Ke(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(l)+Math.cos(a)*Math.sin(l)*Math.cos(s));return Ye([qe(i+Math.atan2(Math.sin(s)*Math.sin(l)*Math.cos(a),Math.cos(l)-Math.sin(a)*Math.sin(c))),qe(c)],n.properties)}function Ao(e){if(!e)throw new Error("geojson is required");var t=[];return tt(e,function(e){!function(e,t){var r=[],n=e.geometry;if(null!==n){switch(n.type){case"Polygon":r=_o(n);break;case"LineString":r=[_o(n)]}r.forEach(function(r){var n=function(e,t){var r=[];return e.reduce(function(e,n){var o,i,a,s,l,c,u=He([e,n],t);return u.bbox=(i=n,a=(o=e)[0],s=o[1],[a<(l=i[0])?a:l,s<(c=i[1])?s:c,a>l?a:l,s>c?s:c]),r.push(u),n}),r}(r,e.properties);n.forEach(function(e){e.id=t.length,t.push(e)})})}}(e,t)}),ze(t)}var To={exports:{}};function Co(e,t,r,n,o){Lo(e,t,r||0,n||e.length-1,o||ko)}function Lo(e,t,r,n,o){for(;n>r;){if(n-r>600){var i=n-r+1,a=t-r+1,s=Math.log(i),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(i-l)/i)*(a-i/2<0?-1:1);Lo(e,t,Math.max(r,Math.floor(t-a*l/i+c)),Math.min(n,Math.floor(t+(i-a)*l/i+c)),o)}var u=e[t],d=r,p=n;for(Do(e,r,t),o(e[n],u)>0&&Do(e,r,n);d<p;){for(Do(e,d,p),d++,p--;o(e[d],u)<0;)d++;for(;o(e[p],u)>0;)p--}0===o(e[r],u)?Do(e,r,p):Do(e,++p,n),p<=t&&(r=p+1),t<=p&&(n=p-1)}}function Do(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function ko(e,t){return e<t?-1:e>t?1:0}function jo(e,t,r){if(!r)return t.indexOf(e);for(let n=0;n<t.length;n++)if(r(e,t[n]))return n;return-1}function Ro(e,t){No(e,0,e.children.length,t,e)}function No(e,t,r,n,o){o||(o=Jo(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(let i=t;i<r;i++){const t=e.children[i];Fo(o,e.leaf?n(t):t)}return o}function Fo(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Bo(e,t){return e.minX-t.minX}function Vo(e,t){return e.minY-t.minY}function Uo(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Yo(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Go(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function Ho(e,t){const r=Math.max(e.minX,t.minX),n=Math.max(e.minY,t.minY),o=Math.min(e.maxX,t.maxX),i=Math.min(e.maxY,t.maxY);return Math.max(0,o-r)*Math.max(0,i-n)}function zo(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Wo(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Jo(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ko(e,t,r,n,o){const i=[t,r];for(;i.length;){if((r=i.pop())-(t=i.pop())<=n)continue;const a=t+Math.ceil((r-t)/n/2)*n;Co(e,a,t,r,o),i.push(t,a,a,r)}}var qo,Zo=Object.freeze({__proto__:null,default:class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const r=[];if(!Wo(e,t))return r;const n=this.toBBox,o=[];for(;t;){for(let i=0;i<t.children.length;i++){const a=t.children[i],s=t.leaf?n(a):a;Wo(e,s)&&(t.leaf?r.push(a):zo(e,s)?this._all(a,r):o.push(a))}t=o.pop()}return r}collides(e){let t=this.data;if(!Wo(e,t))return!1;const r=[];for(;t;){for(let n=0;n<t.children.length;n++){const o=t.children[n],i=t.leaf?this.toBBox(o):o;if(Wo(e,i)){if(t.leaf||zo(e,i))return!0;r.push(o)}}t=r.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Jo([]),this}remove(e,t){if(!e)return this;let r=this.data;const n=this.toBBox(e),o=[],i=[];let a,s,l;for(;r||o.length;){if(r||(r=o.pop(),s=o[o.length-1],a=i.pop(),l=!0),r.leaf){const n=jo(e,r.children,t);if(-1!==n)return r.children.splice(n,1),o.push(r),this._condense(o),this}l||r.leaf||!zo(r,n)?s?(a++,r=s.children[a],l=!1):r=null:(o.push(r),i.push(a),a=0,s=r,r=r.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const r=[];for(;e;)e.leaf?t.push(...e.children):r.push(...e.children),e=r.pop();return t}_build(e,t,r,n){const o=r-t+1;let i,a=this._maxEntries;if(o<=a)return i=Jo(e.slice(t,r+1)),Ro(i,this.toBBox),i;n||(n=Math.ceil(Math.log(o)/Math.log(a)),a=Math.ceil(o/Math.pow(a,n-1))),i=Jo([]),i.leaf=!1,i.height=n;const s=Math.ceil(o/a),l=s*Math.ceil(Math.sqrt(a));Ko(e,t,r,l,this.compareMinX);for(let c=t;c<=r;c+=l){const t=Math.min(c+l-1,r);Ko(e,c,t,s,this.compareMinY);for(let r=c;r<=t;r+=s){const o=Math.min(r+s-1,t);i.children.push(this._build(e,r,o,n-1))}}return Ro(i,this.toBBox),i}_chooseSubtree(e,t,r,n){for(;n.push(t),!t.leaf&&n.length-1!==r;){let r,n=1/0,o=1/0;for(let i=0;i<t.children.length;i++){const a=t.children[i],s=Uo(a),l=Go(e,a)-s;l<o?(o=l,n=s<n?s:n,r=a):l===o&&s<n&&(n=s,r=a)}t=r||t.children[0]}return t}_insert(e,t,r){const n=r?e:this.toBBox(e),o=[],i=this._chooseSubtree(n,this.data,t,o);for(i.children.push(e),Fo(i,n);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(n,o,t)}_split(e,t){const r=e[t],n=r.children.length,o=this._minEntries;this._chooseSplitAxis(r,o,n);const i=this._chooseSplitIndex(r,o,n),a=Jo(r.children.splice(i,r.children.length-i));a.height=r.height,a.leaf=r.leaf,Ro(r,this.toBBox),Ro(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(r,a)}_splitRoot(e,t){this.data=Jo([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Ro(this.data,this.toBBox)}_chooseSplitIndex(e,t,r){let n,o=1/0,i=1/0;for(let a=t;a<=r-t;a++){const t=No(e,0,a,this.toBBox),s=No(e,a,r,this.toBBox),l=Ho(t,s),c=Uo(t)+Uo(s);l<o?(o=l,n=a,i=c<i?c:i):l===o&&c<i&&(i=c,n=a)}return n||r-t}_chooseSplitAxis(e,t,r){const n=e.leaf?this.compareMinX:Bo,o=e.leaf?this.compareMinY:Vo;this._allDistMargin(e,t,r,n)<this._allDistMargin(e,t,r,o)&&e.children.sort(n)}_allDistMargin(e,t,r,n){e.children.sort(n);const o=this.toBBox,i=No(e,0,t,o),a=No(e,r-t,r,o);let s=Yo(i)+Yo(a);for(let l=t;l<r-t;l++){const t=e.children[l];Fo(i,e.leaf?o(t):t),s+=Yo(i)}for(let l=r-t-1;l>=t;l--){const t=e.children[l];Fo(a,e.leaf?o(t):t),s+=Yo(a)}return s}_adjustParentBBoxes(e,t,r){for(let n=r;n>=0;n--)Fo(t[n],e)}_condense(e){for(let t,r=e.length-1;r>=0;r--)0===e[r].children.length?r>0?(t=e[r-1].children,t.splice(t.indexOf(e[r]),1)):this.clear():Ro(e[r],this.toBBox)}}}),Xo=function(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var r=function e(){var r=!1;try{r=this instanceof e}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}(Zo),$o={};function Qo(){if(qo)return $o;qo=1,Object.defineProperty($o,"__esModule",{value:!0});var e=6371008.8,t={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*e,kilometers:6371.0088,kilometres:6371.0088,meters:e,metres:e,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:e/1852,radians:1,yards:6967335.223679999},r={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:2.9155334959812285e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046};function n(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function o(e,t,r={}){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(!f(e[0])||!f(e[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:e},t,r)}function i(e,t,r={}){for(const n of e){if(n.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(n[n.length-1].length!==n[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<n[n.length-1].length;e++)if(n[n.length-1][e]!==n[0][e])throw new Error("First and last Position are not equivalent.")}return n({type:"Polygon",coordinates:e},t,r)}function a(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return n({type:"LineString",coordinates:e},t,r)}function s(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function l(e,t,r={}){return n({type:"MultiLineString",coordinates:e},t,r)}function c(e,t,r={}){return n({type:"MultiPoint",coordinates:e},t,r)}function u(e,t,r={}){return n({type:"MultiPolygon",coordinates:e},t,r)}function d(e,r="kilometers"){const n=t[r];if(!n)throw new Error(r+" units is invalid");return e*n}function p(e,r="kilometers"){const n=t[r];if(!n)throw new Error(r+" units is invalid");return e/n}function h(e){return e%(2*Math.PI)*180/Math.PI}function f(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}return $o.areaFactors=r,$o.azimuthToBearing=function(e){return(e%=360)>180?e-360:e<-180?e+360:e},$o.bearingToAzimuth=function(e){let t=e%360;return t<0&&(t+=360),t},$o.convertArea=function(e,t="meters",n="kilometers"){if(!(e>=0))throw new Error("area must be a positive number");const o=r[t];if(!o)throw new Error("invalid original units");const i=r[n];if(!i)throw new Error("invalid final units");return e/o*i},$o.convertLength=function(e,t="kilometers",r="kilometers"){if(!(e>=0))throw new Error("length must be a positive number");return d(p(e,t),r)},$o.degreesToRadians=function(e){return e%360*Math.PI/180},$o.earthRadius=e,$o.factors=t,$o.feature=n,$o.featureCollection=s,$o.geometry=function(e,t,r={}){switch(e){case"Point":return o(t).geometry;case"LineString":return a(t).geometry;case"Polygon":return i(t).geometry;case"MultiPoint":return c(t).geometry;case"MultiLineString":return l(t).geometry;case"MultiPolygon":return u(t).geometry;default:throw new Error(e+" is invalid")}},$o.geometryCollection=function(e,t,r={}){return n({type:"GeometryCollection",geometries:e},t,r)},$o.isNumber=f,$o.isObject=function(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)},$o.lengthToDegrees=function(e,t){return h(p(e,t))},$o.lengthToRadians=p,$o.lineString=a,$o.lineStrings=function(e,t,r={}){return s(e.map(e=>a(e,t)),r)},$o.multiLineString=l,$o.multiPoint=c,$o.multiPolygon=u,$o.point=o,$o.points=function(e,t,r={}){return s(e.map(e=>o(e,t)),r)},$o.polygon=i,$o.polygons=function(e,t,r={}){return s(e.map(e=>i(e,t)),r)},$o.radiansToDegrees=h,$o.radiansToLength=d,$o.round=function(e,t=0){if(t&&!(t>=0))throw new Error("precision must be a positive number");const r=Math.pow(10,t||0);return Math.round(e*r)/r},$o.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(e=>{if(!f(e))throw new Error("bbox must only contain numbers")})},$o.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")},$o}var ei,ti={};function ri(){if(ei)return ti;ei=1,Object.defineProperty(ti,"__esModule",{value:!0});var e=Qo();function t(e,r,n){if(null!==e)for(var o,i,a,s,l,c,u,d,p=0,h=0,f=e.type,g="FeatureCollection"===f,v="Feature"===f,y=g?e.features.length:1,m=0;m<y;m++){l=(d=!!(u=g?e.features[m].geometry:v?e.geometry:e)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var b=0;b<l;b++){var E=0,P=0;if(null!==(s=d?u.geometries[b]:u)){c=s.coordinates;var O=s.type;switch(p=!n||"Polygon"!==O&&"MultiPolygon"!==O?0:1,O){case null:break;case"Point":if(!1===r(c,h,m,E,P))return!1;h++,E++;break;case"LineString":case"MultiPoint":for(o=0;o<c.length;o++){if(!1===r(c[o],h,m,E,P))return!1;h++,"MultiPoint"===O&&E++}"LineString"===O&&E++;break;case"Polygon":case"MultiLineString":for(o=0;o<c.length;o++){for(i=0;i<c[o].length-p;i++){if(!1===r(c[o][i],h,m,E,P))return!1;h++}"MultiLineString"===O&&E++,"Polygon"===O&&P++}"Polygon"===O&&E++;break;case"MultiPolygon":for(o=0;o<c.length;o++){for(P=0,i=0;i<c[o].length;i++){for(a=0;a<c[o][i].length-p;a++){if(!1===r(c[o][i][a],h,m,E,P))return!1;h++}P++}E++}break;case"GeometryCollection":for(o=0;o<s.geometries.length;o++)if(!1===t(s.geometries[o],r,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function r(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function n(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function o(e,t){var r,n,o,i,a,s,l,c,u,d,p=0,h="FeatureCollection"===e.type,f="Feature"===e.type,g=h?e.features.length:1;for(r=0;r<g;r++){for(s=h?e.features[r].geometry:f?e.geometry:e,c=h?e.features[r].properties:f?e.properties:{},u=h?e.features[r].bbox:f?e.bbox:void 0,d=h?e.features[r].id:f?e.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=l?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,u,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,u,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,u,d))return!1;p++}}function i(t,r){o(t,function(t,n,o,i,a){var s,l=null===t?null:t.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return!1!==r(e.feature.call(void 0,t,o,{bbox:i,id:a}),n,0)&&void 0}switch(l){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<t.coordinates.length;c++){var u={type:s,coordinates:t.coordinates[c]};if(!1===r(e.feature.call(void 0,u,o),n,c))return!1}})}function a(r,n){i(r,function(r,o,i){var a=0;if(r.geometry){var s=r.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var l,c=0,u=0,d=0;return!1!==t(r,function(t,s,p,h,f){if(void 0===l||o>c||h>u||f>d)return l=t,c=o,u=h,d=f,void(a=0);var g=e.lineString.call(void 0,[l,t],r.properties);if(!1===n(g,o,i,f,a))return!1;a++,l=t})&&void 0}}})}function s(t,r){if(!t)throw new Error("geojson is required");i(t,function(t,n,o){if(null!==t.geometry){var i=t.geometry.type,a=t.geometry.coordinates;switch(i){case"LineString":if(!1===r(t,n,o,0,0))return!1;break;case"Polygon":for(var s=0;s<a.length;s++)if(!1===r(e.lineString.call(void 0,a[s],t.properties),n,o,s))return!1}}})}return ti.coordAll=function(e){var r=[];return t(e,function(e){r.push(e)}),r},ti.coordEach=t,ti.coordReduce=function(e,r,n,o){var i=n;return t(e,function(e,t,o,a,s){i=0===t&&void 0===n?e:r(i,e,t,o,a,s)},o),i},ti.featureEach=n,ti.featureReduce=function(e,t,r){var o=r;return n(e,function(e,n){o=0===n&&void 0===r?e:t(o,e,n)}),o},ti.findPoint=function(t,r){if(r=r||{},!e.isObject.call(void 0,r))throw new Error("options is invalid");var n,o=r.featureIndex||0,i=r.multiFeatureIndex||0,a=r.geometryIndex||0,s=r.coordIndex||0,l=r.properties;switch(t.type){case"FeatureCollection":o<0&&(o=t.features.length+o),l=l||t.features[o].properties,n=t.features[o].geometry;break;case"Feature":l=l||t.properties,n=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":n=t;break;default:throw new Error("geojson is invalid")}if(null===n)return null;var c=n.coordinates;switch(n.type){case"Point":return e.point.call(void 0,c,l,r);case"MultiPoint":return i<0&&(i=c.length+i),e.point.call(void 0,c[i],l,r);case"LineString":return s<0&&(s=c.length+s),e.point.call(void 0,c[s],l,r);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s),e.point.call(void 0,c[a][s],l,r);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),e.point.call(void 0,c[i][s],l,r);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s),e.point.call(void 0,c[i][a][s],l,r)}throw new Error("geojson is invalid")},ti.findSegment=function(t,r){if(r=r||{},!e.isObject.call(void 0,r))throw new Error("options is invalid");var n,o=r.featureIndex||0,i=r.multiFeatureIndex||0,a=r.geometryIndex||0,s=r.segmentIndex||0,l=r.properties;switch(t.type){case"FeatureCollection":o<0&&(o=t.features.length+o),l=l||t.features[o].properties,n=t.features[o].geometry;break;case"Feature":l=l||t.properties,n=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":n=t;break;default:throw new Error("geojson is invalid")}if(null===n)return null;var c=n.coordinates;switch(n.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),e.lineString.call(void 0,[c[s],c[s+1]],l,r);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s-1),e.lineString.call(void 0,[c[a][s],c[a][s+1]],l,r);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),e.lineString.call(void 0,[c[i][s],c[i][s+1]],l,r);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s-1),e.lineString.call(void 0,[c[i][a][s],c[i][a][s+1]],l,r)}throw new Error("geojson is invalid")},ti.flattenEach=i,ti.flattenReduce=function(e,t,r){var n=r;return i(e,function(e,o,i){n=0===o&&0===i&&void 0===r?e:t(n,e,o,i)}),n},ti.geomEach=o,ti.geomReduce=function(e,t,r){var n=r;return o(e,function(e,o,i,a,s){n=0===o&&void 0===r?e:t(n,e,o,i,a,s)}),n},ti.lineEach=s,ti.lineReduce=function(e,t,r){var n=r;return s(e,function(e,o,i,a){n=0===o&&void 0===r?e:t(n,e,o,i,a)}),n},ti.propEach=r,ti.propReduce=function(e,t,n){var o=n;return r(e,function(e,r){o=0===r&&void 0===n?e:t(o,e,r)}),o},ti.segmentEach=a,ti.segmentReduce=function(e,t,r){var n=r,o=!1;return a(e,function(e,i,a,s,l){n=!1===o&&void 0===r?e:t(n,e,i,a,s,l),o=!0}),n},ti}var ni,oi,ii={},ai=function(){if(oi)return To.exports;oi=1;var e=Xo,t=Qo(),r=ri(),n=function(){if(ni)return ii;ni=1,Object.defineProperty(ii,"__esModule",{value:!0});var e=ri();function t(t,r={}){if(null!=t.bbox&&!0!==r.recompute)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return e.coordEach.call(void 0,t,e=>{n[0]>e[0]&&(n[0]=e[0]),n[1]>e[1]&&(n[1]=e[1]),n[2]<e[0]&&(n[2]=e[0]),n[3]<e[1]&&(n[3]=e[1])}),n}var r=t;return ii.bbox=t,ii.default=r,ii}().default,o=r.featureEach;r.coordEach,t.polygon;var i=t.featureCollection;function a(t){var r=new e(t);return r.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:n(t),e.prototype.insert.call(this,t)},r.load=function(t){var r=[];return Array.isArray(t)?t.forEach(function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:n(e),r.push(e)}):o(t,function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:n(e),r.push(e)}),e.prototype.load.call(this,r)},r.remove=function(t,r){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:n(t),e.prototype.remove.call(this,t,r)},r.clear=function(){return e.prototype.clear.call(this)},r.search=function(t){var r=e.prototype.search.call(this,this.toBBox(t));return i(r)},r.collides=function(t){return e.prototype.collides.call(this,this.toBBox(t))},r.all=function(){var t=e.prototype.all.call(this);return i(t)},r.toJSON=function(){return e.prototype.toJSON.call(this)},r.fromJSON=function(t){return e.prototype.fromJSON.call(this,t)},r.toBBox=function(e){var t;if(e.bbox)t=e.bbox;else if(Array.isArray(e)&&4===e.length)t=e;else if(Array.isArray(e)&&6===e.length)t=[e[0],e[1],e[3],e[4]];else if("Feature"===e.type)t=n(e);else{if("FeatureCollection"!==e.type)throw new Error("invalid geojson");t=n(e)}return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}},r}return To.exports=a,To.exports.default=a,To.exports}(),si=q(ai);function li(e,t){var r={},n=[];if("LineString"===e.type&&(e=Ue(e)),"LineString"===t.type&&(t=Ue(t)),"Feature"===e.type&&"Feature"===t.type&&null!==e.geometry&&null!==t.geometry&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var o=ci(e,t);return o&&n.push(o),ze(n)}var i=si();return i.load(Ao(t)),Qe(Ao(e),function(e){Qe(i.search(e),function(t){var o=ci(e,t);if(o){var i=_o(o).join(",");r[i]||(r[i]=!0,n.push(o))}})}),ze(n)}function ci(e,t){var r=_o(e),n=_o(t);if(2!==r.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==n.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var o=r[0][0],i=r[0][1],a=r[1][0],s=r[1][1],l=n[0][0],c=n[0][1],u=n[1][0],d=n[1][1],p=(d-c)*(a-o)-(u-l)*(s-i);if(0===p)return null;var h=((u-l)*(i-c)-(d-c)*(o-l))/p,f=((a-o)*(i-c)-(s-i)*(o-l))/p;return h>=0&&h<=1&&f>=0&&f<=1?Ye([o+h*(a-o),i+h*(s-i)]):null}function ui(e,t,r){void 0===r&&(r={});var n=Ye([1/0,1/0],{dist:1/0}),o=0;return tt(e,function(e){for(var i=_o(e),a=0;a<i.length-1;a++){var s=Ye(i[a]);s.properties.dist=Mo(t,s,r);var l=Ye(i[a+1]);l.properties.dist=Mo(t,l,r);var c=Mo(s,l,r),u=Math.max(s.properties.dist,l.properties.dist),d=Kr(s,l),p=Io(t,u,d+90,r),h=Io(t,u,d-90,r),f=li(He([p.geometry.coordinates,h.geometry.coordinates]),He([s.geometry.coordinates,l.geometry.coordinates])),g=null;f.features.length>0&&((g=f.features[0]).properties.dist=Mo(t,g,r),g.properties.location=o+Mo(s,g,r)),s.properties.dist<n.properties.dist&&((n=s).properties.index=a,n.properties.location=o),l.properties.dist<n.properties.dist&&((n=l).properties.index=a+1,n.properties.location=o+c),g&&g.properties.dist<n.properties.dist&&((n=g).properties.index=a),o+=c}}),n}function di(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}var pi=function(){return pi=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},pi.apply(this,arguments)},hi=function(){function e(e){var t;this.status=null!==(t=e.status)&&void 0!==t&&t,this.map=e.map,this.drawing=e.drawing,this.options=e.options,this.onSnapped=function(t){void 0!==e.onSnapped&&e.onSnapped(t)},this.features={},this.snapStatus=!1,this.snapCoords=[],this.radiusInMeters=0,this.addRadiusCircleLayer(),this.addEvents()}return e.prototype.changeSnappedPoints=function(){for(var e=this.drawing.getAll(),t=[],r=0;r<e.features.length;r++){var n=e.features[r],o=n.id;if(this.features[o]){var i=this.features[o].snapPoints;if(void 0!==this.features.unknow){var a=this.features.unknow.snapPoints;i=pi(pi({},i),a)}var s=this.doSnap(n,i);t.push(s)}else void 0!==this.features.unknow?(a=this.features.unknow.snapPoints,s=this.doSnap(n,a),t.push(s)):t.push(n)}var l={type:"FeatureCollection",features:t};this.drawing.set(l),this.onSnapped&&this.onSnapped(l)},e.prototype.isPointSnapped=function(e,t){return Mo(Ye(e),Ye(t),{units:"meters"})<this.radiusInMeters},e.prototype.doSnap=function(e,t){switch(e.geometry.type){case"Point":var r=e.geometry.coordinates;for(var n in t)this.isPointSnapped(r,t[n])&&(e.geometry.coordinates=t[n]);break;case"Polygon":for(var o=e.geometry.coordinates,i=[],a=0;a<o.length;a++){for(var s=o[a],l=[],c=0;c<s.length;c++){var u=s[c],d=!1;for(var n in t)if(this.isPointSnapped(u,t[n])){d=!0,l.push(t[n]);break}0==d&&l.push(u)}i.push(l)}e.geometry.coordinates=i;break;case"LineString":var p=e.geometry.coordinates;for(l=[],c=0;c<p.length;c++){var h=p[c];for(var n in d=!1,t)if(this.isPointSnapped(h,t[n])){d=!0,l.push(t[n]);break}0==d&&l.push(h)}e.geometry.coordinates=l}return e},e.prototype.getMe=function(){return this},e.prototype.setStatus=function(e){this.status=e},e.prototype.setMapData=function(e){var t=this.map.getSource("snap-helper-circle");t&&t.setData(e)},e.prototype.snapToClosestPoint=function(e){if(this.status){var t=e.point,r=this.map.unproject(t),n=[t.x+this.options.radius,t.y],o=this.map.unproject(n),i=Mo(Ye([r.lng,r.lat]),Ye([o.lng,o.lat]),{units:"meters"});this.radiusInMeters=i;var a=!1,s=this.getCloseFeatures(e,i);s?(this.snapStatus=!0,this.snapCoords=s.coords,a=function(e,t,r={}){const n=r.steps||64,o=r.properties?r.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},i=[];for(let a=0;a<n;a++)i.push(qr(e,t,-360*a/n,r).geometry.coordinates);return i.push(i[0]),Ge([i],o)}(s.coords,i,{steps:64,units:"meters",properties:{color:s.color}})):(this.snapStatus=!1,this.snapCoords=[]);var l=ze(0==a?[]:[a]);this.setMapData(l)}},e.prototype.addEvents=function(){var e=this;this.map.on("mousemove",function(t){e.snapToClosestPoint(t)}),this.map.on("draw.delete",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.update",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.create",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.selectionchange",function(t){t.features.length>0?e.status=!0:(e.status=!1,e.setMapData(ze([])))}),this.map.on("draw.modechange",function(t){e.status=!0,"simple_select"==t.mode&&(e.status=!1)}),this.map.on("draw.render",function(t){var r=e.map.getSource("mapbox-gl-draw-hot");if(r){var n=r._data;if(e.snapStatus){var o=[e.snapCoords[0],e.snapCoords[1]];n.features.length>0&&(n.features[0].geometry.coordinates=o)}}}),this.map.on("mouseup",function(){e.drawingSnapCheck()}),this.map.on("click",function(){e.drawingSnapCheck()})},e.prototype.drawingSnapCheck=function(){if(this.snapStatus){var e=this.map.getSource("mapbox-gl-draw-hot"),t=[this.snapCoords[0],this.snapCoords[1]],r=t[0].toFixed(6),n=t[1].toFixed(6),o={};if(o["".concat(r,"_").concat(n)]=t,e){var i=e._data;if(i.features.length>0){var a=i.features.find(function(e){return"feature"==e.properties.meta});if(a){var s=a.properties.id;this.features[s]?this.features[s].snapPoints["".concat(r,"_").concat(n)]=t:this.features[s]={id:s,snapPoints:o}}}else this.features.unknow?this.features.unknow.snapPoints["".concat(r,"_").concat(n)]=t:this.features.unknow={id:s,snapPoints:o}}}},e.prototype.searchInVertex=function(e,t,r){var n,o=(n=[],$e(e,function(e){n.push(e)}),n),i=[];if(o.map(function(e){var n=Mo(Ye(e),Ye([t.lng,t.lat]),{units:"meters"});n<r&&i.push({coords:e,dist:n,color:"#8bc34a"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.getLines=function(e,t,r){var n=[];switch(e.geometry.type){case"LineString":n.push(e);break;case"MultiLineString":e.geometry.coodinates.map(function(e){n.push(He(e))});break;case"Polygon":var o=xo(e.geometry);n.push(o);break;case"MultiPolygon":xo(e.geometry).coodinates.map(function(e){n.push(He(e))})}return n},e.prototype.searchInMidPoint=function(e,t,r){var n=this.getLines(e,t,r),o=[];n.map(function(e){o=o.concat(Ao(e).features)});var i=[];if(o.map(function(e){var n=function(e,t){var r=function(e,t,r,n){void 0===n&&(n={});var o=di(e),i=Ze(o[0]),a=Ze(o[1]),s=Ze(r),l=Ke(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(l)+Math.cos(a)*Math.sin(l)*Math.cos(s));return Ye([qe(i+Math.atan2(Math.sin(s)*Math.sin(l)*Math.cos(a),Math.cos(l)-Math.sin(a)*Math.sin(c))),qe(c)],n.properties)}(e,function(e,t,r){void 0===r&&(r={});var n=di(e),o=di(t),i=Ze(o[1]-n[1]),a=Ze(o[0]-n[0]),s=Ze(n[1]),l=Ze(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(l);return Je(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)}(e,t)/2,Kr(e,t));return r}(e.geometry.coordinates[0],e.geometry.coordinates[1]),o=Mo(n,Ye([t.lng,t.lat]),{units:"meters"});o<r&&i.push({coords:n.geometry.coordinates,dist:o,color:"#03a9f4"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.searchInEdge=function(e,t,r){for(var n=this.getLines(e,t,r),o=[],i=0;i<n.length;i++){var a=ui(n[i],Ye([t.lng,t.lat]),{units:"meters"});void 0!==a.properties.dist&&a.properties.dist<r&&o.push({coords:a.geometry.coordinates,dist:a.properties.dist,color:"#ff9800"})}if(o.length>0)return o.sort(function(e,t){return e.dist-t.dist}),o[0]},e.prototype.getCloseFeatures=function(e,t){var r=this.map.queryRenderedFeatures(e.point,{layers:this.options.layers});if(r.length>0){for(var n,o=!1,i=0;i<r.length;i++){var a=r[i],s=this.options.rules,l=e.lngLat;if(o=!1,-1!==s.indexOf("vertex")&&null==n&&(n=this.searchInVertex(a,l,t))){o=!0;break}if(-1!==s.indexOf("midpoint")&&null==n&&(n=this.searchInMidPoint(a,l,t))){o=!0;break}if(-1!==s.indexOf("edge")&&null==n&&(n=this.searchInEdge(a,l,t))){o=!0;break}}return!!o&&n}return!1},e.prototype.addRadiusCircleLayer=function(){this.map.addSource("snap-helper-circle",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"snap-helper-circle",type:"fill",source:"snap-helper-circle",paint:{"fill-color":["get","color"],"fill-opacity":.6}})},e}();function fi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}var gi="snap-helper-circle";function vi(e,t){!function r(){var n=e();null!==n&&(n?t(n):requestAnimationFrame(r))}()}function yi(e){var t;if(!(!e||e._data&&Array.isArray(null===(t=e._data)||void 0===t?void 0:t.features))){var r={type:"FeatureCollection",features:[]};Object.defineProperty(e,"_data",{get:()=>r,set:e=>{r=e&&"object"==typeof e&&Array.isArray(e.features)?e:{type:"FeatureCollection",features:[]}},configurable:!0})}}function mi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function bi(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?mi(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mi(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Ei=e=>{var{mapStyle:t,mapProvider:r,events:o,eventBus:i,snapLayers:a}=e,{map:s}=r;Ht.constants.classes.CONTROL_BASE="maplibregl-ctrl",Ht.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",Ht.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var l=new Ht({modes:bi(bi({},Ht.modes),{},{disabled:zt,edit_vertex:eo,draw_polygon:oo,draw_line:io}),styles:So(t),displayControlsDefault:!1,userProperties:!0,defaultMode:"disabled"});s.addControl(l);var c=s.getCanvas(),u=null,d=e=>{1===e.touches.length&&(u={x:e.touches[0].clientX,y:e.touches[0].clientY,time:Date.now()})},p=e=>{if("disabled"===l.getMode()&&u){var t=e.changedTouches[0],r=t.clientX-u.x,n=t.clientY-u.y;Date.now()-u.time<300&&Math.abs(r)<10&&Math.abs(n)<10&&c.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY})),u=null}else u=null};c.addEventListener("touchstart",d,{passive:!0}),c.addEventListener("touchend",p,{passive:!0}),r.draw=l,s._drawCurrentMapStyle=t,r.snapEnabled=!1;var h=(e=>{var t=[],r=()=>{e.fire("draw.undochange",{length:t.length})};return{push(e){t.push(e),r()},pop(){var e=t.pop();return r(),e},clear(){t.length=0,r()},get length(){return t.length}}})(s);r.undoStack=h,s._undoStack=h,function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e._snapInitialized)return e._snapInstance;e._snapInitialized=!0;var{layers:o=[],radius:i=15,rules:a=["vertex","midpoint","edge"],status:s=!1,onSnapped:l=()=>{},colors:c={}}=r;function u(r){if(e._snapInstance||e._snapCreating)return e._snapInstance;e._snapCreating=!0,e.getLayer(gi)&&e.removeLayer(gi),e.getSource(gi)&&e.removeSource(gi),yi(r);var n=new hi({map:e,drawing:t,options:{layers:o,radius:i,rules:a},status:s,onSnapped:l}),c=s;return Object.defineProperty(n,"status",{get:()=>c,set(){},configurable:!0}),n.setSnapStatus=e=>{c=e},n._defaultLayers=o,n._activeLayers=null,n.setSnapLayers=e=>{null==e?n._activeLayers=null:Array.isArray(e)&&(n._activeLayers=e)},void 0!==e._pendingSnapLayers&&(n.setSnapLayers(e._pendingSnapLayers),delete e._pendingSnapLayers),e._snapInstance=n,n}!function(e){if(!hi.prototype.__snapPatched){hi.prototype.__snapPatched=!0;var t=hi.prototype,r={setMapData:t.setMapData,drawingSnapCheck:t.drawingSnapCheck,getLines:t.getLines,getCloseFeatures:t.getCloseFeatures,searchInVertex:t.searchInVertex,searchInMidPoint:t.searchInMidPoint,searchInEdge:t.searchInEdge,snapToClosestPoint:t.snapToClosestPoint};t.changeSnappedPoints=()=>{},t.setMapData=function(e){var t,n;if(this.status){var o=r.setMapData.call(this,e);return(null==e||null===(t=e.features)||void 0===t?void 0:t.length)>0&&null!==(n=this.map)&&void 0!==n&&n.getLayer(gi)&&this.map.setLayoutProperty(gi,"visibility","visible"),o}},t.drawingSnapCheck=function(){if(this.status)return r.drawingSnapCheck.call(this)},t.getLines=function(e,t,n){var o=e.geometry;if(!o||!o.coordinates)return[];var i=o.coordinates;if(!Array.isArray(i)||0===i.length)return[];try{return"MultiPolygon"===o.type?i.filter(e=>Array.isArray(e)&&e.length>0).map(e=>Ge(e)):"MultiLineString"===o.type?i.filter(e=>Array.isArray(e)&&e.length>0).map(e=>He(e)):r.getLines.call(this,e,t,n)}catch(e){return console.log(e),[]}},t.getCloseFeatures=function(e,t){if(!this.status)return[];var n=this._activeLayers||this._defaultLayers||[];this.options.layers=n.filter(e=>this.map.getLayer(e));var o=this.options.radius||15,i=e.point;e.point=[[i.x-o,i.y-o],[i.x+o,i.y+o]];var a=r.getCloseFeatures.call(this,e,t);return e.point=i,a},t.searchInVertex=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInVertex.apply(this,n);return i&&(i.color=e.vertex),i},t.searchInMidPoint=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInMidPoint.apply(this,n);return i&&(i.color=e.midpoint),i},t.searchInEdge=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInEdge.apply(this,n);return i&&(i.color=e.edge),i},t.snapToClosestPoint=function(e){var t;if(this.status&&(null===(t=this.map)||void 0===t||!t._isZooming))try{var n,o,i=r.snapToClosestPoint.call(this,e);return(null===(n=this.closeFeatures)||void 0===n?void 0:n.length)>100&&(this.closeFeatures.length=0),(null===(o=this.lines)||void 0===o?void 0:o.length)>100&&(this.lines.length=0),i}catch(e){console.log(e),this.snapStatus=!1,this.snapCoords=null}}}}(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fi(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fi(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({vertex:ao.snapVertex,midpoint:ao.snapMidpoint,edge:ao.snapEdge},c)),e.on("style.load",()=>{vi(()=>e._removed?null:e.getSource("mapbox-gl-draw-hot"),t=>{var r;yi(t),e.getSource(gi)||e.addSource(gi,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(gi)||e.addLayer({id:gi,type:"fill",source:gi,paint:{"fill-color":["get","color"],"fill-opacity":.6},layout:{visibility:null!==(r=e._snapInstance)&&void 0!==r&&r.status?"visible":"none"}}),e._snapInstance||u(t)})}),e.on("zoomstart",()=>{e._isZooming=!0}),e.on("zoomend",()=>{if(e._isZooming=!1,e.getLayer(gi)){e.setLayoutProperty(gi,"visibility","none");var t=e._snapInstance;null!=t&&t.status&&e.setLayoutProperty(gi,"visibility","visible")}}),vi(()=>e._removed?null:e.getSource("mapbox-gl-draw-hot"),u)}(s,l,{layers:a,radius:10,rules:["vertex","edge"]});var f=e=>{s._drawCurrentMapStyle=e,s.once("idle",()=>{var t;((e,t)=>{So(t).forEach(t=>{Object.entries(t.paint).forEach(r=>{var[n,o]=r;e.getLayer("".concat(t.id,".cold"))&&e.setPaintProperty("".concat(t.id,".cold"),n,o),e.getLayer("".concat(t.id,".hot"))&&e.setPaintProperty("".concat(t.id,".hot"),n,o)})})})(s,e);var r=null===(t=s._drawEditContainer)||void 0===t?void 0:t.querySelector("[data-touch-vertex-target]");rr(r,e)})};return i.on(o.MAP_SET_STYLE,f),i.on(o.MAP_SET_SIZE,e=>{s.fire("draw.scalechange",{scale:{small:1,medium:1.5,large:2}[e]})}),{draw:l,remove(){c.removeEventListener("touchstart",d),c.removeEventListener("touchend",p),i.off(o.MAP_SET_STYLE,f),l.deleteAll(),l.changeMode("disabled"),s.removeControl(l)}}},Pi=["stroke","fill","strokeWidth"],Oi=e=>{if(!e)return{};var t={};for(var[r,n]of Object.entries(e))if(Pi.includes(r)&&"object"==typeof n&&null!==n){var o=Object.entries(n);for(var[i,a]of(o.length>0&&(t[r]=o[0][1]),o))t["".concat(r).concat(i.charAt(0).toUpperCase()+i.slice(1))]=a}else t[r]=n;return t},Si=["stroke","fill","strokeWidth","properties"];function wi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?wi(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wi(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Mi=["stroke","fill","strokeWidth","properties"];function xi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ii(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?xi(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xi(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Ai=["stroke","fill","strokeWidth","properties"];function Ti(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ci(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ti(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ti(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Li(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Di(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Li(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Li(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ki=e=>({mobile:{slot:"actions",showLabel:e},tablet:{slot:"actions",showLabel:e},desktop:{slot:"actions",showLabel:e}}),ji={reducer:{initialState:{mode:null,action:null,actionValid:!1,feature:null,tempFeature:null,selectedVertexIndex:-1,numVertecies:null,snap:!1,hasSnapLayers:!1,undoStackLength:0},actions:c},InitComponent:e=>{var{appState:t,appConfig:r,mapState:n,pluginConfig:i,pluginState:a,services:s,mapProvider:l,buttonConfig:c}=e,{eventBus:d}=s,{crossHair:p}=n,f=["touch","keyboard"].includes(t.interfaceType);(0,o.vJ)(()=>{var e,r,o,s,c,p=null===(e=null===(r=i.includeModes)||void 0===r?void 0:r.includes(t.mode))||void 0===e||e,h=null!==(o=null===(s=i.excludeModes)||void 0===s?void 0:s.includes(t.mode))&&void 0!==o&&o;if(n.isMapReady&&p&&!h){var{remove:f}=Ei({mapStyle:n.mapStyle,snapLayers:i.snapLayers,mapProvider:l,events:u,eventBus:d});return a.dispatch({type:"SET_HAS_SNAP_LAYERS",payload:(null===(c=i.snapLayers)||void 0===c?void 0:c.length)>0}),d.emit("draw:ready"),()=>f()}},[n.isMapReady,t.mode]),(0,o.vJ)(()=>{l.draw&&(l.draw._crossHair=p)},[l.draw,p]),(0,o.vJ)(()=>{if(["draw_polygon","draw_line"].includes(a.mode)&&f){var e=p.isVisible;return p.fixAtCenter(),()=>{e||p.hide()}}},[a.mode,t.interfaceType]),(0,o.vJ)(()=>{"edit_vertex"===a.mode&&l.map&&l.map.fire("draw.interfacetypechange",{interfaceType:t.interfaceType})},[t.interfaceType,a.mode]),(0,o.vJ)(()=>{if(l.draw){var e=function(e){var{pluginState:t,mapProvider:r,buttonConfig:n,eventBus:o}=e,{drawDone:i,drawAddPoint:a,drawUndo:s,drawDeletePoint:l,drawSnap:c,drawCancel:u}=n,{map:d,draw:p}=r,{dispatch:f,feature:g,tempFeature:v}=t,b=()=>{r.snapEnabled=!1,f({type:"SET_SNAP",payload:!1});var e,t=h(d);t&&(null===(e=t.setSnapStatus)||void 0===e||e.call(t,!1),m(t)),d.getLayer("snap-helper-circle")&&d.setLayoutProperty("snap-helper-circle","visibility","none")},E=()=>{var e;null===(e=r.undoStack)||void 0===e||e.clear(),f({type:"SET_MODE",payload:null}),f({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}})},P=()=>{p.trash(),null!=v&&v.id&&p.delete(v.id),g&&p.add(g),b(),p.changeMode("disabled"),E(),o.emit("draw:cancelled",g)},O=0,S=["draw_polygon","draw_line"],w=e=>{S.includes(e.mode)||y(h(d),d)},_=()=>{var e,t=d.getStyle().layers||[];!t.length||null!==(e=t[t.length-1].source)&&void 0!==e&&e.startsWith("mapbox-gl-draw")||t.filter(e=>{var t;return null===(t=e.source)||void 0===t?void 0:t.startsWith("mapbox-gl-draw")}).forEach(e=>d.moveLayer(e.id))},M=e=>t=>{var r=t.features[0];b(),E(),setTimeout(()=>p.changeMode("disabled"),0),o.emit(e,r)},x=e=>{var t=e.features[0];o.emit("draw:updated",t)},I=M("draw:created"),A=M("draw:edited"),T=e=>{f({type:"SET_SELECTED_VERTEX_INDEX",payload:e}),o.emit("draw:vertexselection",e)},C=e=>{f({type:"SET_SELECTED_VERTEX_INDEX",payload:{index:-1,numVertecies:e.numVertecies}})},L=e=>{f({type:"SET_UNDO_STACK_LENGTH",payload:e.length})};return i.onClick=()=>{var e,t=p.getMode();b(),null===(e=r.undoStack)||void 0===e||e.clear(),"edit_vertex"!==t?["draw_polygon","draw_line"].includes(t)&&p.changeMode("disabled"):d.fire("draw.editfinish",{features:[p.get(v.id)]})},u.onClick=P,s.onClick=()=>{if("edit_vertex"!==p.getMode()){var e=r.undoStack;if(null!=e&&e.length){var t=e.pop();d._undoInProgress=!0,setTimeout(()=>{d._undoInProgress=!1},100),d.fire("draw.undo",{operation:t})}}},c.onClick=()=>{var e=Date.now();if(!(e-O<300)){O=e;var n=!t.snap;f({type:"TOGGLE_SNAP"}),r.snapEnabled=n;var o=h(d);null!=o&&o.setSnapStatus&&o.setSnapStatus(n),!n&&o&&(m(o),d.getLayer("snap-helper-circle")&&d.setLayoutProperty("snap-helper-circle","visibility","none"))}},d.on("styledata",_),d.on("draw.cancel",P),d.on("draw.create",I),d.on("draw.modechange",w),d.on("draw.editfinish",A),d.on("draw.update",x),d.on("draw.vertexselection",T),d.on("draw.vertexchange",C),d.on("draw.undochange",L),()=>{[i,a,s,l,c,u].forEach(e=>{e&&(e.onClick=null)}),d.off("styledata",_),d.off("draw.cancel",P),d.off("draw.create",I),d.off("draw.editfinish",A),d.off("draw.update",x),d.off("draw.modechange",w),d.off("draw.vertexselection",T),d.off("draw.vertexchange",C),d.off("draw.undochange",L)}}({mapProvider:l,buttonConfig:c,pluginState:a,eventBus:d});return()=>e()}},[l,t,a])},buttons:[Di({id:"drawCancel",label:"Cancel",variant:"tertiary",exclusiveSlot:!0,hiddenWhen:e=>{var{pluginState:t}=e;return!t.mode}},ki(!0)),Di({id:"drawAddPoint",label:"Add point",variant:"primary",exclusiveSlot:!0,hiddenWhen:e=>{var{appState:t,pluginState:r}=e;return!["draw_polygon","draw_line"].includes(r.mode)||"touch"!==t.interfaceType}},ki(!0)),Di({id:"drawDone",label:"Done",variant:"primary",exclusiveSlot:!0,hiddenWhen:e=>{var{pluginState:t}=e;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:e=>{var{pluginState:t}=e;return t.numVertecies>=("draw_polygon"===t.mode?3:2)}},ki(!0)),{id:"drawMenu",label:"Menu",iconId:"menu",hiddenWhen:e=>{var{pluginState:t}=e;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},menuItems:[{id:"drawUndo",label:"Undo",iconId:"undo",hiddenWhen:e=>{var{pluginState:t}=e;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:e=>{var{pluginState:t}=e;return t.undoStackLength>0}},{id:"drawSnap",label:"Snap to feature",iconId:"magnet",hiddenWhen:e=>{var{pluginState:t}=e;return!t.mode||!t.hasSnapLayers},pressedWhen:e=>{var{pluginState:t}=e;return!!t.snap}},{id:"drawDeletePoint",label:"Delete point",iconId:"trash",enableWhen:e=>{var t,{pluginState:r}=e;return r.selectedVertexIndex>=0&&r.numVertecies>("Polygon"===(null===(t=r.tempFeature)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type)?3:2)},hiddenWhen:e=>{var{pluginState:t}=e;return!["simple_select","edit_vertex"].includes(t.mode)}}],mobile:{slot:"bottom-right"},tablet:{slot:"top-middle"},desktop:{slot:"top-middle"}}],keyboardShortcuts:[{id:"drawStart",group:"Drawing",title:"Edit vertex",command:"<kbd>Spacebar</kbd></dd>"}],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:"check",svgContent:'<path d="M20 6 9 17l-5-5"/>'},{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 r,{appState:n,appConfig:o,pluginConfig:a,pluginState:s,mapProvider:l,services:c}=e,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{dispatch:d}=s,{draw:p,map:f}=l,{eventBus:g}=c;if(p){var v;g.emit("draw:started",{mode:"draw_polygon"}),v=void 0!==u.snapLayers?u.snapLayers:void 0!==a.snapLayers?a.snapLayers:null;var y=h(f);null!=y&&y.setSnapLayers?y.setSnapLayers(v):v&&(f._pendingSnapLayers=v),d({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=v)||void 0===r?void 0:r.length)>0});var{stroke:m,fill:b,strokeWidth:E,properties:P}=u,O=(0,i.A)(u,Si),S=_i(_i({},P),Oi({stroke:m,fill:b,strokeWidth:E}));p.changeMode("draw_polygon",_i(_i({container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,crossHair:p._crossHair,getSnapEnabled:()=>!0===l.snapEnabled,featureId:t},O),{},{properties:S})),d({type:"SET_MODE",payload:"draw_polygon"})}},newLine:function(e,t){var r,{appState:n,appConfig:o,pluginConfig:a,pluginState:s,mapProvider:l,services:c}=e,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{dispatch:d}=s,{draw:p,map:f}=l,{eventBus:g}=c;if(p){var v;g.emit("draw:started",{mode:"draw_line"}),v=void 0!==u.snapLayers?u.snapLayers:void 0!==a.snapLayers?a.snapLayers:null;var y=h(f);null!=y&&y.setSnapLayers?y.setSnapLayers(v):v&&(f._pendingSnapLayers=v),d({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=v)||void 0===r?void 0:r.length)>0});var{stroke:m,fill:b,strokeWidth:E,properties:P}=u,O=(0,i.A)(u,Mi),S=Ii(Ii({},P),Oi({stroke:m,fill:b,strokeWidth:E}));p.changeMode("draw_line",Ii(Ii({container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,crossHair:p._crossHair,getSnapEnabled:()=>!0===l.snapEnabled,featureId:t},O),{},{properties:S})),d({type:"SET_MODE",payload:"draw_line"})}},editFeature:function(e,t){var r,{appState:n,appConfig:o,mapState:i,pluginConfig:a,pluginState:s,mapProvider:l,services:c}=e,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{dispatch:d}=s,{draw:p,map:f}=l,{eventBus:g}=c;if(!p)return!1;var v=p.get(t);if(!v)return!1;g.emit("draw:editstart",{mode:{LineString:"edit_line",Polygon:"edit_polygon"}[v.geometry.type]});var y,m;m=void 0===u.snapLayers?null!==(y=a.snapLayers)&&void 0!==y?y:null:u.snapLayers;var b=h(f);null!=b&&b.setSnapLayers?b.setSnapLayers(m):m&&(f._pendingSnapLayers=m),d({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=m)||void 0===r?void 0:r.length)>0}),p.changeMode("edit_vertex",{container:n.layoutRefs.viewportRef.current,deleteVertexButtonId:"".concat(o.id,"-draw-delete-point"),undoButtonId:"".concat(o.id,"-draw-undo"),isPanEnabled:"keyboard"!==n.interfaceType,interfaceType:n.interfaceType,scale:{small:1,medium:1.5,large:2}[i.mapSize],featureId:t,getSnapEnabled:()=>!0===l.snapEnabled});var E=p.get(t);return d({type:"SET_FEATURE",payload:{feature:E,tempFeature:E}}),d({type:"SET_MODE",payload:"edit_vertex"}),!0},addFeature:(e,t)=>{var{mapProvider:r,services:n}=e,{draw:o}=r,{eventBus:a}=n;if(o){var{stroke:s,fill:l,strokeWidth:c,properties:u}=t,d=Ci(Ci({},(0,i.A)(t,Ai)),{},{properties:Ci(Ci({},u),Oi({stroke:s,fill:l,strokeWidth:c}))});o.add(d,{userProperties:!0}),a.emit("draw:add",d)}},deleteFeature:(e,t)=>{var{mapProvider:r,services:n}=e,{draw:o}=r,{eventBus:i}=n;o&&(o.delete(t),i.emit("draw:delete",{featureIds:t}))},split:function(e,t){var{appState:r,appConfig:n,pluginState:o,mapProvider:i}=e,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{dispatch:s}=o,{draw:l,map:c}=i;if(l){var u=l.get(t),d=["stroke-inactive.cold",...a.snapLayers||[]],p=h(c);null!=p&&p.setSnapLayers?p.setSnapLayers(d):a.snapLayers&&(c._pendingSnapLayers=d),s({type:"SET_HAS_SNAP_LAYERS",payload:!0}),l.changeMode("draw_line",{container:r.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(n.id,"-cross-hair"),addVertexButtonId:"".concat(n.id,"-draw-add-point"),interfaceType:r.interfaceType,getSnapEnabled:()=>!0===i.snapEnabled,featureId:"_splitter",properties:{splitter:"invalid"}}),c.on("draw.create",e=>{var t=e.features[0],r=Wn(u,t);l.setFeatureProperty("_splitter","splitter",r?"valid":"invalid"),s({type:"SET_ACTION",payload:{name:"split",isValid:!!r}})});var f,g,v,y=(f=e=>{if(!(e.coordinates.length<2)){var t={id:"_splitter",geometry:{type:"LineString",coordinates:e.coordinates}},r=!!Wn(u,t);e.properties.splitter=r?"valid":"invalid",e.ctx.store.render(),"edit_vertex"===l.getMode()&&s({type:"SET_ACTION",payload:{name:"split",isValid:r}})}},v=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];clearTimeout(g),g=setTimeout(()=>f(...t),50)},v.cancel=()=>{clearTimeout(g),g=null},v);c.on("draw.geometrychange",y),s({type:"SET_MODE",payload:"draw_line"}),s({type:"SET_ACTION",payload:{name:"split"}})}},merge:(e,t)=>{var{services:r}=e;console.log("merge"),console.log(t)}}}},171:(e,t,r)=>{r.r(t),r.d(t,{manifest:()=>f});var n,o,i=r(452),a=r(247),s=r(585),l="app:ready",c=/mac/i.test(null!==(n=null===(o=navigator.userAgentData)||void 0===o?void 0:o.platform)&&void 0!==n?n:navigator.platform)?"<kbd>Option</kbd>":"<kbd>Alt</kbd>";function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach(function(t){(0,s.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}"".concat(c," + <kbd>Enter</kbd>"),"".concat(c," + <kbd>→</kbd>, <kbd>←</kbd>, <kbd>↑</kbd> or <kbd>↓</kbd>"),new Set;var p={slot:"middle",open:!1,dismissible:!0,modal:!0};d({},p),d(d({},p),{},{width:"500px"}),d(d({},p),{},{width:"500px"});var h={small:1,medium:1.5,large:2},f={InitComponent:function(e){var{pluginConfig:t,services:r}=e,{eventBus:n}=r,o=()=>{n.emit("map:initmapstyles",t.mapStyles)};return(0,i.vJ)(()=>(n.on(l,o),()=>n.off(l,o)),[]),(0,a.Y)(a.FK,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},desktop:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},render:e=>{var{mapState:t,pluginConfig:r,services:n,mapProvider:o}=e,{mapStyle:i,mapSize:s}=t,{mapStyles:l}=r,{eventBus:c}=n,{supportsMapSizes:u}=o.capabilities;return(0,a.FD)("div",{className:"im-c-map-styles",children:[(0,a.Y)("div",{className:"im-c-map-styles__group",children:(0,a.Y)("div",{className:"im-c-map-styles__inner",children:l.filter(e=>e.url).map(e=>(0,a.Y)("div",{className:"im-c-map-styles__item",children:(0,a.FD)("button",{className:"im-c-map-styles__button","aria-pressed":e.id===i.id,onClick:()=>{return t=e,void c.emit("map:setstyle",t);var t},children:[(0,a.Y)("div",{className:"im-c-map-styles__image",children:(0,a.Y)("img",{src:e.thumbnail||void 0,alt:"",height:"60",width:"60"})}),e.label]})},e.id))})}),u&&(0,a.FD)("div",{className:"im-c-map-styles__group",children:[(0,a.Y)("h3",{className:"im-c-map-styles__heading",id:"map-text-sizes",children:"Map size"}),(0,a.Y)("div",{className:"im-c-map-styles__inner",children:["small","medium","large"].map(e=>(0,a.Y)("div",{className:"im-c-map-styles__item",children:(0,a.FD)("button",{className:"im-c-map-styles__button",onClick:()=>{return t=e,c.emit("map:setsize",t),void c.emit("map:setpixelratio",window.devicePixelRatio*h[t]);var t},"aria-pressed":e===s,children:[(0,a.Y)("div",{className:"im-c-map-styles__image",children:(0,a.FD)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fillRule:"evenodd",children:[(0,a.Y)("rect",{className:"im-c-map-styles__image-bg",width:"100%",height:"100%"}),(0,a.Y)("g",{style:{transform:"scale(".concat(h[e],")"),transformOrigin:"8px 52px"},children:(0,a.Y)("path",{d:"M8 51.785L12.948 38.9h1.837l5.274 12.885h-1.943l-1.503-3.903h-5.387l-1.415 3.903H8zm3.718-5.291h4.368l-1.345-3.569-.914-2.671c-.164.826-.395 1.646-.694 2.46l-1.415 3.78zm15.592 4.139c-3.698 3.143-7.836.271-6.315-2.562.963-1.794 5.529-1.982 6.183-2.21.022-.825.052-2.27-2.241-2.312-1.751-.031-2.242 1.025-2.435 1.776l-1.547-.211c.234-1.102.963-2.856 4.21-2.874 4.037-.022 3.612 2.962 3.612 3.524v2.11c0 .315 0 3.012.501 3.911h-1.652c-.164-.328-.27-.712-.316-1.152zm-.132-3.533c-.907.37-3.444.694-3.964.914-1.293.548-.911 2.399.225 2.637.639.134 3.739.476 3.739-2.971v-.58z"})})]})}),e[0].toUpperCase()+e.slice(1)]})},e))})]})]})}}],buttons:[{id:"mapStyles",label:"Styles",panelId:"mapStyles",iconId:"map",mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"map",svgContent:'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>'}]}},415:(e,t,r)=>{r.r(t),r.d(t,{manifest:()=>l});var n=r(452),o=r(247),i={small:1,medium:1.5,large:2},a={metric:[{threshold:1,abbr:"m",abbrPlural:"m",unit:"metre",unitPlural:"metres",factor:1},{threshold:1e3,abbr:"km",abbrPlural:"km",unit:"kilometre",unitPlural:"kilometres",factor:.001}],imperial:[{threshold:1609.344,abbr:"mi",abbrPlural:"mi",unit:"mile",unitPlural:"miles",factor:1/1609.344},{threshold:.9144,abbr:"yd",abbrPlural:"yds",unit:"yard",unitPlural:"yards",factor:1/.9144},{threshold:.3048,abbr:"ft",abbrPlural:"ft",unit:"foot",unitPlural:"feet",factor:1/.3048}]},s=e=>{var t=Math.pow(10,Math.floor(Math.log10(e))),r=e/t;return(r>=10?10:r>=5?5:r>=3?3:r>=2?2:1)*t},l={controls:[{id:"scaleBar",label:"Scale bar",mobile:{slot:"right-bottom"},tablet:{slot:"right-bottom"},desktop:{slot:"right-bottom"},render:function(e){var{mapState:t,pluginConfig:r}=e,{resolution:l,mapSize:c}=t,u=(0,n.li)(null),d=(0,n.Kr)(()=>l?((e,t,r,n)=>{var o=e/i[n],l=120*o,c=a[r];for(var{abbr:u,abbrPlural:d,unit:p,unitPlural:h,factor:f}of c){var g=s(l*f);if(g>=1&&g<1e3){var v=g/f/o;if(v<=120)return{label:g,abbr:g>1?d:u,width:v,unit:g>1?h:p}}}var y=c[c.length-1],m=l*y.factor,b=s(m),E=b>1?y.abbrPlural:y.abbr,P=b>1?y.abbrPlural:y.abbr;return{label:b,abbr:E,width:b/y.factor/o,unit:P}})(l/1,0,r.units,c):{width:0,label:"",abbr:"",unit:""},[l,c,r.units]);return(0,o.Y)("div",{className:"im-c-scale-bar",ref:u,style:{width:"".concat(d.width,"px")},children:(0,o.FD)("span",{className:"im-c-scale-bar__label",children:[(0,o.Y)("span",{className:"im-u-visually-hidden",children:"Scale bar: "}),d.label,(0,o.Y)("span",{"aria-hidden":"true",children:d.abbr}),(0,o.Y)("span",{className:"im-u-visually-hidden",children:d.unit})]})})}}]}},706:(e,t,r)=>{r.r(t),r.d(t,{manifest:()=>we});var n=r(585),o=r(452),i=(r(247),{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_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 a(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function s(e,t,r={}){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(!d(e[0])||!d(e[1]))throw new Error("coordinates must contain numbers");return a({type:"Point",coordinates:e},t,r)}function l(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return a({type:"LineString",coordinates:e},t,r)}function c(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function u(e,t,r={}){return a({type:"MultiLineString",coordinates:e},t,r)}function d(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}const p=11102230246251565e-32,h=134217729,f=(3+8*p)*p;function g(e,t,r,n,o){let i,a,s,l,c=t[0],u=n[0],d=0,p=0;u>c==u>-c?(i=c,c=t[++d]):(i=u,u=n[++p]);let h=0;if(d<e&&p<r)for(u>c==u>-c?(a=c+i,s=i-(a-c),c=t[++d]):(a=u+i,s=i-(a-u),u=n[++p]),i=a,0!==s&&(o[h++]=s);d<e&&p<r;)u>c==u>-c?(a=i+c,l=a-i,s=i-(a-l)+(c-l),c=t[++d]):(a=i+u,l=a-i,s=i-(a-l)+(u-l),u=n[++p]),i=a,0!==s&&(o[h++]=s);for(;d<e;)a=i+c,l=a-i,s=i-(a-l)+(c-l),c=t[++d],i=a,0!==s&&(o[h++]=s);for(;p<r;)a=i+u,l=a-i,s=i-(a-l)+(u-l),u=n[++p],i=a,0!==s&&(o[h++]=s);return 0===i&&0!==h||(o[h++]=i),h}function v(e){return new Float64Array(e)}const y=v(4),m=v(8),b=v(12),E=v(16),P=v(4);function O(e,t,r,n,o,i){const a=(t-i)*(r-o),s=(e-o)*(n-i),l=a-s,c=Math.abs(a+s);return Math.abs(l)>=33306690738754716e-32*c?l:-function(e,t,r,n,o,i,a){let s,l,c,u,d,p,v,O,S,w,_,M,x,I,A,T,C,L;const D=e-o,k=r-o,j=t-i,R=n-i;I=D*R,p=h*D,v=p-(p-D),O=D-v,p=h*R,S=p-(p-R),w=R-S,A=O*w-(I-v*S-O*S-v*w),T=j*k,p=h*j,v=p-(p-j),O=j-v,p=h*k,S=p-(p-k),w=k-S,C=O*w-(T-v*S-O*S-v*w),_=A-C,d=A-_,y[0]=A-(_+d)+(d-C),M=I+_,d=M-I,x=I-(M-d)+(_-d),_=x-T,d=x-_,y[1]=x-(_+d)+(d-T),L=M+_,d=L-M,y[2]=M-(L-d)+(_-d),y[3]=L;let N=function(e,t){let r=t[0];for(let n=1;n<4;n++)r+=t[n];return r}(0,y),F=22204460492503146e-32*a;if(N>=F||-N>=F)return N;if(d=e-D,s=e-(D+d)+(d-o),d=r-k,c=r-(k+d)+(d-o),d=t-j,l=t-(j+d)+(d-i),d=n-R,u=n-(R+d)+(d-i),0===s&&0===l&&0===c&&0===u)return N;if(F=11093356479670487e-47*a+f*Math.abs(N),N+=D*u+R*s-(j*c+k*l),N>=F||-N>=F)return N;I=s*R,p=h*s,v=p-(p-s),O=s-v,p=h*R,S=p-(p-R),w=R-S,A=O*w-(I-v*S-O*S-v*w),T=l*k,p=h*l,v=p-(p-l),O=l-v,p=h*k,S=p-(p-k),w=k-S,C=O*w-(T-v*S-O*S-v*w),_=A-C,d=A-_,P[0]=A-(_+d)+(d-C),M=I+_,d=M-I,x=I-(M-d)+(_-d),_=x-T,d=x-_,P[1]=x-(_+d)+(d-T),L=M+_,d=L-M,P[2]=M-(L-d)+(_-d),P[3]=L;const B=g(4,y,4,P,m);I=D*u,p=h*D,v=p-(p-D),O=D-v,p=h*u,S=p-(p-u),w=u-S,A=O*w-(I-v*S-O*S-v*w),T=j*c,p=h*j,v=p-(p-j),O=j-v,p=h*c,S=p-(p-c),w=c-S,C=O*w-(T-v*S-O*S-v*w),_=A-C,d=A-_,P[0]=A-(_+d)+(d-C),M=I+_,d=M-I,x=I-(M-d)+(_-d),_=x-T,d=x-_,P[1]=x-(_+d)+(d-T),L=M+_,d=L-M,P[2]=M-(L-d)+(_-d),P[3]=L;const V=g(B,m,4,P,b);I=s*u,p=h*s,v=p-(p-s),O=s-v,p=h*u,S=p-(p-u),w=u-S,A=O*w-(I-v*S-O*S-v*w),T=l*c,p=h*l,v=p-(p-l),O=l-v,p=h*c,S=p-(p-c),w=c-S,C=O*w-(T-v*S-O*S-v*w),_=A-C,d=A-_,P[0]=A-(_+d)+(d-C),M=I+_,d=M-I,x=I-(M-d)+(_-d),_=x-T,d=x-_,P[1]=x-(_+d)+(d-T),L=M+_,d=L-M,P[2]=M-(L-d)+(_-d),P[3]=L;const U=g(V,b,4,P,E);return E[U-1]}(e,t,r,n,o,i,c)}function S(e,t){var r,n,o,i,a,s,l,c,u,d=0,p=e[0],h=e[1],f=t.length;for(r=0;r<f;r++){n=0;var g=t[r],v=g.length-1;if((c=g[0])[0]!==g[v][0]&&c[1]!==g[v][1])throw new Error("First and last coordinates in a ring must be the same");for(i=c[0]-p,a=c[1]-h;n<v;n++){if(s=(u=g[n+1])[0]-p,l=u[1]-h,0===a&&0===l){if(s<=0&&i>=0||i<=0&&s>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(0===(o=O(i,s,a,l,0,0)))return 0;(o>0&&l>0&&a<=0||o<0&&l<=0&&a>0)&&d++}c=u,a=l,i=s}}return d%2!=0}function w(e){return"Feature"===e.type?e.geometry:e}function _(e,t,r={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=function(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}(e),o=w(t),i=o.type,a=t.bbox;let s=o.coordinates;if(a&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(n,a))return!1;"Polygon"===i&&(s=[s]);let l=!1;for(var c=0;c<s.length;++c){const e=S(n,s[c]);if(0===e)return!r.ignoreBoundary;e&&(l=!0)}return l}class M{constructor(e=[],t=x){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const o=e-1>>1,i=t[o];if(r(n,i)>=0)break;t[e]=i,e=o}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,o=t[e];for(;e<n;){let n=1+(e<<1),i=t[n];const a=n+1;if(a<this.length&&r(t[a],i)<0&&(n=a,i=t[a]),r(i,o)>=0)break;t[e]=i,e=n}t[e]=o}}function x(e,t){return e<t?-1:e>t?1:0}function I(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function A(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class T{constructor(e,t,r,n){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=n,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}let C=0,L=0,D=0;function k(e,t){const r="Feature"===e.type?e.geometry:e;let n=r.coordinates;"Polygon"!==r.type&&"MultiLineString"!==r.type||(n=[n]),"LineString"===r.type&&(n=[[n]]);for(let o=0;o<n.length;o++)for(let e=0;e<n[o].length;e++){let r=n[o][e][0],i=null;L+=1;for(let a=0;a<n[o][e].length-1;a++){i=n[o][e][a+1];const s=new T(r,C,L,D),l=new T(i,C,L,D+1);s.otherEvent=l,l.otherEvent=s,I(s,l)>0?(l.isLeftEndpoint=!0,s.isLeftEndpoint=!1):(s.isLeftEndpoint=!0,l.isLeftEndpoint=!1),t.push(s),t.push(l),r=i,D+=1}}C+=1}class j{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function R(e,t){if(null===e||null===t)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const r=e.leftSweepEvent.p.x,n=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,i=e.rightSweepEvent.p.y,a=t.leftSweepEvent.p.x,s=t.leftSweepEvent.p.y,l=t.rightSweepEvent.p.x,c=t.rightSweepEvent.p.y,u=(c-s)*(o-r)-(l-a)*(i-n);if(0===u)return!1;const d=((l-a)*(n-s)-(c-s)*(r-a))/u,p=((o-r)*(n-s)-(i-n)*(r-a))/u;return d>=0&&d<=1&&p>=0&&p<=1&&[r+d*(o-r),n+d*(i-n)]}function N(e,t,r={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:o=!0}=r;let i=[];"FeatureCollection"===e.type?i=i.concat(e.features):"Feature"===e.type?i.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||i.push(a(e)),"FeatureCollection"===t.type?i=i.concat(t.features):"Feature"===t.type?i.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||i.push(a(t));const l=function(e,t){const r=new M([],I);return function(e,t){if("FeatureCollection"===e.type){const r=e.features;for(let e=0;e<r.length;e++)k(r[e],t)}else k(e,t)}(e,r),function(e,t){t=t||!1;const r=[],n=new M([],A);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const e=new j(o);for(let i=0;i<n.data.length;i++){const a=n.data[i];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const s=R(e,a);!1!==s&&r.push(s)}n.push(e)}else!1===o.isLeftEndpoint&&n.pop()}return r}(r,t)}(c(i),o);let u=[];if(n){const e={};l.forEach(t=>{const r=t.join(",");e[r]||(e[r]=!0,u.push(t))})}else u=l;return c(u.map(e=>s(e)))}function F(e,t){!function(e,t){var r,n,o,i,a,s,l,c,u,d,p=0,h="FeatureCollection"===e.type,f="Feature"===e.type,g=h?e.features.length:1;for(r=0;r<g;r++){for(s=h?e.features[r].geometry:f?e.geometry:e,c=h?e.features[r].properties:f?e.properties:{},u=h?e.features[r].bbox:f?e.bbox:void 0,d=h?e.features[r].id:f?e.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=l?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,u,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,u,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,u,d))return!1;p++}}(e,function(e,r,n,o,i){var s,l=null===e?null:e.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return!1!==t(a(e,n,{bbox:o,id:i}),r,0)&&void 0}switch(l){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<e.coordinates.length;c++){var u=e.coordinates[c];if(!1===t(a({type:s,coordinates:u},n),r,c))return!1}})}function B(e,t={}){const r=w(e);switch(t.properties||"Feature"!==e.type||(t.properties=e.properties),r.type){case"Polygon":return function(e,t={}){return V(w(e).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}(r,t);case"MultiPolygon":return function(e,t={}){const r=w(e).coordinates,n=t.properties?t.properties:"Feature"===e.type?e.properties:{},o=[];return r.forEach(e=>{o.push(V(e,n))}),c(o)}(r,t);default:throw new Error("invalid poly")}}function V(e,t){return e.length>1?u(e,t):l(e[0],t)}function U(e,t){for(let r=0;r<e.coordinates.length-1;r++)if(G(e.coordinates[r],e.coordinates[r+1],t.coordinates))return!0;return!1}function Y(e,t,r){for(const n of t.coordinates)if(_(n,e))return!0;return N(t,B(e),{ignoreSelfIntersections:r}).features.length>0}function G(e,t,r){const n=r[0]-e[0],o=r[1]-e[1],i=t[0]-e[0],a=t[1]-e[1];return 0===n*a-o*i&&(Math.abs(i)>=Math.abs(a)?i>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:a>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1])}function H(e){var t=e.geometry||e;switch(t.type){case"Polygon":return function(e,t,r={}){for(const n of e){if(n.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(n[n.length-1].length!==n[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<n[n.length-1].length;e++)if(n[n.length-1][e]!==n[0][e])throw new Error("First and last Position are not equivalent.")}return a({type:"Polygon",coordinates:e},t,r)}(t.coordinates);case"MultiPolygon":return function(e,t,r={}){return a({type:"MultiPolygon",coordinates:e},void 0,r)}(t.coordinates);case"LineString":return l(t.coordinates);case"MultiLineString":return u(t.coordinates);case"Point":return s(t.coordinates);case"MultiPoint":return function(e,t,r={}){return a({type:"MultiPoint",coordinates:e},void 0,r)}(t.coordinates);default:throw new Error("Unsupported geometry type: ".concat(t.type))}}function z(e,t){return t.some(t=>!function(e,t,{ignoreSelfIntersections:r=!0}={ignoreSelfIntersections:!0}){let n=!0;return F(e,e=>{F(t,t=>{if(!1===n)return!1;n=function(e,t,r){switch(e.type){case"Point":switch(t.type){case"Point":return n=e.coordinates,o=t.coordinates,!(n[0]===o[0]&&n[1]===o[1]);case"LineString":return!U(t,e);case"Polygon":return!_(e,t)}break;case"LineString":switch(t.type){case"Point":return!U(e,t);case"LineString":return!function(e,t,r){return N(e,t,{ignoreSelfIntersections:r}).features.length>0}(e,t,r);case"Polygon":return!Y(t,e,r)}break;case"Polygon":switch(t.type){case"Point":return!_(t,e);case"LineString":return!Y(e,t,r);case"Polygon":return!function(e,t,r){for(const n of e.coordinates[0])if(_(n,t))return!0;for(const n of t.coordinates[0])if(_(n,e))return!0;return N(B(e),B(t),{ignoreSelfIntersections:r}).features.length>0}(t,e,r)}}var n,o;return!1}(e.geometry,t.geometry,r)})}),n}(H(t),H(e)))}function W(e){if(e.length<2)return!1;if(e.some(e=>{var t;return!(null!==(t=e.geometry)&&void 0!==t&&t.type)}))return!1;for(var t=new Set([0]),r=!0;r;){r=!1;for(var n=1;n<e.length;n++)if(!t.has(n)){var o=[...t].map(t=>e[t]);z(e[n],o)&&(t.add(n),r=!0)}}return t.size===e.length}var J,K,q=e=>{var t={};for(var r of e)t[r.layerId]=r;return t},Z=(e,t,r)=>{try{return(null==e?void 0:e.getFeaturesAtPoint(t,r))||[]}catch(e){return console.warn("Feature query failed:",e),[]}},X=e=>{var t,r=null===(t=e.geometry)||void 0===t?void 0:t.type;return"Point"===r||"MultiPoint"===r},$=/mac/i.test(null!==(J=null===(K=navigator.userAgentData)||void 0===K?void 0:K.platform)&&void 0!==J?J:navigator.platform)?"<kbd>Option</kbd>":"<kbd>Alt</kbd>";function Q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ee(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Q(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}"".concat($," + <kbd>Enter</kbd>"),"".concat($," + <kbd>→</kbd>, <kbd>←</kbd>, <kbd>↑</kbd> or <kbd>↓</kbd>"),new Set;var te={slot:"middle",open:!1,dismissible:!0,modal:!0};ee({},te),ee(ee({},te),{},{width:"500px"}),ee(ee({},te),{},{width:"500px"});var re={small:1,medium:1.5,large:2},ne=e=>!(!e.label||e.symbol||e.symbolSvgContent||null!==e.symbol&&null!==e.symbolSvgContent);function oe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ie(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?oe(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ae=(e,t,r,n)=>({featureId:e,multiSelect:t,layerId:r.layerId,idProperty:r.idProperty,properties:n.properties,geometry:n.geometry});function se(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function le(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?se(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):se(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ce=(e,t)=>{var r,n;return t?null!==(r=null===(n=e.properties)||void 0===n?void 0:n[t.idProperty])&&void 0!==r?r:e.id:null},ue=e=>{var t=e.closest(".im-c-viewport__markers");if(!t)return!1;var r=t.getBoundingClientRect(),{left:n,right:o,top:i,bottom:a}=e.getBoundingClientRect();return o>r.left&&n<r.right&&a>r.top&&i<r.bottom},de=(e,t,r)=>{var n,o,i,a=t[null===(n=e.layer)||void 0===n?void 0:n.id];if(null==a||!a.labelProperty)return null;var s=ce(e,a),l=null==s?null:String(s);return null==l||r.has(l)?null:(r.add(l),{id:l,label:null!==(o=null===(i=e.properties)||void 0===i?void 0:i[a.labelProperty])&&void 0!==o?o:l})};var pe=(e,t)=>{if(!e)return null;if("string"==typeof e)return e.trim();if("object"==typeof e){if(t&&e[t])return e[t];var r=Object.values(e)[0];return null!=r?r:null}return null},he={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}};function fe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ge(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fe(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fe(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ve=e=>1===(null==e?void 0:e.length)&&e.includes("selectMarker");function ye(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function me(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ye(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ye(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var be={ENABLE:(e,t)=>me(me(me({},e),t),{},{enabled:!0}),DISABLE:e=>me(me({},e),{},{enabled:!1,selectedFeatures:[],selectedMarkers:[],listboxActiveItem:null}),TOGGLE_SELECTED_FEATURES:(e,t)=>{var{featureId:r,multiSelect:n,layerId:o,idProperty:i,addToExisting:a=!0,replaceAll:s=!1,properties:l,geometry:c}=t,u=Array.isArray(e.selectedFeatures)?e.selectedFeatures:[],d=u.findIndex(e=>e.featureId===r&&e.layerId===o);if(!1===a){var p=u.filter((e,t)=>t!==d);return me(me({},e),{},{selectedFeatures:p})}var h,f={featureId:r,layerId:o,idProperty:i,properties:l,geometry:c};if(n&&!s){var g=[...u];-1===d?g.push(f):g.splice(d,1),h=g}else h=-1!==d&&1===u.length?[]:[f];return me(me({},e),{},{selectedFeatures:h,selectedMarkers:n&&!s?e.selectedMarkers:[]})},TOGGLE_SELECTED_MARKERS:(e,t)=>{var{markerId:r,multiSelect:n}=t,o=e.selectedMarkers,i=o.includes(r);if(n){var a=i?o.filter(e=>e!==r):[...o,r];return me(me({},e),{},{selectedMarkers:a})}return me(me({},e),{},{selectedFeatures:[],selectedMarkers:i&&1===o.length?[]:[r]})},CLEAR_SELECTED_FEATURES:e=>me(me({},e),{},{selectedFeatures:[],selectedMarkers:[]}),SET_SELECTED_FEATURES:(e,t)=>me(me({},e),{},{selectedFeatures:t}),SELECT_MARKER:(e,t)=>{var{markerId:r,multiSelect:n}=t,o=e.selectedMarkers;if(o.includes(r))return e;var i=n?[...o,r]:[r];return me(me({},e),{},{selectedFeatures:n?e.selectedFeatures:[],selectedMarkers:i})},UNSELECT_MARKER:(e,t)=>{var{markerId:r}=t,n=e.selectedMarkers;return n.includes(r)?me(me({},e),{},{selectedMarkers:n.filter(e=>e!==r)}):e},SET_LISTBOX_ACTIVE:(e,t)=>me(me({},e),{},{listboxActiveItem:null!=t?t:null})},Ee={tolerance:10,interactionModes:["selectMarker"],multiSelect:!1,contiguous:!1,deselectOnClickOutside:!1,marker:{}};function Pe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Oe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Pe(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Pe(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Se="Select features",we={InitComponent:e=>{var{appState:t,mapState:r,services:n,buttonConfig:a,mapProvider:s,pluginState:l}=e,{enabled:c,selectedFeatures:u,interactionModes:d,layers:p}=l,{eventBus:h}=n,{crossHair:f,mapStyle:g,markers:v}=r,y=ve(d);!function(e){var{mapState:t,pluginState:r,services:n,mapProvider:a}=e,{markers:s}=t,{dispatch:l,interactionModes:c,layers:u,multiSelect:d}=r,{eventBus:p}=n,h=(0,o.li)(null);(function(e){var{markers:t,interactionModes:r,layers:n,mapProvider:a,multiSelect:s,eventBus:l}=e;(0,o.vJ)(()=>{var e=()=>{var e=[];null!=r&&r.includes("selectMarker")&&e.push(...(e=>{var t=[];for(var r of e.items){var n;if(r.label){var o=null===(n=e.markerRefs)||void 0===n?void 0:n.get(r.id);!ne(r)&&o&&ue(o)&&t.push({id:r.id,label:r.label})}}return t})(t)),null!=r&&r.includes("selectFeature")&&n.length>0&&e.push(...((e,t)=>{var r=[],n=new Set,o=t.map(e=>e.layerId),i=q(t),a=e.getVisibleFeatures(o);for(var s of a){var l=de(s,i,n);l&&r.push(l)}return r})(a,n)),l.emit(i.MAP_SET_FEATURES,{items:e,multiselectable:s})};return e(),l.on(i.MAP_MOVE_END,e),l.on(i.MAP_DATA_CHANGE,e),()=>{l.off(i.MAP_MOVE_END,e),l.off(i.MAP_DATA_CHANGE,e)}},[t,r,n,a,s,l])})({markers:s,interactionModes:c,layers:u,mapProvider:a,multiSelect:d,eventBus:p}),function(e){var{markers:t,interactionModes:r,layers:n,mapProvider:a,eventBus:s,dispatch:l,listboxActiveItemRef:c}=e;(0,o.vJ)(()=>{var e=e=>{var{id:o}=e;if(null===o)return c.current=null,void l({type:"SET_LISTBOX_ACTIVE",payload:null});if(t.items.find(e=>e.id===o))return c.current={id:o,isMarker:!0},void l({type:"SET_LISTBOX_ACTIVE",payload:null});if(null!=r&&r.includes("selectFeature")&&n.length>0){var i=n.map(e=>e.layerId),s=q(n),u=((e,t,r)=>{for(var n of e){var o,i=t[null===(o=n.layer)||void 0===o?void 0:o.id],a=ce(n,i);if(null!=a&&String(a)===String(r))return{feature:n,config:i,rawId:a}}return null})(a.getVisibleFeatures(i),s,o);if(u){var d={featureId:u.rawId,layerId:u.config.layerId,idProperty:u.config.idProperty,geometry:u.feature.geometry};c.current=le(le({id:o,isMarker:!1},d),{},{properties:u.feature.properties}),l({type:"SET_LISTBOX_ACTIVE",payload:d})}}};return s.on(i.MAP_SET_ACTIVE_FEATURE,e),()=>{s.off(i.MAP_SET_ACTIVE_FEATURE,e)}},[t,r,n,a,s,l,c])}({markers:s,interactionModes:c,layers:u,mapProvider:a,eventBus:p,dispatch:l,listboxActiveItemRef:h}),function(e){var{eventBus:t,dispatch:r,listboxActiveItemRef:n,multiSelect:a}=e;(0,o.vJ)(()=>{var e=()=>{var e=n.current;if(e)if(e.isMarker)r({type:"TOGGLE_SELECTED_MARKERS",payload:{markerId:e.id,multiSelect:a}});else{var{featureId:t,layerId:o,idProperty:i,geometry:s,properties:l}=e;r({type:"TOGGLE_SELECTED_FEATURES",payload:{featureId:t,layerId:o,idProperty:i,geometry:s,properties:l,multiSelect:a,replaceAll:!a}})}};return t.on(i.MAP_SELECT_FEATURE,e),()=>{t.off(i.MAP_SELECT_FEATURE,e)}},[t,r,n,a])}({eventBus:p,dispatch:l,listboxActiveItemRef:h,multiSelect:d})}({mapState:r,pluginState:l,services:n,mapProvider:s});var{handleInteraction:m}=(e=>{var t,{mapState:r,pluginState:n,services:i,mapProvider:a}=e,{markers:s,mapSize:l}=r,{dispatch:c,layers:u,interactionModes:d,multiSelect:p,contiguous:h,marker:f,tolerance:g,selectedFeatures:v,selectedMarkers:y,deselectOnClickOutside:m}=n,{eventBus:b}=i,E=q(u),P=null!==(t=re[l])&&void 0!==t?t:1,O=(0,o.hb)(e=>{var t,r,n,{feature:o,config:i}=e;s.remove("location");var l=null!==(t=null===(r=o.properties)||void 0===r?void 0:r[i.idProperty])&&void 0!==t?t:o.id;if(null!=l){var u=null===(n=a.getFeatureGeometry)||void 0===n?void 0:n.call(a,i.layerId,l,i.idProperty),d=u?ie(ie({},o),{},{geometry:u}):o;if(h&&p&&(e=>{var t,{featureId:r,feature:n,config:o,selectedFeatures:i,dispatch:a,multiSelect:s}=e;if(!i.length)return!1;var l=i.findIndex(e=>e.featureId===r&&e.layerId===o.layerId);if(-1!==l){if(i.length<3)return!1;var c=(e=>{for(var t=new Set([0]),r=!0;r;){r=!1;for(var n=1;n<e.length;n++){var o;if(!t.has(n)){var i=[...t].map(t=>e[t]);null!==(o=e[n].geometry)&&void 0!==o&&o.type&&z(e[n],i)&&(t.add(n),r=!0)}}}return t.size===e.length?null:[...t].map(t=>e[t])})(i.filter((e,t)=>t!==l));return!!c&&(a({type:"SET_SELECTED_FEATURES",payload:c}),!0)}var u=i.filter(e=>{var t;return null===(t=e.geometry)||void 0===t?void 0:t.type});return!(null===(t=n.geometry)||void 0===t||!t.type||!u.length||z(n,u)||(a({type:"TOGGLE_SELECTED_FEATURES",payload:ie(ie({},ae(r,s,o,n)),{},{replaceAll:!0})}),0))})({featureId:l,feature:d,config:i,selectedFeatures:v,dispatch:c,multiSelect:p}))return;c({type:"TOGGLE_SELECTED_FEATURES",payload:ae(l,p,i,d)})}},[s,c,p,h,v,a]),S=(0,o.hb)(e=>{var{coords:t}=e,r=d.includes("placeMarker");(r||m)&&(c({type:"CLEAR_SELECTED_FEATURES"}),r&&(s.add("location",t,f),b.emit("interact:markerchange",{coords:t})))},[d,c,s,f,b,m]),w=(e=>{var{mapProvider:t,layers:r,interactionModes:n,multiSelect:i,dispatch:a,markers:s,layerConfigMap:l,debug:c,tolerance:u,processFeatureMatch:d,processFallback:p,scale:h}=e;return(0,o.hb)(e=>{var{point:o,coords:f}=e,g=c?Z(t,o,{radius:u}):null;if(g&&((e,t)=>{var[r,n]=e;console.groupCollapsed("[interact] click (".concat(r.toFixed(4),", ").concat(n.toFixed(4),") — ").concat(t.length," feature").concat(1!==t.length?"s":"")),t.forEach(e=>{var t,r;console.log({layer:e.layer.id,type:e.layer.type,id:null!==(t=e.id)&&void 0!==t?t:"—",sourceLayer:null!==(r=e.sourceLayer)&&void 0!==r?r:"—",properties:e.properties})}),console.groupEnd()})(f,g),n.includes("selectMarker")){var v=((e,t,r)=>{for(var n of e.items){var o,i=null===(o=e.markerRefs)||void 0===o?void 0:o.get(n.id);if(i&&!ne(n)){var a=i.closest(".im-c-viewport__markers")||i.parentElement,s=a?a.getBoundingClientRect():{left:0,top:0},{left:l,top:c,right:u,bottom:d}=i.getBoundingClientRect(),p=t.x*r,h=t.y*r;if(p>=l-s.left&&p<=u-s.left&&h>=c-s.top&&h<=d-s.top)return n.id}}return null})(s,o,h);if(v)return void a({type:"TOGGLE_SELECTED_MARKERS",payload:{markerId:v,multiSelect:i}})}if(n.includes("selectFeature")&&r.length>0){var y=((e,t)=>{var r=e.filter(e=>{var r;return t[null===(r=e.layer)||void 0===r?void 0:r.id]}),n=r.find(X);if(n)return{feature:n,config:t[n.layer.id]};var o=r[0];return o?{feature:o,config:t[o.layer.id]}:null})(null!=g?g:Z(t,o,{radius:u}),l);if(y)return void d(y)}p({coords:f})},[t,r,n,i,a,s,l,c,u,d,p,h])})({mapProvider:a,layers:u,interactionModes:d,multiSelect:p,dispatch:c,markers:s,layerConfigMap:E,debug:null==n?void 0:n.debug,tolerance:g,processFeatureMatch:O,processFallback:S,scale:P});return((e,t,r)=>{var n=(0,o.li)(null);(0,o.vJ)(()=>{var o=n.current;(null===o||0===o.features.length&&0===o.markers.length)&&0===t.length&&0===r.length||(e.emit("interact:selectionchange",{selectedFeatures:t.map(e=>{var{featureId:t,layerId:r,idProperty:n,properties:o}=e;return{featureId:t,layerId:r,idProperty:n,properties:o}}),selectedMarkers:r,contiguous:W(t)}),n.current={features:t,markers:r})},[t,r])})(b,v,y),{handleInteraction:w}})({mapState:r,pluginState:l,services:n,mapProvider:s});return(e=>{var{mapProvider:t,mapStyle:r,pluginState:n,selectedFeatures:i,events:a,eventBus:s}=e,{layers:l,listboxActiveItem:c}=n,u=(0,o.Kr)(()=>r?((e,t)=>{var r,n,o,i={};if(!t)return i;var a=null!==(r=he[t.mapColorScheme])&&void 0!==r?r:he.light,s=null!==(n=t.activeColor)&&void 0!==n?n:a.activeColor,l=null!==(o=t.selectedColor)&&void 0!==o?o:a.selectedColor;return e.forEach(e=>{var r=e.activeStroke||s,n=e.selectedStroke||l,o=e.selectedFill||"transparent",a=e.selectedStrokeWidth||3,c=a+6;i[e.layerId]={stroke:pe(r,t.id),selectionStroke:pe(n,t.id),fill:pe(o,t.id),strokeWidth:a,activeStrokeWidth:c}}),i})(l,r):null,[l,r]),d=()=>{var e,r=c?[{featureId:c.featureId,layerId:c.layerId,idProperty:c.idProperty,geometry:c.geometry}]:[];null===(e=t.updateHighlightedFeatures)||void 0===e||e.call(t,i,r,u)};(0,o.vJ)(()=>{if(t&&u){d();var e=()=>{s.once(a.MAP_DATA_CHANGE,d)};return s.on(a.MAP_STYLE_CHANGE,e),()=>{s.off(a.MAP_STYLE_CHANGE,e)}}},[i,c,t,u,s])})({mapProvider:s,mapStyle:g,pluginState:l,selectedFeatures:u,events:i,eventBus:h}),(0,o.vJ)(()=>{h.emit("interact:active",{active:c,interactionModes:d})},[c,d]),function(e){var{enabled:t,interactionModes:r,markers:n,layers:i,eventBus:a}=e;(0,o.vJ)(()=>{if(t){var e=(null==r?void 0:r.includes("selectMarker"))&&n.items.some(e=>e.label),o=(null==r?void 0:r.includes("selectFeature"))&&i.some(e=>e.labelProperty);(e||o)&&a.emit("interact:listboxcapable")}},[t,r,n,i,a])}({enabled:c,interactionModes:d,markers:v,layers:p,eventBus:h}),((e,t,r,n)=>{(0,o.vJ)(()=>{var o,i=t&&(null==r?void 0:r.includes("selectFeature"))?n.map(e=>e.layerId):[];return null===(o=e.setHoverCursor)||void 0===o||o.call(e,i),()=>{var t;return null===(t=e.setHoverCursor)||void 0===t?void 0:t.call(e,[])}},[t,r,n])})(s,c,d,p),function(e){var{crossHair:t,enabled:r,selectMarkerOnly:n,appState:i}=e,a=(0,o.li)(r);a.current=r;var s=(0,o.li)(n);s.current=n;var l=(0,o.li)(t);l.current=t;var c=(0,o.li)(!1),u=(0,o.li)(i.interfaceType);u.current=i.interfaceType;var d=(0,o.hb)(()=>{var e=u.current,t=["touch","keyboard"].includes(e);!a.current||c.current||!t||"touch"===e&&s.current?l.current.hide():l.current.fixAtCenter()},[]);(0,o.vJ)(()=>{d()},[r,n,i.interfaceType,d]),(0,o.vJ)(()=>{var e,t=null===(e=i.layoutRefs)||void 0===e||null===(e=e.appContainerRef)||void 0===e?void 0:e.current;if(t){var r=e=>{var t=!!e.target.closest('[role="listbox"], [role="option"]');c.current!==t&&(c.current=t,d())};return t.addEventListener("focusin",r),()=>{t.removeEventListener("focusin",r)}}},[i.layoutRefs,d])}({crossHair:f,enabled:c,selectMarkerOnly:y,appState:t}),function(e){var{pluginState:t,appState:r,mapState:n,buttonConfig:a,eventBus:s,handleInteraction:l}=e,c=(0,o.li)(l);c.current=l;var u=(0,o.li)(t);u.current=t;var d=(0,o.li)(r);d.current=r;var p=(0,o.li)(!1);(0,o.vJ)(()=>{p.current=!1;var e=setTimeout(()=>{p.current=!0},0);return()=>clearTimeout(e)},[t.enabled]),(0,o.vJ)(()=>{if(t.enabled)return function(e){var t,r,n,{getAppState:o,mapState:i,getPluginState:a,buttonConfig:s,events:l,eventBus:c,handleInteraction:u,clickReadyRef:d}=e,{selectAtTarget:p}=s,h=()=>u(i.crossHair.getDetail()),f=e=>{d.current&&u(e)},{handleKeydown:g,handleKeyup:v}=(t=o().layoutRefs.viewportRef,r=h,n=!1,{handleKeydown:e=>{n="Enter"===e.key&&t.current===e.target},handleKeyup:e=>{"Enter"===e.key&&n&&(e.preventDefault(),r())}}),y=((e,t)=>(r,n)=>{var o=t();e.markers.remove("location"),o.dispatch({type:"TOGGLE_SELECTED_FEATURES",payload:ge({multiSelect:o.multiSelect,addToExisting:n},r)})})(i,a),m=e=>y(e,!0),b=e=>y(e,!1);return document.addEventListener("keydown",g),document.addEventListener("keyup",v),c.on(l.MAP_CLICK,f),c.on("interact:selectFeature",m),c.on("interact:unselectFeature",b),p.onClick=h,()=>{p.onClick=null,document.removeEventListener("keydown",g),document.removeEventListener("keyup",v),c.off(l.MAP_CLICK,f),c.off("interact:selectFeature",m),c.off("interact:unselectFeature",b)}}({getAppState:()=>d.current,mapState:n,getPluginState:()=>u.current,buttonConfig:a,events:i,eventBus:s,handleInteraction:e=>c.current(e),clickReadyRef:p})},[t.enabled,a,s])}({pluginState:l,appState:t,mapState:r,buttonConfig:a,eventBus:h,handleInteraction:m}),null},reducer:{initialState:{enabled:!1,layers:[],marker:null,interactionModes:null,multiSelect:!1,deselectOnClickOutside:!1,selectedFeatures:[],selectedMarkers:[],closeOnAction:!0,listboxActiveItem:null},actions:be},buttons:[{id:"selectAtTarget",label:"Select",variant:"primary",hiddenWhen:e=>{var{appState:t,pluginState:r}=e;return!r.enabled||"touch"!==t.interfaceType||ve(r.interactionModes)},mobile:{slot:"actions"},tablet:{slot:"actions"},desktop:{slot:"actions"}}],keyboardShortcuts:[{id:"clickAtTarget",title:"Click at target",command:"<kbd>Enter</kbd>"},{id:"selectFeatures",group:Se,context:"listbox",title:"Select features",command:"<kbd>Tab</kbd>"},{id:"navigateFeatures",group:Se,context:"listbox",title:"Navigate features",command:"<kbd>↑</kbd> or <kbd>↓</kbd>"},{id:"selectFeature",group:Se,context:"listbox",title:"Select a feature",command:"<kbd>Enter</kbd> or <kbd>Space</kbd>"},{id:"dismissHintOrReturn",group:Se,context:"listbox",title:"Dismiss hint / return to map",command:"<kbd>Escape</kbd>"}],icons:[{id:"select",svgContent:'<path d="M22 14a8 8 0 0 1-8 8"/><path d="M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2"/><path d="M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1"/><path d="M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10"/><path d="M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/>'}],api:{enable:(e,t)=>{var{pluginState:r,pluginConfig:n}=e;r.dispatch({type:"ENABLE",payload:Oe(Oe(Oe({},Ee),n),t)})},disable:e=>{var{pluginState:t}=e;t.dispatch({type:"DISABLE"})},clear:e=>{var{pluginState:t,mapState:r}=e;t.dispatch({type:"CLEAR_SELECTED_FEATURES"}),r.markers.remove("location")},selectFeature:(e,t)=>{var{services:r}=e,{featureId:n,layerId:o,idProperty:i}=t;r.eventBus.emit("interact:selectFeature",{featureId:n,layerId:o,idProperty:i})},unselectFeature:(e,t)=>{var{services:r}=e,{featureId:n,layerId:o,idProperty:i}=t;r.eventBus.emit("interact:unselectFeature",{featureId:n,layerId:o,idProperty:i})},selectMarker:(e,t)=>{var{pluginState:r}=e;r.dispatch({type:"SELECT_MARKER",payload:{markerId:t,multiSelect:r.multiSelect}})},unselectMarker:(e,t)=>{var{pluginState:r}=e;r.dispatch({type:"UNSELECT_MARKER",payload:{markerId:t}})}}}},814:(e,t,r)=>{r.r(t),r.d(t,{default:()=>Z});var n=r(585),o=r(505),i=r(321),a=400,s=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"],l=(e,t)=>{var r=null,n=function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];clearTimeout(r),r=setTimeout(()=>{e(...o)},t)};return n.cancel=()=>{r&&(clearTimeout(r),r=null)},n};function c(e){var{map:t,events:r,eventBus:n,getCenter:o,getZoom:i,getBounds:a,getResolution:s}=e,c=[],u=[],d=()=>{var e=i();return{center:o(),bounds:a(),resolution:s(),zoom:e,isAtMaxZoom:t.getMaxZoom()<=e,isAtMinZoom:t.getMinZoom()>=e}},p=(e,t)=>n.emit(e,t),h=()=>p(r.MAP_LOADED);t.on("load",h),c.push(["load",h]),t.once("idle",()=>p(r.MAP_FIRST_IDLE,d()));var f=()=>p(r.MAP_MOVE_START);t.on("movestart",f),c.push(["movestart",f]);var g=l(()=>{p(r.MAP_MOVE_END,d())},500);t.on("moveend",g),c.push(["moveend",g]);var v,y,m=(v=()=>{p(r.MAP_MOVE,d())},y=0,function(){var e=Date.now();e-y>=10&&(y=e,v(...arguments))});t.on("zoom",m),c.push(["zoom",m]);var b=()=>p(r.MAP_RENDER);t.on("render",b),c.push(["render",b]);var E=l(()=>{p(r.MAP_DATA_CHANGE,d())},500),P=e=>{e.isSourceLoaded&&E()};t.on("styledata",E),t.on("sourcedata",P),c.push(["styledata",E],["sourcedata",P]);var O=()=>p(r.MAP_STYLE_CHANGE);t.on("style.load",O),c.push(["style.load",O]);var S=e=>p(r.MAP_CLICK,{point:e.point,coords:[e.lngLat.lng,e.lngLat.lat]});return t.on("click",S),c.push(["click",S]),u.push(g,m,E),{remove(){u.forEach(e=>e.cancel()),c.forEach(e=>{var[r,n]=e;return t.off(r,n)})}}}let u=" ";class d{static get separator(){return u}static set separator(e){u=e}static parse(e){if(!isNaN(parseFloat(e))&&isFinite(e))return Number(e);const t=String(e).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==t[t.length-1]&&t.splice(t.length-1),""==t)return NaN;let r=null;switch(t.length){case 3:r=t[0]/1+t[1]/60+t[2]/3600;break;case 2:r=t[0]/1+t[1]/60;break;case 1:r=t[0];break;default:return NaN}return/^-|[WS]$/i.test(e.trim())&&(r=-r),Number(r)}static toDms(e,t="d",r=void 0){if(isNaN(e))return null;if("string"==typeof e&&""==e.trim())return null;if("boolean"==typeof e)return null;if(e==1/0)return null;if(null==e)return null;if(void 0===r)switch(t){case"d":case"deg":r=4;break;case"dm":case"deg+min":r=2;break;case"dms":case"deg+min+sec":r=0;break;default:t="d",r=4}e=Math.abs(e);let n=null,o=null,i=null,a=null;switch(t){default:case"d":case"deg":o=e.toFixed(r),o<100&&(o="0"+o),o<10&&(o="0"+o),n=o+"°";break;case"dm":case"deg+min":o=Math.floor(e),i=(60*e%60).toFixed(r),60==i&&(i=(0).toFixed(r),o++),o=("000"+o).slice(-3),i<10&&(i="0"+i),n=o+"°"+d.separator+i+"′";break;case"dms":case"deg+min+sec":o=Math.floor(e),i=Math.floor(3600*e/60)%60,a=(3600*e%60).toFixed(r),60==a&&(a=(0).toFixed(r),i++),60==i&&(i=0,o++),o=("000"+o).slice(-3),i=("00"+i).slice(-2),a<10&&(a="0"+a),n=o+"°"+d.separator+i+"′"+d.separator+a+"″"}return n}static toLat(e,t,r){const n=d.toDms(d.wrap90(e),t,r);return null===n?"–":n.slice(1)+d.separator+(e<0?"S":"N")}static toLon(e,t,r){const n=d.toDms(d.wrap180(e),t,r);return null===n?"–":n+d.separator+(e<0?"W":"E")}static toBrng(e,t,r){const n=d.toDms(d.wrap360(e),t,r);return null===n?"–":n.replace("360","0")}static fromLocale(e){const t=123456.789.toLocaleString(),r={thousands:t.slice(3,4),decimal:t.slice(7,8)};return e.replace(r.thousands,"⁜").replace(r.decimal,".").replace("⁜",",")}static toLocale(e){const t=123456.789.toLocaleString(),r={thousands:t.slice(3,4),decimal:t.slice(7,8)};return e.replace(/,([0-9])/,"⁜$1").replace(".",r.decimal).replace("⁜",r.thousands)}static compassPoint(e,t=3){if(![1,2,3].includes(Number(t)))throw new RangeError(`invalid precision ‘${t}’`);e=d.wrap360(e);const r=4*2**(t-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(e*r/360)%r*16/r]}static wrap90(e){if(-90<=e&&e<=90)return e;const t=e;return 1*Math.abs(((t-90)%360+360)%360-180)-90}static wrap180(e){if(-180<=e&&e<=180)return e;const t=360;return((360*e/t-180)%t+t)%t-180}static wrap360(e){if(0<=e&&e<360)return e;const t=360;return(360*e/t%t+t)%t}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const p=Math.PI;class h{constructor(e,t){if(isNaN(e))throw new TypeError(`invalid lat ‘${e}’`);if(isNaN(t))throw new TypeError(`invalid lon ‘${t}’`);this._lat=d.wrap90(Number(e)),this._lon=d.wrap180(Number(t))}get lat(){return this._lat}get latitude(){return this._lat}set lat(e){if(this._lat=isNaN(e)?d.wrap90(d.parse(e)):d.wrap90(Number(e)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${e}’`)}set latitude(e){if(this._lat=isNaN(e)?d.wrap90(d.parse(e)):d.wrap90(Number(e)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${e}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(e){if(this._lon=isNaN(e)?d.wrap180(d.parse(e)):d.wrap180(Number(e)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${e}’`)}set lng(e){if(this._lon=isNaN(e)?d.wrap180(d.parse(e)):d.wrap180(Number(e)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${e}’`)}set longitude(e){if(this._lon=isNaN(e)?d.wrap180(d.parse(e)):d.wrap180(Number(e)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${e}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...e){if(0==e.length)throw new TypeError("invalid (empty) point");if(null===e[0]||null===e[1])throw new TypeError("invalid (null) point");let t,r;if(2==e.length&&([t,r]=e,t=d.wrap90(d.parse(t)),r=d.wrap180(d.parse(r)),isNaN(t)||isNaN(r)))throw new TypeError(`invalid point ‘${e.toString()}’`);if(1==e.length&&"string"==typeof e[0]&&([t,r]=e[0].split(","),t=d.wrap90(d.parse(t)),r=d.wrap180(d.parse(r)),isNaN(t)||isNaN(r)))throw new TypeError(`invalid point ‘${e[0]}’`);if(1==e.length&&"object"==typeof e[0]){const n=e[0];if("Point"==n.type&&Array.isArray(n.coordinates)?[r,t]=n.coordinates:(null!=n.latitude&&(t=n.latitude),null!=n.lat&&(t=n.lat),null!=n.longitude&&(r=n.longitude),null!=n.lng&&(r=n.lng),null!=n.lon&&(r=n.lon),t=d.wrap90(d.parse(t)),r=d.wrap180(d.parse(r))),isNaN(t)||isNaN(r))throw new TypeError(`invalid point ‘${JSON.stringify(e[0])}’`)}if(isNaN(t)||isNaN(r))throw new TypeError(`invalid point ‘${e.toString()}’`);return new h(t,r)}distanceTo(e,t=6371e3){if(e instanceof h||(e=h.parse(e)),isNaN(t))throw new TypeError(`invalid radius ‘${t}’`);const r=t,n=this.lat.toRadians(),o=this.lon.toRadians(),i=e.lat.toRadians(),a=i-n,s=e.lon.toRadians()-o,l=Math.sin(a/2)*Math.sin(a/2)+Math.cos(n)*Math.cos(i)*Math.sin(s/2)*Math.sin(s/2);return r*(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)))}initialBearingTo(e){if(e instanceof h||(e=h.parse(e)),this.equals(e))return NaN;const t=this.lat.toRadians(),r=e.lat.toRadians(),n=(e.lon-this.lon).toRadians(),o=Math.cos(t)*Math.sin(r)-Math.sin(t)*Math.cos(r)*Math.cos(n),i=Math.sin(n)*Math.cos(r),a=Math.atan2(i,o).toDegrees();return d.wrap360(a)}finalBearingTo(e){e instanceof h||(e=h.parse(e));const t=e.initialBearingTo(this)+180;return d.wrap360(t)}midpointTo(e){e instanceof h||(e=h.parse(e));const t=this.lat.toRadians(),r=this.lon.toRadians(),n=e.lat.toRadians(),o=(e.lon-this.lon).toRadians(),i=Math.cos(t),a=Math.sin(t),s={x:i+Math.cos(n)*Math.cos(o),y:0+Math.cos(n)*Math.sin(o),z:a+Math.sin(n)},l=Math.atan2(s.z,Math.sqrt(s.x*s.x+s.y*s.y)),c=r+Math.atan2(s.y,s.x),u=l.toDegrees(),d=c.toDegrees();return new h(u,d)}intermediatePointTo(e,t){if(e instanceof h||(e=h.parse(e)),this.equals(e))return new h(this.lat,this.lon);const r=this.lat.toRadians(),n=this.lon.toRadians(),o=e.lat.toRadians(),i=e.lon.toRadians(),a=o-r,s=i-n,l=Math.sin(a/2)*Math.sin(a/2)+Math.cos(r)*Math.cos(o)*Math.sin(s/2)*Math.sin(s/2),c=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),u=Math.sin((1-t)*c)/Math.sin(c),d=Math.sin(t*c)/Math.sin(c),p=u*Math.cos(r)*Math.cos(n)+d*Math.cos(o)*Math.cos(i),f=u*Math.cos(r)*Math.sin(n)+d*Math.cos(o)*Math.sin(i),g=u*Math.sin(r)+d*Math.sin(o),v=Math.atan2(g,Math.sqrt(p*p+f*f)),y=Math.atan2(f,p),m=v.toDegrees(),b=y.toDegrees();return new h(m,b)}destinationPoint(e,t,r=6371e3){const n=e/r,o=Number(t).toRadians(),i=this.lat.toRadians(),a=this.lon.toRadians(),s=Math.sin(i)*Math.cos(n)+Math.cos(i)*Math.sin(n)*Math.cos(o),l=Math.asin(s),c=Math.sin(o)*Math.sin(n)*Math.cos(i),u=Math.cos(n)-Math.sin(i)*s,d=a+Math.atan2(c,u),p=l.toDegrees(),f=d.toDegrees();return new h(p,f)}static intersection(e,t,r,n){if(e instanceof h||(e=h.parse(e)),r instanceof h||(r=h.parse(r)),isNaN(t))throw new TypeError(`invalid brng1 ‘${t}’`);if(isNaN(n))throw new TypeError(`invalid brng2 ‘${n}’`);const o=e.lat.toRadians(),i=e.lon.toRadians(),a=r.lat.toRadians(),s=r.lon.toRadians(),l=Number(t).toRadians(),c=Number(n).toRadians(),u=a-o,d=s-i,f=2*Math.asin(Math.sqrt(Math.sin(u/2)*Math.sin(u/2)+Math.cos(o)*Math.cos(a)*Math.sin(d/2)*Math.sin(d/2)));if(Math.abs(f)<Number.EPSILON)return new h(e.lat,e.lon);const g=(Math.sin(a)-Math.sin(o)*Math.cos(f))/(Math.sin(f)*Math.cos(o)),v=(Math.sin(o)-Math.sin(a)*Math.cos(f))/(Math.sin(f)*Math.cos(a)),y=Math.acos(Math.min(Math.max(g,-1),1)),m=Math.acos(Math.min(Math.max(v,-1),1)),b=l-(Math.sin(s-i)>0?y:2*p-y),E=(Math.sin(s-i)>0?2*p-m:m)-c;if(0==Math.sin(b)&&0==Math.sin(E))return null;if(Math.sin(b)*Math.sin(E)<0)return null;const P=-Math.cos(b)*Math.cos(E)+Math.sin(b)*Math.sin(E)*Math.cos(f),O=Math.atan2(Math.sin(f)*Math.sin(b)*Math.sin(E),Math.cos(E)+Math.cos(b)*P),S=Math.asin(Math.min(Math.max(Math.sin(o)*Math.cos(O)+Math.cos(o)*Math.sin(O)*Math.cos(l),-1),1)),w=i+Math.atan2(Math.sin(l)*Math.sin(O)*Math.cos(o),Math.cos(O)-Math.sin(o)*Math.sin(S)),_=S.toDegrees(),M=w.toDegrees();return new h(_,M)}crossTrackDistanceTo(e,t,r=6371e3){e instanceof h||(e=h.parse(e)),t instanceof h||(t=h.parse(t));const n=r;if(this.equals(e))return 0;const o=e.distanceTo(this,n)/n,i=e.initialBearingTo(this).toRadians(),a=e.initialBearingTo(t).toRadians();return Math.asin(Math.sin(o)*Math.sin(i-a))*n}alongTrackDistanceTo(e,t,r=6371e3){e instanceof h||(e=h.parse(e)),t instanceof h||(t=h.parse(t));const n=r;if(this.equals(e))return 0;const o=e.distanceTo(this,n)/n,i=e.initialBearingTo(this).toRadians(),a=e.initialBearingTo(t).toRadians(),s=Math.asin(Math.sin(o)*Math.sin(i-a));return Math.acos(Math.cos(o)/Math.abs(Math.cos(s)))*Math.sign(Math.cos(a-i))*n}maxLatitude(e){const t=Number(e).toRadians(),r=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(t)*Math.cos(r))).toDegrees()}static crossingParallels(e,t,r){if(e.equals(t))return null;const n=Number(r).toRadians(),o=e.lat.toRadians(),i=e.lon.toRadians(),a=t.lat.toRadians(),s=t.lon.toRadians()-i,l=Math.sin(o)*Math.cos(a)*Math.cos(n)*Math.sin(s),c=Math.sin(o)*Math.cos(a)*Math.cos(n)*Math.cos(s)-Math.cos(o)*Math.sin(a)*Math.cos(n),u=Math.cos(o)*Math.cos(a)*Math.sin(n)*Math.sin(s);if(u*u>l*l+c*c)return null;const p=Math.atan2(-c,l),h=Math.acos(u/Math.sqrt(l*l+c*c)),f=i+p+h,g=(i+p-h).toDegrees(),v=f.toDegrees();return{lon1:d.wrap180(g),lon2:d.wrap180(v)}}rhumbDistanceTo(e,t=6371e3){e instanceof h||(e=h.parse(e));const r=t,n=this.lat.toRadians(),o=e.lat.toRadians(),i=o-n;let a=Math.abs(e.lon-this.lon).toRadians();Math.abs(a)>p&&(a=a>0?-(2*p-a):2*p+a);const s=Math.log(Math.tan(o/2+p/4)/Math.tan(n/2+p/4)),l=Math.abs(s)>1e-11?i/s:Math.cos(n);return Math.sqrt(i*i+l*l*a*a)*r}rhumbBearingTo(e){if(e instanceof h||(e=h.parse(e)),this.equals(e))return NaN;const t=this.lat.toRadians(),r=e.lat.toRadians();let n=(e.lon-this.lon).toRadians();Math.abs(n)>p&&(n=n>0?-(2*p-n):2*p+n);const o=Math.log(Math.tan(r/2+p/4)/Math.tan(t/2+p/4)),i=Math.atan2(n,o).toDegrees();return d.wrap360(i)}rhumbDestinationPoint(e,t,r=6371e3){const n=this.lat.toRadians(),o=this.lon.toRadians(),i=Number(t).toRadians(),a=e/r,s=a*Math.cos(i);let l=n+s;Math.abs(l)>p/2&&(l=l>0?p-l:-p-l);const c=Math.log(Math.tan(l/2+p/4)/Math.tan(n/2+p/4)),u=Math.abs(c)>1e-11?s/c:Math.cos(n),d=o+a*Math.sin(i)/u,f=l.toDegrees(),g=d.toDegrees();return new h(f,g)}rhumbMidpointTo(e){e instanceof h||(e=h.parse(e));const t=this.lat.toRadians();let r=this.lon.toRadians();const n=e.lat.toRadians(),o=e.lon.toRadians();Math.abs(o-r)>p&&(r+=2*p);const i=(t+n)/2,a=Math.tan(p/4+t/2),s=Math.tan(p/4+n/2),l=Math.tan(p/4+i/2);let c=((o-r)*Math.log(l)+r*Math.log(s)-o*Math.log(a))/Math.log(s/a);isFinite(c)||(c=(r+o)/2);const u=i.toDegrees(),d=c.toDegrees();return new h(u,d)}static areaOf(e,t=6371e3){const r=t,n=e[0].equals(e[e.length-1]);n||e.push(e[0]);const o=e.length-1;let i=0;for(let s=0;s<o;s++){const t=e[s].lat.toRadians(),r=e[s+1].lat.toRadians(),n=(e[s+1].lon-e[s].lon).toRadians();i+=2*Math.atan2(Math.tan(n/2)*(Math.tan(t/2)+Math.tan(r/2)),1+Math.tan(t/2)*Math.tan(r/2))}(function(e){let t=0,r=e[0].initialBearingTo(e[1]);for(let n=0;n<e.length-1;n++){const o=e[n].initialBearingTo(e[n+1]),i=e[n].finalBearingTo(e[n+1]);t+=(o-r+540)%360-180,t+=(i-o+540)%360-180,r=i}return t+=(e[0].initialBearingTo(e[1])-r+540)%360-180,Math.abs(t)<90})(e)&&(i=Math.abs(i)-2*p);const a=Math.abs(i*r*r);return n||e.pop(),a}equals(e){return e instanceof h||(e=h.parse(e)),!(Math.abs(this.lat-e.lat)>Number.EPSILON||Math.abs(this.lon-e.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(e="d",t=void 0){if(!["d","dm","dms","n"].includes(e))throw new RangeError(`invalid format ‘${e}’`);return"n"==e?(null==t&&(t=4),`${this.lat.toFixed(t)},${this.lon.toFixed(t)}`):`${d.toLat(this.lat,e,t)}, ${d.toLon(this.lon,e,t)}`}}function f(e,t,r){if(null!==e)for(var n,o,i,a,s,l,c,u,d=0,p=0,h=e.type,g="FeatureCollection"===h,v="Feature"===h,y=g?e.features.length:1,m=0;m<y;m++){s=(u=!!(c=g?e.features[m].geometry:v?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var b=0;b<s;b++){var E=0,P=0;if(null!==(a=u?c.geometries[b]:c)){l=a.coordinates;var O=a.type;switch(d=0,O){case null:break;case"Point":if(!1===t(l,p,m,E,P))return!1;p++,E++;break;case"LineString":case"MultiPoint":for(n=0;n<l.length;n++){if(!1===t(l[n],p,m,E,P))return!1;p++,"MultiPoint"===O&&E++}"LineString"===O&&E++;break;case"Polygon":case"MultiLineString":for(n=0;n<l.length;n++){for(o=0;o<l[n].length-d;o++){if(!1===t(l[n][o],p,m,E,P))return!1;p++}"MultiLineString"===O&&E++,"Polygon"===O&&P++}"Polygon"===O&&E++;break;case"MultiPolygon":for(n=0;n<l.length;n++){for(P=0,o=0;o<l[n].length;o++){for(i=0;i<l[n][o].length-d;i++){if(!1===t(l[n][o][i],p,m,E,P))return!1;p++}P++}E++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===f(a.geometries[n],t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}var g=function(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const r=[1/0,1/0,-1/0,-1/0];return f(e,e=>{r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])}),r},v=(e,t)=>{var[r,n]=e,[o,i]=t,a=new h(n,r),s=new h(i,o);return a.distanceTo(s)},y=e=>{var t=e/1609.344;if(t<.5)return"".concat(Math.round(e),"m");if(t<10){var r=Number.parseFloat(t.toFixed(1)),n=1===r?"mile":"miles";return"".concat(r," ").concat(n)}var o=Math.round(t);return"".concat(o," miles")},m=e=>g(e);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var P="highlighted-label";function O(e,t){if("number"==typeof e)return e;if(!Array.isArray(e)||"interpolate"!==e[0])return function(e,t){var{stops:r}=e;if(r.length<2)return r.length>0?r[0][1]:0;for(var n=r[0],o=r[r.length-1],i=1;i<r.length;i++){var a=r[i];if(a[0]>t){o=a,n=r[i-1];break}n=r[i-1],o=a}var[s,l]=n,[c,u]=o;return t<=s?l:t>=c?u:l+(t-s)/(c-s)*(u-l)}(e,t);var[,,r,...n]=e;if("zoom"!==r[0])throw new Error("Only zoom-based expressions supported");for(var o=0;o<n.length-2;o+=2){var i=n[o],a=n[o+1],s=n[o+2],l=n[o+3];if(t<=i)return a;if(t<=s)return a+(t-i)/(s-i)*(l-a)}return n[n.length-1]}function S(e,t){if(t.highlightLayerId&&e.getLayer(t.highlightLayerId)){try{e.removeLayer(t.highlightLayerId)}catch(e){}t.highlightLayerId=null,t.highlightedExpr=null}}function w(e,t,r){var n;if(null!=t&&null!==(n=t.feature)&&void 0!==n&&n.layer){S(e,r);var{feature:o,layer:i}=t;r.highlightLayerId="highlight-".concat(i.id);var{id:a,type:s,properties:l,geometry:c}=o;e.getSource(P).setData({id:a,type:s,properties:l,geometry:c}),r.highlightedExpr=i.layout["text-size"];var u=e.getZoom(),d=function(e,t,r){return{id:"highlight-".concat(e.id),type:e.type,source:P,layout:E(E({},e.layout),{},{"text-size":t,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90}),paint:E(E({},e.paint),{},{"text-color":r.text,"text-halo-color":r.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1})}}(i,1.5*O(r.highlightedExpr,u),r.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"});e.addLayer(d),e.moveLayer(r.highlightLayerId)}}function _(e){e.getSource(P)||e.addSource(P,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function M(e){e.getStyle().layers.filter(e=>{var t;return"line"===(null===(t=e.layout)||void 0===t?void 0:t["symbol-placement"])}).forEach(t=>e.setLayoutProperty(t.id,"symbol-placement","line-center"))}function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function I(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?x(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var A,T="icon-image",C="active-highlight",L="active-highlight-inner",D="selected-highlight",k=(e,t)=>{var r,n;return null!==(r=null===(n=e._activeSymbolImageMap)||void 0===n?void 0:n[t])&&void 0!==r?r:null},j=(e,t)=>{var r,n;return null!==(r=null===(n=e._selectedSymbolImageMap)||void 0===n?void 0:n[t])&&void 0!==r?r:null},R=(e,t,r,n)=>{t.forEach(t=>{if(!r.has(t)){var o="".concat(n,"-").concat(t);["".concat(o,"-fill"),"".concat(o,"-line"),"".concat(o,"-symbol")].forEach(t=>{e.getLayer(t)&&e.setFilter(t,["==","id",""])})}})},N=(e,t)=>{var r="_".concat(t.replaceAll("-",""),"Sources");R(e,e[r]||new Set,new Set,t),e[r]=new Set},F=(e,t,r,n,o,i,a)=>{!!e.getLayer(t)||e.addLayer(I(I({id:t,type:r,source:n},o&&{"source-layer":o}),{},{paint:i})),Object.entries(i).forEach(r=>{var[n,o]=r;e.setPaintProperty(t,n,o)}),e.setFilter(t,a),e.moveLayer(t)},B=(e,t,r,n,o)=>{var i=((e,t)=>{var r={};return null==t||t.forEach(t=>{var{featureId:n,layerId:o,idProperty:i,geometry:a}=t,s=e.getLayer(o);if(s){var l=s.source;r[l]||(r[l]={ids:new Set,fillIds:new Set,idProperty:i,layerId:o,hasFillGeometry:!1}),!a||"Polygon"!==a.type&&"MultiPolygon"!==a.type||(r[l].hasFillGeometry=!0,r[l].fillIds.add(n)),r[l].ids.add(n)}}),r})(e,t),a=new Set(Object.keys(i)),s="_".concat(n.replaceAll("-",""),"Sources"),l=e[s]||new Set;return R(e,l,a,n),e[s]=a,a.forEach(t=>((e,t,r,n,o,i)=>{var{ids:a,fillIds:s,idProperty:l,layerId:c,hasFillGeometry:u}=r[t],d=e.getLayer(c);if(d&&n[c]){var p=n[c],h=d.sourceLayer,f=u?"fill":d.type,g="".concat(o,"-").concat(t),{fill:v}=p,y=o===D,m=(e=>e===D||e===L)(o),{lineColor:b,lineWidth:E}=((e,t)=>({lineColor:t?e.selectionStroke:e.stroke,lineWidth:t?e.strokeWidth:e.activeStrokeWidth}))(p,m),P=l?["get",l]:["id"],O=["in",P,["literal",Array.from(a)]];if("fill-extrusion"!==d.type)switch(f){case"fill":((e,t,r,n,o)=>{var{isSelected:i,idExpression:a,fillIds:s,fill:l,lineColor:c,lineWidth:u,filter:d}=o;if(i){var p=[];s.forEach(e=>p.push(e));var h=["in",a,["literal",p]];F(e,"".concat(t,"-fill"),"fill",r,n,{"fill-color":l},h)}F(e,"".concat(t,"-line"),"line",r,n,{"line-color":c,"line-width":u},d)})(e,g,t,h,{isSelected:y,idExpression:P,fillIds:s,fill:v,lineColor:b,lineWidth:E,filter:O});break;case"line":((e,t,r,n,o,i,a)=>{e.getLayer("".concat(t,"-fill"))&&e.setFilter("".concat(t,"-fill"),["==","id",""]),F(e,"".concat(t,"-line"),"line",r,n,{"line-color":o,"line-width":i},a)})(e,g,t,h,b,E,O);break;case"symbol":((e,t,r,n,o,i,a)=>{((e,t,r,n,o,i,a)=>{var s=e.getLayoutProperty(o,T),l=a(e,s);l&&((e,t,r,n,o,i,a)=>{var s;e.getLayer(t)||e.addLayer(I(I({id:t,type:"symbol",source:r},n&&{"source-layer":n}),{},{layout:{[T]:i,"icon-anchor":null!==(s=e.getLayoutProperty(o,"icon-anchor"))&&void 0!==s?s:"center","icon-allow-overlap":!0}})),e.setLayoutProperty(t,T,i),e.setFilter(t,a),e.moveLayer(t)})(e,"".concat(t,"-symbol"),r,n,o,l,i)})(e,t,r,n,o,i,a)})(e,g,t,h,c,O,i)}else((e,t,r,n)=>{var{ids:o,lineColor:i,lineWidth:a,idExpression:s}=n,l=[];o.forEach(e=>l.push(e));var c=["in",s,["literal",l]],{source:u,sourceLayer:d}=e.getLayer(r);F(e,"".concat(t,"-line"),"line",u,d,{"line-color":i,"line-width":a},c)})(e,g,c,{ids:a,lineColor:b,lineWidth:E,idExpression:P})}})(e,t,i,r,n,o)),i},V=(e,t,r)=>{var n=(t.x-r.x)**2+(t.y-r.y)**2;if(0===n)return(e.x-t.x)**2+(e.y-t.y)**2;var o=((e.x-t.x)*(r.x-t.x)+(e.y-t.y)*(r.y-t.y))/n;return o=Math.max(0,Math.min(1,o)),(e.x-(t.x+o*(r.x-t.x)))**2+(e.y-(t.y+o*(r.y-t.y)))**2},U=(A=(0,i.A)(function*(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2;t.length&&(e._activeSymbolImageMap={},e._selectedSymbolImageMap={},yield Promise.all(t.flatMap(t=>{var a=n.getSymbolImageId(t,r,!1,o),s=n.getSymbolImageId(t,r,!0,o);return a&&s&&(e._activeSymbolImageMap[a]=s),["normal","active","selected"].map(function(){var l=(0,i.A)(function*(i){var l="active"===i?s:a;if("selected"===i||l&&!e.hasImage(l)){var c=yield n.rasteriseSymbolImage(t,r,i,o);c&&("selected"===i&&a&&(e._selectedSymbolImageMap[a]=c.imageId),e.hasImage(c.imageId)||e.addImage(c.imageId,c.imageData,{pixelRatio:o}))}});return function(e){return l.apply(this,arguments)}}())})))}),function(e,t,r,n){return A.apply(this,arguments)}),Y=e=>Math.max(2,2*e),G=(e,t)=>{if(!e)return null;if("string"==typeof e)return e.trim();if("object"==typeof e){if(t&&e[t])return e[t];var r=Object.values(e)[0];return null!=r?r:null}return null},H=new Map,z=function(){var e=(0,i.A)(function*(e,t,r,n){var o=r.getPatternInnerContent(e);if(!o)return null;var i=r.getPatternImageId(e,t,n);if(!i)return null;var a,s,l=H.get(i);if(!l){var c=G(e.fillPatternForegroundColor,t)||"black",u=G(e.fillPatternBackgroundColor,t)||"transparent",d=(a=c,s=u,o.replace(/\{\{foregroundColor\}\}/g,a||"black").replace(/\{\{backgroundColor\}\}/g,s||"transparent")),p='<rect width="16" height="16" fill="'.concat(u,'"/>'),h=Y(n),f=Math.round(8*h),g='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(f,'" height="').concat(f,'" viewBox="0 0 16 16">').concat(p).concat(d,"</svg>");l=yield((e,t,r)=>new Promise((n,o)=>{var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(e)),a=new Image(t,r);a.onload=()=>{var e=document.createElement("canvas");e.width=t,e.height=r;var o=e.getContext("2d");o.drawImage(a,0,0,t,r),n(o.getImageData(0,0,t,r))},a.onerror=()=>{o(new Error("Failed to rasterise SVG: ".concat(e.slice(0,80))))},a.src=i}))(g,f,f),H.set(i,l)}return{imageId:i,imageData:l}});return function(t,r,n,o){return e.apply(this,arguments)}}(),W=function(){var e=(0,i.A)(function*(e,t,r,n,o){if(t.length){var a=Y(o),s=t.reduce((t,s)=>{var l=n.getPatternImageId(s,r,o);return!l||t[l]||e.hasImage(l)||(t[l]=(0,i.A)(function*(){var t=yield z(s,r,n,o);t&&!e.hasImage(t.imageId)&&e.addImage(t.imageId,t.imageData,{pixelRatio:a})})),t},{});yield Promise.all(Object.values(s).map(e=>e()))}});return function(t,r,n,o,i){return e.apply(this,arguments)}}(),J=["container","padding","mapStyle","mapSize","center","zoom","bounds","pixelRatio"];function K(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Z{constructor(e){var{mapFramework:t,mapProviderConfig:r={},events:n,eventBus:o}=e;this.maplibreModule=t,this.events=n,this.eventBus=o,this.capabilities={supportedShortcuts:s,supportsMapSizes:!0},Object.assign(this,r)}get name(){return"MapLibreProvider"}initMap(e){var t=this;return(0,i.A)(function*(){var{container:r,padding:n,mapStyle:i,mapSize:a,center:s,zoom:l,bounds:u,pixelRatio:d}=e,p=(0,o.A)(e,J);t.mapStyleId=null==i?void 0:i.id,t.mapSize=a;var{Map:h}=t.maplibreModule,{events:f,eventBus:g}=t,v=new h(q(q({},p),{},{container:r,style:null==i?void 0:i.url,pixelRatio:d,padding:n,center:s,zoom:l,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1}));v.touchZoomRotate.disableRotation(),t.map=v,t.map.setPadding(n),u&&v.fitBounds(u,{duration:0}),function(e){var t=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){var r=e.getCanvas();if(r&&(this.target===r||r.contains(this.target)))return}t.call(this)}}(v),function(e){var t=e.getCanvas();t.removeAttribute("role"),t.setAttribute("tabindex",-1),t.removeAttribute("aria-label"),t.style.display="block",t.addEventListener("focus",e=>{t.blur(),e.relatedTarget&&e.relatedTarget.focus({preventScroll:!0})})}(v),c({map:v,events:f,eventBus:g,getCenter:t.getCenter.bind(t),getZoom:t.getZoom.bind(t),getBounds:t.getBounds.bind(t),getResolution:t.getResolution.bind(t)}),function(e){var{mapProvider:t,map:r,events:n,eventBus:o}=e;o.on(n.MAP_SET_STYLE,e=>{r.once("style.load",()=>{o.emit(n.MAP_STYLE_CHANGE,{mapStyleId:e.id})}),r.setStyle(e.url,{diff:!1})}),o.on(n.MAP_SET_PIXEL_RATIO,e=>{r.setPixelRatio(e)}),o.on(n.MAP_SIZE_CHANGE,e=>{var{mapSize:r}=e;t.mapSize=r})}({mapProvider:t,map:v,events:f,eventBus:g}),v.on("load",()=>{t.labelNavigator=function(e,t,r,n){var o={isDarkStyle:"dark"===t,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function i(){var t=e.getStyle().layers.filter(e=>"symbol"===e.type),r=e.queryRenderedFeatures({layers:t.map(e=>e.id)});o.labels=function(e,t,r){return t.flatMap(t=>{var n,o=function(e){var t,r;return"string"==typeof e?null===(t=/^{(.+)}$/.exec(e))||void 0===t?void 0:t[1]:Array.isArray(e)?null===(r=e.find(e=>Array.isArray(e)&&"get"===e[0]))||void 0===r?void 0:r[1]:null}(null===(n=t.layout)||void 0===n?void 0:n["text-field"]);return o?r.filter(e=>{var r;return e.layer.id===t.id&&(null===(r=e.properties)||void 0===r?void 0:r[o])}).map(r=>function(e,t,r,n){var o=function(e){var{type:t,coordinates:r}=e;if("Point"===t)return r;if("MultiPoint"===t)return r[0];if(t.includes("LineString")){var n="LineString"===t?r:r[0];return[(n[0][0]+n[n.length-1][0])/2,(n[0][1]+n[n.length-1][1])/2]}if(t.includes("Polygon")){var o="Polygon"===t?r[0]:r[0][0],i=o.reduce((e,t)=>[e[0]+t[0],e[1]+t[1]],[0,0]);return[i[0]/o.length,i[1]/o.length]}return null}(e.geometry);if(!o)return null;var i=n.project({lng:o[0],lat:o[1]});return{text:e.properties[r],x:i.x,y:i.y,feature:e,layer:t}}(r,t,o,e)).filter(Boolean):[]})}(e,t,r)}function a(){if(i(),!o.labels.length)return null;var t=e.project(e.getCenter()),r=function(e,t){var r;return null===(r=e.reduce((e,r)=>{var n=(r.x-t.x)**2+(r.y-t.y)**2;return!e||n<e.dist?{label:r,dist:n}:e},null))||void 0===r?void 0:r.label}(o.labels,t);return o.currentPixel={x:r.x,y:r.y},w(e,r,o),"".concat(r.text," (").concat(r.layer.id,")")}return M(e),_(e),null==n||n.on(r.MAP_SET_STYLE,t=>{e.once("styledata",()=>e.once("idle",()=>{M(e),_(e),o.isDarkStyle="dark"===(null==t?void 0:t.mapColorScheme)}))}),e.on("zoom",()=>{if(o.highlightLayerId&&o.highlightedExpr){var t=O(o.highlightedExpr,e.getZoom());e.setLayoutProperty(o.highlightLayerId,"text-size",1.5*t)}}),function(e){e.getStyle().layers.filter(e=>"symbol"===e.type).forEach(t=>{e.setPaintProperty(t.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(e),{refreshLabels:i,highlightNextLabel:function(t){if(i(),!o.labels.length)return null;if(!o.currentPixel)return a();var r=function(e,t){if(!t.currentPixel)return null;var r=t.labels.map((e,t)=>({pixel:[e.x,e.y],index:t})).filter(e=>e.pixel[0]!==t.currentPixel.x||e.pixel[1]!==t.currentPixel.y);if(!r.length)return null;var n=r.map(e=>e.pixel),o=((e,t,r)=>{var[n,o]=t,i=r.filter(t=>{var[r,i]=t;return(r!==n||i!==o)&&((e,t,r)=>{switch(e){case"ArrowUp":return r<0&&Math.abs(r)>=Math.abs(t);case"ArrowDown":return r>0&&Math.abs(r)>=Math.abs(t);case"ArrowLeft":return t<0&&Math.abs(t)>Math.abs(r);case"ArrowRight":return t>0&&Math.abs(t)>Math.abs(r);default:return!1}})(e,r-n,i-o)});if(!i.length)return r.findIndex(e=>e[0]===n&&e[1]===o);var a=-1,s=1/0;return i.forEach(e=>{var t=e[0]-n,i=e[1]-o,l=t*t+i*i;l<s&&(s=l,a=r.indexOf(e))}),a})(e,[t.currentPixel.x,t.currentPixel.y],n);return(null==o||o<0||o>=r.length)&&(o=0),t.labels[r[o].index]}(t,o);return r?(o.currentPixel={x:r.x,y:r.y},w(e,r,o),"".concat(r.text," (").concat(r.layer.id,")")):null},highlightLabelAtCenter:a,clearHighlightedLabel:()=>S(e,o)}}(v,null==i?void 0:i.mapColorScheme,f,g)}),t.eventBus.emit(f.MAP_READY,{map:t.map,mapStyleId:t.mapStyleId,mapSize:t.mapSize,crs:t.crs})})()}destroyMap(){var e,t;this.setHoverCursor([]),null===(e=this.mapEvents)||void 0===e||e.remove(),null===(t=this.appEvents)||void 0===t||t.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}setHoverCursor(e){this.map&&(this._onHoverMove=((e,t,r)=>{var n=e.getCanvas();if(r&&e.off("mousemove",r),null==t||!t.length)return n.style.cursor="",null;var o=r=>{var o=t.filter(t=>e.getLayer(t));if(0!==o.length){var{lineLayers:i,otherLayers:a}=((e,t)=>{var r=[],n=[];for(var o of t)if("line"===e.getLayer(o).type){var i=o.endsWith("-stroke")?o.slice(0,-7):null;null!==i&&t.includes(i)||r.push(o)}else n.push(o);return{lineLayers:r,otherLayers:n}})(e,o),{x:s,y:l}=r.point,c=[[s-10,l-10],[s+10,l+10]],u=i.length>0&&e.queryRenderedFeatures(c,{layers:i}).length>0,d=a.length>0&&e.queryRenderedFeatures(r.point,{layers:a}).length>0;n.style.cursor=u||d?"pointer":""}else n.style.cursor=""};return e.on("mousemove",o),o})(this.map,e,this._onHoverMove))}setView(e){var{center:t,zoom:r}=e;this.map.flyTo({center:t||this.getCenter(),zoom:r||this.getZoom(),duration:this.map.isStyleLoaded()?a:0})}zoomIn(e){this.map.easeTo({zoom:this.getZoom()+e,duration:a})}zoomOut(e){this.map.easeTo({zoom:this.getZoom()-e,duration:a})}panBy(e){this.map.panBy(e,{duration:a})}fitToBounds(e){var t=Array.isArray(e)?e:m(e),r=this.map.isStyleLoaded()?a:0;this.map.fitBounds(t,{duration:r})}setPadding(e){this.map.setPadding(e)}updateHighlightedFeatures(e,t,r){var{LngLatBounds:n}=this.maplibreModule;return function(e){var{LngLatBounds:t,map:r,selectedFeatures:n,activeFeatures:o,stylesMap:i}=e;if(!r)return null;null!=o&&o.length?(B(r,o,i,C,k),B(r,o,i,L,j)):(N(r,C),N(r,L));var a={};null!=n&&n.length?a=B(r,n,i,D,j):N(r,D);var s=[];return Object.entries(a).forEach(e=>{var[,{ids:t,idProperty:n,layerId:o}]=e;s.push(...r.queryRenderedFeatures({layers:[o]}).filter(e=>{var r;return t.has(n?null===(r=e.properties)||void 0===r?void 0:r[n]:e.id)}))}),((e,t)=>{if(!t.length)return null;var r=new e;return t.forEach(e=>{var t=e=>"number"==typeof e[0]?r.extend(e):e.forEach(t);t(e.geometry.coordinates)}),[r.getWest(),r.getSouth(),r.getEast(),r.getNorth()]})(t,s)}({LngLatBounds:n,map:this.map,selectedFeatures:e,activeFeatures:t,stylesMap:r})}highlightNextLabel(e){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.highlightNextLabel(e))||null}highlightLabelAtCenter(){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.highlightLabelAtCenter())||null}clearHighlightedLabel(){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.clearHighlightedLabel())||null}getCenter(){var e=this.map.getCenter();return[Number(e.lng.toFixed(7)),Number(e.lat.toFixed(7))]}getZoom(){return Number(this.map.getZoom().toFixed(7))}getBounds(){return this.map.getBounds().toArray().flat(1)}getFeaturesAtPoint(e,t){return function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{radius:n=10}=r,o=[[t.x-n,t.y-n],[t.x+n,t.y+n]],i=e.queryRenderedFeatures(o);if(0===i.length)return[];var a=new Set(e.queryRenderedFeatures([t.x,t.y]).map(e=>{var t,r=void 0===e.id?JSON.stringify(e.properties):e.id;return"".concat(null===(t=e.layer)||void 0===t?void 0:t.source,":").concat(r)})),s=[];i.forEach(e=>{!1===s.includes(e.layer.id)&&s.push(e.layer.id)});for(var l=new Set,c=[],u=i.length-1;u>=0;u--){var d,p=i[u],h=void 0===p.id?JSON.stringify(p.properties):p.id,f="".concat(null===(d=p.layer)||void 0===d?void 0:d.source,":").concat(h);!1===l.has(f)&&(l.add(f),c.push(p))}var g=e.unproject(t),v=[g.lng,g.lat],y=c.filter(e=>{var t=e.geometry.type;if(t.includes("Polygon"))return("Polygon"===t?[e.geometry.coordinates]:e.geometry.coordinates).some(e=>((e,t)=>{for(var[r,n]=e,o=!1,i=0,a=t.length-1;i<t.length;a=i,i++){var[s,l]=t[i],[c,u]=t[a];l>n!=u>n&&r<(c-s)*(n-l)/(u-l)+s&&(o=!o)}return o})(v,e[0]));if("Point"===t||"MultiPoint"===t){var r,n=void 0===e.id?JSON.stringify(e.properties):e.id;return a.has("".concat(null===(r=e.layer)||void 0===r?void 0:r.source,":").concat(n))}return!0});return y.map(r=>{var n=0,o=r.geometry.type,i=((e,t,r)=>{var{coordinates:n,type:o}=r,i=1/0,a=t=>e.project(t),s=e=>{for(var r=0;r<e.length-1;r++){var n=V(t,a(e[r]),a(e[r+1]));n<i&&(i=n)}};if("Point"===o){var l=a(n);i=(t.x-l.x)**2+(t.y-l.y)**2}else"LineString"===o||"MultiPoint"===o?"LineString"===o?s(n):n.forEach(e=>{var r=a(e),n=(t.x-r.x)**2+(t.y-r.y)**2;n<i&&(i=n)}):"Polygon"===o||"MultiLineString"===o?n.forEach(s):"MultiPolygon"===o&&n.forEach(e=>e.forEach(s));return i})(e,t,r.geometry);return n+=1e6*s.indexOf(r.layer.id),o.includes("Polygon")&&(n-=5e5),{f:r,score:n+=i}}).sort((e,t)=>e.score-t.score).map(e=>{var{f:t}=e;return t})}(this.map,e,t)}getVisibleFeatures(e){var t=e.filter(e=>this.map.getLayer(e));return t.length?this.map.queryRenderedFeatures(void 0,{layers:t}):[]}addSymbolsToMap(e,t,r){var n=this;return(0,i.A)(function*(){var o=n.map.getPixelRatio()||1;return U(n.map,e,t,r,o)})()}addPatternsToMap(e,t,r){var n=this;return(0,i.A)(function*(){var o=n.map.getPixelRatio()||1;return W(n.map,e,t,r,o)})()}getAreaDimensions(){var{LngLatBounds:e}=this.maplibreModule;return(e=>{var t,r,n,o;if(e&&"function"==typeof e.getWest)t=e.getWest(),r=e.getSouth(),n=e.getEast(),o=e.getNorth();else{if(!Array.isArray(e)||2!==e.length)return"";[[t,r],[n,o]]=e}var i=v([t,r],[n,r]),a=v([t,r],[t,o]),s=y(i),l=y(a);return"".concat(l," by ").concat(s)})(((e,t)=>{var{width:r,height:n}=t.getContainer().getBoundingClientRect(),o=t.getPadding(),i=[o.left,n-o.bottom],a=[r-o.right,o.top];return new e(t.unproject(i),t.unproject(a))})(e,this.map))}getCardinalMove(e,t){return((e,t)=>{var[r,n]=e,[o,i]=t,a=i-n,s=o-r,l=[];if(Math.abs(a)>1e-4){var c=Math.round(v([r,n],[r,i]));l.push("".concat(a>0?"north":"south"," ").concat(y(c)))}if(Math.abs(s)>1e-4){var u=Math.round(v([r,n],[o,n]));l.push("".concat(s>0?"east":"west"," ").concat(y(u)))}return l.join(", ")})(e,t)}getResolution(){return e=this.map.getCenter(),t=this.map.getZoom(),r=e.lat,n=Math.pow(2,t),40075016.686*Math.cos(r*Math.PI/180)/(512*n);var e,t,r,n}mapToScreen(e){return this.map.project(e)}screenToMap(e){var{lng:t,lat:r}=this.map.unproject([e.x,e.y]);return[t,r]}isGeometryObscured(e,t){return((e,t,r)=>{var n=r.getContainer().getBoundingClientRect(),[o,i,a,s]=m(e),l=[r.project([o,i]),r.project([o,s]),r.project([a,i]),r.project([a,s])],c=Math.min(...l.map(e=>e.x)),u=Math.max(...l.map(e=>e.x)),d=Math.min(...l.map(e=>e.y)),p=Math.max(...l.map(e=>e.y)),h=t.left-n.left,f=t.top-n.top,g=t.right-n.left,v=t.bottom-n.top;return c<g&&u>h&&d<v&&p>f})(e,t,this.map)}}}}]);
1
+ (self.webpackChunk=self.webpackChunk||[]).push([[402],{967:(e,t,n)=>{n.r(t),n.d(t,{initialiseApp:()=>Nr});var r=n(818),o=n(196),i=n(452),s=n(247);const a=(0,i.q6)(null);function l(){return(0,i.NT)(a)}const c=(e,t)=>{const n={...e};for(const r in t)"object"!=typeof t[r]||Array.isArray(t[r])||null===t[r]?n[r]=t[r]:n[r]=c(e[r]||{},t[r]);return n},d=(e,t)=>({...e,...t}),u=(e,t,n)=>{const r=c(In,n);return{...e,[t]:r}},p=(e,t)=>({...e,...t}),h=(e,t,n)=>{const r=c(wn,n);return{...e,[t]:{...r,html:r.html,render:r.render}}},f=(e,t)=>{const{[t]:n,...r}=e;return r},g=(e,t)=>({...e,...t}),m=(e,t,n)=>{const r=c(Pn,n);return{...e,[t]:{id:t,...r}}};function y(e,t,n,r,o){const i=e.panelConfig||e.panelRegistry.getPanelConfig(),s=i[t]?.[n];if(!s)return e.openPanels;const a=!!s.exclusive&&!s.modal,l=!!s.modal,c=Object.fromEntries(Object.entries(e.openPanels).filter(([e])=>!i[e]?.[n]?.exclusive));return{...a?{}:c,...l?e.openPanels:{},[t]:{props:r,...void 0!==o&&{focusOnOpen:o}}}}const v=(e,t)=>e===t||!!e&&!!t&&e.length===t.length&&e.every((e,n)=>e===t[n]),b={SET_BREAKPOINT:(e,t)=>{const{behaviour:n,hybridWidth:r,maxMobileWidth:i}=t,s=Object.keys(e.openPanels),a=s[s.length-1],l="hybrid"===n?e.isFullscreen:(0,o.g)({behaviour:n,hybridWidth:r,maxMobileWidth:i}),c=a?y(e,a,t.breakpoint,e.openPanels[a]?.props||{}):{},d=e.panelConfig||e.panelRegistry.getPanelConfig(),u=Object.fromEntries(Object.entries(d).filter(([e,n])=>{const r=n[t.breakpoint];return!0===r?.open&&!1===r?.dismissible&&!c[e]}).map(([t])=>[t,e.openPanels[t]||{props:{}}]));return{...e,breakpoint:t.breakpoint,isFullscreen:l,previousOpenPanels:e.openPanels,openPanels:{...c,...u}}},SET_MEDIA:(e,t)=>({...e,...t}),SET_HYBRID_FULLSCREEN:(e,t)=>({...e,isFullscreen:t}),SET_INTERFACE_TYPE:(e,t)=>e.interfaceType===t?e:{...e,interfaceType:t},PLUGINS_EVALUATED:e=>e.arePluginsEvaluated?e:{...e,arePluginsEvaluated:!0},CLEAR_PLUGINS_EVALUATED:e=>e.arePluginsEvaluated?{...e,arePluginsEvaluated:!1}:e,SET_LISTBOX_ACTIVE:e=>e.listboxIsActive?e:{...e,listboxIsActive:!0},SET_SAFE_ZONE_INSET:(e,{safeZoneInset:t,syncMapPadding:n=!0})=>((e,t)=>{if(e===t)return!0;if(!e||!t||"object"!=typeof e||"object"!=typeof t)return!1;const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.is(e[n],t[n]))})(e.safeZoneInset,t)?e:{...e,safeZoneInset:t,syncMapPadding:n,isLayoutReady:!0},OPEN_PANEL:(e,t)=>{const{panelId:n,props:r={},focusOnOpen:o}=t,i=y(e,n,e.breakpoint,r,o);return i===e.openPanels?e:{...e,previousOpenPanels:e.openPanels,openPanels:i}},CLOSE_PANEL:(e,t)=>{const{[t]:n,...r}=e.openPanels;return{...e,previousOpenPanels:e.openPanels,openPanels:r}},CLOSE_ALL_PANELS:e=>({...e,previousOpenPanels:e.openPanels,openPanels:{}}),RESTORE_PREVIOUS_PANELS:e=>({...e,openPanels:e.previousOpenPanels||{},previousOpenPanels:e.openPanels}),TOGGLE_APP_VISIBLE:(e,t)=>({...e,appVisible:t}),SET_APPLICATION_MODE:(e,{id:t,include:n=null,exclude:r=null})=>{const o=e.applicationModeEntries,i=o[o.length-1];return i?.id===t&&v(i.include,n)&&v(i.exclude,r)?e:{...e,applicationModeEntries:[...o.filter(e=>e.id!==t),{id:t,include:n,exclude:r}]}},CLEAR_APPLICATION_MODE:(e,t)=>{const n=e.applicationModeEntries.filter(e=>e.id!==t);return n.length===e.applicationModeEntries.length?e:{...e,applicationModeEntries:n}},TOGGLE_NUDGE_STEP:e=>({...e,nudgeStepSize:"small"===e.nudgeStepSize?"large":"small"}),TOGGLE_BUTTON_DISABLED:(e,t)=>{const{id:n,isDisabled:r}=t,o=new Set(e.disabledButtons);return r?o.add(n):o.delete(n),{...e,disabledButtons:o}},TOGGLE_BUTTON_HIDDEN:(e,t)=>{const{id:n,isHidden:r}=t,o=new Set(e.hiddenButtons);return r?o.add(n):o.delete(n),{...e,hiddenButtons:o}},TOGGLE_BUTTON_PRESSED:(e,t)=>{const{id:n,isPressed:r}=t,o=new Set(e.pressedButtons);return r?o.add(n):o.delete(n),{...e,pressedButtons:o}},TOGGLE_BUTTON_EXPANDED:(e,t)=>{const{id:n,isExpanded:r}=t,o=new Set(e.expandedButtons);return r?o.add(n):o.delete(n),{...e,expandedButtons:o}},REGISTER_BUTTON:(e,t)=>({...e,buttonConfig:d(e.buttonConfig,t)}),ADD_BUTTON:(e,t)=>{const{id:n,config:r}=t,o=u(e.buttonConfig,n,r),i=new Set(e.hiddenButtons);r.isHidden&&i.add(n);const s=new Set(e.disabledButtons);r.isDisabled&&s.add(n);const a=new Set(e.pressedButtons);r.isPressed&&a.add(n);const l=new Set(e.expandedButtons);return r.isExpanded&&l.add(n),e.buttonRegistry?.addButton&&e.buttonRegistry.addButton(n,r),{...e,buttonConfig:o,hiddenButtons:i,disabledButtons:s,pressedButtons:a,expandedButtons:l}},REGISTER_PANEL:(e,t)=>({...e,panelConfig:p(e.panelConfig,t)}),ADD_PANEL:(e,t)=>{const{id:n,config:r}=t,o=h(e.panelConfig,n,r),i=o[n];e.panelRegistry?.addPanel&&e.panelRegistry.addPanel(n,r);const s=i?.[e.breakpoint],a=s?.open;return{...e,panelConfig:o,openPanels:a?y({...e,panelConfig:o},n,e.breakpoint,{}):e.openPanels}},REMOVE_PANEL:(e,t)=>{const n=t,{[n]:r,...o}=e.openPanels;return e.panelRegistry?.removePanel&&e.panelRegistry.removePanel(n),{...e,panelConfig:f(e.panelConfig,n),openPanels:o}},REGISTER_CONTROL:(e,t)=>({...e,controlConfig:g(e.controlConfig,t)}),ADD_CONTROL:(e,t)=>{const{id:n,config:r}=t,o=m(e.controlConfig,n,r);return e.controlRegistry?.addControl&&e.controlRegistry.addControl(n,r),{...e,controlConfig:o}}};function _(){return{preferredColorScheme:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",prefersReducedMotion:window.matchMedia("(prefers-reduced-motion: reduce)").matches}}const E=(e,t)=>{const{type:n,payload:r}=t,o=b[n];return o?o(e,r):e},S=Object.freeze({SIDE:"side",HEADER:"header",BANNER:"banner",TOP_LEFT:"top-left",TOP_MIDDLE:"top-middle",TOP_RIGHT:"top-right",LEFT_TOP:"left-top",LEFT_BOTTOM:"left-bottom",MIDDLE:"middle",RIGHT_TOP:"right-top",RIGHT_BOTTOM:"right-bottom",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",DRAWER:"drawer",ACTIONS:"actions",MODAL:"modal"}),x=Object.freeze({control:[S.HEADER,S.BANNER,S.TOP_LEFT,S.TOP_RIGHT,S.MIDDLE,S.RIGHT_TOP,S.RIGHT_BOTTOM,S.BOTTOM_RIGHT,S.DRAWER,S.ACTIONS],panel:[S.SIDE,S.HEADER,S.BANNER,S.LEFT_TOP,S.LEFT_BOTTOM,S.MIDDLE,S.RIGHT_TOP,S.RIGHT_BOTTOM,S.DRAWER,S.MODAL],button:[S.TOP_LEFT,S.TOP_MIDDLE,S.TOP_RIGHT,S.LEFT_TOP,S.LEFT_BOTTOM,S.RIGHT_TOP,S.RIGHT_BOTTOM,S.BOTTOM_LEFT,S.BOTTOM_RIGHT,S.ACTIONS]}),I=["mobile","tablet","desktop"],w=(0,i.q6)(null),P=({options:e,children:t})=>{const{pluginRegistry:n,buttonRegistry:r,panelRegistry:l,controlRegistry:d,keyboardShortcutRegistry:u,spatialListRegistry:p,eventBus:g,breakpointDetector:m}=e,y={appContainerRef:(0,i.li)(null),sideRef:(0,i.li)(null),mainRef:(0,i.li)(null),headerRef:(0,i.li)(null),topRef:(0,i.li)(null),topLeftColRef:(0,i.li)(null),topRightColRef:(0,i.li)(null),leftRef:(0,i.li)(null),leftTopRef:(0,i.li)(null),leftBottomRef:(0,i.li)(null),middleRef:(0,i.li)(null),rightRef:(0,i.li)(null),rightTopRef:(0,i.li)(null),rightBottomRef:(0,i.li)(null),drawerRef:(0,i.li)(null),bottomRef:(0,i.li)(null),bottomRightRef:(0,i.li)(null),attributionsRef:(0,i.li)(null),actionsRef:(0,i.li)(null),bannerRef:(0,i.li)(null),modalRef:(0,i.li)(null),viewportRef:(0,i.li)(null)},v=(0,i.li)({}),[b,S]=(0,i.WO)(E,(e=>{const{initialBreakpoint:t,initialInterfaceType:n,appColorScheme:r,autoColorScheme:i,pluginRegistry:s,buttonRegistry:a,panelRegistry:l,controlRegistry:c}=e,{preferredColorScheme:d,prefersReducedMotion:u}=_(),p=(0,o.g)(e),h=function(e,t,n={}){const r={};return Object.keys(e).forEach(o=>{const i=e[o][t];i?.open&&(r[o]=n[o]||{props:{}})}),r}(l.getPanelConfig(),t);return{appVisible:null,isLayoutReady:!1,arePluginsEvaluated:!1,breakpoint:t,interfaceType:n,preferredColorScheme:i?d:r,prefersReducedMotion:u,isFullscreen:p,safeZoneInset:null,disabledButtons:e.backAndContinue?.continueLabel?new Set(["journeyContinue"]):new Set,hiddenButtons:new Set,pressedButtons:new Set,expandedButtons:new Set,applicationModeEntries:[],nudgeStepSize:"large",openPanels:h,previousOpenPanels:{},listboxIsActive:!1,syncMapPadding:!0,pluginRegistry:s,buttonRegistry:a,panelRegistry:l,controlRegistry:c,buttonConfig:a.getButtonConfig(),panelConfig:l.getPanelConfig(),controlConfig:c.getControlConfig()}})(e)),P=(0,i.li)(b.panelConfig);P.current=b.panelConfig;const C=(0,i.hb)(t=>{const n=P.current||e.panelRegistry.getPanelConfig(),r=b;S(t),P.current=((e,{type:t,payload:n})=>"ADD_PANEL"===t?h(e,n.id,n.config):"REMOVE_PANEL"===t?f(e,n):e)(n,t),function(e,t,n,r){const{type:i,payload:s}=e;if("CLOSE_PANEL"===i&&queueMicrotask(()=>{r.emit(o.E.APP_PANEL_CLOSED,{panelId:s})}),"CLOSE_ALL_PANELS"===i&&queueMicrotask(()=>{Object.keys(t.openPanels).forEach(e=>{r.emit(o.E.APP_PANEL_CLOSED,{panelId:e})})}),"OPEN_PANEL"===i&&function({panelId:e,props:t},n,r,i){if(!r?.[e]?.[n.breakpoint])return;const s=function(e,t,n,r){const o=r[e]?.[n],i=!!o?.exclusive&&!o?.modal,s=[];if(o?.modal)return s;const a=Object.keys(t);return i?a.forEach(e=>{const t=r[e]?.[n];t?.exclusive||s.push(e)}):a.forEach(e=>{const t=r[e]?.[n];t?.exclusive&&!t?.modal&&s.push(e)}),s}(e,n.openPanels,n.breakpoint,r);queueMicrotask(()=>{s.forEach(e=>{i.emit(o.E.APP_PANEL_CLOSED,{panelId:e})}),i.emit(o.E.APP_PANEL_OPENED,{panelId:e,props:t})})}(s,t,n,r),"ADD_BUTTON"===i){const{id:e,config:t}=s,n=c(In,t);I.forEach(t=>{const r=n[t]?.slot;r&&!x.button.includes(r)&&o.l.warn(`button "${e}" has invalid slot "${r}" at breakpoint "${t}". Allowed slots: ${x.button.join(", ")}.`)})}if("ADD_CONTROL"===i){const{id:e,config:t}=s,n=c(Pn,t);I.forEach(t=>{const r=n[t]?.slot;!r||x.control.includes(r)||r.endsWith("-panel")||o.l.warn(`control "${e}" has invalid slot "${r}" at breakpoint "${t}". Allowed slots: ${x.control.join(", ")}.`)})}if("ADD_PANEL"===i){const{id:e,config:n}=s,i=c(wn,n);I.forEach(t=>{const n=i[t]?.slot;!n||x.panel.includes(n)||n.endsWith("-button")||o.l.warn(`panel "${e}" has invalid slot "${n}" at breakpoint "${t}". Allowed slots: ${x.panel.join(", ")}.`)});const a=i[t.breakpoint];a?.open&&queueMicrotask(()=>{const t=a.slot,{visibleGeometry:n}=i,s={panelId:e,slot:t};n&&(s.visibleGeometry=n),r.emit(o.E.APP_PANEL_OPENED,s)})}}(t,r,n,g)},[b,e,g]);!function(e,t){const{appColorScheme:n,autoColorScheme:r,behaviour:o,hybridWidth:s,maxMobileWidth:a}=t;(0,i.vJ)(()=>{const t=[window.matchMedia("(prefers-color-scheme: dark)"),window.matchMedia("(prefers-reduced-motion: reduce)")];function i(){const{preferredColorScheme:t,prefersReducedMotion:o}=_();e({type:"SET_MEDIA",payload:{preferredColorScheme:r?t:n,prefersReducedMotion:o}})}t.forEach(e=>e.addEventListener("change",i));let l=null,c=null;if("hybrid"===o){const t=s??a;l=window.matchMedia(`(max-width: ${t}px)`),c=t=>{e({type:"SET_HYBRID_FULLSCREEN",payload:t.matches})},l.addEventListener("change",c)}return()=>{t.forEach(e=>e.removeEventListener("change",i)),l&&c&&l.removeEventListener("change",c)}},[e,o,s,a])}(S,e),(0,i.vJ)(()=>{const t=m.subscribe(t=>{C({type:"SET_BREAKPOINT",payload:{behaviour:e.behaviour,breakpoint:t,hybridWidth:e.hybridWidth,maxMobileWidth:e.maxMobileWidth}})}),n=(0,o.s)(e=>{C({type:"SET_INTERFACE_TYPE",payload:e})});return()=>{t(),n()}},[]);const T=(0,i.Kr)(()=>({...b,dispatch:C,layoutRefs:y,buttonRefs:v,pluginRegistry:n,buttonRegistry:r,panelRegistry:l,controlRegistry:d,keyboardShortcutRegistry:u,spatialListRegistry:p}),[b,C]);return(0,s.Y)(a.Provider,{value:e,children:(0,s.Y)(w.Provider,{value:T,children:t})})};function C(){return(0,i.NT)(w)}const T=(e,t)=>`${e}-tabs-tab-${t.toLowerCase().replaceAll(/\s+/g,"-")}`,M=(e,t)=>`${e}-tabs-panel-${t.toLowerCase().replaceAll(/\s+/g,"-")}`,L=({tabs:e,defaultTab:t,panelProps:n})=>{const{id:r}=l(),o=e.map(e=>e.name),[a,c]=(0,i.J0)(t??o[0]),d=(0,i.hb)(e=>{c(e),document.getElementById(T(r,e))?.focus()},[r]),u=(0,i.hb)(e=>{const t=o.indexOf(a);"ArrowRight"===e.key?(e.preventDefault(),d(o[(t+1)%o.length])):"ArrowLeft"===e.key?(e.preventDefault(),d(o[(t-1+o.length)%o.length])):"Home"===e.key?(e.preventDefault(),d(o[0])):"End"===e.key&&(e.preventDefault(),d(o.at(-1)))},[o,a,d]),p=["im-c-tabs__panel",n?.className].filter(Boolean).join(" ");return(0,s.FD)("div",{className:"im-c-tabs",children:[(0,s.Y)("div",{role:"tablist",className:"im-c-tabs__list",children:e.map(({name:e})=>(0,s.Y)("button",{type:"button",id:T(r,e),role:"tab","aria-selected":a===e,"aria-controls":M(r,e),tabIndex:a===e?0:-1,className:"im-c-tabs__tab",onClick:()=>d(e),onKeyDown:u,children:(0,s.Y)("span",{className:"im-c-tabs__label",children:e})},e))}),e.map(({name:e,content:t})=>{const o=a===e;return(0,s.Y)("div",{ref:o?n?.ref:void 0,id:M(r,e),role:"tabpanel","aria-labelledby":T(r,e),tabIndex:o?n?.tabIndex??-1:-1,hidden:!o,className:p,children:t},e)})]})};function A(e){const t=e.filter(e=>null==e.order||0===e.order),n=e.filter(e=>null!=e.order&&0!==e.order);n.sort((e,t)=>e.order-t.order);const r=[...t];for(const o of n){const e=Math.min(Math.max(o.order-1,0),r.length);r.splice(e,0,o)}return r}function O(e){return e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function k({items:e,keyFn:t}){const n=new Map;for(const r of e){const e=t(r),o=e?O(e):null;n.has(o)||n.set(o,[]),n.get(o).push(r)}return n}function D({items:e,fallbackLabel:t}){const n=k({items:e,keyFn:e=>e.tab});if(n.size<=1)return null;const r=Array.from(n.entries()).map(([e,n])=>{const r=A(n),o=r[0];return{id:e??"default",order:o.order,name:e?o.tab:t,items:r}});return A(r)}const R=({items:e})=>(0,s.Y)("dl",{className:"im-c-keyboard-help__list",children:e.map(e=>(0,s.FD)("div",{className:"im-c-keyboard-help__item"+(e.visuallyHidden?" im-u-visually-hidden":""),children:[(0,s.Y)("dt",{className:"im-c-keyboard-help__title",children:e.title}),(0,s.Y)("dd",{className:"im-c-keyboard-help__description",dangerouslySetInnerHTML:{__html:e.command}})]},e.id))}),N=(e,t)=>{const n=e.find(e=>e.items.some(({shortcut:e})=>(e.context??"viewport")===t));if(n)return n.name;const r=e.find(e=>e.items.some(({shortcut:e})=>"global"===e.context));return r?.name??e[0].name},F=({context:e="viewport"})=>{const t=l(),{listboxIsActive:n,keyboardShortcutRegistry:r}=C(),o=r.getKeyboardShortcuts(t),i=n?o:o.filter(e=>"listbox"!==e.context),a=D({items:i.map(e=>({id:e.id,order:0,tab:e.group,shortcut:e})),fallbackLabel:"Navigate"});if(!a)return(0,s.Y)("div",{className:"im-c-keyboard-help",children:(0,s.Y)(R,{items:i})});const c=a.map(e=>({name:e.name,content:(0,s.Y)(R,{items:e.items.map(({shortcut:e})=>e)})}));return(0,s.Y)("div",{className:"im-c-keyboard-help",children:(0,s.Y)(L,{tabs:c,defaultTab:N(a,e)})})},V=(e,t)=>`${e}-panel-${O(t)}`;let B=0;const U=({children:e,content:t})=>{const{interfaceType:n}=C(),r=(0,i.li)(null),o=(0,i.li)(null),[a,l]=(0,i.J0)(!1),[c,d]=(0,i.J0)(!1),[u,p]=(0,i.J0)(null),[h]=(0,i.J0)(()=>(B+=1,`tooltip-${B}`)),f=(0,i.li)(null),g=(0,i.li)(null),m=()=>{clearTimeout(f.current),l(!1)},y=()=>{clearTimeout(g.current),f.current=setTimeout(()=>l(!0),500)},v=()=>{clearTimeout(f.current),g.current=setTimeout(()=>l(!1),0)};return(0,i.vJ)(()=>{const e=e=>{"Escape"===e.key&&(clearTimeout(f.current),clearTimeout(g.current),l(!1))};if(window.addEventListener("keydown",e),a){const e=function(e,t){if(!e)return"bottom";t||(t=e.closest(".im-o-app__main"));const n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),o={top:n.top-r.top,bottom:r.bottom-n.bottom,left:n.left-r.left,right:r.right-n.right},i=Object.entries(o);i.sort(([,e],[,t])=>e-t);const[s,a]=i[0];if("top"===s||"bottom"===s)for(const[l,c]of i)if(("left"===l||"right"===l)&&Math.abs(c-a)<=50)return"left"===l?"right":"left";return{top:"bottom",bottom:"top",left:"right",right:"left"}[s]}(r.current);p(e)}return()=>{window.removeEventListener("keydown",e),clearTimeout(f.current),clearTimeout(g.current)}},[a]),(0,s.FD)("div",{className:"im-c-tooltip-wrapper"+(c?" im-c-tooltip-wrapper--has-focus":""),children:[(0,i.Ob)(e,{ref:t=>{r.current=t;const n=e.props?.ref;"function"==typeof n?n(t):n&&"object"==typeof n&&(n.current=t)},onMouseEnter:y,onMouseLeave:v,onMouseDown:m,onKeyDown:m,onFocus:()=>{"keyboard"===n&&y(),d(!0)},onBlur:()=>{v(),d(!1)},"aria-labelledby":h}),(0,s.Y)("div",{id:h,ref:o,className:`im-c-tooltip im-c-tooltip--${u||"hidden"} ${a?"im-c-tooltip--is-visible":""}`,role:"tooltip","aria-hidden":!a,children:t})]})};let G={close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>'};const j=()=>G,H=({id:e,svgContent:t,isMenu:n})=>{const r=n?j().chevron:j()[e]||t;return(0,s.Y)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:r},className:"im-c-icon"+(n?" im-c-icon--narrow":"")})},$=(e,t)=>({...e,...t}),Y={SET_MAP_READY:e=>({...e,isMapReady:!0}),MAP_MOVE:$,MAP_MOVE_END:$,MAP_FIRST_IDLE:$,SET_MAP_STYLE:(e,t)=>({...e,mapStyle:t}),SET_MAP_SIZE:(e,t)=>({...e,mapSize:t}),UPDATE_CROSS_HAIR:(e,t)=>({...e,crossHair:{...e.crossHair,...t}}),UPSERT_LOCATION_MARKER:(e,t)=>{const n=new Map(e.markers.items.map(e=>[e.id,e])),r=n.get(t.id)||{};n.set(t.id,{...r,...t});const o=Array.from(n.values());return{...e,markers:{...e.markers,items:o}}},REMOVE_LOCATION_MARKER:(e,t)=>{const n=e.markers.items.filter(e=>e.id!==t);return{...e,markers:{...e.markers,items:n}}}},z=(e,t)=>{const{type:n,payload:r}=t,o=Y[n];return o?o(e,r):e},K=(0,i.q6)(null),W=({options:e,children:t})=>{const[n,r]=(0,i.WO)(z,(e=>{const{center:t,zoom:n,bounds:r,extent:o,mapStyle:i,mapSize:s,markers:a}=e,{registeredPlugins:l}=e.pluginRegistry;return{isMapReady:!1,mapProvider:null,mapStyle:l?.find(e=>e.config?.handlesMapStyle)?null:i,mapSize:s,center:t,zoom:n,bounds:r||o,resolution:null,isAtMaxZoom:null,isAtMinZoom:null,crossHair:{isVisible:!1,isPinnedToMap:!1,state:"active"},markers:{items:a||[]}}})(e)),{eventBus:a}=e,l=(0,i.li)(!1),c=()=>{r({type:"SET_MAP_READY"})},d=t=>{const n=localStorage.getItem(`${e.id}:mapStyleId`),o=t.find(e=>e.id===n)||t[0],i=localStorage.getItem(`${e.id}:mapSize`)||e.mapSize;r({type:"SET_MAP_STYLE",payload:o}),r({type:"SET_MAP_SIZE",payload:i})},u=e=>{r({type:"SET_MAP_STYLE",payload:e})},p=e=>{r({type:"SET_MAP_SIZE",payload:e})};(0,i.vJ)(()=>(a.on(o.E.MAP_READY,c),a.on(o.E.MAP_INIT_MAP_STYLES,d),a.on(o.E.MAP_SET_STYLE,u),a.on(o.E.MAP_SET_SIZE,p),()=>{a.off(o.E.MAP_READY,c),a.off(o.E.MAP_INIT_MAP_STYLES,d),a.off(o.E.MAP_SET_STYLE,u),a.off(o.E.MAP_SET_SIZE,p)}),[]),(0,i.vJ)(()=>{n.mapSize&&(l.current?a.emit(o.E.MAP_SIZE_CHANGE,{mapSize:n.mapSize}):l.current=!0)},[n.mapSize]),(0,i.vJ)(()=>{n.mapStyle&&n.mapSize&&(localStorage.setItem(`${e.id}:mapStyleId`,n.mapStyle.id),localStorage.setItem(`${e.id}:mapSize`,n.mapSize))},[n.mapStyle,n.mapSize]);const h=(0,i.Kr)(()=>({...n,dispatch:r}),[n]);return(0,s.Y)(K.Provider,{value:h,children:t})};function J(){return(0,i.NT)(K)}const q="aria-label",X=(e,t)=>e?"string"==typeof e?e.trim():"object"==typeof e?t&&e[t]?e[t]:Object.values(e)[0]??null:null:null,Z={symbol:"pin",size:"medium",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},Q={small:.75,medium:1,large:1.25},ee=[.5,.5],te="0 0 44 44",ne={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},re={id:"pin",path:"M22 7a13 13 0 0 1 13 13C35 28.258 23.758 39.499 22 39.499S9 28.259 9 20.001a13 13 0 0 1 13-13z",bounds:[9,7,26,32.499],anchorPoint:[22,40.5],graphicCentre:[22,20],graphic:ne.dot},oe={id:"circle",path:"M22 9a13 13 0 1 1 0 26 13 13 0 1 1 0-26z",bounds:[9,9,26,26],anchorPoint:[22,22],graphicCentre:[22,22],graphic:ne.dot},ie={id:"square",path:"M13.2 33.8a3 3 0 0 1-3-3V13.2a3 3 0 0 1 3-3h17.6a3 3 0 0 1 3 3v17.6a3 3 0 0 1-3 3H13.2z",bounds:[10.2,10.2,23.6,23.6],anchorPoint:[22,22],graphicCentre:[22,22],graphic:ne.dot},se={id:"hexagon",path:"M23.5 8.317L33.1 13.859A3 3 0 0 1 34.6 16.457L34.6 27.543A3 3 0 0 1 33.1 30.141L23.5 35.683A3 3 0 0 1 20.5 35.683L10.9 30.141A3 3 0 0 1 9.4 27.543L9.4 16.457A3 3 0 0 1 10.9 13.859L20.5 8.317A3 3 0 0 1 23.5 8.317z",bounds:[9.4,7.915,25.2,28.17],anchorPoint:[22,22],graphicCentre:[22,22],graphic:ne.dot},ae={id:"triangle",path:"M25.598 9.7L38.415 31.9A3 3 0 0 1 35.817 36.4L10.183 36.4A3 3 0 0 1 7.585 31.9L20.402 9.7A3 3 0 0 1 25.598 9.7z",bounds:[7.183,8.2,31.634,28.2],anchorPoint:[23,26],graphicCentre:[23,26.5],graphic:ne.dot},le={id:"diamond",path:"M25.121 8.716L37.284 20.879A3 3 0 0 1 37.284 25.121L25.121 37.284A3 3 0 0 1 20.879 37.284L8.716 25.121A3 3 0 0 1 8.716 20.879L20.879 8.716A3 3 0 0 1 25.121 8.716z",bounds:[7.838,7.838,30.325,30.325],anchorPoint:[23,23],graphicCentre:[23,23],graphic:ne.dot},ce=new Set,de=e=>`'${e}'`,ue=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),pe=e=>!(!e.label||e.symbol||e.svgContent||null!==e.symbol&&null!==e.svgContent),he=e=>{if(t=e,!t?.symbol&&!t?.symbolSvgContent)return{};var t;const n={};return ue.forEach(t=>{if(null!=e[t]){const r=t.charAt(6).toLowerCase()+t.slice(7);n[r]=e[t]}}),n},fe={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}},ge=e=>{const{haloColor:t,selectedColor:n,activeColor:r,foregroundColor:o}=(e=>{const t=fe[e?.mapColorScheme]??fe.light;return{haloColor:e?.haloColor??t.haloColor,selectedColor:e?.selectedColor??t.selectedColor,activeColor:e?.activeColor??t.activeColor,foregroundColor:e?.foregroundColor??t.foregroundColor}})(e);return{"--map-overlay-halo-color":t,"--map-overlay-selected-color":n,"--map-overlay-active-color":r,"--map-overlay-foreground-color":o}},me=(e,t,n)=>new Promise((r,o)=>{const i=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,s=new Image(t,n);s.onload=()=>{const e=document.createElement("canvas");e.width=t,e.height=n;const o=e.getContext("2d");o.drawImage(s,0,0,t,n),r(o.getImageData(0,0,t,n))},s.onerror=()=>{o(new Error(`Failed to rasterise SVG: ${e.slice(0,80)}`))},s.src=i}),ye=e=>{let t=0,n=2166136261;for(const r of e){const e=r.codePointAt(0);t=Math.imul(t,31)+e,n=Math.imul(n^e,16777619)}return(t>>>0).toString(36)+(n>>>0).toString(36)},ve=e=>{const t=new Map,n=new Map;return{get:e=>{const n=t.get(e);return n&&(t.delete(e),t.set(e,n)),n},rasteriseOnce:(r,o)=>{if(!n.has(r)){const i=o().then(n=>(((n,r)=>{t.set(n,r),t.size>e&&t.delete(t.keys().next().value)})(r,n),n)).finally(()=>n.delete(r));n.set(r,i)}return n.get(r)}}},be=/[MmLlHhVvCcSsQqTtAaZz]/,_e=/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/y,Ee=/[\s,]*/y,Se=/[-+.\d]/,xe={m:"nn",l:"nn",h:"n",v:"n",c:"nnnnnn",s:"nnnn",q:"nnnn",t:"nn",a:"nnnffnn",z:""},Ie=1e6,we=.5,Pe=2*Math.PI,Ce=Math.PI/180,Te=e=>Math.round(e*Ie)/Ie,Me=e=>Math.abs(e)<1e-12,Le=e=>e>0&&e<1;class Ae{position=0;constructor(e){this.pathData=e}fail(e){throw new Error(`Invalid SVG path: ${e} at position ${this.position} in "${this.pathData}"`)}skipSeparators(){Ee.lastIndex=this.position,Ee.exec(this.pathData),this.position=Ee.lastIndex}atEnd(){return this.skipSeparators(),this.position>=this.pathData.length}peek(){return this.pathData[this.position]}readCommand(){if(!be.test(this.peek()))return null;const e=this.peek();return this.position++,e}readNumber(){this.skipSeparators(),_e.lastIndex=this.position;const e=_e.exec(this.pathData);return e||this.fail("expected a number"),this.position=_e.lastIndex,Number.parseFloat(e[0])}readFlag(){this.skipSeparators();const e=this.peek();return"0"!==e&&"1"!==e&&this.fail("expected an arc flag (0 or 1)"),this.position++,Number(e)}readParameters(e){return[...xe[e.toLowerCase()]].map(e=>"f"===e?this.readFlag():this.readNumber())}}const Oe=(e,t,n,r)=>{const o=3*t-e-3*n+r,i=2*(e-2*t+n),s=t-e;if(Me(o))return Me(i)?[]:[-s/i];const a=i*i-4*o*s;if(a<0)return[];const l=Math.sqrt(a);return[(-i+l)/(2*o),(-i-l)/(2*o)]},ke=(e,t,n,r,o)=>{const i=1-o;return i**3*e+3*i**2*o*t+3*i*o**2*n+o**3*r},De=(e,t,n)=>{const r=e-2*t+n;return Me(r)?[]:[(e-t)/r]},Re=(e,t,n,r)=>{const o=1-r;return o**2*e+2*o*r*t+r**2*n},Ne=e=>(e%Pe+Pe)%Pe;class Fe{currentX=0;currentY=0;subpathStartX=0;subpathStartY=0;lastCubicControl=null;lastQuadControl=null;hasPoints=!1;minX=1/0;minY=1/0;maxX=-1/0;maxY=-1/0;include(e,t){this.hasPoints=!0,this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,t),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,t)}moveCurrentPoint(e,t){this.currentX=e,this.currentY=t,this.include(e,t)}moveTo(e,t){this.moveCurrentPoint(e,t),this.subpathStartX=e,this.subpathStartY=t}lineTo(e,t){this.moveCurrentPoint(e,t)}reflect(e){return e?[2*this.currentX-e[0],2*this.currentY-e[1]]:[this.currentX,this.currentY]}cubicTo(e,t,n,r,o,i){const s=[this.currentX,e,n,o],a=[this.currentY,t,r,i];[...Oe(...s),...Oe(...a)].filter(Le).forEach(e=>this.include(ke(...s,e),ke(...a,e))),this.moveCurrentPoint(o,i),this.lastCubicControl=[n,r]}quadTo(e,t,n,r){const o=[this.currentX,e,n],i=[this.currentY,t,r];[...De(...o),...De(...i)].filter(Le).forEach(e=>this.include(Re(...o,e),Re(...i,e))),this.moveCurrentPoint(n,r),this.lastQuadControl=[e,t]}arcTo(e){(e=>{if(Me(e.radiusX)||Me(e.radiusY)||e.startX===e.endX&&e.startY===e.endY)return[];const{centreX:t,centreY:n,radiusX:r,radiusY:o,cosRotation:i,sinRotation:s,startAngle:a,sweepAngle:l}=(({startX:e,startY:t,endX:n,endY:r,radiusX:o,radiusY:i,rotation:s,largeArc:a,sweep:l})=>{const c=Math.cos(s*Ce),d=Math.sin(s*Ce),u=(e-n)*we,p=(t-r)*we,h=c*u+d*p,f=-d*u+c*p,g=Math.max(1,Math.sqrt(h*h/(o*o)+f*f/(i*i))),m=o*g,y=i*g,v=m*m*y*y,b=m*m*f*f+y*y*h*h,_=(a===l?-1:1)*Math.sqrt(Math.max(0,(v-b)/b)),E=_*(m*f/y),S=_*(-y*h/m),x=Math.atan2((f-S)/y,(h-E)/m);let I=Math.atan2((-f-S)/y,(-h-E)/m)-x;return l&&I<0&&(I+=Pe),!l&&I>0&&(I-=Pe),{centreX:c*E-d*S+(e+n)*we,centreY:d*E+c*S+(t+r)*we,radiusX:m,radiusY:y,cosRotation:c,sinRotation:d,startAngle:x,sweepAngle:I}})(e),c=Math.atan2(-o*s,r*i),d=Math.atan2(o*i,r*s);return[c,c+Math.PI,d,d+Math.PI].filter(e=>l>=0?Ne(e-a)<=l:Ne(a-e)<=-l).map(e=>[t+r*i*Math.cos(e)-o*s*Math.sin(e),n+r*s*Math.cos(e)+o*i*Math.sin(e)])})({...e,startX:this.currentX,startY:this.currentY}).forEach(([e,t])=>this.include(e,t)),this.moveCurrentPoint(e.endX,e.endY)}close(){this.currentX=this.subpathStartX,this.currentY=this.subpathStartY}}const Ve={m:(e,[t,n],[r,o])=>e.moveTo(t+r,n+o),l:(e,[t,n],[r,o])=>e.lineTo(t+r,n+o),h:(e,[t],[n])=>e.lineTo(t+n,e.currentY),v:(e,[t],[,n])=>e.lineTo(e.currentX,t+n),c:(e,[t,n,r,o,i,s],[a,l])=>e.cubicTo(t+a,n+l,r+a,o+l,i+a,s+l),s:(e,[t,n,r,o],[i,s],a)=>e.cubicTo(...e.reflect(a.cubic),t+i,n+s,r+i,o+s),q:(e,[t,n,r,o],[i,s])=>e.quadTo(t+i,n+s,r+i,o+s),t:(e,[t,n],[r,o],i)=>e.quadTo(...e.reflect(i.quad),t+r,n+o),a:(e,[t,n,r,o,i,s,a],[l,c])=>e.arcTo({radiusX:Math.abs(t),radiusY:Math.abs(n),rotation:r,largeArc:o,sweep:i,endX:s+l,endY:a+c}),z:e=>e.close()},Be=.5,Ue=e=>4*Math.ceil(e/4),Ge=e=>Math.round(1e3*e)/1e3,je=new Set,He=new WeakMap,$e=(e,t)=>{let n=He.get(e);if(n||(n=new Map,He.set(e,n)),n.has(t))return n.get(t);const[r,o,i,s]=e.bounds,a=Ue(i*t+16),l=Ue(s*t+16),c=(a-i*t)*Be,d=(l-s*t)*Be,[u,p]=e.anchorPoint,h={...e,scale:t,viewBox:`0 0 ${a} ${l}`,anchor:[((u-r)*t+c)/a,((p-o)*t+d)/l],bodyBox:[c,d,i*t,s*t],transform:`translate(${Ge(c)}, ${Ge(d)}) scale(${t}) translate(${-r}, ${-o})`};return n.set(t,h),h},Ye=new Map,ze=(e,t,n)=>{if(!Ye.has(e)){let t={scale:1,graphicCentreX:8,graphicCentreY:8};if(e)try{const[n,r,o,i]=(e=>{const t=new Fe;for(const[n,...r]of(e=>{const t=new Ae(e),n=[];let r=null;for(;!t.atEnd();){const e=t.readCommand();e||r&&Se.test(t.peek())||t.fail(`unexpected "${t.peek()}"`),r=e??r,n.push([r,...t.readParameters(r)]),r={M:"L",m:"l",Z:null,z:null}[r]??r}return n})(e)){const e=n.toLowerCase(),o=n===e?[t.currentX,t.currentY]:[0,0],i={cubic:t.lastCubicControl,quad:t.lastQuadControl};t.lastCubicControl=null,t.lastQuadControl=null,Ve[e](t,r,o,i)}if(!t.hasPoints)throw new Error(`Invalid SVG path: "${e}" draws nothing`);return[Te(t.minX),Te(t.minY),Te(t.maxX-t.minX),Te(t.maxY-t.minY)]})(e);t={scale:Math.min(1,16/Math.max(o,i,Number.EPSILON)),graphicCentreX:n+o*Be,graphicCentreY:r+i*Be}}catch(e){o.l.warn(`Symbol graphic could not be measured, so it isn't centred — ${e.message}`)}Ye.set(e,t)}const{scale:r,graphicCentreX:i,graphicCentreY:s}=Ye.get(e);return`translate(${t}, ${n}) scale(${Ge(.8*r)}) translate(${Ge(-i)}, ${Ge(-s)})`},Ke=e=>!!e&&"none"!==e,We=ve(256),Je=(e,t,n,r)=>`symbol-${e}${ye(`${n}|${t}`)}-${r}x`,qe=new Set(["id","svg","viewBox","anchor","symbol","svgContent","size","symbolSvgContent","symbolSize","path","bounds","anchorPoint","graphicCentre","bodyBox","transform","scale"]),Xe={normal:{resolveWith:"resolve",prefix:""},active:{resolveWith:"resolveActive",prefix:"act-"},selected:{resolveWith:"resolveSelected",prefix:"sel-"}},Ze=(e,t)=>Array.isArray(e)&&e.length===t&&e.every(Number.isFinite);function Qe(e,t){return e.path?((e,t)=>{const{path:n,scale:r,transform:o,graphicCentre:[i,s]}=e,a=(e,t)=>`<path d="${n}" fill="none" stroke="${e}" stroke-width="${Ge(t/r)}" stroke-linejoin="round"/>`;return`<g transform="${o}">${[Ke(t.activeColor)?a(t.activeColor,14):"",Ke(t.selectedColor)?a(t.selectedColor,8):"",`<path d="${n}" fill="${t.backgroundColor}" stroke="${t.haloColor}" stroke-width="${Ge(2/r)}" stroke-linejoin="round" paint-order="stroke fill"/>`,`<g transform="${ze(t.graphic,i,s)}"><path d="${t.graphic}" fill="${t.foregroundColor}"/></g>`].join("")}</g>`})(e.transform?e:$e(e,1),t):((e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e))(e.svg,t)}function et(e,t,n,r){const o=n?.id,i=Object.fromEntries(Object.entries(e||{}).filter(([e])=>!qe.has(e))),s=Object.fromEntries(Object.entries(r).filter(([e])=>!qe.has(e))),a=Object.fromEntries(Object.entries(t).filter(([,e])=>null!=e)),l={...Z,...s,...i,...a},c=fe[n?.mapColorScheme]??fe.light;return l.haloColor=n?.haloColor??c.haloColor,l.selectedColor=n?.selectedColor??c.selectedColor,l.activeColor=n?.activeColor??c.activeColor,"string"==typeof l.graphic&&ne[l.graphic]&&(l.graphic=ne[l.graphic]),Object.fromEntries(Object.entries(l).map(([e,t])=>[e,X(t,o)||""]))}const tt={getMarkerSymbolDef(e){const t=this.getDefaults(),n=e.svgContent||t.svgContent,r=n?{svg:n}:this.get(e.symbol||t.symbol);if(r)return this.getSizedSymbolDef(r,{viewBox:e.viewBox||t.viewBox,size:e.size??t.size,anchor:e.anchor??t.anchor})},resolveVariant(e,t,n,r){const{resolveWith:o}=Xe[r]??Xe.normal;return this[o](e,t,n)},getKeySymbol(e,t){const n=this.getSymbolDef({...e,symbolSize:"medium"});if(!n)return null;const r={...t,mapColorScheme:t?.appColorScheme??"light"};return{svg:this.resolve(n,he(e),r),viewBox:n.viewBox}},resolveSymbolImage(e,t,n,r){const o=this.getSymbolDef(e);if(!o)return null;const{prefix:i}=Xe[n]??Xe.normal,s=this.resolveVariant(o,he(e),t,n);return{symbolDef:o,resolvedContent:s,imageId:Je(i,s,o.viewBox,r)}},getSymbolImageId(e,t,n,r){return this.resolveSymbolImage(e,t,n,r)?.imageId??null},getSymbolImageIds(e,t,n){const r=this.getSymbolImageId(e,t,"normal",n);return r?{normal:r,active:this.getSymbolImageId(e,t,"active",n),selected:this.getSymbolImageId(e,t,"selected",n)}:null},getSymbolDef(e){const t=e.symbolSvgContent?{svg:e.symbolSvgContent}:e.symbol&&this.get(e.symbol);if(t)return this.getSizedSymbolDef(t,{viewBox:e.symbolViewBox,size:e.symbolSize,anchor:e.symbolAnchor})},getSizedSymbolDef(e,{viewBox:t,size:n,anchor:r}={}){const i=(e=>{if(null==e||Object.keys(Q).includes(e))return Q[e]??Q.medium;if(!ce.has(e)){ce.add(e);const t=Object.keys(Q).map(de).join(", ");o.l.warn(`Unknown symbol size "${e}" — expected ${t}. Using 'medium'.`)}return Q.medium})(n??this.getDefaults().size),s=e.path?$e(e,i):((e,t,n)=>{const r={anchor:ee,...e};if(1===n)return{...r,viewBox:t};const o=t.split(" ").map(e=>Ge(Number(e)*n)).join(" ");return{...r,viewBox:o,svg:`<g transform="scale(${n})">${e.svg}</g>`}})(e,t??e.viewBox??te,i);return((e,t)=>{if(!t)return e;if(!(e=>Array.isArray(e)&&2===e.length&&e.every(Number.isFinite))(t)){const n=JSON.stringify(t);return je.has(n)||(je.add(n),o.l.warn(`Invalid symbolAnchor ${n} — expected [x, y] numbers. Using the symbol's own anchor.`)),e}if(!e.bodyBox)return{...e,anchor:t};const[n,r,i,s]=e.bodyBox,[,,a,l]=e.viewBox.split(" ").map(Number);return{...e,anchor:[(n+t[0]*i)/a,(r+t[1]*s)/l]}})(s,r)},async rasteriseSymbolImage(e,t,n,r){const o=this.resolveSymbolImage(e,t,n,r);if(!o)return null;const{symbolDef:{viewBox:i},resolvedContent:s,imageId:a}=o;let l=We.get(a);if(!l){const[,,e,t]=i.split(" ").map(Number),n=`<svg xmlns="http://www.w3.org/2000/svg" width="${e*r}" height="${t*r}" viewBox="${i}">${s}</svg>`;l=await We.rasteriseOnce(a,()=>me(n,e*r,t*r))}return{imageId:a,imageData:l}}},nt=()=>{const e=new Map;let t={};const n={setDefaults(e){t=e||{}},getDefaults:()=>({...Z,...t}),register(t){(e=>{if("string"!=typeof e?.id||!e.id)throw new TypeError('symbolRegistry.register: a symbol needs a string "id"');e.path?(({id:e,bounds:t,anchorPoint:n,graphicCentre:r})=>{if(!Ze(t,4))throw new TypeError(`symbolRegistry.register: symbol "${e}" has a "path" but no valid "bounds" ([x, y, width, height])`);if(!Ze(n,2)||!Ze(r,2))throw new TypeError(`symbolRegistry.register: symbol "${e}" has a "path" but no valid "anchorPoint" and "graphicCentre" ([x, y])`)})(e):(({id:e,svg:t,viewBox:n,anchor:r})=>{if("string"!=typeof t||!t)throw new TypeError(`symbolRegistry.register: symbol "${e}" needs an "svg" template`);if("string"!=typeof n||4!==n.trim().split(/[\s,]+/).length)throw new TypeError(`symbolRegistry.register: symbol "${e}" needs a "viewBox" ('minX minY width height')`);if(void 0!==r&&!Ze(r,2))throw new TypeError(`symbolRegistry.register: symbol "${e}" has an invalid "anchor" — expected [x, y] in 0–1`)})(e)})(t),e.set(t.id,t)},get:t=>e.get(t),list:()=>[...e.values()],clear(){e.clear()},initialise(){this.register(re),this.register(oe),this.register(ie),this.register(se),this.register(ae),this.register(le)},resolve(e,n,r){const o=et(e,n||{},r,t);return e?(o.selectedColor="none",o.activeColor="none",Qe(e,o)):""},resolveActive(e,n,r){const o=et(e,n||{},r,t);return e?Qe(e,o):""},resolveSelected(e,n,r){const o=et(e,n||{},r,t);return e?(o.activeColor="none",Qe(e,o)):""},...tt};return n.initialise(),n},rt={"cross-hatch":'<path d="M0 4.486V3.485h3.5V.001h1v3.484h7.002V.001h1v3.484h3.5v1.001h-3.5v7h3.5v.999h-3.5v3.516h-1v-3.516H4.499v3.516h-1v-3.516H0v-.999h3.5v-7H0zm11.501 0H4.499v7h7.002v-7z" fill="{{foregroundColor}}"/>',"diagonal-cross-hatch":'<path d="M0 8.707V7.293L7.293 0h1.414L16 7.293v1.414L8.707 16H7.293L0 8.707zM.707 8L8 15.293 15.293 8 8 .707.707 8z" fill="{{foregroundColor}}"/>',"forward-diagonal-hatch":'<path d="M16 8.707V7.293L7.293 16h1.414L16 8.707zm-16 0L8.707 0H7.293L0 7.293v1.414z" fill="{{foregroundColor}}"/>',"backward-diagonal-hatch":'<path d="M0 8.707V7.293L8.707 16H7.293L0 8.707zm16 0L7.293 0h1.414L16 7.293v1.414z" fill="{{foregroundColor}}"/>',"horizontal-hatch":'<path d="M0 4.5V3.499h15.999V4.5H0zm0 7h15.999V12.5H0v-1.001z" fill="{{foregroundColor}}"/>',"vertical-hatch":'<path d="M3.501 16.001V0h1v16.001h-1zm7.998 0V0h1v16.001h-1z" fill="{{foregroundColor}}"/>',dot:'<path d="M3.999 2A2 2 0 0 1 6 3.999C6 5.103 5.103 6 3.999 6a2 2 0 0 1-1.999-2.001A2 2 0 0 1 3.999 2zm0 7.999C5.103 10 6 10.897 6 12.001A2 2 0 0 1 3.999 14a2 2 0 0 1-1.999-1.999A2 2 0 0 1 3.999 10zM11.999 2A2 2 0 0 1 14 3.999C14 5.103 13.103 6 11.999 6S10 5.103 10 3.999A2 2 0 0 1 11.999 2zm0 7.999c1.104 0 2.001.897 2.001 2.001A2 2 0 0 1 11.999 14 2 2 0 0 1 10 12.001c0-1.104.897-2.001 1.999-2.001z" fill="{{foregroundColor}}"/>',diamond:'<path d="M4 .465L7.535 4 4 7.535.465 4 4 .465zm0 7.999l3.535 3.535L4 15.535.465 11.999 4 8.464zm8-8l3.535 3.535-3.536 3.536L8.464 4 12 .464zm0 8.001L15.536 12 12 15.536 8.465 12 12 8.465z" fill="{{foregroundColor}}"/>'},ot=e=>Math.max(2,2*e),it=(e,t,n)=>e.replace(/\{\{foregroundColor\}\}/g,t||"black").replace(/\{\{backgroundColor\}\}/g,n||"transparent"),st=ve(128),at={getPatternInnerContent(e){return e.fillPatternSvgContent?e.fillPatternSvgContent:e.fillPattern?this.get(e.fillPattern)?.svgContent??null:null},getKeyPatternPaths(e,t){const n=this.getPatternInnerContent(e);if(!n)return null;const r=X(e.fillPatternForegroundColor,t)||"black",o=X(e.fillPatternBackgroundColor,t)||"transparent",i=X(e.stroke,t)||r;return{border:it('<path d="M19 2.862v14.275c0 1.028-.835 1.862-1.862 1.862H2.863c-1.028 0-1.862-.835-1.862-1.862V2.862C1.001 1.834 1.836 1 2.863 1h14.275C18.166 1 19 1.835 19 2.862z" fill="{{backgroundColor}}" stroke="{{foregroundColor}}" stroke-width="2"/>',i,o),content:it(n,r,o)}},getPatternImageId(e,t,n){const r=this.getPatternInnerContent(e);if(!r)return null;const o=X(e.fillPatternForegroundColor,t)||"black",i=X(e.fillPatternBackgroundColor,t)||"transparent",s=ot(n);return`pattern-${ye(r+o+i)}-${s}x`},async rasterisePatternImage(e,t,n){const r=this.getPatternInnerContent(e);if(!r)return null;const o=this.getPatternImageId(e,t,n);if(!o)return null;let i=st.get(o);if(!i){const s=X(e.fillPatternForegroundColor,t)||"black",a=X(e.fillPatternBackgroundColor,t)||"transparent",l=it(r,s,a),c=`<rect width="16" height="16" fill="${a}"/>`,d=Math.round(8*ot(n)),u=`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${d}" viewBox="0 0 16 16">${c}${l}</svg>`;i=await st.rasteriseOnce(o,()=>me(u,d,d))}return{imageId:o,imageData:i}}},lt=()=>{const e=new Map,t={register(t,n){e.set(t,{id:t,svgContent:n})},get:t=>e.get(t),list:()=>[...e.values()],clear(){e.clear()},initialise(){Object.entries(rt).forEach(([e,t])=>{this.register(e,t)})},...at};return t.initialise(),t},ct=(0,i.q6)(null),dt=({eventBus:e,pluginRegistry:t,children:n})=>{const{id:r,handleExitClick:a,symbolDefaults:c}=l(),d=(0,i.li)(null),u=(0,i.Kr)(()=>function(e,{startupGraceDelay:t=1e3}={}){const n=t,r=Date.now();let o=null,i=null,s=!1;const a=t=>{if(!e?.current||!t)return;const o=Math.max(0,n-(Date.now()-r));e.current.textContent="",setTimeout(()=>{e.current&&(s=t===i&&!s,i=t,e.current.textContent=s?t+"​":t)},100+o)},l=(e=>{let t=null;const n=(...n)=>{clearTimeout(t),t=setTimeout(()=>{e(...n)},500)};return n.cancel=()=>{t&&(clearTimeout(t),t=null)},n})(a),c=(e,t="action")=>{if(e)if("ambient"!==t)clearTimeout(o),o=setTimeout(()=>{o=null},1e3),l(e);else{if(o)return;a(e)}};return c.clear=()=>{e?.current&&(e.current.textContent="")},c}(d),[]),p=(0,i.Kr)(()=>function(e){const t=new Set;let n=null,r=null;const o=()=>t.forEach(e=>e(n)),i=()=>{r&&(clearTimeout(r),r=null)},s=()=>{i(),n=null,o(),e.clear?.()};return{show:(t,a={})=>{const{duration:l=4e3,announce:c}=a;i(),n={html:t},o(),e(c??(e=>e.replace(/<[^<>]*>/g,""))(t),"ambient"),l>0&&(r=setTimeout(s,l))},dismiss:s,subscribe:e=>(t.add(e),()=>t.delete(e))}}(u),[u]),{layoutRefs:h}=C(),f=(0,i.Kr)(()=>function({viewportRef:e}){let t=null,n=!1,r=!1;return{focus:({message:o}={})=>{const i=e.current;i&&(o&&(n||(t=i.getAttribute(q)),i.setAttribute(q,o),n=!0,r=!0),i.focus())},clear:()=>{if(r=!1,!n)return;n=!1;const o=e.current;o&&(null===t?o.removeAttribute(q):o.setAttribute(q,t))},releaseAnnouncements:()=>{r=!1},isHoldingAnnouncements:()=>r}}({viewportRef:h.viewportRef}),[]),g=(0,i.Kr)(()=>nt(),[]),m=(0,i.Kr)(()=>lt(),[]);g.setDefaults(c||{});const y=(0,i.Kr)(()=>({announce:u,hints:p,reverseGeocode:(e,t)=>(0,o.r)(e,t),eventBus:e,mapStatusRef:d,focusMap:f.focus,mapFocus:f,closeApp:()=>function(e,t){t()}(0,a),symbolRegistry:g,patternRegistry:m,getPlugin:e=>t?.getPlugin(e)}),[u,p,f,t,g,m]);return(0,s.Y)(ct.Provider,{value:y,children:n})};function ut(){return(0,i.NT)(ct)}const pt=(0,i.q6)(null),ht=({children:e})=>{const{pluginRegistry:t}=l(),n={},r={},o=(0,i.li)({});t.registeredPlugins.forEach(e=>{const t=e.reducer;if(t){const{initialState:o,actions:i}=t;n[e.id]=function(e){return(t={},n)=>{const r=e?.[n?.type];return r?r(t,n.payload):t}}(i),r[e.id]=o}o.current[e.id]||(o.current[e.id]={})});const[a,c]=(0,i.WO)((e,t)=>{const{pluginId:r}=t;return r&&n[r]?{...e,[r]:n[r](e[r],t)}:e},r),d=(e,t)=>(o.current[e]||(o.current[e]={}),o.current[e][t]||(o.current[e][t]=i.Ay.createRef()),o.current[e][t]),u=(0,i.Kr)(()=>({state:a,dispatch:c,refs:o,getPluginRef:d}),[a,c]);return(0,s.Y)(pt.Provider,{value:u,children:e})},ft=e=>{const t=(0,i.NT)(pt);if(!t)throw new Error("usePlugin must be used within PluginProvider");const{state:n,dispatch:r,refs:o,getPluginRef:s}=t;return o.current[e]||(o.current[e]={}),{...n[e],dispatch:t=>r({...t,pluginId:e}),refs:o.current[e],useRef:t=>s(e,t)}},gt=new Map;function mt(e){const t=e;return gt.has(t)||gt.set(t,function({pluginId:t,pluginConfig:n,...r}){const o=l(),a=C(),c=J(),d=ut(),u=ft(t),p=(0,i.li)(a.dispatch);p.current=a.dispatch;const h=(0,i.li)(null);h.current||(h.current={setApplicationMode:(e,{include:t=null,exclude:n=null}={})=>p.current({type:"SET_APPLICATION_MODE",payload:{id:e,include:t,exclude:n}}),clearApplicationMode:e=>p.current({type:"CLEAR_APPLICATION_MODE",payload:e})});const{setApplicationMode:f,clearApplicationMode:g}=h.current;return(0,s.Y)(e,{...r,pluginConfig:n,pluginState:u,appConfig:o,appState:a,mapState:c,services:d,mapProvider:o.mapProvider,iconRegistry:j(),setApplicationMode:f,clearApplicationMode:g,buttonConfig:(0,i.Kr)(()=>Object.fromEntries(Object.entries(a.buttonConfig).filter(([e,n])=>n.pluginId===t)),[a.buttonConfig,t])})}),gt.get(t)}const yt=(e,t)=>e.modal?"modal":"drawer"===e.slot&&["tablet","desktop"].includes(t)?"left-top":e.slot,vt=e=>"string"==typeof e.html&&!e.pluginId,bt=(e,{targetSlot:t,slot:n,isFullscreen:r})=>{const o=t.endsWith("-button");return!(!x.panel.includes(t)&&!o||!1===e.inline&&!r||void 0!==n&&t!==n)},_t=(e,t,n)=>{const r=Object.keys(e).filter(e=>t[e]?.[n]?.modal);return r.length>0?r[r.length-1]:null},Et=(e,t=e=>e.slot)=>{const n=new Map;for(const r of e){const e=t(r);n.has(e)||n.set(e,[]),n.get(e).push(r)}return n},St=(e,t)=>({entries:e?.applicationModeEntries??[],declarations:(e?.pluginRegistry?.registeredPlugins??[]).flatMap(e=>Object.entries(e.manifest?.applicationModes??{}).map(([t,n])=>({id:t,pluginId:e.id,...n}))),config:t?.applicationModes??{}}),xt=({entries:e,config:t})=>{const n=e.filter(e=>!1!==t[e.id]);return n[n.length-1]??null},It=e=>{const t=xt(e);return t?`im-o-app--mode-${t.id}`:null},wt=(e,t)=>!!e&&t.some(t=>e.includes(t)),Pt=(e,t)=>{const n=e.map(e=>e?.[t]).filter(Boolean);return n.length?n.flat():null},Ct=()=>!1;function Tt({slot:e,appState:t,evaluateProp:n,isHiddenByApplicationMode:r=Ct}){const{breakpoint:o,pluginRegistry:i,controlConfig:a}=t;return Object.values(a).filter(r=>{if(vt(r))return!1;const i=r[o];if(!i)return!1;if("function"==typeof r.excludeWhen&&n(r.excludeWhen,r.pluginId))return!1;const s=x.control.includes(i.slot)||i.slot?.endsWith("-panel");return!(!1===r.inline&&!t.isFullscreen)&&(void 0===e||i.slot===e)&&s}).map(e=>{const t=i.registeredPlugins.find(t=>t.manifest?.controls?.some(t=>t.id===e.id)),a=t?.id,l=r({ids:[e.id],pluginId:a});let c;if(e.html)c=(0,s.Y)("div",{className:`im-c-control im-c-control--${O(e.id)}`,hidden:l,dangerouslySetInnerHTML:{__html:n(e.html,a)}},e.id);else{const n=mt(e.render);c=(0,s.Y)("div",{className:`im-c-control-wrapper im-c-control-wrapper--${O(e.id)}`,hidden:l,children:(0,s.Y)(n,{pluginId:a,pluginConfig:t?.config})},e.id)}return{id:e.id,type:"control",slot:e[o].slot,order:e[o]?.order??0,tab:e[o]?.tab,element:c}})}function Mt(e,t){const n=(0,i.li)(),r=(0,i.li)(new WeakMap),o=(0,i.li)(t);return o.current=t,(0,i.vJ)(()=>{const i=(Array.isArray(e)?e:[e]).map(e=>e?.current).filter(Boolean);if(!i.length||!t)return;const s=new window.ResizeObserver(e=>{const t=[];for(const n of e){const{width:e,height:o}=n.contentRect,i=r.current.get(n.target)||{};i.width===e&&i.height===o||(r.current.set(n.target,{width:e,height:o}),t.push(n))}t.length&&(cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{for(const e of t)o.current(e)}))});return i.forEach(e=>s.observe(e)),()=>{s.disconnect(),n.current&&cancelAnimationFrame(n.current)}},[e]),{frameRef:n}}const Lt={"left-top":{inset:"var(--left-offset-top) auto auto var(--primary-gap)",maxHeight:"var(--left-top-max-height)"},"left-bottom":{inset:"auto auto var(--left-offset-bottom) var(--primary-gap)",maxHeight:"var(--left-top-max-height)"},"right-top":{inset:"var(--right-offset-top) var(--primary-gap) auto auto",maxHeight:"var(--right-top-max-height)"},"right-bottom":{inset:"auto var(--primary-gap) var(--right-offset-bottom) auto",maxHeight:"var(--right-top-max-height)"}},At="--modal-inset",Ot="--modal-max-height",kt=({isModal:e,mainRef:t,panelRef:n,buttonContainerEl:r,layoutRefs:o})=>{if(!e||!t.current)return;const i=document.documentElement,s=getComputedStyle(i),a=Number.parseInt(s.getPropertyValue("--divider-gap"),10),l=Number.parseInt(s.getPropertyValue("--primary-gap"),10),c=n.current.dataset.slot;if(c?.endsWith("-button")){const e=n.current?.id,o=e?document.querySelector(`[aria-controls="${e}"]`):null,i=o?.parentElement??(r?.isConnected?r:null)??document.querySelector(`[data-button-slot="${c}"]`);if(!i)return;return void((e,t,n)=>{const r=document.documentElement,o=t.current.getBoundingClientRect(),i=e.getBoundingClientRect(),s=!!e.closest(".im-o-app__left-bottom, .im-o-app__right-bottom"),a=!!e.closest(".im-o-app__left-top, .im-o-app__left-bottom"),l=s?"auto":`${Math.round(i.top-o.top)}px`,c=s?`${Math.round(o.bottom-i.bottom)}px`:"auto",d=a?"auto":`${Math.round(o.right-i.left+n)}px`,u=a?`${Math.round(i.right-o.left+n)}px`:"auto",p=s?Math.round(o.bottom-i.bottom):Math.round(i.top-o.top);r.style.setProperty(At,`${l} ${d} ${c} ${u}`),r.style.setProperty(Ot,o.height-p-n+"px")})(i,t,a)}((e,t,n)=>{const r=document.documentElement,o=Lt[e];if(o)return r.style.setProperty(At,o.inset),void r.style.setProperty(Ot,o.maxHeight);const i=`${e[0].toLowerCase()+e.slice(1)}Ref`,s=t[i]?.current,a=t.mainRef?.current;if(!s||!a)return;const l=s.getBoundingClientRect(),c=a.getBoundingClientRect(),d=l.left-c.left,u=l.top-c.top;r.style.setProperty(At,`${u}px auto auto ${d}px`),r.style.setProperty(Ot,c.height-u-n+"px")})(c,o,l)};const Dt=e=>{const t=!0===e.modal,n="side"===e.slot&&e.open&&!t,r=t||!1!==e.dismissible;return{isModal:t,isAside:n,isDismissible:r,isDialog:!n&&r}},Rt=({isDialog:e,isDismissible:t})=>e?"dialog":t?"complementary":"region",Nt=({items:e,WrappedChild:t,props:n,children:r})=>e?e.map(e=>(0,s.Y)(i.Ay.Fragment,{children:e.element},e.id)):t?(0,s.Y)(t,{...n}):r,Ft=({innerHtmlProp:e,tabs:t,items:n,WrappedChild:r,props:o,children:a,bodyProps:l,panelBodySlot:c})=>{if(e)return(0,s.Y)("div",{...l,dangerouslySetInnerHTML:e});const{className:d,...u}=l;return t?(0,s.Y)("div",{className:d,"data-panel-slot":c,children:(0,s.Y)(L,{tabs:t.map(e=>({name:e.name,content:e.items.map(e=>(0,s.Y)(i.Ay.Fragment,{children:e.element},e.id))})),panelProps:u})}):(0,s.FD)("div",{...l,"data-panel-slot":c,children:[" ",(0,s.Y)(Nt,{items:n,WrappedChild:r,props:o,children:a})]})},Vt=({panelId:e,panelConfig:t,props:n,focusOnOpen:r,WrappedChild:a,items:c,tabs:d,label:u,html:p,children:h,isOpen:f=!0,isHidden:g=!1,rootRef:m})=>{const{id:y}=l(),{dispatch:v,breakpoint:b,layoutRefs:_,interfaceType:E}=C(),S=document.getElementById(`${y}-im-app`),x=t[b],I=V(y,e),{isDialog:w,isModal:P,isDismissible:T,shouldFocus:M,buttonContainerEl:L}=((e,t,n,r)=>{const{isModal:o,isAside:i,isDismissible:s,isDialog:a}=Dt(e);return{isAside:i,isDialog:a,isModal:o,isDismissible:s,shouldFocus:o||!0===r||!1!==r&&!1!==n&&(!0===n||Boolean(t)),buttonContainerEl:e.slot.endsWith("button")?t?.parentNode:void 0}})(x,n?.triggeringElement,t.focus,r),A=P&&f,k=_.mainRef,D=(0,i.li)(null),R=(0,i.li)(null),N=(0,i.li)(f),F=function(e){const[t,n]=(0,i.J0)(!1),r=(0,i.hb)(()=>{const t=e?.current;t&&n(t.scrollHeight>t.clientHeight)},[e]);return Mt(e,r),t}(R),B=m||D,U=()=>{requestAnimationFrame(()=>{const e=n?.triggeringElement,t=e&&document.contains(e)?e:_.viewportRef.current;t?.focus?.({preventScroll:"keyboard"!==E})}),v({type:"CLOSE_PANEL",payload:e})};(function({mainRef:e,panelRef:t,isModal:n,rootEl:r,buttonContainerEl:s,handleClose:a}){const{layoutRefs:l}=C();((e,t,n)=>{(0,i.vJ)(()=>{if(!t)return;const r=t=>{"Escape"===t.key&&(t.stopPropagation(),t.preventDefault(),n()),"Tab"===t.key&&e.current&&function(e,t){if("Tab"!==t.key)return;let n=Array.from(e.querySelectorAll(['a[href]:not([disabled]):not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','*[tabindex="0"]:not([disabled])'].join(",")));if(n=n.filter(e=>!!e.offsetParent),0===n.length)return;const r=n[0],o=n[n.length-1];!t.shiftKey||document.activeElement!==e&&document.activeElement!==r||(o.focus(),t.preventDefault()),t.shiftKey||document.activeElement!==o||(r.focus(),t.preventDefault())}(e.current,t)},o=e.current;return o?.addEventListener("keydown",r),()=>{o?.removeEventListener("keydown",r)}},[t,e,n])})(t,n,a),Mt([e],()=>kt({isModal:n,mainRef:e,panelRef:t,buttonContainerEl:s,layoutRefs:l})),(0,i.Nf)(()=>{kt({isModal:n,mainRef:e,panelRef:t,buttonContainerEl:s,layoutRefs:l})},[n,e,t,s,l]),(0,i.vJ)(()=>{if(!n)return;const e=e=>{const t=e.target.closest(".im-o-app__modal-backdrop");r&&t&&r.contains(t)&&a()};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[n,r,a]),(0,i.Nf)(()=>{if(n&&t.current&&r)return(0,o.t)({containerEl:t.current,isFullscreen:!0,boundaryEl:r}),()=>{(0,o.t)({containerEl:t.current,isFullscreen:!1,boundaryEl:r})}},[n,t,r]),((e,t,n)=>{(0,i.vJ)(()=>{if(!e)return;const r=e=>{const r=e.target,o=t.current;if(!r||!o||!n)return;const i=n.contains(r),s=o.contains(r);i&&!s&&o.focus()};return document.addEventListener("focusin",r),()=>{document.removeEventListener("focusin",r)}},[e,t,n])})(n,t,r)})({mainRef:k,panelRef:B,isModal:A,rootEl:S,buttonContainerEl:L,handleClose:U}),(0,i.vJ)(()=>{const e=f&&!N.current;N.current=f,M&&(e||f)&&B.current?.focus()},[f]);const G=["im-c-panel",`im-c-panel--${x.slot}`,!(x.showLabel??1)&&"im-c-panel--no-heading"].filter(Boolean).join(" "),j=((e,t)=>["im-c-panel__body",!e&&t&&"im-c-panel__body--offset"].filter(Boolean).join(" "))(x.showLabel??!0,T),$=(0,i.Kr)(()=>p?{__html:p}:null,[p]),Y=(({elementId:e,shouldFocus:t,isDialog:n,isDismissible:r,isModal:o,width:i,panelClass:s,slot:a,isOpen:l,isHidden:c})=>({id:e,"aria-labelledby":`${e}-label`,tabIndex:t?-1:void 0,role:Rt({isDialog:n,isDismissible:r}),"aria-modal":n&&o?"true":void 0,style:i?{width:i}:void 0,className:s,"data-slot":a,hidden:!l||c}))({elementId:I,shouldFocus:M,isDialog:w,isDismissible:T,isModal:P,width:x.width,panelClass:G,slot:x.slot,isOpen:f,isHidden:g}),z=(({bodyRef:e,panelBodyClass:t,isBodyScrollable:n,elementId:r})=>({ref:e,className:t,tabIndex:n?0:void 0,role:n?"region":void 0,"aria-labelledby":n?`${r}-label`:void 0}))({bodyRef:R,panelBodyClass:j,isBodyScrollable:F,elementId:I}),K=`${O(e)}-panel`;return(0,s.FD)("div",{ref:B,...Y,children:[(0,s.Y)("h2",{id:`${I}-label`,className:x.showLabel??1?"im-c-panel__heading im-e-heading-m":"im-u-visually-hidden",children:u}),T&&(0,s.Y)("button",{type:"button","aria-label":`Close ${u}`,className:"im-c-panel__close",onClick:U,children:(0,s.Y)(H,{id:"close"})}),(0,s.Y)(Ft,{innerHtmlProp:$,tabs:d,items:c,WrappedChild:a,props:n,bodyProps:z,panelBodySlot:K,children:h})]})};function Bt({panelId:e,config:t,bpConfig:n,props:r,plugin:o,pluginId:i,html:a,label:l,appState:c,evaluateProp:d,isHiddenByApplicationMode:u,controlsBySlot:p}){const h=`${O(e)}-panel`,f=p?p.get(h)??[]:Tt({slot:h,appState:c,evaluateProp:d,isHiddenByApplicationMode:u});if(a)return{};let g=null;if(t.render){const a=mt(t.render);g={id:e,order:0,tab:n.tab,element:(0,s.Y)(a,{...r,pluginId:i,pluginConfig:o?.config})}}const m=g?[g,...f]:f,y=D({items:m,fallbackLabel:l});return y?{tabs:y}:{items:A(m)}}const Ut=(e,t,{appState:n,isHiddenByApplicationMode:r})=>n.hiddenButtons.has(e)||r({ids:[e],pluginId:t.pluginId}),Gt=({buttonId:e,config:t,isHidden:n,appState:r,appConfig:o,evaluateProp:i})=>({buttonId:e,config:t,appState:r,appConfig:o,evaluateProp:i,isHidden:n,variant:t.variant});function jt({buttonId:e,config:t,isHidden:n=!1,appState:r,appConfig:o,evaluateProp:i}){const a=t[r.breakpoint]??{},l=function(e,t,n){const r=!(!e.panelId||!t.openPanels[e.panelId]),o=void 0!==e.isPressed||!!e.pressedWhen;return i=>{if("function"==typeof e.onClick)return e.onClick(i,n(e=>e,e.pluginId)),void(o||e.keepFocus||requestAnimationFrame(()=>t.layoutRefs.viewportRef.current?.focus()));if(e.panelId){const n=i.currentTarget;t.dispatch({type:r?"CLOSE_PANEL":"OPEN_PANEL",payload:r?e.panelId:{panelId:e.panelId,props:{triggeringElement:n},...e.keepFocus&&{focusOnOpen:!1}}})}}}(t,r,i),c=!(!t.panelId||!r.openPanels[t.panelId]),d=t.panelId?r.panelConfig?.[t.panelId]?.[r.breakpoint]:void 0,u=d?Rt(Dt(d)):void 0;return(0,s.Y)(dn,{buttonId:e,iconId:i(t.iconId,t.pluginId),iconSvgContent:i(t.iconSvgContent,t.pluginId),variant:t.variant,label:i(t.label,t.pluginId),href:i(t.href,t.pluginId),showLabel:a.showLabel??!0,isDisabled:r.disabledButtons.has(e),isHidden:n,isPressed:void 0!==t.isPressed||t.pressedWhen?r.pressedButtons.has(e):void 0,isExpanded:void 0!==t.isExpanded||t.expandedWhen?r.expandedButtons.has(e):void 0,isPanelOpen:c,panelRole:u,onClick:l,panelId:t.panelId,menuItems:t.menuItems,idPrefix:o.id,ariaControls:i(t.ariaControls,t.pluginId)})}function Ht(e,t){return e.map(([e,n])=>({id:e,type:"button",slot:n[t.breakpoint].slot,order:n[t.breakpoint]?.order??0,element:(0,s.Y)(jt,{...Gt({buttonId:e,config:n,isHidden:Ut(e,n,t),...t})},e)}))}function $t(e,t,n){const[,r]=t[0],o=r.group.slotOrder??0;if(t.length<2){const[e,r]=t[0];return{id:e,type:"button",slot:r[n.breakpoint].slot,order:o,element:(0,s.Y)(jt,{...Gt({buttonId:e,config:r,isHidden:Ut(e,r,n),...n})},e)}}const i=A(t.map(([e,t])=>({id:e,order:t[n.breakpoint]?.order??0,buttonId:e,config:t,isHidden:Ut(e,t,n)})));return{id:`group-${e}`,type:"group",slot:r[n.breakpoint].slot,order:o,element:(0,s.Y)("div",{role:"group","aria-label":r.group.label,className:"im-c-button-group",hidden:i.every(e=>e.isHidden),children:i.map(({buttonId:e,config:t,isHidden:r})=>(0,s.Y)(jt,{...Gt({buttonId:e,config:t,isHidden:r,...n})},e))},`group-${e}`)}}function Yt(){const e=l(),t=C(),n=J(),r=ut(),o=(0,i.NT)(pt),s={appConfig:e,appState:t,mapState:n,services:r,mapProvider:e?.mapProvider,iconRegistry:j()};function a(t){if(!t)return{pluginStates:o?.state??{}};const n=e.pluginRegistry.registeredPlugins.find(e=>e.id===t),r=n?{pluginId:n.id,...n.config}:{};return Object.hasOwn(o?.state??{},t)?{pluginConfig:r,pluginState:{...o?.state?.[t]??{},dispatch:e=>o?.dispatch?.({...e,pluginId:t})}}:{pluginConfig:r,pluginStates:o?.state??{}}}function c(e,t){const n={...s,...a(t)};return"function"==typeof e?e(n):e}return c.ctx=s,c}const zt=()=>{const e=l(),t=C();return(e=>{const t=xt(e);if(!t)return Ct;const{modeRules:n,ownerIds:r}=((e,{declarations:t,config:n})=>{const r=t.filter(t=>t.id===e.id);return{modeRules:[r.length?{include:Pt(r,"include"),exclude:Pt(r,"exclude")}:null,n[e.id]||null,e.include||e.exclude?{include:e.include,exclude:e.exclude}:null].filter(Boolean),ownerIds:r.map(e=>e.pluginId)}})(t,e),o=!!n[0]?.include;return({ids:e,pluginId:t,isModal:i=!1})=>{if(i)return!1;let s=!o||r.includes(t);return n.forEach(t=>{wt(t.include,e)&&(s=!0),wt(t.exclude,e)&&(s=!1)}),!s}})(St(t,e))},Kt=(0,i.q6)(new Map),Wt=({children:e})=>{const t=function(e){const t=Tt(e),n=function({slot:e,appState:t,evaluateProp:n,isHiddenByApplicationMode:r=Ct,controlsBySlot:o}){const{breakpoint:i,pluginRegistry:a,panelConfig:l,openPanels:c}=t,d=_t(c,l,i);return Object.keys(l).map(u=>{const p=((e,t,n,{slot:r,isFullscreen:o})=>{const i=t[e];if(!i||vt(i))return null;const s=i[n];if(!s)return null;const a=yt(s,n);return bt(i,{targetSlot:a,slot:r,isFullscreen:o})?{config:i,bpConfig:s,targetSlot:a}:null})(u,l,i,{slot:e,isFullscreen:t.isFullscreen});if(!p)return null;const{config:h,bpConfig:f,targetSlot:g}=p,m=c[u],y=((e,t,n,r)=>Boolean(e)&&(!t.modal||n===r))(m,f,u,d),{props:v={},focusOnOpen:b}=m??{},_=a.registeredPlugins.find(e=>e.id===h.pluginId),E=_?.id,S=r({ids:[u],pluginId:E,isModal:!!f.modal}),x=E?n(h.html,E):h.html,I=n(h.label,E);return{id:u,type:"panel",slot:g,order:f.order??0,element:(0,s.Y)(Vt,{panelId:u,panelConfig:h,props:v,focusOnOpen:b,isOpen:y,isHidden:S,...y?Bt({panelId:u,config:h,bpConfig:f,props:v,plugin:_,pluginId:E,html:x,label:I,appState:t,evaluateProp:n,isHiddenByApplicationMode:r,controlsBySlot:o}):{},label:I,html:x},u)}}).filter(Boolean)}({...e,controlsBySlot:Et(t)}),r=function({slot:e,appState:t,appConfig:n,evaluateProp:r,isHiddenByApplicationMode:i=Ct}){const{buttonConfig:s,breakpoint:a}=t,l=function({appState:e,buttonConfig:t,slot:n,evaluateProp:r}){const{breakpoint:o}=e;return t?Object.entries(t).filter(([t,i])=>{const s=i[o];if(i.isMenuItem)return!1;if("function"==typeof i.excludeWhen&&r(i.excludeWhen,i.pluginId))return!1;if(!1===i.inline&&!e.isFullscreen)return!1;if(i.panelId){const t=e.panelConfig?.[i.panelId]?.[o];if(!0===t?.open&&!1===t?.dismissible)return!1}return!(void 0!==n&&s?.slot!==n||!x.button.includes(s?.slot))}):[]}({appState:t,buttonConfig:s,slot:e,evaluateProp:r}),c={breakpoint:a,appState:t,appConfig:n,evaluateProp:r,isHiddenByApplicationMode:i};return[...Et(l,([,e])=>e[a].slot).values()].flatMap(e=>function(e,t){const n=k({items:function(e,t){let n=null;for(const[r,i]of e)if(i.exclusiveSlot&&!t.hiddenButtons.has(r)&&i.pluginId){if(null!==n&&n!==i.pluginId)return o.l.warn(`Slot exclusivity conflict: plugins [${n}, ${i.pluginId}] are both claiming exclusive slot ownership. Showing all buttons.`),e;n=i.pluginId}return null===n?e:e.filter(([e,t])=>t.pluginId===n)}(e,t.appState),keyFn:([,e])=>e.group?.label}),r=[];for(const[o,i]of n)null===o?r.push(...Ht(i,t)):r.push($t(o,i,t));return r}(e,c))}(e),i=Et([...t,...n,...r]);for(const[o,s]of i)i.set(o,A(s));return i}({appConfig:l(),appState:C(),evaluateProp:Yt(),isHiddenByApplicationMode:zt()});return(0,s.Y)(Kt.Provider,{value:t,children:e})},Jt=[],qt=({children:e})=>{const{openPanels:t,panelConfig:n,breakpoint:r}=C(),o=["im-c-panel","im-c-actions",!i.Ay.Children.toArray(e).some(e=>!1===e.props?.isHidden&&"touch"!==e.props?.variant)&&"im-c-actions--hidden",Object.keys(t).some(e=>"mobile"===r&&"drawer"===n[e]?.[r]?.slot)&&"im-c-actions--border-top"].filter(Boolean).join(" ");return(0,s.Y)("div",{className:o,children:e})},Xt=({slot:e})=>{const t=(e=>(0,i.NT)(Kt).get(e)??Jt)(e);return t.length?(0,s.Y)(s.FK,{children:"actions"===e?(0,s.Y)(qt,{slot:"actions",children:t.map(e=>e.element)}):(0,s.Y)(s.FK,{children:t.map(e=>e.element)})}):null},Zt=(e,t,{buttonConfig:n,evaluateProp:r,pluginId:o,id:i})=>{const s=n[t.id];if("function"==typeof s?.onClick?s.onClick(e,r(e=>e,o)):"function"==typeof t.onClick&&t.onClick(e.nativeEvent),e.nativeEvent instanceof KeyboardEvent){const e=document.getElementById(`${i}-${O(t.id)}`);if(e){const t=new MouseEvent("click",{bubbles:!0,cancelable:!0});t._fromKeyboardActivation=!0,e.dispatchEvent(t)}}},Qt=(e,t,n)=>"number"==typeof e?e:"first"===t?n[0]??-1:"last"===t?n[n.length-1]??-1:-1,en=(e,t)=>({panelId:t[e.id]?.panelId??e.panelId,keepFocus:t[e.id]?.keepFocus??e.keepFocus}),tn=(e,t)=>{e?e.focus():t.current?.focus()},nn=({item:e,isSelected:t,hiddenButtons:n,disabledButtons:r,pressedButtons:o,id:i,onItemClick:a})=>(0,s.FD)("li",{id:`${i}-${O(e.id)}`,className:"im-c-popup-menu__item"+(t?" im-c-popup-menu__item--selected":""),role:void 0!==e.isPressed||e.pressedWhen?"menuitemcheckbox":"menuitem","aria-disabled":r.has(e.id)||void 0,"aria-checked":void 0!==e.isPressed||e.pressedWhen?o.has(e.id):void 0,hidden:n.has(e.id),onClick:t=>a(t,e),children:[(e.iconId||e.iconSvgContent)&&(0,s.Y)(H,{id:e.iconId,svgContent:e.iconSvgContent}),(0,s.Y)("span",{className:"im-c-popup-menu__item-label",children:e.label})]}),rn=({popupMenuId:e,buttonId:t,instigatorId:n,pluginId:r,startPos:o,startIndex:a,menuRef:c,items:d,setIsOpen:u,buttonRect:p,isOpen:h=!0})=>{const{id:f}=l(),{buttonRefs:g,buttonConfig:m,hiddenButtons:y,disabledButtons:v,pressedButtons:b,layoutRefs:_}=C(),E=t??n,S=g.current[E],x=Yt(),{index:I,handleMenuKeyDown:w,handleItemClick:P,menuStyle:T,menuDirection:M,menuHAlign:L}=(({items:e,hiddenButtons:t,startIndex:n,startPos:r,instigator:o,instigatorKey:s,buttonRefs:a,buttonConfig:l,disabledButtons:c,pluginId:d,evaluateProp:u,id:p,menuRef:h,setIsOpen:f,buttonRect:g,isOpen:m})=>{const{dispatch:y,layoutRefs:v}=C(),b=v.viewportRef,_=(0,i.Kr)(()=>{const n=[];return e.forEach((e,r)=>{t.has(e.id)||n.push(r)}),n},[e,t]),[E,S]=(0,i.J0)(()=>Qt(n,r,_)),x={buttonConfig:l,evaluateProp:u,pluginId:d,id:p},I=(({items:e,visibleIndices:t,index:n,setIndex:r,disabledButtons:o,instigator:i,setIsOpen:s,activateCtx:a,dispatch:l,viewportRef:c})=>{const d={items:e,index:n,disabledButtons:o,activateCtx:a,instigator:i,dispatch:l,viewportRef:c,setIsOpen:s};return e=>{if(!["Escape","Esc"].includes(e.key))return"Tab"===e.key?(e.preventDefault(),((e,t,n)=>{const r=e??n,o=r.closest?.('[role="dialog"][aria-modal="true"]')??document,i=function({el:e,direction:t,root:n=document}){const r=n.querySelectorAll("input, button, select, textarea, a[href]"),o=Array.prototype.filter.call(r,e=>e.tabIndex>=0&&!!e.offsetParent),i=o.indexOf(e);return o["next"===t?i+1:i-1]||o[0]}({el:r,direction:t?"prev":"next",root:o});i?.focus()})(i,e.shiftKey,e.currentTarget),void s(!1)):void(["ArrowDown","ArrowUp"].includes(e.key)?(e=>{e.preventDefault();const o=t.length;if(0===o)return;const i=t.indexOf(n);let s;s="ArrowDown"===e.key?-1===i?0:(i+1)%o:-1===i?o-1:(i-1+o)%o,r(t[s])})(e):"Home"===e.key&&t.length?r(t[0]):"End"===e.key&&t.length?r(t[t.length-1]):("Enter"===e.key&&((e,{items:t,index:n,disabledButtons:r,activateCtx:o,instigator:i,dispatch:s,viewportRef:a,setIsOpen:l})=>{e.preventDefault();const c=t[n];if(c&&!r.has(c.id)){const{panelId:t,keepFocus:n}=en(c,o.buttonConfig);if(t)return s({type:"OPEN_PANEL",payload:{panelId:t,props:{triggeringElement:i},...n&&{focusOnOpen:!1}}}),void l(!1);if(Zt(e,c,o),n)return tn(i,a),void l(!1)}requestAnimationFrame(()=>a.current?.focus()),l(!1)})(e,d)," "===e.key&&((e,{items:t,index:n,disabledButtons:r,activateCtx:o,instigator:i,dispatch:s,viewportRef:a,setIsOpen:l})=>{e.preventDefault();const c=t[n];if(!c||r.has(c.id))return;const{panelId:d,keepFocus:u}=en(c,o.buttonConfig);if(d)return s({type:"OPEN_PANEL",payload:{panelId:d,props:{triggeringElement:i},...u&&{focusOnOpen:!1}}}),void l(!1);Zt(e,c,o),void 0!==c.isPressed||c.pressedWhen||(u?tn(i,a):requestAnimationFrame(()=>a.current?.focus()),l(!1))})(e,d)));(e=>{e.preventDefault(),tn(i,c),s(!1)})(e)}})({items:e,visibleIndices:_,index:E,setIndex:S,disabledButtons:c,instigator:o,setIsOpen:f,activateCtx:x,dispatch:y,viewportRef:b}),w=e=>{h.current?.contains(e.target)||a.current[s]?.contains(e.target)||f(!1)};(0,i.vJ)(()=>{if(!m)return;h.current?.focus(),S(Qt(n,r,_));const e=()=>f(!1);return document.addEventListener("focusin",w),document.addEventListener("pointerdown",w),window.addEventListener("resize",e),()=>{document.removeEventListener("focusin",w),document.removeEventListener("pointerdown",w),window.removeEventListener("resize",e)}},[m]);const{style:P,direction:T,halign:M}=(e=>{if(!e)return{style:{},direction:"below"};const t={};let n;e.top>=window.innerHeight/2?(t.bottom=window.innerHeight-e.top+"px",n="above"):(t.top=`${e.bottom}px`,n="below");const r=(e.left+e.right)/2;let o;return r>2*window.innerWidth/3?(t.right=window.innerWidth-e.right+"px",o="right"):r<window.innerWidth/3?(t.left=`${e.left}px`,o="left"):(t.left=`${r}px`,o="center"),{style:t,direction:n,halign:o}})(g);return{index:E,handleMenuKeyDown:I,handleItemClick:(e,t)=>{if(e.nativeEvent._fromKeyboardActivation||c.has(t.id))return;const{panelId:n,keepFocus:r}=en(t,l);if(n)return y({type:"OPEN_PANEL",payload:{panelId:n,props:{triggeringElement:o},...r&&{focusOnOpen:!1}}}),void f(!1);f(!1),Zt(e,t,x),r?tn(o,b):b.current?.focus()},menuStyle:P,menuDirection:T,menuHAlign:M}})({items:d,hiddenButtons:y,startIndex:a,startPos:o,instigator:S,instigatorKey:E,buttonRefs:g,buttonConfig:m,disabledButtons:v,pluginId:r,evaluateProp:x,id:f,menuRef:c,setIsOpen:u,buttonRect:p,isOpen:h});return(0,i.d5)((0,s.Y)("ul",{ref:c,id:e,className:"im-c-popup-menu","data-direction":M,"data-halign":L,style:T,role:"menu",tabIndex:"-1",hidden:!h,"aria-labelledby":E,"aria-activedescendant":I>=0?`${f}-${O(d[I].id)}`:void 0,onKeyDown:w,children:h&&d.map((e,t)=>(0,s.Y)(nn,{item:e,isSelected:I===t,hiddenButtons:y,disabledButtons:v,pressedButtons:b,id:f,onItemClick:P},e.id))}),_?.appContainerRef?.current??document.body)},on=(e,t,n)=>["im-c-map-button",e&&`im-c-map-button--${O(e)}`,t&&`im-c-map-button--${t}`,n&&"im-c-map-button--with-label"].filter(Boolean).join(" "),sn=(e,t)=>["im-c-button-wrapper",e&&`im-c-button-wrapper--${O(e)}`,t&&"im-c-button-wrapper--wide"].filter(Boolean).join(" "),an=e=>{" "!==e.key&&"Spacebar"!==e.key||(e.preventDefault(),e.currentTarget.click())},ln=(e,t,n)=>{const r=e.current[t];r&&n(r.getBoundingClientRect().toJSON())},cn=new Set(["menu","listbox","tree","grid","dialog"]),dn=({buttonId:e,iconId:t,iconSvgContent:n,label:r,showLabel:o,isDisabled:a,isPressed:c,isExpanded:d,isHidden:u,isPanelOpen:p,panelRole:h,variant:f,onClick:g,panelId:m,menuItems:y,idPrefix:v,href:b,ariaControls:_})=>{const{id:E}=l(),{buttonRefs:S}=C(),[x,I]=(0,i.J0)(!1),[w,P]=(0,i.J0)(null),[T,M]=(0,i.J0)(null),L=(0,i.li)(null),A=(0,i.hb)(t=>{S.current&&e&&(S.current[e]=t)},[S,e]),k=b?"a":"button",D=y?.length>=1,R=t||n||D,N=((e,t)=>e?`${O(t)}-button`:void 0)(m,e),F=(({idPrefix:e,panelId:t,buttonId:n,hasMenu:r,panelRole:o})=>t?{id:V(e,t),type:"panel",role:o}:r?{id:`${e}-popup-${O(n)}`,type:"popup",role:"menu"}:null)({idPrefix:v,panelId:m,buttonId:e,hasMenu:D,panelRole:h}),B=((e,t,n,r,o,i)=>s=>{e&&["ArrowDown","ArrowUp"].includes(s.key)&&(r("ArrowUp"===s.key?"last":"first"),ln(t,n,o),i(!0))})(D,S,e,P,M,I),G=(e=>t=>{e&&["ArrowDown","ArrowUp"].includes(t.key)&&t.preventDefault()})(D),j=(({appId:e,buttonId:t,className:n,onClick:r,onKeyUp:o,onKeyDown:i,setButtonRef:s,isDisabled:a,isPressed:l,isExpanded:c,isPanelOpen:d,isPopupOpen:u,controlledElement:p,ariaControls:h,href:f})=>{let g;return"panel"===p?.type?g=String(d):"popup"===p?.type?g=u:"boolean"==typeof c&&(g=c),{id:`${e}-${O(t)}`,className:n,onClick:r,onKeyUp:o,onKeyDown:i,ref:s,"aria-disabled":a||void 0,"aria-expanded":g,"aria-pressed":"boolean"==typeof l?l:void 0,"aria-controls":p?.id??h,"aria-haspopup":cn.has(p?.role)?p.role:void 0,...f?{href:f,target:"_blank",onKeyUp:an,role:"button"}:{type:"button"}}})({appId:E,buttonId:e,className:on(e,f,o),onClick:t=>{if(!a){if("popup"===F?.type){const n=""===t.nativeEvent.pointerType;P(n?"first":null),x||ln(S,e,M),I(e=>!e)}g&&g(t)}},onKeyUp:B,onKeyDown:G,setButtonRef:A,isDisabled:a,isPressed:c,isExpanded:d,isPanelOpen:p,isPopupOpen:x,controlledElement:F,ariaControls:_,href:b}),$=(0,s.FD)(k,{...j,children:[R&&(0,s.Y)(H,{id:t,svgContent:n,isMenu:D}),o&&(0,s.Y)("span",{children:r})]});return(0,s.FD)("div",{className:sn(e,o),"data-button-slot":N,hidden:u,children:[o?$:(0,s.Y)(U,{content:r,children:$}),N&&(0,s.Y)(Xt,{slot:N}),"popup"===F?.type&&(0,s.Y)(rn,{popupMenuId:F.id,buttonId:e,startPos:w,menuRef:L,items:y,setIsOpen:I,buttonRect:T,isOpen:x})]})},un=(e,t,n)=>e?n:t,pn=[{id:"panUp",verb:"up",dx:0,dy:-1,key:"ArrowUp"},{id:"panDown",verb:"down",dx:0,dy:1,key:"ArrowDown"},{id:"panLeft",verb:"left",dx:-1,dy:0,key:"ArrowLeft"},{id:"panRight",verb:"right",dx:1,dy:0,key:"ArrowRight"}],hn=[{id:"nudgeZoomIn",label:"Zoom in",announceLabel:"Zoomed in",method:"zoomIn"},{id:"nudgeZoomOut",label:"Zoom out",announceLabel:"Zoomed out",method:"zoomOut"}],fn={small:1,medium:1.5,large:2},gn={slot:"middle",open:!1,dismissible:!0,modal:!0},mn={slot:"top-right",showLabel:!1},yn={slot:"right-top",showLabel:!1},vn={slot:"right-bottom"},bn={slot:"top-left",showLabel:!1,order:1},_n={slot:"actions",showLabel:!0},En={slot:"actions",showLabel:!0,order:10},Sn={buttons:[{id:"journeyBack",label:({appConfig:e})=>e.backAndContinue?.backLabel,variant:"tertiary",onClick:(e,{appConfig:t,services:n})=>"mapOnly"===t.behaviour?globalThis.history.back():n.closeApp(),excludeWhen:({appConfig:e,appState:t})=>!e.backAndContinue?.backLabel||!t.isFullscreen||"mapOnly"===e.behaviour&&globalThis.history.length<=1,mobile:_n,tablet:_n,desktop:_n},{id:"journeyContinue",label:({appConfig:e})=>e.backAndContinue?.continueLabel,variant:"primary",onClick:(e,{services:t,pluginStates:n,mapState:r})=>t.eventBus.emit("app:continue",{pluginStates:n,mapState:r}),excludeWhen:({appConfig:e,appState:t})=>!e.backAndContinue?.continueLabel||!t.isFullscreen,mobile:En,tablet:En,desktop:En},{id:"exit",label:"Close map view",iconId:"close",onClick:(e,{services:t})=>t.closeApp(),excludeWhen:({appConfig:e,appState:t})=>!e.hasExitButton||!t.isFullscreen,mobile:bn,tablet:bn,desktop:bn},{id:"fullscreen",label:()=>(document.fullscreenElement?"Exit":"Enter")+" fullscreen",iconId:()=>document.fullscreenElement?"minimise":"maximise",onClick:(e,{appState:t})=>{const n=t.layoutRefs.appContainerRef.current;document.fullscreenElement?document.exitFullscreen():n.requestFullscreen()},excludeWhen:({appState:e,appConfig:t})=>!t.enableFullscreen||e.isFullscreen,mobile:mn,tablet:mn,desktop:mn},{id:"zoomIn",group:{label:"Zoom controls",slotOrder:0},label:"Zoom in",iconId:"plus",keepFocus:!0,onClick:(e,{mapProvider:t,appConfig:n})=>t.zoomIn(n.zoomDelta),excludeWhen:({appState:e,appConfig:t})=>!t.enableZoomControls||t.enableMapControls||"touch"===e.interfaceType,enableWhen:({mapState:e})=>!e.isAtMaxZoom,mobile:yn,tablet:yn,desktop:yn},{id:"zoomOut",group:{label:"Zoom controls",slotOrder:0},label:"Zoom out",iconId:"minus",keepFocus:!0,onClick:(e,{mapProvider:t,appConfig:n})=>t.zoomOut(n.zoomDelta),excludeWhen:({appState:e,appConfig:t})=>!t.enableZoomControls||t.enableMapControls||"touch"===e.interfaceType,enableWhen:({mapState:e})=>!e.isAtMinZoom,mobile:yn,tablet:yn,desktop:yn},{id:"mapControls",label:"Map controls",iconId:"move",keepFocus:!0,isExpanded:!1,ariaControls:({appConfig:e})=>`${e.id}-map-controls-content`,onClick:(e,{appState:t})=>t.dispatch({type:"TOGGLE_BUTTON_EXPANDED",payload:{id:"mapControls",isExpanded:!t.expandedButtons.has("mapControls")}}),excludeWhen:({appConfig:e})=>!e.enableMapControls,mobile:mn,tablet:mn,desktop:mn}],panels:[{id:"keyboardHelp",label:"Keyboard shortcuts",mobile:{...gn},tablet:{...gn,width:"500px"},desktop:{...gn,width:"500px"},render:e=>(0,s.Y)(F,{context:e?.context})}],controls:[{id:"mapControls",label:"Move and zoom",excludeWhen:({appConfig:e})=>!e.enableMapControls,mobile:vn,tablet:vn,desktop:vn,render:()=>{const{id:e,mapProvider:t,panDelta:n,nudgePanDelta:r,zoomDelta:o,nudgeZoomDelta:a}=l(),{dispatch:c,expandedButtons:d,nudgeStepSize:u,interfaceType:p,layoutRefs:h}=C(),{isAtMaxZoom:f,isAtMinZoom:g}=J(),{announce:m}=ut(),y=d.has("mapControls"),v=`${e}-pan-up`;(0,i.vJ)(()=>{y&&document.getElementById(v)?.focus()},[y,v]);const b="large"===u,_=b?"Move":"Nudge",E=()=>{"keyboard"!==p&&requestAnimationFrame(()=>h.viewportRef.current?.focus())},S=(e,o,i,s=!1)=>{const a=!s&&b,l=a?"Move":"Nudge",c=t.activeMoveTarget;if(c){c.move(e,o,a);const t=c.label?`${c.label} `:"";return m(`${l}d ${t}${i}`),void E()}const d=un(a,r,n);t.panBy([e*d,o*d]),m(`${l}d ${i}`),E()},x=["im-c-map-controls",!y&&"im-c-map-controls--collapsed"].filter(Boolean).join(" "),I=(0,s.FD)("div",{role:"group","aria-label":"Direction controls",className:"im-c-map-controls__directions",children:[pn.map(({id:e,verb:t,dx:n,dy:r})=>(0,s.Y)(dn,{buttonId:e,label:`${_} ${t}`,iconId:"chevron",onClick:()=>S(n,r,t)},e)),(0,s.Y)(dn,{buttonId:"nudgeStepToggle",label:(0,s.FD)(s.FK,{children:["Precision ",(0,s.FD)("span",{"aria-hidden":"true",children:["(",b?"Off":"On",")"]})]}),iconId:b?"precision":"precision-active",isPressed:!b,onClick:()=>{c({type:"TOGGLE_NUDGE_STEP"}),m(b?"Precision on":"Precision off")}})]},"directions"),w=(0,s.Y)("div",{role:"group","aria-label":"Zoom controls",className:"im-c-map-controls__zoom",children:hn.map(({id:e,label:n,announceLabel:r,method:i})=>(0,s.Y)(dn,{buttonId:e,label:n,iconId:"zoomIn"===i?"plus":"minus",isDisabled:"zoomIn"===i?f:g,onClick:()=>((e,n)=>{const r=un(b,a,o);t[e](r),m(n),E()})(i,r)},e))},"zoom");return(0,s.FD)("div",{id:`${e}-map-controls-content`,className:x,onKeyDown:e=>{const t=pn.find(({key:t})=>t===e.key);t&&(e.preventDefault(),S(t.dx,t.dy,t.verb,e.shiftKey))},"data-map-keyboard-scope":!0,children:[I,w]})}}],icons:[{id:"maximise",svgContent:'<path d="M15 3h6v6"/><path d="m21 3-7 7"/><path d="m3 21 7-7"/><path d="M9 21H3v-6"/>'},{id:"minimise",svgContent:'<path d="m14 10 7-7"/><path d="M20 10h-6V4"/><path d="m3 21 7-7"/><path d="M4 14h6v6"/>'},{id:"plus",svgContent:'<path d="M5 12h14"/><path d="M12 5v14"/>'},{id:"minus",svgContent:'<path d="M5 12h14"/>'},{id:"chevron",svgContent:'<path d="m6 9 6 6 6-6"/>'},{id:"move",svgContent:'<path d="M11.146 15.854a1.207 1.207 0 0 1 1.708 0l1.56 1.56A2 2 0 0 1 15 18.828V21a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1v-2.172a2 2 0 0 1 .586-1.414z"/><path d="M18.828 15a2 2 0 0 1-1.414-.586l-1.56-1.56a1.207 1.207 0 0 1 0-1.708l1.56-1.56A2 2 0 0 1 18.828 9H21a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1z"/><path d="M6.586 14.414A2 2 0 0 1 5.172 15H3a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h2.172a2 2 0 0 1 1.414.586l1.56 1.56a1.207 1.207 0 0 1 0 1.708z"/><path d="M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2.172a2 2 0 0 1-.586 1.414l-1.56 1.56a1.207 1.207 0 0 1-1.708 0l-1.56-1.56A2 2 0 0 1 9 5.172z"/>'},{id:"precision",svgContent:'<circle cx="12" cy="12" r="10"/><line x1="22" x2="18" y1="12" y2="12"/><line x1="6" x2="2" y1="12" y2="12"/><line x1="12" x2="12" y1="6" y2="2"/><line x1="12" x2="12" y1="22" y2="18"/>'},{id:"precision-active",svgContent:'<circle cx="12" cy="12" r="10"/><line x1="22" x2="16" y1="12" y2="12"/><line x1="8" x2="2" y1="12" y2="12"/><line x1="12" x2="12" y1="8" y2="2"/><line x1="12" x2="12" y1="22" y2="16"/><circle cx="12" cy="12" r="1.5" fill="currentColor" stroke="none"/>'}]},xn={slot:"right-top",showLabel:!0},In={label:"Button",mobile:xn,tablet:xn,desktop:xn},wn={label:"Panel",focus:!0,mobile:{slot:"drawer",open:!0,dismissible:!0,modal:!1,showLabel:!0},tablet:{slot:"left-top",open:!0,dismissible:!0,modal:!1,showLabel:!0},desktop:{slot:"left-top",open:!0,dismissible:!0,modal:!1,showLabel:!0},render:null,html:null},Pn={label:"Control",mobile:{slot:"drawer"},tablet:{slot:"top-left"},desktop:{slot:"top-left"}},Cn=e=>Array.isArray(e)?e:[e],Tn=["mobile","tablet","desktop"];function Mn(e,t){const n=x[t];Tn.forEach(r=>{const i=e[r]?.slot;!i||n.includes(i)||"panel"===t&&i.endsWith("-button")||"control"===t&&i.endsWith("-panel")||o.l.warn(`${t} "${e.id}" has invalid slot "${i}" at breakpoint "${r}". Allowed slots: ${n.join(", ")}.`)})}function Ln({registerButton:e,registerPanel:t,registerControl:n,registerKeyboardShortcut:r}){const o=[];return{registeredPlugins:o,registerPlugin:function(i){const{manifest:s}=i,a={pluginId:i.id};s.buttons&&Cn(s.buttons).forEach(t=>{Mn(t,"button"),e({[t.id]:{...a,...t}}),t?.menuItems?.forEach(t=>{e({[t.id]:{...a,...t,isMenuItem:!0}})})}),s.panels&&Cn(s.panels).forEach(e=>{Mn(e,"panel"),t({[e.id]:{...a,...e}})}),s.controls&&Cn(s.controls).forEach(e=>{Mn(e,"control"),n({[e.id]:{...a,...e}})}),s.icons&&Cn(s.icons).forEach(e=>(e=>{G={...G,...e}})({[e.id]:e.svgContent})),s.keyboardShortcuts&&Cn(s.keyboardShortcuts).forEach(e=>r({...a,shortcut:e})),o.push(i)},getPlugin:function(e){return o.find(t=>t.id===e)?._originalPlugin},clear:function(){o.length=0}}}const An=()=>"undefined"!=typeof navigator&&/mac/i.test(navigator.userAgentData?.platform||navigator.platform||""),On=An()?"<kbd>Option</kbd>":"<kbd>Alt</kbd>",kn=[{id:"showKeyboardHelp",title:"Show keyboard help",command:"<kbd>Shift</kbd> + <kbd>?</kbd>",context:"global",enabled:!0},{id:"getInfo",title:"Get current location and visible area",command:(An()?"<kbd>Option</kbd>":"<kbd>Ctrl</kbd>")+" + <kbd>I</kbd>",enabled:!0,visuallyHidden:!0,mapProviderAgnostic:!0,requiredConfig:["reverseGeocodeProvider"]},{id:"moveLarge",title:"Move in large steps",command:"<kbd>←</kbd>, <kbd>↑</kbd>, <kbd>→</kbd> or <kbd>↓</kbd>",enabled:!0},{id:"nudgeMap",title:"Nudge map",command:"<kbd>Shift</kbd> + <kbd>←</kbd>, <kbd>↑</kbd>, <kbd>→</kbd> or <kbd>↓</kbd>",enabled:!1},{id:"zoomLarge",title:"Zoom in large steps",command:"<kbd>+</kbd> or <kbd>-</kbd>",enabled:!0},{id:"nudgeZoom",title:"Nudge zoom",command:"<kbd>Shift</kbd> + <kbd>+</kbd> or <kbd>-</kbd>",enabled:!1},{id:"highlightLabelAtCenter",title:"Highlight label at centre",command:`${On} + <kbd>Enter</kbd>`,enabled:!1,requiredConfig:["readMapText"]},{id:"highlightNextLabel",title:"Highlight nearby label",command:`${On} + <kbd>→</kbd>, <kbd>←</kbd>, <kbd>↑</kbd> or <kbd>↓</kbd>`,enabled:!1,requiredConfig:["readMapText"]}];function Dn(e={},t={}){const n=(e=[],t=[])=>{Array.isArray(e)||(e=[]),Array.isArray(t)||(t=[]);const n=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>{e?.id&&(n.has(e.id)?n.set(e.id,{...n.get(e.id),...e}):n.set(e.id,e))}),Array.from(n.values())},r={...e,...t};return(e.buttons||t.buttons)&&(r.buttons=n(e.buttons,t.buttons)),(e.panels||t.panels)&&(r.panels=n(e.panels,t.panels)),(e.controls||t.controls)&&(r.controls=n(e.controls,t.controls)),(e.icons||t.icons)&&(r.icons=n(e.icons,t.icons)),r}const Rn=({plugin:e})=>{const t=function(e){const t=(0,i.li)(null),n=l(),r=C(),o=J(),s=ut(),a=ft(e);return(0,i.vJ)(()=>{t.current={appConfig:n,appState:r,mapState:o,services:s,mapProvider:n.mapProvider,pluginState:a}}),t}(e.id);(0,i.vJ)(()=>{e.api&&e._originalPlugin&&Object.entries(e.api).forEach(([n,r])=>{e._originalPlugin[n]=function(e,{pluginId:t,pluginConfig:n,stateRef:r}){return(...o)=>{const i=r.current;if(!i)throw new Error(`Plugin API "${t}" called before state is initialized`);return e({...i,pluginConfig:n,pluginId:t},...o)}}(r,{pluginId:e.id,pluginConfig:e?.config||{},stateRef:t})})},[e,t]);const{InitComponent:n}=e,r=(0,i.Kr)(()=>{const{api:t,...n}=e?.config||{};return n},[e]);if(!n)return null;const o=mt(n);return(0,s.Y)(o,{pluginId:e.id,pluginConfig:r})},Nn=()=>{const{pluginRegistry:e}=l();(()=>{const{dispatch:e,hiddenButtons:t,disabledButtons:n,pressedButtons:r,expandedButtons:s}=C(),{eventBus:a}=ut(),l=(0,i.li)(e),c=(0,i.li)({hiddenButtons:t,disabledButtons:n,pressedButtons:r,expandedButtons:s});l.current=e,c.current={hiddenButtons:t,disabledButtons:n,pressedButtons:r,expandedButtons:s},(0,i.vJ)(()=>{const e=((e,t)=>[[o.E.APP_OPENED,()=>e.current({type:"TOGGLE_APP_VISIBLE",payload:!0})],[o.E.APP_CLOSED,()=>e.current({type:"TOGGLE_APP_VISIBLE",payload:!1})],[o.E.APP_ADD_BUTTON,({id:t,config:n})=>{e.current({type:"ADD_BUTTON",payload:{id:t,config:n}}),Array.isArray(n.menuItems)&&n.menuItems.forEach(t=>{e.current({type:"ADD_BUTTON",payload:{id:t.id,config:{...t,isMenuItem:!0}}})})}],[o.E.APP_TOGGLE_BUTTON_STATE,({id:n,prop:r,value:o})=>{const{hiddenButtons:i,disabledButtons:s,pressedButtons:a,expandedButtons:l}=t.current;switch(r){case"hidden":{const t="boolean"==typeof o?o:!i.has(n);e.current({type:"TOGGLE_BUTTON_HIDDEN",payload:{id:n,isHidden:t}});break}case"disabled":{const t="boolean"==typeof o?o:!s.has(n);e.current({type:"TOGGLE_BUTTON_DISABLED",payload:{id:n,isDisabled:t}});break}case"pressed":{const t="boolean"==typeof o?o:!a.has(n);e.current({type:"TOGGLE_BUTTON_PRESSED",payload:{id:n,isPressed:t}});break}case"expanded":{const t="boolean"==typeof o?o:!l.has(n);e.current({type:"TOGGLE_BUTTON_EXPANDED",payload:{id:n,isExpanded:t}});break}}}],[o.E.APP_ADD_PANEL,({id:t,config:n})=>e.current({type:"ADD_PANEL",payload:{id:t,config:n}})],[o.E.APP_REMOVE_PANEL,t=>e.current({type:"REMOVE_PANEL",payload:t})],[o.E.APP_SHOW_PANEL,({id:t,focus:n=!0,triggeringElement:r})=>e.current({type:"OPEN_PANEL",payload:{panelId:t,focusOnOpen:n,props:r?{triggeringElement:r}:void 0}})],[o.E.APP_HIDE_PANEL,t=>e.current({type:"CLOSE_PANEL",payload:t})],[o.E.APP_ADD_CONTROL,({id:t,config:n})=>e.current({type:"ADD_CONTROL",payload:{id:t,config:n}})],[o.E.APP_SET_APPLICATION_MODE,({id:t,include:n,exclude:r})=>e.current({type:"SET_APPLICATION_MODE",payload:{id:t,include:n,exclude:r}})],[o.E.APP_CLEAR_APPLICATION_MODE,t=>e.current({type:"CLEAR_APPLICATION_MODE",payload:t})]])(l,c);return e.forEach(([e,t])=>a.on(e,t)),()=>{e.forEach(([e,t])=>a.off(e,t))}},[a])})(),(()=>{const{eventBus:e,hints:t}=ut(),{layoutRefs:n}=C(),r=(0,i.li)(!1);(0,i.vJ)(()=>{const n=({text:e,options:n}={})=>{e&&t.show(e,n)},r=()=>t.dismiss();return e.on(o.E.APP_SHOW_HINT,n),e.on(o.E.APP_DISMISS_HINT,r),()=>{e.off(o.E.APP_SHOW_HINT,n),e.off(o.E.APP_DISMISS_HINT,r)}},[e,t]),(0,i.vJ)(()=>t.subscribe(e=>{r.current=Boolean(e)}),[t]),(0,i.vJ)(()=>{const e=e=>{if("Escape"!==e.key||!r.current)return;const o=n.appContainerRef?.current;o&&!o.contains(e.target)||t.dismiss()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,n])})();const t=Yt();return function(e){const t=C(),{pluginRegistry:n}=l(),r=(0,i.NT)(pt);(0,i.Nf)(()=>{if(!t?.dispatch||!r)return;const{dispatch:o}=t;let i=0;const s=e=>{i++,o(e)};n.registeredPlugins.forEach(n=>{(n?.manifest?.buttons??[]).flatMap(e=>[e,...e.menuItems??[]]).forEach(r=>function({btn:e,pluginId:t,appState:n,dispatch:r,evaluateProp:o}){[{prop:"enableWhen",state:n.disabledButtons,action:"TOGGLE_BUTTON_DISABLED",invert:!0,key:"isDisabled"},{prop:"hiddenWhen",state:n.hiddenButtons,action:"TOGGLE_BUTTON_HIDDEN",key:"isHidden"},{prop:"pressedWhen",state:n.pressedButtons,action:"TOGGLE_BUTTON_PRESSED",key:"isPressed"},{prop:"expandedWhen",state:n.expandedButtons,action:"TOGGLE_BUTTON_EXPANDED",key:"isExpanded"}].forEach(({prop:n,state:i,action:s,key:a,invert:l})=>{if("function"==typeof e[n])try{const c=o(e[n],t),d=l?!c:c;i.has(e.id)!==d&&r({type:s,payload:{id:e.id,[a]:d}})}catch(t){console.warn(`${n} error for button ${e.id}:`,t)}})}({btn:r,pluginId:n.id,appState:t,dispatch:s,evaluateProp:e}))}),0!==i||t.arePluginsEvaluated||o({type:"PLUGINS_EVALUATED"})},[t,r,e])}(t),function(){const e=l()?.backAndContinue,{dispatch:t}=C(),n=J(),r=(0,i.NT)(pt),o=(0,i.li)(!0);(0,i.Nf)(()=>{if("function"!=typeof e?.continueEnabledWhen)return;let i=!1;try{i=e.continueEnabledWhen({pluginStates:r?.state??{},mapState:n})}catch(e){console.warn("continueEnabledWhen error:",e)}const s=!i;o.current!==s&&(o.current=s,t({type:"TOGGLE_BUTTON_DISABLED",payload:{id:"journeyContinue",isDisabled:s}}))},[e,r,n,t])}(),(0,s.Y)(s.FK,{children:e.registeredPlugins.map((e,n)=>(0,s.Y)(Rn,{plugin:e,evaluateProp:t},`init-${e.id}-${n}`))})},Fn=(e,t,n)=>{const r=(e,t)=>e[0]===t[0]&&e[1]===t[1],o=t.filter(t=>{const o=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);let s=!1;return s="ArrowUp"===n?t[1]<=e[1]&&i>=o:"ArrowDown"===n?t[1]>e[1]&&i>=o:"ArrowLeft"===n?t[0]<=e[0]&&i<o:"ArrowRight"!==n||t[0]>e[0]&&i<o,s&&!r(t,e)});o.length||o.push(e);const i=t=>Math.hypot(e[0]-t[0],e[1]-t[1]),s=o.reduce((e,t)=>i(t)<i(e)?t:e,o[0]);return t.findIndex(e=>r(e,s))},Vn=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"]),Bn=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Un=(e,t)=>{if(!t)return null;const n=e.filter(e=>null!=e.x&&null!=e.y);if(!n.length)return null;const r=n.map(e=>[e.x,e.y]);return n[Fn([t.x,t.y],r,void 0)].id},Gn=(e,t,n,r)=>{const o=e.find(e=>n.includes(e.id));return o?o.id:t&&e.some(e=>e.id===t)?t:Un(e,r)??e[0].id},jn=(e,t,n)=>{const r=Array.from(e?.children??[]).find(e=>e.dataset.id===String(t));r&&(n.current=!0,r.focus({preventScroll:!0}),n.current=!1)};const Hn="map:setspatiallist",$n="map:setspatiallistsuppressed",Yn=e=>{if(!e?.current)return{offsetWidth:0,offsetHeight:0};const t=e.current.firstElementChild;return t?.classList.contains("im-c-panel")&&0!==t.offsetWidth&&0!==t.offsetHeight?{offsetWidth:t.offsetWidth,offsetHeight:t.offsetHeight}:{offsetWidth:0,offsetHeight:0}},zn=e=>{const t=e?.current?.querySelector(".im-c-button-group");return t?t.offsetWidth:0},Kn=(e,t,n,r,o)=>e.offsetHeight+t.offsetHeight+(e.offsetHeight>0&&t.offsetHeight>0?o:0)>n?r+Math.max(e.offsetWidth,t.offsetWidth)+o:0,Wn=(e,t,n,r,o)=>e.offsetWidth+t.offsetWidth+(e.offsetWidth>0&&t.offsetWidth>0?o:0)>n?r+Math.max(e.offsetHeight,t.offsetHeight)+o:0,Jn=({mainRef:e,leftRef:t,rightRef:n,actionsRef:r,bottomRef:o,leftTopRef:i,leftBottomRef:s,rightTopRef:a,rightBottomRef:l})=>{if([e,t,n,r,o].some(e=>!e?.current))return;const c=e.current,d=t.current,u=r.current,p=o.current,h=Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue("--divider-gap"),10),f=Yn(i),g=Yn(s),m=Yn(a),y=Yn(l),v=Math.max(zn(t),zn(n)),b=c.offsetLeft+d.offsetLeft+v+h,_=d.offsetLeft+v+h,E=d.offsetTop,S=c.offsetHeight-p.offsetTop-p.offsetHeight,x=Math.max(S,c.offsetHeight-p.offsetTop+h),I=Math.max(c.offsetHeight-u.offsetTop+h,x),w=c.offsetHeight-E-I,P=c.offsetWidth-(b-c.offsetLeft)-_,C=Kn(f,g,w/2,c.offsetLeft+d.offsetLeft,h),T=Kn(m,y,w/2,d.offsetLeft,h),M=Wn(f,m,P/2,E,h),L=Wn(g,y,P/2,x,h),A=c.offsetWidth-2*h,O=c.offsetHeight-2*h,k=c.offsetLeft+2*A/3,D=2*A/3,R=2*O/3;return{left:Math.max(b,Math.min(C,k)),right:Math.max(_,Math.min(T,D)),top:Math.max(E,Math.min(M,R)),bottom:Math.max(I,Math.min(L,R))}},qn=".im-c-panel--banner",Xn=e=>e?.current?.offsetHeight??0,Zn=e=>e?.current?.offsetWidth??0,Qn=e=>!e.hidden&&(e.getClientRects().length>0||e.classList.contains("im-c-control-wrapper")&&Array.from(e.children).some(Qn)),er=e=>{const t=Array.from(e.children);return t.length>0&&!t.some(Qn)?0:e.offsetHeight},tr=(e,t,n)=>e-(t?t+n:0);function nr(e,t){const{appContainerRef:n,mainRef:r,topRef:o,topLeftColRef:i,topRightColRef:s,bottomRef:a,attributionsRef:l,bottomRightRef:c,leftTopRef:d,leftBottomRef:u,rightTopRef:p,rightBottomRef:h,actionsRef:f,bannerRef:g,leftRef:m,rightRef:y}=e,v=n.current,b=r.current,_=o.current,E=i.current,S=s.current,x=a.current,I=l.current;if([b,_,x].some(e=>!e))return;const w=document.documentElement,P=Number.parseInt(getComputedStyle(w).getPropertyValue("--divider-gap"),10),C=Number.parseInt(getComputedStyle(w).getPropertyValue("--primary-gap"),10),T="mobile"===t,{isBannerStacked:M,bannerTop:L,bannerHeight:A}=function({appContainer:e,root:t,top:n,bannerRef:r,leftRef:o,rightRef:i,isMobile:s,dividerGap:a,primaryGap:l}){const c=r?.current;var d;s&&(d=c,d?.querySelectorAll(qn).forEach(e=>{e.style.width=""}));const u=Xn(r),p=u>0,h=(f=Zn(o),g=Zn(i),f||g?Math.max(f,g):0);var f,g;const m=Number.parseInt(getComputedStyle(t).getPropertyValue("--banner-preferred-width"),10),y=(e=>{const t=Array.from(e?.querySelectorAll(qn)??[]).map(e=>Number.parseInt(e.style.width,10)).filter(e=>!Number.isNaN(e));return t.length?Math.max(...t):null})(c)??m;e.style.setProperty("--banner-preferred-width",`${y}px`);const v=n.offsetWidth-2*h-2*a,b=!s&&((e,t)=>e>=t)(v,y);c?.classList.toggle("im-o-app__banner--docked",b);const _=`${((e,t,n,r)=>e?t+n+r:t)(b,l,h,a)}px`;e.style.setProperty("--banner-left",_),e.style.setProperty("--banner-right",_);const E=p&&!b,S=p?n.offsetTop+n.offsetHeight:0;return e.style.setProperty("--banner-top",`${S}px`),{isBannerStacked:E,bannerTop:S,bannerHeight:u}}({appContainer:v,root:w,top:_,bannerRef:g,leftRef:m,rightRef:y,isMobile:T,dividerGap:P,primaryGap:C}),O=e=>M?L+A+P:e+_.offsetTop,{rise:k}=function({appContainer:e,bottom:t,attributions:n,dividerGap:r,primaryGap:o}){const i=t.children[1],s=(e=>{const t=e?.firstElementChild;if(!t)return 0;const n=t.style.whiteSpace;t.style.whiteSpace="nowrap";const r=t.scrollWidth;return t.style.whiteSpace=n,r})(n)>(i?.offsetWidth??0);n.classList.toggle("im-o-app__attributions--stacked",s);const a=i?Math.round(i.getBoundingClientRect().left-t.getBoundingClientRect().left):0;e.style.setProperty("--attributions-left",`${a}px`);const l=((e,t,n)=>Math.max(0,e+t-n))(n.offsetHeight,r,o);return e.style.setProperty("--bottom-right-clearance",`${((e,t)=>e?0:t)(s,l)}px`),{rise:l}}({appContainer:v,bottom:x,attributions:I,dividerGap:P,primaryGap:C}),D=O(er(E)),R=x.offsetTop-D-P;v.style.setProperty("--left-offset-top",`${D}px`),v.style.setProperty("--left-offset-bottom",`${b.offsetHeight-x.offsetTop+P}px`),v.style.setProperty("--left-top-max-height",`${R}px`);const N=Xn(c),F=b.offsetHeight-x.offsetTop-x.offsetHeight,V=O(er(S)),B=x.offsetTop+x.offsetHeight-N-k-V-P;v.style.setProperty("--right-offset-top",`${V}px`),v.style.setProperty("--right-offset-bottom",`${((e,t,n,r,o)=>e+(t>0?t+r+o:n))(F,N,I.offsetHeight,k,P)}px`),v.style.setProperty("--right-top-max-height",`${B}px`),v.style.setProperty("--hint-bottom",`${((e,t,n,r)=>{const o=e.offsetHeight-t.offsetTop+r,i=(n?.offsetHeight??0)>0?e.offsetHeight-n.offsetTop:0;return Math.max(o,i+r)})(b,x,f?.current,P)}px`),v.style.setProperty("--left-top-panel-max-height",`${tr(R,Xn(u),P)}px`),v.style.setProperty("--left-bottom-panel-max-height",`${tr(R,Xn(d),P)}px`),v.style.setProperty("--right-top-panel-max-height",`${tr(B,Xn(h),P)}px`),v.style.setProperty("--right-bottom-panel-max-height",`${tr(B,Xn(p),P)}px`)}const rr=(e,t)=>Object.entries(e).reduce((e,[n,r])=>(e[n]=Math.round(r/t),e),{}),or=e=>"Feature"===e.type?or(e.geometry):"Point"===e.type?e.coordinates:"MultiPoint"===e.type?e.coordinates[0]:null,ir=({mapContainerRef:e})=>{const t=l(),{id:n,mapProvider:r}=t,{safeZoneInset:s,breakpoint:a,isLayoutReady:c,syncMapPadding:d}=C(),{isMapReady:u,mapStyle:p,mapSize:h,center:f,zoom:g,bounds:m}=J(),y=(0,i.li)(!1),v=(({id:e,center:t,zoom:n,bounds:r,urlPosition:o="sync"},i=window.location.search)=>{const s="none"===o?null:((e,t)=>{const n=new URLSearchParams(t),r=n.get(`${e}:center`),o=n.get(`${e}:zoom`);if(!r||!o)return null;const[i,s]=r.split(",").map(Number);return{center:[i,s],zoom:Number(o)}})(e,i);return s?{center:s.center,zoom:s.zoom}:r?{bounds:r}:{center:t,zoom:n}})({id:n,center:f,zoom:g,bounds:m,urlPosition:t.urlPosition});return(0,i.vJ)(()=>{if(s&&c&&p&&h&&!y.current)return requestAnimationFrame(()=>{r.initMap({...t,pixelRatio:window.devicePixelRatio*fn[h],container:e.current,padding:s,center:v.center,zoom:v.zoom,bounds:v.bounds,mapStyle:p,mapSize:h})}),y.current=!0,()=>{}},[s,c,p,h]),function(){const{mapProvider:e}=l(),{dispatch:t}=J(),{eventBus:n}=ut(),r=(0,i.li)(null),s=(0,i.li)(!1);(0,i.vJ)(()=>{if(!e)return;const i=e=>{t({type:"MAP_MOVE",payload:e})},a=e=>{t({type:"MAP_MOVE_END",payload:e}),n.emit(o.E.MAP_STATE_UPDATED,{previous:r.current,current:e}),r.current=e},l=n=>{s.current||(r.current={center:e.getCenter(),zoom:e.getZoom()},s.current=!0),t({type:"MAP_FIRST_IDLE",payload:n})};return n.on(o.E.MAP_MOVE,i),n.on(o.E.MAP_MOVE_END,a),n.on(o.E.MAP_FIRST_IDLE,l),()=>{n.off(o.E.MAP_MOVE,i),n.off(o.E.MAP_MOVE_END,a),n.off(o.E.MAP_FIRST_IDLE,l)}},[e,t])}(),function(){const{id:e,urlPosition:t}=l(),{eventBus:n}=ut();(0,i.vJ)(()=>{if(!e||"sync"!==t)return;const r=({current:t})=>{((e,t,n=window.location.href)=>{const r=new URL(n||"http://localhost"),o=new Set,i=[];if(t.center){const n=`${e}:center`;o.add(n),i.push(`${n}=${t.center[0]},${t.center[1]}`)}if(null!=t.zoom){const n=`${e}:zoom`;o.add(n),i.push(`${n}=${t.zoom}`)}const s=[];r.searchParams.forEach((e,t)=>{o.has(t)||s.push(`${t}=${e}`)});const a=[...s,...i].join("&"),l=a?"?"+a:"",c=`${r.origin}${r.pathname}${l}${r.hash}`;window.history.replaceState(window.history.state,"",c)})(e,{center:t.center,zoom:t.zoom})};return n.on(o.E.MAP_STATE_UPDATED,r),()=>n.off(o.E.MAP_STATE_UPDATED,r)},[e,t])}(),function(){const{mapProvider:e}=l(),{eventBus:t,announce:n,mapFocus:r}=ut();(0,i.vJ)(()=>{const i=({previous:t,current:o})=>{if(!t?.center||!o?.center)return;if(r.isHoldingAnnouncements())return;const i=((e,t,n)=>{const r=e.zoom!==t.zoom,o=e.center[0]!==t.center[0]||e.center[1]!==t.center[1],i=n.getAreaDimensions();return o&&!r?(({direction:e})=>`Map moved ${e}.`)({direction:n.getCardinalMove(e.center,t.center),areaDimensions:i}):!o&&r?(({from:e,to:t,areaDimensions:n,isAtMaxZoom:r,isAtMinZoom:o})=>`Map zoomed ${t>e?"in":"out"}${r?" (Maximum zoom)":""}${o?" (Minimum zoom)":""}. New area approximately ${n}.`)({...t,from:e.zoom,to:t.zoom,areaDimensions:i}):o||r?(({areaDimensions:e,isAtMaxZoom:t,isAtMinZoom:n})=>`New area approximately ${e}${t?" (Maximum zoom)":""}${n?" (Minimum zoom)":""}.`)({...t,areaDimensions:i}):(({isAtMaxZoom:e,isAtMinZoom:t})=>`No change, ${e?"maximum zoom reached":""}${t?"minimum zoom reached":""}.`)({...t})})(t,o,e);i&&n(i,"action")};return t.on(o.E.MAP_STATE_UPDATED,i),()=>{t.off(o.E.MAP_STATE_UPDATED,i)}},[e,n,r])}(),(()=>{const{mapProvider:e,eventBus:t}=l(),{dispatch:n,layoutRefs:r,breakpoint:s}=C(),{mapSize:a}=J(),c=(0,i.li)(a);c.current=a;const d=(0,i.li)(s);d.current=s;const u=()=>{nr(r,d.current);const t=Jn(r),o=rr(t,fn[c.current]);"function"==typeof n&&n({type:"SET_SAFE_ZONE_INSET",payload:{safeZoneInset:t,syncMapPadding:!1}}),"function"==typeof e.setPadding&&e.setPadding(o)};(0,i.vJ)(()=>{if(!e)return;const t=e.fitToBounds;e.fitToBounds=(n,r=!1)=>{if(n)return r?t.call(e,n):void requestAnimationFrame(()=>{u(),t.call(e,n)})};const n=e.setView;return e.setView=({center:t,zoom:r})=>{t&&requestAnimationFrame(()=>{u(),n.call(e,{center:t,zoom:r})})},()=>{e.fitToBounds=t,e.setView=n}},[e,n,r,a]),(0,i.vJ)(()=>{if(!e||!t)return;const n=t=>e.fitToBounds(t),r=t=>e.setView(t);return t.on(o.E.MAP_FIT_TO_BOUNDS,n),t.on(o.E.MAP_SET_VIEW,r),()=>{t.off(o.E.MAP_FIT_TO_BOUNDS,n),t.off(o.E.MAP_SET_VIEW,r)}},[e,t])})(),(()=>{const{id:e,mapProvider:t,eventBus:n}=l(),{layoutRefs:r,panelConfig:s,panelRegistry:a,breakpoint:c}=C(),d=(0,i.li)({layoutRefs:r,panelConfig:s,panelRegistry:a,breakpoint:c});d.current={layoutRefs:r,panelConfig:s,panelRegistry:a,breakpoint:c},(0,i.vJ)(()=>{if(!t||!n)return;const i=({panelId:n,visibleGeometry:o})=>{const{panelConfig:i,panelRegistry:s}=d.current,a=i?.[n]?i:s?.getPanelConfig()??i,l=o??a?.[n]?.visibleGeometry,c=r.appContainerRef.current?.querySelector(`#${e}-panel-${n}`);if(!l)return;if("function"!=typeof t.isGeometryObscured)return;const u=()=>{if(!c)return;const e=c.getBoundingClientRect();if(e&&0!==e.width&&0!==e.height){if(t.isGeometryObscured(l,e))if((e=>{const t=(e=>e?"Feature"===e.type?e.geometry?.type:e.type:null)(e);return"Point"===t||"MultiPoint"===t})(l)){const e=or(l);e&&t.setView({center:e})}else t.fitToBounds(l)}else requestAnimationFrame(u)};requestAnimationFrame(u)};return n.on(o.E.APP_PANEL_OPENED,i),()=>{n.off(o.E.APP_PANEL_OPENED,i)}},[t,n])})(),(0,i.vJ)(()=>{u&&d&&r.setPadding(rr(s,fn[h]))},[u,h,a,s]),null},sr=An()?"Alt":"Ctrl",ar={keydown:{ArrowUp:"panUp",ArrowDown:"panDown",ArrowLeft:"panLeft",ArrowRight:"panRight","+":"zoomIn","=":"zoomIn","-":"zoomOut",_:"zoomOut"},keyup:{"?":"showKeyboardControls","Alt+ArrowRight":"highlightNextLabel","Alt+ArrowLeft":"highlightNextLabel","Alt+ArrowUp":"highlightNextLabel","Alt+ArrowDown":"highlightNextLabel","Alt+Enter":"highlightLabelAtCenter",[`${sr}+i`]:"getInfo",[`${sr}+I`]:"getInfo",Escape:"clearSelection"}},lr=e=>{let t;return t=/^Key[A-Z]$/.test(e.code)?e.code.slice(3):e.key,"Add"===t||"NumpadAdd"===t?t="+":"Subtract"!==t&&"NumpadSubtract"!==t||(t="-"),e.altKey?`Alt+${t}`:e.ctrlKey?`Ctrl+${t}`:t},cr=(e,t,n)=>{const r=ar[t][n];return r&&e[r]?r:null},dr=()=>{const{mapStatusRef:e}=ut();return(0,s.Y)("div",{ref:e,role:"status",className:"im-u-visually-hidden"})},ur={active:"M5.035 20H1v-2h4.035C5.525 11.069 11.069 5.525 18 5.035V1h2v4.035c6.931.49 12.475 6.034 12.965 12.965H37v2h-4.035c-.49 6.931-6.034 12.475-12.965 12.965V37h-2v-4.035C11.069 32.475 5.525 26.931 5.035 20zM19 7c-6.581.005-11.995 5.419-12 12 .005 6.581 5.419 11.995 12 12 6.581-.005 11.995-5.419 12-12-.005-6.581-5.419-11.995-12-12zm0 10a2.01 2.01 0 0 1 2 2 2.01 2.01 0 0 1-2 2 2.01 2.01 0 0 1-2-2 2.01 2.01 0 0 1 2-2z",inactive:"M5.035 20H1v-2h4.035a13.98 13.98 0 0 1 .246-1.8l1.96.399C7.083 17.375 7 18.178 7 19s.083 1.625.241 2.401l-1.96.399a13.98 13.98 0 0 1-.246-1.8zM20 5.035a13.98 13.98 0 0 1 1.8.246l-.399 1.96C20.625 7.083 19.822 7 19 7s-1.625.083-2.401.241l-.399-1.96a13.98 13.98 0 0 1 1.8-.246V1h2v4.035zm-2 27.93a13.98 13.98 0 0 1-1.8-.246l.399-1.96c.776.158 1.579.241 2.401.241s1.625-.083 2.401-.241l.399 1.96a13.98 13.98 0 0 1-1.8.246V37h-2v-4.035zM32.965 20a13.98 13.98 0 0 1-.246 1.8l-1.96-.399c.158-.776.241-1.579.241-2.401s-.083-1.625-.241-2.401l1.96-.399a13.98 13.98 0 0 1 .246 1.8H37v2h-4.035zM19 17a2.01 2.01 0 0 1 2 2 2.01 2.01 0 0 1-2 2 2.01 2.01 0 0 1-2-2 2.01 2.01 0 0 1 2-2zm3.8-9.385l.634-1.897c1.789.598 3.438 1.553 4.848 2.805l-1.327 1.496c-1.196-1.06-2.605-1.886-4.155-2.404zm5.181 3.43l1.496-1.327c1.252 1.41 2.207 3.059 2.805 4.848l-1.897.634c-.518-1.55-1.344-2.959-2.404-4.155zM30.385 22.8l1.897.634c-.598 1.789-1.553 3.438-2.805 4.848l-1.496-1.327c1.06-1.196 1.886-2.605 2.404-4.155zm-3.43 5.181l1.327 1.496c-1.41 1.252-3.059 2.207-4.848 2.805l-.634-1.897c1.55-.518 2.959-1.344 4.155-2.404zM15.2 30.385l-.634 1.897c-1.789-.598-3.438-1.553-4.848-2.805l1.327-1.496c1.196 1.06 2.605 1.886 4.155 2.404zm-5.181-3.43l-1.496 1.327c-1.252-1.41-2.207-3.059-2.805-4.848l1.897-.634c.518 1.55 1.344 2.959 2.404 4.155zM7.615 15.2l-1.897-.634c.598-1.789 1.553-3.438 2.805-4.848l1.496 1.327c-1.06 1.196-1.886 2.605-2.404 4.155zm3.43-5.181L9.718 8.523c1.41-1.252 3.059-2.207 4.848-2.805l.634 1.897c-1.55.518-2.959 1.344-4.155 2.404z"},pr=()=>{const{id:e}=l(),{crossHairRef:t,crossHair:n}=(()=>{const{mapProvider:e}=l(),{safeZoneInset:t,expandedButtons:n}=C(),{eventBus:r}=ut(),{crossHair:s,dispatch:a,mapSize:c}=J(),d=(e,n,r)=>{if(!t)return;const o=n*fn[c],i=r*fn[c];e.style.transform=`translate(${o-t.left}px, ${i-t.top}px)`,e.style.left="0",e.style.top="0",e.style.display="block"},u=(0,i.hb)(t=>{if(!t)return;((e,t,n,r,o)=>{e.pinToMap=(i,s)=>{const{x:a,y:l}=n.mapToScreen(i);e.coords=i,r({type:"UPDATE_CROSS_HAIR",payload:{isPinnedToMap:!0,isVisible:!0,coords:i,state:s}}),o(t,a,l)},e.fixAtCenter=()=>{t.style.left="50%",t.style.top="50%",t.style.transform="translate(0,0)",t.style.display="block",r({type:"UPDATE_CROSS_HAIR",payload:{isPinnedToMap:!1,isVisible:!0}})},e.remove=()=>{t.style.display="none",r({type:"UPDATE_CROSS_HAIR",payload:{isPinnedToMap:!1,isVisible:!1}})},e.show=()=>{t.style.display="block",r({type:"UPDATE_CROSS_HAIR",payload:{isVisible:!0}})},e.hide=()=>{e.isMapControlsOpen||(t.style.display="none",r({type:"UPDATE_CROSS_HAIR",payload:{isVisible:!1}}))},e.setStyle=e=>{r({type:"UPDATE_CROSS_HAIR",payload:{state:e}})},e.getDetail=()=>{const t=e.isPinnedToMap?e.coords:n.getCenter();return{state:e.state,point:n.mapToScreen(t),zoom:n.getZoom(),coords:t}}})(s,t,e,a,d);const n=()=>{if(s.coords&&s.isPinnedToMap){const{x:n,y:r}=e.mapToScreen(s.coords);d(t,n,r)}};return r.on(o.E.MAP_RENDER,n),()=>{r.off(o.E.MAP_RENDER,n)}},[s,e,c,a,t]);return(0,i.vJ)(()=>{s.coords&&s.isPinnedToMap&&s.pinToMap(s.coords,s.state)},[c]),s.isMapControlsOpen=n?.has("mapControls"),{crossHair:s,crossHairRef:u}})(),{isVisible:r,isPinnedToMap:a,state:c}=n;return(0,s.Y)("button",{tabIndex:"-1",ref:t,id:`${e}-cross-hair`,className:"im-c-cross-hair-button","aria-label":"Target",onMouseDown:e=>e.preventDefault(),onClick:()=>n.activate?.(),style:{position:"absolute",left:a?0:"50%",top:a?0:"50%",display:r?"block":"none"},children:(0,s.Y)("svg",{width:"38",height:"38",viewBox:"0 0 38 38",fillRule:"evenodd",fill:"currentColor","aria-hidden":"true",children:(0,s.Y)("path",{d:ur[c||"active"]})})})},hr=(0,i.Rf)(({activeItemId:e,tabbableId:t,selectedIds:n=[],multiselectable:r=!1,items:o=[],label:i="Map features",focusable:a=!0,onFocus:c,onBlur:d,onSelectItem:u},p)=>{const{id:h}=l(),f=o.length>0,g=e??t;return(0,s.Y)("ul",{id:`${h}-spatial-list`,ref:p,role:"listbox","aria-hidden":!f||void 0,"aria-label":i,"aria-describedby":`${h}-keyboard-desc`,"aria-multiselectable":r||void 0,className:"im-c-spatial-list",onFocus:c,onBlur:d,children:o.map(e=>(0,s.Y)("li",{id:`${h}-spatial-list-item-${e.id}`,role:"option","data-id":e.id,tabIndex:a&&e.id===g?0:-1,"aria-selected":n.includes(e.id),style:null!=e.x?{left:e.x,top:e.y}:void 0,onClick:()=>u?.(e.id),children:e.label},e.id))})});hr.displayName="SpatialList";const fr=(e,t,n,r)=>{if(!t||!r)return{x:0,y:0};const{x:o,y:i}=t.mapToScreen(e);return{x:o*fn[n],y:i*fn[n]}},gr=(e,t,n,r,o)=>{e.forEach(e=>{const i=t.get(e.id);if(!i||!e.coords)return;const{x:s,y:a}=fr(e.coords,n,r,o);i.style.transform=`translate(${s}px, ${a}px)`,i.style.display="block"})},mr=({marker:e,mapId:t,markerRef:n})=>(0,s.Y)("div",{ref:n(e.id),id:`${t}-marker-${e.id}`,className:"im-c-marker-wrapper im-c-marker-wrapper--label",style:{display:e.isVisible?"block":"none"},children:(0,s.Y)("div",{role:"note",className:"im-c-marker__label im-c-marker__label--standalone",children:e.label})}),yr=({marker:e,mapId:t,markerRef:n,isSelected:r,symbolProps:o})=>{const{resolvedSvg:i,viewBox:a,anchor:l,shapeId:c,scaledWidth:d,scaledHeight:u}=o;return(0,s.FD)("div",{ref:n(e.id),id:`${t}-marker-${e.id}`,className:["im-c-marker-wrapper",`im-c-marker-wrapper--${O(c)}`,r&&"im-c-marker-wrapper--selected"].filter(Boolean).join(" "),style:{display:e.isVisible?"block":"none",marginLeft:-l[0]*d+"px",marginTop:-l[1]*u+"px",width:`${d}px`,height:`${u}px`},children:[(0,s.Y)("svg",{className:["im-c-marker__svg",`im-c-marker--${O(c)}`,r&&"im-c-marker--selected"].filter(Boolean).join(" "),width:d,height:u,viewBox:a,overflow:"hidden","aria-hidden":"true",children:(0,s.Y)("g",{dangerouslySetInnerHTML:{__html:i}})}),(0,s.Y)("div",{role:"note",className:"im-c-marker__label",children:e.label})]})},vr=({marker:e,mapId:t,markerRef:n,isSelected:r,symbolProps:o})=>{const{resolvedSvg:i,viewBox:a,anchor:l,shapeId:c,scaledWidth:d,scaledHeight:u}=o;return(0,s.Y)("svg",{ref:n(e.id),id:`${t}-marker-${e.id}`,className:["im-c-marker",`im-c-marker--${O(c)}`,r&&"im-c-marker--selected"].filter(Boolean).join(" "),width:d,height:u,viewBox:a,overflow:"hidden","aria-hidden":"true",style:{display:e.isVisible?"block":"none",marginLeft:-l[0]*d+"px",marginTop:-l[1]*u+"px"},children:(0,s.Y)("g",{dangerouslySetInnerHTML:{__html:i}})})},br=new Set(["id","coords","x","y","isVisible","symbol","svgContent","size","viewBox","anchor","selectedColor","label","showLabel"]),_r=()=>{const{id:e}=l(),{mapStyle:t,mapSize:n}=J(),{markers:r,markerRef:a}=(()=>{const{mapProvider:e}=l(),{eventBus:t}=ut(),{markers:n,dispatch:r,mapSize:s,isMapReady:a}=J(),c=(0,i.li)(new Map),d=(0,i.li)(n);(0,i.Nf)(()=>{e&&(d.current=n,n.markerRefs=c.current,n.add=(t,n,o)=>{const{x:i,y:l}=fr(n,e,s,a);r({type:"UPSERT_LOCATION_MARKER",payload:{id:t,coords:n,...o,x:i,y:l,isVisible:!0}})},n.update=(t,o={})=>{const i=n.items.find(e=>e.id===t);if(!i)return;const{coords:l,...c}=o,d=l??i.coords,{x:u,y:p}=fr(d,e,s,a);r({type:"UPSERT_LOCATION_MARKER",payload:{id:t,coords:d,...c,x:u,y:p}})},n.remove=e=>{r({type:"REMOVE_LOCATION_MARKER",payload:e})},n.getMarker=e=>n.items.find(t=>t.id===e))},[e,n,r,s]);const u=(0,i.hb)(r=>i=>{if(!i)return void c.current.delete(r);c.current.set(r,i);const l=()=>{a&&e&&gr(n.items,c.current,e,s,a)};return t.on(o.E.MAP_RENDER,l),()=>{t.off(o.E.MAP_RENDER,l)}},[n,e,a,s]);return(0,i.vJ)(()=>{a&&e&&gr(n.items,c.current,e,s,a)},[s,n.items,e,a]),((e,t)=>{(0,i.vJ)(()=>{const n=(e={})=>{if(!e?.id||!e?.coords)return;const{id:n,coords:r,options:o}=e;t.current.add(n,r,o)};e.on(o.E.APP_ADD_MARKER,n);const r=(e={})=>{if(!e?.id)return;const{id:n,options:r}=e;t.current.update(n,r)};e.on(o.E.APP_UPDATE_MARKER,r);const i=e=>{e&&t.current.remove(e)};return e.on(o.E.APP_REMOVE_MARKER,i),()=>{e.off(o.E.APP_ADD_MARKER,n),e.off(o.E.APP_UPDATE_MARKER,r),e.off(o.E.APP_REMOVE_MARKER,i)}},[])})(t,d),{markers:n,markerRef:u}})(),{symbolRegistry:c,eventBus:d}=ut(),[u,p]=(0,i.J0)(!1),[h,f]=(0,i.J0)([]),[g,m]=(0,i.J0)(null),y=(0,i.li)(null);if((0,i.vJ)(()=>{const e=({active:e,interactionModes:t=[]})=>p(e&&t.includes("selectMarker")),t=({selectedMarkers:e=[]})=>f(e),n=({id:e})=>m(e);return d.on("interact:active",e),d.on("interact:selectionchange",t),d.on(o.E.MAP_SET_ACTIVE_ITEM,n),()=>{d.off("interact:active",e),d.off("interact:selectionchange",t),d.off(o.E.MAP_SET_ACTIVE_ITEM,n)}},[d]),(0,i.vJ)(()=>{y.current=document.querySelector(".im-c-viewport")},[]),((e,t,n)=>{(0,i.vJ)(()=>{if(!t)return;const r=n.current;if(!r)return;const o=t=>{const n=e.items.some(n=>{if(pe(n))return!1;const r=e.markerRefs?.get(n.id);if(!r)return!1;const{left:o,top:i,right:s,bottom:a}=r.getBoundingClientRect();return t.clientX>=o&&t.clientX<=s&&t.clientY>=i&&t.clientY<=a});r.style.cursor=n?"pointer":""};return r.addEventListener("mousemove",o),()=>{r.removeEventListener("mousemove",o),r.style.cursor=""}},[e,t,n])})(r,u,y),!t)return;const v=c.getDefaults();return(0,s.Y)(s.FK,{children:r.items.map(r=>{const o=h.includes(r.id),i=r.id===g;if(pe(r))return(0,s.Y)(mr,{marker:r,mapId:e,markerRef:a},r.id);const l=((e,t,n,r,o,i)=>{const s=n.getMarkerSymbolDef(e),a=Object.fromEntries(Object.entries(e).filter(([e])=>!br.has(e))),l=n.resolveVariant(s,a,r,i),c=s?.viewBox??te,[,,d,u]=c.split(" ").map(Number),p=s?.anchor??ee,h=e.symbol||t.symbol,f=fn[o]??1;return{resolvedSvg:l,viewBox:c,anchor:p,shapeId:h,scaledWidth:d*f,scaledHeight:u*f}})(r,v,c,t,n,((e,t)=>t?"active":e?"selected":"normal")(o,i));return r.showLabel&&r.label?(0,s.Y)(yr,{marker:r,mapId:e,markerRef:a,isSelected:o,symbolProps:l},r.id):(0,s.Y)(vr,{marker:r,mapId:e,markerRef:a,isSelected:o,symbolProps:l},r.id)})})},Er=()=>{const{id:e,mapProvider:t,mapLabel:n,keyboardHintText:r,focusOnMount:a}=l(),{layoutRefs:c,safeZoneInset:d,dispatch:u}=C(),{mapSize:p,isMapReady:h}=J(),{eventBus:f,hints:g,mapFocus:m}=ut(),y=(0,i.li)(null),v=(0,i.li)(null),{items:b,multiselectable:_,label:E,focusable:S}=function(e){const[t,n]=(0,i.J0)([]),[r,o]=(0,i.J0)(!1),[s,a]=(0,i.J0)(void 0),[l,c]=(0,i.J0)(!0),[d,u]=(0,i.J0)(!1);return(0,i.vJ)(()=>{if(!e)return;const t=({items:e=[],multiselectable:t=!1,label:r,focusable:i=!0}={})=>{n(e),o(t),a(r),c(i)},r=({suppressed:e=!1}={})=>{u(e)};return e.on(Hn,t),e.on($n,r),()=>{e.off(Hn,t),e.off($n,r)}},[e]),{items:d?[]:t,multiselectable:r,label:s,focusable:l}}(f);let x=null;if(h){const e=t.mapToScreen(t.getCenter());x={x:e.x*fn[p],y:e.y*fn[p]}}const{activeItemId:I,tabbableId:w,selectedIds:P,onFocus:T,onBlur:M,selectItem:L}=function({viewportRef:e,spatialListRef:t,items:n=[],eventBus:r,hints:s,centerScreenPoint:a}){const[l,c]=(0,i.J0)(null),[d,u]=(0,i.J0)([]),p=(0,i.li)(!1),h=(0,i.li)(null),f=(0,i.li)(null),g=(0,i.li)([]),m=(0,i.li)(null),y=(0,i.li)(!1);(0,i.vJ)(()=>s.subscribe(e=>{m.current=e}),[s]),f.current=l,g.current=d,function({eventBus:e,lastActiveIdRef:t,setActiveItemId:n,setSelectedIds:r}){(0,i.vJ)(()=>{if(!e)return;const i=({id:e})=>{null!==e&&(t.current=e),n(e)},s=({selectedFeatures:e=[],selectedMarkers:t=[]})=>{r([...e.map(e=>String(e.featureId)),...t])};return e.on(o.E.MAP_SET_ACTIVE_ITEM,i),e.on("interact:selectionchange",s),()=>{e.off(o.E.MAP_SET_ACTIVE_ITEM,i),e.off("interact:selectionchange",s)}},[e])}({eventBus:r,lastActiveIdRef:h,setActiveItemId:c,setSelectedIds:u}),function({items:e,eventBus:t,isFocusedRef:n,spatialListRef:r,isInternalFocusMoveRef:s,lastActiveIdRef:a,activeItemIdRef:l,selectedIdsRef:c,setActiveItemId:d,centerScreenPoint:u}){(0,i.vJ)(()=>{if(!n.current)return;if(!e.length)return d(null),void t?.emit(o.E.MAP_SET_ACTIVE_ITEM,{id:null});if(e.some(e=>e.id===l.current))return;const i=Gn(e,a.current,c.current,u);a.current=i,d(i),t?.emit(o.E.MAP_SET_ACTIVE_ITEM,{id:i}),jn(r.current,i,s)},[e])}({items:n,eventBus:r,isFocusedRef:p,spatialListRef:t,isInternalFocusMoveRef:y,lastActiveIdRef:h,activeItemIdRef:f,selectedIdsRef:g,setActiveItemId:c,centerScreenPoint:a}),function({spatialListRef:e,viewportRef:t,items:n,eventBus:r,activeItemIdRef:s,lastActiveIdRef:a,setActiveItemId:l,isInternalFocusMoveRef:c,hints:d,currentHintRef:u}){(0,i.vJ)(()=>{const i=e.current;if(!i)return;const p=e=>{a.current=e,l(e),r?.emit(o.E.MAP_SET_ACTIVE_ITEM,{id:e}),jn(i,e,c)},h=e=>{"Escape"===e.key?(e.preventDefault(),e.stopPropagation(),u.current?d.dismiss():t.current?.focus()):e.altKey&&Bn.has(e.key)?(e.preventDefault(),e.stopPropagation(),(e=>{p(function(e,t,n){const r=e.filter(e=>null!=e.x&&null!=e.y);if(!r.length)return t;const o=r.map(e=>[e.x,e.y]),i=r.findIndex(e=>e.id===t),s=-1===i?o[0]:o[i],a=Fn(s,o,n);return r[a]?.id??t}(n,s.current,e.key))})(e)):"ArrowDown"===e.key||"ArrowUp"===e.key||"Home"===e.key||"End"===e.key?(e.preventDefault(),e.stopPropagation(),p(((e,t,n)=>{if(!n.length)return e;if("Home"===t)return n[0].id;if("End"===t)return n[n.length-1].id;const r=n.findIndex(t=>t.id===e);return"ArrowDown"===t?-1===r?n[0].id:n[Math.min(r+1,n.length-1)].id:-1===r?n[n.length-1].id:n[Math.max(r-1,0)].id})(s.current,e.key,n))):"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),r?.emit(o.E.MAP_SELECT_ITEM))},f=e=>{(e=>{e.altKey&&Vn.has(e.key)&&e.stopPropagation()})(e)};return i.addEventListener("keydown",h),i.addEventListener("keyup",f),()=>{i.removeEventListener("keydown",h),i.removeEventListener("keyup",f)}},[t,e,n,r])}({spatialListRef:t,viewportRef:e,items:n,eventBus:r,activeItemIdRef:f,lastActiveIdRef:h,setActiveItemId:c,isInternalFocusMoveRef:y,hints:s,currentHintRef:m}),function({viewportRef:e,spatialListRef:t,isFocusedRef:n}){(0,i.vJ)(()=>{const r=e.current;if(!r)return;const o=r=>{n.current&&!t.current?.contains(r.target)&&e.current?.focus()};return r.addEventListener("pointerdown",o),()=>{r.removeEventListener("pointerdown",o)}},[e,t])}({viewportRef:e,spatialListRef:t,isFocusedRef:p});let v=null;return n.length&&(v=h.current&&n.some(e=>e.id===h.current)?h.current:Un(n,a)??n[0].id),{activeItemId:l,tabbableId:v,selectedIds:d,onFocus:()=>{if(p.current=!0,y.current)return;if(!n.length)return;const e=Gn(n,h.current,d,a);h.current=e,c(e),r?.emit(o.E.MAP_SET_ACTIVE_ITEM,{id:e}),jn(t.current,e,y)},onBlur:()=>{y.current||(p.current=!1,c(null),r?.emit(o.E.MAP_SET_ACTIVE_ITEM,{id:null}))},selectItem:e=>{h.current=e,c(e),r?.emit(o.E.MAP_SET_ACTIVE_ITEM,{id:e}),jn(t.current,e,y),r?.emit(o.E.MAP_SELECT_ITEM)}}}({viewportRef:c.viewportRef,spatialListRef:v,items:b,eventBus:f,hints:g,centerScreenPoint:x});(0,i.vJ)(()=>{const e=()=>u({type:"SET_LISTBOX_ACTIVE"});return f.on("interact:listboxcapable",e),()=>f.off("interact:listboxcapable",e)},[f]),function(e){const{mapProvider:t,panDelta:n,nudgePanDelta:r,zoomDelta:s,nudgeZoomDelta:a,readMapText:c}=l(),{dispatch:d,layoutRefs:u}=C(),{announce:p}=ut();(0,i.vJ)(()=>{const i=e.current,l=u.appContainerRef?.current;if(!i||!l)return;const h=((e,t,{containerRef:n,dispatch:r,panDelta:i,nudgePanDelta:s,zoomDelta:a,nudgeZoomDelta:l,readMapText:c})=>{const d=e=>un(!e,s,i),u=e=>un(!e,l,a);return{showKeyboardControls:e=>{const t=e.target===n.current?"viewport":"listbox";r({type:"OPEN_PANEL",payload:{panelId:"keyboardHelp",props:{triggeringElement:e.target,context:t}}})},panUp:t=>e.panBy([0,-d(t.shiftKey)]),panDown:t=>e.panBy([0,d(t.shiftKey)]),panLeft:t=>e.panBy([-d(t.shiftKey),0]),panRight:t=>e.panBy([d(t.shiftKey),0]),zoomIn:t=>e.zoomIn(u(t.shiftKey)),zoomOut:t=>e.zoomOut(u(t.shiftKey)),getInfo:async n=>{if(!(0,o.h)())return void o.l.warn("Alt+I pressed but reverseGeocode has not been configured");const r=e.getCenter(),i=await(0,o.r)(e.getZoom(),r),s=e.getAreaDimensions?.();t(s?`${i}. Covering ${s}.`:`${i}.`,"action")},highlightNextLabel:n=>{if(!c||!e.highlightNextLabel)return;const r=e.highlightNextLabel(n.key);t(r,"action")},highlightLabelAtCenter:()=>{if(!c||!e.highlightLabelAtCenter)return;const n=e.highlightLabelAtCenter();t(n,"action")},clearSelection:()=>e?.clearHighlightedLabel?.()}})(t,p,{containerRef:e,dispatch:d,panDelta:n,nudgePanDelta:r,zoomDelta:s,nudgeZoomDelta:a,readMapText:c}),{handleKeyDown:f,handleKeyUp:g}=(e=>({handleKeyDown:t=>{const n=lr(t),r=cr(e,"keydown",n);if(r)return e[r](t),void t.preventDefault();cr(e,"keyup",n)&&t.preventDefault()},handleKeyUp:t=>{const n=cr(e,"keyup",lr(t));n&&(e[n](t),t.preventDefault())}}))(h);return i.addEventListener("keydown",f),l.addEventListener("keyup",g),()=>{i.removeEventListener("keydown",f),l.removeEventListener("keyup",g)}},[e,t,n,r,s,a])}(c.viewportRef),function(e={}){const{mapProvider:t}=l(),{eventBus:n}=ut();(0,i.vJ)(()=>{if(!t)return;const r={};return Object.entries(e).forEach(([e,t])=>{const o=e=>t(e);r[e]=o,n.on(e,o)}),()=>{Object.entries(r).forEach(([e,t])=>{n.off(e,t)})}},[t,e])}({[o.E.MAP_CLICK]:()=>t?.clearHighlightedLabel?.()});const{handleFocus:A,handleBlur:O}=function({containerRef:e,onViewportFocusChange:t}){return(0,i.vJ)(()=>{const n=e.current;if(!n)return;const r=e=>{"Escape"===e.key&&t(!1)};return n.addEventListener("keydown",r),()=>{n.removeEventListener("keydown",r)}},[e,t]),{handleFocus:()=>{"keyboard"===(0,o.a)()&&t(!0)},handleBlur:()=>{t(!1)}}}({containerRef:c.viewportRef,onViewportFocusChange:e=>{e?g.show(r,{duration:0}):g.dismiss()}});return(0,i.vJ)(()=>{a&&c.viewportRef?.current.focus()},[]),(0,s.FD)(s.FK,{children:[(0,s.Y)(ir,{mapContainerRef:y}),(0,s.FD)("div",{id:`${e}-viewport`,className:`im-c-viewport im-c-viewport--${p}`,"aria-label":n,role:"application",tabIndex:"0","data-map-keyboard-scope":!0,onFocus:A,onBlur:e=>{O(e),m.clear()},onKeyDown:()=>m.releaseAnnouncements(),onPointerDown:()=>m.releaseAnnouncements(),ref:c.viewportRef,"aria-describedby":`${e}-keyboard-desc`,"aria-controls":`${e}-spatial-list`,children:[(0,s.Y)("div",{className:"im-c-viewport__map-container",ref:y,"aria-hidden":"true"}),(0,s.Y)(dr,{}),(0,s.Y)("div",{className:"im-c-viewport__safezone",style:d,ref:c.safeZoneRef,children:(0,s.Y)(pr,{})}),(0,s.Y)("div",{className:"im-c-viewport__markers","aria-hidden":"true",children:(0,s.Y)(_r,{})})]}),(0,s.Y)(hr,{ref:v,activeItemId:I,tabbableId:w,selectedIds:P,multiselectable:_,items:b,label:E,focusable:S,onFocus:()=>{T(),g.show(r,{duration:0})},onBlur:()=>{M(),g.dismiss()},onSelectItem:L})]})},Sr=()=>{const{mapStyle:e}=J();if(e?.logo)return(0,s.Y)("img",{className:"im-c-logo",src:e.logo,alt:e.logoAltText})},xr=()=>{const{breakpoint:e}=C(),{mapStyle:t}=J();return t?(!("mobile"===e)||t.showAttributionOnMobile)&&(0,s.Y)("div",{className:"im-c-attributions",dangerouslySetInnerHTML:{__html:t.attribution}}):null},Ir=(e,t,n,r,o,s)=>{const a=(0,i.li)(r);a.current=r,(0,i.Nf)(()=>{const r=e.current;if(n){const e=((e,t)=>{const n={side:t.sideRef,banner:t.bannerRef,"top-left":t.topLeftColRef,"top-right":t.topRightColRef,"left-top":t.leftTopRef,"left-bottom":t.leftBottomRef,middle:t.middleRef,"right-top":t.rightTopRef,"right-bottom":t.rightBottomRef,"bottom-right":t.bottomRightRef,drawer:t.drawerRef,actions:t.actionsRef,modal:t.modalRef};if(e?.endsWith("-button")){const t=document.querySelector(`[data-button-slot="${e}"]`);return t?{current:t}:null}if(e?.endsWith("-panel")){const t=document.querySelector(`[data-panel-slot="${e}"]`);return t?{current:t}:null}return n[e]||null})(t,a.current);if(e?.current){const t=e.current.querySelector(":scope > .im-o-app__modal-backdrop");t?e.current.insertBefore(r,t):e.current.appendChild(r),r.style.display=""}}else r.parentElement===a.current.modalRef?.current&&a.current.appContainerRef?.current?.appendChild(r),r.style.display="none";return()=>{r.style.display="none"}},[n,t,o,e,s])},wr=({panelId:e,config:t,isOpen:n,openPanelProps:r,focusOnOpen:o,allowedModalPanelId:a,appState:l,isHiddenByApplicationMode:c})=>{const d=(0,i.li)(null),{breakpoint:u,isFullscreen:p,layoutRefs:h}=l,f=t[u],g=f?yt(f,u):null,m=Boolean(f&&g&&bt(t,{targetSlot:g,isFullscreen:p})),y=!f?.modal||e===a,v=c({ids:[e],pluginId:t.pluginId,isModal:!!f?.modal});return Ir(d,g,n&&m&&y&&!v,h,u),(0,s.Y)(Vt,{panelId:e,panelConfig:t,props:r,focusOnOpen:o,html:t.html,label:t.label,isOpen:n,rootRef:d})},Pr=({control:e,appState:t,isHiddenByApplicationMode:n})=>{const r=(0,i.li)(null),{breakpoint:o,isFullscreen:a,layoutRefs:l,openPanels:c}=t,d=e[o],u=n({ids:[e.id],pluginId:e.pluginId}),p=((e,{breakpoint:t,isFullscreen:n})=>{const r=e[t];return!(!r||!x.control.includes(r.slot)&&!r.slot?.endsWith("-panel")||!1===e.inline&&!n)})(e,{breakpoint:o,isFullscreen:a})&&!u,h=d?.slot||null,f=h?.endsWith("-panel")?Object.keys(c||{}).sort((e,t)=>e.localeCompare(t)).join(","):null;Ir(r,h,p,l,o,f);const g=(0,i.Kr)(()=>({__html:e.html}),[e.html]);return(0,s.Y)("div",{ref:r,className:`im-c-control im-c-control--${O(e.id)}`,style:{display:"none"},dangerouslySetInnerHTML:g})},Cr=()=>{const e=C(),t=zt(),{panelConfig:n={},controlConfig:r={},openPanels:o={},breakpoint:a}=e,l=(0,i.Kr)(()=>Object.entries(n).filter(([e,t])=>vt(t)),[n]),c=(0,i.Kr)(()=>Object.values(r).filter(e=>vt(e)),[r]),d=(0,i.Kr)(()=>_t(o,n,a),[o,n,a]);return l.length||c.length?(0,s.FD)(s.FK,{children:[l.map(([n,r])=>(0,s.Y)(wr,{panelId:n,config:r,isOpen:!!o[n],openPanelProps:o[n]?.props,focusOnOpen:o[n]?.focusOnOpen,allowedModalPanelId:d,appState:e,isHiddenByApplicationMode:t},n)),c.map(n=>(0,s.Y)(Pr,{control:n,appState:e,isHiddenByApplicationMode:t},n.id))]}):null},Tr=e=>{const t=(new DOMParser).parseFromString(e,"text/html");return t.querySelectorAll('[aria-hidden="true"]').forEach(e=>e.remove()),t.body.textContent.replace(/\s{2,}/g," ").trim()},Mr=()=>{const{id:e,keyboardHintText:t,enableMapControls:n,mapControlsHintText:r}=l(),{hints:o}=ut(),{layoutRefs:a}=C(),[c,d]=(0,i.J0)(null),[u,p]=(0,i.J0)(!1);if((0,i.vJ)(()=>(p(!0),o.subscribe(d)),[o]),!u||!a.mainRef?.current)return null;const h=n?`${t} ${r}`:t;return(0,i.d5)((0,s.FD)("div",{className:"im-o-hints",children:[(0,s.Y)("div",{id:`${e}-hints`,className:"im-c-hints",children:c&&(0,s.Y)("div",{className:"im-c-hints__hint",dangerouslySetInnerHTML:{__html:c.html}})}),(0,s.Y)("div",{id:`${e}-keyboard-desc`,className:"im-u-visually-hidden",dangerouslySetInnerHTML:{__html:Tr(h)}})]}),a.mainRef.current)},Lr=()=>{const e=l(),{id:t,mapLabel:n,mapHintText:r}=e,a=C(),{breakpoint:c,interfaceType:d,preferredColorScheme:u,layoutRefs:p,isLayoutReady:h,isFullscreen:f,openPanels:g,panelConfig:m}=a,{mapStyle:y}=J(),v=((e,t,n)=>null!==_t(e,t,n))(g??{},m??{},c),b=St(a,e);return function(){const{dispatch:e,breakpoint:t,layoutRefs:n,arePluginsEvaluated:r,appVisible:o,isFullscreen:s}=C(),{mapSize:a,isMapReady:l}=J(),{bannerRef:c,mainRef:d,headerRef:u,topRef:p,topLeftColRef:h,topRightColRef:f,bottomRef:g,bottomRightRef:m,attributionsRef:y,leftTopRef:v,leftBottomRef:b,rightTopRef:_,rightBottomRef:E,drawerRef:S,actionsRef:x,leftRef:I,rightRef:w}=n;(0,i.Nf)(()=>{e({type:"CLEAR_PLUGINS_EVALUATED"})},[t,a,l,o,s]),(0,i.Nf)(()=>{r&&requestAnimationFrame(()=>{nr(n,t);const r=Jn(n);r&&e({type:"SET_SAFE_ZONE_INSET",payload:{safeZoneInset:r}})})},[r]),Mt((0,i.Kr)(()=>[c,d,u,p,h,f,x,g,m,y,v,b,_,E,S,I,w],[]),()=>{nr(n,t)})}(),function(){const{layoutRefs:e}=C();(0,i.vJ)(()=>{if(e.appContainerRef.current)return document.addEventListener("focusin",t),document.addEventListener("focusout",n),document.addEventListener("pointerdown",r),()=>{document.removeEventListener("focusin",t),document.removeEventListener("focusout",n),document.removeEventListener("pointerdown",r)};function t(e){e.target.dataset.focusVisible="keyboard"===(0,o.a)()}function n(e){delete e.target.dataset.focusVisible}function r(){delete document.activeElement.dataset.focusVisible}},[e.appContainerRef])}(),function(){const{applicationModeEntries:e,layoutRefs:t}=C();(0,i.vJ)(()=>{const e=t.appContainerRef?.current,n=document.activeElement;e&&n&&e.contains(n)&&!(n.getClientRects().length>0)&&t.viewportRef?.current?.focus({preventScroll:!0})},[e])}(),(0,s.FD)("div",{id:`${t}-im-app`,className:["im-o-app",`im-o-app--${c}`,`im-o-app--${d}`,"im-o-app--"+(f?"fullscreen":"inline"),`im-o-app--${y?.appColorScheme||u}-app`,It(b)].filter(Boolean).join(" "),style:{backgroundColor:y?.backgroundColor||void 0,...ge(y)},ref:p.appContainerRef,children:[(0,s.FD)("div",{className:"im-u-visually-hidden",children:[n,". ",r]}),(0,s.Y)(Er,{}),(0,s.FD)("div",{className:"im-o-app__overlay"+(h?"":" im-o-app__overlay--not-ready"),children:[(0,s.Y)("div",{className:"im-o-app__side",ref:p.sideRef,children:(0,s.Y)(Xt,{slot:S.SIDE})}),(0,s.FD)("div",{className:"im-o-app__main",ref:p.mainRef,children:[(0,s.Y)("div",{className:"im-o-app__header",ref:p.headerRef,children:(0,s.Y)(Xt,{slot:S.HEADER})}),(0,s.FD)("div",{className:"im-o-app__top",ref:p.topRef,children:[(0,s.Y)("div",{className:"im-o-app__top-col",ref:p.topLeftColRef,children:(0,s.Y)(Xt,{slot:S.TOP_LEFT})}),(0,s.Y)("div",{className:"im-o-app__top-col",children:(0,s.Y)(Xt,{slot:S.TOP_MIDDLE})}),(0,s.Y)("div",{className:"im-o-app__top-col",ref:p.topRightColRef,children:(0,s.Y)(Xt,{slot:S.TOP_RIGHT})})]}),(0,s.Y)("div",{className:"im-o-app__banner",ref:p.bannerRef,children:(0,s.Y)(Xt,{slot:S.BANNER})}),(0,s.FD)("div",{className:"im-o-app__left",ref:p.leftRef,children:[(0,s.Y)("div",{className:"im-o-app__left-top",ref:p.leftTopRef,children:(0,s.Y)(Xt,{slot:S.LEFT_TOP})}),(0,s.Y)("div",{className:"im-o-app__left-bottom",ref:p.leftBottomRef,children:(0,s.Y)(Xt,{slot:S.LEFT_BOTTOM})})]}),(0,s.Y)("div",{className:"im-o-app__middle",ref:p.middleRef,children:(0,s.Y)(Xt,{slot:S.MIDDLE})}),(0,s.FD)("div",{className:"im-o-app__right",ref:p.rightRef,children:[(0,s.Y)("div",{className:"im-o-app__right-top",ref:p.rightTopRef,children:(0,s.Y)(Xt,{slot:S.RIGHT_TOP})}),(0,s.Y)("div",{className:"im-o-app__right-bottom",ref:p.rightBottomRef,children:(0,s.Y)(Xt,{slot:S.RIGHT_BOTTOM})})]}),(0,s.FD)("div",{className:"im-o-app__bottom",ref:p.bottomRef,children:[(0,s.FD)("div",{className:"im-o-app__bottom-col",children:[(0,s.Y)(Sr,{}),(0,s.Y)("div",{className:"im-o-app__bottom-left",children:(0,s.Y)(Xt,{slot:S.BOTTOM_LEFT})})]}),(0,s.Y)("div",{className:"im-o-app__bottom-col",children:(0,s.Y)("div",{className:"im-o-app__bottom-right",ref:p.bottomRightRef,children:(0,s.Y)(Xt,{slot:S.BOTTOM_RIGHT})})}),(0,s.Y)("div",{className:"im-o-app__attributions",ref:p.attributionsRef,children:(0,s.Y)(xr,{})})]}),(0,s.Y)("div",{className:"im-o-app__drawer",ref:p.drawerRef,children:(0,s.Y)(Xt,{slot:S.DRAWER})}),(0,s.Y)("div",{className:"im-o-app__actions",ref:p.actionsRef,children:(0,s.Y)(Xt,{slot:S.ACTIONS})}),(0,s.FD)("div",{className:"im-o-app__modal",ref:p.modalRef,children:[(0,s.Y)(Xt,{slot:S.MODAL}),(0,s.Y)("div",{className:"im-o-app__modal-backdrop"+(v?" im-o-app__modal-backdrop--visible":"")})]})]})]}),(0,s.Y)(Mr,{}),(0,s.Y)(Cr,{})]})},Ar=e=>((0,i.vJ)(()=>{(0,o.b)(),e.eventBus.emit(o.E.APP_READY)},[]),(0,s.Y)(P,{options:e,children:(0,s.Y)(W,{options:e,children:(0,s.Y)(dt,{eventBus:e.eventBus,pluginRegistry:e.pluginRegistry,children:(0,s.FD)(ht,{children:[(0,s.Y)(Nn,{}),(0,s.Y)(Wt,{children:(0,s.Y)(Lr,{})})]})})})})),Or=new WeakMap,kr=new WeakMap,Dr=new WeakMap,Rr=(e,t)=>{let n=Dr.get(e);if(!n){const r=function(){let e={};return{registerButton:t=>{e=d(e,t)},addButton:(t,n)=>(e=u(e,t,n),t),getButtonConfig:t=>((e,t)=>t?Object.fromEntries(Object.entries(e).filter(([e,n])=>n.pluginId===t)):e)(e,t),clear:()=>{e={}}}}(),i=function(){let e={};return{registerPanel:t=>{e=p(e,t)},addPanel:(t,n)=>(e=h(e,t,n),e[t]),removePanel:t=>{e=f(e,t)},getPanelConfig:()=>e,clear:()=>{e={}}}}(),s=function(){let e={};return{registerControl:t=>{e=g(e,t)},addControl:(t,n)=>(e=m(e,t,n),e[t]),getControlConfig:()=>e,clear:()=>{e={}}}}(),a=function(){const e={pluginShortcutHelp:[],pluginShortcutIds:new Set,providerSupportedIds:new Set};return{registerKeyboardShortcut:t=>((e,{shortcut:t})=>{const{pluginShortcutHelp:n,pluginShortcutIds:r}=e;r.has(t.id)?n[n.findIndex(e=>e.id===t.id)]=t:(r.add(t.id),n.push(t))})(e,t),setProviderSupportedShortcuts:t=>((e,t=[])=>{e.providerSupportedIds=new Set(t)})(e,t),getKeyboardShortcuts:t=>((e,t={})=>[...kn.filter(n=>!(!n.mapProviderAgnostic&&!e.providerSupportedIds.has(n.id))&&(!n.requiredConfig||n.requiredConfig.every(e=>t[e]))),...e.pluginShortcutHelp])(e,t)}}(),l=function({eventBus:e}){const t=new Map;let n=null;const r=()=>{let r,i,s=[],a=!1;if(n&&t.has(n)){const e=t.get(n).getItems()??{};s=e.items??[],a=!!e.multiselectable,r=e.label,i=e.focusable}else t.forEach(e=>{if(e.exclusive)return;const t=e.getItems()??{};s=s.concat(t.items??[]),a=a||!!t.multiselectable,r=r??t.label,i=i??t.focusable});e.emit(o.E.MAP_SET_SPATIAL_LIST,{items:s,multiselectable:a,label:r,focusable:i})};return{registerItemProvider:function(e,{getItems:n,exclusive:o=!1}){t.set(e,{getItems:n,exclusive:o}),r()},unregisterItemProvider:function(e){t.delete(e),n===e&&(n=null),r()},claimExclusive:function(e){n=e,r()},releaseExclusive:function(e){n===e&&(n=null,r())},notifyItemsChanged:function(e){t.has(e)&&(n&&n!==e||r())},clear:function(){t.clear(),n=null}}}({eventBus:t});n={buttonRegistry:r,panelRegistry:i,controlRegistry:s,pluginRegistry:Ln({registerButton:r.registerButton,registerPanel:i.registerPanel,registerControl:s.registerControl,registerKeyboardShortcut:a.registerKeyboardShortcut}),keyboardShortcutRegistry:a,spatialListRegistry:l},Dr.set(e,n)}return n};async function Nr(e,{MapProvider:t,mapProviderConfig:n,mapFramework:i,plugins:a=[],...l}){const{eventBus:c}=l;let d=kr.get(e);d||(d=new t({mapFramework:i,mapProviderConfig:n,events:o.E,eventBus:c}),kr.set(e,d));const{buttonRegistry:u,panelRegistry:p,controlRegistry:h,pluginRegistry:f,keyboardShortcutRegistry:g,spatialListRegistry:m}=Rr(e,c),{registerPlugin:y}=f;d.capabilities?.supportedShortcuts&&g.setProviderSupportedShortcuts(d.capabilities.supportedShortcuts),f.clear(),y({id:"appConfig",manifest:Sn});let v=Or.get(e);v||(v=(0,r.Hr)(e),Or.set(e,v));const b={_root:v,on:c.on,off:c.off,emit:c.emit,unmount(){v.unmount(),Or.delete(e),d.destroyMap?.(),kr.delete(e),f.clear()}};return await(async(e,t)=>{for(const n of e)if("function"==typeof n.load){const e=await n.load(),{id:r,load:o,manifest:i,...s}=n,{InitComponent:a,api:l,reducer:c,...d}=e;t({id:r,InitComponent:a,api:l,reducer:c,config:s,manifest:Dn(d,i),_originalPlugin:n})}})(a,y),v.render((0,s.Y)(Ar,{...l,buttonRegistry:u,panelRegistry:p,controlRegistry:h,pluginRegistry:f,keyboardShortcutRegistry:g,spatialListRegistry:m,mapProvider:d})),b}},684:(e,t,n)=>{n.d(t,{default:()=>a}),Object(function(){var e=new Error("Cannot find module '@arcgis/core/layers/VectorTileLayer.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module '@arcgis/core/layers/FeatureLayer.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module '@arcgis/core/layers/GroupLayer.js'");throw e.code="MODULE_NOT_FOUND",e}());var r=n(964),o=n(900);n(452),n(247);class i extends o.D{applyLayerPaintProperties(e){const{mapStyle:t}=this._datasetRegistry;return this.hasStroke&&(e["line-color"]=(0,r.g)(this.style.stroke,t.id)),this.hasFill&&(e["fill-color"]=(0,r.g)(this.style.fill,t.id)),e}get esriGroupId(){return void 0===this._datasetDefinition.esriGroupId?this.parent?.esriGroupId:this._datasetDefinition.esriGroupId}get useServerStyle(){return Boolean(this._datasetDefinition.esriUseServerStyle)}get renderer(){if("FeatureService"!==this.type)return;const e=this._datasetDefinition.style?.renderer||this.parent?.renderer;if(!e)return;const{mapStyle:t}=this._datasetRegistry,n=structuredClone(e);return n.symbol?.color&&(n.symbol.color=(0,r.g)(n.symbol.color,t.id)),n.symbol?.outline?.color&&(n.symbol.outline.color=(0,r.g)(n.symbol.outline.color,t.id)),n}}const s=(e,t)=>{if("baseLayer"===e.id)return-1/0;if(e.id.includes("ketchLayer"))return 1/0;const n="group"===e.type?e.layers?.items?.[0]?.id:e.id;return t.indexOf(n)};class a extends r.L{constructor(e,t,n,r){super(),this._datasetRegistry=r,this.ready=new Promise(e=>{this.resolveReady=e}),this._mapProvider=e,this._map=e.map,this._mapVisibilityLayers={},this._mapOpacityLayers={},this._groupLayers={}}createDataset(e,t){return new i(e,t)}async init(){const e=this._datasetRegistry.topLevelDatasets(),t=async e=>this._addLayers(e).then(()=>{const t=this._mapVisibilityLayers[e.id];e.sublayers?.forEach(e=>{"visible"===e.visibility&&this._applyStyleLayerPaintProperties(e,t)}),this.applyDatasetVisibility(e.id)});for(const n of e)"visible"===n.visibility&&await t(n);this._reorderLayers();for(const n of e)"visible"!==n.visibility&&await t(n);await this.onMapStyleChange(),await this.applyGlobalOpacity(),await Promise.all(e.map(e=>this.applyDatasetVisibility(e.id))),this._reorderLayers(),this.resolveReady()}_reorderLayers(){const e=this._map?.allLayers?.items;if(!e?.length)return;const t=this._datasetRegistry._orderedDatasets;[...e.filter(e=>"group"!==e.parent?.type)].sort((e,n)=>s(e,t)-s(n,t)).forEach((e,t)=>this._map.reorder(e,t)),this._reorderGroupLayers()}_reorderGroupLayers(){const e=this._datasetRegistry._orderedDatasets;Object.values(this._groupLayers).forEach(t=>{[...t?.allLayers?.items||[]].filter(Boolean).sort((t,n)=>s(t,e)-s(n,e)).forEach((e,n)=>t?.reorder?.(e,n))})}_addGroupLayer(e){if(!this._groupLayers[e]){const t=new Object(function(){var e=new Error("Cannot find module '@arcgis/core/layers/GroupLayer.js'");throw e.code="MODULE_NOT_FOUND",e}())({id:e,opacity:1,visible:!0});this._groupLayers[e]=t,this._map.add(t)}return this._groupLayers[e]}async _addFeatureLayers(e){const t=new Object(function(){var e=new Error("Cannot find module '@arcgis/core/layers/FeatureLayer.js'");throw e.code="MODULE_NOT_FOUND",e}())({id:e.id,url:e.tiles,renderer:e.renderer,opacity:1,visible:!1});this._mapVisibilityLayers[e.id]=t,this._mapOpacityLayers[e.id]=t;try{return this._map.add(t),t.when()}catch(n){o.l.error(`Error adding FeatureLayer for dataset ${e.id}:`,n)}return null}async _addLayers(e){const{type:t,esriGroupId:n,tiles:r}=e;if(!r)return null;if("FeatureService"===t)return this._addFeatureLayers(e);const o=n?this._addGroupLayer(n):this._map,i=new Object(function(){var e=new Error("Cannot find module '@arcgis/core/layers/VectorTileLayer.js'");throw e.code="MODULE_NOT_FOUND",e}())({id:e.id,url:e.tiles,opacity:1,visible:!1});return this._mapVisibilityLayers[e.id]=i,this._mapOpacityLayers[e.id]=n?o:i,o.add(i),i.when()}async addDataset(e){const t=this._datasetRegistry.getDataset(e);if(!t)return void o.l.warn(`addDataset called, but Dataset with id ${e} not found in registry`);await this._addLayers(t);const{parentId:n}=t,r=this._mapVisibilityLayers[n||e];this._reorderLayers(),this.applyDatasetOpacity(e),this._applyStyleLayerPaintProperties(t,r),this.applyDatasetVisibility(e)}async removeDataset(e){const t=this._datasetRegistry.getDataset(e);if(!t)return;const{esriGroupId:n}=t,r=this._mapVisibilityLayers[e],o=n?this._groupLayers[n]:null,i=o||this._map;r&&(i.remove(r),delete this._mapVisibilityLayers[e],delete this._mapOpacityLayers[e]),0===o?.layers.length&&(this._map.remove(o),delete this._groupLayers[n])}_applyRegistryDatasetVisibility(e){const{id:t,isSublayer:n,parentId:r}=e,o="visible"===e.visibility,i=this._mapVisibilityLayers[n?r:t];i&&(n?this._applyStyleLayerVisibility(e,i):(o&&e.sublayers.forEach(e=>this._applyStyleLayerVisibility(e,i)),i.visible=o))}async applyDatasetVisibility(e){const t=this._datasetRegistry.getDataset(e);t&&this._applyRegistryDatasetVisibility(t)}async applyGlobalVisibility(){this._datasetRegistry.forEachDataset(e=>this._applyRegistryDatasetVisibility(e))}async applyDatasetOpacity(e){const t=this._mapOpacityLayers[e],n=this._datasetRegistry.getDataset(e);t&&n&&(t.opacity=n.opacity)}async applyGlobalOpacity(){Object.entries(this._mapOpacityLayers).forEach(([e,t])=>{const n=this._datasetRegistry.getDataset(e);n&&(t.opacity=n.opacity)})}_applyStyleLayerVisibility(e,t){const{esriStyleLayerId:n}=e;n&&t&&this.ready.then(()=>{t.setStyleLayerVisibility(n,e.visibility)})}_applyStyleLayerPaintProperties(e,t){const{esriStyleLayerId:n,useServerStyle:r}=e;if(r||!n||!t)return;const o=t.getPaintProperties(n);o&&t.setPaintProperties(n,e.applyLayerPaintProperties(o))}async onMapStyleChange(){this._datasetRegistry.forEach(e=>{const{id:t,isSublayer:n,parent:r}=e,o=this._mapVisibilityLayers[n?r.id:t];o&&("FeatureService"===e.type?o.renderer=e.renderer:(this._applyStyleLayerVisibility(e,o),this._applyStyleLayerPaintProperties(e,o)))})}async onMapSizeChange(){}async applyFeatureFilter(...e){console.log("TODO: applyFeatureFilter",e)}async setData(...e){console.log("TODO: setData",e)}async applyStyle(...e){console.log("TODO: applyStyle",e)}}},932:(e,t,n)=>{n.d(t,{default:()=>l});var r=n(964),o=n(982),i=n(900);n(452),n(247);const s=(e,t,n,o,i,a)=>{const{map:l}=e,{sourceId:c,source:d}=t;d&&!l.getSource(c)&&l.addSource(c,d);const u=n.id;return((e,t,n,r,o)=>{const{map:i}=e,{hasSymbol:s,symbolLayerId:a}=t;if(!s||!r||!a||i.getLayer(a))return;const l=r.getSymbolDef(t.style);if(!l)return;const c=r.getSymbolImageId(t.style,n,"normal",o);c&&i.addLayer(t.getSymbolSource(c,e.getSymbolIconLayout(l)))})(e,t,n,o,a),((e,t,n,o,i=1)=>{const{hasFill:s,fillLayerId:a}=t;if(!s||!a||e.getLayer(a))return;const l=o.getPatternImageId(t.style,n,i),c=l?{"fill-pattern":l,"fill-opacity":t.opacity}:{"fill-color":(0,r.g)(t.style.fill,n),"fill-opacity":t.opacity};e.addLayer(t.getFillSource(c))})(l,t,u,i,a),((e,t,n)=>{const{hasStroke:o,strokeLayerId:i}=t;if(!o||e.getLayer(i))return;const s={"line-color":(0,r.g)(t.style.stroke,n),"line-width":t.style.strokeWidth,"line-opacity":t.opacity,...t.style.strokeDashArray?{"line-dasharray":t.style.strokeDashArray}:{}},a=t.getStrokeSource(s);e.addLayer(a)})(l,t,u),t.sublayers?.length?(t.sublayers.forEach(t=>{s(e,t,n,o,i,a)}),c):t.isSublayer?void 0:c};class a extends o.M{get fillLayerId(){return this.hasSublayers||this.hasSymbol?null:this.hasFill?this.id:null}get strokeLayerId(){return this.hasSublayers||this.hasSymbol?null:this.hasStroke?this.hasFill?`${this.id}-stroke`:this.id:null}get symbolLayerId(){return this.hasSublayers?null:this.hasSymbol?this.id:null}get leafLayerIds(){return[this.symbolLayerId,this.fillLayerId,this.strokeLayerId].filter(Boolean)}_geojsonIdStrategy(){return this.idProperty?{promoteId:this.idProperty}:this.generateIds?{generateId:!0}:(this.geojson?.features?.some(e=>"string"==typeof e.id)&&i.l.warn(`Dataset "${this.id}" has GeoJSON features with string native IDs. MapLibre only surfaces integer native feature IDs through queryRenderedFeatures. Use idProperty to promote a string property instead.`),{})}get source(){if(this.hasDynamicGeoJSON)return this.dynamicGeoJSON.source;if(this.tiles){const e={type:"vector",tiles:this.tiles,minzoom:this.minZoom||0,maxzoom:this.maxZoom||22};return this.idProperty&&this.sourceLayer&&(e.promoteId={[this.sourceLayer]:this.idProperty}),e}return this.geojson?{type:"geojson",data:this.geojson,...this._geojsonIdStrategy()}:null}getSymbolSource(e,t){return{id:this.symbolLayerId,type:"symbol",source:this.sourceId,"source-layer":this.sourceLayer,minzoom:this.minZoom,maxzoom:this.maxZoom,layout:{visibility:this.visibility,"icon-image":e,...t,"icon-allow-overlap":!0},...this.filter?{filter:this.filter}:{}}}getFillSource(e){return{id:this.fillLayerId,type:"fill",source:this.sourceId,"source-layer":this.sourceLayer,minzoom:this.minZoom,maxzoom:this.maxZoom,layout:{visibility:this.visibility},paint:e,...this.filter?{filter:this.filter}:{}}}getStrokeSource(e){return{id:this.strokeLayerId,type:"line",source:this.sourceId,"source-layer":this.sourceLayer,minzoom:this.minZoom,maxzoom:this.maxZoom,layout:{visibility:this.visibility},paint:e,...this.filter?{filter:this.filter}:{}}}}class l extends o.a{constructor(e,t,n,r){super(e,t,n,r),this._datasetSourceMap=new Map,window._datasetSourceMap=this._datasetSourceMap,this._symbolLayerIds=new Set}createDataset(e,t){return new a(e,t)}async init(){const{patternConfigs:e,symbolConfigs:t}=this._datasetRegistry.getPatternAndSymbolConfigs();await this.addPatternsAndSymbolsToMap(e,t),this._symbolLayerIds.clear(),this._datasetRegistry.forEachDataset(e=>this._addLayers(e)),await new Promise(e=>this._map.once("idle",e))}removeLayer(e){this._map.getLayer(e)&&this._map.removeLayer(e),this._symbolLayerIds.delete(e)}async addPatternsAndSymbolsToMap(e,t){const n=this._datasetRegistry.mapStyle,r=n.id;return Promise.all([this._mapProvider.addPatternsToMap(e,r,this._patternRegistry),this._mapProvider.addSymbolsToMap(t,n,this._symbolRegistry)])}destroy(){const e=new Set;this._datasetRegistry.forEachDataset(t=>{const n=t.sourceId;this._getLayersUsingSource(n).forEach(e=>this.removeLayer(e)),!e.has(n)&&this._map.getSource(n)&&(this._map.removeSource(n),e.add(n))}),this._datasetSourceMap.clear()}async onMapStyleChange(){await new Promise(e=>this._map.once("idle",e));const{patternConfigs:e,symbolConfigs:t}=this._datasetRegistry.getPatternAndSymbolConfigs();await this.addPatternsAndSymbolsToMap(e,t),this._symbolLayerIds.clear(),this._datasetRegistry.forEachDataset(e=>{this._addLayers(e),this._applyFeatureFilter(e)}),this.dynamicSources.forEach(e=>e.reapply())}async onMapSizeChange(){const{mapStyle:e}=this._datasetRegistry,t=this._pixelRatio,{patternConfigs:n,symbolConfigs:r}=this._datasetRegistry.getPatternAndSymbolConfigs();await this.addPatternsAndSymbolsToMap(n,r),this._pixelRatio===t&&this._datasetRegistry.forEach(n=>{const{fillLayerId:r,symbolLayerId:o}=n;if(o&&this._symbolLayerIds.has(o)&&this._map.getLayer(o)){const r=this._symbolRegistry.getSymbolImageId(n.style,e,"normal",t);return void(r&&this._map.setLayoutProperty(o,"icon-image",r))}if(r&&this._map.getLayer(r)){const o=this._patternRegistry.getPatternImageId(n.style,e.id,t);o&&this._map.setPaintProperty(r,"fill-pattern",o)}})}_registerPatternsAndSymbols(e){return this.addPatternsAndSymbolsToMap(e.patternConfigs,e.symbolConfigs)}removeDataset(e){const t=this._datasetRegistry.getDataset(e);if(!t)return;const{sourceId:n,layerIds:r}=t;r.forEach(e=>this.removeLayer(e)),!this._datasetRegistry.topLevelDatasets().some(t=>t.id!==e&&t.sourceId===n)&&this._map.getSource(n)&&this._map.removeSource(n),this._datasetSourceMap.delete(e)}applyFeatureFilter(e){const t=this._datasetRegistry.getDataset(e);t&&this._applyFeatureFilter(t)}async applyStyle(e){const t=this._datasetRegistry.getDataset(e);t.layerIds.forEach(e=>this.removeLayer(e)),await this._registerPatternsAndSymbols(t),this._addLayers(t)}setData(e,t){const n=this._datasetSourceMap.get(e);if(!n)return;const r=this._map.getSource(n);r&&"function"==typeof r.setData&&r.setData(t)}_addLayers(e){const{mapStyle:t}=this._datasetRegistry,n=s(this._mapProvider,e,t,this._symbolRegistry,this._patternRegistry,this._pixelRatio);this._datasetSourceMap.set(e.id,n),this._maintainSymbolOrdering(e)}_getFirstSymbolLayerId(){const e=this._map.getStyle();if(!e?.layers)return null;const t=e.layers.find(e=>this._symbolLayerIds.has(e.id));return t?.id??null}_maintainSymbolOrdering(e){const t=(e=e.isSublayer?e.parent:e).layerIds.filter(e=>e&&this._map.getLayer(e));t.forEach(e=>{"symbol"===this._map.getLayer(e)?.type?this._symbolLayerIds.add(e):this._symbolLayerIds.delete(e)});const n=this._getFirstSymbolLayerId();n&&t.forEach(e=>{this._symbolLayerIds.has(e)||this._map.moveLayer(e,n)})}_setLayerVisibility(e,t){this._map.getLayer(e)&&this._map.setLayoutProperty(e,"visibility",t)}_applyFeatureFilter(e){e.getLayersWithFilters().forEach(({layerIds:e,filter:t})=>{e.forEach(e=>{this._map.getLayer(e)&&this._map.setFilter(e,t)})})}_setLayerOpacity(e,t){const n=this._map.getLayer(e);if(!n)return;const r={line:"line-opacity",symbol:"icon-opacity"}[n.type]||"fill-opacity";this._map.setPaintProperty(e,r,t)}_getLayersUsingSource(e){const t=this._map.getStyle();return t?.layers?t.layers.filter(t=>t.source===e).map(e=>e.id):[]}}},518:(e,t,n)=>{n.d(t,{default:()=>m});var r=n(982),o=n(964);Object(function(){var e=new Error("Cannot find module 'ol/source/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/layer/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/source/VectorTile.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/layer/VectorTile.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/format/GeoJSON.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/format/MVT.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/Feature.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/tilegrid/TileGrid.js'");throw e.code="MODULE_NOT_FOUND",e}());var i=n(900);Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}()),n(452),n(247);class s extends r.M{get leafLayerIds(){return this.hasSublayers?[]:this.hasFill||this.hasStroke||this.hasSymbol?[this.id]:[]}get source(){return this.hasDynamicGeoJSON?{type:"geojson",data:{type:"FeatureCollection",features:[]}}:this.tiles?{type:"vector",tiles:this.tiles,minzoom:this.minZoom||0,maxzoom:this.maxZoom||22}:this.geojson?{type:"geojson",data:this.geojson}:null}get idStrategy(){return this.hasDynamicGeoJSON?this.dynamicGeoJSON.idProperty||null:this.idProperty||null}get filter(){const e=super.filter;if(!this.sourceLayer)return e;const t=["==",["get","layer"],this.sourceLayer];return e?"all"===e[0]?[...e,t]:["all",e,t]:t}_wrapWithFilter(e){return this.filter?[{filter:this.filter,style:e}]:e}getSymbolMeta({pixelRatio:e,symbolRegistry:t}){if(!this.hasSymbol)return null;const n=t.getSymbolImageId(this.style,this._datasetRegistry.mapStyle,"normal",e);return n?{imageId:n,anchor:t.getSymbolDef(this.style).anchor,pixelRatio:e}:null}_symbolStyle(e){const t={},n=this.getSymbolMeta(e),r=n&&e.getSymbolDataUri(n.imageId);return r&&(t["icon-src"]=r,t["icon-anchor"]=n.anchor,t["icon-scale"]=1/e.pixelRatio),this._wrapWithFilter(t)}getFlatStyle(e){if(this.hasSymbol)return this._symbolStyle(e);const t=this._datasetRegistry.mapStyle?.id,n={};return this.hasFill&&!this.hasPattern&&(n["fill-color"]=(0,o.g)(this.style.fill,t)),this.hasStroke&&(n["stroke-color"]=(0,o.g)(this.style.stroke,t),n["stroke-width"]=this.style.strokeWidth,this.style.strokeDashArray&&(n["stroke-line-dash"]=this.style.strokeDashArray)),this._wrapWithFilter(n)}}const a=(e,t)=>{if(e.hasStroke)return new Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:(0,o.g)(e.style.stroke,t),width:e.style.strokeWidth,lineDash:e.style.strokeDashArray})},l="EPSG:27700",c=new Object(function(){var e=new Error("Cannot find module 'ol/format/GeoJSON.js'");throw e.code="MODULE_NOT_FOUND",e}())({dataProjection:l,featureProjection:l}),d=1e-6,u=13e5,p=[0,0,u,u],h=new Object(function(){var e=new Error("Cannot find module 'ol/tilegrid/TileGrid.js'");throw e.code="MODULE_NOT_FOUND",e}())({extent:p,origin:[p[0],p[3]],resolutions:Array.from({length:25},(e,t)=>(p[2]-p[0])/(256*2**t)),tileSize:256}),f=(e,t)=>{if(!t)return c.readFeatures(e);const n={...e,features:e.features.map(e=>({...e,id:e.properties?.[t]??e.id}))};return c.readFeatures(n)},g=(e,t={})=>e.hasPattern?((e,{mapStyleId:t,pixelRatio:n,patternRegistry:r,getPatternFill:o,buildFilterEvaluator:i})=>{const s=r.getPatternImageId(e.style,t,n),l=s&&o(s),c=l?new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({fill:l,stroke:a(e,t)}):void 0,d=i(e.filter);return e=>{if(c&&(!d||d(e)))return c}})(e,t):e.getFlatStyle(t);class m extends r.a{constructor(e,t,n,r){super(e,t,n,r),this._sourcesById=new Map,this._layersById=new Map,this.createDataset=this.createDataset.bind(this)}createDataset(e,t){return new s(e,t)}get _styleContext(){return{mapStyleId:this._datasetRegistry.mapStyle?.id,pixelRatio:this._pixelRatio,patternRegistry:this._patternRegistry,symbolRegistry:this._symbolRegistry,getSymbolDataUri:e=>this._mapProvider.getSymbolDataUri(e),getPatternFill:e=>this._mapProvider.getPatternFill(e),buildFilterEvaluator:e=>this._mapProvider.buildFilterEvaluator(e)}}async init(){await Promise.all([this._registerPatterns(),this._registerSymbols()]),this._datasetRegistry.forEachDataset(e=>this._addLayers(e))}destroy(){this._layersById.forEach(e=>this._map.removeLayer(e)),this._layersById.clear(),this._sourcesById.clear()}async onMapStyleChange(){await Promise.all([this._registerPatterns(),this._registerSymbols()]),this._datasetRegistry.forEachDataset(e=>this._forEachLeafDataset(e,e=>{this._setLayerStyle(e)})),this._reapplyHighlights()}async onMapSizeChange(){const e=this._pixelRatio;await Promise.all([this._registerPatterns(),this._registerSymbols()]),this._pixelRatio===e&&(this._datasetRegistry.forEachDataset(e=>this._forEachLeafDataset(e,e=>{(e.hasPattern||e.hasSymbol)&&this._setLayerStyle(e)})),this._reapplyHighlights())}_reapplyHighlights(){this._mapProvider.reapplyHighlights()}_registerPatternsAndSymbols(e){return Promise.all([this._registerPatterns([e]),this._registerSymbols([e])])}removeDataset(e){const t=this._datasetRegistry.getDataset(e);if(!t)return;t.layerIds.forEach(e=>{const t=this._layersById.get(e);t&&(this._map.removeLayer(t),this._layersById.delete(e))});const{sourceId:n}=t;this._datasetRegistry.topLevelDatasets().some(t=>t.id!==e&&t.sourceId===n)||this._sourcesById.delete(n)}async applyStyle(e){const t=this._datasetRegistry.getDataset(e);t&&(await this._registerPatternsAndSymbols(t),this._forEachLeafDataset(t,e=>{this._layersById.has(e.id)?this._setLayerStyle(e):this._addLayers(e)}))}_setLayerOpacity(e,t){this._layersById.get(e)?.setOpacity(t)}_setLayerVisibility(e,t){this._layersById.get(e)?.setVisible("visible"===t)}applyFeatureFilter(e){const t=this._datasetRegistry.getDataset(e);t&&this._forEachLeafDataset(t,e=>{this._setLayerStyle(e)})}setData(e,t){const n=this._datasetRegistry.getDataset(e),r=n&&this._sourcesById.get(n.sourceId);r&&(r.clear(),t?.features?.length&&r.addFeatures(f(t,n.idStrategy)))}async _registerPatterns(e=this._datasetRegistry.topLevelDatasets()){const t=[];e.forEach(e=>this._forEachLeafDataset(e,e=>{e.hasPattern&&t.push(e.style)})),t.length&&await this._mapProvider.addPatternsToMap(t,this._datasetRegistry.mapStyle?.id,this._patternRegistry,this._pixelRatio)}async _registerSymbols(e=this._datasetRegistry.topLevelDatasets()){const t=[];e.forEach(e=>this._forEachLeafDataset(e,e=>{e.hasSymbol&&t.push(e.style)})),t.length&&await this._mapProvider.addSymbolsToMap(t,this._datasetRegistry.mapStyle,this._symbolRegistry,this._pixelRatio)}_setLayerStyle(e){const t=this._layersById.get(e.id);if(t)try{t.setStyle(g(e,this._styleContext)),e.hasSymbol&&t.set("symbolMeta",e.getSymbolMeta(this._styleContext))}catch(t){i.l.warn(`OpenLayers datasets adapter: failed to build a style for dataset "${e.id}" — ${t.message}`)}}_forEachLeafDataset(e,t){e.hasSublayers?e.sublayers.forEach(e=>this._forEachLeafDataset(e,t)):t(e)}_getOrCreateSource(e){const{sourceId:t}=e;if(this._sourcesById.has(t))return this._sourcesById.get(t);let n;try{n=(e=>{const{source:t,id:n,idStrategy:r}=e;if(!t)return null;if("geojson"===t.type){const e=new Object(function(){var e=new Error("Cannot find module 'ol/source/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}());return"string"==typeof t.data?((e,t,n,r)=>{fetch(t).then(e=>{if(!e.ok)throw new Error(`${e.status} ${e.statusText}`);return e.json()}).then(t=>e.addFeatures(f(t,n))).catch(e=>i.l.warn(`OpenLayers datasets adapter: failed to fetch geojson for dataset "${r}" — ${e.message}`))})(e,t.data,r,n):t.data?.features?.length&&e.addFeatures(f(t.data,r)),e}if("vector"===t.type){const e=Array.isArray(t.tiles)?t.tiles:[t.tiles];return new Object(function(){var e=new Error("Cannot find module 'ol/source/VectorTile.js'");throw e.code="MODULE_NOT_FOUND",e}())({format:new Object(function(){var e=new Error("Cannot find module 'ol/format/MVT.js'");throw e.code="MODULE_NOT_FOUND",e}())({featureClass:Object(function(){var e=new Error("Cannot find module 'ol/Feature.js'");throw e.code="MODULE_NOT_FOUND",e}()),idProperty:r||void 0}),urls:e,projection:l,tileGrid:h})}return i.l.warn(`OpenLayers datasets adapter: unsupported source type "${t.type}" (dataset "${n}")`),null})(e)}catch(t){return i.l.warn(`OpenLayers datasets adapter: failed to build a source for dataset "${e.id}" — ${t.message}`),null}return n&&this._sourcesById.set(t,n),n}_addLayers(e){if(e.hasSublayers)return this._getOrCreateSource(e),void e.sublayers.forEach(e=>this._addLayers(e));if(!e.leafLayerIds.length)return;const t=this._getOrCreateSource(e);if(!t)return;let n;try{n=((e,t,n)=>{const r=t instanceof Object(function(){var e=new Error("Cannot find module 'ol/source/VectorTile.js'");throw e.code="MODULE_NOT_FOUND",e}()),o=new(Object(r?function(){var e=new Error("Cannot find module 'ol/layer/VectorTile.js'");throw e.code="MODULE_NOT_FOUND",e}():function(){var e=new Error("Cannot find module 'ol/layer/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}()))({source:t,style:g(e,n),opacity:e.opacity,visible:"visible"===e.visibility,minZoom:(s=e.minZoom,void 0===s?void 0:s-d),maxZoom:(i=e.maxZoom,void 0===i?void 0:i-d),zIndex:e.hasSymbol?1:0,...r?{renderMode:"vector"}:{}});var i,s;return o.set("layerType",r?"vectorTile":"vector"),o.set("layerId",e.id),e.filter&&o.set("filter",e.filter),e.hasSymbol&&o.set("symbolMeta",e.getSymbolMeta(n)),o})(e,t,this._styleContext)}catch(t){return void i.l.warn(`OpenLayers datasets adapter: failed to build a style for dataset "${e.id}" — ${t.message}`)}this._map.addLayer(n),this._layersById.set(e.id,n)}}},900:(e,t,n)=>{n.d(t,{D:()=>U,l:()=>g,m:()=>K});var r=n(452),o=n(247);const i=e=>{const{datasets:t=[]}=e,n=[],r=t.filter(e=>e.showInMenu||e.sublayers?.some(e=>e.showInMenu)),o=new Map;return r.forEach(e=>{if(e.sublayers?.length){const t=e.sublayers.filter(t=>e.showInMenu?!1!==t.showInMenu:t.showInMenu);if(!1===e.showInMenu&&!t.length)return;const r={id:e.id,groupLabel:e.label,visibleWhen:!0,type:"checkbox",items:t.map(t=>({id:`${e.id}-${t.id}`,label:t.label}))};0===r.items.length&&(delete r.groupLabel,r.items.push({id:e.id,label:e.label})),n.push(r)}else if(e.groupLabel){const t=o.has(e.groupLabel)?o.get(e.groupLabel):{id:e.groupLabel,groupLabel:e.groupLabel,visibleWhen:!0,type:"checkbox",items:[]};o.has(e.groupLabel)||(o.set(e.groupLabel,t),n.push(t)),t.items.push({id:e.id,label:e.label})}else n.push({visibleWhen:!0,type:"checkbox",id:e.id,items:[{id:e.id,label:e.label}]})}),n},s=(e,t)=>e.reduce((e,n)=>{const r=n.items.filter(e=>!t.includes(e.id));return r.length&&e.push({...n,items:r}),e},[]),a={minZoom:6,maxZoom:24,showInKey:!1,showInMenu:!1,visible:!0,style:{stroke:"#d4351c",strokeWidth:2,symbolDescription:"red outline"}},l=["stroke","strokeWidth","strokeDashArray","fill","fillPattern","fillPatternSvgContent","fillPatternForegroundColor","fillPatternBackgroundColor","opacity","symbolDescription","symbol","symbolSvgContent","symbolViewBox","symbolAnchor","symbolSize","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"],c=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"],d=e=>c.some(t=>t in e),u=(e={})=>d(e)?{strokeWidth:a.style.strokeWidth,...e}:{...a.style,...e},p=(e,t)=>{const{id:n}=t,r=(e=>{!0!==e.visible&&!1!==e.visible&&(e.visible="hidden"!==e.visibility);const t={...a,...e,style:{...e.style}};return l.forEach(e=>delete t[e]),t})(t);t.parentId&&("showInKey"in t||delete r.showInKey,"showInMenu"in t||delete r.showInMenu),e[n]=r;const{orderedDatasets:o}=e;o.push(n);const i=t.sublayers?.map(e=>((e,t)=>{const n=`${e}-${t.id}`,r=t.id;return"hidden"!==t.visibility&&(t.visibility="visible"),{...t,id:n,parentId:e,sublayerId:r}})(n,e));if(i?.length){const t=i?.map(e=>e.id),r=i?.reduce(p,{orderedDatasets:o});return e[n].sublayerIds=t,delete e[n].sublayers,{...e,...r,orderedDatasets:o}}return{...e,orderedDatasets:o}},h=e=>{const t=(e.datasets||[]).reduce(p,{orderedDatasets:[]}),{orderedDatasets:n}=t;return delete t.orderedDatasets,{...e,mappedDatasets:t,orderedDatasets:n}},f="[interactive-map]",g={warn:(...e)=>console.warn(f,...e),error:(...e)=>console.error(f,...e)},m={globals:{visible:!0,opacity:1,opacityMode:"dataset"},key:{items:[],hasGroups:!1},mappedDatasets:{},orderedDatasets:[],actionsArray:[],menu:[],menuInitialised:!1},y=(e,t,n,r="not found")=>!!e.mappedDatasets[t]||(g.error(`${n}: Dataset with id '${t}' ${r}`),!1),v=(e,t,n)=>({...n,actionsArray:[...n.actionsArray,{method:e,parameters:t}]}),b={SET_DATASETS:(e,t)=>{const{mappedDatasets:n,orderedDatasets:r}=t;return{...e,mappedDatasets:n,orderedDatasets:r}},ADD_DATASET:(e,t)=>{const{dataset:n,mapStyle:r}=t;if(e.mappedDatasets[n.id])return g.error(`addDataset: Dataset with id '${n.id}' already exists`),e;const{mappedDatasets:o,orderedDatasets:s}=h({datasets:[n]}),a=((e,t)=>{const n=[...e.menu],r=i({datasets:[t]}),o=n.find(e=>e.groupLabel===r[0].groupLabel);return o?o.items.push(...r[0].items):n.push(...r),n})(e,n);return v("addDataset",[n.id,r],{...e,mappedDatasets:{...e.mappedDatasets,...o},orderedDatasets:[...e.orderedDatasets,...s],menu:a})},REMOVE_DATASET:(e,t)=>{const{id:n}=t;if(!y(e,n,"removeDataset"))return e;const r={...e.mappedDatasets},o=[n,...r[n]?.sublayerIds||[]];o.forEach(e=>delete r[e]);const i=e.orderedDatasets.filter(e=>!o.includes(e));return{...e,mappedDatasets:r,orderedDatasets:i,menu:s(e.menu,o)}},SET_DATASET_VISIBILITY:(e,t)=>{const{datasetId:n,visible:r}=t;return y(e,n,"setDatasetVisibility")?e.mappedDatasets[n].visible===r?e:v("applyDatasetVisibility",[n,r],{...e,mappedDatasets:{...e.mappedDatasets,[n]:{...e.mappedDatasets[n],visible:r}}}):e},SET_GLOBAL_VISIBILITY:(e,t)=>{const{visible:n}=t;return v("applyGlobalVisibility",[n],{...e,globals:{...e.globals,visible:n}})},SET_DATASET_STYLE:(e,t)=>{const{datasetId:n,styleChanges:r,mapStyle:o}=t;if(!y(e,n,"setDatasetStyle"))return e;const i={...e.mappedDatasets[n].style,...r},s={...e.mappedDatasets[n],...r,style:i};return v("applyStyle",[n,o],{...e,mappedDatasets:{...e.mappedDatasets,[n]:s}})},SET_OPACITY:(e,t)=>{const{datasetId:n,opacity:r}=t;if(!y(e,n,"setOpacity"))return e;const o={...e.mappedDatasets[n].style,opacity:r},i={...e.mappedDatasets[n],style:o};return v("applyDatasetOpacity",[n],{...e,mappedDatasets:{...e.mappedDatasets,[n]:i}})},SET_GLOBAL_OPACITY:(e,t)=>{const{opacity:n}=t;return v("applyGlobalOpacity",[],{...e,globals:{...e.globals,opacity:n}})},HIDE_FEATURES:(e,t)=>{const{datasetId:n,featureIds:r}=t;if(!y(e,n,"setFeatureVisibility - hideFeatures"))return e;const o={...e.mappedDatasets[n]},i=o.hiddenFeatures||[],s=Array.from(new Set([...i,...r]));return o.hiddenFeatures=s,v("applyFeatureFilter",[n],{...e,mappedDatasets:{...e.mappedDatasets,[n]:o}})},SHOW_FEATURES:(e,t)=>{const{datasetId:n,featureIds:r}=t;if(!y(e,n,"setFeatureVisibility - showFeatures"))return e;const o={...e.mappedDatasets[n]},i=(o.hiddenFeatures||[]).filter(e=>!r.includes(e));return o.hiddenFeatures=i.length?i:[-1],v("applyFeatureFilter",[n],{...e,mappedDatasets:{...e.mappedDatasets,[n]:o}})},REMOVE_ADAPTER_ACTIONS:(e,t)=>t?.length?{...e,actionsArray:e.actionsArray.filter(e=>!t.includes(e))}:e,SET_GLOBAL_STATE:(e,t)=>v("applyGlobalOpacity",[],{...e,globals:{...e.globals,...t}}),SET_MENU:(e,t)=>{const{menu:n}=t;return{...e,menu:n,menuInitialised:!0}}},_={APP_HIDE_PANEL:"app:hidepanel",MAP_SIZE_CHANGE:"map:sizechange",MAP_DATA_CHANGE:"map:datachange"},E=(e,t)=>!(!e||!t||e[2]<t[0]||e[0]>t[2]||e[3]<t[1]||e[1]>t[3]),S=e=>{let t=1/0,n=1/0,r=-1/0,o=-1/0;const i=(e,s)=>{var a;0===s?(a=e,t=Math.min(t,a[0]),n=Math.min(n,a[1]),r=Math.max(r,a[0]),o=Math.max(o,a[1])):e.forEach(e=>i(e,s-1))};switch(e.type){case"Point":i(e.coordinates,0);break;case"LineString":case"MultiPoint":i(e.coordinates,1);break;case"Polygon":case"MultiLineString":i(e.coordinates,2);break;case"MultiPolygon":i(e.coordinates,3);break;case"GeometryCollection":e.geometries.forEach(e=>{const i=S(e);t=Math.min(t,i[0]),n=Math.min(n,i[1]),r=Math.max(r,i[2]),o=Math.max(o,i[3])});break;default:throw new Error(`Unsupported geometry type: ${e.type}`)}return[t,n,r,o]},x=e=>({type:"FeatureCollection",features:Array.from(e.values()).map(e=>e.feature)}),I=({pluginConfig:e,pluginState:t})=>!1!==e.hasMenu&&(t.menuInitialised?t.menu.length>0:(e.datasets||[]).some(e=>e.showInMenu||e.sublayers?.some(e=>e.showInMenu))),w="datasetsLayers";function P({appConfig:e,appState:t,pluginConfig:o,pluginState:s,mapState:a,mapProvider:l,services:c}){const{dispatch:d,datasetRegistry:u}=s,{eventBus:p,symbolRegistry:f,patternRegistry:g}=c,m=Boolean(l?.isBaseMapReady());!function({appConfig:e,appState:t,pluginConfig:n,pluginState:o,services:i}){const{eventBus:s,focusMap:a}=i,l=I({pluginConfig:n,pluginState:o}),c=Boolean(t.openPanels[w]),d=(0,r.li)(null);(0,r.vJ)(()=>{if(l||!c)return;const t=document.getElementById(`${e.id}-panel-${n=w,n?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`);var n;const r=Boolean(t?.contains(document.activeElement));s.emit(_.APP_HIDE_PANEL,w),r&&(d.current=requestAnimationFrame(()=>a()))},[l,c]),(0,r.vJ)(()=>()=>cancelAnimationFrame(d.current),[])}({appConfig:e,appState:t,pluginConfig:o,pluginState:s,services:c});const y=(0,r.li)(s);y.current=s;const v=(0,r.li)(null),b=e=>{const t=l?.datasets;e.length&&t&&(e.forEach(({method:e,parameters:n})=>t[e](...n)),d({type:"REMOVE_ADAPTER_ACTIONS",payload:e}))};return(0,r.vJ)(()=>{m&&(v.current||(async()=>{const e=await(async(e,t,r,o)=>{const i=await(async e=>{switch(e.name){case"MapLibreProvider":{const{default:e}=await n.e(402).then(n.bind(n,932));return e}case"EsriProvider":{const{default:e}=await n.e(402).then(n.bind(n,684));return e}case"OpenLayersProvider":{const{default:e}=await n.e(402).then(n.bind(n,518));return e}default:throw new Error(`No layer adapter available for map provider ${e.name}. Please provide a compatible layer adapter.`)}})(e);return new i(e,t,r,o)})(l,f,g,u);v.current=(({adapter:e,datasetRegistry:t,pluginConfig:n,mapStyle:r,mapProvider:o,events:s,dispatch:a,eventBus:l})=>{const{datasets:c}=n,d=new Map;n.globals&&a({type:"SET_GLOBAL_STATE",payload:n.globals});const{mappedDatasets:u,orderedDatasets:p}=h({datasets:c});e.createDataset&&t.attachCreateDataset(e.createDataset),t.attach(u,p,r);const f=i({datasets:c});l.requestOnce("menu:state",e=>t.attachMenuStateRef(e)),a({type:"SET_MENU",payload:{menu:f}}),a({type:"SET_DATASETS",payload:{mappedDatasets:u,orderedDatasets:p}}),e.init().then(()=>{t.forEachDataset(t=>{if(!t.hasDynamicGeoJSON)return;const{dynamicGeoJSON:n}=t,r=(({dynamicGeoJSON:e,mapProvider:t,onUpdate:n})=>{const r={features:new Map,fetchedBbox:null,currentController:null},o=()=>(async(e,{mapProvider:t,dynamicGeoJSON:n,onUpdate:r})=>{const{url:o,idProperty:i,transformRequest:s,maxFeatures:a,minZoom:l=0}=n,c=t.getZoom();if(c<l)return;const d=(e=>e.getBounds())(t);if(!(e.fetchedBbox&&(u=e.fetchedBbox,p=d,u&&p&&p[0]>=u[0]&&p[1]>=u[1]&&p[2]<=u[2]&&p[3]<=u[3]))){var u,p,h,f;e.currentController&&e.currentController.abort(),e.currentController=new AbortController;try{const t={bbox:d,zoom:c},l=await(async(e,t,n,r)=>{const o=n(e,t),i="string"==typeof o?{url:o}:o,{url:s,headers:a={}}=i,l=await fetch(s,{headers:a,signal:r});if(!l.ok)throw new Error(`Failed to fetch GeoJSON: ${l.status} ${l.statusText}`);const c=await l.json();if("FeatureCollection"===c.type)return c;if("Feature"===c.type)return{type:"FeatureCollection",features:[c]};if(Array.isArray(c))return{type:"FeatureCollection",features:c};throw new Error("Invalid GeoJSON response")})(o,t,s,e.currentController.signal);((e,t,n)=>{const r=Date.now();t.features.forEach(t=>{const o=((e,t)=>t?e.properties?.[t]??e.id:e.id)(t,n);null!=o?e.set(o,{feature:t,bbox:S(t.geometry),lastSeenAt:r}):console.warn("Feature missing ID, skipping:",t)})})(e.features,l,i),e.fetchedBbox=(h=e.fetchedBbox,f=d,h?[Math.min(h[0],f[0]),Math.min(h[1],f[1]),Math.max(h[2],f[2]),Math.max(h[3],f[3])]:[...f]);const u=e.features.size;((e,t,n)=>{if(!n||e.size<=1.2*n)return;const r=n,o=[],i=[];for(const[a,l]of e)E(l.bbox,t)?o.push(a):i.push({id:a,lastSeenAt:l.lastSeenAt});i.sort((e,t)=>e.lastSeenAt-t.lastSeenAt);const s=e.size-r;for(let a=0;a<s&&a<i.length;a++)e.delete(i[a].id);if(e.size>r){const t=e.size-r,n=o.map(t=>({id:t,lastSeenAt:e.get(t).lastSeenAt})).sort((e,t)=>e.lastSeenAt-t.lastSeenAt);for(let r=0;r<t&&r<n.length;r++)e.delete(n[r].id)}})(e.features,d,a),e.features.size<u&&(e.fetchedBbox=d),r(n.id,x(e.features))}catch(e){if("AbortError"===e.name)return;console.error(`Failed to fetch dynamic GeoJSON for ${n.id}:`,e)}}})(r,{mapProvider:t,dynamicGeoJSON:e,onUpdate:n}),i=(e=>{let t;const n=(...n)=>{clearTimeout(t),t=setTimeout(()=>e(...n),200)};return n.cancel=()=>{clearTimeout(t),t=null},n})(o),s=()=>{i()};return t.map.on("moveend",s),o(),{destroy(){var e,n;e=t.map,n=s,(e.off||e.un).call(e,"moveend",n),i.cancel(),r.currentController&&r.currentController.abort()},clear(){r.features.clear(),r.fetchedBbox=null,n(e.id,{type:"FeatureCollection",features:[]})},refresh(){r.features.clear(),r.fetchedBbox=null,o()},getFeatureCount:()=>r.features.size,reapply(){r.features.size>0&&n(e.id,x(r.features))}}})({dynamicGeoJSON:n,mapProvider:o,onUpdate:(t,n)=>e.setData(t,n)});d.set(t.id,r)}),e.attachDynamicSources(d),l.emit("datasets:ready")});const g=()=>{e.onMapSizeChange()};l.on(s.MAP_SIZE_CHANGE,g);const m=l.emitWhenRequested("datasets:registry",t);return l.on("menu:changed",n=>{t.invalidateKeyItemsOnMenuStateChange(n),e.applyGlobalVisibility()}),{remove(){l.off(s.MAP_SIZE_CHANGE,g),m(),d.forEach(e=>e.destroy()),d.clear(),e.destroy()},refreshDataset(e){d.get(e)?.refresh()},clearDatasetCache(e){d.get(e)?.clear()},getFeatureCount:e=>d.get(e)?.getFeatureCount()??null}})({adapter:e,datasetRegistry:u,pluginConfig:o,mapStyle:a.mapStyle,mapProvider:l,events:_,dispatch:d,eventBus:p}),l.datasets=e,b(y.current.actionsArray)})())},[m]),(0,r.vJ)(()=>{u.attach(s.mappedDatasets,s.orderedDatasets),p.emit("datasets:changed")},[s.mappedDatasets,s.orderedDatasets]),(0,r.vJ)(()=>{u.attachMapStyle(a.mapStyle);const e=l?.datasets;e?.onMapStyleChange&&Promise.resolve(e.onMapStyleChange()).then(()=>{p.emit(_.MAP_DATA_CHANGE)})},[a.mapStyle]),(0,r.vJ)(()=>u.attachGlobals(s.globals),[s.globals]),(0,r.vJ)(()=>b(s.actionsArray),[s.actionsArray]),(0,r.vJ)(()=>()=>{v.current&&(v.current.remove(),v.current=null,l.datasets=null)},[]),null}const C=({pluginState:{dispatch:e}},t,n={})=>{const{datasetId:r,sublayerId:o}=n,i=o?`${r}-${o}`:r;e(i?{type:"SET_DATASET_VISIBILITY",payload:{datasetId:i,visible:t}}:{type:"SET_GLOBAL_VISIBILITY",payload:{visible:t}})},T=({menuGroupItem:e,datasetRegistry:t,onChange:n})=>{const r=t.getDataset(e.id);if(!r)return null;const i=r.isSublayer?r.parentId:r.id,s=r.isSublayer?r.id:void 0,a="im-c-datasets-layers__item govuk-checkboxes govuk-checkboxes--small"+(r.visible?"":" im-c-datasets-layers__item--checked");return(0,o.Y)("div",{className:a,"data-module":"govuk-checkboxes",children:(0,o.FD)("div",{className:"govuk-checkboxes__item",children:[(0,o.Y)("input",{className:"govuk-checkboxes__input",id:r.id,"data-dataset-id":i,"data-sublayer-id":s,name:"layers",type:"checkbox",value:r.id,checked:r.isLocallyVisible,onChange:n}),(0,o.Y)("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:r.id,children:r.label})]})},r.id)},M=({menuGroup:e,children:t})=>e.groupLabel?(0,o.Y)("div",{className:"govuk-form-group im-c-datasets-layers-group",children:(0,o.FD)("fieldset",{className:"im-c-datasets-layers-group__fieldset",children:[(0,o.Y)("legend",{className:"im-c-datasets-layers-group__legend",children:(0,o.Y)("h3",{children:e.groupLabel})}),t]})},e.id):(0,o.Y)(o.FK,{children:t}),L=({pluginState:{dispatch:e},mapState:t},n)=>{e({type:"ADD_DATASET",payload:{dataset:n,mapStyle:t.mapStyle}})},A=({pluginState:{dispatch:e},mapProvider:t},n)=>{t.datasets?.removeDataset(n),e({type:"REMOVE_DATASET",payload:{id:n}})},O=({pluginState:{dispatch:e,datasetRegistry:t}},n,r,{datasetId:o=null}={})=>{if(o){const e=t.getDataset(o);!e||e.idProperty||e.generateIds||g.warn(`setFeatureVisibility: Dataset "${o}" has no idProperty or generateIds configured. Features may not be matched correctly. Add idProperty to match by a feature property, or add generateIds: true to use auto-generated IDs.`)}e({type:n?"SHOW_FEATURES":"HIDE_FEATURES",payload:{datasetId:o,featureIds:r}})},k=({pluginState:{dispatch:e},mapState:t},n,{datasetId:r,sublayerId:o}={})=>{e({type:"SET_DATASET_STYLE",payload:{datasetId:r=o?`${r}-${o}`:r,styleChanges:n,mapStyle:t.mapStyle}})},D=({pluginState:{datasetRegistry:e}},{datasetId:t,sublayerId:n}={})=>{t=n?`${t}-${n}`:t;const r=e.getDataset(t);return r?r.style:(g.warn(`getStyle: Dataset with id ${t} not found`),null)},R=({pluginState:{dispatch:e}},t,n={})=>{const{datasetId:r,sublayerId:o}=n,i=o?`${r}-${o}`:r;e(i?{type:"SET_OPACITY",payload:{datasetId:i,opacity:t}}:{type:"SET_GLOBAL_OPACITY",payload:{opacity:t}})},N=({pluginState:{globals:e,datasetRegistry:t}},n={})=>{const{datasetId:r,sublayerId:o}=n,i=o?`${r}-${o}`:r;if(i){const e=t.getDataset(i);return e?e.opacity??null:(g.warn(`getOpacity: Dataset with id ${i} not found`),null)}return e.opacity??null},F=({pluginState:{datasetRegistry:e},mapProvider:t},n,{datasetId:r})=>{const o=e.getDataset(r);o?o?.tiles?g.warn(`setData called on vector tile dataset "${r}" — has no effect`):t.datasets?.setData(r,n):g.warn(`setData: Dataset with id ${r} not found`)},V=({pluginState:{dispatch:e}},t)=>{const{opacityMode:n}=t,r={};let o=!1;n&&(["dataset","global","multiply"].includes(n)?(o=!0,r.opacityMode=n):g.warn(`Ignoring invalid opacityMode: ${n}. Must be one of 'dataset', 'global' or 'multiply'.`)),o?e({type:"SET_GLOBAL_STATE",payload:r}):g.warn("setGlobals: requires a valid value for opacityMode to be set")};class B{constructor(e){this.id=e.id,this.url=e.url,this.transformRequest=e.transformRequest,this.maxFeatures=e.maxFeatures,this.minZoom=e.minZoom,this.idProperty=e.idProperty,this.hiddenFeaturesIdExpression=["to-string",["get",this.idProperty]],this.sourceId=`geojson-dynamic-${this.id}`,this.source={type:"geojson",data:{type:"FeatureCollection",features:[]},...this.idProperty?{promoteId:this.idProperty}:{generateId:!0}}}}class U{constructor(e,t){this._datasetDefinition=e,this._datasetRegistry=t}get id(){return this._datasetDefinition.id}get label(){return this._datasetDefinition.label}get hasSymbol(){return!(this.hasSublayers||(e=this.style,!e?.symbol&&!e?.symbolSvgContent));var e}get hasPattern(){return!(this.hasSublayers||this.hasSymbol||(e=this.style,!e.fillPattern&&!e.fillPatternSvgContent));var e}get hasFill(){return!this.hasSublayers&&!this.hasSymbol&&(this.hasPattern||this.style?.fill&&"transparent"!==this.style?.fill)}get hasStroke(){return!this.hasSublayers&&!this.hasSymbol&&Boolean(this.style?.stroke)}get tiles(){return this._datasetDefinition.tiles}get geojson(){return this._datasetDefinition.geojson}get idProperty(){return this._datasetDefinition.idProperty}get generateIds(){return this._datasetDefinition.generateIds}get parentId(){return this._datasetDefinition.parentId}get minZoom(){return this._datasetDefinition.minZoom||this.parent?.minZoom}get maxZoom(){return this._datasetDefinition.maxZoom||this.parent?.maxZoom}get type(){return this._datasetDefinition.type||this.parent?.type}get showInKey(){const e=this._datasetDefinition.showInKey;return void 0!==e?e:this.parent?.showInKey??!1}get visibleWhen(){return void 0===this._datasetDefinition.visibleWhen?this.parent?.visibleWhen:this._datasetDefinition.visibleWhen}get groupLabel(){return this._datasetDefinition.groupLabel||this.parent?.groupLabel||this.parent?.label}get groupId(){return this._datasetDefinition.groupId||this.parent?.groupId||(this.groupLabel?this.groupLabel.toLowerCase().replace(/\s+/g,"-"):null)}get opacity(){const e=this.style?.opacity,t=this.parent?.style?.opacity;return((e,t,n)=>{switch(e.opacityMode){case"global":return e.opacity;case"multiply":return((e,t=1,n=1)=>Math.round(100*(t*n*e.opacity+Number.EPSILON))/100)(e,t,n);default:return((e,t,n)=>void 0===t?void 0===n?e.opacity:n:t)(e,t,n)}})(this._datasetRegistry.globals,e,t)}get hasDynamicGeoJSON(){return Boolean(this._datasetDefinition.dynamicGeoJSON)}get dynamicGeoJSON(){return new B({...this._datasetDefinition.dynamicGeoJSON,id:this.id,minZoom:this.minZoom})}get hiddenFeatures(){return this._datasetDefinition.hiddenFeatures}get hasHiddenFeatures(){return Boolean(this.hiddenFeatures?.length>0||this.parent?.hasHiddenFeatures)}get filter(){return null}get isHiddenByInheritance(){return this.isSublayer?!this.parent?.visible:!this._datasetRegistry.globals.visible}get isLocallyVisible(){return!!this.isVisible||this._datasetDefinition.visible}get visible(){return this.isSublayer?this._datasetDefinition.visible&&this.parent?.visible:this._datasetDefinition.visible&&this._datasetRegistry.globals.visible}get esriStyleLayerId(){return this._datasetDefinition.esriStyleLayerId}get visibility(){const{visible:e,visibleWhen:t}=this;return e&&t?this._datasetRegistry.isVisibleWhen(t)?"visible":"none":e?"visible":"none"}get keyVisibility(){return this.showInKey&&"visible"===this.visibility}get symbolAnchor(){return this.style?.symbolAnchor?this.style.symbolAnchor:this.parent?.symbolAnchor}get sourceLayer(){return this.isSublayer?this.parent.sourceLayer:this.tiles?this._datasetDefinition.sourceLayer:void 0}get isSublayer(){return Boolean(this._datasetDefinition.parentId)}get hasSublayers(){return this._datasetDefinition.sublayerIds?.length>0}get sublayerIds(){return this._datasetDefinition.sublayerIds}get sublayers(){const{sublayerIds:e}=this;return e?e.map(e=>this._datasetRegistry.getDataset(e)):[]}get parent(){if(this._datasetDefinition.parentId)return this._datasetRegistry.getDataset(this._datasetDefinition.parentId)}get inheritedStyle(){const e=this._datasetDefinition.style||{},t=this.parent;return t?{...t.inheritedStyle,opacity:void 0,...e}:e}get style(){return{...u(this.inheritedStyle),symbolDescription:this.symbolDescription}}get hasCustomVisualStyle(){return d(this._datasetDefinition.style||{})}get symbolDescription(){return this._datasetDefinition.style?.symbolDescription?this._datasetDefinition.style.symbolDescription:this.hasCustomVisualStyle?void 0:this.parent?this.parent.symbolDescription:a.style.symbolDescription}get patternConfigs(){const e=this.hasPattern?[this.style]:[];return this.hasSublayers?[...e,...this.sublayers.flatMap(e=>e.patternConfigs)]:e}get symbolConfigs(){const e=this.hasSymbol?[this.style]:[];return this.hasSublayers?[...e,...this.sublayers.flatMap(e=>e.symbolConfigs)]:e}get keyDefinition(){return{id:this.id,type:"dataset",label:this.label,hasSymbol:this.hasSymbol,hasPattern:this.hasPattern,style:this.style,symbolDescription:this.symbolDescription}}}class G{constructor(){this.idToDefinitionMap=new Map,this.definitionToInstanceMap=new Map}add(e){this.idToDefinitionMap.set(e.id,e._datasetDefinition),this.definitionToInstanceMap.set(e._datasetDefinition,e)}invalidateDataset(e){const t=this.idToDefinitionMap.get(e.id);[t.id,...t?.sublayerIds||[]].forEach(e=>{const t=this.idToDefinitionMap.get(e);this.definitionToInstanceMap.delete(t),this.idToDefinitionMap.delete(e)})}invalidateChangedDatasets(e){e.forEach(e=>{const t=this.idToDefinitionMap.get(e.id);if(t&&t!==e){const e=this.definitionToInstanceMap.get(t);this.invalidateDataset(e.isSublayer&&e.parent?e.parent:e)}})}getByDefinition(e){return this.definitionToInstanceMap.get(e)}}const j=(e,t={})=>{for(const[n,r]of Object.entries(e)){const e=t[n];if(!r.includes(e))return!1}return!0},H=(e,t)=>(Array.isArray(e)?e:[e]).includes(t),$={attach(e,t,n){this._datasets=e,this._orderedDatasets=t,this.attachMapStyle(n),this._invalidateChangedDatasets()},_invalidateCache(){this._definitionCache=new G},_invalidateChangedDatasets(){this._datasets?this._definitionCache.invalidateChangedDatasets(Object.values(this._datasets)):this._invalidateCache()},attachCreateDataset(e){this._createDataset=e},_createDataset:(e,t)=>((e,t)=>new U(e,t))(e,t),attachMapStyle(e){e&&(this._mapStyle=e)},get mapStyle(){return this._mapStyle},attachGlobals(e){e&&(this._globals=e)},get globals(){return this._globals},attachMenuStateRef(e){this._menuStateRef=e},isVisibleWhen(e){return((e,{mapStyleId:t,menuState:n}={})=>{if(null==e)return!0;if("boolean"==typeof e)return e;if("object"==typeof e){for(const[r,o]of Object.entries(e)){if("mapStyleId"===r&&!H(o,t))return!1;if("menu"===r&&!j(o,n))return!1}return!0}return!0})(e,{mapStyleId:this._mapStyle?.id,menuState:this._menuStateRef?.current?.menuState})},get datasets(){return this._datasets},getDataset(e){const t=this.datasets[e];if(!t)return;const n=this._definitionCache.getByDefinition(t);if(n)return n;const r=this._createDataset(t,this);return this._definitionCache.add(r),r.isSublayer&&this.getDataset(r.parentId),r},forEach(e){this._orderedDatasets.forEach(t=>e(this.getDataset(t)))},forEachDataset(e){Object.values(this.datasets).filter(e=>!e.parentId).forEach(t=>e(this.getDataset(t.id)))},topLevelDatasets(){return Object.values(this.datasets).filter(e=>!e.parentId).map(e=>this.getDataset(e.id))},getPatternAndSymbolConfigs(){return this.topLevelDatasets().reduce((e,t)=>({...e,patternConfigs:[...e.patternConfigs,...t.patternConfigs],symbolConfigs:[...e.symbolConfigs,...t.symbolConfigs]}),{patternConfigs:[],symbolConfigs:[]})},invalidateKeyItemsOnMenuStateChange(e){e!==this._lastMenuState&&(this._lastMenuState=e,this._lastKeyItemsDatasets=null)},keyItems(){if(this.datasets===this._lastKeyItemsDatasets)return this._lastKeyItems;this._lastKeyItemsDatasets=this.datasets;const e=[],t=new Map;this.forEach(n=>{if(!n.keyVisibility)return;if(!(n.hasSublayers||n.groupId||n.groupLabel))return void e.push({type:"flat",id:n.id,keyDefinition:n.keyDefinition});const r=n.groupId,o=((n,r)=>{if(t.has(r))return t.get(r);const o={type:"group",id:r,groupLabel:n,keyDefinitions:[]};return t.set(r,o),e.push(o),o})(n.groupLabel||r||n.label,r);n.hasSublayers||o.keyDefinitions.push(n.keyDefinition)});const n=e.filter(e=>"flat"===e.type||Boolean(e.keyDefinitions?.length)),r=n.some(e=>"group"===e.type);return this._lastKeyItems={items:n,hasGroups:r},this._lastKeyItems}},Y={id:"datasetsLayers",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:({pluginState:e})=>{const{menu:t=[]}=e,n=t=>{const{value:n,checked:r}=t.target;C({pluginState:e},r,{datasetId:n})},r=t.some(e=>e.groupLabel);return(0,o.Y)("div",{className:"im-c-datasets-layers"+(r?" im-c-datasets-layers--has-groups":""),children:t.map(t=>(0,o.FD)(M,{menuGroup:t,children:[" ",t.items.map(t=>(0,o.Y)(T,{menuGroupItem:t,datasetRegistry:e.datasetRegistry,onChange:n},t.id))]},t.id))})}},z={id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",excludeWhen:e=>!I(e),iconId:"layers",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}};var K=Object.freeze({__proto__:null,createManifest:({hasMenu:e}={})=>({InitComponent:P,reducer:{initialState:{...m,datasetRegistry:Object.assign(Object.create($),{_definitionCache:new G,_globals:{},_menuStateRef:{},_lastMenuState:{},_lastKeyItems:{}})},actions:b},panels:!1===e?[]:[Y],buttons:!1===e?[]:[z],icons:[{id:"layers",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addDataset:L,removeDataset:A,setDatasetVisibility:C,setFeatureVisibility:O,setStyle:k,getStyle:D,setOpacity:R,getOpacity:N,setData:F,setGlobals:V}})})},964:(e,t,n)=>{n.d(t,{L:()=>o,g:()=>r});const r=(e,t)=>e?"string"==typeof e?e.trim():"object"==typeof e?t&&e[t]?e[t]:Object.values(e)[0]??null:null:null;class o{attachDynamicSources(e){this._dynamicSources=e}get dynamicSources(){return this._dynamicSources}}},982:(e,t,n)=>{n.d(t,{M:()=>s,a:()=>a});var r=n(900),o=n(964);const i=e=>{let t=0,n=2166136261;for(const r of e){const e=r.codePointAt(0);t=Math.imul(t,31)+e,n=Math.imul(n^e,16777619)}return(t>>>0).toString(36)+(n>>>0).toString(36)};class s extends r.D{get _hiddenFeaturesIdExpression(){return this.hasDynamicGeoJSON?this.dynamicGeoJSON.hiddenFeaturesIdExpression:this.idProperty?["to-string",["get",this.idProperty]]:["to-string",["id"]]}get _hiddenFeaturesFilter(){const e=this.hiddenFeatures?.filter(e=>-1!==e);return e?.length?["!",["in",this._hiddenFeaturesIdExpression,["literal",e.map(String)]]]:null}get filter(){const e=["all"];this.parent?.filter&&e.push(this.parent.filter),this._datasetDefinition.filter&&e.push(this._datasetDefinition.filter);const t=this._hiddenFeaturesFilter;return t&&e.push(t),1===e.length?null:e.length>2?e:e[1]}get leafLayerIds(){return[]}get layerIds(){return this.hasSublayers?this.sublayers.flatMap(e=>e.layerIds).filter(Boolean):this.leafLayerIds}getLayersWithValue(e,t=!1){const n=[];if(!1===t||this[t]){const t=this.leafLayerIds;if(t.length){const r=this[e];n.push({layerIds:t,[e]:r})}}return this.hasSublayers&&this.sublayers.forEach(r=>{if(!1===t||r[t]){const[t]=r.getLayersWithValue(e);t&&n.push(t)}}),n}getLayersWithVisibility(){return this.getLayersWithValue("visibility")}getLayersWithOpacity(){return this.getLayersWithValue("opacity")}getLayersWithFilters(){return this.getLayersWithValue("filter","hasHiddenFeatures")}get sourceId(){if(this.isSublayer)return this.parent.sourceId;if(this.hasDynamicGeoJSON)return this.dynamicGeoJSON.sourceId;if(this.tiles){const e=Array.isArray(this.tiles)?this.tiles.join(","):this.tiles;return`tiles-${i(e)}`}return this.geojson?"string"==typeof this.geojson?`geojson-${i(this.geojson)}`:`geojson-${this.id}`:`source-${this.id}`}}class a extends o.L{constructor(e,t,n,r){super(),this._mapProvider=e,this._map=e.map,this._symbolRegistry=t,this._patternRegistry=n,this._datasetRegistry=r}get _pixelRatio(){return this._map.getPixelRatio()}async addDataset(e){const t=this._datasetRegistry.getDataset(e);t&&(await this._registerPatternsAndSymbols(t),this._addLayers(t))}applyDatasetOpacity(e){const t=this._datasetRegistry.getDataset(e);t&&this._applyRegistryDatasetOpacity(t)}_applyRegistryDatasetOpacity(e){e.getLayersWithOpacity().forEach(({layerIds:e,opacity:t})=>{e.forEach(e=>this._setLayerOpacity(e,t))})}applyGlobalOpacity(){this._datasetRegistry.forEachDataset(e=>this._applyRegistryDatasetOpacity(e))}applyDatasetVisibility(e){const t=this._datasetRegistry.getDataset(e);t&&this._applyRegistryDatasetVisibility(t)}_applyRegistryDatasetVisibility(e){e.getLayersWithVisibility().forEach(({layerIds:e,visibility:t})=>{e.forEach(e=>this._setLayerVisibility(e,t))})}applyGlobalVisibility(){this._datasetRegistry.forEachDataset(e=>this._applyRegistryDatasetVisibility(e))}}},278:(e,t,n)=>{n.d(t,{MaplibreDrawAdapter:()=>co});var r=n(666),o=n(106);n(452),n(247);const i={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},s={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},a={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},l={POLYGON:"polygon",LINE:"line_string",POINT:"point"},c={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},d={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},u={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},p={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},h={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},f={ACTIVE:"true",INACTIVE:"false"},g=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"];var m=Object.freeze({__proto__:null,LAT_MAX:90,LAT_MIN:-90,LAT_RENDERED_MAX:85,LAT_RENDERED_MIN:-85,LNG_MAX:270,LNG_MIN:-270,activeStates:f,classes:i,cursors:a,events:u,geojsonTypes:c,interactions:g,meta:h,modes:d,sources:s,types:l,updateActions:p});function y(e){return function(t){const n=t.featureTarget;return!!n&&!!n.properties&&n.properties.meta===e}}function v(e){return!!e.originalEvent&&!!e.originalEvent.shiftKey&&0===e.originalEvent.button}function b(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===f.ACTIVE&&e.featureTarget.properties.meta===h.FEATURE}function _(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===f.INACTIVE&&e.featureTarget.properties.meta===h.FEATURE}function E(e){return void 0===e.featureTarget}function S(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.meta===h.FEATURE}function x(e){const t=e.featureTarget;return!!t&&!!t.properties&&t.properties.meta===h.VERTEX}function I(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function w(e){return"Escape"===e.key||27===e.keyCode}function P(e){return"Enter"===e.key||13===e.keyCode}function C(e){return"Backspace"===e.key||8===e.keyCode}function T(e){return"Delete"===e.key||46===e.keyCode}function M(e){return"1"===e.key||49===e.keyCode}function L(e){return"2"===e.key||50===e.keyCode}function A(e){return"3"===e.key||51===e.keyCode}function O(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}var k=Object.freeze({__proto__:null,isActiveFeature:b,isBackspaceKey:C,isDeleteKey:T,isDigit1Key:M,isDigit2Key:L,isDigit3Key:A,isDigitKey:O,isEnterKey:P,isEscapeKey:w,isFeature:S,isInactiveFeature:_,isOfMetaType:y,isShiftDown:I,isShiftMousedown:v,isTrue:function(){return!0},isVertex:x,noTarget:E});function D(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var R,N,F={},V={},B=D(function(){if(N)return F;N=1;var e=(R||(R=1,V.RADIUS=6378137,V.FLATTENING=1/298.257223563,V.POLAR_RADIUS=6356752.3142),V);function t(e){var t=0;if(e&&e.length>0){t+=Math.abs(n(e[0]));for(var r=1;r<e.length;r++)t-=Math.abs(n(e[r]))}return t}function n(t){var n,o,i,s,a,l,c=0,d=t.length;if(d>2){for(l=0;l<d;l++)l===d-2?(i=d-2,s=d-1,a=0):l===d-1?(i=d-1,s=0,a=1):(i=l,s=l+1,a=l+2),n=t[i],o=t[s],c+=(r(t[a][0])-r(n[0]))*Math.sin(r(o[1]));c=c*e.RADIUS*e.RADIUS/2}return c}function r(e){return e*Math.PI/180}return F.geometry=function e(n){var r,o=0;switch(n.type){case"Polygon":return t(n.coordinates);case"MultiPolygon":for(r=0;r<n.coordinates.length;r++)o+=t(n.coordinates[r]);return o;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(r=0;r<n.geometries.length;r++)o+=e(n.geometries[r]);return o}},F.ring=n,F}());const U={Point:0,LineString:1,MultiLineString:1,Polygon:2};function G(e,t){const n=U[e.geometry.type]-U[t.geometry.type];return 0===n&&e.geometry.type===c.POLYGON?e.area-t.area:n}function j(e){return e.map(e=>(e.geometry.type===c.POLYGON&&(e.area=B.geometry({type:c.FEATURE,property:{},geometry:e.geometry})),e)).sort(G).map(e=>(delete e.area,e))}function H(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]}function $(e){if(this._items={},this._nums={},this._length=e?e.length:0,e)for(let t=0,n=e.length;t<n;t++)this.add(e[t]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}$.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},$.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},$.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},$.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((e,t)=>e.v-t.v).map(e=>e.k)},$.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const Y=[h.FEATURE,h.MIDPOINT,h.VERTEX];var z={click:function(e,t,n){return K(e,t,n,n.options.clickBuffer)},touch:function(e,t,n){return K(e,t,n,n.options.touchBuffer)}};function K(e,t,n,r){if(null===n.map)return[];const o=e?H(e,r):t,i={};n.options.styles&&(i.layers=n.options.styles.map(e=>e.id).filter(e=>null!=n.map.getLayer(e)));const s=n.map.queryRenderedFeatures(o,i).filter(e=>-1!==Y.indexOf(e.properties.meta)),a=new $,l=[];return s.forEach(e=>{const t=e.properties.id;a.has(t)||(a.add(t),l.push(e))}),j(l)}function W(e,t){const n=z.click(e,null,t),r={mouse:a.NONE};return n[0]&&(r.mouse=n[0].properties.active===f.ACTIVE?a.MOVE:a.POINTER,r.feature=n[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(r.mouse=a.ADD),t.ui.queueMapClasses(r),t.ui.updateMapClasses(),n[0]}function J(e,t){const n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function q(e,t,n={}){const r=null!=n.fineTolerance?n.fineTolerance:4,o=null!=n.grossTolerance?n.grossTolerance:12,i=null!=n.interval?n.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;const s=J(e.point,t.point);return s<r||s<o&&t.time-e.time<i}function X(e,t,n={}){const r=null!=n.tolerance?n.tolerance:25,o=null!=n.interval?n.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,J(e.point,t.point)<r&&t.time-e.time<o}const Z=function(e,t){const n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},r={on(e,t,r){if(void 0===n[e])throw new Error(`Invalid event type: ${e}`);n[e].push({selector:t,fn:r})},render(e){t.store.featureChanged(e)}},o=function(e,o){const i=n[e];let s=i.length;for(;s--;){const e=i[s];if(e.selector(o)){e.fn.call(r,o)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(r),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(e){o("drag",e)},click(e){o("click",e)},mousemove(e){o("mousemove",e)},mousedown(e){o("mousedown",e)},mouseup(e){o("mouseup",e)},mouseout(e){o("mouseout",e)},keydown(e){o("keydown",e)},keyup(e){o("keyup",e)},touchstart(e){o("touchstart",e)},touchmove(e){o("touchmove",e)},touchend(e){o("touchend",e)},tap(e){o("tap",e)}}},Q=((e,t=21)=>(n=t)=>{let r="",o=0|n;for(;o--;)r+=e[Math.random()*e.length|0];return r})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function ee(){return Q()}const te=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||ee(),this.type=t.geometry.type};te.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},te.prototype.incomingCoords=function(e){this.setCoordinates(e)},te.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},te.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},te.prototype.setProperty=function(e,t){this.properties[e]=t},te.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:c.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},te.prototype.internal=function(e){const t={id:this.id,meta:h.FEATURE,"meta:type":this.type,active:f.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const n in this.properties)t[`user_${n}`]=this.properties[n];return{type:c.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const ne=function(e,t){te.call(this,e,t)};(ne.prototype=Object.create(te.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},ne.prototype.updateCoordinate=function(e,t,n){this.coordinates=3===arguments.length?[t,n]:[e,t],this.changed()},ne.prototype.getCoordinate=function(){return this.getCoordinates()};const re=function(e,t){te.call(this,e,t)};(re.prototype=Object.create(te.prototype)).isValid=function(){return this.coordinates.length>1},re.prototype.addCoordinate=function(e,t,n){this.changed();const r=parseInt(e,10);this.coordinates.splice(r,0,[t,n])},re.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},re.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},re.prototype.updateCoordinate=function(e,t,n){const r=parseInt(e,10);this.coordinates[r]=[t,n],this.changed()};const oe=function(e,t){te.call(this,e,t),this.coordinates=this.coordinates.map(e=>e.slice(0,-1))};(oe.prototype=Object.create(te.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},oe.prototype.incomingCoords=function(e){this.coordinates=e.map(e=>e.slice(0,-1)),this.changed()},oe.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},oe.prototype.addCoordinate=function(e,t,n){this.changed();const r=e.split(".").map(e=>parseInt(e,10));this.coordinates[r[0]].splice(r[1],0,[t,n])},oe.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(e=>parseInt(e,10)),n=this.coordinates[t[0]];n&&(n.splice(t[1],1),n.length<3&&this.coordinates.splice(t[0],1))},oe.prototype.getCoordinate=function(e){const t=e.split(".").map(e=>parseInt(e,10)),n=this.coordinates[t[0]];return JSON.parse(JSON.stringify(n[t[1]]))},oe.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},oe.prototype.updateCoordinate=function(e,t,n){this.changed();const r=e.split("."),o=parseInt(r[0],10),i=parseInt(r[1],10);void 0===this.coordinates[o]&&(this.coordinates[o]=[]),this.coordinates[o][i]=[t,n]};const ie={MultiPoint:ne,MultiLineString:re,MultiPolygon:oe},se=(e,t,n,r,o)=>{const i=n.split("."),s=parseInt(i[0],10),a=i[1]?i.slice(1).join("."):null;return e[s][t](a,r,o)},ae=function(e,t){if(te.call(this,e,t),delete this.coordinates,this.model=ie[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};function le(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}(ae.prototype=Object.create(te.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(e=>new t(this.ctx,{id:ee(),type:c.FEATURE,properties:{},geometry:{coordinates:e,type:this.type.replace("Multi","")}}))},ae.prototype.isValid=function(){return this.features.every(e=>e.isValid())},ae.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},ae.prototype.getCoordinate=function(e){return se(this.features,"getCoordinate",e)},ae.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===c.POLYGON?e.getCoordinates():e.coordinates)))},ae.prototype.updateCoordinate=function(e,t,n){se(this.features,"updateCoordinate",e,t,n),this.changed()},ae.prototype.addCoordinate=function(e,t,n){se(this.features,"addCoordinate",e,t,n),this.changed()},ae.prototype.removeCoordinate=function(e){se(this.features,"removeCoordinate",e),this.changed()},ae.prototype.getFeatures=function(){return this.features},le.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},le.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((e,t)=>(void 0===e[t.feature_id]&&(e[t.feature_id]=!0,this._ctx.store.get(t.feature_id).changed()),e),{})},le.prototype.getSelected=function(){return this._ctx.store.getSelected()},le.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},le.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},le.prototype.getFeature=function(e){return this._ctx.store.get(e)},le.prototype.select=function(e){return this._ctx.store.select(e)},le.prototype.deselect=function(e){return this._ctx.store.deselect(e)},le.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},le.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},le.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},le.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},le.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)},le.prototype.changeMode=function(e,t={},n={}){return this._ctx.events.changeMode(e,t,n)},le.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},le.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},le.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},le.prototype.featuresAt=function(e,t,n="click"){if("click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return z[n](e,t,this._ctx)},le.prototype.newFeature=function(e){const t=e.geometry.type;return t===c.POINT?new ne(this._ctx,e):t===c.LINE_STRING?new re(this._ctx,e):t===c.POLYGON?new oe(this._ctx,e):new ae(this._ctx,e)},le.prototype.isInstanceOf=function(e,t){if(e===c.POINT)return t instanceof ne;if(e===c.LINE_STRING)return t instanceof re;if(e===c.POLYGON)return t instanceof oe;if("MultiFeature"===e)return t instanceof ae;throw new Error(`Unknown feature class: ${e}`)},le.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)},le.prototype.onSetup=function(){},le.prototype.onDrag=function(){},le.prototype.onClick=function(){},le.prototype.onMouseMove=function(){},le.prototype.onMouseDown=function(){},le.prototype.onMouseUp=function(){},le.prototype.onMouseOut=function(){},le.prototype.onKeyUp=function(){},le.prototype.onKeyDown=function(){},le.prototype.onTouchStart=function(){},le.prototype.onTouchMove=function(){},le.prototype.onTouchEnd=function(){},le.prototype.onTap=function(){},le.prototype.onStop=function(){},le.prototype.onTrash=function(){},le.prototype.onCombineFeature=function(){},le.prototype.onUncombineFeature=function(){},le.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const ce={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},de=Object.keys(ce);function ue(e){return[].concat(e).filter(e=>void 0!==e)}function pe(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(s.HOT))return l();const t=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:t});let n=[],r=[];e.isDirty?r=e.getAllIds():(n=e.getChangedIds().filter(t=>void 0!==e.get(t)),r=e.sources.hot.filter(t=>t.properties.id&&-1===n.indexOf(t.properties.id)&&void 0!==e.get(t.properties.id)).map(e=>e.properties.id)),e.sources.hot=[];const o=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(e=>{const t=e.properties.id||e.properties.parent;return-1===n.indexOf(t)});const i=o!==e.sources.cold.length||r.length>0;function a(n,r){const o=e.get(n).internal(t);e.ctx.events.currentModeRender(o,n=>{n.properties.mode=t,e.sources[r].push(n)})}function l(){e.isDirty=!1,e.clearChangedIds()}n.forEach(e=>a(e,"hot")),r.forEach(e=>a(e,"cold")),i&&e.ctx.map.getSource(s.COLD).setData({type:c.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(s.HOT).setData({type:c.FEATURE_COLLECTION,features:e.sources.hot}),l()}function he(e){let t;this._features={},this._featureIds=new $,this._selectedFeatureIds=new $,this._selectedCoordinates=[],this._changedFeatureIds=new $,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,pe.call(this),this._emitSelectionChange&&(this.ctx.events.fire(u.SELECTION_CHANGE,{features:this.getSelected().map(e=>e.toGeoJSON()),points:this.getSelectedCoordinates().map(e=>({type:c.FEATURE,properties:{},geometry:{type:c.POINT,coordinates:e.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(u.RENDER,{})}))},this.isDirty=!1}function fe(e,t={}){const n=e._selectedCoordinates.filter(t=>e._selectedFeatureIds.has(t.feature_id));e._selectedCoordinates.length===n.length||t.silent||(e._emitSelectionChange=!0),e._selectedCoordinates=n}he.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},he.prototype.setDirty=function(){return this.isDirty=!0,this},he.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const t=this.get(e);this.ctx.events.fire(u.CREATE,{features:[t.toGeoJSON()]})}return this},he.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(u.UPDATE,{action:t.action?t.action:p.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},he.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},he.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},he.prototype.getAllIds=function(){return this._featureIds.values()},he.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},he.prototype.delete=function(e,t={}){const n=[];return ue(e).forEach(e=>{this._featureIds.has(e)&&(this._featureIds.delete(e),this._selectedFeatureIds.delete(e),t.silent||-1===n.indexOf(this._features[e])&&n.push(this._features[e].toGeoJSON()),delete this._features[e],this.isDirty=!0)}),n.length&&this.ctx.events.fire(u.DELETE,{features:n}),fe(this,t),this},he.prototype.get=function(e){return this._features[e]},he.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},he.prototype.select=function(e,t={}){return ue(e).forEach(e=>{this._selectedFeatureIds.has(e)||(this._selectedFeatureIds.add(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),this},he.prototype.deselect=function(e,t={}){return ue(e).forEach(e=>{this._selectedFeatureIds.has(e)&&(this._selectedFeatureIds.delete(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),fe(this,t),this},he.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},he.prototype.setSelected=function(e,t={}){return e=ue(e),this.deselect(this._selectedFeatureIds.values().filter(t=>-1===e.indexOf(t)),{silent:t.silent}),this.select(e.filter(e=>!this._selectedFeatureIds.has(e)),{silent:t.silent}),this},he.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},he.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},he.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},he.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},he.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)}))},he.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},he.prototype.setFeatureProperty=function(e,t,n,r={}){this.get(e).setProperty(t,n),this.featureChanged(e,{silent:r.silent,action:p.CHANGE_PROPERTIES})},he.prototype.storeMapConfig=function(){g.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},he.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},he.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const ge=["mode","feature","mouse"];const me="#3bb2d0",ye="#fbb03b",ve="#fff";var be=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],ye,me],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],ye,me],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":ve}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],ye,me]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":ve}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":ye}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":ye}}];function _e(e,t){this.x=e,this.y=t}function Ee(e,t){const n=t.getBoundingClientRect();return new _e(e.clientX-n.left-(t.clientLeft||0),e.clientY-n.top-(t.clientTop||0))}function Se(e,t,n,r){return{type:c.FEATURE,properties:{meta:h.VERTEX,parent:e,coord_path:n,active:r?f.ACTIVE:f.INACTIVE},geometry:{type:c.POINT,coordinates:t}}}function xe(e){const t={type:"Feature"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"properties":case"geometry":return;default:t[n]=e[n]}}),t.properties=Ie(e.properties),null==e.geometry?t.geometry=null:t.geometry=we(e.geometry),t}function Ie(e){const t={};return e?(Object.keys(e).forEach(n=>{const r=e[n];"object"==typeof r?null===r?t[n]=null:Array.isArray(r)?t[n]=r.map(e=>e):t[n]=Ie(r):t[n]=r}),t):t}function we(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(e=>we(e)),t):(t.coordinates=Pe(e.coordinates),t)}function Pe(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(e=>Pe(e))}function Ce(e,t={}){return Te(e,"mercator",t)}function Te(e,t,n={}){var o=(n=n||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&(0,r.i)(e[0])?e="mercator"===t?Me(e):Le(e):(!0!==o&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return xe(e);case"FeatureCollection":return function(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"features":return;default:t[n]=e[n]}}),t.features=e.features.map(e=>xe(e)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return we(e);default:throw new Error("unknown GeoJSON type")}}(e)),(0,r.c)(e,function(e){var n="mercator"===t?Me(e):Le(e);e[0]=n[0],e[1]=n[1]})),e}function Me(e){var t,n=Math.PI/180,r=6378137,o=20037508.342789244,i=[r*(Math.abs(e[0])<=180?e[0]:e[0]-360*((t=e[0])<0?-1:t>0?1:0))*n,r*Math.log(Math.tan(.25*Math.PI+.5*e[1]*n))];return i[0]>o&&(i[0]=o),i[0]<-o&&(i[0]=-o),i[1]>o&&(i[1]=o),i[1]<-o&&(i[1]=-o),i}function Le(e){var t=180/Math.PI,n=6378137;return[e[0]*t/n,(.5*Math.PI-2*Math.atan(Math.exp(-e[1]/n)))*t]}function Ae(e,t,n){const r=t.geometry.coordinates,o=n.geometry.coordinates;if(r[1]>85||r[1]<-85||o[1]>85||o[1]<-85)return null;const i=Ce(r),s=Ce(o),a=e=>Number(e.toFixed(8)),l=(e,t)=>(e+t)/2,d=function(e,t={}){return Te(e,"wgs84",t)}([l(i[0],s[0]),l(i[1],s[1])]),u=[a(d[0]),a(d[1])];return{type:c.FEATURE,properties:{meta:h.MIDPOINT,parent:e,lng:u[0],lat:u[1],coord_path:n.properties.coord_path},geometry:{type:c.POINT,coordinates:u}}}function Oe(e,t={},n=null){const{type:r,coordinates:o}=e.geometry,i=e.properties&&e.properties.id;let s=[];function a(e,n){let r="",o=null;e.forEach((e,a)=>{const c=null!=n?`${n}.${a}`:String(a),d=Se(i,e,c,l(c));if(t.midpoints&&o){const e=Ae(i,o,d);e&&s.push(e)}o=d;const u=JSON.stringify(e);r!==u&&s.push(d),0===a&&(r=u)})}function l(e){return!!t.selectedPaths&&-1!==t.selectedPaths.indexOf(e)}return r===c.POINT?s.push(Se(i,o,n,l(n))):r===c.POLYGON?o.forEach((e,t)=>{a(e,null!==n?`${n}.${t}`:String(t))}):r===c.LINE_STRING?a(o,n):0===r.indexOf(c.MULTI_PREFIX)&&function(){const n=r.replace(c.MULTI_PREFIX,"");o.forEach((r,o)=>{const i={type:c.FEATURE,properties:e.properties,geometry:{type:n,coordinates:r}};s=s.concat(Oe(i,t,o))})}(),s}_e.prototype={clone(){return new _e(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[0]*this.x+e[1]*this.y,n=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=n,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),n=Math.sin(e),r=t*this.x-n*this.y,o=n*this.x+t*this.y;return this.x=r,this.y=o,this},_rotateAround(e,t){const n=Math.cos(e),r=Math.sin(e),o=t.x+n*(this.x-t.x)-r*(this.y-t.y),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=o,this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:_e},_e.convert=function(e){if(e instanceof _e)return e;if(Array.isArray(e))return new _e(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new _e(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var ke={enable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e._ctx&&e._ctx.store&&e._ctx.store.getInitialConfigValue&&e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e.map.doubleClickZoom.disable()},0)}};const{LAT_MIN:De,LAT_MAX:Re,LAT_RENDERED_MIN:Ne,LAT_RENDERED_MAX:Fe,LNG_MIN:Ve,LNG_MAX:Be}=m;function Ue(e,t){let n=De,r=Re,o=De,i=Re,s=Be,a=Ve;e.forEach(e=>{const t=function(e){const t={Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type],n=[e.geometry.coordinates].flat(t),r=n.map(e=>e[0]),o=n.map(e=>e[1]),i=e=>Math.min.apply(null,e),s=e=>Math.max.apply(null,e);return[i(r),i(o),s(r),s(o)]}(e),l=t[1],c=t[3],d=t[0],u=t[2];l>n&&(n=l),c<r&&(r=c),c>o&&(o=c),l<i&&(i=l),d<s&&(s=d),u>a&&(a=u)});const l=t;return n+l.lat>Fe&&(l.lat=Fe-n),o+l.lat>Re&&(l.lat=Re-o),r+l.lat<Ne&&(l.lat=Ne-r),i+l.lat<De&&(l.lat=De-i),s+l.lng<=Ve&&(l.lng+=360*Math.ceil(Math.abs(l.lng)/360)),a+l.lng>=Be&&(l.lng-=360*Math.ceil(Math.abs(l.lng)/360)),l}function Ge(e,t){const n=Ue(e.map(e=>e.toGeoJSON()),t);e.forEach(e=>{const t=e.getCoordinates(),r=e=>{const t={lng:e[0]+n.lng,lat:e[1]+n.lat};return[t.lng,t.lat]},o=e=>e.map(e=>r(e));let i;e.type===c.POINT?i=r(t):e.type===c.LINE_STRING||e.type===c.MULTI_POINT?i=t.map(r):e.type===c.POLYGON||e.type===c.MULTI_LINE_STRING?i=t.map(o):e.type===c.MULTI_POLYGON&&(i=t.map(e=>e.map(e=>o(e)))),e.incomingCoords(i)})}const je={onSetup:function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(e=>void 0!==this.getFeature(e))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(u.UPDATE,{action:p.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(){const e=this.getSelected(),t=e.filter(e=>this.isInstanceOf("MultiFeature",e));let n=!1;if(e.length>1){n=!0;const t=e[0].type.replace("Multi","");e.forEach(e=>{e.type.replace("Multi","")!==t&&(n=!1)})}const r=t.length>0,o=e.length>0;this.setActionableState({combineFeatures:n,uncombineFeatures:r,trash:o})},getUniqueIds:function(e){return e.length?e.map(e=>e.properties.id).filter(e=>void 0!==e).reduce((e,t)=>(e.add(t),e),new $).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){ke.enable(this)},onMouseMove:function(e,t){return S(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};je.onTap=je.onClick=function(e,t){return E(t)?this.clickAnywhere(e,t):y(h.VERTEX)(t)?this.clickOnVertex(e,t):S(t)?this.clickOnFeature(e,t):void 0},je.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(e=>this.doRender(e))),ke.enable(this),this.stopExtendedInteractions(e)},je.clickOnVertex=function(e,t){this.changeMode(d.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:a.MOVE})},je.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},je.clickOnFeature=function(e,t){ke.disable(this),this.stopExtendedInteractions(e);const n=I(t),r=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!n&&i&&this.getFeature(o).type!==c.POINT)return this.changeMode(d.DIRECT_SELECT,{featureId:o});i&&n?(this.deselect(o),this.updateUIClasses({mouse:a.POINTER}),1===r.length&&ke.enable(this)):!i&&n?(this.select(o),this.updateUIClasses({mouse:a.MOVE})):i||n||(r.forEach(e=>this.doRender(e)),this.setSelected(o),this.updateUIClasses({mouse:a.MOVE})),this.doRender(o)},je.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),b(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&v(t)?this.startBoxSelect(e,t):void 0},je.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ee(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},je.onTouchStart=function(e,t){if(b(t))return this.startOnActiveFeature(e,t)},je.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},je.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:a.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(i.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const n=Ee(t.originalEvent,this.map.getContainer()),r=Math.min(e.boxSelectStartLocation.x,n.x),o=Math.max(e.boxSelectStartLocation.x,n.x),s=Math.min(e.boxSelectStartLocation.y,n.y),l=Math.max(e.boxSelectStartLocation.y,n.y),c=`translate(${r}px, ${s}px)`;e.boxSelectElement.style.transform=c,e.boxSelectElement.style.WebkitTransform=c,e.boxSelectElement.style.width=o-r+"px",e.boxSelectElement.style.height=l-s+"px"},je.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};Ge(this.getSelected(),n),e.dragMoveLocation=t.lngLat},je.onTouchEnd=je.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const n=[e.boxSelectStartLocation,Ee(t.originalEvent,this.map.getContainer())],r=this.featuresAt(null,n,"click"),o=this.getUniqueIds(r).filter(e=>!this.isSelected(e));o.length&&(this.select(o),o.forEach(e=>this.doRender(e)),this.updateUIClasses({mouse:a.MOVE}))}this.stopExtendedInteractions(e)},je.toDisplayFeatures=function(e,t,n){t.properties.active=this.isSelected(t.properties.id)?f.ACTIVE:f.INACTIVE,n(t),this.fireActionable(),t.properties.active===f.ACTIVE&&t.geometry.type!==c.POINT&&Oe(t).forEach(n)},je.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},je.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],n=[],r=e[0].type.replace("Multi","");for(let o=0;o<e.length;o++){const i=e[o];if(i.type.replace("Multi","")!==r)return;i.type.includes("Multi")?i.getCoordinates().forEach(e=>{t.push(e)}):t.push(i.getCoordinates()),n.push(i.toGeoJSON())}if(n.length>1){const e=this.newFeature({type:c.FEATURE,properties:n[0].properties,geometry:{type:`Multi${r}`,coordinates:t}});this.addFeature(e),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([e.id]),this.fire(u.COMBINE_FEATURES,{createdFeatures:[e.toGeoJSON()],deletedFeatures:n})}this.fireActionable()},je.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],n=[];for(let r=0;r<e.length;r++){const o=e[r];this.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach(e=>{this.addFeature(e),e.properties=o.properties,t.push(e.toGeoJSON()),this.select([e.id])}),this.deleteFeature(o.id,{silent:!0}),n.push(o.toGeoJSON()))}t.length>1&&this.fire(u.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:n}),this.fireActionable()};const He=y(h.VERTEX),$e=y(h.MIDPOINT),Ye={fireUpdate:function(){this.fire(u.UPDATE,{action:p.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){null==e.initialDragPanState&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties,r=e.selectedCoordPaths.indexOf(n.coord_path);I(t)||-1!==r?I(t)&&-1===r&&e.selectedCoordPaths.push(n.coord_path):e.selectedCoordPaths=[n.coord_path];const o=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(o)},onMidpoint:function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties;e.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),e.selectedCoordPaths=[n.coord_path]},pathsToCoordinates:function(e,t){return t.map(t=>({feature_id:e,coord_path:t}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,n){Ge(this.getSelected(),n),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,n){const r=e.selectedCoordPaths.map(t=>e.feature.getCoordinate(t)),o=Ue(r.map(e=>({type:c.FEATURE,properties:{},geometry:{type:c.POINT,coordinates:e}})),n);for(let i=0;i<r.length;i++){const t=r[i];e.feature.updateCoordinate(e.selectedCoordPaths[i],t[0]+o.lng,t[1]+o.lat)}},clickNoTarget:function(){this.changeMode(d.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(d.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},onSetup:function(e){const t=e.featureId,n=this.getFeature(t);if(!n)throw new Error("You must provide a featureId to enter direct_select mode");if(n.type===c.POINT)throw new TypeError("direct_select mode doesn't handle point features");const r={featureId:t,feature:n,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,r.selectedCoordPaths)),this.setSelected(t),ke.disable(this),this.setActionableState({trash:!0}),r},onStop:function(){ke.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,n){e.featureId===t.properties.id?(t.properties.active=f.ACTIVE,n(t),Oe(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(n)):(t.properties.active=f.INACTIVE,n(t)),this.fireActionable(e)},onTrash:function(e){e.selectedCoordPaths.sort((e,t)=>t.localeCompare(e,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(d.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const n=b(t),r=He(t),o=$e(t),i=0===e.selectedCoordPaths.length;return n&&i||r&&!i?this.updateUIClasses({mouse:a.MOVE}):this.updateUIClasses({mouse:a.NONE}),(r||n||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};Ye.onTouchStart=Ye.onMouseDown=function(e,t){return He(t)?this.onVertex(e,t):b(t)?this.onFeature(e,t):$e(t)?this.onMidpoint(e,t):void 0},Ye.onDrag=function(e,t){if(!0!==e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,n):this.dragFeature(e,t,n),e.dragMoveLocation=t.lngLat},Ye.onClick=function(e,t){return E(t)?this.clickNoTarget(e,t):b(t)?this.clickActiveFeature(e,t):_(t)?this.clickInactive(e,t):void this.stopDragging(e)},Ye.onTap=function(e,t){return E(t)?this.clickNoTarget(e,t):b(t)?this.clickActiveFeature(e,t):_(t)?this.clickInactive(e,t):void 0},Ye.onTouchEnd=Ye.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const ze={};function Ke(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]}ze.onSetup=function(){const e=this.newFeature({type:c.FEATURE,properties:{},geometry:{type:c.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:a.ADD}),this.activateUIButton(l.POINT),this.setActionableState({trash:!0}),{point:e}},ze.stopDrawingAndRemove=function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)},ze.onTap=ze.onClick=function(e,t){this.updateUIClasses({mouse:a.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(u.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.point.id]})},ze.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},ze.toDisplayFeatures=function(e,t,n){const r=t.properties.id===e.point.id;if(t.properties.active=r?f.ACTIVE:f.INACTIVE,!r)return n(t)},ze.onTrash=ze.stopDrawingAndRemove,ze.onKeyUp=function(e,t){if(w(t)||P(t))return this.stopDrawingAndRemove(e,t)};const We={onSetup:function(){const e=this.newFeature({type:c.FEATURE,properties:{},geometry:{type:c.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),ke.disable(this),this.updateUIClasses({mouse:a.ADD}),this.activateUIButton(l.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Ke(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:a.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),x(t)&&this.updateUIClasses({mouse:a.POINTER})}};We.onTap=We.onClick=function(e,t){return x(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},We.onKeyUp=function(e,t){w(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)):P(t)&&this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},We.onStop=function(e){this.updateUIClasses({mouse:a.NONE}),ke.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(u.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT,{},{silent:!0})))},We.toDisplayFeatures=function(e,t,n){const r=t.properties.id===e.polygon.id;if(t.properties.active=r?f.ACTIVE:f.INACTIVE,!r)return n(t);if(0===t.geometry.coordinates.length)return;const o=t.geometry.coordinates[0].length;if(!(o<3)){if(t.properties.meta=h.FEATURE,n(Se(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const r=t.geometry.coordinates[0].length-3;n(Se(e.polygon.id,t.geometry.coordinates[0][r],`0.${r}`,!1))}if(o<=4){const e=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(n({type:c.FEATURE,properties:t.properties,geometry:{coordinates:e,type:c.LINE_STRING}}),3===o)return}return n(t)}},We.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)};const Je={onSetup:function(e){const t=(e=e||{}).featureId;let n,r,o="forward";if(t){if(n=this.getFeature(t),!n)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const s=n.coordinates.length-1;if(n.coordinates[s][0]===i[0]&&n.coordinates[s][1]===i[1])r=s+1,n.addCoordinate(r,...n.coordinates[s]);else{if(n.coordinates[0][0]!==i[0]||n.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");o="backwards",r=0,n.addCoordinate(r,...n.coordinates[0])}}else n=this.newFeature({type:c.FEATURE,properties:{},geometry:{type:c.LINE_STRING,coordinates:[]}}),r=0,this.addFeature(n);return this.clearSelectedFeatures(),ke.disable(this),this.updateUIClasses({mouse:a.ADD}),this.activateUIButton(l.LINE),this.setActionableState({trash:!0}),{line:n,currentVertexPosition:r,direction:o}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Ke(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&Ke(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:a.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),x(t)&&this.updateUIClasses({mouse:a.POINTER})}};Je.onTap=Je.onClick=function(e,t){if(x(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},Je.onKeyUp=function(e,t){P(t)?this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.line.id]}):w(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT))},Je.onStop=function(e){ke.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(u.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT,{},{silent:!0})))},Je.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)},Je.toDisplayFeatures=function(e,t,n){const r=t.properties.id===e.line.id;if(t.properties.active=r?f.ACTIVE:f.INACTIVE,!r)return n(t);t.geometry.coordinates.length<2||(t.properties.meta=h.FEATURE,n(Se(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),n(t))};var qe={simple_select:je,direct_select:Ye,draw_point:ze,draw_polygon:We,draw_line_string:Je};const Xe={defaultMode:d.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:be,modes:qe,controls:{},userProperties:!1,suppressAPIEvents:!0},Ze={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Qe={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function et(e,t){return e.map(e=>e.source?e:Object.assign({},e,{id:`${e.id}.${t}`,source:"hot"===t?s.HOT:s.COLD}))}var tt,nt,rt,ot,it=D(nt?tt:(nt=1,tt=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!==o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!==o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;0!==o--;){var s=i[o];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n})),st=D(function(){if(ot)return rt;ot=1,rt=function(t){if(!t||!t.type)return null;var n=e[t.type];return n?"geometry"===n?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:t}]}:"feature"===n?{type:"FeatureCollection",features:[t]}:"featurecollection"===n?t:void 0:null};var e={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};return rt}());function at(e,t){return e.length===t.length&&JSON.stringify(e.map(e=>e).sort())===JSON.stringify(t.map(e=>e).sort())}const lt={Polygon:oe,LineString:re,Point:ne,MultiPolygon:ae,MultiLineString:ae,MultiPoint:ae};var ct=Object.freeze({__proto__:null,CommonSelectors:k,ModeHandler:Z,StringSet:$,constrainFeatureMovement:Ue,createMidPoint:Ae,createSupplementaryPoints:Oe,createVertex:Se,doubleClickZoom:ke,euclideanDistance:J,featuresAt:z,getFeatureAtAndSetCursors:W,isClick:q,isEventAtCoordinates:Ke,isTap:X,mapEventToBoundingBox:H,moveFeatures:Ge,sortFeatures:j,stringSetsAreEqual:at,theme:be,toDenseArray:ue});function dt(e){!function(e,t){const n={options:e=function(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),!1===e.displayControlsDefault?t.controls=Object.assign({},Qe,e.controls):t.controls=Object.assign({},Ze,e.controls),t=Object.assign({},Xe,t),t.styles=et(t.styles,"cold").concat(et(t.styles,"hot")),t}(e)};t=function(e,t){t.modes=d;const n=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(t){return z.click({point:t},null,e).map(e=>e.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:c.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(t=>e.store.get(t)).map(e=>e.toGeoJSON())}},t.getSelectedPoints=function(){return{type:c.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(e=>({type:c.FEATURE,properties:{},geometry:{type:c.POINT,coordinates:e.coordinates}}))}},t.set=function(n){if(void 0===n.type||n.type!==c.FEATURE_COLLECTION||!Array.isArray(n.features))throw new Error("Invalid FeatureCollection");const r=e.store.createRenderBatch();let o=e.store.getAllIds().slice();const i=t.add(n),s=new $(i);return o=o.filter(e=>!s.has(e)),o.length&&t.delete(o),r(),i},t.add=function(t){const r=JSON.parse(JSON.stringify(st(t))).features.map(t=>{if(t.id=t.id||ee(),null===t.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(t.id)||e.store.get(t.id).type!==t.geometry.type){const r=lt[t.geometry.type];if(void 0===r)throw new Error(`Invalid geometry type: ${t.geometry.type}.`);const o=new r(e,t);e.store.add(o,{silent:n})}else{const r=e.store.get(t.id),o=r.properties;r.properties=t.properties,it(o,t.properties)||e.store.featureChanged(r.id,{silent:n}),it(r.getCoordinates(),t.geometry.coordinates)||r.incomingCoords(t.geometry.coordinates)}return t.id});return e.store.render(),r},t.get=function(t){const n=e.store.get(t);if(n)return n.toGeoJSON()},t.getAll=function(){return{type:c.FEATURE_COLLECTION,features:e.store.getAll().map(e=>e.toGeoJSON())}},t.delete=function(r){return e.store.delete(r,{silent:n}),t.getMode()!==d.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(d.SIMPLE_SELECT,void 0,{silent:n}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:n}),t.getMode()===d.DIRECT_SELECT?e.events.changeMode(d.SIMPLE_SELECT,void 0,{silent:n}):e.store.render(),t},t.changeMode=function(r,o={}){return r===d.SIMPLE_SELECT&&t.getMode()===d.SIMPLE_SELECT?(at(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:n}),e.store.render()),t):(r===d.DIRECT_SELECT&&t.getMode()===d.DIRECT_SELECT&&o.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(r,o,{silent:n}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:n}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:n}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:n}),t},t.setFeatureProperty=function(r,o,i){return e.store.setFeatureProperty(r,o,i,{silent:n}),t},t}(n,t),n.api=t;const r=function(e){let t=null,n=null;const r={onRemove(){return e.map.off("load",r.connect),clearInterval(n),r.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",r.connect),clearInterval(n),r.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(o){if(e.map=o,e.events=function(e){const t=Object.keys(e.options.modes).reduce((t,n)=>(t[n]=function(e){const t=Object.keys(e);return function(n,r={}){let o={};const i=t.reduce((t,n)=>(t[n]=e[n],t),new le(n));return{start(){o=i.onSetup(r),de.forEach(t=>{const n=ce[t];let r=()=>!1;var s;e[n]&&(r=()=>!0),this.on(t,r,(s=n,e=>i[s](o,e)))})},stop(){i.onStop(o)},trash(){i.onTrash(o)},combineFeatures(){i.onCombineFeatures(o)},uncombineFeatures(){i.onUncombineFeatures(o)},render(e,t){i.toDisplayFeatures(o,e,t)}}}}(e.options.modes[n]),t),{});let n={},r={};const o={};let s=null,l=null;o.drag=function(t,n){n({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:a.DRAG}),l.drag(t)):t.originalEvent.stopPropagation()},o.mousedrag=function(e){o.drag(e,e=>!q(n,e))},o.touchdrag=function(e){o.drag(e,e=>!X(r,e))},o.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return o.mousedrag(t);const n=W(t,e);t.featureTarget=n,l.mousemove(t)},o.mousedown=function(t){n={time:(new Date).getTime(),point:t.point};const r=W(t,e);t.featureTarget=r,l.mousedown(t)},o.mouseup=function(t){const r=W(t,e);t.featureTarget=r,q(n,{point:t.point,time:(new Date).getTime()})?l.click(t):l.mouseup(t)},o.mouseout=function(e){l.mouseout(e)},o.touchstart=function(t){if(!e.options.touchEnabled)return;r={time:(new Date).getTime(),point:t.point};const n=z.touch(t,null,e)[0];t.featureTarget=n,l.touchstart(t)},o.touchmove=function(t){if(e.options.touchEnabled)return l.touchmove(t),o.touchdrag(t)},o.touchend=function(t){if(t.originalEvent.preventDefault(),!e.options.touchEnabled)return;const n=z.touch(t,null,e)[0];t.featureTarget=n,X(r,{time:(new Date).getTime(),point:t.point})?l.tap(t):l.touchend(t)};const c=e=>{const t=C(e),n=T(e),r=O(e);return!(t||n||r)};function p(n,r,o={}){l.stop();const i=t[n];if(void 0===i)throw new Error(`${n} is not valid`);s=n;const a=i(e,r);l=Z(a,e),o.silent||e.map.fire(u.MODE_CHANGE,{mode:n}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains(i.CANVAS)&&((C(t)||T(t))&&e.options.controls.trash?(t.preventDefault(),l.trash()):c(t)?l.keydown(t):M(t)&&e.options.controls.point?p(d.DRAW_POINT):L(t)&&e.options.controls.line_string?p(d.DRAW_LINE_STRING):A(t)&&e.options.controls.polygon&&p(d.DRAW_POLYGON))},o.keyup=function(e){c(e)&&l.keyup(e)},o.zoomend=function(){e.store.changeZoom()},o.data=function(t){if("style"===t.dataType){const{setup:t,map:n,options:r,store:o}=e;r.styles.some(e=>n.getLayer(e.id))||(t.addLayers(),o.setDirty(),o.render())}};const h={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start(){s=e.options.defaultMode,l=Z(t[s](e),e)},changeMode:p,actionable:function(t){let n=!1;Object.keys(t).forEach(e=>{if(void 0===h[e])throw new Error("Invalid action type");h[e]!==t[e]&&(n=!0),h[e]=t[e]}),n&&e.map.fire(u.ACTIONABLE,{actions:h})},currentModeName:()=>s,currentModeRender:(e,t)=>l.render(e,t),fire(t,n){e.map&&e.map.fire(t,n)},addEventListeners(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash(e){l.trash(e)},combineFeatures(){l.combineFeatures()},uncombineFeatures(){l.uncombineFeatures()},getMode:()=>s}}(e),e.ui=function(e){const t={};let n=null,r={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function s(e){o=Object.assign(o,e)}function a(){if(!e.container)return;const t=[],n=[];ge.forEach(e=>{o[e]!==r[e]&&(t.push(`${e}-${r[e]}`),null!==o[e]&&n.push(`${e}-${o[e]}`))}),t.length>0&&e.container.classList.remove(...t),n.length>0&&e.container.classList.add(...n),r=Object.assign(r,o)}function c(e,t={}){const r=document.createElement("button");return r.className=`${i.CONTROL_BUTTON} ${t.className}`,r.setAttribute("title",t.title),t.container.appendChild(r),r.addEventListener("click",r=>{if(r.preventDefault(),r.stopPropagation(),r.target===n)return u(),void t.onDeactivate();p(e),t.onActivate()},!0),r}function u(){n&&(n.classList.remove(i.ACTIVE_BUTTON),n=null)}function p(e){u();const r=t[e];r&&r&&"trash"!==e&&(r.classList.add(i.ACTIVE_BUTTON),n=r)}return{setActiveButton:p,queueMapClasses:s,updateMapClasses:a,clearMapClasses:function(){s({mode:null,feature:null,mouse:null}),a()},addButtons:function(){const n=e.options.controls,r=document.createElement("div");return r.className=`${i.CONTROL_GROUP} ${i.CONTROL_BASE}`,n?(n[l.POINT]&&(t[l.POINT]=c(l.POINT,{container:r,className:i.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(d.DRAW_POINT),onDeactivate:()=>e.events.trash()})),n[l.LINE]&&(t[l.LINE]=c(l.LINE,{container:r,className:i.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(d.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),n[l.POLYGON]&&(t[l.POLYGON]=c(l.POLYGON,{container:r,className:i.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(d.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),n.trash&&(t.trash=c("trash",{container:r,className:i.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),n.combine_features&&(t.combine_features=c("combineFeatures",{container:r,className:i.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),n.uncombine_features&&(t.uncombine_features=c("uncombineFeatures",{container:r,className:i.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}})),r):r},removeButtons:function(){Object.keys(t).forEach(e=>{const n=t[e];n.parentNode&&n.parentNode.removeChild(n),delete t[e]})}}}(e),e.container=o.getContainer(),e.store=new he(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=o.boxZoom.isEnabled(),o.boxZoom.disable();const t=o.dragPan.isEnabled();o.dragPan.disable(),o.dragPan.enable(),t||o.dragPan.disable()}return o.loaded()?r.connect():(o.on("load",r.connect),n=setInterval(()=>{o.loaded()&&r.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(s.COLD,{data:{type:c.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(s.HOT,{data:{type:c.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(t=>{e.map.addLayer(t)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(t=>{e.map.getLayer(t.id)&&e.map.removeLayer(t.id)}),e.map.getSource(s.COLD)&&e.map.removeSource(s.COLD),e.map.getSource(s.HOT)&&e.map.removeSource(s.HOT)}};return e.setup=r,r}(n);t.onAdd=r.onAdd,t.onRemove=r.onRemove,t.types=l,t.options=e}(e,this)}dt.modes=qe,dt.constants=m,dt.lib=ct;const ut={onSetup:()=>({}),onClick:()=>!1,onKeyUp:()=>!1,onDrag:()=>!1,toDisplayFeatures(e,t,n){t.properties.active="false",n(t)}},pt="draw.create",ht="draw.update",ft="draw.modechange",gt="draw.editfinish",mt="draw.cancel",yt="draw.vertexselection",vt="draw.vertexchange",bt="draw.undochange",_t="draw.geometrychange",Et="draw.interfacetypechange",St="draw.placementblocked",xt="draw.nudgevertex",It="draw.selectvertex",wt="draw.insertvertexatmidpoint",Pt="styledata",Ct=e=>{if(!e?.coordinates)return[];switch(e.type){case"LineString":return e.coordinates;case"Polygon":case"MultiLineString":return e.coordinates.flat(1);case"MultiPolygon":return e.coordinates.flat(2);default:return[]}},Tt=e=>{const t=Ct(e),n=Mt(e);if(!t.length||!n.length)return[];const r=[];for(const o of n){const e=o.closed?o.length:o.length-1;for(let n=0;n<e;n++){const e=o.start+n,i=o.start+(n+1)%o.length,[s,a]=t[e],[l,c]=t[i];r.push([(s+l)/2,(a+c)/2])}}return r},Mt=e=>{if(!e?.coordinates)return[];const t=[];let n=0;switch(e.type){case"LineString":t.push({start:0,length:e.coordinates.length,path:[],closed:!1});break;case"Polygon":e.coordinates.forEach((e,r)=>{t.push({start:n,length:e.length,path:[r],closed:!0}),n+=e.length});break;case"MultiLineString":e.coordinates.forEach((e,r)=>{t.push({start:n,length:e.length,path:[r],closed:!1}),n+=e.length});break;case"MultiPolygon":e.coordinates.forEach((e,r)=>{e.forEach((e,o)=>{t.push({start:n,length:e.length,path:[r,o],closed:!0}),n+=e.length})})}return t},Lt=(e,t)=>{for(const n of e)if(t>=n.start&&t<n.start+n.length)return{segment:n,localIdx:t-n.start};return null},At=(e,t)=>{let n=e.geometry.coordinates;for(const r of t)n=n[r];return n},Ot=(e,t)=>{const n=t.split(".").map(Number),r=Mt(e);for(const o of r)if(o.path.every((e,t)=>e===n[t])&&n.length===o.path.length+1){const e=n[n.length-1];return o.start+e}return n[n.length-1]},kt=(e,t)=>({x:e.x*t,y:e.y*t}),Dt=e=>e instanceof window.SVGElement||e.ownerSVGElement;function Rt(e){return e?._snapInstance??null}function Nt(e){return!!(e?.status&&e?.snapStatus&&e.snapCoords?.length>=2)}function Ft(e){return Nt(e)?{lng:e.snapCoords[0],lat:e.snapCoords[1]}:null}function Vt(e,t,n){if(!e||!t||!e.status)return!1;const r=t.unproject(n);return e.snapToClosestPoint({point:n,lngLat:r,_explicit:!0}),!0}function Bt(e,t){e&&(e._autoSnapSuspended=t)}function Ut(e,t){if(!e||!t||!e.status)return!1;const n=t.getCenter(),r=t.project(n);return e.snapToClosestPoint({point:r,lngLat:n,_explicit:!0}),!0}function Gt(e,t){e&&(e.snapStatus=!1,e.snapCoords=null,e.snappedFeatures?.length&&(e.snappedFeatures.length=0),e.closeFeatures?.length&&(e.closeFeatures.length=0),e.lines?.length&&(e.lines.length=0)),t?.getLayer("snap-helper-circle")&&t.setLayoutProperty("snap-helper-circle","visibility","none")}function jt(e){e&&(e.snapStatus=!1,e.snapCoords=null,e.snappedFeatures?.length&&(e.snappedFeatures.length=0),e.closeFeatures?.length&&(e.closeFeatures.length=0),e.lines?.length&&(e.lines.length=0))}function Ht(e){return"function"==typeof e?.getSnapEnabled&&!0===e.getSnapEnabled()}const $t=(e,t,n={})=>{const r=n=>r=>n.call(e,t,r),o={keydown:r(e.onKeydown),keyup:r(e.onKeyup),pointerdown:r(e.onPointerevent),pointermove:r(e.onPointerevent),pointerup:r(e.onPointerevent),click:r(e.onButtonClick),touchstart:r(e.onTouchstart),touchmove:r(e.onTouchmove),touchend:r(e.onTouchend),scalechange:r(e.onScaleChange),move:r(e.onMove),interfacetypechange:r(e.onInterfaceTypeChange)};for(const[i,s]of Object.entries(n))o[i]=r(s);return o},Yt=(e,t,n)=>{window.addEventListener("keydown",n.keydown,{capture:!0}),window.addEventListener("keyup",n.keyup,{capture:!0}),window.addEventListener("click",n.click),e.container.addEventListener("pointerdown",n.pointerdown),e.container.addEventListener("pointermove",n.pointermove),e.container.addEventListener("pointerup",n.pointerup),e.container.addEventListener("touchstart",n.touchstart,{passive:!1}),e.container.addEventListener("touchmove",n.touchmove,{passive:!1}),e.container.addEventListener("touchend",n.touchend,{passive:!1}),t.on("draw.scalechange",n.scalechange),t.on("move",n.move),t.on(Et,n.interfacetypechange),t.on(xt,n.nudge)},zt=(e,t,n)=>{e.container.removeEventListener("pointerdown",n.pointerdown),e.container.removeEventListener("pointermove",n.pointermove),e.container.removeEventListener("pointerup",n.pointerup),e.container.removeEventListener("touchstart",n.touchstart),e.container.removeEventListener("touchmove",n.touchmove),e.container.removeEventListener("touchend",n.touchend),t.off("draw.scalechange",n.scalechange),t.off("move",n.move),t.off(Et,n.interfacetypechange),t.off(xt,n.nudge),t.dragPan.enable(),window.removeEventListener("click",n.click),window.removeEventListener("keydown",n.keydown,{capture:!0}),window.removeEventListener("keyup",n.keyup,{capture:!0})},Kt=e=>{const t=Rt(e);t&&Gt(t,e)},Wt={fireGeometryChange(e){const t=this.getFeature(e.featureId);t&&this.map.fire("draw.update",{features:[t.toGeoJSON()],action:"change_coordinates"})},emitGeometryValidation(e,t,n){e&&setTimeout(()=>{const r=this.getFeature(n);r&&this.map.fire("draw.geometrychange",{feature:r.toGeoJSON(),phase:e,vertexIndex:t})},0)},pushUndo(e){const t=this.map._undoStack;t&&(t.push(e),this.emitGeometryValidation(this.UNDO_OP_PHASE[e.type],e.vertexIndex,e.featureId))}},Jt={move_vertex:"commit-move",insert_vertex:"commit-delete",delete_vertex:"commit-insert"},qt={...Wt,UNDO_OP_PHASE:{move_vertex:"commit-move",insert_vertex:"commit-insert",delete_vertex:"commit-delete"},UNDO_INVERSE_PHASE:Jt,handleUndo(e){const t=this.map._undoStack;if(!t||0===t.length)return;const n=t.pop();"move_vertex"===n.type?this.undoMoveVertex(e,n):"insert_vertex"===n.type?this.undoInsertVertex(e,n):"delete_vertex"===n.type&&this.undoDeleteVertex(e,n),this.emitGeometryValidation(Jt[n.type],n.vertexIndex,n.featureId)},undoMoveVertex(e,t){const{vertexIndex:n,previousPosition:r,featureId:o}=t,i=this.getFeature(o);if(!i)return;const s=i.toGeoJSON(),a=Mt(i),l=Lt(a,n);if(!l)return;At(s,l.segment.path)[l.localIdx]=r,this._applyUndoAndSync(e,s,o);const c=e.vertices[e.selectedVertexIndex];c&&this.updateTouchVertexTarget(e,kt(this.map.project(c),e.scale))},undoInsertVertex(e,t){const{vertexIndex:n,featureId:r}=t,o=this.getFeature(r);if(!o)return;const i=o.toGeoJSON(),s=Mt(o),a=Lt(s,n);a&&(At(i,a.segment.path).splice(a.localIdx,1),this._applyUndoAndSync(e,i,r),this.clearSelectedCoordinates(),this.hideTouchVertexIndicator(e),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null}))},undoDeleteVertex(e,t){const{vertexIndex:n,position:r,featureId:o}=t,i=this.getFeature(o);if(!i)return;const s=i.toGeoJSON(),a=Mt(i);let l=Lt(a,n);if(!l)for(const c of a)if(n===c.start+c.length){l={segment:c,localIdx:c.length};break}l&&(At(s,l.segment.path).splice(l.localIdx,0,r),this._applyUndoAndSync(e,s,o),this.updateTouchVertexTarget(e,kt(this.map.project(e.vertices[n]),e.scale)),this.changeMode(e,{selectedVertexIndex:n,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,n)}))},_applyUndoAndSync(e,t,n){this._ctx.api.add(t),e.vertices=this.getVertices(n),e.midpoints=this.getMidpoints(n),this._ctx.store.render(),this.fireGeometryChange(e)}},Xt=e=>({x:e.touches[0].clientX,y:e.touches[0].clientY}),Zt=(e,t,n,r,o)=>{const i=window.getComputedStyle(t),s={x:n.x-Number.parseFloat(i.left),y:n.y-Number.parseFloat(i.top)},a=e.project(r);return{deltaTarget:s,deltaVertex:{x:n.x/o-a.x,y:n.y/o-a.y}}},Qt=(e,t,n)=>{const r={x:n.x/t.scale-t.deltaVertex.x,y:n.y/t.scale-t.deltaVertex.y};let o=e.unproject(r);if(Ht(t)){const t=Rt(e);Vt(t,e,r),o=Ft(t)||o}return o},en=(e,t,n={})=>{if(!e)return;const{editActive:r,editHalo:i,editVertex:s}=(0,o.r)(t,n);(0,o.a)(e,{editActive:r,editHalo:i,editVertex:s})},tn={addTouchVertexTarget(e){e.touchVertexTarget=(0,o.c)(e.container),en(e.touchVertexTarget,this.map._drawCurrentMapStyle,this.map._drawPluginConfig)},updateTouchVertexTarget(e,t){t&&"touch"===e.interfaceType&&e.selectedVertexIndex>=0?Object.assign(e.touchVertexTarget.style,{display:"block",top:`${t.y}px`,left:`${t.x}px`}):e.touchVertexTarget.style.display="none"},hideTouchVertexIndicator(e){e.touchVertexTarget.style.display="none"},onPointerevent(e,t){e.interfaceType="touch"===t.pointerType?"touch":"mouse",e.isPanEnabled=!0,"touch"!==t.pointerType||"pointermove"!==t.type||Dt(t.target.parentNode)||e._ignorePointermoveDeselect||this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,coordPath:null})},onTouchStart(){},onTouchMove(){},onTouchEnd(){},onTouchend(e){if(jt(Rt(this.map)),e?.featureId){this.syncVertices(e),e._touchMoved&&e._moveStartPosition&&null!=e._moveStartIndex&&this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,e._moveStartIndex=null,e._touchMoved=!1;const t=e.vertices[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,kt(this.map.project(t),e.scale))}},onTap(e,t){const n=Rt(this.map);n&&Gt(n,this.map);const r=t.featureTarget?.properties.meta,o=t.featureTarget?.properties.coord_path;if("vertex"===r){const t=this.getFeature(e.featureId),n=Ot(t,o);this.changeMode(e,{selectedVertexIndex:n,selectedVertexType:"vertex",coordPath:o})}else"midpoint"===r?this.insertVertex({...e,selectedVertexIndex:this.getVertexIndexFromMidpoint(e,o),selectedVertexType:"midpoint"}):this.clickNoTarget(e)},onTouchstart(e,t){jt(Rt(this.map));const n=this.getVertices(e.featureId),r=n?.[e.selectedVertexIndex];if(!r||!Dt(t.target.parentNode))return;e._moveStartPosition=[...r],e._moveStartIndex=e.selectedVertexIndex,e._touchMoved=!1;const o=Xt(t);Object.assign(e,Zt(this.map,e.touchVertexTarget,o,r,e.scale))},onTouchmove(e,t){if(e.selectedVertexIndex<0||!Dt(t.target.parentNode))return;e._touchMoved=!0;const n=Xt(t);this.moveVertex(e,Qt(this.map,e,n)),this.updateTouchVertexTarget(e,{x:n.x-e.deltaTarget.x,y:n.y-e.deltaTarget.y})}},nn=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),rn={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},on=new Set(["INPUT","TEXTAREA","BUTTON","SELECT","A"]),sn=e=>{const t=document.activeElement;return!(!t||t===document.body)&&!e.container?.contains(t)&&(on.has(t.tagName)||t.isContentEditable||t.hasAttribute("tabindex"))},an=e=>"z"===e.key&&(e.metaKey||e.ctrlKey)&&!e.shiftKey,ln={handleUndoShortcut(e,t){const n=document.activeElement?.tagName;"INPUT"!==n&&"TEXTAREA"!==n&&(t.preventDefault(),t.stopPropagation(),this.handleUndo(e))}},cn={getOffset(e,t){const n=this.map.project(e),o=t?.shiftKey?r.K.nudgeAmount:r.K.stepAmount,[i,s]=t?rn[t.key].map(e=>e*o):[0,0];return this.map.unproject({x:n.x+i,y:n.y+s})},getOffsetByDelta(e,t,n,o){const i=this.map.project(e),s=o?r.K.stepAmount:r.K.nudgeAmount;return this.map.unproject({x:i.x+t*s,y:i.y+n*s})},resolveSnapTarget(e,t,n,o,i){const s=Rt(this.map);if(Ht(e)&&e._isSnapped&&s){const i=function(e){return e?.options?.radius??r.T.snapRadius}(s)+1,a=this.map.project(o);return e._isSnapped=!1,Gt(s,this.map),this.map.unproject({x:a.x+t*i,y:a.y+n*i})}const a=i();return Ht(e)&&s&&(Vt(s,this.map,this.map.project(a)),Nt(s))?(e._isSnapped=!0,Ft(s)):(e._isSnapped=!1,a)}},dn={...cn,updateMidpoint(e){setTimeout(()=>{this.map.getSource("mapbox-gl-draw-hot").setData({type:"Feature",properties:{meta:"midpoint",active:"true",id:"active-midpoint"},geometry:{type:"Point",coordinates:e}})},0)},updateVertex(e,t){const[n,r]=this.getVertexOrMidpoint(e,t);n<0||!r||this.changeMode(e,{selectedVertexIndex:n,selectedVertexType:r,..."vertex"===r&&{coordPath:this.getCoordPath(e,n)}})},getNewCoord(e,t){return this.getOffset(Ct(this.getFeature(e.featureId))[e.selectedVertexIndex],t)},nudgeVertexByDelta(e,t,n,r){if("vertex"!==e.selectedVertexType||e.selectedVertexIndex<0)return;const o=this.getFeature(e.featureId),i=o&&Ct(o)?.[e.selectedVertexIndex];if(!i)return;const s=[...i],a=e.selectedVertexIndex,l=this.resolveSnapTarget(e,t,n,i,()=>this.getOffsetByDelta(i,t,n,r));this.moveVertex(e,l),this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:a,previousPosition:s})},insertVertex(e,t){const n=e.selectedVertexIndex-e.vertices.length,r=this.getOffset(e.midpoints[n],t),o=this.getFeature(e.featureId),i=o.toGeoJSON(),s=Mt(o);let a=n+1,l=null,c=0,d=0;for(const u of s){const e=u.closed?u.length:u.length-1;if(n<d+e){l=u,c=n-d+1,a=u.start+c;break}d+=e}l&&(At(i,l.path).splice(c,0,[r.lng,r.lat]),this._ctx.api.add(i),this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:a}),this.changeMode(e,{selectedVertexIndex:a,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,a)}))},moveVertex(e,t,n={}){if(n.checkSnap&&!1!==e.enableSnap){const e=this.map._snapInstance;e?.snapStatus&&e.snapCoords?.length>=2&&(t={lng:e.snapCoords[0],lat:e.snapCoords[1]})}const r=this.getFeature(e.featureId),o=r.toGeoJSON(),i=Mt(r),s=Lt(i,e.selectedVertexIndex);s&&(At(o,s.segment.path)[s.localIdx]=[t.lng,t.lat],this._ctx.api.add(o),e.vertices=this.getVertices(e.featureId),this.map.fire("draw.geometrychange",e.feature))},deleteVertex(e){const t=this.getFeature(e.featureId);if(!t)return;const n=Mt(t),o=Lt(n,e.selectedVertexIndex);if(!o)return;const{segment:i}=o,s=i.closed?r.M.Polygon:r.M.LineString;if(i.length<=s)return;const a=[...e.vertices[e.selectedVertexIndex]],l=e.selectedVertexIndex,c=[...o.segment.path,o.localIdx].join(".");t.removeCoordinate(c),this.fireUpdate(),this.clearSelectedCoordinates(),t.changed(),this._ctx.store.render(),this.pushUndo({type:"delete_vertex",featureId:e.featureId,vertexIndex:l,position:a}),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null})}},un={findVertexIndex(e,t,n){const r=[];return e.forEach((e,n)=>{e[0]===t[0]&&e[1]===t[1]&&r.push(n)}),0===r.length?-1:1===r.length?r[0]:n>=0?r.reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e,r[0]):r[0]},getCoordPath(e,t){const n=this.getFeature(e.featureId);if(!n)return"0";const r=Mt(n),o=Lt(r,t);if(!o)return"0";const{segment:i,localIdx:s}=o;return[...i.path,s].join(".")},syncVertices(e){e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId)},getVertices(e){return Ct(this.getFeature(e))},getMidpoints(e){return Tt(this.getFeature(e))},getVertexOrMidpoint(e,t){if(e.vertices?.length||(e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),!e.vertices?.length)return[-1,null];const n=e=>e?Object.values(this.map.project(e)):null,r=[...e.vertices.map(n),...e.midpoints.map(n)].filter(Boolean);if(!r.length)return[-1,null];const i=r[e.selectedVertexIndex]||Object.values(this.map.project(this.map.getCenter())),s=(0,o.s)(i,r,t);return[s,s<e.vertices.length?"vertex":"midpoint"]},getVertexIndexFromMidpoint(e,t){const n=this.getFeature(e.featureId),r=Mt(n),o=t.split(".").map(Number);let i=0;for(const s of r){if(s.path.every((e,t)=>e===o[t])&&o.length===s.path.length+1){const t=o[o.length-1],n=t>0?t-1:s.length-2;return e.vertices.length+i+n}i+=s.closed?s.length:s.length-1}return e.vertices.length}},pn={...ln,onKeydown(e,t){sn(e)||(e.interfaceType="keyboard",this.hideTouchVertexIndicator(e)," "!==t.key?nn.has(t.key)&&e.selectedVertexIndex>=0?this.handleArrowKey(e,t):"Escape"!==t.key?an(t)&&this.handleUndoShortcut(e,t):this.changeMode(e,{isPanEnabled:!0,selectedVertexIndex:-1,selectedVertexType:null}):this.handleSpace(e,t))},handleSpace(e,t){t.preventDefault(),e.selectedVertexIndex<0&&this.startKeyboardSelection(e)},handleArrowKey(e,t){t.preventDefault(),t.stopPropagation(),t.altKey?this.updateVertex(e,t.key):this.moveVertexByKey(e,t)},startKeyboardSelection(e){const t=Rt(this.map);t&&Gt(t,this.map),e.vertices?.length||(e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),e.vertices?.length&&(e.isPanEnabled=!1,this.updateVertex(e))},moveVertexByKey(e,t){if("midpoint"===e.selectedVertexType)return void this.insertVertex(e,t);const n=this.getFeature(e.featureId),r=n&&Ct(n)?.[e.selectedVertexIndex];r&&(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=[...r],e._keyboardMoveStartIndex=e.selectedVertexIndex),this.moveVertex(e,this._keyboardMoveTarget(e,t,r)))},_keyboardMoveTarget(e,t,n){const[r,o]=rn[t.key];return this.resolveSnapTarget(e,r,o,n,()=>this.getNewCoord(e,t))},onKeyup(e,t){sn(e)||(e.interfaceType="keyboard",e.selectedVertexIndex>=0&&(0,o.b)(t),nn.has(t.key)&&e.selectedVertexIndex>=0&&(t.stopPropagation(),e._keyboardMoveStartPosition&&null!=e._keyboardMoveStartIndex&&(this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._keyboardMoveStartIndex,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null,e._keyboardMoveStartIndex=null)),"Delete"===t.key&&this.deleteVertex(e))}},hn={onMouseDown(e,t){jt(Rt(this.map));const n=t.featureTarget?.properties.meta,r=t.featureTarget?.properties.coord_path;if(["vertex","midpoint"].includes(n)&&(e.dragMoveLocation=t.lngLat,e.dragMoving=!1,Ye.onMouseDown.call(this,e,t),"vertex"===n&&r)){const t=this.getFeature(e.featureId),n=Ot(t,r);e.selectedVertexIndex=n,e.selectedVertexType="vertex",e.coordPath=r;const o=e.vertices?.[n];o&&(e._moveStartPosition=[...o],e._moveStartIndex=n)}if("midpoint"===n){const t=this.getFeature(e.featureId),n=Ot(t,r);e._insertedVertexIndex=n,e._isInsertingVertex=!0,e.selectedVertexIndex=this.getVertexIndexFromMidpoint(e,r),e.selectedVertexType="vertex",e.coordPath=null,this.map.fire(yt,{index:e.selectedVertexIndex,numVertices:e.vertices.length})}},onClick(e,t){if(e._isInsertingVertex&&null!=e._insertedVertexIndex){const t=e._insertedVertexIndex;return this.syncVertices(e),this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:t}),e.selectedVertexIndex=t,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=null,void this.map.fire(yt,{index:t,numVertices:e.vertices.length})}Ye.onClick.call(this,e,t)},onMouseUp(e,t){jt(Rt(this.map));const n=e._isInsertingVertex&&null!=e._insertedVertexIndex,r=this._didVertexMove(e);(e.dragMoving||r||n)&&(this.syncVertices(e),n?this._recordInsertionUndo(e):r&&this._recordMoveUndo(e)),e._moveStartPosition=null,e._moveStartIndex=null,Ye.onMouseUp.call(this,e,t)},_didVertexMove(e){if(!e._moveStartPosition||null==e._moveStartIndex)return!1;const t=this.getFeature(e.featureId),n=t&&Ct(t)?.[e._moveStartIndex];return!!n&&(n[0]!==e._moveStartPosition[0]||n[1]!==e._moveStartPosition[1])},_recordInsertionUndo(e){const t=e._insertedVertexIndex;this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:t}),e.selectedVertexIndex=t,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=null,this.map.fire(yt,{index:t,numVertices:e.vertices.length})},_recordMoveUndo(e){this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition})},onDrag(e,t){if("touch"===e.interfaceType)return;this.map.fire("draw.geometrychange",e.feature);const n=Rt(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),!Ht(e)||!n?.status)return void Ye.onDrag.call(this,e,t);if(!e.selectedCoordPaths?.length||!e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation(),Vt(n,this.map,t.point);const r=Ft(n)||t.lngLat;e.feature.updateCoordinate(e.selectedCoordPaths[0],r.lng,r.lat),e.dragMoveLocation=t.lngLat}},fn={...dt.modes.direct_select,...qt,...tn,...dn,...un,...pn,...hn,onSetup(e){const t=dt.modes.direct_select.onSetup.call(this,e);Object.assign(t,{container:e.container,interfaceType:e.interfaceType,deleteVertexButtonId:e.deleteVertexButtonId,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,featureId:t.featureId,selectedVertexIndex:e.selectedVertexIndex??-1,selectedVertexType:e.selectedVertexType,coordPath:e.coordPath,scale:e.scale??1}),this.map._lastEditFeatureId!==t.featureId&&(this.map._undoStack?.clear(),this.map._lastEditFeatureId=t.featureId);const n=this.getFeature(t.featureId);if(t.featureType=n?.type,t.vertices=this.getVertices(t.featureId),t.midpoints=this.getMidpoints(t.featureId),this.setupEventListeners(t),this.applyVertexSelection(t,e),this.map._drawEditContainer=e.container,this.addTouchVertexTarget(t),Kt(this.map),"touch"===t.interfaceType&&t.selectedVertexIndex>=0&&"vertex"===t.selectedVertexType){const e=t.vertices[t.selectedVertexIndex];e&&setTimeout(()=>{this.updateTouchVertexTarget(t,kt(this.map.project(e),t.scale))},0)}return t._ignorePointermoveDeselect=!0,setTimeout(()=>{t._ignorePointermoveDeselect=!1},100),t},setupEventListeners(e){const t=this.handlers=$t(this,e,{nudge:this.onNudgeVertex,selectionchange:this.onSelectionChange,update:this.onUpdate,selectvertex:this.onSelectVertex,insertvertexatmidpoint:this.onInsertVertexAtMidpoint});Yt(e,this.map,t),this.map.on("draw.selectionchange",t.selectionchange),this.map.on("draw.update",t.update),this.map.on(It,t.selectvertex),this.map.on(wt,t.insertvertexatmidpoint)},applyVertexSelection(e,t){if("midpoint"===t.selectedVertexType)return e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed(),this._ctx.store.render(),void this.updateMidpoint(e.midpoints[t.selectedVertexIndex-e.vertices.length]);-1===t.selectedVertexIndex&&(e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed(),this._ctx.store.render())},onSelectionChange(e,t){this.syncVertices(e);const n=t.points[t.points.length-1]?.geometry.coordinates;if("keyboard"!==e.interfaceType&&n&&!e.coordPath){const r=t.features[0]?.geometry,o=Ct(r);e.selectedVertexIndex=this.findVertexIndex(o,n,e.selectedVertexIndex)}e.selectedVertexType??=e.selectedVertexIndex>=0?"vertex":null,this.map.fire(yt,{index:"vertex"===e.selectedVertexType?e.selectedVertexIndex:-1,numVertices:e.vertices.length});const r=n||(e.selectedVertexIndex>=0?e.vertices[e.selectedVertexIndex]:null);this.updateTouchVertexTarget(e,r?kt(this.map.project(r),e.scale):null)},onScaleChange(e,t){e.scale=t.scale},onInterfaceTypeChange(e,t){e.interfaceType=t.interfaceType;const n=e.selectedVertexIndex>=0?e.vertices[e.selectedVertexIndex]:null;this.updateTouchVertexTarget(e,n?kt(this.map.project(n),e.scale):null)},onUpdate(e){new Set(e.vertices.map(e=>JSON.stringify(e))).size!==e.vertices.length&&(e.selectedVertexIndex=-1,e.selectedVertexType??=null)},onMove(e){const t=e.vertices[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,kt(this.map.project(t),e.scale))},onNudgeVertex(e,t){this.nudgeVertexByDelta(e,t.dx,t.dy,t.isLargeStep);const n=e.vertices[e.selectedVertexIndex];n&&this.updateTouchVertexTarget(e,kt(this.map.project(n),e.scale))},onSelectVertex(e,t){e.vertices?.length||(e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId));const n=t.index<e.vertices.length?"vertex":"midpoint";this.changeMode(e,{selectedVertexIndex:t.index,selectedVertexType:n,..."vertex"===n&&{coordPath:this.getCoordPath(e,t.index)}})},onInsertVertexAtMidpoint(e,t){e.vertices?.length||(e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),this.insertVertex({...e,selectedVertexIndex:t.index,selectedVertexType:"midpoint"})},onButtonClick(e,t){t.target.closest(`#${e.deleteVertexButtonId}`)&&"vertex"===e.selectedVertexType&&this.deleteVertex(e),t.target.closest(`#${e.undoButtonId}`)&&this.handleUndo(e)},clickNoTarget(e){this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,isPanEnabled:!0})},changeMode(e,t){e.featureId&&this._ctx.api.changeMode("edit_vertex",{...e,...t})},onStop(e){this.map._drawEditContainer=null,this.map._editingFeatureId=null;const t=this.handlers;this.map.off("draw.selectionchange",t.selectionchange),this.map.off("draw.update",t.update),this.map.off(It,t.selectvertex),this.map.off(wt,t.insertvertexatmidpoint),zt(e,this.map,t),this.hideTouchVertexIndicator(e)}},gn={move_point:"commit-move"},mn={...Wt,UNDO_OP_PHASE:{move_point:"commit-move"},UNDO_INVERSE_PHASE:gn,handleUndo(e){const t=this.map._undoStack;if(!t||0===t.length)return;const n=t.pop();"move_point"===n.type&&this.undoMovePoint(e,n),this.emitGeometryValidation(gn[n.type],n.vertexIndex,n.featureId)},undoMovePoint(e,t){const{previousPosition:n,featureId:r}=t,o=this.getFeature(r);o&&(o.updateCoordinate("",n[0],n[1]),this._ctx.store.render(),this.fireGeometryChange(e),this.updateTouchPointTarget(e,kt(this.map.project(n),e.scale)))}},yn={addTouchPointTarget(e){e.touchPointTarget=(0,o.c)(e.container),en(e.touchPointTarget,this.map._drawCurrentMapStyle,this.map._drawPluginConfig)},updateTouchPointTarget(e,t){t&&"touch"===e.interfaceType?Object.assign(e.touchPointTarget.style,{display:"block",top:`${t.y}px`,left:`${t.x}px`}):e.touchPointTarget.style.display="none"},hideTouchPointIndicator(e){e.touchPointTarget.style.display="none"},onPointerevent(e,t){e.interfaceType="touch"===t.pointerType?"touch":"mouse",e.isPanEnabled=!0},onTouchStart(){},onTouchMove(){},onTouchEnd(){},onTouchend(e){jt(Rt(this.map)),e._touchMoved&&e._moveStartPosition&&this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,e._touchMoved=!1,e.feature&&this.updateTouchPointTarget(e,kt(this.map.project(e.feature.coordinates),e.scale))},onTap(){},onTouchstart(e,t){jt(Rt(this.map));const n=this.getPointCoord(e);if(!n||!Dt(t.target.parentNode))return;e._moveStartPosition=[...n],e._touchMoved=!1;const r=Xt(t);Object.assign(e,Zt(this.map,e.touchPointTarget,r,n,e.scale))},onTouchmove(e,t){if(!Dt(t.target.parentNode))return;e._touchMoved=!0;const n=Xt(t);this.movePoint(e,Qt(this.map,e,n)),this.updateTouchPointTarget(e,{x:n.x-e.deltaTarget.x,y:n.y-e.deltaTarget.y})}},vn={...cn,getPointCoord(e){return this.getFeature(e.featureId)?.coordinates},getNewCoord(e,t){return this.getOffset(this.getPointCoord(e),t)},movePoint(e,t){e.feature.updateCoordinate("",t.lng,t.lat),this._ctx.store.render(),this.map.fire("draw.geometrychange",e.feature)},nudgePointByDelta(e,t,n,r){const o=this.getPointCoord(e);if(!o)return;const i=[...o],s=this.resolveSnapTarget(e,t,n,o,()=>this.getOffsetByDelta(o,t,n,r));this.movePoint(e,s),this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:i})}},bn={...ln,onKeydown(e,t){sn(e)||(e.interfaceType="keyboard",this.hideTouchPointIndicator(e)," "!==t.key?nn.has(t.key)?this.handleArrowKey(e,t):an(t)&&this.handleUndoShortcut(e,t):t.preventDefault())},handleArrowKey(e,t){t.preventDefault(),t.stopPropagation(),this.movePointByKey(e,t)},movePointByKey(e,t){const n=this.getPointCoord(e);n&&(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=[...n]),this.movePoint(e,this._keyboardMoveTarget(e,t,n)))},_keyboardMoveTarget(e,t,n){const[r,o]=rn[t.key];return this.resolveSnapTarget(e,r,o,n,()=>this.getNewCoord(e,t))},onKeyup(e,t){sn(e)||(e.interfaceType="keyboard",(0,o.b)(t),nn.has(t.key)&&(t.stopPropagation(),e._keyboardMoveStartPosition&&(this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null)))}},_n="edit_point",En={onFeature(e,t){e.dragMoving||(e._moveStartPosition=[...e.feature.coordinates],e._grabOffset=[e.feature.coordinates[0]-t.lngLat.lng,e.feature.coordinates[1]-t.lngLat.lat],Bt(Rt(this.map),!0)),Ye.onFeature.call(this,e,t)},onClick(e,t){if(b(t))return;if(!((e,t)=>{const n={type:"Feature",geometry:{type:"Point",coordinates:t},properties:{}},{valid:o,reason:i}=(0,r.v)(n,{mode:_n,vertexIndex:0},{onGeometryChange:e._drawGeometryValidator});return o||e.fire("draw.placementblocked",{feature:n,reason:i??null,phase:"place",mode:_n,vertexIndex:0}),o})(this.map,[t.lngLat.lng,t.lngLat.lat]))return;const n=[...e.feature.coordinates],o=Rt(this.map);let i=t.lngLat;Ht(e)&&o&&(Vt(o,this.map,t.point),i=Ft(o)||t.lngLat),this.movePoint(e,i),this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:n})},onMouseUp(e,t){const n=Rt(this.map);jt(n),Bt(n,!1),this._didPointMove(e)&&this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,Ye.onMouseUp.call(this,e,t)},_didPointMove(e){if(!e._moveStartPosition)return!1;const t=e.feature.coordinates;return t[0]!==e._moveStartPosition[0]||t[1]!==e._moveStartPosition[1]},onDrag(e,t){if("touch"===e.interfaceType)return;this.map.fire("draw.geometrychange",e.feature);const n=Rt(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),!Ht(e)||!n?.status)return void Ye.onDrag.call(this,e,t);if(!e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng+e._grabOffset[0],lat:t.lngLat.lat+e._grabOffset[1]};Vt(n,this.map,this.map.project([r.lng,r.lat]));const o=Ft(n)||r;e.feature.updateCoordinate("",o.lng,o.lat),e.dragMoveLocation=t.lngLat},onTrash(){}},Sn={...dt.modes.direct_select,...mn,...yn,...vn,...bn,...En,onSetup(e){const t=e.featureId,n=this.getFeature(t);if(!n)throw new Error("You must provide a featureId to enter edit_point mode");const r={featureId:t,feature:n,dragMoveLocation:null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:[]};return this.setSelectedCoordinates([]),this.setSelected(t),ke.disable(this),this.setActionableState({trash:!1}),Object.assign(r,{container:e.container,interfaceType:e.interfaceType,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,scale:e.scale??1}),this.map._lastEditFeatureId!==r.featureId&&(this.map._undoStack?.clear(),this.map._lastEditFeatureId=r.featureId),this.setupEventListeners(r),this.map._drawEditContainer=e.container,this.addTouchPointTarget(r),r.container?.focus({preventScroll:!0}),Kt(this.map),"touch"===r.interfaceType&&setTimeout(()=>{this.updateTouchPointTarget(r,kt(this.map.project(r.feature.coordinates),r.scale))},0),this.map.fire(yt,{index:0,numVertices:1}),r},setupEventListeners(e){const t=this.handlers=$t(this,e,{nudge:this.onNudgePoint});Yt(e,this.map,t)},toDisplayFeatures(e,t,n){t.properties.active=e.featureId===t.properties.id?"true":"false",n(t)},onScaleChange(e,t){e.scale=t.scale},onInterfaceTypeChange(e,t){e.interfaceType=t.interfaceType,this.updateTouchPointTarget(e,kt(this.map.project(e.feature.coordinates),e.scale))},onMove(e){this.updateTouchPointTarget(e,kt(this.map.project(e.feature.coordinates),e.scale))},onNudgePoint(e,t){this.nudgePointByDelta(e,t.dx,t.dy,t.isLargeStep),this.updateTouchPointTarget(e,kt(this.map.project(e.feature.coordinates),e.scale))},onButtonClick(e,t){t.target.closest(`#${e.undoButtonId}`)&&this.handleUndo(e)},onStop(e){this.map._drawEditContainer=null,this.map._editingFeatureId=null,zt(e,this.map,this.handlers),this.hideTouchPointIndicator(e)}},xn=({ParentMode:e,featureProp:t,excludeFeatureIdFromSetup:n})=>({onSetup(r){const{map:i}=this,s=n?{...r,featureId:null}:r,a={...e.onSetup.call(this,s),...r};a[t].properties=r.properties;const{container:l,vertexMarkerId:c,getInterfaceType:d}=a,u=d?d():a.interfaceType;a.interfaceType=u;const p=l.querySelector(`#${c}`);a.vertexMarker=p,["touch","keyboard"].includes(u)?this._showCrossHair(a):this._hideCrossHair(a),a.crossHair&&(a.crossHair.activate=()=>this._placeAtCrossHair?.(a));const h=(e,t)=>this[e]=t.bind(this,a),f={keydownHandler:this.onKeydown,keyupHandler:this.onKeyup,blurHandler:this.onBlur,createHandler:this.onCreate,moveHandler:this.onMove,pointerdownHandler:this.onPointerdown,pointermoveHandler:this.onPointermove,pointerupHandler:this.onPointerup,vertexButtonClickHandler:this.onVertexButtonClick,undoHandler:this.onUndo,interfaceTypeChangeHandler:this.onInterfaceTypeChange};return Object.entries(f).forEach(([e,t])=>h(e,t)),this._listeners=[[window,"keydown",this.keydownHandler],[window,"keyup",this.keyupHandler],[window,"keyup",o.b,{capture:!0}],[window,"click",this.vertexButtonClickHandler],[l,"blur",this.blurHandler],[l,"pointermove",this.pointermoveHandler],[l,"pointerup",this.pointerupHandler],[i,"pointerdown",this.pointerdownHandler],[i,"draw.create",this.createHandler],[i,"move",this.moveHandler],[i,"draw.undo",this.undoHandler],[i,"draw.interfacetypechange",this.interfaceTypeChangeHandler]],this._listeners.forEach(([e,t,n,r])=>e.addEventListener?e.addEventListener(t,n,r):e.on(t,n)),a},onStop(t){e.onStop.call(this,t),this._listeners.forEach(([e,t,n,r])=>e.removeEventListener?e.removeEventListener(t,n,r):e.off(t,n)),t.crossHair?.activate&&(t.crossHair.activate=null),["touch","keyboard"].includes(t.interfaceType)||this._hideCrossHair(t),this.map.fire("draw.interfacetypechange",{interfaceType:t.interfaceType})}}),In=({geometryType:e,getFeature:t,getCoords:n})=>({_isIgnorableClick(e){return e.originalEvent.button>0||this.map._undoInProgress||e.originalEvent.target!==this.map.getCanvas()},_canPlaceVertex(o,i){const s=t(o);if(!s||!i)return!0;const a=(0,r.a)({placed:n(s).slice(0,-1),point:i,geometryType:e,onGeometryChange:this.map._drawGeometryValidator});return a.valid||this.map.fire("draw.placementblocked",a.blocked),a.valid},dispatchVertexChange(e){this.map.fire("draw.vertexchange",{numVertices:Math.max(0,e.length-1)})},emitDrawValidation(e,r="commit-add"){((e,t,n,r,o)=>{setTimeout(()=>{const i=t(r);i&&e.fire("draw.geometrychange",((e,t,n)=>{const r=t(e).slice(0,-1);return{feature:{type:"Feature",geometry:"Polygon"===e.toGeoJSON().geometry.type?{type:"Polygon",coordinates:[r]}:{type:"LineString",coordinates:r},properties:{}},phase:n,vertexIndex:Math.max(0,r.length-1)}})(i,n,o))},0)})(this.map,t,n,e,r)},onTap(){},onVertexButtonClick(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest(`#${e.addVertexButtonId}`)&&this.doClick(e)},onCreate(e,t){((e,t,n)=>{e.delete(t.id),t.id=n,e.add(t,{userProperties:!0})})(this._ctx.api,t.features[0],e.featureId)}}),wn=({ParentMode:e,getFeature:t,getCoords:n,validateClick:r,finishOnInvalidClick:o})=>({onClick(i,s){if(this._isIgnorableClick(s))return;if(!1===this.map._drawGeometryValid&&"vertex"===s.featureTarget?.properties?.meta)return;const a=Rt(this.map);if(Ht(i)&&Nt(a))s=function(e,t){const n=Ft(t);return n?{...e,lngLat:n}:e}(s,a);else if(!((e,i)=>{const s=n(t(e));return s.length>0&&(s[s.length-1]=[i.lngLat.lng,i.lngLat.lat]),o||r(t(e))})(i,s))return;if(!this._canPlaceVertex(i,[s.lngLat.lng,s.lngLat.lat]))return;const l=n(t(i)).length;e.onClick.call(this,i,s),n(t(i)).length>l&&(this.pushDrawUndo(i),this.dispatchVertexChange(n(t(i))),this.emitDrawValidation(i))},doClick(i){if(this.map._undoInProgress)return;const s=t(i),a=n(s);if(this.dispatchVertexChange(a),!r(s))return void(o&&!1!==this.map._drawGeometryValid&&(a.pop(),this.map.fire("draw.create",{features:[s.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[s.id]})));const l=Rt(this.map),c=Ht(i)&&function(e,t){const n=Ft(t);if(!n)return null;const r=e.project([n.lng,n.lat]);return{lngLat:n,point:r,originalEvent:new MouseEvent("click",{clientX:r.x,clientY:r.y,bubbles:!0,cancelable:!0})}}(this.map,l),d=c?c.lngLat:this.map.getCenter();if(!this._canPlaceVertex(i,[d.lng,d.lat]))return;c?(e.onClick.call(this,i,c),this._ctx.store.render()):this._simulateMouse("click",e.onClick,i);const u=n(t(i));this.pushDrawUndo(i),this.dispatchVertexChange(u),this.emitDrawValidation(i)},_placeAtCrossHair(e){this.doClick(e)}}),Pn=e=>({...In(e),...wn(e)}),Cn=({geometryType:e,getFeature:t})=>({pushDrawUndo(n){const r=this.map._undoStack;r&&!this.map._undoInProgress&&r.push({type:"draw_vertex",geometryType:e,featureId:t(n).id})},onUndo(e){const t=this.map._undoStack;if(!t||0===t.length)return;const n=t.pop();"draw_vertex"===n?.type&&(this.map._undoInProgress=!0,setTimeout(()=>{this.map._undoInProgress=!1},100),this.undoVertex(e),this.emitDrawValidation(e,"commit-delete"))},_handleUndoKeydown(e,t){const n=document.activeElement?.tagName;"INPUT"!==n&&"TEXTAREA"!==n&&(t.preventDefault(),t.stopPropagation(),this.onUndo(e))}}),Tn=({ParentMode:e,geometryType:t,getCoords:n,getFeature:r,RUBBER_BAND_OFFSET:o})=>({undoVertex(e){const t=r(e),o=n(t);return!(o.length<2)&&(2===o.length?this._reinitializeFeature(e,t):(this._removeLastVertex(e,t,o),!0))},_removeLastVertex(e,r,i){const s="Polygon"===t?r.coordinates[0]:i;s.splice(-o,1),s[s.length-1]=[...s[s.length-2]],e.currentVertexPosition=Math.max(1,e.currentVertexPosition-1),this._ctx.store.render(),this._updateRubberBand(e,n(r))},_updateRubberBand(n,r){if(["touch","keyboard"].includes(n.interfaceType))this._simulateMouse("mousemove",e.onMouseMove,n),this._ctx.store.render();else{const o=r["Polygon"===t?r.length-2:r.length-1],i={lng:o[0],lat:o[1]},s=this.map.project(i);e.onMouseMove.call(this,n,{lngLat:i,point:s,originalEvent:new MouseEvent("mousemove",{clientX:s.x,clientY:s.y})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",n.polygon||n.line)}this.dispatchVertexChange(r)}}),Mn=({ParentMode:e,featureProp:t,geometryType:n})=>({_reinitializeFeature(r,o){const i=o.id;if(this._ctx.store.delete([i]),"LineString"===n)return this._restartLineStringDraw(r,i);const s=this.map.getCenter(),a=[[s.lng,s.lat],[s.lng,s.lat]],l=this.newFeature({type:"Feature",properties:r.properties||{},geometry:{type:n,coordinates:[a]}});return l.id=i,this._ctx.store.add(l),r[t]=l,r.currentVertexPosition=0,this._ctx.store.render(),this._simulateMouse("mousemove",e.onMouseMove,r),this._ctx.store.render(),this.dispatchVertexChange(a),!0},_restartLineStringDraw(e,t){const n=this.map._undoStack;return n&&n.clear(),this._ctx.api.changeMode("draw_line",{featureId:t,container:e.container,interfaceType:e.interfaceType,crossHair:e.crossHair,vertexMarkerId:e.vertexMarkerId,addVertexButtonId:e.addVertexButtonId,getSnapEnabled:e.getSnapEnabled,properties:e.properties}),!0}}),Ln=e=>({...Cn(e),...Tn(e),...Mn(e)}),An=({ParentMode:e,getFeature:t,INTERFACE_KEYS:n})=>({onKeydown(e,t){"z"!==t.key||!t.metaKey&&!t.ctrlKey||t.shiftKey?document.activeElement===e.container&&("Escape"!==t.key?("Enter"===t.key&&(e.isActive=!0),n.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e,t))):t.preventDefault()):this._handleUndoKeydown(e,t)},onKeyup(e,t){"Escape"!==t.key?document.activeElement===e.container&&n.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e,t),"Enter"===t.key&&e.isActive&&this.doClick(e)):"keyboard"!==e.interfaceType&&this.map.fire("draw.cancel")},onKeyUp(n,r){const o=document.activeElement;if(!o||o===n.container||!n.container.contains(o))if("Escape"!==r.key)o!==n.container&&e.onKeyUp.call(this,n,r);else if("keyboard"===n.interfaceType){const e=this.map._undoStack;e&&e.clear(),this._reinitializeFeature(n,t(n))}}}),On=({ParentMode:e,getFeature:t,getCoords:n})=>({onTouchStart(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onTouchEnd(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onInterfaceTypeChange(e,t){this._setInterface(e,t.interfaceType,["touch","keyboard"].includes(t.interfaceType)),this.onMove(e)},onBlur(e,t){t.target!==e.container&&this._hideCrossHair(e)},onMouseMove(t,n){if(Ht(t)){const e=Rt(this.map);Vt(e,this.map,n.point);const t=Ft(e);t&&(n={...n,lngLat:t})}e.onMouseMove.call(this,t,n),this.map.fire("draw.geometrychange",t.polygon||t.line)},onMove(t,n){const r="move"===n?.type&&!n.originalEvent;if(["touch","keyboard"].includes(t.interfaceType)||r){Ht(t)&&Ut(Rt(this.map),this.map);const n=Rt(this.map),r=Ht(t)&&Ft(n);if(r){const n=this.map.project([r.lng,r.lat]);e.onMouseMove.call(this,t,{lngLat:r,point:n,originalEvent:new MouseEvent("mousemove",{clientX:n.x,clientY:n.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",t.polygon||t.line)}else this._simulateMouse("mousemove",e.onMouseMove,t)}},onPointerdown(e,t){"touch"!==t.pointerType&&this._setInterface(e,"mouse",!1)},onPointermove(e,t){"touch"!==t.pointerType&&this._hideCrossHair(e)},onPointerup(e){this.dispatchVertexChange(n(t(e)))}}),kn=({ParentMode:e,geometryType:t,getFeature:n,getPlacedCoords:r})=>({_simulateMouse(e,t,n){const{map:r}=this,o=r.getCenter(),i=r.project(o);t.call(this,n,{lngLat:o,point:i,originalEvent:new MouseEvent(e,{clientX:i.x,clientY:i.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",n.polygon||n.line)},_showCrossHair(e){e.crossHair?e.crossHair.show():e.vertexMarker.style.display="block"},_hideCrossHair(e){e.crossHair?e.crossHair.hide():e.vertexMarker.style.display="none"},_setInterface(e,t,n=!0){e.interfaceType=t,n&&this._showCrossHair(e)},toDisplayFeatures(o,i,s){e.toDisplayFeatures.call(this,o,i,s);const a=n(o);i.geometry.type===t&&i.properties.id===a.id&&r(i).forEach(e=>s({type:"Feature",properties:{meta:"draw-vertex",parent:a.id,active:"false"},geometry:{type:"Point",coordinates:e}}))}}),Dn=(e,t)=>{const{featureProp:n,geometryType:r,getCoords:o,validateClick:i,getPlacedCoords:s,excludeFeatureIdFromSetup:a=!1,finishOnInvalidClick:l=!1}=t,c={ParentMode:e,featureProp:n,geometryType:r,getCoords:o,validateClick:i,getPlacedCoords:s,excludeFeatureIdFromSetup:a,finishOnInvalidClick:l,getFeature:e=>e[n],RUBBER_BAND_OFFSET:2,INTERFACE_KEYS:new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"])};return{...e,...xn(c),...Pn(c),...Ln(c),...An(c),...On(c),...kn(c)}},Rn=Dn(dt.modes.draw_polygon,{featureProp:"polygon",geometryType:"Polygon",getCoords:e=>e.coordinates[0],validateClick:e=>(0,r.b)(e.coordinates),getPlacedCoords:e=>e.geometry.coordinates[0].slice(0,-2)}),Nn=Dn(dt.modes.draw_line_string,{featureProp:"line",geometryType:"LineString",getCoords:e=>e.coordinates,validateClick:e=>(0,r.d)(e.coordinates),excludeFeatureIdFromSetup:!0,finishOnInvalidClick:!0,getPlacedCoords:e=>e.geometry.coordinates.slice(0,-1)}),Fn="draw_point",Vn=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"]),Bn=dt.modes.draw_point,Un=xn({ParentMode:Bn,featureProp:"point",excludeFeatureIdFromSetup:!1}),Gn={onKeyUp(){},_showCrossHair(e){e.crossHair?e.crossHair.show():e.vertexMarker.style.display="block"},_hideCrossHair(e){e.crossHair?e.crossHair.hide():e.vertexMarker.style.display="none"},_setInterface(e,t,n=!0){e.interfaceType=t,n&&this._showCrossHair(e)},onCreate(e,t){const n=t.features[0];this._ctx.api.delete(n.id),n.id=e.featureId,this._ctx.api.add(n,{userProperties:!0}),e.resolvePointSymbol?.(e.featureId,n.properties)},onUndo(){},onPointerup(){},onMove(e,t){const n="move"===t?.type&&!t.originalEvent;(["touch","keyboard"].includes(e.interfaceType)||n)&&Ht(e)&&Ut(Rt(this.map),this.map)},onBlur(e,t){t.target!==e.container&&this._hideCrossHair(e)},onPointerdown(e,t){"touch"!==t.pointerType&&this._setInterface(e,"mouse",!1)},onPointermove(e,t){"touch"!==t.pointerType&&this._hideCrossHair(e)},onTouchStart(e){this._setInterface(e,"touch"),this.onMove(e)},onTouchEnd(e){this._setInterface(e,"touch"),this.onMove(e)},onInterfaceTypeChange(e,t){this._setInterface(e,t.interfaceType,["touch","keyboard"].includes(t.interfaceType)),this.onMove(e)},onMouseMove(e,t){Ht(e)&&Vt(Rt(this.map),this.map,t.point)},onVertexButtonClick(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest(`#${e.addVertexButtonId}`)&&this._placeAtCrossHair(e)},onKeydown(e,t){document.activeElement===e.container&&("Escape"!==t.key?("Enter"===t.key&&(e.isActive=!0),Vn.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e))):t.preventDefault())},onKeyup(e,t){"Escape"!==t.key?document.activeElement===e.container&&Vn.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e),"Enter"===t.key&&e.isActive&&this._placeAtCrossHair(e)):this.map.fire("draw.cancel")},onClick(e,t){if(t.originalEvent.button>0||t.originalEvent.target!==this.map.getCanvas())return;const n=Rt(this.map),r=Ht(e)&&Nt(n)?Ft(n):null;this._commit(e,r||t.lngLat)},onTap(e,t){this.onClick(e,t)},_placeAtCrossHair(e){const t=Rt(this.map);Ht(e)&&Ut(t,this.map);const n=Ht(e)&&Nt(t)?Ft(t):null;this._commit(e,n||this.map.getCenter()),this._ctx.store.render()},_commit(e,t){((e,t)=>{const n={type:"Feature",geometry:{type:"Point",coordinates:t},properties:{}},{valid:o,reason:i}=(0,r.v)(n,{mode:Fn,vertexIndex:0},{onGeometryChange:e._drawGeometryValidator});return o||e.fire("draw.placementblocked",{feature:n,reason:i??null,phase:"place",mode:Fn,vertexIndex:0}),o})(this.map,[t.lng,t.lat])&&(e.point.updateCoordinate("",t.lng,t.lat),this.map.fire("draw.create",{features:[e.point.toGeoJSON()]}))}},jn={...Bn,...Un,...Gn},Hn=(e,t,n)=>["coalesce",["get",`user_${t}${e.id.charAt(0).toUpperCase()+e.id.slice(1)}`],["get",`user_${t}`],n],$n=["coalesce",["get","user_sortKey"],0],Yn=(e,t)=>({id:"fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","false"]],layout:{"fill-sort-key":$n},paint:{"fill-color":Hn(e,"fill",t.shapeFill)}}),zn=(e,t)=>({id:"stroke-inactive",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","false"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round","line-sort-key":$n},paint:{"line-color":Hn(e,"stroke",t.shapeStroke),"line-width":t.strokeWidth}}),Kn=e=>({id:"stroke-preview-line",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}),Wn=(e,t)=>({id:"vertex",type:"circle",filter:["all",["==","$type","Point"],["in","meta","vertex","draw-vertex"]],paint:{"circle-radius":t,"circle-color":e}}),Jn=(e,t,n)=>({id:"vertex-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":n,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}),qn=(e,t)=>({id:"vertex-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":t,"circle-color":e}}),Xn=(e,t)=>({id:"midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":t,"circle-color":e}}),Zn=(e,t,n)=>({id:"midpoint-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":n,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}),Qn=(e,t)=>({id:"midpoint-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":t,"circle-color":e}}),er=e=>({id:"circle",type:"line",filter:["==","id","circle"],paint:{"line-color":e,"line-width":2,"line-opacity":.8}}),tr=(e,t={})=>{const n=(0,o.r)(e,t),{vertexRadius:i,midpointRadius:s,vertexHaloRadius:a,midpointHaloRadius:l}=r.S;return[Yn(e,n),(h=n.editFill,{id:"fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":h}}),(p=n.editStroke,{id:"stroke-active",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":p,"line-width":2,"line-opacity":1}}),(u=n.invalidStroke,{id:"stroke-active-invalid",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round",visibility:"none"},paint:{"line-color":u,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}),zn(e,n),{id:"point-symbol",type:"symbol",filter:["all",["==","$type","Point"],["==","meta","feature"]],layout:{"icon-image":["case",["==",["get","active"],"true"],["coalesce",["get","user_symbolSelectedImageId"],["get","user_symbolImageId"]],["get","user_symbolImageId"]],"icon-anchor":["get","user_symbolIconAnchor"],"icon-offset":["literal",[0,0]],"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":$n},paint:{}},(d=n.splitInvalid,{id:"stroke-invalid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","invalid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":d,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}),(c=n.splitValid,{id:"stroke-valid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","valid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":c,"line-width":2,"line-opacity":1}}),Kn(n.editStroke),Xn(n.editMidpoint,s),Zn(n.editHalo,n.editActive,l),Qn(n.editMidpoint,s),Wn(n.editVertex,i),Jn(n.editHalo,n.editActive,a),qn(n.editVertex,i),er(n.editStroke),{id:"touch-vertex-indicator",type:"circle",filter:["all",["==","$type","Point"],["==","meta","touch-vertex-indicator"]],paint:{"circle-radius":30,"circle-color":"#3bb2d0","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":.9}}];var c,d,u,p,h};function nr(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function rr(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 or(e,t,n){void 0===n&&(n={});var o=nr(e),i=nr(t),s=(0,r.e)(i[1]-o[1]),a=(0,r.e)(i[0]-o[0]),l=(0,r.e)(o[1]),c=(0,r.e)(i[1]),d=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(l)*Math.cos(c);return(0,r.r)(2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)),n.units)}function ir(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function sr(e,t,n,o={}){const i=ir(e),s=(0,r.e)(i[0]),a=(0,r.e)(i[1]),l=(0,r.e)(n),c=(0,r.l)(t,o.units),d=Math.asin(Math.sin(a)*Math.cos(c)+Math.cos(a)*Math.sin(c)*Math.cos(l)),u=s+Math.atan2(Math.sin(l)*Math.sin(c)*Math.cos(a),Math.cos(c)-Math.sin(a)*Math.sin(d)),p=(0,r.f)(u),h=(0,r.f)(d);return void 0!==i[2]?(0,r.p)([p,h,i[2]],o.properties):(0,r.p)([p,h],o.properties)}function ar(e,t){var n;return void 0===t&&(t={}),function(e,t){return e.length>1?(0,r.m)(e,t):(0,r.h)(e[0],t)}(("Feature"===(n=e).type?n.geometry:n).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}var lr=function e(t,n,o={}){if(!0===o.final)return function(t,n){let r=e(n,t);return r=(r+180)%360,r}(t,n);const i=ir(t),s=ir(n),a=(0,r.e)(i[0]),l=(0,r.e)(s[0]),c=(0,r.e)(i[1]),d=(0,r.e)(s[1]),u=Math.sin(l-a)*Math.cos(d),p=Math.cos(c)*Math.sin(d)-Math.sin(c)*Math.cos(d)*Math.cos(l-a);return(0,r.f)(Math.atan2(u,p))};function cr(e,t,n,o){void 0===o&&(o={});var i=nr(e),s=(0,r.e)(i[0]),a=(0,r.e)(i[1]),l=(0,r.e)(n),c=(0,r.l)(t,o.units),d=Math.asin(Math.sin(a)*Math.cos(c)+Math.cos(a)*Math.sin(c)*Math.cos(l)),u=s+Math.atan2(Math.sin(l)*Math.sin(c)*Math.cos(a),Math.cos(c)-Math.sin(a)*Math.sin(d)),p=(0,r.f)(u),h=(0,r.f)(d);return(0,r.p)([p,h],o.properties)}function dr(e){if(!e)throw new Error("geojson is required");var t=[];return(0,r.j)(e,function(e){!function(e,t){var n=[],o=e.geometry;if(null!==o){switch(o.type){case"Polygon":n=rr(o);break;case"LineString":n=[rr(o)]}n.forEach(function(n){var o=function(e,t){var n=[];return e.reduce(function(e,o){var i,s,a,l,c,d,u=(0,r.h)([e,o],t);return u.bbox=(s=o,a=(i=e)[0],l=i[1],[a<(c=s[0])?a:c,l<(d=s[1])?l:d,a>c?a:c,l>d?l:d]),n.push(u),o}),n}(n,e.properties);o.forEach(function(e){e.id=t.length,t.push(e)})})}}(e,t)}),(0,r.k)(t)}var ur={exports:{}};function pr(e,t,n,r,o){hr(e,t,n||0,r||e.length-1,o||gr)}function hr(e,t,n,r,o){for(;r>n;){if(r-n>600){var i=r-n+1,s=t-n+1,a=Math.log(i),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(i-l)/i)*(s-i/2<0?-1:1);hr(e,t,Math.max(n,Math.floor(t-s*l/i+c)),Math.min(r,Math.floor(t+(i-s)*l/i+c)),o)}var d=e[t],u=n,p=r;for(fr(e,n,t),o(e[r],d)>0&&fr(e,n,r);u<p;){for(fr(e,u,p),u++,p--;o(e[u],d)<0;)u++;for(;o(e[p],d)>0;)p--}0===o(e[n],d)?fr(e,n,p):fr(e,++p,r),p<=t&&(n=p+1),t<=p&&(r=p-1)}}function fr(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function gr(e,t){return e<t?-1:e>t?1:0}function mr(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function yr(e,t){vr(e,0,e.children.length,t,e)}function vr(e,t,n,r,o){o||(o=Tr(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(let i=t;i<n;i++){const t=e.children[i];br(o,e.leaf?r(t):t)}return o}function br(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function _r(e,t){return e.minX-t.minX}function Er(e,t){return e.minY-t.minY}function Sr(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function xr(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Ir(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function wr(e,t){const n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),o=Math.min(e.maxX,t.maxX),i=Math.min(e.maxY,t.maxY);return Math.max(0,o-n)*Math.max(0,i-r)}function Pr(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Cr(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Tr(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Mr(e,t,n,r,o){const i=[t,n];for(;i.length;){if((n=i.pop())-(t=i.pop())<=r)continue;const s=t+Math.ceil((n-t)/r/2)*r;pr(e,s,t,n,o),i.push(t,s,s,n)}}var Lr,Ar=function(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var n=function e(){var n=!1;try{n=this instanceof e}catch{}return n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}(Object.freeze({__proto__:null,default:class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const n=[];if(!Cr(e,t))return n;const r=this.toBBox,o=[];for(;t;){for(let i=0;i<t.children.length;i++){const s=t.children[i],a=t.leaf?r(s):s;Cr(e,a)&&(t.leaf?n.push(s):Pr(e,a)?this._all(s,n):o.push(s))}t=o.pop()}return n}collides(e){let t=this.data;if(!Cr(e,t))return!1;const n=[];for(;t;){for(let r=0;r<t.children.length;r++){const o=t.children[r],i=t.leaf?this.toBBox(o):o;if(Cr(e,i)){if(t.leaf||Pr(e,i))return!0;n.push(o)}}t=n.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Tr([]),this}remove(e,t){if(!e)return this;let n=this.data;const r=this.toBBox(e),o=[],i=[];let s,a,l;for(;n||o.length;){if(n||(n=o.pop(),a=o[o.length-1],s=i.pop(),l=!0),n.leaf){const r=mr(e,n.children,t);if(-1!==r)return n.children.splice(r,1),o.push(n),this._condense(o),this}l||n.leaf||!Pr(n,r)?a?(s++,n=a.children[s],l=!1):n=null:(o.push(n),i.push(s),s=0,a=n,n=n.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,r){const o=n-t+1;let i,s=this._maxEntries;if(o<=s)return i=Tr(e.slice(t,n+1)),yr(i,this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,r-1))),i=Tr([]),i.leaf=!1,i.height=r;const a=Math.ceil(o/s),l=a*Math.ceil(Math.sqrt(s));Mr(e,t,n,l,this.compareMinX);for(let c=t;c<=n;c+=l){const t=Math.min(c+l-1,n);Mr(e,c,t,a,this.compareMinY);for(let n=c;n<=t;n+=a){const o=Math.min(n+a-1,t);i.children.push(this._build(e,n,o,r-1))}}return yr(i,this.toBBox),i}_chooseSubtree(e,t,n,r){for(;r.push(t),!t.leaf&&r.length-1!==n;){let n,r=1/0,o=1/0;for(let i=0;i<t.children.length;i++){const s=t.children[i],a=Sr(s),l=Ir(e,s)-a;l<o?(o=l,r=a<r?a:r,n=s):l===o&&a<r&&(r=a,n=s)}t=n||t.children[0]}return t}_insert(e,t,n){const r=n?e:this.toBBox(e),o=[],i=this._chooseSubtree(r,this.data,t,o);for(i.children.push(e),br(i,r);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(r,o,t)}_split(e,t){const n=e[t],r=n.children.length,o=this._minEntries;this._chooseSplitAxis(n,o,r);const i=this._chooseSplitIndex(n,o,r),s=Tr(n.children.splice(i,n.children.length-i));s.height=n.height,s.leaf=n.leaf,yr(n,this.toBBox),yr(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(n,s)}_splitRoot(e,t){this.data=Tr([e,t]),this.data.height=e.height+1,this.data.leaf=!1,yr(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r,o=1/0,i=1/0;for(let s=t;s<=n-t;s++){const t=vr(e,0,s,this.toBBox),a=vr(e,s,n,this.toBBox),l=wr(t,a),c=Sr(t)+Sr(a);l<o?(o=l,r=s,i=c<i?c:i):l===o&&c<i&&(i=c,r=s)}return r||n-t}_chooseSplitAxis(e,t,n){const r=e.leaf?this.compareMinX:_r,o=e.leaf?this.compareMinY:Er;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,o)&&e.children.sort(r)}_allDistMargin(e,t,n,r){e.children.sort(r);const o=this.toBBox,i=vr(e,0,t,o),s=vr(e,n-t,n,o);let a=xr(i)+xr(s);for(let l=t;l<n-t;l++){const t=e.children[l];br(i,e.leaf?o(t):t),a+=xr(i)}for(let l=n-t-1;l>=t;l--){const t=e.children[l];br(s,e.leaf?o(t):t),a+=xr(s)}return a}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)br(t[r],e)}_condense(e){for(let t,n=e.length-1;n>=0;n--)0===e[n].children.length?n>0?(t=e[n-1].children,t.splice(t.indexOf(e[n]),1)):this.clear():yr(e[n],this.toBBox)}}})),Or={};function kr(){if(Lr)return Or;Lr=1,Object.defineProperty(Or,"__esModule",{value:!0});var e=6371008.8,t={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*e,kilometers:6371.0088,kilometres:6371.0088,meters:e,metres:e,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:e/1852,radians:1,yards:6967335.223679999},n={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:2.9155334959812285e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046};function r(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 o(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(!f(e[0])||!f(e[1]))throw new Error("coordinates must contain numbers");return r({type:"Point",coordinates:e},t,n)}function i(e,t,n={}){for(const r of e){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<r[r.length-1].length;e++)if(r[r.length-1][e]!==r[0][e])throw new Error("First and last Position are not equivalent.")}return r({type:"Polygon",coordinates:e},t,n)}function s(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return r({type:"LineString",coordinates:e},t,n)}function a(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function l(e,t,n={}){return r({type:"MultiLineString",coordinates:e},t,n)}function c(e,t,n={}){return r({type:"MultiPoint",coordinates:e},t,n)}function d(e,t,n={}){return r({type:"MultiPolygon",coordinates:e},t,n)}function u(e,n="kilometers"){const r=t[n];if(!r)throw new Error(n+" units is invalid");return e*r}function p(e,n="kilometers"){const r=t[n];if(!r)throw new Error(n+" units is invalid");return e/r}function h(e){return e%(2*Math.PI)*180/Math.PI}function f(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}return Or.areaFactors=n,Or.azimuthToBearing=function(e){return(e%=360)>180?e-360:e<-180?e+360:e},Or.bearingToAzimuth=function(e){let t=e%360;return t<0&&(t+=360),t},Or.convertArea=function(e,t="meters",r="kilometers"){if(!(e>=0))throw new Error("area must be a positive number");const o=n[t];if(!o)throw new Error("invalid original units");const i=n[r];if(!i)throw new Error("invalid final units");return e/o*i},Or.convertLength=function(e,t="kilometers",n="kilometers"){if(!(e>=0))throw new Error("length must be a positive number");return u(p(e,t),n)},Or.degreesToRadians=function(e){return e%360*Math.PI/180},Or.earthRadius=e,Or.factors=t,Or.feature=r,Or.featureCollection=a,Or.geometry=function(e,t,n={}){switch(e){case"Point":return o(t).geometry;case"LineString":return s(t).geometry;case"Polygon":return i(t).geometry;case"MultiPoint":return c(t).geometry;case"MultiLineString":return l(t).geometry;case"MultiPolygon":return d(t).geometry;default:throw new Error(e+" is invalid")}},Or.geometryCollection=function(e,t,n={}){return r({type:"GeometryCollection",geometries:e},t,n)},Or.isNumber=f,Or.isObject=function(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)},Or.lengthToDegrees=function(e,t){return h(p(e,t))},Or.lengthToRadians=p,Or.lineString=s,Or.lineStrings=function(e,t,n={}){return a(e.map(e=>s(e,t)),n)},Or.multiLineString=l,Or.multiPoint=c,Or.multiPolygon=d,Or.point=o,Or.points=function(e,t,n={}){return a(e.map(e=>o(e,t)),n)},Or.polygon=i,Or.polygons=function(e,t,n={}){return a(e.map(e=>i(e,t)),n)},Or.radiansToDegrees=h,Or.radiansToLength=u,Or.round=function(e,t=0){if(t&&!(t>=0))throw new Error("precision must be a positive number");const n=Math.pow(10,t||0);return Math.round(e*n)/n},Or.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(e=>{if(!f(e))throw new Error("bbox must only contain numbers")})},Or.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")},Or}var Dr,Rr={};function Nr(){if(Dr)return Rr;Dr=1,Object.defineProperty(Rr,"__esModule",{value:!0});var e=kr();function t(e,n,r){if(null!==e)for(var o,i,s,a,l,c,d,u,p=0,h=0,f=e.type,g="FeatureCollection"===f,m="Feature"===f,y=g?e.features.length:1,v=0;v<y;v++){l=(u=!!(d=g?e.features[v].geometry:m?e.geometry:e)&&"GeometryCollection"===d.type)?d.geometries.length:1;for(var b=0;b<l;b++){var _=0,E=0;if(null!==(a=u?d.geometries[b]:d)){c=a.coordinates;var S=a.type;switch(p=!r||"Polygon"!==S&&"MultiPolygon"!==S?0:1,S){case null:break;case"Point":if(!1===n(c,h,v,_,E))return!1;h++,_++;break;case"LineString":case"MultiPoint":for(o=0;o<c.length;o++){if(!1===n(c[o],h,v,_,E))return!1;h++,"MultiPoint"===S&&_++}"LineString"===S&&_++;break;case"Polygon":case"MultiLineString":for(o=0;o<c.length;o++){for(i=0;i<c[o].length-p;i++){if(!1===n(c[o][i],h,v,_,E))return!1;h++}"MultiLineString"===S&&_++,"Polygon"===S&&E++}"Polygon"===S&&_++;break;case"MultiPolygon":for(o=0;o<c.length;o++){for(E=0,i=0;i<c[o].length;i++){for(s=0;s<c[o][i].length-p;s++){if(!1===n(c[o][i][s],h,v,_,E))return!1;h++}E++}_++}break;case"GeometryCollection":for(o=0;o<a.geometries.length;o++)if(!1===t(a.geometries[o],n,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function n(e,t){var n;switch(e.type){case"FeatureCollection":for(n=0;n<e.features.length&&!1!==t(e.features[n].properties,n);n++);break;case"Feature":t(e.properties,0)}}function r(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 o(e,t){var n,r,o,i,s,a,l,c,d,u,p=0,h="FeatureCollection"===e.type,f="Feature"===e.type,g=h?e.features.length:1;for(n=0;n<g;n++){for(a=h?e.features[n].geometry:f?e.geometry:e,c=h?e.features[n].properties:f?e.properties:{},d=h?e.features[n].bbox:f?e.bbox:void 0,u=h?e.features[n].id:f?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,o=0;o<s;o++)if(null!==(i=l?a.geometries[o]:a))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,d,u))return!1;break;case"GeometryCollection":for(r=0;r<i.geometries.length;r++)if(!1===t(i.geometries[r],p,c,d,u))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,d,u))return!1;p++}}function i(t,n){o(t,function(t,r,o,i,s){var a,l=null===t?null:t.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return!1!==n(e.feature.call(void 0,t,o,{bbox:i,id:s}),r,0)&&void 0}switch(l){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var c=0;c<t.coordinates.length;c++){var d={type:a,coordinates:t.coordinates[c]};if(!1===n(e.feature.call(void 0,d,o),r,c))return!1}})}function s(n,r){i(n,function(n,o,i){var s=0;if(n.geometry){var a=n.geometry.type;if("Point"!==a&&"MultiPoint"!==a){var l,c=0,d=0,u=0;return!1!==t(n,function(t,a,p,h,f){if(void 0===l||o>c||h>d||f>u)return l=t,c=o,d=h,u=f,void(s=0);var g=e.lineString.call(void 0,[l,t],n.properties);if(!1===r(g,o,i,f,s))return!1;s++,l=t})&&void 0}}})}function a(t,n){if(!t)throw new Error("geojson is required");i(t,function(t,r,o){if(null!==t.geometry){var i=t.geometry.type,s=t.geometry.coordinates;switch(i){case"LineString":if(!1===n(t,r,o,0,0))return!1;break;case"Polygon":for(var a=0;a<s.length;a++)if(!1===n(e.lineString.call(void 0,s[a],t.properties),r,o,a))return!1}}})}return Rr.coordAll=function(e){var n=[];return t(e,function(e){n.push(e)}),n},Rr.coordEach=t,Rr.coordReduce=function(e,n,r,o){var i=r;return t(e,function(e,t,o,s,a){i=0===t&&void 0===r?e:n(i,e,t,o,s,a)},o),i},Rr.featureEach=r,Rr.featureReduce=function(e,t,n){var o=n;return r(e,function(e,r){o=0===r&&void 0===n?e:t(o,e,r)}),o},Rr.findPoint=function(t,n){if(n=n||{},!e.isObject.call(void 0,n))throw new Error("options is invalid");var r,o=n.featureIndex||0,i=n.multiFeatureIndex||0,s=n.geometryIndex||0,a=n.coordIndex||0,l=n.properties;switch(t.type){case"FeatureCollection":o<0&&(o=t.features.length+o),l=l||t.features[o].properties,r=t.features[o].geometry;break;case"Feature":l=l||t.properties,r=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=t;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":return e.point.call(void 0,c,l,n);case"MultiPoint":return i<0&&(i=c.length+i),e.point.call(void 0,c[i],l,n);case"LineString":return a<0&&(a=c.length+a),e.point.call(void 0,c[a],l,n);case"Polygon":return s<0&&(s=c.length+s),a<0&&(a=c[s].length+a),e.point.call(void 0,c[s][a],l,n);case"MultiLineString":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),e.point.call(void 0,c[i][a],l,n);case"MultiPolygon":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),a<0&&(a=c[i][s].length-a),e.point.call(void 0,c[i][s][a],l,n)}throw new Error("geojson is invalid")},Rr.findSegment=function(t,n){if(n=n||{},!e.isObject.call(void 0,n))throw new Error("options is invalid");var r,o=n.featureIndex||0,i=n.multiFeatureIndex||0,s=n.geometryIndex||0,a=n.segmentIndex||0,l=n.properties;switch(t.type){case"FeatureCollection":o<0&&(o=t.features.length+o),l=l||t.features[o].properties,r=t.features[o].geometry;break;case"Feature":l=l||t.properties,r=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=t;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return a<0&&(a=c.length+a-1),e.lineString.call(void 0,[c[a],c[a+1]],l,n);case"Polygon":return s<0&&(s=c.length+s),a<0&&(a=c[s].length+a-1),e.lineString.call(void 0,[c[s][a],c[s][a+1]],l,n);case"MultiLineString":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a-1),e.lineString.call(void 0,[c[i][a],c[i][a+1]],l,n);case"MultiPolygon":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),a<0&&(a=c[i][s].length-a-1),e.lineString.call(void 0,[c[i][s][a],c[i][s][a+1]],l,n)}throw new Error("geojson is invalid")},Rr.flattenEach=i,Rr.flattenReduce=function(e,t,n){var r=n;return i(e,function(e,o,i){r=0===o&&0===i&&void 0===n?e:t(r,e,o,i)}),r},Rr.geomEach=o,Rr.geomReduce=function(e,t,n){var r=n;return o(e,function(e,o,i,s,a){r=0===o&&void 0===n?e:t(r,e,o,i,s,a)}),r},Rr.lineEach=a,Rr.lineReduce=function(e,t,n){var r=n;return a(e,function(e,o,i,s){r=0===o&&void 0===n?e:t(r,e,o,i,s)}),r},Rr.propEach=n,Rr.propReduce=function(e,t,r){var o=r;return n(e,function(e,n){o=0===n&&void 0===r?e:t(o,e,n)}),o},Rr.segmentEach=s,Rr.segmentReduce=function(e,t,n){var r=n,o=!1;return s(e,function(e,i,s,a,l){r=!1===o&&void 0===n?e:t(r,e,i,s,a,l),o=!0}),r},Rr}var Fr,Vr,Br={},Ur=D(function(){if(Vr)return ur.exports;Vr=1;var e=Ar,t=kr(),n=Nr(),r=function(){if(Fr)return Br;Fr=1,Object.defineProperty(Br,"__esModule",{value:!0});var e=Nr();function t(t,n={}){if(null!=t.bbox&&!0!==n.recompute)return t.bbox;const r=[1/0,1/0,-1/0,-1/0];return e.coordEach.call(void 0,t,e=>{r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])}),r}var n=t;return Br.bbox=t,Br.default=n,Br}().default,o=n.featureEach;n.coordEach,t.polygon;var i=t.featureCollection;function s(t){var n=new e(t);return n.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:r(t),e.prototype.insert.call(this,t)},n.load=function(t){var n=[];return Array.isArray(t)?t.forEach(function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:r(e),n.push(e)}):o(t,function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:r(e),n.push(e)}),e.prototype.load.call(this,n)},n.remove=function(t,n){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:r(t),e.prototype.remove.call(this,t,n)},n.clear=function(){return e.prototype.clear.call(this)},n.search=function(t){var n=e.prototype.search.call(this,this.toBBox(t));return i(n)},n.collides=function(t){return e.prototype.collides.call(this,this.toBBox(t))},n.all=function(){var t=e.prototype.all.call(this);return i(t)},n.toJSON=function(){return e.prototype.toJSON.call(this)},n.fromJSON=function(t){return e.prototype.fromJSON.call(this,t)},n.toBBox=function(e){var t;if(e.bbox)t=e.bbox;else if(Array.isArray(e)&&4===e.length)t=e;else if(Array.isArray(e)&&6===e.length)t=[e[0],e[1],e[3],e[4]];else if("Feature"===e.type)t=r(e);else{if("FeatureCollection"!==e.type)throw new Error("invalid geojson");t=r(e)}return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}},n}return ur.exports=s,ur.exports.default=s,ur.exports}());function Gr(e,t){var n={},o=[];if("LineString"===e.type&&(e=(0,r.n)(e)),"LineString"===t.type&&(t=(0,r.n)(t)),"Feature"===e.type&&"Feature"===t.type&&null!==e.geometry&&null!==t.geometry&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var i=jr(e,t);return i&&o.push(i),(0,r.k)(o)}var s=Ur();return s.load(dr(t)),(0,r.o)(dr(e),function(e){(0,r.o)(s.search(e),function(t){var r=jr(e,t);if(r){var i=rr(r).join(",");n[i]||(n[i]=!0,o.push(r))}})}),(0,r.k)(o)}function jr(e,t){var n=rr(e),o=rr(t);if(2!==n.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==o.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var i=n[0][0],s=n[0][1],a=n[1][0],l=n[1][1],c=o[0][0],d=o[0][1],u=o[1][0],p=o[1][1],h=(p-d)*(a-i)-(u-c)*(l-s);if(0===h)return null;var f=((u-c)*(s-d)-(p-d)*(i-c))/h,g=((a-i)*(s-d)-(l-s)*(i-c))/h;return f>=0&&f<=1&&g>=0&&g<=1?(0,r.p)([i+f*(a-i),s+f*(l-s)]):null}function Hr(e,t,n){void 0===n&&(n={});var o=(0,r.p)([1/0,1/0],{dist:1/0}),i=0;return(0,r.j)(e,function(e){for(var s=rr(e),a=0;a<s.length-1;a++){var l=(0,r.p)(s[a]);l.properties.dist=or(t,l,n);var c=(0,r.p)(s[a+1]);c.properties.dist=or(t,c,n);var d=or(l,c,n),u=Math.max(l.properties.dist,c.properties.dist),p=lr(l,c),h=cr(t,u,p+90,n),f=cr(t,u,p-90,n),g=Gr((0,r.h)([h.geometry.coordinates,f.geometry.coordinates]),(0,r.h)([l.geometry.coordinates,c.geometry.coordinates])),m=null;g.features.length>0&&((m=g.features[0]).properties.dist=or(t,m,n),m.properties.location=i+or(l,m,n)),l.properties.dist<o.properties.dist&&((o=l).properties.index=a,o.properties.location=i),c.properties.dist<o.properties.dist&&((o=c).properties.index=a+1,o.properties.location=i+d),m&&m.properties.dist<o.properties.dist&&((o=m).properties.index=a),i+=d}}),o}function $r(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}var Yr=function(){return Yr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Yr.apply(this,arguments)},zr=function(){function e(e){var t;this.status=null!==(t=e.status)&&void 0!==t&&t,this.map=e.map,this.drawing=e.drawing,this.options=e.options,this.onSnapped=function(t){void 0!==e.onSnapped&&e.onSnapped(t)},this.features={},this.snapStatus=!1,this.snapCoords=[],this.radiusInMeters=0,this.addRadiusCircleLayer(),this.addEvents()}return e.prototype.changeSnappedPoints=function(){for(var e=this.drawing.getAll(),t=[],n=0;n<e.features.length;n++){var r=e.features[n],o=r.id;if(this.features[o]){var i=this.features[o].snapPoints;if(void 0!==this.features.unknow){var s=this.features.unknow.snapPoints;i=Yr(Yr({},i),s)}var a=this.doSnap(r,i);t.push(a)}else void 0!==this.features.unknow?(s=this.features.unknow.snapPoints,a=this.doSnap(r,s),t.push(a)):t.push(r)}var l={type:"FeatureCollection",features:t};this.drawing.set(l),this.onSnapped&&this.onSnapped(l)},e.prototype.isPointSnapped=function(e,t){return or((0,r.p)(e),(0,r.p)(t),{units:"meters"})<this.radiusInMeters},e.prototype.doSnap=function(e,t){switch(e.geometry.type){case"Point":var n=e.geometry.coordinates;for(var r in t)this.isPointSnapped(n,t[r])&&(e.geometry.coordinates=t[r]);break;case"Polygon":for(var o=e.geometry.coordinates,i=[],s=0;s<o.length;s++){for(var a=o[s],l=[],c=0;c<a.length;c++){var d=a[c],u=!1;for(var r in t)if(this.isPointSnapped(d,t[r])){u=!0,l.push(t[r]);break}0==u&&l.push(d)}i.push(l)}e.geometry.coordinates=i;break;case"LineString":var p=e.geometry.coordinates;for(l=[],c=0;c<p.length;c++){var h=p[c];for(var r in u=!1,t)if(this.isPointSnapped(h,t[r])){u=!0,l.push(t[r]);break}0==u&&l.push(h)}e.geometry.coordinates=l}return e},e.prototype.getMe=function(){return this},e.prototype.setStatus=function(e){this.status=e},e.prototype.setMapData=function(e){var t=this.map.getSource("snap-helper-circle");t&&t.setData(e)},e.prototype.snapToClosestPoint=function(e){if(this.status){var t=e.point,n=this.map.unproject(t),o=[t.x+this.options.radius,t.y],i=this.map.unproject(o),s=or((0,r.p)([n.lng,n.lat]),(0,r.p)([i.lng,i.lat]),{units:"meters"});this.radiusInMeters=s;var a=!1,l=this.getCloseFeatures(e,s);l?(this.snapStatus=!0,this.snapCoords=l.coords,a=function(e,t,n={}){const o=n.steps||64,i=n.properties?n.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},s=[];for(let r=0;r<o;r++)s.push(sr(e,t,-360*r/o,n).geometry.coordinates);return s.push(s[0]),(0,r.g)([s],i)}(l.coords,s,{steps:64,units:"meters",properties:{color:l.color}})):(this.snapStatus=!1,this.snapCoords=[]);var c=(0,r.k)(0==a?[]:[a]);this.setMapData(c)}},e.prototype.addEvents=function(){var e=this;this.map.on("mousemove",function(t){e.snapToClosestPoint(t)}),this.map.on("draw.delete",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.update",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.create",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.selectionchange",function(t){t.features.length>0?e.status=!0:(e.status=!1,e.setMapData((0,r.k)([])))}),this.map.on("draw.modechange",function(t){e.status=!0,"simple_select"==t.mode&&(e.status=!1)}),this.map.on("draw.render",function(t){var n=e.map.getSource("mapbox-gl-draw-hot");if(n){var r=n._data;if(e.snapStatus){var o=[e.snapCoords[0],e.snapCoords[1]];r.features.length>0&&(r.features[0].geometry.coordinates=o)}}}),this.map.on("mouseup",function(){e.drawingSnapCheck()}),this.map.on("click",function(){e.drawingSnapCheck()})},e.prototype.drawingSnapCheck=function(){if(this.snapStatus){var e=this.map.getSource("mapbox-gl-draw-hot"),t=[this.snapCoords[0],this.snapCoords[1]],n=t[0].toFixed(6),r=t[1].toFixed(6),o={};if(o["".concat(n,"_").concat(r)]=t,e){var i=e._data;if(i.features.length>0){var s=i.features.find(function(e){return"feature"==e.properties.meta});if(s){var a=s.properties.id;this.features[a]?this.features[a].snapPoints["".concat(n,"_").concat(r)]=t:this.features[a]={id:a,snapPoints:o}}}else this.features.unknow?this.features.unknow.snapPoints["".concat(n,"_").concat(r)]=t:this.features.unknow={id:a,snapPoints:o}}}},e.prototype.searchInVertex=function(e,t,n){var o=(0,r.q)(e),i=[];if(o.map(function(e){var o=or((0,r.p)(e),(0,r.p)([t.lng,t.lat]),{units:"meters"});o<n&&i.push({coords:e,dist:o,color:"#8bc34a"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.getLines=function(e,t,n){var o=[];switch(e.geometry.type){case"LineString":o.push(e);break;case"MultiLineString":e.geometry.coodinates.map(function(e){o.push((0,r.h)(e))});break;case"Polygon":var i=ar(e.geometry);o.push(i);break;case"MultiPolygon":ar(e.geometry).coodinates.map(function(e){o.push((0,r.h)(e))})}return o},e.prototype.searchInMidPoint=function(e,t,n){var o=this.getLines(e,t,n),i=[];o.map(function(e){i=i.concat(dr(e).features)});var s=[];if(i.map(function(e){var o=function(e,t){var n=function(e,t,n,o){void 0===o&&(o={});var i=$r(e),s=(0,r.e)(i[0]),a=(0,r.e)(i[1]),l=(0,r.e)(n),c=(0,r.l)(t,o.units),d=Math.asin(Math.sin(a)*Math.cos(c)+Math.cos(a)*Math.sin(c)*Math.cos(l)),u=s+Math.atan2(Math.sin(l)*Math.sin(c)*Math.cos(a),Math.cos(c)-Math.sin(a)*Math.sin(d)),p=(0,r.f)(u),h=(0,r.f)(d);return(0,r.p)([p,h],o.properties)}(e,function(e,t,n){void 0===n&&(n={});var o=$r(e),i=$r(t),s=(0,r.e)(i[1]-o[1]),a=(0,r.e)(i[0]-o[0]),l=(0,r.e)(o[1]),c=(0,r.e)(i[1]),d=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(l)*Math.cos(c);return(0,r.r)(2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)),n.units)}(e,t)/2,lr(e,t));return n}(e.geometry.coordinates[0],e.geometry.coordinates[1]),i=or(o,(0,r.p)([t.lng,t.lat]),{units:"meters"});i<n&&s.push({coords:o.geometry.coordinates,dist:i,color:"#03a9f4"})}),s.length>0)return s.sort(function(e,t){return e.dist-t.dist}),s[0]},e.prototype.searchInEdge=function(e,t,n){for(var o=this.getLines(e,t,n),i=[],s=0;s<o.length;s++){var a=Hr(o[s],(0,r.p)([t.lng,t.lat]),{units:"meters"});void 0!==a.properties.dist&&a.properties.dist<n&&i.push({coords:a.geometry.coordinates,dist:a.properties.dist,color:"#ff9800"})}if(i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.getCloseFeatures=function(e,t){var n=this.map.queryRenderedFeatures(e.point,{layers:this.options.layers});if(n.length>0){for(var r,o=!1,i=0;i<n.length;i++){var s=n[i],a=this.options.rules,l=e.lngLat;if(o=!1,-1!==a.indexOf("vertex")&&null==r&&(r=this.searchInVertex(s,l,t))){o=!0;break}if(-1!==a.indexOf("midpoint")&&null==r&&(r=this.searchInMidPoint(s,l,t))){o=!0;break}if(-1!==a.indexOf("edge")&&null==r&&(r=this.searchInEdge(s,l,t))){o=!0;break}}return!!o&&r}return!1},e.prototype.addRadiusCircleLayer=function(){this.map.addSource("snap-helper-circle",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"snap-helper-circle",type:"fill",source:"snap-helper-circle",paint:{"fill-color":["get","color"],"fill-opacity":.6}})},e}();const Kr="snap-helper-circle",Wr="mapbox-gl-draw-hot";function Jr(e,t){!function n(){const r=e();null!==r&&(r?t(r):requestAnimationFrame(n))}()}function qr(e){if(!e||e._data&&Array.isArray(e._data?.features))return;let t={type:"FeatureCollection",features:[]};Object.defineProperty(e,"_data",{get:()=>t,set:e=>{t=e&&"object"==typeof e&&Array.isArray(e.features)?e:{type:"FeatureCollection",features:[]}},configurable:!0})}const Xr=new Set(["draw_polygon","draw_line","draw_point","edit_vertex","edit_point"]);function Zr(e,t,n,r){if(e._snapInstance||e._snapCreating)return e._snapInstance;e._snapCreating=!0,function(e){e.getLayer(Kr)&&e.removeLayer(Kr),e.getSource(Kr)&&e.removeSource(Kr)}(e),qr(n);const o=new zr({map:e,drawing:t,options:{layers:r.layers,radius:r.radius,rules:r.rules},status:r.status,onSnapped:r.onSnapped});return function(e,t,n){let r=t;Object.defineProperty(e,"status",{get:()=>r&&Xr.has(n.getMode()),set(){},configurable:!0}),e.setSnapStatus=e=>{r=e}}(o,r.status,t),function(e,t){e._defaultLayers=t,e._activeLayers=null,e.setSnapLayers=t=>{null==t?e._activeLayers=null:Array.isArray(t)&&(e._activeLayers=t)}}(o,r.layers),void 0!==e._pendingSnapLayers&&(o.setSnapLayers(e._pendingSnapLayers),delete e._pendingSnapLayers),e._snapInstance=o,o}const Qr="point-symbol",eo=new Set([`${Qr}.hot`,`${Qr}.cold`]),to=(e,t)=>{const n=(e=>{const t=["match",["get","user_symbolImageId"]];for(const[n,r]of Object.entries(e))t.push(n,["literal",r]);return t.push(["literal",[0,0]]),t})(e._symbolIconOffsetMap);t.options?.styles?.forEach(e=>{eo.has(e.id)&&(e.layout={...e.layout,"icon-offset":n})}),eo.forEach(t=>{e.getLayer(t)&&e.setLayoutProperty(t,"icon-offset",n)})},no=async({draw:e,mapProvider:t,map:n,symbolRegistry:o,featureId:i,properties:s,pixelRatioOverride:a})=>{if(!(0,r.s)(s))return null;const l=n._drawCurrentMapStyle,c=a??(e=>e.getPixelRatio?.()||1)(n);await t.addSymbolsToMap([s],l,o,c);const d=e.get(i);if(!d)return null;const u=o.getSymbolImageId(s,l,"normal",c);if(!u)return null;const p=t.getActiveSymbolImageId(u),h=t.getSelectedSymbolImageId(u),f=t.getSymbolIconLayout(o.getSymbolDef(s));return((e,t,n,r)=>{e._symbolIconOffsetMap??={},e._symbolIconOffsetMap[n]||(e._symbolIconOffsetMap[n]=r,to(e,t))})(n,e,u,f["icon-offset"]),{...d,properties:{...s,symbolImageId:u,symbolIconAnchor:f["icon-anchor"],symbolActiveImageId:p,symbolSelectedImageId:h}}},ro=async({draw:e,mapProvider:t,map:n,symbolRegistry:o,pixelRatioOverride:i})=>{n._pointSymbolRefreshId=(n._pointSymbolRefreshId??0)+1;const s=n._pointSymbolRefreshId,a=e.getAll().features.filter(e=>"Point"===e.geometry.type&&(0,r.s)(e.properties)),l=await Promise.allSettled(a.map(r=>no({draw:e,mapProvider:t,map:n,symbolRegistry:o,featureId:r.id,properties:r.properties,pixelRatioOverride:i})));if(l.filter(e=>"rejected"===e.status).forEach(e=>{r.t.error("[draw] failed to resolve point symbol",e.reason)}),n._pointSymbolRefreshId!==s)return;const c=l.filter(e=>"fulfilled"===e.status&&e.value).map(e=>e.value);c.length&&e.add({type:"FeatureCollection",features:c}),((e,t)=>{const n=e._symbolIconOffsetMap;if(!n)return;const r=new Set(t.getAll().features.map(e=>e.properties?.symbolImageId)),o=Object.keys(n).filter(e=>!r.has(e));o.length&&(o.forEach(e=>delete n[e]),to(e,t))})(n,e)},oo="mapbox-gl-draw-cold",io=({mapStyle:e,mapProvider:t,symbolRegistry:n,events:i,eventBus:s,snapLayers:a,pluginConfig:l={}})=>{const{map:c}=t;dt.constants.classes.CONTROL_BASE="maplibregl-ctrl",dt.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",dt.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";const d={...dt.modes,disabled:ut,edit_vertex:fn,edit_point:Sn,draw_polygon:Rn,draw_line:Nn,draw_point:jn};let u=t._mapboxDrawInstance;u?Object.assign(u.modes,d):(u=new dt({modes:d,styles:tr(e,l),displayControlsDefault:!1,userProperties:!0,defaultMode:"disabled"}),c.addControl(u),t._mapboxDrawInstance=u);const p=((e,t)=>{const n=e.getCanvas();let r=null;const o=e=>{1===e.touches.length&&(r={x:e.touches[0].clientX,y:e.touches[0].clientY,time:Date.now()})},i=e=>{if("disabled"!==t.getMode()||!r)return void(r=null);const o=e.changedTouches[0],i=o.clientX-r.x,s=o.clientY-r.y;Date.now()-r.time<300&&Math.abs(i)<10&&Math.abs(s)<10&&n.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,clientX:o.clientX,clientY:o.clientY})),r=null};return n.addEventListener("touchstart",o,{passive:!0}),n.addEventListener("touchend",i,{passive:!0}),{remove(){n.removeEventListener("touchstart",o),n.removeEventListener("touchend",i)}}})(c,u);t.draw=u,c._drawCurrentMapStyle=e,c._drawPluginConfig=l,t.snapEnabled=!1;let h=t.undoStack;h||(h=(0,o.d)(e=>c.fire("draw.undochange",{length:e})),t.undoStack=h),c._undoStack=h;const f=(0,o.r)(e,l);!function(e,t,n={}){if(e._snapInitialized)return e._snapInstance;e._snapInitialized=!0;const{layers:o=[],radius:i=r.T.snapRadius,rules:s=["vertex","midpoint","edge"],status:a=!1,onSnapped:l=()=>{},colors:c={}}=n,d={layers:o,radius:i,rules:s,status:a,onSnapped:l};(function(e){if(zr.prototype.__snapPatched)return;zr.prototype.__snapPatched=!0;const t=zr.prototype,n={setMapData:t.setMapData,drawingSnapCheck:t.drawingSnapCheck,getLines:t.getLines,getCloseFeatures:t.getCloseFeatures,searchInVertex:t.searchInVertex,searchInMidPoint:t.searchInMidPoint,searchInEdge:t.searchInEdge,snapToClosestPoint:t.snapToClosestPoint};t.changeSnappedPoints=()=>{},function(e,t){e.setMapData=function(e){if(!this.status)return;const n=t.setMapData.call(this,e);return e?.features?.length>0&&this.map?.getLayer(Kr)&&this.map.setLayoutProperty(Kr,"visibility","visible"),n},e.drawingSnapCheck=function(){if(this.status)return t.drawingSnapCheck.call(this)}}(t,n),function(e,t){e.getLines=function(e,n,o){const i=e.geometry;if(!i?.coordinates)return[];const s=i.coordinates;if(!Array.isArray(s)||0===s.length)return[];try{return"MultiPolygon"===i.type?s.filter(e=>Array.isArray(e)&&e.length>0).map(e=>(0,r.g)(e)):"MultiLineString"===i.type?s.filter(e=>Array.isArray(e)&&e.length>0).map(e=>(0,r.h)(e)):t.getLines.call(this,e,n,o)}catch{return[]}},e.getCloseFeatures=function(e,n){if(!this.status)return[];const o=this._activeLayers||this._defaultLayers||[];this.options.layers=o.filter(e=>this.map.getLayer(e));const i=this.options.radius||r.T.snapRadius,s=e.point;e.point=[[s.x-i,s.y-i],[s.x+i,s.y+i]];const a=t.getCloseFeatures.call(this,e,n);return e.point=s,a}}(t,n),function(e,t,n){e.searchInVertex=function(...e){const r=t.searchInVertex.apply(this,e);return r&&(r.color=n.vertex),r},e.searchInMidPoint=function(...e){const r=t.searchInMidPoint.apply(this,e);return r&&(r.color=n.midpoint),r},e.searchInEdge=function(...e){const r=t.searchInEdge.apply(this,e);return r&&(r.color=n.edge),r}}(t,n,e),function(e,t){e.snapToClosestPoint=function(e){if(this.status&&!this.map?._isZooming&&(!this._autoSnapSuspended||e._explicit))try{const n=t.snapToClosestPoint.call(this,e);return this.closeFeatures?.length>100&&(this.closeFeatures.length=0),this.lines?.length>100&&(this.lines.length=0),n}catch{return this.snapStatus=!1,void(this.snapCoords=null)}}}(t,n)})({vertex:r.C.snapVertex,midpoint:r.C.snapMidpoint,edge:r.C.snapEdge,...c}),function(e,t,n){e.on("style.load",()=>{Jr(()=>e._removed?null:e.getSource(Wr),r=>{qr(r),function(e){e.getSource(Kr)||e.addSource(Kr,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(Kr)||e.addLayer({id:Kr,type:"fill",source:Kr,paint:{"fill-color":["get","color"]},layout:{visibility:e._snapInstance?.status?"visible":"none"}})}(e),e._snapInstance||Zr(e,t,r,n)})})}(e,t,d),function(e){e.on("zoomstart",()=>{e._isZooming=!0}),e.on("zoomend",()=>{if(e._isZooming=!1,e.getLayer(Kr)){e.setLayoutProperty(Kr,"visibility","none");const t=e._snapInstance;t?.status&&e.setLayoutProperty(Kr,"visibility","visible")}})}(e),Jr(()=>e._removed?null:e.getSource(Wr),n=>Zr(e,t,n,d)),e._snapInstance}(c,u,{layers:a,radius:l.snapRadius??r.T.snapRadius,rules:["vertex","edge"],colors:{vertex:f.snapVertex,edge:f.snapEdge}});const g=()=>s.emit(i.MAP_DATA_CHANGE),{handleSetMapStyle:m,handleStyleChanged:y}=(({map:e,draw:t,mapProvider:n,symbolRegistry:o,pluginConfig:i,eventBus:s,events:a,notifyPointSymbolsRefreshed:l})=>{const c=t=>{e._drawCurrentMapStyle=t};s.on(a.MAP_SET_STYLE,c);let d=!1;const u=()=>{d||(d=!0,(({map:e,draw:t,mapProvider:n,symbolRegistry:o,pluginConfig:i,onDone:s})=>{const a=e._drawCurrentMapStyle;e.once("idle",()=>{const l=((e,t)=>{if(e.getSource(oo))return!1;const n={type:"FeatureCollection",features:[]};return e.addSource(oo,{data:n,type:"geojson"}),e.addSource("mapbox-gl-draw-hot",{data:n,type:"geojson"}),t.options.styles.forEach(t=>e.addLayer(t)),!0})(e,t);((e,t,n={})=>{tr(t,n).forEach(t=>{Object.entries(t.paint).forEach(([n,r])=>{e.getLayer(`${t.id}.cold`)&&e.setPaintProperty(`${t.id}.cold`,n,r),e.getLayer(`${t.id}.hot`)&&e.setPaintProperty(`${t.id}.hot`,n,r)})})})(e,a,i);const c=e._drawEditContainer?.querySelector("[data-im-draw-touch-target]");en(c,a,i),ro({draw:t,mapProvider:n,map:e,symbolRegistry:o}).then(()=>{l&&t.set(t.getAll()),e.triggerRepaint(),s()}).catch(e=>r.t.error("[draw] failed to refresh point symbols after a style change",e))})})({map:e,draw:t,mapProvider:n,symbolRegistry:o,pluginConfig:i,onDone:()=>{d=!1,l()}}))};return s.on(a.MAP_STYLE_CHANGE,u),{handleSetMapStyle:c,handleStyleChanged:u}})({map:c,draw:u,mapProvider:t,symbolRegistry:n,pluginConfig:l,eventBus:s,events:i,notifyPointSymbolsRefreshed:g}),v=e=>{c.fire("draw.scalechange",{scale:r.u[e]})};s.on(i.MAP_SET_SIZE,v);const b=e=>{ro({draw:u,mapProvider:t,map:c,symbolRegistry:n,pixelRatioOverride:e}).then(()=>{c.triggerRepaint(),g()}).catch(e=>r.t.error("[draw] failed to refresh point symbols",e))};return s.on(i.MAP_SET_PIXEL_RATIO,b),{draw:u,remove(){p.remove(),s.off(i.MAP_SET_STYLE,m),s.off(i.MAP_STYLE_CHANGE,y),s.off(i.MAP_SET_SIZE,v),s.off(i.MAP_SET_PIXEL_RATIO,b),u.changeMode("disabled"),t.draw=null}}},so=e=>({type:"Feature",geometry:{type:"Polygon",coordinates:e}}),ao=e=>({type:"Feature",geometry:{type:"LineString",coordinates:e}}),lo=e=>({type:"Feature",geometry:{type:"Point",coordinates:e}});class co{constructor(e,t){this._mapProvider=e,this._map=e.map,this._symbolRegistry=t.symbolRegistry,this._bus=(()=>{const e=new Map;return{on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)},emit(t,...n){const r=e.get(t);r&&Array.from(r).forEach(e=>e(...n))}}})(),this._editingFeatureId=null,this._sortKeyCounter=0;const{draw:n,remove:i}=io({mapStyle:t.mapStyle,mapProvider:e,symbolRegistry:t.symbolRegistry,events:t.events,eventBus:t.eventBus,snapLayers:t.snapLayers,pluginConfig:t.pluginConfig??{}});this._draw=n,this._cleanupDraw=i,this._liveStroke=(0,o.e)({onChange:(e,t)=>{this._applyStrokeInvalid(e);const n=this._draw.getMode();"edit_vertex"!==n&&"edit_point"!==n||this._bus.emit(r.A.VALIDITY_CHANGE,{valid:!e,reason:t})}}),this._liveDrawChecks=(0,o.f)({onStrokeChange:(e,t)=>this._liveStroke.set(e,t),onPlaceChange:(e,t)=>this._bus.emit(r.A.CAN_PLACE_CHANGE,{canPlace:!e,reason:t})}),this._mapHandlers={create:e=>{const t=e.features[0];setTimeout(()=>{this._draw.setFeatureProperty(t.id,"sortKey",this._nextSortKey()),this._bus.emit(r.A.CREATE,this._draw.get(t.id))},0)},editfinish:e=>this._bus.emit(r.A.EDIT_FINISH,e.features[0]),cancel:()=>this._bus.emit(r.A.CANCEL),vertexselection:e=>this._bus.emit(r.A.VERTEX_SELECTION,e),vertexchange:e=>this._bus.emit(r.A.VERTEX_CHANGE,e),undochange:e=>this._bus.emit(r.A.UNDO_CHANGE,e.length),update:e=>this._bus.emit(r.A.UPDATE,e.features[0]),geometrychange:e=>{e?.phase||(this._updateLiveStroke(e),this._currentDrawEvent=e),this._bus.emit(r.A.GEOMETRY_CHANGE,e)},placementblocked:e=>this._bus.emit(r.A.PLACEMENT_BLOCKED,e),interfacetypechange:e=>this._bus.emit(r.A.INTERFACE_TYPE_CHANGE,{interfaceType:e.interfaceType}),modechange:e=>this._handleModeChange(e),styledata:()=>this._handleStyleData()},this._map.on(pt,this._mapHandlers.create),this._map.on(gt,this._mapHandlers.editfinish),this._map.on(mt,this._mapHandlers.cancel),this._map.on(yt,this._mapHandlers.vertexselection),this._map.on(vt,this._mapHandlers.vertexchange),this._map.on(bt,this._mapHandlers.undochange),this._map.on(ht,this._mapHandlers.update),this._map.on(_t,this._mapHandlers.geometrychange),this._map.on(St,this._mapHandlers.placementblocked),this._map.on(Et,this._mapHandlers.interfacetypechange),this._map.on(ft,this._mapHandlers.modechange),this._map.on(Pt,this._mapHandlers.styledata)}changeMode(e,t={}){"edit_vertex"!==e&&"edit_point"!==e||(this._editingFeatureId=t.featureId??null),"draw_polygon"!==e&&"draw_line"!==e||(this._liveStroke.set(!1),this._liveDrawChecks.reset()),"draw_point"===e&&(t={...t,resolvePointSymbol:(e,t)=>this._resolvePointSymbol(e,t)}),this._draw.changeMode(e,t),this._handleModeChange({mode:e})}_resolvePointSymbol(e,t){(async e=>{const t=await no(e);t&&e.draw.add(t)})({draw:this._draw,mapProvider:this._mapProvider,map:this._map,symbolRegistry:this._symbolRegistry,featureId:e,properties:t}).catch(t=>r.t.error("[draw] failed to resolve point symbol",e,t))}_updateLiveStroke(e){if(!e?.coordinates)return;const t=this._draw.getMode(),n=((e,t)=>{if("draw_polygon"===e)return{feature:so(t),numVertices:(t[0]?.length??1)-1};if("draw_line"===e)return{feature:ao(t),numVertices:(t?.length??1)-1};if("edit_vertex"===e){const e=t[0];return Array.isArray(e?.[0])?{feature:so(t),numVertices:e.length}:{feature:ao(t),numVertices:t?.length??0}}return"edit_point"===e?{feature:lo(t),numVertices:1}:null})(t,e.coordinates);n&&("draw_polygon"===t||"draw_line"===t?this._liveDrawChecks.update({feature:n.feature,numVertices:n.numVertices,context:{mode:t},onGeometryChange:this._geometryValidator}):this._liveStroke.update({...n,context:{mode:t},onGeometryChange:this._geometryValidator}))}getMode(){return this._draw.getMode()}setInterfaceType(e){this._map.fire(Et,{interfaceType:e})}done(){this._mapProvider.undoStack?.clear();const e=this._draw.getMode();if(("edit_vertex"===e||"edit_point"===e)&&this._editingFeatureId)return this._handleModeChange({mode:"disabled"}),void this._map.fire(gt,{features:[this._draw.get(this._editingFeatureId)]});"draw_polygon"!==e&&"draw_line"!==e||(this._draw.changeMode("disabled"),this._handleModeChange({mode:"disabled"}))}cancel(){this._mapProvider.undoStack?.clear();const e=this._draw.getMode();"draw_polygon"!==e&&"draw_line"!==e||this._draw.trash(),this._draw.changeMode("disabled"),this._handleModeChange({mode:"disabled"})}undo(){this._map.fire("draw.undo")}nudgeSelectedVertex(e,t,n){this._map.fire(xt,{dx:e,dy:t,isLargeStep:n})}getVertexItems(){const e={vertices:[],midpoints:[]};if("edit_vertex"!==this._draw.getMode()||!this._editingFeatureId)return e;const t=this._draw.get(this._editingFeatureId);if(!t)return e;const n=(e=>"Polygon"===e.type?{...e,coordinates:e.coordinates.map(e=>e.slice(0,-1))}:"MultiPolygon"===e.type?{...e,coordinates:e.coordinates.map(e=>e.map(e=>e.slice(0,-1)))}:e)(t.geometry);return{vertices:Ct(n),midpoints:Tt(n)}}selectVertex(e){this._map.fire(It,{index:e})}insertVertexAtMidpoint(e){this._map.fire(wt,{index:e})}setGeometryValid(e){this._map._drawGeometryValid=e}set _geometryValidator(e){this._map._drawGeometryValidator=e}get _geometryValidator(){return this._map._drawGeometryValidator}setInvalid(e){this._liveStroke.set(e)}_applyStrokeInvalid(e){this._setLayerVisibility("stroke-active",!e),this._setLayerVisibility("stroke-active-invalid",e),this._setLayerVisibility("fill-active",!e)}_setLayerVisibility(e,t){["hot","cold"].forEach(n=>{const r=`${e}.${n}`;this._map.getLayer(r)&&this._map.setLayoutProperty(r,"visibility",t?"visible":"none")})}deleteVertex(){}get(e){return this._draw.get(e)}_nextSortKey(){return this._sortKeyCounter+=1,this._sortKeyCounter}add(e){const t=null==e.properties?.sortKey?{...e.properties,sortKey:this._nextSortKey()}:e.properties,n={...e,properties:t},o=this._draw.add(n);return"Point"===n.geometry?.type&&(0,r.s)(t)&&this._resolvePointSymbol(o[0],t),o}setStyle(e,t){const n=this._draw.get(e);n&&this.add({...n,properties:{...n.properties,...t}})}delete(e){this._draw.delete(e)}deleteAll(){this._draw.deleteAll()}setSnapEnabled(e){this._mapProvider.snapEnabled=e;const t=Rt(this._map);t?.setSnapStatus&&t.setSnapStatus(e),!e&&t&&(jt(t),this._map.getLayer("snap-helper-circle")&&this._map.setLayoutProperty("snap-helper-circle","visibility","none"))}setSnapLayers(e){const t=Rt(this._map);t?.setSnapLayers?t.setSnapLayers(e):e&&(this._map._pendingSnapLayers=e)}isSnapEnabled(){return!0===this._mapProvider.snapEnabled}setFeatureProperty(e,t,n){this._draw.setFeatureProperty(e,t,n)}setDrawingPreviewProperty(e,t){const n=this._currentDrawEvent;n?.properties&&(n.properties[e]=t),n?.ctx?.store?.render()}on(e,t){this._bus.on(e,t)}off(e,t){this._bus.off(e,t)}_handleModeChange(e){new Set(["draw_polygon","draw_line","draw_point","edit_vertex","edit_point"]).has(e.mode)||Gt(Rt(this._map),this._map)}_handleStyleData(){const e=this._map.getStyle();if(!e)return;this._liveStroke.refresh();const t=e.layers||[];t.length&&!t[t.length-1].source?.startsWith("mapbox-gl-draw")&&t.filter(e=>e.source?.startsWith("mapbox-gl-draw")).forEach(e=>this._map.moveLayer(e.id))}remove(){this._map.off(pt,this._mapHandlers.create),this._map.off(gt,this._mapHandlers.editfinish),this._map.off(mt,this._mapHandlers.cancel),this._map.off(yt,this._mapHandlers.vertexselection),this._map.off(vt,this._mapHandlers.vertexchange),this._map.off(bt,this._mapHandlers.undochange),this._map.off(ht,this._mapHandlers.update),this._map.off(_t,this._mapHandlers.geometrychange),this._map.off(St,this._mapHandlers.placementblocked),this._map.off(Et,this._mapHandlers.interfacetypechange),this._map.off(ft,this._mapHandlers.modechange),this._map.off(Pt,this._mapHandlers.styledata),this._liveStroke.destroy(),this._liveDrawChecks.destroy(),this._cleanupDraw()}}},308:(e,t,n)=>{n.d(t,{OLDrawAdapter:()=>Ie}),Object(function(){var e=new Error("Cannot find module 'ol/layer/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/source/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/format/GeoJSON.js'");throw e.code="MODULE_NOT_FOUND",e}());var r=n(106);Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/style/Fill.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/style/Circle.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/style/Icon.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/geom/MultiPoint.js'");throw e.code="MODULE_NOT_FOUND",e}());var o=n(666);Object(function(){var e=new Error("Cannot find module 'ol/proj.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/Feature.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/geom/Point.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/style.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/interaction/Interaction.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/interaction/Draw.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/events/condition.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/interaction/Modify.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/Collection.js'");throw e.code="MODULE_NOT_FOUND",e}()),Object(function(){var e=new Error("Cannot find module 'ol/interaction/Pointer.js'");throw e.code="MODULE_NOT_FOUND",e}()),n(452),n(247);const i="EPSG:27700",s=new Object(function(){var e=new Error("Cannot find module 'ol/format/GeoJSON.js'");throw e.code="MODULE_NOT_FOUND",e}())({dataProjection:i,featureProjection:i}),a=()=>{const e=new Object(function(){var e=new Error("Cannot find module 'ol/source/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}());return{source:e,getOL:t=>e.getFeatureById(String(t))??null,add(t){const n=this.getOL(t.id);n&&e.removeFeature(n);const r=s.readFeature(t);return e.addFeature(r),r},get(e){const t=this.getOL(e);return t?s.writeFeatureObject(t):null},remove(t){const n=Array.isArray(t)?t:[t];for(const r of n){const t=this.getOL(r);t&&e.removeFeature(t)}},clear(){e.clear()},toGeoJSON:e=>s.writeFeatureObject(e),fromGeoJSON:e=>s.readFeature(e)}},l={Polygon:2,LineString:1},c=e=>{const t=e.getType();return("Polygon"===t?e.getCoordinates()[0]??[]:e.getCoordinates()).slice(0,-l[t])},d=e=>c(e).at(-1)??null,u={outer:o.S.vertexHaloRadius+3,mid:o.S.vertexHaloRadius,inner:o.S.vertexRadius},p={outer:o.S.midpointHaloRadius+3,mid:o.S.midpointHaloRadius,inner:o.S.midpointRadius},h=Math.PI+Math.PI,f=[2,4],g=(e,t,n,r,o)=>{e.beginPath(),e.arc(t,n,r,0,h),e.fillStyle=o,e.fill()},m=({outer:e,mid:t,inner:n},r,o)=>(i,s)=>{const a=s.context,l=s.pixelRatio,[c,d]=i;a.save(),g(a,c,d,e*l,r.editActive),g(a,c,d,t*l,r.editHalo),g(a,c,d,n*l,r[o]),a.restore()},y=e=>e.charAt(0).toUpperCase()+e.slice(1),v=(e,t)=>{const{vertexImage:n,vertexStyle:r,selectedVertexStyle:i}=(e=>{const t=new Object(function(){var e=new Error("Cannot find module 'ol/style/Circle.js'");throw e.code="MODULE_NOT_FOUND",e}())({radius:o.S.vertexRadius,fill:new Object(function(){var e=new Error("Cannot find module 'ol/style/Fill.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.editVertex})});return{vertexImage:t,vertexStyle:new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({image:t}),selectedVertexStyle:new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({renderer:m(u,e,"editVertex")})}})(e),{midpointStyle:s,selectedMidpointStyle:a}=(e=>({midpointStyle:new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({image:new Object(function(){var e=new Error("Cannot find module 'ol/style/Circle.js'");throw e.code="MODULE_NOT_FOUND",e}())({radius:o.S.midpointRadius,fill:new Object(function(){var e=new Error("Cannot find module 'ol/style/Fill.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.editMidpoint})})}),selectedMidpointStyle:new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({renderer:m(p,e,"editMidpoint")})}))(e),l=new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({stroke:new Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.editStroke,width:2}),fill:new Object(function(){var e=new Error("Cannot find module 'ol/style/Fill.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.editFill})}),d=new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({stroke:new Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.invalidStroke,width:2,lineDash:f})}),h=(e=>({valid:new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({stroke:new Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.editStroke,width:2}),fill:new Object(function(){var e=new Error("Cannot find module 'ol/style/Fill.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.editFill})}),invalid:new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({stroke:new Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.invalidStroke,width:2,lineDash:f})}),splitValid:new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({stroke:new Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.splitValid,width:2})}),splitInvalid:new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({stroke:new Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.splitInvalid,width:2,lineDash:f})})}))(e),g=new Object(function(){var e=new Error("Cannot find module 'ol/geom/MultiPoint.js'");throw e.code="MODULE_NOT_FOUND",e}())([]),v=new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({image:n,geometry:e=>{const t=c(e.getGeometry());return t.length?(g.setCoordinates(t),g):null}}),{pointStyleFor:b,selectedPointStyleFor:_}=((e,t)=>{const n=(e=>new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({image:new Object(function(){var e=new Error("Cannot find module 'ol/style/Circle.js'");throw e.code="MODULE_NOT_FOUND",e}())({radius:o.S.vertexRadius+3,fill:new Object(function(){var e=new Error("Cannot find module 'ol/style/Fill.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.shapeFill}),stroke:new Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:e.shapeStroke,width:2})})}))(e),r=new WeakMap,i=(e,n="symbolImageId")=>{const o=e[n],i=o&&t?.(o);if(!i||!e.symbolImageAnchor)return null;const[s,a]=e.symbolImageAnchor,l=e.symbolPixelRatio||1;r.has(i)||r.set(i,new Map);const c=r.get(i),d=`${s}|${a}|${l}`;let u=c.get(d);return u||(u=new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({image:new Object(function(){var e=new Error("Cannot find module 'ol/style/Icon.js'");throw e.code="MODULE_NOT_FOUND",e}())({img:i,anchor:[s,a],scale:1/l})}),c.set(d,u)),u};return{pointStyleFor:e=>i(e.getProperties())??n,selectedPointStyleFor:e=>{const t=e.getProperties();return i(t,"symbolSelectedImageId")??i(t)??n}}})(e,t);return{vertexStyle:r,selectedVertexStyle:i,midpointStyle:s,selectedMidpointStyle:a,editFeatureStyle:l,editFeatureStyleInvalid:d,selectedPointStyleFor:_,createSketchStyle:(e,t=!1)=>n=>{const r=n.getGeometry().getType();if("Point"===r)return[];const o=n.get("splitter");let i=t?h.invalid:h.valid;return"valid"===o&&(i=h.splitValid),"invalid"===o&&(i=h.splitInvalid),r===e?[i,v]:[i]},createFeatureStyle:()=>t=>{if("Point"===t.getGeometry().getType())return[b(t)];const n=t.getProperties(),r=e.mapStyleId,o=r&&n[`stroke${y(r)}`]||n.stroke||e.shapeStroke,i=r&&n[`fill${y(r)}`]||n.fill||e.shapeFill,s=n.strokeWidth||e.strokeWidth;return[new Object(function(){var e=new Error("Cannot find module 'ol/style/Style.js'");throw e.code="MODULE_NOT_FOUND",e}())({stroke:new Object(function(){var e=new Error("Cannot find module 'ol/style/Stroke.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:o,width:s}),fill:new Object(function(){var e=new Error("Cannot find module 'ol/style/Fill.js'");throw e.code="MODULE_NOT_FOUND",e}())({color:i})})]}}},b=(e,t)=>{const n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r},_=(e,t,n)=>{const r=n[0]-t[0],o=n[1]-t[1],i=r*r+o*o;if(0===i)return[t[0],t[1]];const s=Math.max(0,Math.min(1,((e[0]-t[0])*r+(e[1]-t[1])*o)/i));return[t[0]+s*r,t[1]+s*o]},E=(e,t)=>S(e,t)?t:e,S=(e,t)=>e?!!t&&("edge"===e.type&&"vertex"===t.type||("vertex"!==e.type||"edge"!==t.type)&&t.distSq<e.distSq):!!t,x=(e,t,n,r)=>{let o=null;const i=r&&e.length>1?e.length-1:e.length,s=r?i:i-1;for(let a=0;a<i;a++){const r=e[a],i=b(t,r);i<=n&&(o=E(o,{type:"vertex",coord:[r[0],r[1]],distSq:i}))}for(let a=0;a<s;a++){const r=e[a],s=e[(a+1)%i],l=_(t,r,s),c=b(t,l);c<=n&&(o=E(o,{type:"edge",coord:l,distSq:c}))}return o},I=(e,t,n,r,o,i)=>{let s=null;for(let a=0;a<r;a++){const r=t+2*a,l=t+(a+1)%n*2,c=[e[r],e[r+1]],d=[e[l],e[l+1]],u=_(o,c,d),p=b(o,u);p<=i&&(s=E(s,{type:"edge",coord:u,distSq:p,seg:[c,d]}))}return s},w=(e,t,n)=>[e>0||n?e>0?e-1:t-1:null,e<t-1||n?e<t-1?e+1:0:null],P=(e,t,n,r,o,i)=>{const s=r===n,a=n=>null===n?null:[e[t+2*n],e[t+2*n+1]];let l=null;for(let c=0;c<n;c++){const e=a(c),t=b(o,e);if(t<=i){const[r,o]=w(c,n,s),i=[a(r),a(o)];l=E(l,{type:"vertex",coord:e,distSq:t,adjacent:i})}}return l},C=(e,t,n,r,o,i)=>{const s=(n-t)/2,a=i?s:s-1;return{vertex:P(e,t,s,a,r,o),edge:I(e,t,s,a,r,o)}},T={point:(e,t,n)=>{const r=e.getCoordinates(),o=b(t,r);return o<=n?{type:"vertex",coord:[r[0],r[1]],distSq:o}:null},lineString:(e,t,n)=>x(e.getCoordinates(),t,n,!1),linearRing:(e,t,n)=>x(e.getCoordinates(),t,n,!0),polygon:(e,t,n)=>{let r=null;for(const o of e.getCoordinates())r=E(r,x(o,t,n,!0));return r},multiLineString:(e,t,n)=>{let r=null;for(const o of e.getCoordinates())r=E(r,x(o,t,n,!1));return r},multiPolygon:(e,t,n)=>{let r=null;for(const o of e.getCoordinates())for(const e of o)r=E(r,x(e,t,n,!0));return r}},M=(e,t,n)=>{const r=e.getGeometry();if(!r)return null;const o=r.getType(),i=T[o[0].toLowerCase()+o.slice(1)];return i?i(r,t,n):null},L=(e,t,n)=>{if(!t||!n)return!1;const[r,o,i,s]=e.extent,a=(t,n,r)=>Math.min(Math.abs(t-n),Math.abs(t-r))<=e.band,l=Math.abs(t[0]-n[0])<=e.eps&&a(t[0],r,i),c=Math.abs(t[1]-n[1])<=e.eps&&a(t[1],o,s);return l||c},A=()=>!0===globalThis.DEBUG_SNAP_VISIBILITY,O=(e,t)=>{A()&&console.log("[snap-candidate-found]",{type:e.type,layerId:t?.id,layerType:t?.type,coord:[e.coord[0].toFixed(2),e.coord[1].toFixed(2)],distSq:e.distSq.toFixed(2)})},k=({candidate:e,cursorCoord:t,mapboxLayer:n,boundaryState:r,map:o,vtLayers:i,resolution:s})=>((e,t)=>{const n=((e,t)=>{if(!e)return null;const{tileGrid:n,viewProj:r,sourceProj:o,zoom:i}=e,s=e=>"string"==typeof e?e:e.getCode(),a=e=>e?s(o)===s(r)?e:Object(function(){var e=new Error("Cannot find module 'ol/proj.js'");throw e.code="MODULE_NOT_FOUND",e}())(e,r,o):null,l=a(t),c=n.getTileCoordForCoordAndZ(l,i),d=n.getTileCoordExtent(c),u=d[2]-d[0];return{toSource:a,anchor:l,extent:d,band:.0625*u,eps:u/4096*2}})(e,t.coord);if(!n)return!1;if("edge"===t.type){const[e,r]=t.seg;return L(n,n.toSource(e),n.toSource(r))}const[r,o]=t.adjacent??[];return L(n,n.anchor,n.toSource(r))||L(n,n.anchor,n.toSource(o))})(r,e)?(A()&&console.log("[snap-filtered] tile clip artefact",e.type),!0):!("edge"!==e.type||"fill"!==n?.type||!((e,t,n,r,o,i)=>{const s=e[0]-t[0],a=e[1]-t[1],l=s*s+a*a;if(l<1)return!1;const c=Math.sqrt(l),d=4*i,u=[e[0]+s/c*d,e[1]+a/c*d],p=r.getPixelFromCoordinate(u);return!!p&&!!r.forEachFeatureAtPixel(p,e=>e.get("mapbox-layer")?.id===n,{hitTolerance:2,layerFilter:e=>o.includes(e)})})(e.coord,t,n.id,o,i,s)||(A()&&console.log("[snap-filtered] invisible fill boundary"),0)),D=e=>(t,n)=>{const r=n.context,[o,i]=t;r.beginPath(),r.arc(o,i,10*n.pixelRatio,0,2*Math.PI),r.fillStyle=e,r.fill()},R=e=>({vertex:new Object(function(){var e=new Error("Cannot find module 'ol/style.js'");throw e.code="MODULE_NOT_FOUND",e}())({renderer:D(e.snapVertex)}),edge:new Object(function(){var e=new Error("Cannot find module 'ol/style.js'");throw e.code="MODULE_NOT_FOUND",e}())({renderer:D(e.snapEdge)})}),N=new Set(["pointermove","pointerdrag","pointerdown","pointerup","singleclick","click"]),F=new Set(["pointermove","pointerdrag"]),V=(e,t)=>{const n=e.getPixelFromCoordinate(t);return n?{x:n[0],y:n[1]}:null},B=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),U=(e,t,n,r)=>{const o=e.getPixelFromCoordinate(t);return o?e.getCoordinateFromPixel([o[0]+n,o[1]+r]):t},G=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),j=(e,t)=>{e&&(["touch","keyboard"].includes(t)?e.fixAtCenter():e.hide())},H=({container:e,addVertexButtonId:t,olView:n,onUndo:o,getInterfaceType:i,setInterfaceType:s,clearLastCoord:a,updateRubberbanding:l,placeVertex:c})=>{const d=()=>{("mouse"!==i()||n?.getAnimating())&&l()};n?.on("change:center",d);const u=t=>{e.contains(document.activeElement)&&(G.has(t.key)?s("keyboard"):("Enter"===t.key&&(t.preventDefault(),s("keyboard"),c()),"z"===t.key&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),o?.())))},p=e=>{t&&e.target.closest(`#${t}`)&&c()},h=e=>{"touch"!==e.pointerType&&(s("mouse"),a())},f=()=>{s("touch")},g=()=>{"mouse"!==i()&&l()};return globalThis.addEventListener("keydown",u),globalThis.addEventListener("click",p),e.addEventListener("pointerdown",h),e.addEventListener("touchstart",f,{passive:!0}),e.addEventListener("pointermove",g),globalThis.addEventListener("keyup",r.b,{capture:!0}),{destroy(){n?.un("change:center",d),globalThis.removeEventListener("keydown",u),globalThis.removeEventListener("click",p),e.removeEventListener("pointerdown",h),e.removeEventListener("touchstart",f),e.removeEventListener("pointermove",g),globalThis.removeEventListener("keyup",r.b,{capture:!0})}}},$="styleschanged",Y=(e,t)=>!!t&&c(t.getGeometry()).length>=o.M[e],z=(e,t,n,r)=>o=>{if(!Object(function(){var e=new Error("Cannot find module 'ol/events/condition.js'");throw e.code="MODULE_NOT_FOUND",e}())(o))return!1;const i=n();if(!r(o.coordinate))return!1;if(!i||Y(t,i))return!0;const s=d(i.getGeometry());if(!s)return!0;const a=e.getPixelFromCoordinate(s);if(!a)return!0;const l=o.pixel[0]-a[0],c=o.pixel[1]-a[1];return l*l+c*c>4},K={Polygon:2,LineString:1},W=(e,t)=>{const n=e.toGeoJSON(t),r=n.geometry.type,o=K[r],i=("Polygon"===r?n.geometry.coordinates[0]:n.geometry.coordinates).slice(0,-o);return{type:"Feature",geometry:"Polygon"===r?{type:"Polygon",coordinates:[i]}:{type:"LineString",coordinates:i},properties:n.properties}},J=({map:e,manager:t,options:n})=>{const{geometryType:i,featureId:s,properties:a={}}=n;let l=null,u=!1,p=t.styles.createSketchStyle(i);const{updateVertexCount:h,resetCount:f,emitUndoValidation:g}=((e,t)=>{let n=0;const r=(n,r)=>{setTimeout(()=>{const i=t();i&&e.emit(o.A.GEOMETRY_CHANGE,{feature:W(e.store,i),phase:n,vertexIndex:r})},0)};return{resetCount:()=>{n=0},updateVertexCount:()=>{const i=t();if(!i)return;const s=c(i.getGeometry()).length;e.emit(o.A.VERTEX_CHANGE,{numVertices:s}),s>n&&r("commit-add",s-1),n=s},emitUndoValidation:()=>{const e=t();e&&r("commit-delete",c(e.getGeometry()).length)}}})(t,()=>l),m=(({manager:e,geometryType:t,getSketch:n})=>r=>{const i=n(),s=(0,o.a)({placed:i?c(i.getGeometry()):[],point:r,geometryType:t,onGeometryChange:e._geometryValidator});return s.valid||e.emit(o.A.PLACEMENT_BLOCKED,s.blocked),s.valid})({manager:t,geometryType:i,getSketch:()=>l}),y=new Object(function(){var e=new Error("Cannot find module 'ol/interaction/Draw.js'");throw e.code="MODULE_NOT_FOUND",e}())({type:i,style:e=>p(e),stopClick:!0,snapTolerance:o.T.snapRadius,condition:z(e,i,()=>l,m),finishCondition:()=>!1!==t._geometryValid});e.addInteraction(y);const v=(0,r.e)({onChange:e=>{u=e,p=t.styles.createSketchStyle(i,u),y.overlay_.changed()}}),b=(0,r.f)({onStrokeChange:(e,t)=>v.set(e,t),onPlaceChange:(e,n)=>t.emit(o.A.CAN_PLACE_CHANGE,{canPlace:!e,reason:n})}),_=o.w[i],E=()=>{p=t.styles.createSketchStyle(i,u),y.overlay_.changed()};t.on($,E),y.overlay_.updateWhileAnimating_=!0,((e,{manager:t,featureId:n,properties:r,onStart:i,onSketchChange:s})=>{e.on("drawstart",e=>{i(e.feature),e.feature.getGeometry().on("change",s)}),e.on("drawend",e=>((e,t,n,r)=>{t.setId(String(n)),t.setProperties(r),e.store.source.addFeature(t),e.emit(o.A.CREATE,e.store.toGeoJSON(t))})(t,e.feature,n,r)),e.on("drawabort",()=>{t.emit(o.A.CANCEL)})})(y,{manager:t,featureId:s,properties:a,onStart:e=>{l=e,f()},onSketchChange:()=>{h(),(()=>{if(!l)return;const{feature:e,numVertices:n}=((e,t)=>{const n=t.getGeometry(),r=n.getCoordinates(),o="Polygon"===e?r[0]??[]:r;return{feature:{type:"Feature",geometry:"Polygon"===e?{type:"Polygon",coordinates:[o]}:{type:"LineString",coordinates:o}},numVertices:c(n).length}})(i,l);b.update({feature:e,context:{mode:_},numVertices:n,onGeometryChange:t._geometryValidator})})()}});const S=(({drawInteraction:e,options:t,geometryType:n,getSketch:r,updateVertexCount:o,emitUndoValidation:i,canPlaceVertex:s})=>(({drawInteraction:e,options:t})=>{const{container:n,addVertexButtonId:r,mapProvider:o,snap:i,onUndo:s,canFinish:a,canPlace:l,crossHair:c}=t;let u=t.interfaceType??"mouse";const p=()=>u,h=(({drawInteraction:e,mapProvider:t,snap:n,canFinish:r,canPlace:o})=>{let i=null,s=null;const a=(e=null)=>{i=e,s=null};e.on("drawstart",e=>a(e.feature)),e.on("drawend",()=>a()),e.on("drawabort",()=>a());const l=()=>{const e=t.getCenter();return n?n.apply(e):e};return{placeVertex:()=>{const t=l();if(n?.hideIndicator(),i){const n=i.getGeometry(),o=n.getCoordinates(),a="Polygon"===n.getType()?o[0]||[]:o,l=(({drawInteraction:e,canFinish:t,geom:n,sketchCoords:r,coord:o,lastPlacedCoord:i})=>{if(i&&i[0]===o[0]&&i[1]===o[1])return t?.()&&e.finishDrawing(),{handled:!0,lastPlacedCoord:null};const s=e.getMap();if(((e,t,n,r)=>{if("Polygon"!==r||n.length<4)return!1;const o=V(e,t),i=V(e,n[0]);return!(!o||!i)&&B(o,i)<12})(s,o,r,n.getType()))return e.finishDrawing(),{handled:!0,lastPlacedCoord:i};const a=d(n);if(a){const e=s.getPixelFromCoordinate(a),t=s.getPixelFromCoordinate(o);if(e&&t){const n=e[0]-t[0],r=e[1]-t[1];if(n*n+r*r<4)return{handled:!0,lastPlacedCoord:o}}}return{handled:!1,lastPlacedCoord:i}})({drawInteraction:e,canFinish:r,geom:n,sketchCoords:a,coord:t,lastPlacedCoord:s});if(s=l.lastPlacedCoord,l.handled)return}o&&!o(t)||(e.appendCoordinates([t]),s=t)},updateRubberbanding:()=>{if(!i)return void(n&&n.apply(t.getCenter()));const e=i.getGeometry();e.getCoordinates().length&&((e,t)=>{if("LineString"===e.getType()){const n=[...e.getCoordinates()];n[n.length-1]=t,e.setCoordinates(n)}else if("Polygon"===e.getType()){const n=e.getCoordinates().map((e,n)=>{if(0!==n)return e;const r=[...e];return r[r.length-1]=t,r});e.setCoordinates(n)}})(e,l())},clearLastCoord(){s=null}}})({drawInteraction:e,mapProvider:o,snap:i,canFinish:a,canPlace:l}),f=e.getMap(),g=f?.getView(),m=H({container:n,addVertexButtonId:r,olView:g,onUndo:s,getInterfaceType:p,setInterfaceType:e=>{u=e,j(c,e)},clearLastCoord:h.clearLastCoord,updateRubberbanding:h.updateRubberbanding,placeVertex:h.placeVertex});j(c,u),c&&(c.activate=h.placeVertex);const y=()=>{g?.getAnimating()&&h.updateRubberbanding()};return f?.on("postrender",y),{getInterfaceType:p,setInterfaceType(e){u=e,j(c,e),"mouse"!==e&&h.updateRubberbanding()},destroy(){c?.activate===h.placeVertex&&(c.activate=null),m.destroy(),f?.un("postrender",y)}}})({drawInteraction:e,options:{container:t.container,interfaceType:t.interfaceType,addVertexButtonId:t.addVertexButtonId,mapProvider:t.mapProvider,snap:t.snap,crossHair:t.crossHair,onUndo:()=>{e.removeLastPoint(),o(),i()},canFinish:()=>Y(n,r()),canPlace:s}}))({drawInteraction:y,options:n,geometryType:i,getSketch:()=>l,updateVertexCount:h,emitUndoValidation:g,canPlaceVertex:m});return(({map:e,manager:t,drawInteraction:n,input:r,geometryType:i,getSketch:s,updateVertexCount:a,emitUndoValidation:l,onStylesChanged:c,clearSketch:d,setInvalid:u,liveStroke:p,liveDrawChecks:h})=>({done(){Y(i,s())&&n.finishDrawing()},cancel(){n.abortDrawing()},undo(){n.removeLastPoint(),a(),l()},setInvalid:u,setInterfaceType(e){r.setInterfaceType(e)},setDrawingPreviewProperty(e,t){const r=s();r&&(r.set(e,t),n.overlay_.changed())},destroy(){p.destroy(),h.destroy(),t.off($,c),t.emit(o.A.INTERFACE_TYPE_CHANGE,{interfaceType:r.getInterfaceType()}),r.destroy(),e.removeInteraction(n),d()}}))({map:e,manager:t,drawInteraction:y,input:S,geometryType:i,getSketch:()=>l,updateVertexCount:h,emitUndoValidation:g,onStylesChanged:E,clearSketch:()=>{l=null},setInvalid:e=>v.set(e),liveStroke:v,liveDrawChecks:b})},q=e=>{if(!e?.coordinates)return[];switch(e.type){case"LineString":return e.coordinates;case"Polygon":return e.coordinates.flatMap(e=>e.slice(0,-1));case"MultiLineString":return e.coordinates.flat(1);case"MultiPolygon":return e.coordinates.flatMap(e=>e.flatMap(e=>e.slice(0,-1)));default:return[]}},X=e=>{if(!e?.coordinates)return[];const t=[];let n=0;switch(e.type){case"LineString":t.push({start:0,length:e.coordinates.length,path:[],closed:!1});break;case"Polygon":e.coordinates.forEach((e,r)=>{const o=e.length-1;t.push({start:n,length:o,path:[r],closed:!0}),n+=o});break;case"MultiLineString":e.coordinates.forEach((e,r)=>{t.push({start:n,length:e.length,path:[r],closed:!1}),n+=e.length});break;case"MultiPolygon":e.coordinates.forEach((e,r)=>{e.forEach((e,o)=>{const i=e.length-1;t.push({start:n,length:i,path:[r,o],closed:!0}),n+=i})})}return t},Z=(e,t)=>{for(const n of e)if(t>=n.start&&t<n.start+n.length)return{segment:n,localIdx:t-n.start};return null},Q=(e,t)=>{let n=e.coordinates;for(const r of t)n=n[r];return n},ee=e=>{const t=q(e),n=X(e);if(!t.length||!n.length)return[];const r=[];for(const o of n){const e=o.closed?o.length:o.length-1;for(let n=0;n<e;n++){const e=o.start+n,i=o.start+(n+1)%o.length,[s,a]=t[e],[l,c]=t[i];r.push([(s+l)/2,(a+c)/2])}}return r},te=(e,t,n,r,o=12)=>((e,t,n,r=12)=>{let o=-1,i=r;return t.forEach((t,r)=>{const s=V(e,t);if(!s)return;const a=B(s,n);a<i&&(i=a,o=r)}),o>=0?{index:o,type:"vertex"}:null})(e,t,r,o)??((e,t,n,r,o=12)=>{let i=-1,s=o;return t.forEach((t,r)=>{const o=V(e,t);if(!o)return;const a=B(o,n);a<s&&(s=a,i=r)}),i>=0?{index:r+i,type:"midpoint"}:null})(e,n,r,t.length,o),ne=(e,t)=>{if(t.length>e.length){const n=t.findIndex((t,n)=>t[0]!==e[n]?.[0]);return{type:"insert_vertex",vertexIndex:Math.max(0,n)}}if(t.length===e.length){const n=t.findIndex((t,n)=>t[0]!==e[n][0]||t[1]!==e[n][1]);if(n>=0)return{type:"move_vertex",vertexIndex:n,previousCoord:e[n]}}return null},re=(e,t,n,r)=>{const o=n-r,i=t[o];if(!i)return null;const s=e.getGeometry(),a={type:s.getType(),coordinates:s.getCoordinates()},l=X(a);let c=0;for(const d of l){const e=d.closed?d.length:d.length-1;if(o<c+e){const e=o-c+1,t=d.start+e;return Q(a,d.path).splice(e,0,[...i]),s.setCoordinates(a.coordinates),{insertedIndex:t}}c+=e}return null},oe=(e,t,n)=>{const r=e.getGeometry(),o={type:r.getType(),coordinates:r.getCoordinates()},i=X(o),s=Z(i,t);if(!s)return;const a=Q(o,s.segment.path);a[s.localIdx]=[...n],s.segment.closed&&0===s.localIdx&&(a[a.length-1]=[...n]),r.setCoordinates(o.coordinates)},ie=({map:e,container:t,getState:n,setState:o,onVertexMoved:i,onTap:s,colors:a,snap:l,moveCoord:c=oe})=>{const d=(0,r.c)(t);(0,r.a)(d,a);const u={scale:1,ox:0,oy:0},p=e=>({x:e.x*u.scale+u.ox,y:e.y*u.scale+u.oy}),h=()=>{const n=e.getViewport(),r=n.getBoundingClientRect(),o=t.getBoundingClientRect(),i=n.offsetWidth>0?r.width/n.offsetWidth:1,s=t.offsetWidth>0?o.width/t.offsetWidth:1;Object.assign(u,{scale:i/s,ox:(r.left-o.left)/s,oy:(r.top-o.top)/s})},f=()=>{const{selectedVertexIndex:t,vertices:o,interfaceType:i}=n();if(t<0||!o[t]||"touch"!==i)return void(0,r.h)(d);const s=V(e,o[t]);s?(0,r.g)(d,p(s)):(0,r.h)(d)},g=(e=>{const{container:t}=e,n={dragStartCoord:null,dragStartIndex:null,vertexTouchDelta:null,targetTouchDelta:null,tapStart:null},o={...e,drag:n},i=e=>((e,{map:t,targetEl:n,cssToOl:o,getState:i,drag:s})=>{const a=e.touches[0],l=(0,r.i)(e.target);if(s.tapStart={x:a.clientX,y:a.clientY,time:Date.now(),onTarget:l},!l)return;const{selectedVertexIndex:c,vertices:d}=i(),u=d[c];if(!u)return;const p=t.getEventPixel({clientX:a.clientX,clientY:a.clientY}),h=V(t,u),f=getComputedStyle(n),g=o({x:Number.parseFloat(f.left),y:Number.parseFloat(f.top)});s.dragStartCoord=[...u],s.dragStartIndex=c,s.vertexTouchDelta={x:p[0]-h.x,y:p[1]-h.y},s.targetTouchDelta={x:p[0]-g.x,y:p[1]-g.y},e.preventDefault()})(e,o),s=e=>((e,{map:t,targetEl:n,olToCSS:o,getState:i,setState:s,snap:a,drag:l,moveCoord:c})=>{if(!(0,r.i)(e.target)||null==l.dragStartIndex)return;e.preventDefault();const d=t.getEventPixel({clientX:e.touches[0].clientX,clientY:e.touches[0].clientY}),u=((e,t)=>e.getCoordinateFromPixel([t.x,t.y]))(t,{x:d[0]-l.vertexTouchDelta.x,y:d[1]-l.vertexTouchDelta.y}),p=a?a.apply(u):u,{olFeature:h,vertices:f}=i();h&&(c(h,l.dragStartIndex,p),s({vertices:f.map((e,t)=>t===l.dragStartIndex?p:e)}),(0,r.g)(n,o({x:d[0]-l.targetTouchDelta.x,y:d[1]-l.targetTouchDelta.y})))})(e,o),a=e=>((e,t)=>{const{getState:n,onVertexMoved:r,drag:o,updateTargetPosition:i}=t;if(null==o.dragStartIndex)return((e,{map:t,getState:n,onTap:r,drag:o})=>{if(!o.tapStart||o.tapStart.onTarget||0===e.changedTouches.length)return;const i=e.changedTouches[0],s=Date.now()-o.tapStart.time;if(Math.hypot(i.clientX-o.tapStart.x,i.clientY-o.tapStart.y)<10&&s<400){const o=t.getEventPixel({clientX:i.clientX,clientY:i.clientY}),s=n();r?.(te(t,s.vertices,s.midpoints,{x:o[0],y:o[1]},24)),e.preventDefault()}})(e,t),void(o.tapStart=null);o.tapStart=null;const{vertices:s}=n();s[o.dragStartIndex]&&o.dragStartCoord&&r({vertexIndex:o.dragStartIndex,previousCoord:o.dragStartCoord}),o.dragStartCoord=null,o.dragStartIndex=null,o.vertexTouchDelta=null,o.targetTouchDelta=null,i(),e.preventDefault()})(e,o);return t.addEventListener("touchstart",i,{passive:!1}),t.addEventListener("touchmove",s,{passive:!1}),t.addEventListener("touchend",a,{passive:!1}),t.addEventListener("touchcancel",a,{passive:!1}),{isDragging:()=>null!=n.dragStartIndex,destroy(){t.removeEventListener("touchstart",i),t.removeEventListener("touchmove",s),t.removeEventListener("touchend",a),t.removeEventListener("touchcancel",a)}}})({container:t,map:e,targetEl:d,olToCSS:p,cssToOl:e=>({x:(e.x-u.ox)/u.scale,y:(e.y-u.oy)/u.scale}),getState:n,setState:o,onVertexMoved:i,onTap:s,snap:l,moveCoord:c,updateTargetPosition:f}),m=()=>{const{selectedVertexIndex:e,interfaceType:t}=n();e>=0&&!g.isDragging()&&"touch"===t&&f()};e.on("postrender",m);const y=()=>{h(),e.once("postrender",f)};return e.on("change:size",y),h(),{updateTargetPosition:f,updateColors(e){(0,r.a)(d,e)},hide(){(0,r.h)(d)},destroy(){e.un("change:size",y),e.un("postrender",m),g.destroy(),(0,r.h)(d)}}},se=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),ae=new Set(["INPUT","TEXTAREA","BUTTON","SELECT","A"]),le=e=>{const{map:t,snap:n,getState:i,setState:s,onVertexMoved:a,onInserted:l,onDeleted:c,onUndo:d,onKeyboardActive:u,moveCoord:p}=e,{nudge:h,keyMove:f,nudgeByDelta:g}=(({map:e,snap:t,getState:n,setState:r,onInserted:i,onVertexMoved:s,moveCoord:a=oe})=>{const l={start:null,index:null},c=(o,i)=>{const{selectedVertexIndex:s,vertices:l,olFeature:c}=n();if(!c||s<0||!l[s])return null;const d=l[s],u=U(e,d,o,i),p=t?t.apply(u):u,h=((e,t,n,r,o,i,s)=>{if(!e)return o;const a=[r[0]-n[0],r[1]-n[1]],l=[o[0]-n[0],o[1]-n[1]],c=a[0]**2+a[1]**2;if(c>0&&(l[0]*a[0]+l[1]*a[1])/c<.5){const r=e.snapRadius+1;return U(t,n,0===i?0:Math.sign(i)*r,0===s?0:Math.sign(s)*r)}return o})(t,e,d,u,p,o,i);return t&&h!==p&&t.hideIndicator(),a(c,s,h),r({vertices:l.map((e,t)=>t===s?h:e)}),{previousCoord:d,vertexIndex:s}};return{nudge:s=>{const{selectedVertexIndex:a,selectedVertexType:d,vertices:u,midpoints:p,olFeature:h}=n();if(!h)return;const f=s.shiftKey?o.K.nudgeAmount:o.K.stepAmount,g={ArrowUp:[0,-f],ArrowDown:[0,f],ArrowLeft:[-f,0],ArrowRight:[f,0]},[m,y]=g[s.key];"midpoint"!==d?a<0||!u[a]||(l.start||(l.start=[...u[a]],l.index=a),c(m,y)):((o,s,a,c,d,u)=>{const p=re(o,s,a,c.length);if(!p)return;i({insertedIndex:p.insertedIndex});const h=n().vertices,f=h[p.insertedIndex];if(!f)return;l.start=[...f],l.index=p.insertedIndex;const g=U(e,f,d,u),m=t?t.apply(g):g;oe(o,p.insertedIndex,m),r({selectedVertexIndex:p.insertedIndex,selectedVertexType:"vertex",vertices:h.map((e,t)=>t===p.insertedIndex?m:e)})})(h,p,a,u,m,y)},keyMove:l,nudgeByDelta:(e,t,n)=>{const r=n?o.K.stepAmount:o.K.nudgeAmount,i=c(e*r,t*r);i&&s({vertexIndex:i.vertexIndex,previousCoord:i.previousCoord})}}})({map:t,snap:n,getState:i,setState:s,onInserted:l,onVertexMoved:a,moveCoord:p}),m=t.getViewport().closest('[role="application"]')??t.getViewport(),y=()=>(e=>{const t=document.activeElement;return!(!t||t===document.body)&&!e.contains(t)&&(ae.has(t.tagName)||t.isContentEditable||t.hasAttribute("tabindex"))})(m),v=(({map:e,getState:t,setState:n,nudge:o,keyMove:i,onUndo:s,onKeyboardActive:a,isFocused:l})=>{const c=i=>{i.altKey?(i.preventDefault(),i.stopPropagation(),((e,t,n,o)=>{const{selectedVertexIndex:i,vertices:s,midpoints:a}=n();if(!s.length)return;const l=[...s,...a].map(e=>V(t,e)).filter(Boolean).map(e=>[e.x,e.y]),c=i>=0?l[i]:(()=>{const e=V(t,t.getView().getCenter());return e?[e.x,e.y]:null})();if(!c)return;const d=(0,r.s)(c,l,e);o({selectedVertexIndex:d,selectedVertexType:d<s.length?"vertex":"midpoint"})})(i.key,e,t,n)):t().selectedVertexIndex>=0&&(i.preventDefault(),i.stopPropagation(),o(i))},d=o=>{if(a?.()," "===o.key)o.preventDefault(),t().selectedVertexIndex<0&&((e,t,n)=>{const{vertices:o,midpoints:i}=t();if(!o.length)return;const s=V(e,e.getView().getCenter());if(!s)return;const a=[...o.map(t=>V(e,t)),...i.map(t=>V(e,t))].filter(Boolean).map(e=>[e.x,e.y]),l=(0,r.s)([s.x,s.y],a,void 0);n({selectedVertexIndex:l,selectedVertexType:l<o.length?"vertex":"midpoint"})})(e,t,n);else if(se.has(o.key))c(o);else if("z"===o.key&&(o.metaKey||o.ctrlKey)){const e=document.activeElement?.tagName;ae.has(e)||(o.preventDefault(),o.stopPropagation(),s())}};return e=>{l()||("Escape"===e.key&&t().selectedVertexIndex>=0?(e.preventDefault(),i.start=null,i.index=null,n({selectedVertexIndex:-1,selectedVertexType:null})):d(e))}})({map:t,getState:i,setState:s,nudge:h,keyMove:f,onUndo:d,onKeyboardActive:u,isFocused:y}),b=(({getState:e,keyMove:t,onVertexMoved:n,onDeleted:o,isFocused:i})=>s=>{i()||(e().selectedVertexIndex>=0&&(0,r.b)(s),se.has(s.key)&&t.start&&null!=t.index&&(n({vertexIndex:t.index,previousCoord:t.start}),t.start=null,t.index=null),"Delete"===s.key&&o())})({getState:i,keyMove:f,onVertexMoved:a,onDeleted:c,isFocused:y});return globalThis.addEventListener("keydown",v,{capture:!0}),globalThis.addEventListener("keyup",b,{capture:!0}),{nudgeByDelta:g,destroy(){globalThis.removeEventListener("keydown",v,{capture:!0}),globalThis.removeEventListener("keyup",b,{capture:!0})}}},ce="touch",de="vertex",ue="commit-move",pe="commit-insert",he="commit-delete",fe={move_vertex:ue,insert_vertex:pe,delete_vertex:he},ge={move_vertex:ue,insert_vertex:he,delete_vertex:pe},me=({map:e,manager:t,options:n})=>{const{featureId:i,container:s,interfaceType:a,deleteVertexButtonId:l,snap:c}=n,{store:d,undoStack:u}=t,p=d.getOL(i);if(!p)return null;const h=p.getStyle(),f=((e,t)=>{let n=t,r=-1;const o=new Object(function(){var e=new Error("Cannot find module 'ol/source/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}()),i=new Object(function(){var e=new Error("Cannot find module 'ol/layer/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}())({source:o,style:e=>e.get("midpointIndex")===r?null:[n],zIndex:101});return e.addLayer(i),{update(e){o.clear();const t=ee(e).map((e,t)=>{const n=new Object(function(){var e=new Error("Cannot find module 'ol/Feature.js'");throw e.code="MODULE_NOT_FOUND",e}())({geometry:new Object(function(){var e=new Error("Cannot find module 'ol/geom/Point.js'");throw e.code="MODULE_NOT_FOUND",e}())(e)});return n.set("midpointIndex",t),n});o.addFeatures(t)},setSelected(e){r=e,o.changed()},updateStyle(e){n=e,o.changed()},getCoords:()=>o.getFeatures().sort((e,t)=>e.get("midpointIndex")-t.get("midpointIndex")).map(e=>e.getGeometry().getCoordinates()),remove(){o.clear(),e.removeLayer(i)}}})(e,t.styles.midpointStyle),g=((e,t)=>{let n=t,r=-1;const o=new Object(function(){var e=new Error("Cannot find module 'ol/source/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}()),i=new Object(function(){var e=new Error("Cannot find module 'ol/layer/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}())({source:o,style:e=>e.get("vertexIndex")===r?null:[n],zIndex:102});return e.addLayer(i),{update(e){o.clear(),q(e).forEach((e,t)=>{const n=new Object(function(){var e=new Error("Cannot find module 'ol/Feature.js'");throw e.code="MODULE_NOT_FOUND",e}())({geometry:new Object(function(){var e=new Error("Cannot find module 'ol/geom/Point.js'");throw e.code="MODULE_NOT_FOUND",e}())(e)});n.set("vertexIndex",t),o.addFeature(n)})},setSelected(e){r=e,o.changed()},updateStyle(e){n=e,o.changed()},remove(){o.clear(),e.removeLayer(i)}}})(e,t.styles.vertexStyle),m=((e,t)=>{const n=new Object(function(){var e=new Error("Cannot find module 'ol/source/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}()),r=new Object(function(){var e=new Error("Cannot find module 'ol/layer/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}())({source:n,zIndex:103});return e.addLayer(r),{update(e){if(n.clear(),e.selectedVertexIndex<0)return;const{coord:r,style:o}=(({selectedVertexIndex:e,selectedVertexType:n,vertices:r,midpoints:o})=>{const i=t();return"vertex"===n?{coord:r[e],style:i.selectedVertexStyle}:"midpoint"===n?{coord:o[e-r.length],style:i.selectedMidpointStyle}:{coord:null,style:null}})(e);if(!r)return;const i=new Object(function(){var e=new Error("Cannot find module 'ol/Feature.js'");throw e.code="MODULE_NOT_FOUND",e}())({geometry:new Object(function(){var e=new Error("Cannot find module 'ol/geom/Point.js'");throw e.code="MODULE_NOT_FOUND",e}())(r)});i.setStyle(o),n.addFeature(i)},remove(){n.clear(),e.removeLayer(r)}}})(e,()=>t.styles),y=(({map:e,manager:t,store:n,olFeature:r,interfaceType:i,layers:s})=>{const{vertexLayer:a,midpointLayer:l,activeLayer:c}=s,d={olFeature:r,selectedVertexIndex:-1,selectedVertexType:null,vertices:[],midpoints:[],interfaceType:i??"mouse"},u={onDeselect:null,onUpdate:null},p=()=>{const e=r.getGeometry();return{type:e.getType(),coordinates:e.getCoordinates()}},h=()=>((e,{vertexLayer:t,midpointLayer:n,activeLayer:r,manager:i,hooks:s})=>{t.setSelected("vertex"===e.selectedVertexType?e.selectedVertexIndex:-1),n.setSelected("midpoint"===e.selectedVertexType?e.selectedVertexIndex-e.vertices.length:-1),e.selectedVertexIndex<0&&s.onDeselect?.(),r.update(e),i.emit(o.A.VERTEX_SELECTION,{index:"vertex"===e.selectedVertexType?e.selectedVertexIndex:-1,numVertices:e.vertices.length})})(d,{vertexLayer:a,midpointLayer:l,activeLayer:c,manager:t,hooks:u}),f=()=>{const e=p();d.vertices=q(e),d.midpoints=ee(e),l.update(e),a.update(e),c.update(d)},g=((e,t,n)=>(r,i)=>{r&&setTimeout(()=>{e.emit(o.A.GEOMETRY_CHANGE,{feature:t.toGeoJSON(n),phase:r,vertexIndex:i})},0)})(t,n,r),m=()=>f();return r.getGeometry().on("change",m),{state:d,getState:()=>d,setState:t=>{Object.assign(d,t),void 0!==t.selectedVertexIndex&&h(),void 0!==t.vertices&&(()=>{const t=p();l.update(t),a.update(t),d.midpoints=l.getCoords(),c.update(d),u.onUpdate?.(),e.render()})()},syncGeom:()=>{f(),t.emit(o.A.VERTEX_CHANGE,{numVertices:d.vertices.length}),t.emit(o.A.UPDATE,n.toGeoJSON(r))},emitGeometryValidation:g,updateLayersFromGeom:f,setHooks:({onDeselect:e,onUpdate:t})=>Object.assign(u,{onDeselect:e,onUpdate:t}),destroy(){r.getGeometry().un("change",m)}}})({map:e,manager:t,store:d,olFeature:p,interfaceType:a,layers:{vertexLayer:g,midpointLayer:f,activeLayer:m}}),{state:v,getState:b,setState:_,syncGeom:E,emitGeometryValidation:S}=y,x=(({map:e,olFeature:t,getState:n,onModifyEnd:r,condition:o})=>{const i=o??(({map:e,getState:t})=>n=>{const{interfaceType:r,vertices:o,midpoints:i}=t();if("touch"===r)return!1;const s=e.getEventPixel(n.originalEvent);return null!==te(e,o,i,{x:s[0],y:s[1]})})({map:e,getState:n}),s=new Object(function(){var e=new Error("Cannot find module 'ol/interaction/Modify.js'");throw e.code="MODULE_NOT_FOUND",e}())({features:new Object(function(){var e=new Error("Cannot find module 'ol/Collection.js'");throw e.code="MODULE_NOT_FOUND",e}())([t]),style:()=>[],pixelTolerance:12,condition:i});e.addInteraction(s);let a=null;return s.on("modifystart",()=>{"touch"!==n().interfaceType&&(a=n().vertices.map(e=>[...e]))}),s.on("modifyend",()=>{if("touch"===n().interfaceType)return;const e=a;a=null,r(e)}),{destroy(){e.removeInteraction(s)}}})({map:e,olFeature:p,getState:b,onModifyEnd(e){E();const t=e&&ne(e,v.vertices);t&&(u.push(t),S(fe[t.type],t.vertexIndex),_({selectedVertexIndex:t.vertexIndex,selectedVertexType:de}))}});E();const I={vertexLayer:g,midpointLayer:f,activeLayer:m},w=(({map:e,manager:t,olFeature:n})=>{let i=!1;n.setStyle(()=>i?t.styles.editFeatureStyleInvalid:t.styles.editFeatureStyle);const s=(0,r.e)({onChange:(n,r)=>{i=n,e.render(),t.emit(o.A.VALIDITY_CHANGE,{valid:!n,reason:r})}}),a=()=>{const e=n.getGeometry(),r=e.getType(),o=e.getCoordinates(),i="Polygon"===r?Math.max(0,(o[0]?.length??1)-1):o.length;s.update({feature:{type:"Feature",geometry:{type:r,coordinates:o}},context:{mode:"edit_vertex"},numVertices:i,onGeometryChange:t._geometryValidator})};return n.getGeometry().on("change",a),{liveStroke:s,destroy(){n.getGeometry().un("change",a),s.destroy()}}})({map:e,manager:t,olFeature:p}),P=(({map:e,container:t,manager:n,snap:r,olFeature:o,undoStack:i,selection:s})=>{const{state:a,getState:l,setState:c,syncGeom:d,emitGeometryValidation:u}=s,p=e=>c({selectedVertexIndex:e,selectedVertexType:de}),h=ie({map:e,container:t,getState:l,setState:c,colors:n.colors,snap:r,onVertexMoved({vertexIndex:e,previousCoord:t}){i.push({type:"move_vertex",vertexIndex:e,previousCoord:t}),d(),u(ue,e),p(e),h.updateTargetPosition()},onTap(e){if(!e)return void c({selectedVertexIndex:-1,selectedVertexType:null});if(e.type===de)return p(e.index),void h.updateTargetPosition();const t=re(o,a.midpoints,e.index,a.vertices.length);t&&(i.push({type:"insert_vertex",vertexIndex:t.insertedIndex}),d(),u(pe,t.insertedIndex),p(t.insertedIndex),h.updateTargetPosition())}});return s.setHooks({onDeselect:()=>h.hide(),onUpdate(){a.interfaceType===ce&&h.updateTargetPosition()}}),h})({map:e,container:s,manager:t,snap:c,olFeature:p,undoStack:u,selection:y}),C=(({olFeature:e,undoStack:t,selection:n,getTouchHandler:r})=>{const{state:i,setState:s,syncGeom:a,emitGeometryValidation:l}=n;return{doDeleteVertex:()=>{if(i.selectedVertexType!==de||i.selectedVertexIndex<0)return;const n=((e,t)=>{const n=e.getGeometry(),r={type:n.getType(),coordinates:n.getCoordinates()},i=q(r),s=X(r),a=Z(s,t);if(!a)return null;const{segment:l}=a,c=l.closed?o.M.Polygon:o.M.LineString;if(l.length<=c)return null;const d=[...i[t]],u=Q(r,l.path);return u.splice(a.localIdx,1),l.closed&&(u[u.length-1]=[...u[0]]),n.setCoordinates(r.coordinates),{deletedIndex:t,deletedCoord:d}})(e,i.selectedVertexIndex);n&&(t.push({type:"delete_vertex",vertexIndex:n.deletedIndex,deletedCoord:n.deletedCoord}),a(),l(he,n.deletedIndex),s({selectedVertexIndex:-1,selectedVertexType:null}))},doUndo:()=>{const n=t.pop();if(!n)return;const o=i.selectedVertexIndex,c=((e,t)=>{switch(t.type){case"move_vertex":return((e,t)=>{const{vertexIndex:n,previousCoord:r}=t,o=e.getGeometry(),i={type:o.getType(),coordinates:o.getCoordinates()},s=X(i),a=Z(s,n);if(!a)return-1;const l=Q(i,a.segment.path);return l[a.localIdx]=[...r],a.segment.closed&&0===a.localIdx&&(l[l.length-1]=[...r]),o.setCoordinates(i.coordinates),n})(e,t);case"insert_vertex":return((e,t)=>{const{vertexIndex:n}=t,r=e.getGeometry(),o={type:r.getType(),coordinates:r.getCoordinates()},i=X(o),s=Z(i,n);if(s){const e=Q(o,s.segment.path);e.splice(s.localIdx,1),s.segment.closed&&(e[e.length-1]=[...e[0]]),r.setCoordinates(o.coordinates)}return-1})(e,t);case"delete_vertex":return((e,t)=>{const{vertexIndex:n,deletedCoord:r}=t,o=e.getGeometry(),i={type:o.getType(),coordinates:o.getCoordinates()},s=X(i);let a=Z(s,n);if(!a)for(const c of s)if(n===c.start+c.length){a={segment:c,localIdx:c.length};break}if(!a)return-1;const l=Q(i,a.segment.path);return l.splice(a.localIdx,0,[...r]),a.segment.closed&&(l[l.length-1]=[...l[0]]),o.setCoordinates(i.coordinates),n})(e,t);default:return-1}})(e,n);a(),l(ge[n.type],c);const d=o>=0?c:-1;s({selectedVertexIndex:d,selectedVertexType:d>=0?de:null}),o>=0&&d>=0&&i.interfaceType===ce&&r().updateTargetPosition()}}})({olFeature:p,undoStack:u,selection:y,getTouchHandler:()=>P}),T=(({map:e,container:t,snap:n,undoStack:r,selection:o,touchHandler:i,actions:s})=>{const{state:a,getState:l,setState:c,syncGeom:d,emitGeometryValidation:u}=o;return le({map:e,getState:l,setState:c,snap:n,onVertexMoved({vertexIndex:e,previousCoord:t}){r.push({type:"move_vertex",vertexIndex:e,previousCoord:t}),d(),u(ue,e),c({selectedVertexIndex:e,selectedVertexType:de})},onInserted({insertedIndex:e}){r.push({type:"insert_vertex",vertexIndex:e}),d(),u(pe,e)},onDeleted:s.doDeleteVertex,onUndo:s.doUndo,onKeyboardActive(){"keyboard"!==a.interfaceType&&(a.interfaceType="keyboard",i.hide(),t.focus({preventScroll:!0}))}})})({map:e,container:s,snap:c,undoStack:u,selection:y,touchHandler:P,actions:C}),M=(({map:e,container:t,getState:n,setState:r,touchHandler:o,deleteVertexButtonId:i,onDeleteVertex:s})=>{const a=t=>{const{vertices:r,midpoints:o}=n(),i=e.getEventPixel(t);return te(e,r,o,{x:i[0],y:i[1]})},l=e=>{const t=n();if("touch"===e.pointerType)return t.interfaceType="touch",void o.updateTargetPosition();t.interfaceType="mouse";const i=a(e);"vertex"===i?.type&&r({selectedVertexIndex:i.index,selectedVertexType:"vertex"})},c=e=>{if("touch"===n().interfaceType)return;const t=a(e);"vertex"===t?.type?r({selectedVertexIndex:t.index,selectedVertexType:"vertex"}):"midpoint"===t?.type||r({selectedVertexIndex:-1,selectedVertexType:null})},d=e=>{const t=n();"mouse"===e.pointerType&&"mouse"!==t.interfaceType&&(t.interfaceType="mouse",o.hide())},u=e=>{i&&e.target.closest(`#${i}`)&&s()};return t.addEventListener("pointerdown",l),t.addEventListener("pointerenter",d),t.addEventListener("pointermove",d),t.addEventListener("click",c),globalThis.addEventListener("click",u),{destroy(){t.removeEventListener("pointerdown",l),t.removeEventListener("pointerenter",d),t.removeEventListener("pointermove",d),t.removeEventListener("click",c),globalThis.removeEventListener("click",u)}}})({map:e,container:s,getState:b,setState:_,touchHandler:P,deleteVertexButtonId:l,onDeleteVertex:C.doDeleteVertex}),L=(({map:e,manager:t,layers:n,selection:r,touchHandler:o,live:i})=>{const{state:s}=r,a=e=>{i.liveStroke.refresh(),n.vertexLayer.updateStyle(e.vertexStyle),n.midpointLayer.updateStyle(e.midpointStyle),n.activeLayer.update(s),o.updateColors(t.colors)};t.on($,a);const l=()=>{s.interfaceType!==ce||s.selectedVertexIndex<0||e.once("postrender",()=>o.updateTargetPosition())};return e.on("change:size",l),{destroy(){t.off($,a),e.un("change:size",l)}}})({map:e,manager:t,layers:I,selection:y,touchHandler:P,live:w});return(({manager:e,store:t,olFeature:n,originalFeatureStyle:r,selection:i,actions:s,parts:a,undoStack:l})=>{const{state:c,setState:d,syncGeom:u,emitGeometryValidation:p}=i,{touchHandler:h}=a;return{setInterfaceType(e){e!==c.interfaceType&&(c.interfaceType=e,e===ce?h.updateTargetPosition():h.hide())},done(){e.emit(o.A.EDIT_FINISH,t.toGeoJSON(n))},setInvalid(e){a.live.liveStroke.set(e)},cancel(){},undo:s.doUndo,deleteVertex:s.doDeleteVertex,nudgeSelectedVertex:a.keyboardHandler.nudgeByDelta,getVertexItems:()=>({vertices:c.vertices,midpoints:c.midpoints}),selectVertex(e){d({selectedVertexIndex:e,selectedVertexType:e<c.vertices.length?de:"midpoint"}),h.updateTargetPosition()},insertVertexAtMidpoint(e){const t=re(n,c.midpoints,e,c.vertices.length);t&&(l.push({type:"insert_vertex",vertexIndex:t.insertedIndex}),u(),p(pe,t.insertedIndex),d({selectedVertexIndex:t.insertedIndex,selectedVertexType:de}),h.updateTargetPosition())},destroy(){a.live.destroy(),n.setStyle(r),i.destroy(),a.mapSync.destroy(),a.pointerHandlers.destroy(),a.modify.destroy(),a.layers.activeLayer.remove(),a.layers.midpointLayer.remove(),a.layers.vertexLayer.remove(),h.destroy(),a.keyboardHandler.destroy()}}})({manager:t,store:d,olFeature:p,originalFeatureStyle:h,selection:y,actions:C,undoStack:u,parts:{touchHandler:P,keyboardHandler:T,pointerHandlers:M,modify:x,mapSync:L,layers:I,live:w}})},ye=(e,t,n)=>{e.getGeometry().setCoordinates([...n])},ve="touch",be="commit-move",_e=({map:e,olFeature:t})=>n=>{const r=e.getEventPixel(n.originalEvent);return!!e.forEachFeatureAtPixel(r,e=>e===t,{hitTolerance:12})},Ee="draw_point",Se=async({manager:e,mapProvider:t,olFeature:n,pixelRatioOverride:r,refreshId:i})=>{const s=n.getProperties();if(!(0,o.s)(s))return;const{symbolRegistry:a,mapStyle:l}=e,c=r??(e=>e?.map?.getPixelRatio?.()||1)(t);await t.addSymbolsToMap([s],l,a,c);const d=a.getSymbolImageId(s,l,"normal",c);d&&e.store.source.hasFeature(n)&&(void 0===i||i===e.pointSymbolRefreshId)&&n.setProperties({symbolImageId:d,symbolActiveImageId:t.getActiveSymbolImageId(d),symbolSelectedImageId:t.getSelectedSymbolImageId(d),symbolImageAnchor:a.getSymbolDef(s).anchor,symbolPixelRatio:c})};class xe{constructor(e,t={},{mapProvider:n,symbolRegistry:i}={}){this._map=e,this._pluginConfig=t,this.mapProvider=n,this.symbolRegistry=i,this._getSymbolImage=e=>this.mapProvider?.getSymbolImage(e),this._mode="disabled",this._modeInstance=null,this._listeners=new Map,this.store=a(),this.undoStack=(0,r.d)(e=>this.emit(o.A.UNDO_CHANGE,e)),this.mapStyle=null,this.colors=(0,r.r)(null,t),this.styles=v(this.colors,this._getSymbolImage),this.snap=((e,t,n,r)=>{if(!t?.length)return null;const o=((e,t=[])=>{let n=new Set,r=[];const o=e=>{n=new Set,r=[];for(const t of e??[])"string"==typeof t?n.add(t):"function"==typeof t?.getSource&&r.push(t)};return o(t),{query:(t,o)=>{A()&&console.log("[snap-query]",{coord:[t[0].toFixed(2),t[1].toFixed(2)],radiusPx:o,vtLayerCount:n.size,olLayerCount:r.length});const i=e.getView().getResolution();if(!i)return null;const s=o*i,a=s*s,l=[t[0]-s,t[1]-s,t[0]+s,t[1]+s];let c=null;for(const e of r){const n=e.getSource();if(n)for(const e of n.getFeaturesInExtent(l))c=E(c,M(e,t,a))}if(n.size>0){const r=(e=>{const t=[];return e.getLayers().forEach(e=>{"vectorTile"===e.get("layerType")&&t.push(e)}),t})(e),s=r.length>0?e.getPixelFromCoordinate(t):null;if(s){const l=new Map;e.forEachFeatureAtPixel(s,(o,s)=>{const d=o.get("mapbox-layer");if(!n.has(d?.id))return;const u=((e,t,n)=>{const r=e.getType(),o=e.getFlatCoordinates();let i=null,s=null;if("Point"===r){const e=b(t,o);e<=n&&(i={type:"vertex",coord:[o[0],o[1]],distSq:e})}else if("LineString"===r)({vertex:i,edge:s}=C(o,0,o.length,t,n,!1));else if("Polygon"===r||"MultiLineString"===r){const a=e.getEnds();let l=0;const c="Polygon"===r;for(const e of a){const r=C(o,l,e,t,n,c);i=E(i,r.vertex),s=E(s,r.edge),l=e}}return[i,s].filter(Boolean)})(o,t,a);if(!u.length)return;l.has(s)||l.set(s,((e,t)=>{const n=e.getSource(),r=n?.getTileGrid();if(!r)return null;const o=t.getView().getProjection(),i=n.getProjection()??o,s=r.getZForResolution(t.getView().getResolution(),0);return{tileGrid:r,viewProj:o,sourceProj:i,zoom:s}})(s,e));const p=l.get(s);c=((e,t,n)=>{let r=e;for(const o of t)O(o,n.mapboxLayer),k({candidate:o,...n})||(r=E(r,o));return r})(c,u,{cursorCoord:t,mapboxLayer:d,boundaryState:p,map:e,vtLayers:r,resolution:i})},{hitTolerance:o,layerFilter:e=>r.includes(e)})}}return c?{type:c.type,coord:c.coord}:null},setLayers:o}})(e,t),i=((e,t)=>{let n=R(t);const r=new Object(function(){var e=new Error("Cannot find module 'ol/source/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}()),o=new Object(function(){var e=new Error("Cannot find module 'ol/layer/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}())({source:r,style:e=>n[e.get("snapType")]??null,zIndex:99,updateWhileAnimating:!0,updateWhileInteracting:!0});e.addLayer(o);const i=new Object(function(){var e=new Error("Cannot find module 'ol/Feature.js'");throw e.code="MODULE_NOT_FOUND",e}());let s=!1;return{show(e,t){i.setGeometry(new Object(function(){var e=new Error("Cannot find module 'ol/geom/Point.js'");throw e.code="MODULE_NOT_FOUND",e}())(e)),i.set("snapType",t,!0),s?r.changed():(r.addFeature(i),s=!0)},hide(){s&&(r.clear(),s=!1)},updateColors(e){n=R(e),s&&r.changed()},remove(){r.clear(),e.removeLayer(o)}}})(e,n);let s=!1;const a=((e,t,n,r)=>{const o=new Object(function(){var e=new Error("Cannot find module 'ol/interaction/Interaction.js'");throw e.code="MODULE_NOT_FOUND",e}())({handleEvent:i=>(o.getActive()&&((e,t,n,r,o)=>{const{type:i}=e;if("pointerout"===i||"pointerleave"===i)return void n.hide();if(!N.has(i))return;const s=t.query(e.coordinate,r);s&&(e.coordinate=s.coord.slice()),F.has(i)&&o()&&(s?n.show(s.coord,s.type):n.hide())})(i,e,t,n,r),!0)});return o})(o,i,r,()=>s);e.addInteraction(a),a.setActive(!1);let l=!1;return{snapRadius:r,apply(e){if(!l)return e;const t=o.query(e,r);return t?(i.show(t.coord,t.type),t.coord):(i.hide(),e)},hideIndicator(){i.hide()},setIndicatorActive(e){s=e,e||i.hide()},setActive(e){l=e,a.setActive(e),e||i.hide()},setSnapLayers(e){o.setLayers(null==e?t:e)},reattach(){e.removeInteraction(a),e.addInteraction(a)},updateColors(e){i.updateColors(e)},destroy(){e.removeInteraction(a),i.remove()}}})(e,t.snapLayers??null,this.colors,t.snapRadius??o.T.snapRadius),this._layer=new Object(function(){var e=new Error("Cannot find module 'ol/layer/Vector.js'");throw e.code="MODULE_NOT_FOUND",e}())({source:this.store.source,style:this.styles.createFeatureStyle(),zIndex:100}),this._layer.set("layerId","draw"),this._layer.set("layerType","vector"),e.addLayer(this._layer)}setMapStyle(e){this.mapStyle=e,this.colors=(0,r.r)(e,this._pluginConfig),this.styles=v(this.colors,this._getSymbolImage),this._layer.setStyle(this.styles.createFeatureStyle()),this.store.source.changed(),this.snap?.updateColors(this.colors),this.emit($,this.styles)}on(e,t){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t)}off(e,t){this._listeners.get(e)?.delete(t)}emit(e,t){const n=this._listeners.get(e);n&&Array.from(n).forEach(e=>e(t))}changeMode(e,t={}){this._modeInstance?.destroy(),this._modeInstance=null,this._mode=e;const n="draw_polygon"===e||"draw_line"===e||"draw_point"===e||"edit_vertex"===e||"edit_point"===e;this.snap?.setIndicatorActive(n);const i={...t,snap:this.snap};if("draw_polygon"===e||"draw_line"===e)this._modeInstance=J({map:this._map,manager:this,options:i});else if("draw_point"===e){const e={...i,resolvePointSymbol:e=>this.updatePointSymbol(e)};this._modeInstance=(({map:e,manager:t,options:n})=>{const{featureId:r,properties:i={}}=n,s=(e=>t=>{const n={type:"Feature",geometry:{type:"Point",coordinates:t},properties:{}},{valid:r,reason:i}=(0,o.v)(n,{mode:Ee,vertexIndex:0},{onGeometryChange:e._geometryValidator});return r||e.emit(o.A.PLACEMENT_BLOCKED,{feature:n,reason:i??null,phase:"place",mode:Ee,vertexIndex:0}),r})(t),a=new Object(function(){var e=new Error("Cannot find module 'ol/interaction/Draw.js'");throw e.code="MODULE_NOT_FOUND",e}())({type:"Point",style:()=>[],snapTolerance:o.T.snapRadius,condition:e=>Object(function(){var e=new Error("Cannot find module 'ol/events/condition.js'");throw e.code="MODULE_NOT_FOUND",e}())(e)&&s(e.coordinate)});e.addInteraction(a),a.on("drawend",e=>((e,t,n,r,i)=>{n.setId(String(r)),n.setProperties(i),e.store.source.addFeature(n),e.emit(o.A.CREATE,e.store.toGeoJSON(n)),t?.(n)})(t,n.resolvePointSymbol,e.feature,r,i)),a.on("drawabort",()=>{t.emit(o.A.CANCEL)});const l=(({drawInteraction:e,options:t,canPlace:n})=>{const{container:r,addVertexButtonId:o,mapProvider:i,snap:s,crossHair:a}=t;let l=t.interfaceType??"mouse";const c=()=>l,d=()=>{const t=i.getCenter(),r=s?s.apply(t):t;s?.hideIndicator(),n(r)&&(e.appendCoordinates([r]),e.finishDrawing())},u=()=>{s&&s.apply(i.getCenter())},p=e=>{l=e,j(a,e),"mouse"!==e&&u()},h=H({container:r,addVertexButtonId:o,olView:e.getMap()?.getView(),onUndo:null,getInterfaceType:c,setInterfaceType:p,clearLastCoord:()=>{},updateRubberbanding:u,placeVertex:d});return j(a,l),a&&(a.activate=d),{getInterfaceType:c,setInterfaceType:p,destroy(){a?.activate===d&&(a.activate=null),h.destroy()}}})({drawInteraction:a,options:n,canPlace:s});return{done(){},cancel(){a.abortDrawing()},undo(){},setInterfaceType(e){l.setInterfaceType(e)},destroy(){t.emit(o.A.INTERFACE_TYPE_CHANGE,{interfaceType:l.getInterfaceType()}),l.destroy(),e.removeInteraction(a)}}})({map:this._map,manager:this,options:e})}else"edit_vertex"===e?this._modeInstance=me({map:this._map,manager:this,options:i}):"edit_point"===e&&(this._modeInstance=(({map:e,manager:t,options:n})=>{const{featureId:i,container:s,interfaceType:a,snap:l}=n,{store:c,undoStack:d}=t,u=c.getOL(i);if(!u)return null;s?.focus({preventScroll:!0});const p=u.getStyle();u.setStyle(()=>t.styles.selectedPointStyleFor(u));const h=(({manager:e,store:t,olFeature:n,interfaceType:r})=>{const i={olFeature:n,selectedVertexIndex:0,selectedVertexType:"vertex",vertices:[],midpoints:[],interfaceType:r??"mouse"},s={onUpdate:null},a=()=>{i.vertices=[n.getGeometry().getCoordinates()]},l=((e,t,n)=>(r,i)=>{r&&setTimeout(()=>{e.emit(o.A.GEOMETRY_CHANGE,{feature:t.toGeoJSON(n),phase:r,vertexIndex:i})},0)})(e,t,n),c=()=>a();return n.getGeometry().on("change",c),a(),e.emit(o.A.VERTEX_SELECTION,{index:0,numVertices:1}),{state:i,getState:()=>i,setState:e=>{const{selectedVertexIndex:t,selectedVertexType:n,...r}=e;Object.assign(i,r),void 0!==e.vertices&&s.onUpdate?.()},syncGeom:()=>{a(),e.emit(o.A.UPDATE,t.toGeoJSON(n))},emitGeometryValidation:l,setHooks:({onUpdate:e})=>{s.onUpdate=e},destroy(){n.getGeometry().un("change",c)}}})({manager:t,store:c,olFeature:u,interfaceType:a}),{getState:f,setState:g}=h,m=(({map:e,olFeature:t,getState:n,condition:r,snap:o,onModifyEnd:i})=>{let s=null,a=null;const l=t=>e.getCoordinateFromPixel(t.pixel),c=new Object(function(){var e=new Error("Cannot find module 'ol/interaction/Pointer.js'");throw e.code="MODULE_NOT_FOUND",e}())({handleDownEvent:e=>{if("touch"===n().interfaceType||!r(e))return!1;const o=t.getGeometry().getCoordinates(),i=l(e);return s=[o[0]-i[0],o[1]-i[1]],a=[...o],!0},handleDragEvent:e=>{if(!s)return;const n=l(e),r=[n[0]+s[0],n[1]+s[1]],i=o?o.apply(r):r;t.getGeometry().setCoordinates(i)},handleUpEvent:()=>(s=null,a&&i([a]),a=null,!1)});return e.addInteraction(c),{destroy(){e.removeInteraction(c)}}})({map:e,olFeature:u,getState:f,condition:_e({map:e,olFeature:u}),snap:l,onModifyEnd(e){h.syncGeom();const t=e&&ne(e,f().vertices);t&&(d.push(t),h.emitGeometryValidation(be,t.vertexIndex))}}),y=(({olFeature:e,undoStack:t,selection:n})=>()=>{const r=t.pop();r&&(((e,t)=>{"move_vertex"===t.type&&((e,t)=>{const{previousCoord:n}=t;e.getGeometry().setCoordinates([...n])})(e,t)})(e,r),n.syncGeom(),n.emitGeometryValidation(be,0))})({olFeature:u,undoStack:d,selection:h}),v=(({manager:e,olFeature:t})=>{const n=(0,r.e)({onChange:(t,n)=>{e.emit(o.A.VALIDITY_CHANGE,{valid:!t,reason:n})}}),i=()=>{const r=t.getGeometry().getCoordinates();n.update({feature:{type:"Feature",geometry:{type:"Point",coordinates:r}},context:{mode:"edit_point"},numVertices:1,onGeometryChange:e._geometryValidator})};return t.getGeometry().on("change",i),{liveStroke:n,destroy(){t.getGeometry().un("change",i),n.destroy()}}})({manager:t,olFeature:u}),b=(({map:e,container:t,manager:n,snap:r,undoStack:o,selection:i})=>{const{getState:s,setState:a,syncGeom:l,emitGeometryValidation:c}=i,d=ie({map:e,container:t,getState:s,setState:a,colors:n.colors,snap:r,moveCoord:ye,onVertexMoved({vertexIndex:e,previousCoord:t}){o.push({type:"move_vertex",vertexIndex:e,previousCoord:t}),l(),c(be,e)},onTap(){}});return i.setHooks({onUpdate(){s().interfaceType===ve&&d.updateTargetPosition()}}),d})({map:e,container:s,manager:t,snap:l,undoStack:d,selection:h}),_=(({map:e,container:t,snap:n,undoStack:r,selection:o,touchHandler:i,doUndo:s})=>{const{getState:a,setState:l,syncGeom:c,emitGeometryValidation:d}=o;return le({map:e,getState:a,setState:l,snap:n,moveCoord:ye,onVertexMoved({vertexIndex:e,previousCoord:t}){r.push({type:"move_vertex",vertexIndex:e,previousCoord:t}),c(),d(be,e)},onInserted(){},onDeleted(){},onUndo:s,onKeyboardActive(){"keyboard"!==a().interfaceType&&(a().interfaceType="keyboard",i.hide(),t.focus({preventScroll:!0}))}})})({map:e,container:s,snap:l,undoStack:d,selection:h,touchHandler:b,doUndo:y}),E=(({map:e,manager:t,selection:n,touchHandler:r,live:o})=>{const{state:i}=n,s=()=>{o.liveStroke.refresh(),r.updateColors(t.colors)};t.on($,s);const a=()=>{i.interfaceType===ve&&e.once("postrender",()=>r.updateTargetPosition())};return e.on("change:size",a),{destroy(){t.off($,s),e.un("change:size",a)}}})({map:e,manager:t,selection:h,touchHandler:b,live:v});return{setInterfaceType(e){e!==f().interfaceType&&(g({interfaceType:e}),e===ve?b.updateTargetPosition():b.hide())},done(){t.emit(o.A.EDIT_FINISH,c.toGeoJSON(u))},setInvalid(e){v.liveStroke.set(e)},cancel(){},undo:y,deleteVertex(){},nudgeSelectedVertex:_.nudgeByDelta,destroy(){v.destroy(),u.setStyle(p),h.destroy(),E.destroy(),m.destroy(),b.destroy(),_.destroy()}}})({map:this._map,manager:this,options:i}));this.snap?.reattach()}getMode(){return this._mode}done(){this._modeInstance?.done()}cancel(){this._modeInstance?.cancel(),this.changeMode("disabled")}undo(){this._modeInstance?.undo()}deleteVertex(){this._modeInstance?.deleteVertex()}nudgeSelectedVertex(e,t,n){this._modeInstance?.nudgeSelectedVertex?.(e,t,n)}getVertexItems(){return this._modeInstance?.getVertexItems?.()??{vertices:[],midpoints:[]}}selectVertex(e){this._modeInstance?.selectVertex?.(e)}insertVertexAtMidpoint(e){this._modeInstance?.insertVertexAtMidpoint?.(e)}setInvalid(e){this._modeInstance?.setInvalid?.(e)}setDrawingPreviewProperty(e,t){this._modeInstance?.setDrawingPreviewProperty?.(e,t)}setInterfaceType(e){this._modeInstance?.setInterfaceType?.(e),this.emit(o.A.INTERFACE_TYPE_CHANGE,{interfaceType:e})}updatePointSymbol(e){Se({manager:this,mapProvider:this.mapProvider,olFeature:e}).catch(t=>o.t.error("[draw] failed to resolve point symbol",e.getId(),t))}get(e){return this.store.get(e)}add(e){return this.store.add(e)}delete(e){return this.store.remove(e)}deleteAll(){return this.store.clear()}remove(){this._modeInstance?.destroy(),this._modeInstance=null,this.snap?.destroy(),this.snap=null,this.store.clear(),this._map.removeLayer(this._layer),this._listeners.clear()}}class Ie{_snapEnabled=!1;constructor(e,t){const{manager:n,remove:r}=(({mapProvider:e,symbolRegistry:t,events:n,eventBus:r,pluginConfig:i={},mapStyle:s=null})=>{const{map:a}=e,l=new xe(a,i,{mapProvider:e,symbolRegistry:t});s&&l.setMapStyle(s),e.draw=l;const c=()=>r.emit(n.MAP_DATA_CHANGE),d=t=>{(({manager:e,mapProvider:t,pixelRatioOverride:n})=>{e.pointSymbolRefreshId=(e.pointSymbolRefreshId??0)+1;const r=e.pointSymbolRefreshId,i=e.store.source.getFeatures().filter(e=>"Point"===e.getGeometry()?.getType()&&(0,o.s)(e.getProperties()));return Promise.all(i.map(o=>Se({manager:e,mapProvider:t,olFeature:o,pixelRatioOverride:n,refreshId:r})))})({manager:l,mapProvider:e,pixelRatioOverride:t}).then(c).catch(e=>o.t.error("[draw] failed to refresh point symbols",e))},u=e=>{d(e)};r.on(n.MAP_SET_PIXEL_RATIO,u);const p=e=>{l.setMapStyle(e),d()};return r.on(n.MAP_SET_STYLE,p),{manager:l,remove(){r.off(n.MAP_SET_PIXEL_RATIO,u),r.off(n.MAP_SET_STYLE,p),l.remove(),e.draw=null}}})({mapProvider:e,symbolRegistry:t.symbolRegistry,events:t.events,eventBus:t.eventBus,pluginConfig:t.pluginConfig??{snapLayers:t.snapLayers},mapStyle:t.mapStyle});this._cleanupOLDraw=r,this._manager=n,this._mapProvider=e}changeMode(e,t={}){const n={...t,mapProvider:this._mapProvider};return"draw_polygon"===e&&(n.geometryType="Polygon"),"draw_line"===e&&(n.geometryType="LineString"),this._manager.changeMode(e,n)}getMode(){return this._manager.getMode()}setInterfaceType(e){this._manager.setInterfaceType(e)}done(){this._manager.undoStack.clear(),this._manager.done()}cancel(){this._manager.undoStack.clear(),this._manager.cancel()}undo(){this._manager.undo()}deleteVertex(){this._manager.deleteVertex()}nudgeSelectedVertex(e,t,n){this._manager.nudgeSelectedVertex(e,t,n)}getVertexItems(){return this._manager.getVertexItems()}selectVertex(e){this._manager.selectVertex(e)}insertVertexAtMidpoint(e){this._manager.insertVertexAtMidpoint(e)}setGeometryValid(e){this._manager._geometryValid=e}set _geometryValidator(e){this._manager._geometryValidator=e}get _geometryValidator(){return this._manager._geometryValidator}setInvalid(e){this._manager.setInvalid(e)}get(e){return this._manager.get(e)}add(e){const t=this._manager.add(e);return"Point"===e.geometry?.type&&(0,o.s)(e.properties)&&this._manager.updatePointSymbol(t),t}setStyle(e,t){const n=this._manager.store.getOL(e);n&&(n.setProperties(t),"Point"===n.getGeometry()?.getType()&&(0,o.s)(n.getProperties())&&this._manager.updatePointSymbol(n))}delete(e){return this._manager.delete(e)}deleteAll(){return this._manager.deleteAll()}setSnapEnabled(e){this._snapEnabled=e,this._manager.snap?.setActive(e)}setSnapLayers(e){const t=e?.map(e=>"stroke-inactive.cold"===e?this._manager._layer:e);this._manager.snap?.setSnapLayers(t)}isSnapEnabled(){return this._snapEnabled}setFeatureProperty(){}setDrawingPreviewProperty(e,t){this._manager.setDrawingPreviewProperty(e,t)}on(e,t){this._manager.on(e,t)}off(e,t){this._manager.off(e,t)}remove(){this._cleanupOLDraw()}}},666:(e,t,n)=>{n.d(t,{A:()=>a,C:()=>re,H:()=>Y,K:()=>se,L:()=>$,M:()=>L,S:()=>oe,T:()=>ie,a:()=>q,b:()=>_n,c:()=>E,d:()=>bn,e:()=>b,f:()=>v,g:()=>p,h:()=>h,i:()=>_,j:()=>w,k:()=>f,l:()=>y,m:()=>g,n:()=>d,o:()=>S,p:()=>u,q:()=>x,r:()=>m,s:()=>me,t:()=>ge,u:()=>Z,v:()=>W,w:()=>J,x:()=>X,y:()=>K,z:()=>An});var r=n(452);n(247);const o=new Set(["draw_polygon","draw_line"]),i={SET_MODE:(e,t)=>({...e,mode:t,numVertices:o.has(t)?0:e.numVertices,geometryValid:!1,canAddPoint:!0}),SET_ACTION:(e,t)=>({...e,action:t.name,actionValid:t.isValid}),SET_FEATURE:(e,t)=>({...e,feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature}),SET_SELECTED_VERTEX_INDEX:(e,t)=>({...e,selectedVertexIndex:t.index,numVertices:t.numVertices}),TOGGLE_SNAP:e=>({...e,snap:!e.snap}),SET_HAS_SNAP_LAYERS:(e,t)=>({...e,hasSnapLayers:!!t}),SET_UNDO_STACK_LENGTH:(e,t)=>({...e,undoStackLength:t}),SET_GEOMETRY_VALID:(e,t)=>({...e,geometryValid:!!t}),SET_CAN_ADD_POINT:(e,t)=>({...e,canAddPoint:!!t})},s={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",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_SET_APPLICATION_MODE:"app:setapplicationmode",APP_CLEAR_APPLICATION_MODE:"app:clearapplicationmode",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_SPATIAL_LIST:"map:setspatiallist",MAP_SET_SPATIAL_LIST_SUPPRESSED:"map:setspatiallistsuppressed",MAP_SET_ACTIVE_ITEM:"map:setactiveitem",MAP_SELECT_ITEM:"map:selectitem",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"},a={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"};var l=6371008.8,c={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*l,kilometers:6371.0088,kilometres:6371.0088,meters:l,metres:l,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:l/1852,radians:1,yards:6967335.223679999};function d(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 u(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(!_(e[0])||!_(e[1]))throw new Error("coordinates must contain numbers");return d({type:"Point",coordinates:e},t,n)}function p(e,t,n={}){for(const r of e){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<r[r.length-1].length;e++)if(r[r.length-1][e]!==r[0][e])throw new Error("First and last Position are not equivalent.")}return d({type:"Polygon",coordinates:e},t,n)}function h(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return d({type:"LineString",coordinates:e},t,n)}function f(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function g(e,t,n={}){return d({type:"MultiLineString",coordinates:e},t,n)}function m(e,t="kilometers"){const n=c[t];if(!n)throw new Error(t+" units is invalid");return e*n}function y(e,t="kilometers"){const n=c[t];if(!n)throw new Error(t+" units is invalid");return e/n}function v(e){return e%(2*Math.PI)*180/Math.PI}function b(e){return e%360*Math.PI/180}function _(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function E(e,t,n){if(null!==e)for(var r,o,i,s,a,l,c,d,u=0,p=0,h=e.type,f="FeatureCollection"===h,g="Feature"===h,m=f?e.features.length:1,y=0;y<m;y++){a=(d=!!(c=f?e.features[y].geometry:g?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v<a;v++){var b=0,_=0;if(null!==(s=d?c.geometries[v]:c)){l=s.coordinates;var S=s.type;switch(u=0,S){case null:break;case"Point":if(!1===t(l,p,y,b,_))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===t(l[r],p,y,b,_))return!1;p++,"MultiPoint"===S&&b++}"LineString"===S&&b++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(o=0;o<l[r].length-u;o++){if(!1===t(l[r][o],p,y,b,_))return!1;p++}"MultiLineString"===S&&b++,"Polygon"===S&&_++}"Polygon"===S&&b++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(_=0,o=0;o<l[r].length;o++){for(i=0;i<l[r][o].length-u;i++){if(!1===t(l[r][o][i],p,y,b,_))return!1;p++}_++}b++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(!1===E(s.geometries[r],t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function S(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 x(e){var t=[];return E(e,function(e){t.push(e)}),t}function I(e,t){var n,r,o,i,s,a,l,c,d,u,p=0,h="FeatureCollection"===e.type,f="Feature"===e.type,g=h?e.features.length:1;for(n=0;n<g;n++){for(a=h?e.features[n].geometry:f?e.geometry:e,c=h?e.features[n].properties:f?e.properties:{},d=h?e.features[n].bbox:f?e.bbox:void 0,u=h?e.features[n].id:f?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,o=0;o<s;o++)if(null!==(i=l?a.geometries[o]:a))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,d,u))return!1;break;case"GeometryCollection":for(r=0;r<i.geometries.length;r++)if(!1===t(i.geometries[r],p,c,d,u))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,d,u))return!1;p++}}function w(e,t){I(e,function(e,n,r,o,i){var s,a=null===e?null:e.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==t(d(e,r,{bbox:o,id:i}),n,0)&&void 0}switch(a){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var l=0;l<e.coordinates.length;l++){var c=e.coordinates[l];if(!1===t(d({type:s,coordinates:c},r),n,l))return!1}})}function P(e){let t=0;if(e&&e.length>0){t+=Math.abs(M(e[0]));for(let n=1;n<e.length;n++)t-=Math.abs(M(e[n]))}return t}var C=20294876564838.72,T=Math.PI/180;function M(e){const t=e.length-1;if(t<=2)return 0;let n=0,r=0;for(;r<t;){const o=e[r],i=e[r+1===t?0:r+1],s=e[r+2>=t?(r+2)%t:r+2],a=o[0]*T,l=i[1]*T;n+=(s[0]*T-a)*Math.sin(l),r++}return n*C}const L={Polygon:3,LineString:2},A=e=>e?.geometry??e,O=e=>{const t=A(e);return"Polygon"===t?.type?t:null},k=e=>{const t=e.coordinates?.[0]??[],n=t.filter((e,n)=>0===n||e[0]!==t[n-1][0]||e[1]!==t[n-1][1]);for(;n.length>1&&n[0][0]===n[n.length-1][0]&&n[0][1]===n[n.length-1][1];)n.pop();return n},D=e=>[...e,e[0]],R=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]),N=(e,t)=>e>0&&t<0||e<0&&t>0,F=(e,t,n,r)=>0===e&&((e,t,n)=>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=(e,t,n,r)=>{const o=R(n,r,e),i=R(n,r,t),s=R(e,t,n),a=R(e,t,r);return!(!N(o,i)||!N(s,a))||F(o,n,e,r)||F(i,n,t,r)||F(s,e,n,t)||F(a,e,r,t)},B=(e,t)=>{const n=e.length,r=t?n:n-1;for(let o=0;o<r;o++)for(let i=o+1;i<r;i++)if(!(i===o+1||t&&0===o&&i===r-1)&&V(e[o],e[(o+1)%n],e[i],e[(i+1)%n]))return!0;return!1},U=e=>{const t=O(e);if(!t)return{valid:!0};const n=k(t);return n.length<4?{valid:!0}:B(n,!0)?{valid:!1,reason:"Shape must not intersect itself"}:{valid:!0}},G=e=>{const t=O(e);if(!t)return{valid:!0};const n=k(t);if(n.length<L.Polygon)return{valid:!0};let r=0;try{r=function(e){return function(e){var t=0;return I(e,function(e,n,r,o,i){t=((e,t)=>e+function(e){let t,n=0;switch(e.type){case"Polygon":return P(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)n+=P(e.coordinates[t]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(t))(t,e)}),t}(e)}({type:"Feature",geometry:{type:"Polygon",coordinates:[D(n)]},properties:{}})}catch{return{valid:!0}}return r>0?{valid:!0}:{valid:!1,reason:"Shape must enclose an area"}},j={Polygon:"Shape needs at least 3 points",LineString:"Line needs at least 2 points"},H=[U,G,e=>{const t=A(e);return"Polygon"===t?.type?k(t).length>=L.Polygon?{valid:!0}:{valid:!1,reason:j.Polygon}:"LineString"===t?.type?(t.coordinates?.length??0)>=L.LineString?{valid:!0}:{valid:!1,reason:j.LineString}:{valid:!0}}],$=[U,G],Y=[e=>(e=>{const t=O(e);if(!t)return!1;const n=k(t);return!(n.length<4)&&B(n,!1)})(e)?{valid:!1,reason:"Shape must not intersect itself"}:{valid:!0}],z=e=>void 0===e||!0===e?{valid:!0}:!1===e?{valid:!1,reason:null}:{valid:!1!==e.valid,reason:e.reason},K=(e,t={},n={})=>{const{rules:r=H,onGeometryChange:o}=n;for(const i of r){const n=z(i(e,t));if(!n.valid)return n}return"function"==typeof o?z(o({feature:e,...t})):{valid:!0}},W=(e,t={},n={})=>{const{rules:r=Y,onGeometryChange:o}=n;return K(e,{...t,phase:"place"},{rules:r,onGeometryChange:o})},J={Polygon:"draw_polygon",LineString:"draw_line"},q=({placed:e,point:t,geometryType:n,onGeometryChange:r})=>{const o=[...e,t],i={type:"Feature",geometry:"Polygon"===n?{type:"Polygon",coordinates:[o]}:{type:"LineString",coordinates:o},properties:{}},s=J[n],{valid:a,reason:l}=W(i,{mode:s,vertexIndex:e.length},{onGeometryChange:r});return a?{valid:!0}:{valid:!1,blocked:{feature:i,reason:l??null,phase:"place",mode:s,vertexIndex:e.length}}},X=(e,t={},n={})=>{const{rules:r=$,onGeometryChange:o}=n,i=L[e?.geometry?.type??e?.type]??0,s=(t.numVertices??0)<i?[]:r;return K(e,{...t,phase:t.phase??"preview"},{rules:s,onGeometryChange:o})},Z={small:1,medium:1.5,large:2},Q="rgba(29,112,184,1)",ee="#ffffff",te="rgba(11,12,12,1)",ne="rgba(212,53,28,0.5)",re={editStroke:{light:Q,dark:ee},editFill:{light:"rgba(29,112,184,0.1)",dark:"rgba(255,255,255,0.1)"},editVertex:{light:Q,dark:ee},editMidpoint:{light:Q,dark:ee},editHalo:{light:ee,dark:te},editActive:{light:te,dark:ee},splitInvalid:{light:Q,dark:ee},splitValid:{light:Q,dark:ee},invalidStroke:{light:Q,dark:ee},shapeStroke:"rgba(212,53,28,1)",shapeFill:ne,snapVertex:ne,snapMidpoint:"rgba(40,161,151,1)",snapEdge:"rgba(29,112,184,0.5)"},oe={strokeWidth:2,vertexRadius:6,midpointRadius:4,vertexHaloRadius:8,midpointHaloRadius:6,touchTargetSize:48},ie={snapRadius:12},se={nudgeAmount:1,stepAmount:5},ae="draw",le=new Set(["symbol","symbolSvgContent","symbolViewBox","symbolAnchor","symbolSize","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),ce=e=>{if(!e?.properties)return e;const t={};for(const[n,r]of Object.entries(e.properties))"sortKey"===n||n.startsWith("symbol")&&!le.has(n)||(t[n]=r);return{...e,properties:t}},de="edit_vertex",ue=new Set([de,"edit_point"]),pe=({draw:e,pluginState:t,mapProvider:n,eventBus:r})=>({onVertexSelection:o=>{t.dispatch({type:"SET_SELECTED_VERTEX_INDEX",payload:o}),n.activeMoveTarget=o.index>=0?(e=>({move:(t,n,r)=>e.nudgeSelectedVertex(t,n,r),label:"vertex"}))(e):null,r.emit("draw:vertexselection",o)},onVertexChange:e=>{t.dispatch({type:"SET_SELECTED_VERTEX_INDEX",payload:{index:-1,numVertices:e.numVertices}}),n.activeMoveTarget=null}});function he({appState:e,appConfig:t,mapState:n,pluginState:r,mapProvider:o,buttonConfig:i,eventBus:s,hints:l}){const{draw:c}=o,d=function({appState:e,appConfig:t,mapState:n,pluginState:r,mapProvider:o,eventBus:i,hints:s,resetState:a}){const{draw:l}=o,c=((e,t)=>n=>{var r;e.emit("draw:geometryinvalid",n),n.reason&&(r=n.reason,!Object.values(j).includes(r))&&t.show(n.reason)})(i,s),{feature:d,tempFeature:u}=r,{dispatch:p}=r;let h=null;return{handleDone:()=>{l.done()},handleCancel:()=>{const e=l.getMode();ue.has(e)&&u?.id&&l.add(d),h=null,l.cancel(),a(),i.emit("draw:cancelled",ce(d))},handleUndo:()=>l.undo(),handleDeleteVertex:()=>l.deleteVertex(),handleSnap:()=>{r.dispatch({type:"TOGGLE_SNAP"}),l.setSnapEnabled(!r.snap)},onCreate:r=>{const{valid:o,reason:s}=K(r,{phase:"create",mode:l.getMode()},{onGeometryChange:l._geometryValidator});if(!o)return h=r.id,c({feature:ce(r),reason:s,phase:"create",mode:de}),void setTimeout(()=>(({draw:e,appState:t,appConfig:n,mapState:r,dispatch:o},i)=>{e.changeMode(de,{container:t?.layoutRefs?.viewportRef?.current,deleteVertexButtonId:`${n?.id}-draw-delete-point`,undoButtonId:`${n?.id}-draw-undo`,isPanEnabled:"keyboard"!==t?.interfaceType,interfaceType:t?.interfaceType,scale:Z[r?.mapSize],featureId:i,getSnapEnabled:()=>e.isSnapEnabled()});const s=e.get(i);o({type:"SET_FEATURE",payload:{feature:s,tempFeature:s}}),o({type:"SET_MODE",payload:de}),o({type:"SET_GEOMETRY_VALID",payload:!1}),e.setGeometryValid?.(!1),e.setInvalid?.(!0)})({draw:l,appState:e,appConfig:t,mapState:n,dispatch:p},r.id),0);a(),setTimeout(()=>l.changeMode("disabled"),0),i.emit("draw:created",ce(r))},onEditFinish:e=>{a(),setTimeout(()=>l.changeMode("disabled"),0),h&&e.id===h?(h=null,i.emit("draw:created",ce(e))):i.emit("draw:edited",ce(e))},onCancel:()=>{},...pe({draw:l,pluginState:r,mapProvider:o,eventBus:i}),onUndoChange:e=>{r.dispatch({type:"SET_UNDO_STACK_LENGTH",payload:e})},onUpdate:e=>{i.emit("draw:updated",ce(e))},onGeometryChange:e=>{if(!e?.phase)return;const t=l.getMode(),n={phase:e.phase,vertexIndex:e.vertexIndex,mode:t},{valid:o,reason:i}=K(e.feature,n,{onGeometryChange:l._geometryValidator});r.dispatch({type:"SET_GEOMETRY_VALID",payload:o}),l.setGeometryValid?.(o),ue.has(t)&&l.setInvalid?.(!o),o||c({reason:i,...n,feature:ce(e.feature)})},onPlacementBlocked:e=>{c({...e,feature:ce(e.feature)})},onValidityChange:e=>{r.dispatch({type:"SET_GEOMETRY_VALID",payload:e.valid}),l.setGeometryValid?.(e.valid)},onCanPlaceChange:e=>{r.dispatch({type:"SET_CAN_ADD_POINT",payload:e.canPlace})},onInterfaceTypeChange:e=>{i.emit("draw:interfacetypechange",{interfaceType:e.interfaceType})}}}({appState:e,appConfig:t,mapState:n,pluginState:r,mapProvider:o,eventBus:s,hints:l,resetState:()=>{r.dispatch({type:"SET_MODE",payload:null}),r.dispatch({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),o.activeMoveTarget=null}});return function(e,t){const{drawDone:n,drawCancel:r,drawUndo:o,drawDeletePoint:i,drawSnap:s}=e;n.onClick=t.handleDone,r.onClick=t.handleCancel,o.onClick=t.handleUndo,i&&(i.onClick=t.handleDeleteVertex),s&&(s.onClick=t.handleSnap)}(i,d),function(e,t){e.on(a.CREATE,t.onCreate),e.on(a.EDIT_FINISH,t.onEditFinish),e.on(a.CANCEL,t.onCancel),e.on(a.VERTEX_SELECTION,t.onVertexSelection),e.on(a.VERTEX_CHANGE,t.onVertexChange),e.on(a.UNDO_CHANGE,t.onUndoChange),e.on(a.UPDATE,t.onUpdate),e.on(a.GEOMETRY_CHANGE,t.onGeometryChange),e.on(a.PLACEMENT_BLOCKED,t.onPlacementBlocked),e.on(a.VALIDITY_CHANGE,t.onValidityChange),e.on(a.CAN_PLACE_CHANGE,t.onCanPlaceChange),e.on(a.INTERFACE_TYPE_CHANGE,t.onInterfaceTypeChange)}(c,d),()=>{!function(e){const{drawDone:t,drawCancel:n,drawUndo:r,drawDeletePoint:o,drawSnap:i}=e;t.onClick=null,n.onClick=null,r.onClick=null,o&&(o.onClick=null),i&&(i.onClick=null)}(i),function(e,t){e.off(a.CREATE,t.onCreate),e.off(a.EDIT_FINISH,t.onEditFinish),e.off(a.CANCEL,t.onCancel),e.off(a.VERTEX_SELECTION,t.onVertexSelection),e.off(a.VERTEX_CHANGE,t.onVertexChange),e.off(a.UNDO_CHANGE,t.onUndoChange),e.off(a.UPDATE,t.onUpdate),e.off(a.GEOMETRY_CHANGE,t.onGeometryChange),e.off(a.PLACEMENT_BLOCKED,t.onPlacementBlocked),e.off(a.VALIDITY_CHANGE,t.onValidityChange),e.off(a.CAN_PLACE_CHANGE,t.onCanPlaceChange),e.off(a.INTERFACE_TYPE_CHANGE,t.onInterfaceTypeChange)}(c,d)}}const fe="[interactive-map]",ge={warn:(...e)=>console.warn(fe,...e),error:(...e)=>console.error(fe,...e)},me=e=>!(!e?.symbol&&!e?.symbolSvgContent),ye="edit_vertex",ve="draw",be=(e,t,n)=>{const{x:r,y:o}=e.mapToScreen(n);return{x:r*Z[t],y:o*Z[t]}};function _e({mapState:e,pluginState:t,services:n,mapProvider:o,spatialListRegistry:i,viewportRef:l}){const{mapSize:c}=e,{eventBus:d,announce:u}=n,p=(0,r.li)([]),h=(0,r.li)(null);!function({pluginState:e,mapProvider:t,mapSize:n,spatialListRegistry:o,itemsRef:i,eventBus:l}){(0,r.vJ)(()=>{const r=()=>{i.current=e.mode===ye?((e,t)=>{const{vertices:n,midpoints:r}=e.draw?.getVertexItems?.()??{vertices:[],midpoints:[]},o=[];return n.forEach((i,s)=>{o.push(((n,r)=>({id:String(r),label:`Point ${r+1}`,isMidpoint:!1,...be(e,t,n)}))(i,s)),s<r.length&&o.push(((r,o)=>({id:String(n.length+o),label:`Insert ${o+1}-${(o+1)%n.length+1}`,isMidpoint:!0,...be(e,t,r)}))(r[s],s))}),o})(t,n):[],o.notifyItemsChanged(ve)};r(),l.on(s.MAP_MOVE_END,r);const{draw:c}=t;return c?(c.on(a.UPDATE,r),()=>{l.off(s.MAP_MOVE_END,r),c.off(a.UPDATE,r)}):()=>l.off(s.MAP_MOVE_END,r)},[e.mode,t,n,o,i,l]),(0,r.vJ)(()=>(o.registerItemProvider(ve,{getItems:()=>({items:i.current,multiselectable:!1,label:"Shape points",focusable:!1}),exclusive:!0}),()=>{o.unregisterItemProvider(ve)}),[o,i]),(0,r.vJ)(()=>{if(e.mode===ye)return o.claimExclusive(ve),()=>o.releaseExclusive(ve)},[e.mode,o])}({pluginState:t,mapProvider:o,mapSize:c,spatialListRegistry:i,itemsRef:p,eventBus:d}),function({eventBus:e,mapProvider:t,pluginState:n,activeIdRef:o}){(0,r.vJ)(()=>{const r=({id:e})=>{o.current=e,null!==e&&n.mode===ye&&t.draw?.selectVertex?.(Number(e))};return e.on(s.MAP_SET_ACTIVE_ITEM,r),()=>{e.off(s.MAP_SET_ACTIVE_ITEM,r)}},[e,t,n.mode,o])}({eventBus:d,mapProvider:o,pluginState:t,activeIdRef:h}),function({eventBus:e,mapProvider:t,pluginState:n,activeIdRef:o,itemsRef:i,viewportRef:a,announce:l}){(0,r.vJ)(()=>{const r=()=>{if(n.mode!==ye||null===o.current)return;const e=i.current.find(e=>e.id===o.current);e&&(e.isMidpoint?(t.draw?.insertVertexAtMidpoint?.(Number(o.current)),l("New point inserted","action")):l(`${e.label} selected`,"action"),a.current?.focus())};return e.on(s.MAP_SELECT_ITEM,r),()=>{e.off(s.MAP_SELECT_ITEM,r)}},[e,t,n.mode,o,i,a,l])}({eventBus:d,mapProvider:o,pluginState:t,activeIdRef:h,itemsRef:p,viewportRef:l,announce:u})}const Ee=new Set(["draw_polygon","draw_line","draw_point"]),Se=e=>Ee.has(e),xe=({appState:e,pluginState:t})=>Se(t.mode)&&("touch"===e.interfaceType||!!e.expandedButtons?.has("mapControls")),Ie=new Set(["stroke","fill","strokeWidth"]),we=e=>{if(!e)return{};const t={};for(const[n,r]of Object.entries(e))if(Ie.has(n)&&"object"==typeof r&&null!==r){const e=Object.entries(r);e.length>0&&(t[n]=e[0][1]);for(const[r,o]of e)t[`${n}${r.charAt(0).toUpperCase()+r.slice(1)}`]=o}else t[n]=r;return t},Pe=e=>({appState:t,appConfig:n,pluginConfig:r,pluginState:o,mapState:i,mapProvider:s,services:a},l,c={})=>{const{dispatch:d}=o,{draw:u}=s,{eventBus:p}=a;if(!u)return;p.emit("draw:started",{mode:e});const h=void 0===c.snapLayers?r.snapLayers??null:c.snapLayers;u.setSnapLayers(h),d({type:"SET_HAS_SNAP_LAYERS",payload:h?.length>0});const{stroke:f,fill:g,strokeWidth:m,properties:y,onGeometryChange:v,...b}=c;u._geometryValidator=v??r.onGeometryChange;const _={...y,...we({stroke:f,fill:g,strokeWidth:m})};u.changeMode(e,{container:t.layoutRefs.viewportRef.current,addVertexButtonId:`${n.id}-draw-add-point`,interfaceType:t.interfaceType,crossHair:i.crossHair,getSnapEnabled:()=>u.isSnapEnabled(),featureId:l,...b,properties:_}),d({type:"SET_MODE",payload:e})},Ce=Pe("draw_polygon"),Te=Pe("draw_line"),Me=new Set(["Point","LineString","Polygon"]),Le=new Set(["stroke","fill","strokeWidth"]);function Ae(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=Oe(e.properties),t.geometry=ke(e.geometry),t}function Oe(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]=Oe(r):t[n]=r}),t):t}function ke(e){var t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(function(e){return ke(e)}),t):(t.coordinates=De(e.coordinates),t)}function De(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map(function(e){return De(e)})}function Re(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),o=0,i=1;i<r.length;)t=n||r[0],o+=((n=r[i])[0]-t[0])*(n[1]+t[1]),i++;return o>0}function Ne(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 Fe(e,t){if(null===(n=t=t||{})||"object"!=typeof n||Array.isArray(n))throw new Error("options is invalid");var n,r=t.reverse||!1,o=t.mutate||!1;if(!e)throw new Error("<geojson> is required");if("boolean"!=typeof r)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof o)throw new Error("<mutate> must be a boolean");!1===o&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Ae(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 Ae(e)}),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return ke(e);default:throw new Error("unknown GeoJSON type")}}(e));var i=[];switch(e.type){case"GeometryCollection":return I(e,function(e){Ve(e,r)}),e;case"FeatureCollection":return S(e,function(e){S(Ve(e,r),function(e){i.push(e)})}),f(i)}return Ve(e,r)}function Ve(e,t){switch("Feature"===e.type?e.geometry.type:e.type){case"GeometryCollection":return I(e,function(e){Ve(e,t)}),e;case"LineString":return Be(Ne(e),t),e;case"Polygon":return Ue(Ne(e),t),e;case"MultiLineString":return Ne(e).forEach(function(e){Be(e,t)}),e;case"MultiPolygon":return Ne(e).forEach(function(e){Ue(e,t)}),e;case"Point":case"MultiPoint":return e}}function Be(e,t){Re(e)===t&&e.reverse()}function Ue(e,t){Re(e[0])!==t&&e[0].reverse();for(var n=1;n<e.length;n++)Re(e[n])===t&&e[n].reverse()}const Ge=11102230246251565e-32,je=134217729,He=(3+8*Ge)*Ge;function $e(e,t,n,r,o){let i,s,a,l,c=t[0],d=r[0],u=0,p=0;d>c==d>-c?(i=c,c=t[++u]):(i=d,d=r[++p]);let h=0;if(u<e&&p<n)for(d>c==d>-c?(s=c+i,a=i-(s-c),c=t[++u]):(s=d+i,a=i-(s-d),d=r[++p]),i=s,0!==a&&(o[h++]=a);u<e&&p<n;)d>c==d>-c?(s=i+c,l=s-i,a=i-(s-l)+(c-l),c=t[++u]):(s=i+d,l=s-i,a=i-(s-l)+(d-l),d=r[++p]),i=s,0!==a&&(o[h++]=a);for(;u<e;)s=i+c,l=s-i,a=i-(s-l)+(c-l),c=t[++u],i=s,0!==a&&(o[h++]=a);for(;p<n;)s=i+d,l=s-i,a=i-(s-l)+(d-l),d=r[++p],i=s,0!==a&&(o[h++]=a);return 0===i&&0!==h||(o[h++]=i),h}function Ye(e){return new Float64Array(e)}const ze=Ye(4),Ke=Ye(8),We=Ye(12),Je=Ye(16),qe=Ye(4);function Xe(e,t,n,r,o,i){const s=(t-i)*(n-o),a=(e-o)*(r-i),l=s-a,c=Math.abs(s+a);return Math.abs(l)>=33306690738754716e-32*c?l:-function(e,t,n,r,o,i,s){let a,l,c,d,u,p,h,f,g,m,y,v,b,_,E,S,x,I;const w=e-o,P=n-o,C=t-i,T=r-i;_=w*T,p=je*w,h=p-(p-w),f=w-h,p=je*T,g=p-(p-T),m=T-g,E=f*m-(_-h*g-f*g-h*m),S=C*P,p=je*C,h=p-(p-C),f=C-h,p=je*P,g=p-(p-P),m=P-g,x=f*m-(S-h*g-f*g-h*m),y=E-x,u=E-y,ze[0]=E-(y+u)+(u-x),v=_+y,u=v-_,b=_-(v-u)+(y-u),y=b-S,u=b-y,ze[1]=b-(y+u)+(u-S),I=v+y,u=I-v,ze[2]=v-(I-u)+(y-u),ze[3]=I;let M=function(e,t){let n=t[0];for(let r=1;r<4;r++)n+=t[r];return n}(0,ze),L=22204460492503146e-32*s;if(M>=L||-M>=L)return M;if(u=e-w,a=e-(w+u)+(u-o),u=n-P,c=n-(P+u)+(u-o),u=t-C,l=t-(C+u)+(u-i),u=r-T,d=r-(T+u)+(u-i),0===a&&0===l&&0===c&&0===d)return M;if(L=11093356479670487e-47*s+He*Math.abs(M),M+=w*d+T*a-(C*c+P*l),M>=L||-M>=L)return M;_=a*T,p=je*a,h=p-(p-a),f=a-h,p=je*T,g=p-(p-T),m=T-g,E=f*m-(_-h*g-f*g-h*m),S=l*P,p=je*l,h=p-(p-l),f=l-h,p=je*P,g=p-(p-P),m=P-g,x=f*m-(S-h*g-f*g-h*m),y=E-x,u=E-y,qe[0]=E-(y+u)+(u-x),v=_+y,u=v-_,b=_-(v-u)+(y-u),y=b-S,u=b-y,qe[1]=b-(y+u)+(u-S),I=v+y,u=I-v,qe[2]=v-(I-u)+(y-u),qe[3]=I;const A=$e(4,ze,4,qe,Ke);_=w*d,p=je*w,h=p-(p-w),f=w-h,p=je*d,g=p-(p-d),m=d-g,E=f*m-(_-h*g-f*g-h*m),S=C*c,p=je*C,h=p-(p-C),f=C-h,p=je*c,g=p-(p-c),m=c-g,x=f*m-(S-h*g-f*g-h*m),y=E-x,u=E-y,qe[0]=E-(y+u)+(u-x),v=_+y,u=v-_,b=_-(v-u)+(y-u),y=b-S,u=b-y,qe[1]=b-(y+u)+(u-S),I=v+y,u=I-v,qe[2]=v-(I-u)+(y-u),qe[3]=I;const O=$e(A,Ke,4,qe,We);_=a*d,p=je*a,h=p-(p-a),f=a-h,p=je*d,g=p-(p-d),m=d-g,E=f*m-(_-h*g-f*g-h*m),S=l*c,p=je*l,h=p-(p-l),f=l-h,p=je*c,g=p-(p-c),m=c-g,x=f*m-(S-h*g-f*g-h*m),y=E-x,u=E-y,qe[0]=E-(y+u)+(u-x),v=_+y,u=v-_,b=_-(v-u)+(y-u),y=b-S,u=b-y,qe[1]=b-(y+u)+(u-S),I=v+y,u=I-v,qe[2]=v-(I-u)+(y-u),qe[3]=I;const k=$e(O,We,4,qe,Je);return Je[k-1]}(e,t,n,r,o,i,c)}function Ze(e,t){var n,r,o,i,s,a,l,c,d,u=0,p=e[0],h=e[1],f=t.length;for(n=0;n<f;n++){r=0;var g=t[n],m=g.length-1;if((c=g[0])[0]!==g[m][0]&&c[1]!==g[m][1])throw new Error("First and last coordinates in a ring must be the same");for(i=c[0]-p,s=c[1]-h;r<m;r++){if(a=(d=g[r+1])[0]-p,l=d[1]-h,0===s&&0===l){if(a<=0&&i>=0||i<=0&&a>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(0===(o=Xe(i,a,s,l,0,0)))return 0;(o>0&&l>0&&s<=0||o<0&&l<=0&&s>0)&&u++}c=d,s=l,i=a}}return u%2!=0}var Qe=function(e,t,n,r,o){this.p1=e,this.p2=t,this.edgeType=n,this.originalIndex=r,this.polygonContourId=o,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},et=function(e){this.p=e},tt=function(e,t){this.id=e,this.rawCoords=t};function nt(e,t){return!(e.maxX<t[0]||e.minX>t[2]||e.maxY<t[1]||e.minY>t[3])}var rt=function(e,t,n,r){this.p=e,this.polylineEdge=t,this.polygonEdge=n,this.isHeadingIn=r,this.distanceFromPolylineEdgeStart=ot(this.polylineEdge.p1.p,this.p),this.distanceFromPolygonEdgeStart=ot(this.polygonEdge.p1.p,this.p),this.polygonEdge.intersectionPoints.push(this),this.polylineEdge.intersectionPoints.push(this),this.visitCount=0};function ot(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*=n,r*=r,Math.sqrt(n+r)}function it(e,t){return e[0]*t[1]-e[1]*t[0]}function st(e,t){return e[0]*t[0]+e[1]*t[1]}function at(e,t,n){return[e[0]+t*n[0],e[1]+t*n[1]]}function lt(e,t,n){var r=[e.p2.p[0]-e.p1.p[0],e.p2.p[1]-e.p1.p[1]],o=[t.p2.p[0]-t.p1.p[0],t.p2.p[1]-t.p1.p[1]],i=[t.p1.p[0]-e.p1.p[0],t.p1.p[1]-e.p1.p[1]],s=it(r,o),a=s*s,l=st(r,r);if(a>0){var c=it(i,o)/s;if(c<0||c>1)return null;var d=it(i,r)/s;return d<0||d>1?null:0===c||1===c?[at(e.p1.p,c,r)]:0===d||1===d?[at(t.p1.p,d,o)]:[at(e.p1.p,c,r)]}var u=st(i,i);if((a=(s=it(i,r))*s)>1e-9*l*u)return null;var p=st(r,i)/l,h=p+st(r,o)/l,f=Math.min(p,h),g=Math.max(p,h);return f<=1&&g>=0?1===f?[at(e.p1.p,f>0?f:0,r)]:0===g?[at(e.p1.p,g<1?g:1,r)]:[at(e.p1.p,f>0?f:0,r),at(e.p1.p,g<1?g:1,r)]:null}function ct(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.polygonContourId===t)return r}}function dt(e,t){return t.find(function(t){return t.id===e.polygonContourId}).rawCoords}function ut(e,t){for(var n=0;n<t.length;n++){var r=t[n];if(Ze(e[0],[r[0]]))return void r.push(e)}t.push([e])}function pt(e,t){var n=e.polygonEdge;if(n.intersectionPoints.length>1&&n.intersectionPoints[n.intersectionPoints.length-1]!==e){var r=ht(e,n.intersectionPoints),o=n.intersectionPoints[r+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(n.p2.p),null===(n=n.nextEdge))return e;n.intersectionPoints.length>0&&(i=!1)}return n.intersectionPoints[0].incrementVisitCount(),t.push(n.intersectionPoints[0].p),n.intersectionPoints[0]}function ht(e,t){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return null}function ft(e,t){var n=e.polylineEdge;if(2===n.intersectionPoints.length){var r=n.intersectionPoints[n.intersectionPoints.length-1];if(r===e){var o=n.intersectionPoints[0];return t.push(o.p),o.incrementVisitCount(),o}return t.push(r.p),r.incrementVisitCount(),r}if(n.intersectionPoints.length>2&&n.intersectionPoints[0]!==e){var i=ht(e,n.intersectionPoints),s=n.intersectionPoints[i-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 gt(e,t){var n=e.polylineEdge;if(n.intersectionPoints.length>1&&n.intersectionPoints[n.intersectionPoints.length-1]!==e){var r=ht(e,n.intersectionPoints),o=n.intersectionPoints[r+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(n.p2.p),null===(n=n.nextEdge))return e;n.intersectionPoints.length>0&&(i=!1)}if(void 0===n)return e;var s=n.intersectionPoints[0];return s.incrementVisitCount(),t.push(s.p),s}rt.prototype.incrementVisitCount=function(){this.visitCount=this.visitCount+1};var mt=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,yt=Math.ceil,vt=Math.floor,bt="[BigNumber Error] ",_t=bt+"Number primitive has more than 15 significant digits: ",Et=1e14,St=14,xt=9007199254740991,It=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],wt=1e7,Pt=1e9;function Ct(e){var t=0|e;return e>0||e===t?t:t-1}function Tt(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=St-t.length;n--;t="0"+t);i+=t}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function Mt(e,t){var n,r,o=e.c,i=t.c,s=e.s,a=t.s,l=e.e,c=t.e;if(!s||!a)return null;if(n=o&&!o[0],r=i&&!i[0],n||r)return n?r?0:-a:s;if(s!=a)return s;if(n=s<0,r=l==c,!o||!i)return r?0:!o^n?1:-1;if(!r)return l>c^n?1:-1;for(a=(l=o.length)<(c=i.length)?l:c,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[s]^n?1:-1;return l==c?0:l>c^n?1:-1}function Lt(e,t,n,r){if(e<t||e>n||e!==vt(e))throw Error(bt+(r||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function At(e){var t=e.c.length-1;return Ct(e.e/St)==t&&e.c[t]%2!=0}function Ot(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function kt(e,t,n){var r,o;if(t<0){for(o=n+".";++t;o+=n);e=o+e}else if(++t>(r=e.length)){for(o=n,t-=r;--t;o+=n);e+=o}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var Dt=function e(t){var n,r,o,i,s,a,l,c,d,u,p=P.prototype={constructor:P,toString:null,valueOf:null},h=new P(1),f=20,g=4,m=-7,y=21,v=-1e7,b=1e7,_=!1,E=1,S=0,x={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},I="0123456789abcdefghijklmnopqrstuvwxyz",w=!0;function P(e,t){var n,i,s,a,l,c,d,u,p=this;if(!(p instanceof P))return new P(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((c="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]))}u=String(e)}else{if(!mt.test(u=String(e)))return o(p,u,c);p.s=45==u.charCodeAt(0)?(u=u.slice(1),-1):1}(a=u.indexOf("."))>-1&&(u=u.replace(".","")),(l=u.search(/e/i))>0?(a<0&&(a=l),a+=+u.slice(l+1),u=u.substring(0,l)):a<0&&(a=u.length)}else{if(Lt(t,2,I.length,"Base"),10==t&&w)return L(p=new P(e),f+p.e+1,g);if(u=String(e),c="number"==typeof e){if(0*e!=0)return o(p,u,c,t);if(p.s=1/e<0?(u=u.slice(1),-1):1,P.DEBUG&&u.replace(/^0\.0*|\./,"").length>15)throw Error(_t+e)}else p.s=45===u.charCodeAt(0)?(u=u.slice(1),-1):1;for(n=I.slice(0,t),a=l=0,d=u.length;l<d;l++)if(n.indexOf(i=u.charAt(l))<0){if("."==i){if(l>a){a=d;continue}}else if(!s&&(u==u.toUpperCase()&&(u=u.toLowerCase())||u==u.toLowerCase()&&(u=u.toUpperCase()))){s=!0,l=-1,a=0;continue}return o(p,String(e),c,t)}c=!1,(a=(u=r(u,t,10,p.s)).indexOf("."))>-1?u=u.replace(".",""):a=u.length}for(l=0;48===u.charCodeAt(l);l++);for(d=u.length;48===u.charCodeAt(--d););if(u=u.slice(l,++d)){if(d-=l,c&&P.DEBUG&&d>15&&(e>xt||e!==vt(e)))throw Error(_t+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)%St,a<0&&(l+=St),l<d){for(l&&p.c.push(+u.slice(0,l)),d-=St;l<d;)p.c.push(+u.slice(l,l+=St));l=St-(u=u.slice(l)).length}else l-=d;for(;l--;u+="0");p.c.push(+u)}}else p.c=[p.e=0]}function C(e,t,n,r){var o,i,s,a,l;if(null==n?n=g:Lt(n,0,8),!e.c)return e.toString();if(o=e.c[0],s=e.e,null==t)l=Tt(e.c),l=1==r||2==r&&(s<=m||s>=y)?Ot(l,s):kt(l,s,"0");else if(i=(e=L(new P(e),t,n)).e,a=(l=Tt(e.c)).length,1==r||2==r&&(t<=i||i<=m)){for(;a<t;l+="0",a++);l=Ot(l,i)}else if(t-=s+(2===r&&i>s),l=kt(l,i,"0"),i+1>a){if(--t>0)for(l+=".";t--;l+="0");}else if((t+=i-a)>0)for(i+1==a&&(l+=".");t--;l+="0");return e.s<0&&o?"-"+l:l}function T(e,t){for(var n,r,o=1,i=new P(e[0]);o<e.length;o++)(!(r=new P(e[o])).s||(n=Mt(i,r))===t||0===n&&i.s===t)&&(i=r);return i}function M(e,t,n){for(var r=1,o=t.length;!t[--o];t.pop());for(o=t[0];o>=10;o/=10,r++);return(n=r+n*St-1)>b?e.c=e.e=null:n<v?e.c=[e.e=0]:(e.e=n,e.c=t),e}function L(e,t,n,r){var o,i,s,a,l,c,d,u=e.c,p=It;if(u){e:{for(o=1,a=u[0];a>=10;a/=10,o++);if((i=t-o)<0)i+=St,s=t,l=u[c=0],d=vt(l/p[o-s-1]%10);else if((c=yt((i+1)/St))>=u.length){if(!r)break e;for(;u.length<=c;u.push(0));l=d=0,o=1,s=(i%=St)-St+1}else{for(l=a=u[c],o=1;a>=10;a/=10,o++);d=(s=(i%=St)-St+o)<0?0:vt(l/p[o-s-1]%10)}if(r=r||t<0||null!=u[c+1]||(s<0?l:l%p[o-s-1]),r=n<4?(d||r)&&(0==n||n==(e.s<0?3:2)):d>5||5==d&&(4==n||r||6==n&&(i>0?s>0?l/p[o-s]:0:u[c-1])%10&1||n==(e.s<0?8:7)),t<1||!u[0])return u.length=0,r?(t-=e.e+1,u[0]=p[(St-t%St)%St],e.e=-t||0):u[0]=e.e=0,e;if(0==i?(u.length=c,a=1,c--):(u.length=c+1,a=p[St-i],u[c]=s>0?vt(l/p[o-s]%p[s])*a:0),r)for(;;){if(0==c){for(i=1,s=u[0];s>=10;s/=10,i++);for(s=u[0]+=a,a=1;s>=10;s/=10,a++);i!=a&&(e.e++,u[0]==Et&&(u[0]=1));break}if(u[c]+=a,u[c]!=Et)break;u[c--]=0,a=1}for(i=u.length;0===u[--i];u.pop());}e.e>b?e.c=e.e=null:e.e<v&&(e.c=[e.e=0])}return e}function A(e){var t,n=e.e;return null===n?e.toString():(t=Tt(e.c),t=n<=m||n>=y?Ot(t,n):kt(t,n,"0"),e.s<0?"-"+t:t)}return P.clone=e,P.ROUND_UP=0,P.ROUND_DOWN=1,P.ROUND_CEIL=2,P.ROUND_FLOOR=3,P.ROUND_HALF_UP=4,P.ROUND_HALF_DOWN=5,P.ROUND_HALF_EVEN=6,P.ROUND_HALF_CEIL=7,P.ROUND_HALF_FLOOR=8,P.EUCLID=9,P.config=P.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(bt+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(Lt(n=e[t],0,Pt,t),f=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(Lt(n=e[t],0,8,t),g=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((n=e[t])&&n.pop?(Lt(n[0],-Pt,0,t),Lt(n[1],0,Pt,t),m=n[0],y=n[1]):(Lt(n,-Pt,Pt,t),m=-(y=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if((n=e[t])&&n.pop)Lt(n[0],-Pt,-1,t),Lt(n[1],1,Pt,t),v=n[0],b=n[1];else{if(Lt(n,-Pt,Pt,t),!n)throw Error(bt+t+" cannot be zero: "+n);v=-(b=n<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(bt+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw _=!n,Error(bt+"crypto unavailable");_=n}else _=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(Lt(n=e[t],0,9,t),E=n),e.hasOwnProperty(t="POW_PRECISION")&&(Lt(n=e[t],0,Pt,t),S=n),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(bt+t+" not an object: "+n);x=n}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(bt+t+" invalid: "+n);w="0123456789"==n.slice(0,10),I=n}}return{DECIMAL_PLACES:f,ROUNDING_MODE:g,EXPONENTIAL_AT:[m,y],RANGE:[v,b],CRYPTO:_,MODULO_MODE:E,POW_PRECISION:S,FORMAT:x,ALPHABET:I}},P.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!P.DEBUG)return!0;var t,n,r=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(r)){if((1===i||-1===i)&&o>=-Pt&&o<=Pt&&o===vt(o)){if(0===r[0]){if(0===o&&1===r.length)return!0;break e}if((t=(o+1)%St)<1&&(t+=St),String(r[0]).length==t){for(t=0;t<r.length;t++)if((n=r[t])<0||n>=Et||n!==vt(n))break e;if(0!==n)return!0}}}else if(null===r&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(bt+"Invalid BigNumber: "+e)},P.maximum=P.max=function(){return T(arguments,-1)},P.minimum=P.min=function(){return T(arguments,1)},P.random=(i=9007199254740992,s=Math.random()*i&2097151?function(){return vt(Math.random()*i)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,n,r,o,i,a=0,l=[],c=new P(h);if(null==e?e=f:Lt(e,0,Pt),o=yt(e/St),_)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));a<o;)(i=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(i%1e14),a+=2);a=o/2}else{if(!crypto.randomBytes)throw _=!1,Error(bt+"crypto unavailable");for(t=crypto.randomBytes(o*=7);a<o;)(i=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(i%1e14),a+=7);a=o/7}if(!_)for(;a<o;)(i=s())<9e15&&(l[a++]=i%1e14);for(o=l[--a],e%=St,o&&e&&(i=It[St-e],l[a]=vt(o/i)*i);0===l[a];l.pop(),a--);if(a<0)l=[r=0];else{for(r=-1;0===l[0];l.splice(0,1),r-=St);for(a=1,i=l[0];i>=10;i/=10,a++);a<St&&(r-=St-a)}return c.e=r,c.c=l,c}),P.sum=function(){for(var e=1,t=arguments,n=new P(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 o,i,s=[0],a=0,l=e.length;a<l;){for(i=s.length;i--;s[i]*=t);for(s[0]+=r.indexOf(e.charAt(a++)),o=0;o<s.length;o++)s[o]>n-1&&(null==s[o+1]&&(s[o+1]=0),s[o+1]+=s[o]/n|0,s[o]%=n)}return s.reverse()}return function(r,o,i,s,a){var l,c,d,u,p,h,m,y,v=r.indexOf("."),b=f,_=g;for(v>=0&&(u=S,S=0,r=r.replace(".",""),h=(y=new P(o)).pow(r.length-v),S=u,y.c=t(kt(Tt(h.c),h.e,"0"),10,i,e),y.e=y.c.length),d=u=(m=t(r,o,i,a?(l=I,e):(l=e,I))).length;0==m[--u];m.pop());if(!m[0])return l.charAt(0);if(v<0?--d:(h.c=m,h.e=d,h.s=s,m=(h=n(h,y,b,_,i)).c,p=h.r,d=h.e),v=m[c=d+b+1],u=i/2,p=p||c<0||null!=m[c+1],p=_<4?(null!=v||p)&&(0==_||_==(h.s<0?3:2)):v>u||v==u&&(4==_||p||6==_&&1&m[c-1]||_==(h.s<0?8:7)),c<1||!m[0])r=p?kt(l.charAt(1),-b,l.charAt(0)):l.charAt(0);else{if(m.length=c,p)for(--i;++m[--c]>i;)m[c]=0,c||(++d,m=[1].concat(m));for(u=m.length;!m[--u];);for(v=0,r="";v<=u;r+=l.charAt(m[v++]));r=kt(r,d,l.charAt(0))}return r}}(),n=function(){function e(e,t,n){var r,o,i,s,a=0,l=e.length,c=t%wt,d=t/wt|0;for(e=e.slice();l--;)a=((o=c*(i=e[l]%wt)+(r=d*i+(s=e[l]/wt|0)*c)%wt*wt+a)/n|0)+(r/wt|0)+d*s,e[l]=o%n;return a&&(e=[a].concat(e)),e}function t(e,t,n,r){var o,i;if(n!=r)i=n>r?1:-1;else for(o=i=0;o<n;o++)if(e[o]!=t[o]){i=e[o]>t[o]?1:-1;break}return i}function n(e,t,n,r){for(var o=0;n--;)e[n]-=o,o=e[n]<t[n]?1:0,e[n]=o*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,o,i,s,a){var l,c,d,u,p,h,f,g,m,y,v,b,_,E,S,x,I,w=r.s==o.s?1:-1,C=r.c,T=o.c;if(!(C&&C[0]&&T&&T[0]))return new P(r.s&&o.s&&(C?!T||C[0]!=T[0]:T)?C&&0==C[0]||!T?0*w:w/0:NaN);for(m=(g=new P(w)).c=[],w=i+(c=r.e-o.e)+1,a||(a=Et,c=Ct(r.e/St)-Ct(o.e/St),w=w/St|0),d=0;T[d]==(C[d]||0);d++);if(T[d]>(C[d]||0)&&c--,w<0)m.push(1),u=!0;else{for(E=C.length,x=T.length,d=0,w+=2,(p=vt(a/(T[0]+1)))>1&&(T=e(T,p,a),C=e(C,p,a),x=T.length,E=C.length),_=x,v=(y=C.slice(0,x)).length;v<x;y[v++]=0);I=T.slice(),I=[0].concat(I),S=T[0],T[1]>=a/2&&S++;do{if(p=0,(l=t(T,y,x,v))<0){if(b=y[0],x!=v&&(b=b*a+(y[1]||0)),(p=vt(b/S))>1)for(p>=a&&(p=a-1),f=(h=e(T,p,a)).length,v=y.length;1==t(h,y,f,v);)p--,n(h,x<f?I:T,f,a),f=h.length,l=1;else 0==p&&(l=p=1),f=(h=T.slice()).length;if(f<v&&(h=[0].concat(h)),n(y,h,v,a),v=y.length,-1==l)for(;t(T,y,x,v)<1;)p++,n(y,x<v?I:T,v,a),v=y.length}else 0===l&&(p++,y=[0]);m[d++]=p,y[0]?y[v++]=C[_]||0:(y=[C[_]],v=1)}while((_++<E||null!=y[0])&&w--);u=null!=y[0],m[0]||m.splice(0,1)}if(a==Et){for(d=1,w=m[0];w>=10;w/=10,d++);L(g,i+(g.e=d+c*St-1)+1,s,u)}else g.e=c,g.r=+u;return g}}(),a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,c=/^\.([^.]+)$/,d=/^-?(Infinity|NaN)$/,u=/^\s*\+(?=[\w.])|^\s+|\s+$/g,o=function(e,t,n,r){var o,i=n?t:t.replace(u,"");if(d.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!n&&(i=i.replace(a,function(e,t,n){return o="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=o?e:t}),r&&(o=r,i=i.replace(l,"$1").replace(c,"0.$1")),t!=i))return new P(i,o);if(P.DEBUG)throw Error(bt+"Not a"+(r?" base "+r:"")+" number: "+t);e.s=null}e.c=e.e=null},p.absoluteValue=p.abs=function(){var e=new P(this);return e.s<0&&(e.s=1),e},p.comparedTo=function(e,t){return Mt(this,new P(e,t))},p.decimalPlaces=p.dp=function(e,t){var n,r,o,i=this;if(null!=e)return Lt(e,0,Pt),null==t?t=g:Lt(t,0,8),L(new P(i),e+i.e+1,t);if(!(n=i.c))return null;if(r=((o=n.length-1)-Ct(this.e/St))*St,o=n[o])for(;o%10==0;o/=10,r--);return r<0&&(r=0),r},p.dividedBy=p.div=function(e,t){return n(this,new P(e,t),f,g)},p.dividedToIntegerBy=p.idiv=function(e,t){return n(this,new P(e,t),0,1)},p.exponentiatedBy=p.pow=function(e,t){var n,r,o,i,s,a,l,c,d=this;if((e=new P(e)).c&&!e.isInteger())throw Error(bt+"Exponent not an integer: "+A(e));if(null!=t&&(t=new P(t)),s=e.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!e.c||!e.c[0])return c=new P(Math.pow(+A(d),s?e.s*(2-At(e)):+A(e))),t?c.mod(t):c;if(a=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new P(NaN);(r=!a&&d.isInteger()&&t.isInteger())&&(d=d.mod(t))}else{if(e.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||s&&d.c[1]>=24e7:d.c[0]<8e13||s&&d.c[0]<=9999975e7)))return i=d.s<0&&At(e)?-0:0,d.e>-1&&(i=1/i),new P(a?1/i:i);S&&(i=yt(S/St+2))}for(s?(n=new P(.5),a&&(e.s=1),l=At(e)):l=(o=Math.abs(+A(e)))%2,c=new P(h);;){if(l){if(!(c=c.times(d)).c)break;i?c.c.length>i&&(c.c.length=i):r&&(c=c.mod(t))}if(o){if(0===(o=vt(o/2)))break;l=o%2}else if(L(e=e.times(n),e.e+1,1),e.e>14)l=At(e);else{if(0===(o=+A(e)))break;l=o%2}d=d.times(d),i?d.c&&d.c.length>i&&(d.c.length=i):r&&(d=d.mod(t))}return r?c:(a&&(c=h.div(c)),t?c.mod(t):i?L(c,S,g,void 0):c)},p.integerValue=function(e){var t=new P(this);return null==e?e=g:Lt(e,0,8),L(t,t.e+1,e)},p.isEqualTo=p.eq=function(e,t){return 0===Mt(this,new P(e,t))},p.isFinite=function(){return!!this.c},p.isGreaterThan=p.gt=function(e,t){return Mt(this,new P(e,t))>0},p.isGreaterThanOrEqualTo=p.gte=function(e,t){return 1===(t=Mt(this,new P(e,t)))||0===t},p.isInteger=function(){return!!this.c&&Ct(this.e/St)>this.c.length-2},p.isLessThan=p.lt=function(e,t){return Mt(this,new P(e,t))<0},p.isLessThanOrEqualTo=p.lte=function(e,t){return-1===(t=Mt(this,new P(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,o,i,s=this,a=s.s;if(t=(e=new P(e,t)).s,!a||!t)return new P(NaN);if(a!=t)return e.s=-t,s.plus(e);var l=s.e/St,c=e.e/St,d=s.c,u=e.c;if(!l||!c){if(!d||!u)return d?(e.s=-t,e):new P(u?s:NaN);if(!d[0]||!u[0])return u[0]?(e.s=-t,e):new P(d[0]?s:3==g?-0:0)}if(l=Ct(l),c=Ct(c),d=d.slice(),a=l-c){for((i=a<0)?(a=-a,o=d):(c=l,o=u),o.reverse(),t=a;t--;o.push(0));o.reverse()}else for(r=(i=(a=d.length)<(t=u.length))?a:t,a=t=0;t<r;t++)if(d[t]!=u[t]){i=d[t]<u[t];break}if(i&&(o=d,d=u,u=o,e.s=-e.s),(t=(r=u.length)-(n=d.length))>0)for(;t--;d[n++]=0);for(t=Et-1;r>a;){if(d[--r]<u[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=Et}d[r]-=u[r]}for(;0==d[0];d.splice(0,1),--c);return d[0]?M(e,d,c):(e.s=3==g?-1:1,e.c=[e.e=0],e)},p.modulo=p.mod=function(e,t){var r,o,i=this;return e=new P(e,t),!i.c||!e.s||e.c&&!e.c[0]?new P(NaN):!e.c||i.c&&!i.c[0]?new P(i):(9==E?(o=e.s,e.s=1,r=n(i,e,0,3),e.s=o,r.s*=o):r=n(i,e,0,E),(e=i.minus(r.times(e))).c[0]||1!=E||(e.s=i.s),e)},p.multipliedBy=p.times=function(e,t){var n,r,o,i,s,a,l,c,d,u,p,h,f,g,m,y=this,v=y.c,b=(e=new P(e,t)).c;if(!(v&&b&&v[0]&&b[0]))return!y.s||!e.s||v&&!v[0]&&!b||b&&!b[0]&&!v?e.c=e.e=e.s=null:(e.s*=y.s,v&&b?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=Ct(y.e/St)+Ct(e.e/St),e.s*=y.s,(l=v.length)<(u=b.length)&&(f=v,v=b,b=f,o=l,l=u,u=o),o=l+u,f=[];o--;f.push(0));for(g=Et,m=wt,o=u;--o>=0;){for(n=0,p=b[o]%m,h=b[o]/m|0,i=o+(s=l);i>o;)n=((c=p*(c=v[--s]%m)+(a=h*c+(d=v[s]/m|0)*p)%m*m+f[i]+n)/g|0)+(a/m|0)+h*d,f[i--]=c%g;f[i]=n}return n?++r:f.splice(0,1),M(e,f,r)},p.negated=function(){var e=new P(this);return e.s=-e.s||null,e},p.plus=function(e,t){var n,r=this,o=r.s;if(t=(e=new P(e,t)).s,!o||!t)return new P(NaN);if(o!=t)return e.s=-t,r.minus(e);var i=r.e/St,s=e.e/St,a=r.c,l=e.c;if(!i||!s){if(!a||!l)return new P(o/0);if(!a[0]||!l[0])return l[0]?e:new P(a[0]?r:0*o)}if(i=Ct(i),s=Ct(s),a=a.slice(),o=i-s){for(o>0?(s=i,n=l):(o=-o,n=a),n.reverse();o--;n.push(0));n.reverse()}for((o=a.length)-(t=l.length)<0&&(n=l,l=a,a=n,t=o),o=0;t;)o=(a[--t]=a[t]+l[t]+o)/Et|0,a[t]=Et===a[t]?0:a[t]%Et;return o&&(a=[o].concat(a),++s),M(e,a,s)},p.precision=p.sd=function(e,t){var n,r,o,i=this;if(null!=e&&e!==!!e)return Lt(e,1,Pt),null==t?t=g:Lt(t,0,8),L(new P(i),e,t);if(!(n=i.c))return null;if(r=(o=n.length-1)*St+1,o=n[o]){for(;o%10==0;o/=10,r--);for(o=n[0];o>=10;o/=10,r++);}return e&&i.e+1>r&&(r=i.e+1),r},p.shiftedBy=function(e){return Lt(e,-9007199254740991,xt),this.times("1e"+e)},p.squareRoot=p.sqrt=function(){var e,t,r,o,i,s=this,a=s.c,l=s.s,c=s.e,d=f+4,u=new P("0.5");if(1!==l||!a||!a[0])return new P(!l||l<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(l=Math.sqrt(+A(s)))||l==1/0?(((t=Tt(a)).length+c)%2==0&&(t+="0"),l=Math.sqrt(+t),c=Ct((c+1)/2)-(c<0||c%2),r=new P(t=l==1/0?"5e"+c:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+c)):r=new P(l+""),r.c[0])for((l=(c=r.e)+d)<3&&(l=0);;)if(i=r,r=u.times(i.plus(n(s,i,d,1))),Tt(i.c).slice(0,l)===(t=Tt(r.c)).slice(0,l)){if(r.e<c&&--l,"9999"!=(t=t.slice(l-3,l+1))&&(o||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(L(r,r.e+f+2,1),e=!r.times(r).eq(s));break}if(!o&&(L(i,i.e+f+2,0),i.times(i).eq(s))){r=i;break}d+=4,l+=4,o=1}return L(r,r.e+f+1,g,e)},p.toExponential=function(e,t){return null!=e&&(Lt(e,0,Pt),e++),C(this,e,t,1)},p.toFixed=function(e,t){return null!=e&&(Lt(e,0,Pt),e=e+this.e+1),C(this,e,t)},p.toFormat=function(e,t,n){var r,o=this;if(null==n)null!=e&&t&&"object"==typeof t?(n=t,t=null):e&&"object"==typeof e?(n=e,e=t=null):n=x;else if("object"!=typeof n)throw Error(bt+"Argument not an object: "+n);if(r=o.toFixed(e,t),o.c){var i,s=r.split("."),a=+n.groupSize,l=+n.secondaryGroupSize,c=n.groupSeparator||"",d=s[0],u=s[1],p=o.s<0,h=p?d.slice(1):d,f=h.length;if(l&&(i=a,a=l,l=i,f-=i),a>0&&f>0){for(i=f%a||a,d=h.substr(0,i);i<f;i+=a)d+=c+h.substr(i,a);l>0&&(d+=c+h.slice(i)),p&&(d="-"+d)}r=u?d+(n.decimalSeparator||"")+((l=+n.fractionGroupSize)?u.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):u):d}return(n.prefix||"")+r+(n.suffix||"")},p.toFraction=function(e){var t,r,o,i,s,a,l,c,d,u,p,f,m=this,y=m.c;if(null!=e&&(!(l=new P(e)).isInteger()&&(l.c||1!==l.s)||l.lt(h)))throw Error(bt+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+A(l));if(!y)return new P(m);for(t=new P(h),d=r=new P(h),o=c=new P(h),f=Tt(y),s=t.e=f.length-m.e-1,t.c[0]=It[(a=s%St)<0?St+a:a],e=!e||l.comparedTo(t)>0?s>0?t:d:l,a=b,b=1/0,l=new P(f),c.c[0]=0;u=n(l,t,0,1),1!=(i=r.plus(u.times(o))).comparedTo(e);)r=o,o=i,d=c.plus(u.times(i=d)),c=i,t=l.minus(u.times(i=t)),l=i;return i=n(e.minus(r),o,0,1),c=c.plus(i.times(d)),r=r.plus(i.times(o)),c.s=d.s=m.s,p=n(d,o,s*=2,g).minus(m).abs().comparedTo(n(c,r,s,g).minus(m).abs())<1?[d,o]:[c,r],b=a,p},p.toNumber=function(){return+A(this)},p.toPrecision=function(e,t){return null!=e&&Lt(e,1,Pt),C(this,e,t,2)},p.toString=function(e){var t,n=this,o=n.s,i=n.e;return null===i?o?(t="Infinity",o<0&&(t="-"+t)):t="NaN":(null==e?t=i<=m||i>=y?Ot(Tt(n.c),i):kt(Tt(n.c),i,"0"):10===e&&w?t=kt(Tt((n=L(new P(n),f+i+1,g)).c),n.e,"0"):(Lt(e,2,I.length,"Base"),t=r(kt(Tt(n.c),i,"0"),10,e,o,!0)),o<0&&n.c[0]&&(t="-"+t)),t},p.valueOf=p.toJSON=function(){return A(this)},p._isBigNumber=!0,p[Symbol.toStringTag]="BigNumber",p[Symbol.for("nodejs.util.inspect.custom")]=p.valueOf,null!=t&&P.set(t),P}(),Rt=class{key;left=null;right=null;constructor(e){this.key=e}},Nt=class extends Rt{constructor(e){super(e)}},Ft=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,o=null,i=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==o?i=s:o.right=s,o=s,s=t}}return null!=o&&(o.right=s.left,s.left=i),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)}}},Vt=class e extends Ft{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 Nt(e),t),this}addAndReturn(e){const t=this.splay(e);return 0!=t&&this.addNewRoot(new Nt(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 Nt(e.key);return function e(t,n){let r,o;do{if(r=t.left,o=t.right,null!=r){const t=new Nt(r.key);n.left=t,e(r,t)}if(null!=o){const e=new Nt(o.key);n.right=e,t=o,n=e}}while(null!=o)}(e,t),t}toSet(){return this.clone()}entries(){return new Gt(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Ut(this.wrap())}[Symbol.toStringTag]="[object Set]"},Bt=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}},Ut=class extends Bt{getValue(e){return e.key}},Gt=class extends Bt{getValue(e){return[e.key,e.key]}},jt=e=>()=>e,Ht=e=>{const t=e?(t,n)=>n.minus(t).abs().isLessThanOrEqualTo(e):jt(!1);return(e,n)=>t(e,n)?0:e.comparedTo(n)};function $t(e){const t=e?(t,n,r,o,i)=>t.exponentiatedBy(2).isLessThanOrEqualTo(o.minus(n).exponentiatedBy(2).plus(i.minus(r).exponentiatedBy(2)).times(e)):jt(!1);return(e,n,r)=>{const o=e.x,i=e.y,s=r.x,a=r.y,l=i.minus(a).times(n.x.minus(s)).minus(o.minus(s).times(n.y.minus(a)));return t(l,o,i,s,a)?0:l.comparedTo(0)}}var Yt=e=>e,zt=e=>{if(e){const t=new Vt(Ht(e)),n=new Vt(Ht(e)),r=(e,t)=>t.addAndReturn(e),o=e=>({x:r(e.x,t),y:r(e.y,n)});return o({x:new Dt(0),y:new Dt(0)}),o}return Yt},Kt=e=>({set:e=>{Wt=Kt(e)},reset:()=>Kt(e),compare:Ht(e),snap:zt(e),orient:$t(e)}),Wt=Kt(),Jt=(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),qt=(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}}},Xt=(e,t)=>e.x.times(t.y).minus(e.y.times(t.x)),Zt=(e,t)=>e.x.times(t.x).plus(e.y.times(t.y)),Qt=e=>Zt(e,e).sqrt(),en=(e,t,n)=>{const r={x:t.x.minus(e.x),y:t.y.minus(e.y)},o={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Xt(o,r).div(Qt(o)).div(Qt(r))},tn=(e,t,n)=>{const r={x:t.x.minus(e.x),y:t.y.minus(e.y)},o={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Zt(o,r).div(Qt(o)).div(Qt(r))},nn=(e,t,n)=>t.y.isZero()?null:{x:e.x.plus(t.x.div(t.y).times(n.minus(e.y))),y:n},rn=(e,t,n)=>t.x.isZero()?null:{x:n,y:e.y.plus(t.y.div(t.x).times(n.minus(e.x)))},on=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:hn.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 n=0,r=t.length;n<r;n++){const e=t[n];this.point.events.push(e),e.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:en(this.point,e.point,r.point),cosine:tn(this.point,e.point,r.point)})};return(e,r)=>{t.has(e)||n(e),t.has(r)||n(r);const{sine:o,cosine:i}=t.get(e),{sine:s,cosine:a}=t.get(r);return o.isGreaterThanOrEqualTo(0)&&s.isGreaterThanOrEqualTo(0)?i.isLessThan(a)?1:i.isGreaterThan(a)?-1:0:o.isLessThan(0)&&s.isLessThan(0)?i.isLessThan(a)?-1:i.isGreaterThan(a)?1:0:s.isLessThan(o)?-1:s.isGreaterThan(o)?1:0}}},sn=class e{events;poly;_isExteriorRing;_enclosingRing;static factory(t){const n=[];for(let r=0,o=t.length;r<o;r++){const o=t[r];if(!o.isInResult()||o.ringOut)continue;let i=null,s=o.leftSE,a=o.rightSE;const l=[s],c=s.point,d=[];for(;i=s,s=a,l.push(s),s.point!==c;)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,n=d.length;e<n;e++)if(d[e].point===s.point){r=e;break}if(null!==r){const t=d.splice(r)[0],o=l.splice(t.index);o.unshift(o[0].otherSE),n.push(new e(o.reverse()));continue}d.push({index:l.length,point:s.point});const o=s.getLeftmostComparator(i);a=t.sort(o)[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 l=1,c=this.events.length-1;l<c;l++){const n=this.events[l].point,r=this.events[l+1].point;0!==Wt.orient(n,e,r)&&(t.push(n),e=n)}if(1===t.length)return null;const n=t[0],r=t[1];0===Wt.orient(n,e,r)&&t.shift(),t.push(t[0]);const o=this.isExteriorRing()?1:-1,i=this.isExteriorRing()?0:t.length-1,s=this.isExteriorRing()?t.length:-1,a=[];for(let l=i;l!=s;l+=o)a.push([t[l].x.toNumber(),t[l].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 r=1,o=this.events.length;r<o;r++){const t=this.events[r];on.compare(e,t)>0&&(e=t)}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}}},an=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 n=0,r=this.interiorRings.length;n<r;n++){const e=this.interiorRings[n].getGeom();null!==e&&t.push(e)}return t}},ln=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 an(r));else{const e=r.enclosingRing();e?.poly||t.push(new an(e)),e?.poly?.addInterior(r)}}return t}},cn=class{queue;tree;segments;constructor(e,t=hn.compare){this.queue=e,this.tree=new Vt(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,o=t;do{r=this.tree.lastBefore(r)}while(null!=r&&null!=r.consumedBy);do{o=this.tree.firstAfter(o)}while(null!=o&&null!=o.consumedBy);if(e.isLeft){let i=null;if(r){const e=r.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(i=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(o){const e=o.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(s=e),!o.isAnEndpoint(e))){const t=this._splitSafely(o,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}if(null!==i||null!==s){let e=null;e=null===i?s:null===s||on.comparePoints(i,s)<=0?i:s,this.queue.delete(t.rightSE),n.push(t.rightSE);const r=t.split(e);for(let t=0,o=r.length;t<o;t++)n.push(r[t])}n.length>0?(this.tree.delete(t),n.push(e)):(this.segments.push(t),t.prev=r)}else{if(r&&o){const e=r.getIntersection(o);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(!o.isAnEndpoint(e)){const t=this._splitSafely(o,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}},dn=new class{type;numMultiPolys;run(e,t,n){dn.type=e;const r=[new mn(t,!0)];for(let l=0,c=n.length;l<c;l++)r.push(new mn(n[l],!1));if(dn.numMultiPolys=r.length,"difference"===dn.type){const e=r[0];let t=1;for(;t<r.length;)null!==qt(r[t].bbox,e.bbox)?t++:r.splice(t,1)}if("intersection"===dn.type)for(let l=0,c=r.length;l<c;l++){const e=r[l];for(let t=l+1,n=r.length;t<n;t++)if(null===qt(e.bbox,r[t].bbox))return[]}const o=new Vt(on.compare);for(let l=0,c=r.length;l<c;l++){const e=r[l].getSweepEvents();for(let t=0,n=e.length;t<n;t++)o.add(e[t])}const i=new cn(o);let s=null;for(0!=o.size&&(s=o.first(),o.delete(s));s;){const e=i.process(s);for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0===n.consumedBy&&o.add(n)}0!=o.size?(s=o.first(),o.delete(s)):s=null}Wt.reset();const a=sn.factory(i.segments);return new ln(a).getGeom()}},un=dn,pn=0,hn=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,o=e.rightSE.point.x,i=t.rightSE.point.x;if(i.isLessThan(n))return 1;if(o.isLessThan(r))return-1;const s=e.leftSE.point.y,a=t.leftSE.point.y,l=e.rightSE.point.y,c=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(c))return-1;if(s.isGreaterThan(a)&&s.isGreaterThan(c))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(o.isLessThan(i)){const n=t.comparePoint(e.rightSE.point);if(0!==n)return n}if(o.isGreaterThan(i)){const n=e.comparePoint(t.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(!o.eq(i)){const e=l.minus(s),t=o.minus(n),d=c.minus(a),u=i.minus(r);if(e.isGreaterThan(t)&&d.isLessThan(u))return 1;if(e.isLessThan(t)&&d.isGreaterThan(u))return-1}return o.isGreaterThan(i)?1:o.isLessThan(i)||l.isLessThan(c)?-1:l.isGreaterThan(c)?1:e.id<t.id?-1:e.id>t.id?1:0}constructor(e,t,n,r){this.id=++pn,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 o,i,s;const a=on.comparePoints(t,n);if(a<0)o=t,i=n,s=1;else{if(!(a>0))throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);o=n,i=t,s=-1}const l=new on(o,!0),c=new on(i,!1);return new e(l,c,[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 Wt.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){const t=this.bbox(),n=e.bbox(),r=qt(t,n);if(null===r)return null;const o=this.leftSE.point,i=this.rightSE.point,s=e.leftSE.point,a=e.rightSE.point,l=Jt(t,s)&&0===this.comparePoint(s),c=Jt(n,o)&&0===e.comparePoint(o),d=Jt(t,a)&&0===this.comparePoint(a),u=Jt(n,i)&&0===e.comparePoint(i);if(c&&l)return u&&!d?i:!u&&d?a:null;if(c)return d&&o.x.eq(a.x)&&o.y.eq(a.y)?null:o;if(l)return u&&i.x.eq(s.x)&&i.y.eq(s.y)?null:s;if(u&&d)return null;if(u)return i;if(d)return a;const p=((e,t,n,r)=>{if(t.x.isZero())return rn(n,r,e.x);if(r.x.isZero())return rn(e,t,n.x);if(t.y.isZero())return nn(n,r,e.y);if(r.y.isZero())return nn(e,t,n.y);const o=Xt(t,r);if(o.isZero())return null;const i={x:n.x.minus(e.x),y:n.y.minus(e.y)},s=Xt(i,t).div(o),a=Xt(i,r).div(o),l=e.x.plus(a.times(t.x)),c=n.x.plus(s.times(r.x)),d=e.y.plus(a.times(t.y)),u=n.y.plus(s.times(r.y));return{x:l.plus(c).div(2),y:d.plus(u).div(2)}})(o,this.vector(),s,e.vector());return null===p?null:Jt(r,p)?Wt.snap(p):null}split(t){const n=[],r=void 0!==t.events,o=new on(t,!0),i=new on(t,!1),s=this.rightSE;this.replaceRightSE(i),n.push(i),n.push(o);const a=new e(o,s,this.rings.slice(),this.windings.slice());return on.comparePoints(a.leftSE.point,a.rightSE.point)>0&&a.swapEvents(),on.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(o.checkForConsuming(),i.checkForConsuming()),n}swapEvents(){const e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let t=0,n=this.windings.length;t<n;t++)this.windings[t]*=-1}consume(t){let n=this,r=t;for(;n.consumedBy;)n=n.consumedBy;for(;r.consumedBy;)r=r.consumedBy;const o=e.compare(n,r);if(0!==o){if(o>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],o=r.windings[e],i=n.rings.indexOf(t);-1===i?(n.rings.push(t),n.windings.push(o)):n.windings[i]+=o}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 s=0,a=this.rings.length;s<a;s++){const e=this.rings[s],r=this.windings[s],o=t.indexOf(e);-1===o?(t.push(e),n.push(r)):n[o]+=r}const o=[],i=[];for(let s=0,a=t.length;s<a;s++){if(0===n[s])continue;const e=t[s],r=e.poly;if(-1===i.indexOf(r))if(e.isExterior)o.push(r);else{-1===i.indexOf(r)&&i.push(r);const t=o.indexOf(e.poly);-1!==t&&o.splice(t,1)}}for(let s=0,a=o.length;s<a;s++){const e=o[s].multiPoly;-1===r.indexOf(e)&&r.push(e)}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(un.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===un.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}},fn=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=Wt.snap({x:new Dt(e[0][0]),y:new Dt(e[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let o=r;for(let i=1,s=e.length;i<s;i++){if("number"!=typeof e[i][0]||"number"!=typeof e[i][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const t=Wt.snap({x:new Dt(e[i][0]),y:new Dt(e[i][1])});t.x.eq(o.x)&&t.y.eq(o.y)||(this.segments.push(hn.fromRing(o,t,this)),t.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=t.x),t.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=t.y),t.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=t.x),t.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=t.y),o=t)}r.x.eq(o.x)&&r.y.eq(o.y)||this.segments.push(hn.fromRing(o,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}},gn=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 fn(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 n=1,r=e.length;n<r;n++){const t=new fn(e[n],this,!1);t.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=t.bbox.ll.x),t.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=t.bbox.ll.y),t.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=t.bbox.ur.x),t.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=t.bbox.ur.y),this.interiorRings.push(t)}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}},mn=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 Dt(Number.POSITIVE_INFINITY),y:new Dt(Number.POSITIVE_INFINITY)},ur:{x:new Dt(Number.NEGATIVE_INFINITY),y:new Dt(Number.NEGATIVE_INFINITY)}};for(let n=0,r=e.length;n<r;n++){const t=new gn(e[n],this);t.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=t.bbox.ll.x),t.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=t.bbox.ll.y),t.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=t.bbox.ur.x),t.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=t.bbox.ur.y),this.polys.push(t)}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}};Wt.set;const yn=(e,t)=>{const n=function(e,t=.01){const n=e.geometry.coordinates.map(e=>[...e]),r=n.length-1,o=(e,n)=>[e[0]+(e[0]-n[0])*t,e[1]+(e[1]-n[1])*t],i=o(n[0],n[1]),s=o(n[r],n[r-1]);return n[0]=i,n[r]=s,h(n)}(t);let r;try{r=function(e,t){var n=[],r=[],o=[],i=function(e,t,n,r,o){for(var i=0,s=[],a="Feature"===t.type?t.geometry:t,l="LineString"===a.type?[a.coordinates]:a.coordinates,c=0,d=0;d<l.length;d++){for(var u=l[d].length-1,p=new et(l[d][0]),h=null,f={nextEdge:null},g=0;g<u;g++){h=new et(l[d][g+1]),p.nextPoint=h,h.prevPoint=p;var m=new Qe(p,h,"polyline",c,null);r.push(m),f.nextEdge=m,m.prevEdge=f,o[0]=Math.min(o[0],p.p[0]),o[1]=Math.min(o[1],p.p[1]),o[2]=Math.max(o[2],p.p[0]),o[3]=Math.max(o[3],p.p[1]),p=h,c+=1,f=m}o[0]=Math.min(o[0],l[d][u][0]),o[1]=Math.min(o[1],l[d][u][1]),o[2]=Math.max(o[2],l[d][u][0]),o[3]=Math.max(o[3],l[d][u][1])}for(var y="Feature"===e.type?e.geometry:e,v="Polygon"===y.type?[y.coordinates]:y.coordinates,b=v.length,_=0;_<b;_++)for(var E=v[_].length,S=0;S<E;S++){i+=1;var x=v[_][S],I=x.length;s.push(new tt(i,x));for(var w=new et(x[0]),P=w,C=void 0,T=null,M={nextEdge:null,prevEdge:null},L=null,A=1;A<I;A++)C=new et(x[A]),P.nextPoint=C,C.prevPoint=P,T=new Qe(P,C,"polygon",c,i),M.nextEdge=T,T.prevEdge=M,1===A&&(L=T),S>0&&(T.interiorRing=!0),T.intersectPolylineBbox=nt(T,o),n.push(T),P=C,c+=1,M=T;T.nextEdge=L,L.prevEdge=T,C.nextPoint=w.nextPoint,w.prevPoint=C.prevPoint}return s}(Fe(e),t,r,o,[1/0,1/0,1/0,1/0]);if(function(e,t,n){var r,o,i,s=t.length,a=e.length;for(r=0;r<s;r++){var l=t[r];for(o=0;o<a;o++){var c=e[o];if(c.intersectPolylineBbox&&!(c.maxX<l.minX||c.minX>l.maxX||c.maxY<l.minY||c.minY>l.maxY)){var d=lt(l,c);if(null!==d)for(i=0;i<d.length;i++){var u=Xe(c.p1.p[0],c.p1.p[1],c.p2.p[0],c.p2.p[1],l.p1.p[0],l.p1.p[1]),p=new rt(d[i],l,c,u>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,o,n),0===n.length)return e;var s={};i.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=[],c=null,d=0;d<o.length;d++){var u=o[d];if(u.intersectionPoints.length>0){c=u.intersectionPoints[0];break}}for(var p=c,h={visitCount:1};c!==h&&!(a>2*n.length);){if(a=a++,h.visitCount>=2){for(var f=!1,g=0;g<n.length;g++){var m=n[g];if(m.visitCount<2){p=m,f=!0;break}}if(!f)break}p.visitCount=p.visitCount+1;var y=[];l.push(y),y.push(p.p),p.visitCount=p.visitCount+1;var v=pt(p,y),b=!1;if(v===(h=v)&&2===n.length)for(var _=0;_<n.length;_++)n[_].visitCount<2&&(b=!0);for(;v!==p||b;)(v=(v.isHeadingIn?gt:ft)(v,y))!==p&&(v=pt(v,y)),b=!1;if(h.visitCount>=2){for(var E=!1,S=0;S<n.length;S++){var x=n[S];if(x.visitCount<2){p=x,E=!0;break}}E&&(h=p)}p=h}for(var I=l.map(function(e){return[e]}),w=Object.keys(s),P=0;P<w.length;P++){var C=w[P];0===s[C]&&ut(dt(ct(r,parseInt(C)),i),I)}return{type:"Feature",properties:{},geometry:{type:"MultiPolygon",coordinates:I}}}(e,n)}catch{return null}let o=[];if("MultiPolygon"!==r.geometry.type)return null;if(2!==r.geometry.coordinates.length)return null;o=r.geometry.coordinates.map(t=>p(t,e.properties));const i=e.id??e.properties?.id??"poly";return f(o.map((t,n)=>p(t.geometry.coordinates,{...e.properties,id:i},{id:`${i}-${n+1}`})))},vn=([e,t],[n,r])=>{const o=e=>e*Math.PI/180,i=o(r-t),s=o(n-e),a=Math.sin(i/2)**2+Math.cos(o(t))*Math.cos(o(r))*Math.sin(s/2)**2;return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))},bn=(e,t=.01)=>{if(e.length<=1)return!0;const n=e[e.length-1],r=e[e.length-2];return vn(n,r)>=t},_n=e=>e[0].length<=1||((e,t=.01)=>{const n=e[0];return n.length<=1||!(n.length<=3&&((e,t)=>{for(let n=0;n<e.length;n++)for(let r=n+1;r<e.length;r++)if(vn(e[n],e[r])<t)return!0;return!1})(n,t))})(e),En="_splitter",Sn=({draw:e,polygonFeature:t,feature:n})=>{const r=((e,t)=>{const n=t.geometry?.coordinates;return!(!n||n.length<2||!yn(e,{geometry:t.geometry}))})(t,n);return e.setDrawingPreviewProperty("splitter",r?"valid":"invalid"),r},xn=()=>"undefined"!=typeof navigator&&/mac/i.test(navigator.userAgentData?.platform||navigator.platform||""),In=new Set(["edit_vertex","edit_point"]),wn=e=>In.has(e),Pn=xn()?"<kbd>Command</kbd> + <kbd>Z</kbd>":"<kbd>Ctrl</kbd> + <kbd>Z</kbd>",Cn=xn()?"<kbd>Option</kbd>":"<kbd>Alt</kbd>",Tn="top-middle",Mn=(e,t="actions")=>({mobile:{slot:t,showLabel:e},tablet:{slot:t,showLabel:e},desktop:{slot:t,showLabel:e}}),Ln={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:i},InitComponent:({appState:e,appConfig:t,mapState:o,pluginConfig:i,pluginState:a,services:l,mapProvider:c,buttonConfig:d,setApplicationMode:u,clearApplicationMode:p})=>{const{eventBus:h,hints:f,symbolRegistry:g}=l,{crossHair:m}=o;_e({mapState:o,pluginState:a,services:l,mapProvider:c,spatialListRegistry:e.spatialListRegistry,viewportRef:e.layoutRefs.viewportRef});const y=(0,r.li)(!1);y.current=xe({appState:e,pluginState:a})||Se(a.mode)&&"keyboard"===e.interfaceType,function({mapState:e,pluginConfig:t,pluginState:o,mapProvider:i,eventBus:a,symbolRegistry:l}){const c=(0,r.li)(!0),d=(0,r.li)(!1);(0,r.vJ)(()=>{e.isMapReady&&!d.current&&(d.current=!0,(async()=>{if(await new Promise(e=>setTimeout(e,0)),!c.current)return;const r=await(async(e,t)=>{switch(e.name){case"MapLibreProvider":{const{MaplibreDrawAdapter:r}=await n.e(402).then(n.bind(n,278));return new r(e,t)}case"OpenLayersProvider":{const{OLDrawAdapter:r}=await n.e(402).then(n.bind(n,308));return new r(e,t)}default:throw new Error(`No draw adapter available for map provider "${e.name}"`)}})(i,{mapStyle:e.mapStyle,snapLayers:t.snapLayers,pluginConfig:t,events:s,eventBus:a,symbolRegistry:l});c.current?(i.draw=r,o.dispatch({type:"SET_HAS_SNAP_LAYERS",payload:t.snapLayers?.length>0}),a.emit("draw:ready")):r.remove()})().catch(e=>ge.error("[draw] failed to load the draw adapter",e)))},[e.isMapReady]),(0,r.vJ)(()=>()=>{c.current=!1,i.draw?.remove(),i.draw=null,i.activeMoveTarget=null},[])}({mapState:o,pluginConfig:i,pluginState:a,mapProvider:c,eventBus:h,symbolRegistry:g}),(0,r.Nf)(()=>{if(a.mode)return u(ae),()=>p(ae);p(ae)},[a.mode]),(0,r.vJ)(()=>{const e=null!==a.mode&&"edit_vertex"!==a.mode;return h.emit(s.MAP_SET_SPATIAL_LIST_SUPPRESSED,{suppressed:e}),()=>{h.emit(s.MAP_SET_SPATIAL_LIST_SUPPRESSED,{suppressed:!1})}},[a.mode,h]),(0,r.vJ)(()=>{if(!y.current)return;const e=m.isVisible;return m.fixAtCenter(),()=>{e||y.current||m.hide()}},[a.mode,e.interfaceType,e.expandedButtons]),(0,r.vJ)(()=>{["edit_vertex","edit_point","draw_polygon","draw_line","draw_point"].includes(a.mode)&&c.draw&&c.draw.setInterfaceType(e.interfaceType)},[e.interfaceType,a.mode]),(0,r.vJ)(()=>{if(c.draw)return he({appState:e,appConfig:t,mapState:o,mapProvider:c,buttonConfig:d,pluginState:a,eventBus:h,hints:f})},[c,e,a])},applicationModes:{[ae]:{include:["mapStyles","mapControls","scaleBar"]}},buttons:[{id:"drawCancel",label:"Cancel",variant:"tertiary",exclusiveSlot:!0,hiddenWhen:({pluginState:e})=>!e.mode,...Mn(!0)},{id:"drawAddPoint",label:"Add point",variant:"primary",exclusiveSlot:!0,hiddenWhen:({appState:e,pluginState:t})=>!xe({appState:e,pluginState:t}),enableWhen:({pluginState:e})=>e.canAddPoint,...Mn(!0)},{id:"drawDone",label:"Done",variant:"primary",exclusiveSlot:!0,hiddenWhen:({pluginState:e})=>!(["draw_polygon","draw_line"].includes(e.mode)||wn(e.mode)),enableWhen:({pluginState:e})=>{const{mode:t,geometryValid:n}=e;return(["draw_polygon","draw_line"].includes(t)||wn(t))&&n},...Mn(!0)},{id:"drawUndo",label:"Undo",iconId:"undo",hiddenWhen:({pluginState:e})=>!(["draw_polygon","draw_line"].includes(e.mode)||wn(e.mode)),enableWhen:({pluginState:e})=>["draw_polygon","draw_line"].includes(e.mode)?e.numVertices>0:e.undoStackLength>0,...Mn(!1,Tn)},{id:"drawSnap",label:"Snap",iconId:"magnet",hiddenWhen:({pluginState:e})=>!e.mode||!e.hasSnapLayers,pressedWhen:({pluginState:e})=>!!e.snap,...Mn(!0,Tn)},{id:"drawDeletePoint",label:"Delete point",iconId:"trash",enableWhen:({pluginState:e})=>!(e.selectedVertexIndex<0)&&("Polygon"===e.feature?.geometry?.type?e.numVertices>3:e.numVertices>2),hiddenWhen:({pluginState:e})=>"edit_vertex"!==e.mode,...Mn(!1,Tn)}],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:`${Cn} + <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:Pn}],icons:[{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:Ce,newLine:Te,newPoint:({appState:e,appConfig:t,pluginConfig:n,pluginState:r,mapState:o,mapProvider:i,services:s},a,l={})=>{const{dispatch:c}=r,{draw:d}=i,{eventBus:u}=s;if(!d)return;u.emit("draw:started",{mode:"draw_point"});const p=void 0===l.snapLayers?n.snapLayers??null:l.snapLayers;d.setSnapLayers(p),c({type:"SET_HAS_SNAP_LAYERS",payload:p?.length>0});const{properties:h,onGeometryChange:f,...g}=l;d._geometryValidator=f??n.onGeometryChange;const m={};le.forEach(e=>{void 0!==g[e]&&(m[e]=g[e],delete g[e])}),d.changeMode("draw_point",{container:e.layoutRefs.viewportRef.current,addVertexButtonId:`${t.id}-draw-add-point`,interfaceType:e.interfaceType,crossHair:o.crossHair,getSnapEnabled:()=>d.isSnapEnabled(),featureId:a,...g,properties:{...h,...m}}),c({type:"SET_MODE",payload:"draw_point"})},editFeature:({appState:e,appConfig:t,mapState:n,pluginConfig:r,pluginState:o,mapProvider:i,services:s},a,l={})=>{const{dispatch:c}=o,{draw:d}=i,{eventBus:u}=s;if(!d)return!1;const p=d.get(a);if(!p)return!1;d._geometryValidator=l.onGeometryChange??r.onGeometryChange;const h="Point"===p.geometry.type?"edit_point":"edit_vertex";u.emit("draw:editstart",{mode:{LineString:"edit_line",Polygon:"edit_polygon",Point:"edit_point"}[p.geometry.type]});const f=void 0===l.snapLayers?r.snapLayers??null:l.snapLayers;d.setSnapLayers(f),c({type:"SET_HAS_SNAP_LAYERS",payload:f?.length>0}),d.changeMode(h,{container:e.layoutRefs.viewportRef.current,deleteVertexButtonId:`${t.id}-draw-delete-point`,undoButtonId:`${t.id}-draw-undo`,isPanEnabled:"keyboard"!==e.interfaceType,interfaceType:e.interfaceType,scale:Z[n.mapSize],featureId:a,getSnapEnabled:()=>d.isSnapEnabled()});const g=d.get(a);c({type:"SET_FEATURE",payload:{feature:g,tempFeature:g}}),c({type:"SET_MODE",payload:h});const{valid:m}=K(g,{phase:"edit-start",mode:h},{onGeometryChange:d._geometryValidator});return c({type:"SET_GEOMETRY_VALID",payload:m}),d.setInvalid?.(!m),!0},addFeature:({mapProvider:e,services:t},n)=>{const{draw:r}=e,{eventBus:o}=t;if(!r)return;const{stroke:i,fill:s,strokeWidth:a,properties:l,...c}=n,d={type:"Feature",...c,properties:{...l,...we({stroke:i,fill:s,strokeWidth:a})}};(e=>Me.has(e.geometry?.type)&&void 0!==e.geometry?.coordinates)(d)?(r.add(d),o.emit("draw:add",ce(d))):ge.warn("addFeature: ignoring invalid GeoJSON feature",d)},setStyle:({mapProvider:e,services:t},n,r={})=>{const{draw:o}=e,{eventBus:i}=t;if(!o)return!1;if(!o.get(n))return ge.warn("setStyle: no feature found for id",n),!1;const s={},a={};for(const[c,d]of Object.entries(r))(Le.has(c)?s:a)[c]=d;const l=(e=>{const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t})({...we(s),...a});return o.setStyle(n,l),i.emit("draw:stylechange",{featureId:n,properties:l}),!0},deleteFeature:({mapProvider:e,services:t},n)=>{const{draw:r}=e,{eventBus:o}=t;r&&(r.delete(n),o.emit("draw:delete",{featureId:n}))},split:({appState:e,appConfig:t,pluginState:n,mapState:r,mapProvider:o,services:i},s,l={})=>{const{dispatch:c}=n,{draw:d}=o,{eventBus:u}=i;if(!d)return;const p=d.get(s),h=d._geometryValidator;d._geometryValidator=(({draw:e,dispatch:t,polygonFeature:n})=>({feature:r,phase:o})=>{let i;if("preview"===o)i=Sn({draw:e,polygonFeature:n,feature:r});else{if(!o?.startsWith("commit-"))return{valid:!0};i=(({draw:e,dispatch:t,polygonFeature:n,feature:r})=>{const o=Sn({draw:e,polygonFeature:n,feature:r});return t({type:"SET_ACTION",payload:{name:"split",isValid:o}}),t({type:"SET_GEOMETRY_VALID",payload:o}),e.setGeometryValid(o),o})({draw:e,dispatch:t,polygonFeature:n,feature:r})}return i?{valid:!0}:{valid:!1,reason:"Line does not split the shape into two parts"}})({draw:d,dispatch:c,polygonFeature:p});const f=["stroke-inactive.cold",...l.snapLayers||[]];d.setSnapLayers(f),c({type:"SET_HAS_SNAP_LAYERS",payload:!0}),d.changeMode("draw_line",{container:e.layoutRefs.viewportRef.current,addVertexButtonId:`${t.id}-draw-add-point`,interfaceType:e.interfaceType,crossHair:r?.crossHair,getSnapEnabled:()=>d.isSnapEnabled(),featureId:En,properties:{splitter:"invalid"}});const g=()=>{d._geometryValidator=h,d.off(a.CREATE,m),d.off(a.CANCEL,y)},m=e=>{g(),d.delete(En);const t=yn(p,e);c({type:"SET_ACTION",payload:{name:"split",isValid:!!t}}),t&&u.emit("draw:split",{originalFeatureId:s,featureCollection:t})},y=()=>{g()};d.on(a.CREATE,m),d.on(a.CANCEL,y),c({type:"SET_MODE",payload:"draw_line"}),c({type:"SET_ACTION",payload:{name:"split"}})},merge:({mapProvider:e,services:t},n)=>{const{draw:r}=e,{eventBus:o}=t;if(!r)return null;const i=(e=>{let t;try{t=function(e,t={}){const n=[];if(I(e,e=>{n.push(e.coordinates)}),n.length<2)throw new Error("Must have at least 2 geometries");const r=((e,...t)=>un.run("union",e,t))(n[0],...n.slice(1));return 0===r.length?null:1===r.length?p(r[0],t.properties):function(e,t,n={}){return d({type:"MultiPolygon",coordinates:e},t,n)}(r,t.properties)}(f(e))}catch{return null}if("Polygon"!==t?.geometry?.type)return null;const n=e[0].id??e[0].properties?.id??"poly";return p(t.geometry.coordinates,{...e[0].properties,id:n},{id:n})})(n.map(e=>r.get(e)));return i&&o.emit("draw:merge",{originalFeatureIds:n,feature:i}),i}}};var An=Object.freeze({__proto__:null,manifest:Ln})},106:(e,t,n)=>{n.d(t,{a:()=>s,b:()=>h,c:()=>i,d:()=>f,e:()=>y,f:()=>v,g:()=>a,h:()=>l,i:()=>c,r:()=>d,s:()=>u});var r=n(666);const o=r.S.touchTargetSize/2,i=e=>{let t=e.querySelector("[data-im-draw-touch-target]");return t||(e.insertAdjacentHTML("beforeend",function(){const e=r.S.touchTargetSize;return`\n <svg width='${e}' height='${e}' viewBox='0 0 48 48' fill-rule='evenodd'\n style='display:none;position:absolute;top:0;left:0;margin:${o}px 0 0 -${o}px;cursor:grab'\n class='im-draw-touch-target' data-im-draw-touch-target>\n <circle cx='24' cy='24' r='24' fill='var(--draw-halo, #000)'/>\n <path d="M37.543 25H34a1 1 0 1 1 0-2h3.629l-.836-.837a1 1 0 0 1 1.414-1.414l2.5 2.501A1 1 0 0 1 41 24a1 1 0 0 1-.487.858l-2.306 2.306a1 1 0 0 1-1.414-1.414l.75-.75zM23 10.414l-.793.793a1 1 0 0 1-1.414-1.414l2.5-2.5C23.481 7.105 23.734 7 24 7s.519.105.707.293l2.5 2.5a1 1 0 0 1-1.414 1.414L25 10.414V14a1 1 0 1 1-2 0v-3.586zM7 24a1 1 0 0 1 .293-.75l2.5-2.501a1 1 0 0 1 1.414 1.414l-.836.837H14a1 1 0 1 1 0 2h-3.543l.75.75a1 1 0 0 1-1.414 1.414l-2.306-2.306A1 1 0 0 1 7 24zm16.293 16.707l-2.5-2.5a1 1 0 0 1 1.414-1.414l.793.793V34a1 1 0 1 1 2 0v3.586l.793-.793a1 1 0 0 1 1.414 1.414l-2.5 2.5c-.188.188-.441.293-.707.293s-.519-.105-.707-.293zM24 20c2.208 0 4 1.792 4 4s-1.792 4-4 4-4-1.792-4-4 1.792-4 4-4z" fill='var(--draw-bg, #fff)'/>\n </svg>\n `}()),t=e.querySelector("[data-im-draw-touch-target]")),t},s=(e,t)=>{e&&(e.style.setProperty("--draw-halo",t.editActive),e.style.setProperty("--draw-bg",t.editHalo),e.style.setProperty("--draw-primary",t.editVertex))},a=(e,t)=>{t&&e&&(e.style.left=`${t.x}px`,e.style.top=`${t.y}px`,e.style.display="block")},l=e=>{e&&(e.style.display="none")},c=e=>{if(!e)return!1;const t=e.parentNode;return t instanceof globalThis.SVGElement||null!=t?.ownerSVGElement},d=(e,t={})=>{const n=e?.mapColorScheme??"light",o=e?.id??null,i=e=>((e,t,n=null)=>"object"!=typeof e||null===e?e:n&&void 0!==e[n]?e[n]:void 0!==e[t]?e[t]:void 0!==e.light?e.light:Object.values(e)[0])(t[e]??r.C[e],n,o);return{editStroke:i("editStroke"),editFill:i("editFill"),editVertex:i("editVertex"),editMidpoint:i("editMidpoint"),editActive:i("editActive"),editHalo:i("editHalo"),invalidStroke:i("invalidStroke"),splitValid:i("splitValid"),splitInvalid:i("splitInvalid"),shapeStroke:i("shapeStroke"),strokeWidth:t.strokeWidth??r.S.strokeWidth,shapeFill:i("shapeFill"),snapVertex:i("snapVertex"),snapEdge:i("snapEdge"),mapStyleId:o}},u=(e,t,n)=>{const r=(e,t)=>e[0]===t[0]&&e[1]===t[1],o=t.filter(t=>{const o=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);let s=!1;return s="ArrowUp"===n?t[1]<=e[1]&&i>=o:"ArrowDown"===n?t[1]>e[1]&&i>=o:"ArrowLeft"===n?t[0]<=e[0]&&i<o:"ArrowRight"!==n||t[0]>e[0]&&i<o,s&&!r(t,e)});o.length||o.push(e);const i=t=>Math.hypot(e[0]-t[0],e[1]-t[1]),s=o.reduce((e,t)=>i(t)<i(e)?t:e,o[0]);return t.findIndex(e=>r(e,s))},p=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"]),h=e=>{e.altKey&&p.has(e.key)&&e.stopPropagation()},f=e=>{const t=[];return{push(n){t.push(n),e(t.length)},pop(){const n=t.pop();return e(t.length),n},clear(){t.length=0,e(t.length)},get length(){return t.length}}},g=e=>"function"==typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,16),m=e=>"function"==typeof cancelAnimationFrame?cancelAnimationFrame(e):clearTimeout(e),y=({onChange:e,validate:t=r.x})=>{let n=!1,o=null,i=null;const s=()=>{null!=o&&(m(o),o=null),i=null},a=(t,r)=>{t!==n&&(n=t,e(t,r??null))},l=()=>{if(o=null,!i)return;const{feature:e,context:n,onGeometryChange:r}=i,{valid:s,reason:l}=t(e,n,{onGeometryChange:r});a(!s,l)};return{update({feature:e,context:n={},numVertices:r,onGeometryChange:c}){const d={...n,numVertices:r},u=t(e,d);return u.valid?"function"!=typeof c?(s(),void a(!1,null)):(i={feature:e,context:d,onGeometryChange:c},void(null==o&&(o=g(l)))):(s(),void a(!0,u.reason))},set(e,t){s(),a(e,t??null)},refresh(){e(n,null)},destroy(){s()}}},v=({onStrokeChange:e,onPlaceChange:t})=>{const n=e=>{let t=!1;return(n,r)=>{n!==t&&(t=n,e(n,r??null))}},o=n(e),i=n(t);let s=!1,a=null,l=null,c=null;const d=()=>{null!=l&&(m(l),l=null),c=null},u=(e,t,n,o,i)=>{const l=(t.numVertices??0)<o?{valid:!0}:(0,r.y)(e,{...t,phase:"preview"},{rules:n});i(!l.valid||s,l.valid?a:l.reason)},p=()=>{if(!c)return;const{feature:e,context:t}=c,n=r.M[e?.geometry?.type]??0;u(e,t,r.L,n,o),u(e,t,r.H,0,i)},h=()=>{if(l=null,!c)return;const{feature:e,context:t,onGeometryChange:n}=c,o=(0,r.y)(e,{...t,phase:"preview"},{rules:[],onGeometryChange:n});s=!o.valid,a=o.reason,p()};return{update({feature:e,context:t={},numVertices:n,onGeometryChange:r}){c={feature:e,context:{...t,numVertices:n},onGeometryChange:r},p(),"function"==typeof r&&null==l&&(l=g(h))},reset(){d(),s=!1,a=null,o(!1,null),i(!1,null)},destroy(){d()}}}},706:(e,t,n)=>{n.r(t),n.d(t,{manifest:()=>he});var r=n(452);n(247);const o={MAP_SET_SIZE:"map:setsize",MAP_SET_ACTIVE_ITEM:"map:setactiveitem",MAP_SELECT_ITEM:"map:selectitem",MAP_STYLE_CHANGE:"map:stylechange",MAP_MOVE_END:"map:moveend",MAP_DATA_CHANGE:"map:datachange",MAP_CLICK:"map:click"};function i(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(!d(e[0])||!d(e[1]))throw new Error("coordinates must contain numbers");return i({type:"Point",coordinates:e},t,n)}function a(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return i({type:"LineString",coordinates:e},t,n)}function l(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,n={}){return i({type:"MultiLineString",coordinates:e},t,n)}function d(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}const u=11102230246251565e-32,p=134217729,h=(3+8*u)*u;function f(e,t,n,r,o){let i,s,a,l,c=t[0],d=r[0],u=0,p=0;d>c==d>-c?(i=c,c=t[++u]):(i=d,d=r[++p]);let h=0;if(u<e&&p<n)for(d>c==d>-c?(s=c+i,a=i-(s-c),c=t[++u]):(s=d+i,a=i-(s-d),d=r[++p]),i=s,0!==a&&(o[h++]=a);u<e&&p<n;)d>c==d>-c?(s=i+c,l=s-i,a=i-(s-l)+(c-l),c=t[++u]):(s=i+d,l=s-i,a=i-(s-l)+(d-l),d=r[++p]),i=s,0!==a&&(o[h++]=a);for(;u<e;)s=i+c,l=s-i,a=i-(s-l)+(c-l),c=t[++u],i=s,0!==a&&(o[h++]=a);for(;p<n;)s=i+d,l=s-i,a=i-(s-l)+(d-l),d=r[++p],i=s,0!==a&&(o[h++]=a);return 0===i&&0!==h||(o[h++]=i),h}function g(e){return new Float64Array(e)}const m=g(4),y=g(8),v=g(12),b=g(16),_=g(4);function E(e,t,n,r,o,i){const s=(t-i)*(n-o),a=(e-o)*(r-i),l=s-a,c=Math.abs(s+a);return Math.abs(l)>=33306690738754716e-32*c?l:-function(e,t,n,r,o,i,s){let a,l,c,d,u,g,E,S,x,I,w,P,C,T,M,L,A,O;const k=e-o,D=n-o,R=t-i,N=r-i;T=k*N,g=p*k,E=g-(g-k),S=k-E,g=p*N,x=g-(g-N),I=N-x,M=S*I-(T-E*x-S*x-E*I),L=R*D,g=p*R,E=g-(g-R),S=R-E,g=p*D,x=g-(g-D),I=D-x,A=S*I-(L-E*x-S*x-E*I),w=M-A,u=M-w,m[0]=M-(w+u)+(u-A),P=T+w,u=P-T,C=T-(P-u)+(w-u),w=C-L,u=C-w,m[1]=C-(w+u)+(u-L),O=P+w,u=O-P,m[2]=P-(O-u)+(w-u),m[3]=O;let F=function(e,t){let n=t[0];for(let r=1;r<4;r++)n+=t[r];return n}(0,m),V=22204460492503146e-32*s;if(F>=V||-F>=V)return F;if(u=e-k,a=e-(k+u)+(u-o),u=n-D,c=n-(D+u)+(u-o),u=t-R,l=t-(R+u)+(u-i),u=r-N,d=r-(N+u)+(u-i),0===a&&0===l&&0===c&&0===d)return F;if(V=11093356479670487e-47*s+h*Math.abs(F),F+=k*d+N*a-(R*c+D*l),F>=V||-F>=V)return F;T=a*N,g=p*a,E=g-(g-a),S=a-E,g=p*N,x=g-(g-N),I=N-x,M=S*I-(T-E*x-S*x-E*I),L=l*D,g=p*l,E=g-(g-l),S=l-E,g=p*D,x=g-(g-D),I=D-x,A=S*I-(L-E*x-S*x-E*I),w=M-A,u=M-w,_[0]=M-(w+u)+(u-A),P=T+w,u=P-T,C=T-(P-u)+(w-u),w=C-L,u=C-w,_[1]=C-(w+u)+(u-L),O=P+w,u=O-P,_[2]=P-(O-u)+(w-u),_[3]=O;const B=f(4,m,4,_,y);T=k*d,g=p*k,E=g-(g-k),S=k-E,g=p*d,x=g-(g-d),I=d-x,M=S*I-(T-E*x-S*x-E*I),L=R*c,g=p*R,E=g-(g-R),S=R-E,g=p*c,x=g-(g-c),I=c-x,A=S*I-(L-E*x-S*x-E*I),w=M-A,u=M-w,_[0]=M-(w+u)+(u-A),P=T+w,u=P-T,C=T-(P-u)+(w-u),w=C-L,u=C-w,_[1]=C-(w+u)+(u-L),O=P+w,u=O-P,_[2]=P-(O-u)+(w-u),_[3]=O;const U=f(B,y,4,_,v);T=a*d,g=p*a,E=g-(g-a),S=a-E,g=p*d,x=g-(g-d),I=d-x,M=S*I-(T-E*x-S*x-E*I),L=l*c,g=p*l,E=g-(g-l),S=l-E,g=p*c,x=g-(g-c),I=c-x,A=S*I-(L-E*x-S*x-E*I),w=M-A,u=M-w,_[0]=M-(w+u)+(u-A),P=T+w,u=P-T,C=T-(P-u)+(w-u),w=C-L,u=C-w,_[1]=C-(w+u)+(u-L),O=P+w,u=O-P,_[2]=P-(O-u)+(w-u),_[3]=O;const G=f(U,v,4,_,b);return b[G-1]}(e,t,n,r,o,i,c)}function S(e,t){var n,r,o,i,s,a,l,c,d,u=0,p=e[0],h=e[1],f=t.length;for(n=0;n<f;n++){r=0;var g=t[n],m=g.length-1;if((c=g[0])[0]!==g[m][0]&&c[1]!==g[m][1])throw new Error("First and last coordinates in a ring must be the same");for(i=c[0]-p,s=c[1]-h;r<m;r++){if(a=(d=g[r+1])[0]-p,l=d[1]-h,0===s&&0===l){if(a<=0&&i>=0||i<=0&&a>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(0===(o=E(i,a,s,l,0,0)))return 0;(o>0&&l>0&&s<=0||o<0&&l<=0&&s>0)&&u++}c=d,s=l,i=a}}return u%2!=0}function x(e){return"Feature"===e.type?e.geometry:e}function I(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const r=function(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}(e),o=x(t),i=o.type,s=t.bbox;let a=o.coordinates;if(s&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(r,s))return!1;"Polygon"===i&&(a=[a]);let l=!1;for(var c=0;c<a.length;++c){const e=S(r,a[c]);if(0===e)return!n.ignoreBoundary;e&&(l=!0)}return l}class w{constructor(e=[],t=P){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,r=t[e];for(;e>0;){const o=e-1>>1,i=t[o];if(n(r,i)>=0)break;t[e]=i,e=o}t[e]=r}_down(e){const{data:t,compare:n}=this,r=this.length>>1,o=t[e];for(;e<r;){let r=1+(e<<1),i=t[r];const s=r+1;if(s<this.length&&n(t[s],i)<0&&(r=s,i=t[s]),n(i,o)>=0)break;t[e]=i,e=r}t[e]=o}}function P(e,t){return e<t?-1:e>t?1:0}function C(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function T(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class M{constructor(e,t,n,r){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=n,this.eventId=r,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}let L=0,A=0,O=0;function k(e,t){const n="Feature"===e.type?e.geometry:e;let r=n.coordinates;"Polygon"!==n.type&&"MultiLineString"!==n.type||(r=[r]),"LineString"===n.type&&(r=[[r]]);for(let o=0;o<r.length;o++)for(let e=0;e<r[o].length;e++){let n=r[o][e][0],i=null;A+=1;for(let s=0;s<r[o][e].length-1;s++){i=r[o][e][s+1];const a=new M(n,L,A,O),l=new M(i,L,A,O+1);a.otherEvent=l,l.otherEvent=a,C(a,l)>0?(l.isLeftEndpoint=!0,a.isLeftEndpoint=!1):(a.isLeftEndpoint=!0,l.isLeftEndpoint=!1),t.push(a),t.push(l),n=i,O+=1}}L+=1}class D{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function R(e,t){if(null===e||null===t)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const n=e.leftSweepEvent.p.x,r=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,i=e.rightSweepEvent.p.y,s=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,l=t.rightSweepEvent.p.x,c=t.rightSweepEvent.p.y,d=(c-a)*(o-n)-(l-s)*(i-r);if(0===d)return!1;const u=((l-s)*(r-a)-(c-a)*(n-s))/d,p=((o-n)*(r-a)-(i-r)*(n-s))/d;return u>=0&&u<=1&&p>=0&&p<=1&&[n+u*(o-n),r+u*(i-r)]}function N(e,t,n={}){const{removeDuplicates:r=!0,ignoreSelfIntersections:o=!0}=n;let a=[];"FeatureCollection"===e.type?a=a.concat(e.features):"Feature"===e.type?a.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||a.push(i(e)),"FeatureCollection"===t.type?a=a.concat(t.features):"Feature"===t.type?a.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||a.push(i(t));const c=function(e,t){const n=new w([],C);return function(e,t){if("FeatureCollection"===e.type){const n=e.features;for(let e=0;e<n.length;e++)k(n[e],t)}else k(e,t)}(e,n),function(e,t){t=t||!1;const n=[],r=new w([],T);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const e=new D(o);for(let i=0;i<r.data.length;i++){const s=r.data[i];if(t&&s.leftSweepEvent.featureId===o.featureId)continue;const a=R(e,s);!1!==a&&n.push(a)}r.push(e)}else!1===o.isLeftEndpoint&&r.pop()}return n}(n,t)}(l(a),o);let d=[];if(r){const e={};c.forEach(t=>{const n=t.join(",");e[n]||(e[n]=!0,d.push(t))})}else d=c;return l(d.map(e=>s(e)))}function F(e,t,n){if(null!==e)for(var r,o,i,s,a,l,c,d,u=0,p=0,h=e.type,f="FeatureCollection"===h,g="Feature"===h,m=f?e.features.length:1,y=0;y<m;y++){a=(d=!!(c=f?e.features[y].geometry:g?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v<a;v++){var b=0,_=0;if(null!==(s=d?c.geometries[v]:c)){l=s.coordinates;var E=s.type;switch(u=0,E){case null:break;case"Point":if(!1===t(l,p,y,b,_))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===t(l[r],p,y,b,_))return!1;p++,"MultiPoint"===E&&b++}"LineString"===E&&b++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(o=0;o<l[r].length-u;o++){if(!1===t(l[r][o],p,y,b,_))return!1;p++}"MultiLineString"===E&&b++,"Polygon"===E&&_++}"Polygon"===E&&b++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(_=0,o=0;o<l[r].length;o++){for(i=0;i<l[r][o].length-u;i++){if(!1===t(l[r][o][i],p,y,b,_))return!1;p++}_++}b++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(!1===F(s.geometries[r],t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function V(e,t){!function(e,t){var n,r,o,i,s,a,l,c,d,u,p=0,h="FeatureCollection"===e.type,f="Feature"===e.type,g=h?e.features.length:1;for(n=0;n<g;n++){for(a=h?e.features[n].geometry:f?e.geometry:e,c=h?e.features[n].properties:f?e.properties:{},d=h?e.features[n].bbox:f?e.bbox:void 0,u=h?e.features[n].id:f?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,o=0;o<s;o++)if(null!==(i=l?a.geometries[o]:a))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,d,u))return!1;break;case"GeometryCollection":for(r=0;r<i.geometries.length;r++)if(!1===t(i.geometries[r],p,c,d,u))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,d,u))return!1;p++}}(e,function(e,n,r,o,s){var a,l=null===e?null:e.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return!1!==t(i(e,r,{bbox:o,id:s}),n,0)&&void 0}switch(l){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var c=0;c<e.coordinates.length;c++){var d=e.coordinates[c];if(!1===t(i({type:a,coordinates:d},r),n,c))return!1}})}function B(e,t={}){const n=x(e);switch(t.properties||"Feature"!==e.type||(t.properties=e.properties),n.type){case"Polygon":return function(e,t={}){return U(x(e).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}(n,t);case"MultiPolygon":return function(e,t={}){const n=x(e).coordinates,r=t.properties?t.properties:"Feature"===e.type?e.properties:{},o=[];return n.forEach(e=>{o.push(U(e,r))}),l(o)}(n,t);default:throw new Error("invalid poly")}}function U(e,t){return e.length>1?c(e,t):a(e[0],t)}function G(e,t){for(let n=0;n<e.coordinates.length-1;n++)if(H(e.coordinates[n],e.coordinates[n+1],t.coordinates))return!0;return!1}function j(e,t,n){for(const r of t.coordinates)if(I(r,e))return!0;return N(t,B(e),{ignoreSelfIntersections:n}).features.length>0}function H(e,t,n){const r=n[0]-e[0],o=n[1]-e[1],i=t[0]-e[0],s=t[1]-e[1];return 0===r*s-o*i&&(Math.abs(i)>=Math.abs(s)?i>0?e[0]<=n[0]&&n[0]<=t[0]:t[0]<=n[0]&&n[0]<=e[0]:s>0?e[1]<=n[1]&&n[1]<=t[1]:t[1]<=n[1]&&n[1]<=e[1])}var $=function(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const n=[1/0,1/0,-1/0,-1/0];return F(e,e=>{n[0]>e[0]&&(n[0]=e[0]),n[1]>e[1]&&(n[1]=e[1]),n[2]<e[0]&&(n[2]=e[0]),n[3]<e[1]&&(n[3]=e[1])}),n};function Y(e){const t=e.geometry||e;switch(t.type){case"Polygon":return function(e,t,n={}){for(const r of e){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<r[r.length-1].length;e++)if(r[r.length-1][e]!==r[0][e])throw new Error("First and last Position are not equivalent.")}return i({type:"Polygon",coordinates:e},t,n)}(t.coordinates);case"MultiPolygon":return function(e,t,n={}){return i({type:"MultiPolygon",coordinates:e},void 0,n)}(t.coordinates);case"LineString":return a(t.coordinates);case"MultiLineString":return c(t.coordinates);case"Point":return s(t.coordinates);case"MultiPoint":return function(e,t,n={}){return i({type:"MultiPoint",coordinates:e},void 0,n)}(t.coordinates);default:throw new Error(`Unsupported geometry type: ${t.type}`)}}function z(e,t){return t.some(t=>!function(e,t,{ignoreSelfIntersections:n=!0}={ignoreSelfIntersections:!0}){let r=!0;return V(e,e=>{V(t,t=>{if(!1===r)return!1;r=function(e,t,n){switch(e.type){case"Point":switch(t.type){case"Point":return r=e.coordinates,o=t.coordinates,!(r[0]===o[0]&&r[1]===o[1]);case"LineString":return!G(t,e);case"Polygon":return!I(e,t)}break;case"LineString":switch(t.type){case"Point":return!G(e,t);case"LineString":return!function(e,t,n){return N(e,t,{ignoreSelfIntersections:n}).features.length>0}(e,t,n);case"Polygon":return!j(t,e,n)}break;case"Polygon":switch(t.type){case"Point":return!I(t,e);case"LineString":return!j(e,t,n);case"Polygon":return!function(e,t,n){for(const r of e.coordinates[0])if(I(r,t))return!0;for(const r of t.coordinates[0])if(I(r,e))return!0;return N(B(e),B(t),{ignoreSelfIntersections:n}).features.length>0}(t,e,n)}}var r,o;return!1}(e.geometry,t.geometry,n)})}),r}(Y(t),Y(e)))}function K(e){if(e.length<2)return!1;if(e.some(e=>{return t=e.geometry?.type,!("Polygon"===t||"MultiPolygon"===t);var t}))return!1;const t=new Set([0]);let n=!0;for(;n;){n=!1;for(let r=1;r<e.length;r++){if(t.has(r))continue;const o=[...t].map(t=>e[t]);z(e[r],o)&&(t.add(r),n=!0)}}return t.size===e.length}const W={".cold":".hot",".hot":".cold"},J=e=>{for(const[t,n]of Object.entries(W))if(e.endsWith(t))return`${e.slice(0,-t.length)}${n}`;return null},q=e=>{const t={};for(const n of e){t[n.layerId]=n;const e=J(n.layerId);e&&(t[e]=n)}return t},X=(e,t,n)=>{try{return e?.getFeaturesAtPoint(t,n)||[]}catch(e){return console.warn("Feature query failed:",e),[]}},Z=e=>{const t=e.geometry?.type;return"Point"===t||"MultiPoint"===t},Q=(e,t)=>e?"string"==typeof e?e.trim():"object"==typeof e?t&&e[t]?e[t]:Object.values(e)[0]??null:null:null,ee=e=>!(!e.label||e.symbol||e.svgContent||null!==e.symbol&&null!==e.svgContent),te={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}},ne={small:1,medium:1.5,large:2},re=(e,t,n,r)=>({featureId:e,multiSelect:t,layerId:n.layerId,idProperty:n.idProperty,properties:r.properties,geometry:r.geometry}),oe=e=>{const t=e.closest(".im-c-viewport__markers");if(!t)return!1;const n=t.getBoundingClientRect(),{left:r,right:o,top:i,bottom:s}=e.getBoundingClientRect();return o>n.left&&r<n.right&&s>n.top&&i<n.bottom},ie=(e,t,n)=>{const{x:r,y:o}=e.mapToScreen(n);return{x:r*ne[t],y:o*ne[t]}},se=(e,t,n,r,o)=>{const i=t[e.layer?.id];if(!i?.labelProperty)return null;const s=((e,t)=>e.properties?.[t.idProperty]??e.id)(e,i),a=null==s?null:String(s);if(null==a||n.has(a))return null;n.add(a);const l={id:a,label:e.properties?.[i.labelProperty]??a,isMarker:!1,featureId:s,layerId:i.layerId,idProperty:i.idProperty,geometry:e.geometry,properties:e.properties},c=function(e){try{const[t,n,r,o]=$(Y(e));return[(t+r)/2,(n+o)/2]}catch{return null}}(e);return c&&Object.assign(l,ie(r,o,c)),l};const ae='[role="listbox"], [role="option"]',le=e=>!("Enter"!==e.key||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey),ce=({appState:e,pluginState:t})=>{return!!e.expandedButtons?.has("mapControls")||"touch"===e.interfaceType&&!1!==t.touchTarget&&(n=t.interactionModes,!(1===n?.length&&n.includes("selectMarker")));var n},de={ENABLE:(e,t)=>({...e,...t,enabled:!0}),DISABLE:e=>({...e,enabled:!1,selectedFeatures:[],selectedMarkers:[],listboxActiveItem:null}),TOGGLE_SELECTED_FEATURES:(e,t)=>{const{featureId:n,multiSelect:r,layerId:o,idProperty:i,addToExisting:s=!0,replaceAll:a=!1,properties:l,geometry:c}=t,d=Array.isArray(e.selectedFeatures)?e.selectedFeatures:[],u=d.findIndex(e=>e.featureId===n&&e.layerId===o);if(!1===s){const t=d.filter((e,t)=>t!==u);return{...e,selectedFeatures:t}}const p={featureId:n,layerId:o,idProperty:i,properties:l,geometry:c};let h;if(r&&!a){const e=[...d];-1===u?e.push(p):e.splice(u,1),h=e}else h=-1!==u&&1===d.length?[]:[p];return{...e,selectedFeatures:h,selectedMarkers:r&&!a?e.selectedMarkers:[]}},TOGGLE_SELECTED_MARKERS:(e,{markerId:t,multiSelect:n})=>{const r=e.selectedMarkers,o=r.includes(t);if(n){const n=o?r.filter(e=>e!==t):[...r,t];return{...e,selectedMarkers:n}}return{...e,selectedFeatures:[],selectedMarkers:o&&1===r.length?[]:[t]}},CLEAR_SELECTED_FEATURES:e=>({...e,selectedFeatures:[],selectedMarkers:[]}),SET_SELECTED_FEATURES:(e,t)=>({...e,selectedFeatures:t}),SELECT_MARKER:(e,{markerId:t,multiSelect:n})=>{const r=e.selectedMarkers;if(r.includes(t))return e;const o=n?[...r,t]:[t];return{...e,selectedFeatures:n?e.selectedFeatures:[],selectedMarkers:o}},UNSELECT_MARKER:(e,{markerId:t})=>{const n=e.selectedMarkers;return n.includes(t)?{...e,selectedMarkers:n.filter(e=>e!==t)}:e},SET_LISTBOX_ACTIVE:(e,t)=>({...e,listboxActiveItem:t??null}),SET_LISTBOX_FOCUSED:(e,t)=>({...e,listboxFocused:!!t})},ue={tolerance:10,interactionModes:["selectMarker"],multiSelect:!1,contiguous:!1,deselectOnClickOutside:!1,touchTarget:!0,marker:{}},pe="Select",he={InitComponent:({appState:e,mapState:t,services:n,buttonConfig:i,mapProvider:s,pluginState:a})=>{const{enabled:l,selectedFeatures:c,interactionModes:d,layers:u}=a,{eventBus:p}=n,{crossHair:h,mapStyle:f,markers:g}=t,m=ce({appState:e,pluginState:a});!function({mapState:e,pluginState:t,services:n,mapProvider:i,spatialListRegistry:s}){const{markers:a,mapSize:l}=e,{dispatch:c,interactionModes:d,layers:u,multiSelect:p}=t,{eventBus:h}=n,f=(0,r.li)(null),g=(0,r.li)([]);(function({markers:e,mapSize:t,interactionModes:n,layers:i,mapProvider:s,multiSelect:a,spatialListRegistry:l,eventBus:c,itemsRef:d}){const u=(0,r.li)(a);u.current=a,(0,r.vJ)(()=>{const r=()=>{const r=[];n?.includes("selectMarker")&&r.push(...((e,t,n)=>{const r=[];for(const o of e.items){if(!o.label)continue;const i=e.markerRefs?.get(o.id);if(!ee(o)&&i&&oe(i)){const e={id:o.id,label:o.label,isMarker:!0};o.coords&&Object.assign(e,ie(t,n,o.coords)),r.push(e)}}return r})(e,s,t)),n?.includes("selectFeature")&&i.length>0&&r.push(...((e,t,n)=>{const r=[],o=new Set,i=t.map(e=>e.layerId),s=q(t),a=e.getVisibleFeatures(i);for(const l of a){const t=se(l,s,o,e,n);t&&r.push(t)}return r})(s,i,t)),d.current=r,l.notifyItemsChanged("interact")};return r(),c.on(o.MAP_MOVE_END,r),c.on(o.MAP_DATA_CHANGE,r),()=>{c.off(o.MAP_MOVE_END,r),c.off(o.MAP_DATA_CHANGE,r)}},[e,t,n,i,s,a,l,c,d]),(0,r.vJ)(()=>(l.registerItemProvider("interact",{getItems:()=>({items:d.current,multiselectable:u.current,label:"Map features"})}),()=>{l.unregisterItemProvider("interact")}),[l,d])})({markers:a,mapSize:l,interactionModes:d,layers:u,mapProvider:i,multiSelect:p,spatialListRegistry:s,eventBus:h,itemsRef:g}),function({itemsRef:e,eventBus:t,dispatch:n,listboxActiveItemRef:i}){(0,r.vJ)(()=>{const r=({id:t})=>{if(null===t)return i.current=null,void n({type:"SET_LISTBOX_ACTIVE",payload:null});const r=e.current.find(e=>e.id===t);if(!r)return;if(r.isMarker)return i.current={id:t,isMarker:!0},void n({type:"SET_LISTBOX_ACTIVE",payload:null});const o={featureId:r.featureId,layerId:r.layerId,idProperty:r.idProperty,geometry:r.geometry};i.current={id:t,isMarker:!1,...o,properties:r.properties},n({type:"SET_LISTBOX_ACTIVE",payload:o})};return t.on(o.MAP_SET_ACTIVE_ITEM,r),()=>{t.off(o.MAP_SET_ACTIVE_ITEM,r)}},[e,t,n,i])}({itemsRef:g,eventBus:h,dispatch:c,listboxActiveItemRef:f}),function({eventBus:e,dispatch:t,listboxActiveItemRef:n,multiSelect:i}){(0,r.vJ)(()=>{const r=()=>{const e=n.current;if(e)if(e.isMarker)t({type:"TOGGLE_SELECTED_MARKERS",payload:{markerId:e.id,multiSelect:i}});else{const{featureId:n,layerId:r,idProperty:o,geometry:s,properties:a}=e;t({type:"TOGGLE_SELECTED_FEATURES",payload:{featureId:n,layerId:r,idProperty:o,geometry:s,properties:a,multiSelect:i,replaceAll:!i}})}};return e.on(o.MAP_SELECT_ITEM,r),()=>{e.off(o.MAP_SELECT_ITEM,r)}},[e,t,n,i])}({eventBus:h,dispatch:c,listboxActiveItemRef:f,multiSelect:p})}({mapState:t,pluginState:a,services:n,mapProvider:s,spatialListRegistry:e.spatialListRegistry});const{handleInteraction:y}=(({mapState:e,pluginState:t,services:n,mapProvider:o})=>{const{markers:i,mapSize:s}=e,{dispatch:a,layers:l,interactionModes:c,multiSelect:d,contiguous:u,marker:p,tolerance:h,selectedFeatures:f,selectedMarkers:g,deselectOnClickOutside:m}=t,{eventBus:y}=n,v=q(l),b=ne[s]??1,_=(0,r.hb)(({feature:e,config:t})=>{i.remove("location");const n=e.properties?.[t.idProperty]??e.id;if(null==n)return;const r=o.getFeatureGeometry?.(t.layerId,n,t.idProperty),s=r?{...e,geometry:r}:e;u&&d&&(({featureId:e,feature:t,config:n,selectedFeatures:r,dispatch:o,multiSelect:i})=>{if(!r.length)return!1;const s=r.findIndex(t=>t.featureId===e&&t.layerId===n.layerId);if(-1!==s){if(r.length<3)return!1;const e=(e=>{const t=new Set([0]);let n=!0;for(;n;){n=!1;for(let r=1;r<e.length;r++){if(t.has(r))continue;const o=[...t].map(t=>e[t]);e[r].geometry?.type&&z(e[r],o)&&(t.add(r),n=!0)}}return t.size===e.length?null:[...t].map(t=>e[t])})(r.filter((e,t)=>t!==s));return!!e&&(o({type:"SET_SELECTED_FEATURES",payload:e}),!0)}const a=r.filter(e=>e.geometry?.type);return!(!t.geometry?.type||!a.length||z(t,a)||(o({type:"TOGGLE_SELECTED_FEATURES",payload:{...re(e,i,n,t),replaceAll:!0}}),0))})({featureId:n,feature:s,config:t,selectedFeatures:f,dispatch:a,multiSelect:d})||a({type:"TOGGLE_SELECTED_FEATURES",payload:re(n,d,t,s)})},[i,a,d,u,f,o]),E=(0,r.hb)(({coords:e})=>{const t=c.includes("placeMarker");(t||m)&&(a({type:"CLEAR_SELECTED_FEATURES"}),t&&(i.add("location",e,p),y.emit("interact:markerchange",{coords:e})))},[c,a,i,p,y,m]),S=(({mapProvider:e,layers:t,interactionModes:n,multiSelect:o,dispatch:i,markers:s,layerConfigMap:a,debug:l,tolerance:c,processFeatureMatch:d,processFallback:u,scale:p})=>(0,r.hb)(({point:r,coords:h})=>{const f=l?X(e,r,{radius:c}):null;if(f&&((e,t)=>{const[n,r]=e;console.groupCollapsed(`[interact] click (${n.toFixed(4)}, ${r.toFixed(4)}) — ${t.length} feature${1!==t.length?"s":""}`),t.forEach(e=>{console.log({layer:e.layer.id,type:e.layer.type,id:e.id??"—",sourceLayer:e.sourceLayer??"—",properties:e.properties})}),console.groupEnd()})(h,f),n.includes("selectMarker")){const e=((e,t,n)=>{for(const r of e.items){const o=e.markerRefs?.get(r.id);if(!o||ee(r))continue;const i=o.closest(".im-c-viewport__markers")||o.parentElement,s=i?i.getBoundingClientRect():{left:0,top:0},{left:a,top:l,right:c,bottom:d}=o.getBoundingClientRect(),u=t.x*n,p=t.y*n;if(u>=a-s.left&&u<=c-s.left&&p>=l-s.top&&p<=d-s.top)return r.id}return null})(s,r,p);if(e)return void i({type:"TOGGLE_SELECTED_MARKERS",payload:{markerId:e,multiSelect:o}})}if(n.includes("selectFeature")&&t.length>0){const t=((e,t)=>{const n=e.filter(e=>t[e.layer?.id]),r=n.find(Z);if(r)return{feature:r,config:t[r.layer.id]};const o=n[0];return o?{feature:o,config:t[o.layer.id]}:null})(f??X(e,r,{radius:c}),a);if(t)return void d(t)}u({coords:h})},[e,t,n,o,i,s,a,l,c,d,u,p]))({mapProvider:o,layers:l,interactionModes:c,multiSelect:d,dispatch:a,markers:i,layerConfigMap:v,debug:t?.debug,tolerance:h,processFeatureMatch:_,processFallback:E,scale:b});return((e,t,n)=>{const o=(0,r.li)(null);(0,r.vJ)(()=>{const r=o.current;(null===r||0===r.features.length&&0===r.markers.length)&&0===t.length&&0===n.length||(e.emit("interact:selectionchange",{selectedFeatures:t.map(({featureId:e,layerId:t,idProperty:n,properties:r,geometry:o})=>({featureId:e,layerId:t,idProperty:n,properties:r,geometryType:o?.type})),selectedMarkers:n,contiguous:K(t)}),o.current={features:t,markers:n})},[t,n])})(y,f,g),{handleInteraction:S}})({mapState:t,pluginState:a,services:n,mapProvider:s});return(({mapProvider:e,mapStyle:t,pluginState:n,selectedFeatures:o,events:i,eventBus:s})=>{const{layers:a,listboxActiveItem:l}=n,c=(0,r.Kr)(()=>t?((e,t)=>{const n={};if(!t)return console.warn("[interact] buildStylesMap: mapStyle is null/undefined, cannot build styles"),n;const r=te[t.mapColorScheme]??te.light,o=t.activeColor??r.activeColor,i=t.selectedColor??r.selectedColor;return e.forEach(e=>{const r=e.activeStroke||o,s=e.selectedStroke||i,a=e.selectedFill||"transparent",l=e.selectedStrokeWidth||3,c=l+6;n[e.layerId]={stroke:Q(r,t.id),selectionStroke:Q(s,t.id),fill:Q(a,t.id),strokeWidth:l,activeStrokeWidth:c}}),n})(a,t):null,[a,t]),d=()=>{const t=l?[{featureId:l.featureId,layerId:l.layerId,idProperty:l.idProperty,geometry:l.geometry}]:[];e.updateHighlightedFeatures?.(o,t,c)};(0,r.vJ)(()=>{if(!e||!c)return;d();let t=0,n=!1;const r=()=>{d(),Date.now()>=t&&(s.off(i.MAP_DATA_CHANGE,r),n=!1)},o=()=>{t=Date.now()+3e3,n||(n=!0,s.on(i.MAP_DATA_CHANGE,r))};return s.on(i.MAP_STYLE_CHANGE,o),s.on(i.MAP_SET_SIZE,o),()=>{s.off(i.MAP_STYLE_CHANGE,o),s.off(i.MAP_SET_SIZE,o),s.off(i.MAP_DATA_CHANGE,r)}},[o,l,e,c,s])})({mapProvider:s,mapStyle:f,pluginState:a,selectedFeatures:c,events:o,eventBus:p}),(0,r.vJ)(()=>{p.emit("interact:active",{active:l,interactionModes:d})},[l,d]),function({enabled:e,interactionModes:t,markers:n,layers:o,eventBus:i}){(0,r.vJ)(()=>{if(!e)return;const r=t?.includes("selectMarker")&&n.items.some(e=>e.label),s=t?.includes("selectFeature")&&o.some(e=>e.labelProperty);(r||s)&&i.emit("interact:listboxcapable")},[e,t,n,o,i])}({enabled:l,interactionModes:d,markers:g,layers:u,eventBus:p}),((e,t,n,o)=>{(0,r.vJ)(()=>{const r=t&&n?.includes("selectFeature")?o.map(e=>e.layerId):[];return e.setHoverCursor?.(r),()=>e.setHoverCursor?.([])},[t,n,o])})(s,l,d,u),function({crossHair:e,enabled:t,targetNeeded:n,appState:o,dispatch:i}){const s=(0,r.li)(t);s.current=t;const a=(0,r.li)(n);a.current=n;const l=(0,r.li)(e);l.current=e;const c=(0,r.li)(i);c.current=i;const d=(0,r.li)(!1),u=(0,r.li)(!1),p=(0,r.li)(o.interfaceType);p.current=o.interfaceType;const h=(0,r.hb)(()=>{const e="keyboard"===p.current&&u.current,t=a.current&&!d.current;s.current&&(e||t)?l.current.fixAtCenter():l.current.hide()},[]);(0,r.vJ)(()=>{h()},[t,n,o.interfaceType,h]),(0,r.vJ)(()=>{const e=o.layoutRefs?.appContainerRef?.current;if(!e)return;const t=e=>{d.current=e,c.current?.({type:"SET_LISTBOX_FOCUSED",payload:e})};u.current=!!document.activeElement?.closest("[data-map-keyboard-scope]"),document.activeElement?.closest(ae)&&t(!0);const n=e=>{const n=!!e.target.closest(ae),r=!!e.target.closest("[data-map-keyboard-scope]"),o=d.current!==n,i=o||u.current!==r;o&&t(n),u.current=r,i&&s.current&&h()};return e.addEventListener("focusin",n),()=>{e.removeEventListener("focusin",n)}},[o.layoutRefs,h])}({crossHair:h,enabled:l,targetNeeded:m,appState:e,dispatch:a.dispatch}),function({pluginState:e,appState:t,mapState:n,buttonConfig:i,eventBus:s,handleInteraction:a}){const l=(0,r.li)(a);l.current=a;const c=(0,r.li)(e);c.current=e;const d=(0,r.li)(t);d.current=t;const u=(0,r.li)(!1);(0,r.vJ)(()=>{u.current=!1;const e=setTimeout(()=>{u.current=!0},0);return()=>clearTimeout(e)},[e.enabled]),(0,r.vJ)(()=>{if(e.enabled)return function({getAppState:e,mapState:t,getPluginState:n,buttonConfig:r,events:o,eventBus:i,handleInteraction:s,clickReadyRef:a}){const{selectAtTarget:l}=r,c=()=>s(t.crossHair.getDetail()),d=e=>{a.current&&s(e)},{handleKeydown:u,handleKeyup:p}=((e,t)=>{let n=!1;return{handleKeydown:t=>{n=le(t)&&e.current===t.target},handleKeyup:e=>{le(e)&&n&&(e.preventDefault(),t())}}})(e().layoutRefs.viewportRef,c),h=((e,t)=>(n,r)=>{const o=t();e.markers.remove("location"),o.dispatch({type:"TOGGLE_SELECTED_FEATURES",payload:{multiSelect:o.multiSelect,addToExisting:r,...n}})})(t,n),f=e=>h(e,!0),g=e=>h(e,!1);return document.addEventListener("keydown",u),document.addEventListener("keyup",p),i.on(o.MAP_CLICK,d),i.on("interact:selectFeature",f),i.on("interact:unselectFeature",g),l.onClick=c,()=>{l.onClick=null,document.removeEventListener("keydown",u),document.removeEventListener("keyup",p),i.off(o.MAP_CLICK,d),i.off("interact:selectFeature",f),i.off("interact:unselectFeature",g)}}({getAppState:()=>d.current,mapState:n,getPluginState:()=>c.current,buttonConfig:i,events:o,eventBus:s,handleInteraction:e=>l.current(e),clickReadyRef:u})},[e.enabled,i,s]),(0,r.vJ)(()=>{if(!e.enabled)return;const t=()=>l.current(n.crossHair.getDetail());return n.crossHair.activate=t,()=>{n.crossHair.activate===t&&(n.crossHair.activate=null)}},[e.enabled,n.crossHair])}({pluginState:a,appState:e,mapState:t,buttonConfig:i,eventBus:p,handleInteraction:y}),null},reducer:{initialState:{enabled:!1,layers:[],marker:null,interactionModes:null,multiSelect:!1,deselectOnClickOutside:!1,touchTarget:!0,selectedFeatures:[],selectedMarkers:[],closeOnAction:!0,listboxActiveItem:null,listboxFocused:!1},actions:de},buttons:[{id:"selectAtTarget",label:"Select",variant:"primary",hiddenWhen:({appState:e,pluginState:t})=>!t.enabled||t.listboxFocused||!ce({appState:e,pluginState:t}),mobile:{slot:"actions"},tablet:{slot:"actions"},desktop:{slot:"actions"}}],keyboardShortcuts:[{id:"clickAtTarget",title:"Click at target",command:"<kbd>Enter</kbd>"},{id:"selectFeatures",group:pe,context:"listbox",title:"Select features",command:"<kbd>Tab</kbd>"},{id:"navigateFeatures",group:pe,context:"listbox",title:"Highlight next feature",command:"<kbd>↑</kbd> or <kbd>↓</kbd>"},{id:"navigateFeaturesSpatially",group:pe,context:"listbox",title:"Highlight nearby feature",command:("undefined"!=typeof navigator&&/mac/i.test(navigator.userAgentData?.platform||navigator.platform||"")?"<kbd>Option</kbd>":"<kbd>Alt</kbd>")+" + <kbd>↑</kbd>, <kbd>↓</kbd>, <kbd>←</kbd> or <kbd>→</kbd>"},{id:"selectFeature",group:pe,context:"listbox",title:"Select a feature",command:"<kbd>Enter</kbd> or <kbd>Space</kbd>"},{id:"dismissHintOrReturn",group:pe,context:"listbox",title:"Dismiss hint / return to map",command:"<kbd>Escape</kbd>"}],icons:[{id:"select",svgContent:'<path d="M22 14a8 8 0 0 1-8 8"/><path d="M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2"/><path d="M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1"/><path d="M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10"/><path d="M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/>'}],api:{enable:({pluginState:e,pluginConfig:t},n)=>{e.dispatch({type:"ENABLE",payload:{...ue,...t,...n}})},disable:({pluginState:e})=>{e.dispatch({type:"DISABLE"})},clear:({pluginState:e,mapState:t})=>{e.dispatch({type:"CLEAR_SELECTED_FEATURES"}),t.markers.remove("location")},selectFeature:({services:e},{featureId:t,layerId:n,idProperty:r})=>{e.eventBus.emit("interact:selectFeature",{featureId:t,layerId:n,idProperty:r})},unselectFeature:({services:e},{featureId:t,layerId:n,idProperty:r})=>{e.eventBus.emit("interact:unselectFeature",{featureId:t,layerId:n,idProperty:r})},selectMarker:({pluginState:e},t)=>{e.dispatch({type:"SELECT_MARKER",payload:{markerId:t,multiSelect:e.multiSelect}})},unselectMarker:({pluginState:e},t)=>{e.dispatch({type:"UNSELECT_MARKER",payload:{markerId:t}})}}}},232:(e,t,n)=>{n.r(t),n.d(t,{manifest:()=>a});var r=n(452),o=n(247);const i="app:ready",s={small:1,medium:1.5,large:2},a={InitComponent:function({pluginConfig:e,services:t}){const{eventBus:n}=t,s=()=>{n.emit("map:initmapstyles",e.mapStyles)};return(0,r.vJ)(()=>(n.on(i,s),()=>n.off(i,s)),[]),(0,o.Y)(o.FK,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},desktop:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},render:({mapState:e,pluginConfig:t,services:n,mapProvider:r})=>{const{mapStyle:i,mapSize:a}=e,{mapStyles:l}=t,{eventBus:c}=n,{supportsMapSizes:d}=r.capabilities;return(0,o.FD)("div",{className:"im-c-map-styles",children:[(0,o.Y)("div",{className:"im-c-map-styles__group",children:(0,o.Y)("div",{className:"im-c-map-styles__inner",children:l.filter(e=>e.url).map(e=>(0,o.Y)("div",{className:"im-c-map-styles__item",children:(0,o.FD)("button",{className:"im-c-map-styles__button","aria-pressed":e.id===i.id,onClick:()=>{return t=e,void c.emit("map:setstyle",t);var t},children:[(0,o.Y)("div",{className:"im-c-map-styles__image",children:(0,o.Y)("img",{src:e.thumbnail||void 0,alt:"",height:"60",width:"60"})}),e.label]})},e.id))})}),d&&(0,o.FD)("div",{className:"im-c-map-styles__group",children:[(0,o.Y)("h3",{className:"im-c-map-styles__heading",id:"map-text-sizes",children:"Map size"}),(0,o.Y)("div",{className:"im-c-map-styles__inner",children:["small","medium","large"].map(e=>(0,o.Y)("div",{className:"im-c-map-styles__item",children:(0,o.FD)("button",{className:"im-c-map-styles__button",onClick:()=>{return t=e,c.emit("map:setsize",t),void c.emit("map:setpixelratio",window.devicePixelRatio*s[t]);var t},"aria-pressed":e===a,children:[(0,o.Y)("div",{className:"im-c-map-styles__image",children:(0,o.FD)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fillRule:"evenodd",children:[(0,o.Y)("rect",{className:"im-c-map-styles__image-bg",width:"100%",height:"100%"}),(0,o.Y)("g",{style:{transform:`scale(${s[e]})`,transformOrigin:"8px 52px"},children:(0,o.Y)("path",{d:"M8 51.785L12.948 38.9h1.837l5.274 12.885h-1.943l-1.503-3.903h-5.387l-1.415 3.903H8zm3.718-5.291h4.368l-1.345-3.569-.914-2.671c-.164.826-.395 1.646-.694 2.46l-1.415 3.78zm15.592 4.139c-3.698 3.143-7.836.271-6.315-2.562.963-1.794 5.529-1.982 6.183-2.21.022-.825.052-2.27-2.241-2.312-1.751-.031-2.242 1.025-2.435 1.776l-1.547-.211c.234-1.102.963-2.856 4.21-2.874 4.037-.022 3.612 2.962 3.612 3.524v2.11c0 .315 0 3.012.501 3.911h-1.652c-.164-.328-.27-.712-.316-1.152zm-.132-3.533c-.907.37-3.444.694-3.964.914-1.293.548-.911 2.399.225 2.637.639.134 3.739.476 3.739-2.971v-.58z"})})]})}),e[0].toUpperCase()+e.slice(1)]})},e))})]})]})}}],buttons:[{id:"mapStyles",label:"Styles",panelId:"mapStyles",iconId:"map",mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"map",svgContent:'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>'}]}},792:(e,t,n)=>{n.r(t),n.d(t,{manifest:()=>l});var r=n(452),o=n(247);const i={small:1,medium:1.5,large:2},s={metric:[{threshold:1,abbr:"m",abbrPlural:"m",unit:"metre",unitPlural:"metres",factor:1},{threshold:1e3,abbr:"km",abbrPlural:"km",unit:"kilometre",unitPlural:"kilometres",factor:.001}],imperial:[{threshold:1609.344,abbr:"mi",abbrPlural:"mi",unit:"mile",unitPlural:"miles",factor:1/1609.344},{threshold:.9144,abbr:"yd",abbrPlural:"yds",unit:"yard",unitPlural:"yards",factor:1/.9144},{threshold:.3048,abbr:"ft",abbrPlural:"ft",unit:"foot",unitPlural:"feet",factor:1/.3048}]},a=e=>{const t=Math.pow(10,Math.floor(Math.log10(e))),n=e/t;let r;return r=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,r*t},l={controls:[{id:"scaleBar",label:"Scale bar",mobile:{slot:"right-bottom"},tablet:{slot:"right-bottom"},desktop:{slot:"right-bottom"},render:function({mapState:e,pluginConfig:t}){const{resolution:n,mapSize:l}=e,c=(0,r.li)(null),d=(0,r.Kr)(()=>n?((e,t,n,r)=>{const o=e/i[r],l=120*o,c=s[n];for(const{abbr:i,abbrPlural:s,unit:g,unitPlural:m,factor:y}of c){const e=a(l*y);if(e>=1&&e<1e3){const t=e/y/o;if(t<=120)return{label:e,abbr:e>1?s:i,width:t,unit:e>1?m:g}}}const d=c[c.length-1],u=l*d.factor,p=a(u),h=p>1?d.abbrPlural:d.abbr,f=p>1?d.abbrPlural:d.abbr;return{label:p,abbr:h,width:p/d.factor/o,unit:f}})(n/1,0,t.units,l):{width:0,label:"",abbr:"",unit:""},[n,l,t.units]);return(0,o.Y)("div",{className:"im-c-scale-bar",ref:c,style:{width:`${d.width}px`},children:(0,o.FD)("span",{className:"im-c-scale-bar__label",children:[(0,o.Y)("span",{className:"im-u-visually-hidden",children:"Scale bar: "}),d.label,(0,o.Y)("span",{"aria-hidden":"true",children:d.abbr}),(0,o.Y)("span",{className:"im-u-visually-hidden",children:d.unit})]})})}}]}},814:(e,t,n)=>{n.r(t),n.d(t,{default:()=>$});class r{_notImplemented(e){throw new Error(`${this.name} must implement ${e}()`)}isBaseMapReady(){this._notImplemented("isBaseMapReady")}addSymbolsToMap(){this._notImplemented("addSymbolsToMap")}addPatternsToMap(){this._notImplemented("addPatternsToMap")}getActiveSymbolImageId(){this._notImplemented("getActiveSymbolImageId")}getSelectedSymbolImageId(){this._notImplemented("getSelectedSymbolImageId")}}const o=400,i=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"],s=(e,t)=>{let n=null;const r=(...r)=>{clearTimeout(n),n=setTimeout(()=>{e(...r)},t)};return r.cancel=()=>{n&&(clearTimeout(n),n=null)},r};function a({map:e,events:t,eventBus:n,getCenter:r,getZoom:o,getBounds:i,getResolution:a}){const l=[],c=[],d=()=>{const t=o();return{center:r(),bounds:i(),resolution:a(),zoom:t,isAtMaxZoom:e.getMaxZoom()<=t,isAtMinZoom:e.getMinZoom()>=t}},u=(e,t)=>n.emit(e,t),p=()=>u(t.MAP_LOADED);e.on("load",p),l.push(["load",p]),e.once("idle",()=>u(t.MAP_FIRST_IDLE,d()));const h=()=>u(t.MAP_MOVE_START);e.on("movestart",h),l.push(["movestart",h]);const f=s(()=>{u(t.MAP_MOVE_END,d())},500);e.on("moveend",f),l.push(["moveend",f]);const g=(()=>{let e=0;return(...n)=>{const r=Date.now();r-e>=10&&(e=r,(()=>{u(t.MAP_MOVE,d())})(...n))}})();e.on("zoom",g),l.push(["zoom",g]);const m=()=>u(t.MAP_RENDER);e.on("render",m),l.push(["render",m]);const y=s(()=>{u(t.MAP_DATA_CHANGE,d())},500),v=e=>{e.isSourceLoaded&&y()};e.on("styledata",y),e.on("sourcedata",v),l.push(["styledata",y],["sourcedata",v]);const b=()=>u(t.MAP_STYLE_CHANGE);e.on("style.load",b),l.push(["style.load",b]);const _=e=>u(t.MAP_CLICK,{point:e.point,coords:[e.lngLat.lng,e.lngLat.lat]});return e.on("click",_),l.push(["click",_]),c.push(f,g,y),{remove(){c.forEach(e=>e.cancel()),l.forEach(([t,n])=>e.off(t,n))}}}function l(e,t,n){if(null!==e)for(var r,o,i,s,a,c,d,u,p=0,h=0,f=e.type,g="FeatureCollection"===f,m="Feature"===f,y=g?e.features.length:1,v=0;v<y;v++){a=(u=!!(d=g?e.features[v].geometry:m?e.geometry:e)&&"GeometryCollection"===d.type)?d.geometries.length:1;for(var b=0;b<a;b++){var _=0,E=0;if(null!==(s=u?d.geometries[b]:d)){c=s.coordinates;var S=s.type;switch(p=0,S){case null:break;case"Point":if(!1===t(c,h,v,_,E))return!1;h++,_++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(!1===t(c[r],h,v,_,E))return!1;h++,"MultiPoint"===S&&_++}"LineString"===S&&_++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(o=0;o<c[r].length-p;o++){if(!1===t(c[r][o],h,v,_,E))return!1;h++}"MultiLineString"===S&&_++,"Polygon"===S&&E++}"Polygon"===S&&_++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(E=0,o=0;o<c[r].length;o++){for(i=0;i<c[r][o].length-p;i++){if(!1===t(c[r][o][i],h,v,_,E))return!1;h++}E++}_++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(!1===l(s.geometries[r],t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}var c=function(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const n=[1/0,1/0,-1/0,-1/0];return l(e,e=>{n[0]>e[0]&&(n[0]=e[0]),n[1]>e[1]&&(n[1]=e[1]),n[2]<e[0]&&(n[2]=e[0]),n[3]<e[1]&&(n[3]=e[1])}),n};const d=Math.PI/180,u=1e-4,p=e=>e*d,h=(e,t)=>{const[n,r]=e,[o,i]=t,s=p(r),a=p(i),l=a-s,c=p(o-n),d=Math.sin(l/2)**2+Math.cos(s)*Math.cos(a)*Math.sin(c/2)**2;return 2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d))*6371e3},f=e=>{const t=e/1609.344;if(t<.5){const t=Math.round(e);return`${t} ${1===t?"metre":"metres"}`}if(t<10){const e=Number.parseFloat(t.toFixed(1));return`${e} ${1===e?"mile":"miles"}`}return`${Math.round(t)} miles`},g=e=>c(e),m="highlighted-label";function y(e,t){if("number"==typeof e)return e;if(!Array.isArray(e)||"interpolate"!==e[0])return function(e,t){const{stops:n}=e;if(n.length<2)return n.length>0?n[0][1]:0;let r=n[0],o=n[n.length-1];for(let c=1;c<n.length;c++){const e=n[c];if(e[0]>t){o=e,r=n[c-1];break}r=n[c-1],o=e}const[i,s]=r,[a,l]=o;return t<=i?s:t>=a?l:s+(t-i)/(a-i)*(l-s)}(e,t);const[,,n,...r]=e;if("zoom"!==n[0])throw new Error("Only zoom-based expressions supported");for(let o=0;o<r.length-2;o+=2){const e=r[o],n=r[o+1],i=r[o+2],s=r[o+3];if(t<=e)return n;if(t<=i)return n+(t-e)/(i-e)*(s-n)}return r[r.length-1]}function v(e,t){if(t.highlightLayerId&&e.getLayer(t.highlightLayerId)){try{e.removeLayer(t.highlightLayerId)}catch{}t.highlightLayerId=null,t.highlightedExpr=null}}function b(e,t,n){if(!t?.feature?.layer)return;v(e,n);const{feature:r,layer:o}=t;n.highlightLayerId=`highlight-${o.id}`;const{id:i,type:s,properties:a,geometry:l}=r;e.getSource(m).setData({id:i,type:s,properties:a,geometry:l}),n.highlightedExpr=o.layout["text-size"];const c=e.getZoom(),d=function(e,t,n){return{id:`highlight-${e.id}`,type:e.type,source:m,layout:{...e.layout,"text-size":t,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90},paint:{...e.paint,"text-color":n.text,"text-halo-color":n.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1}}}(o,1.5*y(n.highlightedExpr,c),n.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"});e.addLayer(d),e.moveLayer(n.highlightLayerId)}function _(e){e.getSource(m)||e.addSource(m,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function E(e){e.getStyle().layers.filter(e=>"line"===e.layout?.["symbol-placement"]).forEach(t=>e.setLayoutProperty(t.id,"symbol-placement","line-center"))}const S=e=>e.endsWith(".cold")?`${e.slice(0,-5)}.hot`:e.endsWith(".hot")?`${e.slice(0,-4)}.cold`:null,x="icon-image",I="active-highlight",w="active-highlight-inner",P="selected-highlight",C=(e,t)=>"active"===t?{property:"user_symbolActiveImageId",getImageId:t=>e?.getActiveImageId(t)??null}:{property:"user_symbolSelectedImageId",getImageId:t=>e?.getSelectedImageId(t)??null},T=(e,t,n,{featureId:r,idProperty:o,geometry:i})=>{const s=e.getLayer(n);s&&(t[n]||(t[n]={ids:new Set,fillIds:new Set,idProperty:o,sourceId:s.source,hasFillGeometry:!1}),!i||"Polygon"!==i.type&&"MultiPolygon"!==i.type||(t[n].hasFillGeometry=!0,t[n].fillIds.add(r)),t[n].ids.add(r))},M=(e,t,n,r)=>{t.forEach(t=>{if(!n.has(t)){const n=`${r}-${t}`;[`${n}-fill`,`${n}-line`,`${n}-symbol`].forEach(t=>{e.getLayer(t)&&e.setFilter(t,["==","id",""])})}})},L=(e,t)=>{const n=`_${t.replaceAll("-","")}Sources`;M(e,e[n]||new Set,new Set,t),e[n]=new Set},A=(e,t,n,r,o,i,s)=>{!!e.getLayer(t)||e.addLayer({id:t,type:n,source:r,...o&&{"source-layer":o},paint:i}),Object.entries(i).forEach(([n,r])=>{e.setPaintProperty(t,n,r)}),e.setFilter(t,s),e.moveLayer(t)},O=(e,t,n,r,o,i,s)=>{const a=e.getLayoutProperty(o,"icon-offset");e.getLayer(t)||e.addLayer({id:t,type:"symbol",source:n,...r&&{"source-layer":r},layout:{[x]:i,"icon-anchor":e.getLayoutProperty(o,"icon-anchor")??"center",...void 0!==a&&{"icon-offset":a},"icon-allow-overlap":!0}}),e.setLayoutProperty(t,x,i),void 0!==a&&e.setLayoutProperty(t,"icon-offset",a),e.setFilter(t,s),e.moveLayer(t)},k=(e,t,n,r,o)=>{const i=((e,t)=>{const n={};return t?.forEach(t=>{T(e,n,t.layerId,t);const r=S(t.layerId);r&&T(e,n,r,t)}),n})(e,t),s=new Set(Object.keys(i)),a=`_${r.replaceAll("-","")}Sources`,l=e[a]||new Set;return M(e,l,s,r),e[a]=s,s.forEach(t=>((e,t,n,r,o,i)=>{const{ids:s,fillIds:a,idProperty:l,sourceId:c,hasFillGeometry:d}=n[t],u=e.getLayer(t),p=r[t]??r[S(t)];if(!u||!p)return;const h=u.sourceLayer,f=d?"fill":u.type,g=`${o}-${t}`,{fill:m}=p,y=o===P,v=(e=>e===P||e===w)(o),{lineColor:b,lineWidth:_}=((e,t)=>({lineColor:t?e.selectionStroke:e.stroke,lineWidth:t?e.strokeWidth:e.activeStrokeWidth}))(p,v),E=l?["get",l]:["id"],I=["in",E,["literal",Array.from(s)]];if("fill-extrusion"!==u.type)switch(f){case"fill":((e,t,n,r,{isSelected:o,idExpression:i,fillIds:s,fill:a,lineColor:l,lineWidth:c,filter:d})=>{if(o){const o=[];s.forEach(e=>o.push(e)),A(e,`${t}-fill`,"fill",n,r,{"fill-color":a},["in",i,["literal",o]])}A(e,`${t}-line`,"line",n,r,{"line-color":l,"line-width":c},d)})(e,g,c,h,{isSelected:y,idExpression:E,fillIds:a,fill:m,lineColor:b,lineWidth:_,filter:I});break;case"line":((e,t,n,r,o,i,s)=>{e.getLayer(`${t}-fill`)&&e.setFilter(`${t}-fill`,["==","id",""]),A(e,`${t}-line`,"line",n,r,{"line-color":o,"line-width":i},s)})(e,g,c,h,b,_,I);break;case"symbol":((e,t,n,r,o,i,s)=>{const a=e.getLayoutProperty(o,x);if(Array.isArray(a))return void O(e,`${t}-symbol`,n,r,o,["get",s.property],i);const l=s.getImageId(a);l&&O(e,`${t}-symbol`,n,r,o,l,i)})(e,g,c,h,t,I,i)}else((e,t,n,{ids:r,lineColor:o,lineWidth:i,idExpression:s})=>{const a=[];r.forEach(e=>a.push(e));const l=["in",s,["literal",a]],{source:c,sourceLayer:d}=e.getLayer(n);A(e,`${t}-line`,"line",c,d,{"line-color":o,"line-width":i},l)})(e,g,t,{ids:s,lineColor:b,lineWidth:_,idExpression:E})})(e,t,i,n,r,o)),i},D=(e,t,n)=>{const r=(t.x-n.x)**2+(t.y-n.y)**2;if(0===r)return(e.x-t.x)**2+(e.y-t.y)**2;let o=((e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y))/r;return o=Math.max(0,Math.min(1,o)),(e.x-(t.x+o*(n.x-t.x)))**2+(e.y-(t.y+o*(n.y-t.y)))**2};class R{sets=(()=>new Map)();add(e,t){const n=this.sets.get(e)??new Set;this.sets.delete(e),this.sets.set(e,n),t.forEach(e=>n.add(e));const r=new Set;for(;this.sets.size>2;){const[e,t]=this.sets.entries().next().value;this.sets.delete(e),t.forEach(e=>r.add(e))}return this.sets.forEach(e=>e.forEach(e=>r.delete(e))),Array.from(r)}}const N=.25,F=.75,V=([e,t])=>{const n=(e=>e<=N?"left":e>=F?"right":"")(e),r=(e=>e<=N?"top":e>=F?"bottom":"")(t);return r+(n&&r?"-":"")+n||"center"},B=e=>e<=N?0:e>=F?1:.5,U=e=>Math.round(100*e)/100,G=([e,t],n)=>{const[,,r,o]=n.split(" ").map(Number);return[U((B(e)-e)*r),U((B(t)-t)*o)]};class j{activeImageIds=(()=>new Map)();selectedImageIds=(()=>new Map)();recentImageSets=(()=>new R)();constructor(e){this.map=e}getActiveImageId(e){return this.activeImageIds.get(e)??null}getSelectedImageId(e){return this.selectedImageIds.get(e)??null}removeImage(e){this.map.hasImage(e)&&this.map.removeImage(e),this.activeImageIds.delete(e),this.selectedImageIds.delete(e)}async registerSymbols(e,t,n,r){const{map:o}=this,i=await Promise.all(e.map(async e=>{const i=n.getSymbolImageIds(e,t,r);return i?(this.activeImageIds.set(i.normal,i.active),this.selectedImageIds.set(i.normal,i.selected),await Promise.all(Object.entries(i).map(async([i,s])=>{if(o.hasImage(s))return;const a=await n.rasteriseSymbolImage(e,t,i,r);a&&!o.hasImage(a.imageId)&&o.addImage(a.imageId,a.imageData,{pixelRatio:r})})),Object.values(i)):[]}));this.recentImageSets.add(`${t?.id}|${r}`,i.flat()).forEach(e=>this.removeImage(e))}}class H{recentImageSets=(()=>new R)();constructor(e){this.map=e}async registerPatterns(e,t,n,r){const{map:o}=this,i=new Map;e.forEach(e=>{const o=n.getPatternImageId(e,t,r);o&&!i.has(o)&&i.set(o,e)});const s=(e=>Math.max(2,2*e))(r);await Promise.all(Array.from(i,async([e,i])=>{if(o.hasImage(e))return;const a=await n.rasterisePatternImage(i,t,r);a&&!o.hasImage(a.imageId)&&o.addImage(a.imageId,a.imageData,{pixelRatio:s})})),this.recentImageSets.add(`${t}|${r}`,Array.from(i.keys())).forEach(e=>{o.hasImage(e)&&o.removeImage(e)})}}class $ extends r{constructor({mapFramework:e,mapProviderConfig:t={},events:n,eventBus:r}){super(),this.maplibreModule=e,this.events=n,this.eventBus=r,this.capabilities={supportedShortcuts:i,supportsMapSizes:!0},Object.assign(this,t)}get name(){return"MapLibreProvider"}async initMap(e){const{container:t,padding:n,mapStyle:r,mapSize:o,center:i,zoom:s,bounds:l,pixelRatio:c,...d}=e;this.mapStyleId=r?.id,this.mapSize=o;const{Map:u}=this.maplibreModule,{events:p,eventBus:h}=this,f=new u({...d,container:t,style:r?.url,pixelRatio:c,padding:n,center:i,zoom:s,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1});f.touchZoomRotate.disableRotation(),this.map=f,this.symbolImages=new j(f),this.patternImages=new H(f),this.map.setPadding(n),l&&f.fitBounds(l,{duration:0}),function(e){const t=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){const t=e.getCanvas();if(t&&(this.target===t||t.contains(this.target)))return}t.call(this)}}(f),function(e){const t=e.getCanvas();t.removeAttribute("role"),t.setAttribute("tabindex",-1),t.removeAttribute("aria-label"),t.style.display="block",t.addEventListener("focus",e=>{t.blur(),e.relatedTarget&&e.relatedTarget.focus({preventScroll:!0})})}(f),a({map:f,events:p,eventBus:h,getCenter:this.getCenter.bind(this),getZoom:this.getZoom.bind(this),getBounds:this.getBounds.bind(this),getResolution:this.getResolution.bind(this)}),function({mapProvider:e,map:t,events:n,eventBus:r}){r.on(n.MAP_SET_STYLE,e=>{t.once("style.load",()=>{r.emit(n.MAP_STYLE_CHANGE,{mapStyleId:e.id})}),t.setStyle(e.url,{diff:!1})}),r.on(n.MAP_SET_PIXEL_RATIO,e=>{t.setPixelRatio(e)}),r.on(n.MAP_SIZE_CHANGE,({mapSize:t})=>{e.mapSize=t})}({mapProvider:this,map:f,events:p,eventBus:h}),f.on("load",()=>{this.labelNavigator=function(e,t,n,r){const o={isDarkStyle:"dark"===t,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function i(){const t=e.getStyle().layers.filter(e=>"symbol"===e.type),n=e.queryRenderedFeatures({layers:t.map(e=>e.id)});o.labels=function(e,t,n){return t.flatMap(t=>{const r=t.layout?.["text-field"],o=function(e){return"string"==typeof e?/^{(.+)}$/.exec(e)?.[1]:Array.isArray(e)?e.find(e=>Array.isArray(e)&&"get"===e[0])?.[1]:null}(r);return o?n.filter(e=>e.layer.id===t.id&&e.properties?.[o]).map(n=>function(e,t,n,r){const o=function(e){const{type:t,coordinates:n}=e;if("Point"===t)return n;if("MultiPoint"===t)return n[0];if(t.includes("LineString")){const e="LineString"===t?n:n[0];return[(e[0][0]+e[e.length-1][0])/2,(e[0][1]+e[e.length-1][1])/2]}if(t.includes("Polygon")){const e="Polygon"===t?n[0]:n[0][0],r=e.reduce((e,t)=>[e[0]+t[0],e[1]+t[1]],[0,0]);return[r[0]/e.length,r[1]/e.length]}return null}(e.geometry);if(!o)return null;const i=r.project({lng:o[0],lat:o[1]});return{text:e.properties[n],x:i.x,y:i.y,feature:e,layer:t}}(n,t,o,e)).filter(Boolean):[]})}(e,t,n)}function s(){if(i(),!o.labels.length)return null;const t=e.project(e.getCenter()),n=function(e,t){return e.reduce((e,n)=>{const r=(n.x-t.x)**2+(n.y-t.y)**2;return!e||r<e.dist?{label:n,dist:r}:e},null)?.label}(o.labels,t);return o.currentPixel={x:n.x,y:n.y},b(e,n,o),n.text}return E(e),_(e),r?.on(n.MAP_SET_STYLE,t=>{e.once("styledata",()=>e.once("idle",()=>{E(e),_(e),o.isDarkStyle="dark"===t?.mapColorScheme}))}),e.on("zoom",()=>{if(o.highlightLayerId&&o.highlightedExpr){const t=y(o.highlightedExpr,e.getZoom());e.setLayoutProperty(o.highlightLayerId,"text-size",1.5*t)}}),function(e){e.getStyle().layers.filter(e=>"symbol"===e.type).forEach(t=>{e.setPaintProperty(t.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(e),{refreshLabels:i,highlightNextLabel:function(t){if(i(),!o.labels.length)return null;if(!o.currentPixel)return s();const n=function(e,t){if(!t.currentPixel)return null;const n=t.labels.map((e,t)=>({pixel:[e.x,e.y],index:t})).filter(e=>e.pixel[0]!==t.currentPixel.x||e.pixel[1]!==t.currentPixel.y);if(!n.length)return null;const r=n.map(e=>e.pixel);let o=((e,t,n)=>{const r=(e,t)=>e[0]===t[0]&&e[1]===t[1],o=t.filter(t=>{const o=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);let s=!1;return s="ArrowUp"===n?t[1]<=e[1]&&i>=o:"ArrowDown"===n?t[1]>e[1]&&i>=o:"ArrowLeft"===n?t[0]<=e[0]&&i<o:"ArrowRight"!==n||t[0]>e[0]&&i<o,s&&!r(t,e)});o.length||o.push(e);const i=t=>Math.hypot(e[0]-t[0],e[1]-t[1]),s=o.reduce((e,t)=>i(t)<i(e)?t:e,o[0]);return t.findIndex(e=>r(e,s))})([t.currentPixel.x,t.currentPixel.y],r,e);return(null==o||o<0||o>=n.length)&&(o=0),t.labels[n[o].index]}(t,o);return n?(o.currentPixel={x:n.x,y:n.y},b(e,n,o),n.text):null},highlightLabelAtCenter:s,clearHighlightedLabel:()=>v(e,o)}}(f,r?.mapColorScheme,p,h)}),this.eventBus.emit(p.MAP_READY,{map:this.map,mapStyleId:this.mapStyleId,mapSize:this.mapSize,crs:this.crs})}isBaseMapReady(){return Boolean(this.map?.getStyle())}destroyMap(){this.setHoverCursor([]),this.mapEvents?.remove(),this.appEvents?.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}setHoverCursor(e){this.map&&(this._onHoverMove=((e,t,n)=>{const r=e.getCanvas();if(n&&e.off("mousemove",n),!t?.length)return r.style.cursor="",null;const o=n=>{const o=(e=>{const t=new Set(e);return e.forEach(e=>{const n=S(e);n&&t.add(n)}),[...t]})(t).filter(t=>e.getLayer(t));if(0===o.length)return void(r.style.cursor="");const{lineLayers:i,otherLayers:s}=((e,t)=>{const n=[],r=[];for(const o of t)if("line"===e.getLayer(o).type){const e=o.endsWith("-stroke")?o.slice(0,-7):null;null!==e&&t.includes(e)||n.push(o)}else r.push(o);return{lineLayers:n,otherLayers:r}})(e,o),{x:a,y:l}=n.point,c=[[a-10,l-10],[a+10,l+10]],d=i.length>0&&e.queryRenderedFeatures(c,{layers:i}).length>0,u=s.length>0&&e.queryRenderedFeatures(n.point,{layers:s}).length>0;r.style.cursor=d||u?"pointer":""};return e.on("mousemove",o),o})(this.map,e,this._onHoverMove))}setView({center:e,zoom:t}){this.map.flyTo({center:e||this.getCenter(),zoom:t||this.getZoom(),duration:this.map.isStyleLoaded()?o:0})}zoomIn(e){this.map.easeTo({zoom:this.getZoom()+e,duration:o})}zoomOut(e){this.map.easeTo({zoom:this.getZoom()-e,duration:o})}panBy(e){this.map.panBy(e,{duration:o})}fitToBounds(e){const t=Array.isArray(e)?e:g(e),n=this.map.isStyleLoaded()?o:0;this.map.fitBounds(t,{duration:n})}setPadding(e){this.map.setPadding(e)}updateHighlightedFeatures(e,t,n){const{LngLatBounds:r}=this.maplibreModule;return function({LngLatBounds:e,map:t,selectedFeatures:n,activeFeatures:r,stylesMap:o,symbolImages:i}){if(!t)return null;const s=C(i,"active"),a=C(i,"selected");r?.length?(k(t,r,o,I,s),k(t,r,o,w,a)):(L(t,I),L(t,w));let l={};n?.length?l=k(t,n,o,P,a):L(t,P);const c=[];return Object.entries(l).forEach(([e,{ids:n,idProperty:r}])=>{c.push(...t.queryRenderedFeatures({layers:[e]}).filter(e=>n.has(r?e.properties?.[r]:e.id)))}),((e,t)=>{if(!t.length)return null;const n=new e;return t.forEach(e=>{const t=e=>"number"==typeof e[0]?n.extend(e):e.forEach(t);t(e.geometry.coordinates)}),[n.getWest(),n.getSouth(),n.getEast(),n.getNorth()]})(e,c)}({LngLatBounds:r,map:this.map,selectedFeatures:e,activeFeatures:t,stylesMap:n,symbolImages:this.symbolImages})}highlightNextLabel(e){return this.labelNavigator?.highlightNextLabel(e)||null}highlightLabelAtCenter(){return this.labelNavigator?.highlightLabelAtCenter()||null}clearHighlightedLabel(){return this.labelNavigator?.clearHighlightedLabel()||null}getCenter(){const e=this.map.getCenter();return[Number(e.lng.toFixed(7)),Number(e.lat.toFixed(7))]}getZoom(){return Number(this.map.getZoom().toFixed(7))}getBounds(){return this.map.getBounds().toArray().flat(1)}getFeaturesAtPoint(e,t){return((e,t,n={})=>{const{radius:r=10}=n,o=[[t.x-r,t.y-r],[t.x+r,t.y+r]],i=e.queryRenderedFeatures(o);if(0===i.length)return[];const s=new Set(e.queryRenderedFeatures([t.x,t.y]).map(e=>{const t=void 0===e.id?JSON.stringify(e.properties):e.id;return`${e.layer?.source}:${t}`})),a=[];i.forEach(e=>{!1===a.includes(e.layer.id)&&a.push(e.layer.id)});const l=new Set,c=[];for(let h=i.length-1;h>=0;h--){const e=i[h],t=void 0===e.id?JSON.stringify(e.properties):e.id,n=`${e.layer?.source}:${t}`;!1===l.has(n)&&(l.add(n),c.push(e))}const d=e.unproject(t),u=[d.lng,d.lat],p=c.filter(e=>{const t=e.geometry.type;if(t.includes("Polygon"))return("Polygon"===t?[e.geometry.coordinates]:e.geometry.coordinates).some(e=>((e,t)=>{const[n,r]=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i,i++){const[e,a]=t[i],[l,c]=t[s];a>r!=c>r&&n<(l-e)*(r-a)/(c-a)+e&&(o=!o)}return o})(u,e[0]));if("Point"===t||"MultiPoint"===t){const t=void 0===e.id?JSON.stringify(e.properties):e.id;return s.has(`${e.layer?.source}:${t}`)}return!0});return p.map(n=>{let r=0;const o=n.geometry.type,i=((e,t,n)=>{const{coordinates:r,type:o}=n;let i=1/0;const s=t=>e.project(t),a=e=>{for(let n=0;n<e.length-1;n++){const r=D(t,s(e[n]),s(e[n+1]));r<i&&(i=r)}};if("Point"===o){const e=s(r);i=(t.x-e.x)**2+(t.y-e.y)**2}else"LineString"===o||"MultiPoint"===o?"LineString"===o?a(r):r.forEach(e=>{const n=s(e),r=(t.x-n.x)**2+(t.y-n.y)**2;r<i&&(i=r)}):"Polygon"===o||"MultiLineString"===o?r.forEach(a):"MultiPolygon"===o&&r.forEach(e=>e.forEach(a));return i})(e,t,n.geometry);return r+=1e6*a.indexOf(n.layer.id),o.includes("Polygon")&&(r-=5e5),r+=i,{f:n,score:r}}).sort((e,t)=>e.score-t.score).map(({f:e})=>e)})(this.map,e,t)}getVisibleFeatures(e){const t=e.filter(e=>this.map.getLayer(e));return t.length?this.map.queryRenderedFeatures(void 0,{layers:t}):[]}async addSymbolsToMap(e,t,n,r=this.map.getPixelRatio()||1){return this.symbolImages.registerSymbols(e,t,n,r)}getSymbolIconLayout(e){return(({anchor:e,viewBox:t})=>({"icon-anchor":V(e),"icon-offset":G(e,t)}))(e)}getActiveSymbolImageId(e){return this.symbolImages?.getActiveImageId(e)??null}getSelectedSymbolImageId(e){return this.symbolImages?.getSelectedImageId(e)??null}async addPatternsToMap(e,t,n,r=this.map.getPixelRatio()||1){return this.patternImages.registerPatterns(e,t,n,r)}getAreaDimensions(){const{LngLatBounds:e}=this.maplibreModule;return(e=>{let t,n,r,o;if(e&&"function"==typeof e.getWest)t=e.getWest(),n=e.getSouth(),r=e.getEast(),o=e.getNorth();else{if(!Array.isArray(e)||2!==e.length)return"";[[t,n],[r,o]]=e}const i=h([t,n],[r,n]),s=h([t,n],[t,o]),a=f(i);return`${f(s)} by ${a}`})(((e,t)=>{const{width:n,height:r}=t.getContainer().getBoundingClientRect(),o=t.getPadding(),i=[o.left,r-o.bottom],s=[n-o.right,o.top];return new e(t.unproject(i),t.unproject(s))})(e,this.map))}getCardinalMove(e,t){return((e,t)=>{const[n,r]=e,[o,i]=t,s=i-r,a=o-n,l=[];if(Math.abs(s)>u){const e=Math.round(h([n,r],[n,i]));l.push(`${s>0?"north":"south"} ${f(e)}`)}if(Math.abs(a)>u){const e=Math.round(h([n,r],[o,r]));l.push(`${a>0?"east":"west"} ${f(e)}`)}return l.join(", ")})(e,t)}getResolution(){return((e,t)=>{const n=e.lat,r=Math.pow(2,t);return 40075016.686*Math.cos(p(n))/(512*r)})(this.map.getCenter(),this.map.getZoom())}mapToScreen(e){return this.map.project(e)}screenToMap(e){const{lng:t,lat:n}=this.map.unproject([e.x,e.y]);return[t,n]}isGeometryObscured(e,t){return((e,t,n)=>{const r=n.getContainer().getBoundingClientRect(),[o,i,s,a]=g(e),l=[n.project([o,i]),n.project([o,a]),n.project([s,i]),n.project([s,a])],c=Math.min(...l.map(e=>e.x)),d=Math.max(...l.map(e=>e.x)),u=Math.min(...l.map(e=>e.y)),p=Math.max(...l.map(e=>e.y)),h=t.left-r.left,f=t.top-r.top,m=t.right-r.left,y=t.bottom-r.top;return c<m&&d>h&&u<y&&p>f})(e,t,this.map)}}}}]);
2
2
  //# sourceMappingURL=@defra.min.js.map