@defra/interactive-map 0.0.36-alpha → 0.0.38-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/templates/draw-tools.njk +4 -3
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api.md +32 -0
- package/docs/examples/draw-tools.mdx +0 -4
- package/docs/plugins/draw.md +482 -0
- package/docs/plugins.md +2 -6
- package/govuk-prototype-kit.config.json +3 -2
- package/package.json +2 -4
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/events.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/css/index.css +1 -97
- package/plugins/datasets/dist/esm/esriLayerAdapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-esri-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +13 -0
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -0
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -0
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -0
- package/plugins/draw/dist/esm/index.js +1 -0
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -0
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +2 -0
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js.LICENSE.txt +1 -0
- package/plugins/draw/dist/umd/im-draw-plugin.js +2 -0
- package/plugins/draw/dist/umd/im-draw-plugin.js.LICENSE.txt +1 -0
- package/plugins/draw/dist/umd/index.js +2 -0
- package/plugins/draw/dist/umd/index.js.LICENSE.txt +1 -0
- package/plugins/draw/src/DrawInit.jsx +89 -0
- package/plugins/draw/src/DrawInit.test.jsx +184 -0
- package/plugins/draw/src/adapterEvents.js +127 -0
- package/plugins/draw/src/adapterEvents.test.js +20 -0
- package/plugins/draw/src/adapters/adapterContract.test.js +48 -0
- package/plugins/draw/src/adapters/loadDrawAdapter.js +14 -0
- package/plugins/draw/src/adapters/loadDrawAdapter.test.js +53 -0
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +367 -0
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +799 -0
- package/plugins/draw/src/adapters/maplibre/defaults.js +1 -0
- package/plugins/draw/src/adapters/maplibre/drawEvents.js +35 -0
- package/plugins/draw/src/adapters/maplibre/mapboxDraw.js +126 -0
- package/plugins/draw/src/adapters/maplibre/mapboxDraw.test.js +268 -0
- package/plugins/draw/src/adapters/maplibre/mapboxSnap.js +39 -0
- package/plugins/draw/src/adapters/maplibre/mapboxSnap.test.js +91 -0
- package/plugins/draw/src/adapters/maplibre/modes/createDrawMode.js +58 -0
- package/plugins/draw/src/adapters/maplibre/modes/createDrawMode.test.js +53 -0
- package/plugins/draw/src/adapters/maplibre/modes/disabledMode.js +23 -0
- package/plugins/draw/src/adapters/maplibre/modes/disabledMode.test.js +21 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawLineMode.js +15 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawLineMode.test.js +37 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/__helpers__/harness.js +115 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +193 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +241 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/keyboardHandlers.js +78 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/keyboardHandlers.test.js +75 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.js +78 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.test.js +48 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.js +103 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.test.js +127 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/renderHelpers.js +59 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/renderHelpers.test.js +34 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +193 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +195 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawPolygonMode.js +16 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawPolygonMode.test.js +27 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/__helpers__/harness.js +107 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.js +139 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.test.js +46 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/helpers.js +2 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/helpers.test.js +17 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.js +151 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.test.js +123 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.js +161 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.test.js +98 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.js +133 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.test.js +105 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +166 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +133 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.js +210 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.test.js +167 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.js +121 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.test.js +73 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +249 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.test.js +153 -0
- package/plugins/draw/src/adapters/maplibre/snap/constants.js +2 -0
- package/plugins/draw/src/adapters/maplibre/snap/mapHandlers.js +39 -0
- package/plugins/draw/src/adapters/maplibre/snap/mapHandlers.test.js +106 -0
- package/plugins/draw/src/adapters/maplibre/snap/prototypePatches.js +148 -0
- package/plugins/draw/src/adapters/maplibre/snap/prototypePatches.test.js +238 -0
- package/plugins/draw/src/adapters/maplibre/snap/snapInstance.js +115 -0
- package/plugins/draw/src/adapters/maplibre/snap/snapInstance.test.js +151 -0
- package/plugins/draw/src/adapters/maplibre/snap/sourceData.js +34 -0
- package/plugins/draw/src/adapters/maplibre/snap/sourceData.test.js +62 -0
- package/plugins/draw/src/adapters/maplibre/styles.js +207 -0
- package/plugins/draw/src/adapters/maplibre/styles.test.js +155 -0
- package/plugins/draw/src/adapters/maplibre/utils/snapHelpers.js +202 -0
- package/plugins/draw/src/adapters/maplibre/utils/snapHelpers.test.js +253 -0
- package/plugins/draw/src/adapters/maplibre/utils/touchClickWorkaround.js +57 -0
- package/plugins/draw/src/adapters/maplibre/utils/touchClickWorkaround.test.js +106 -0
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +117 -0
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +159 -0
- package/plugins/draw/src/adapters/openlayers/__helpers__/harness.js +90 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +178 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +153 -0
- package/plugins/draw/src/adapters/openlayers/core/featureStore.js +69 -0
- package/plugins/draw/src/adapters/openlayers/core/featureStore.test.js +58 -0
- package/plugins/draw/src/adapters/openlayers/core/internalEvents.js +8 -0
- package/plugins/draw/src/adapters/openlayers/core/styles.js +155 -0
- package/plugins/draw/src/adapters/openlayers/core/styles.test.js +143 -0
- package/plugins/draw/src/adapters/openlayers/defaults.js +1 -0
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +272 -0
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +431 -0
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.js +139 -0
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.test.js +140 -0
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.js +144 -0
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.test.js +196 -0
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +385 -0
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +303 -0
- package/plugins/draw/src/adapters/openlayers/edit/activeVertexLayer.js +55 -0
- package/plugins/draw/src/adapters/openlayers/edit/activeVertexLayer.test.js +53 -0
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.js +157 -0
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.test.js +195 -0
- package/plugins/draw/src/adapters/openlayers/edit/midpointLayer.js +57 -0
- package/plugins/draw/src/adapters/openlayers/edit/midpointLayer.test.js +42 -0
- package/plugins/draw/src/adapters/openlayers/edit/modifyInteraction.js +83 -0
- package/plugins/draw/src/adapters/openlayers/edit/modifyInteraction.test.js +80 -0
- package/plugins/draw/src/adapters/openlayers/edit/nudge.js +118 -0
- package/plugins/draw/src/adapters/openlayers/edit/nudge.test.js +165 -0
- package/plugins/draw/src/adapters/openlayers/edit/pointerHandlers.js +79 -0
- package/plugins/draw/src/adapters/openlayers/edit/pointerHandlers.test.js +78 -0
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +116 -0
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +109 -0
- package/plugins/draw/src/adapters/openlayers/edit/touchHandler.js +184 -0
- package/plugins/draw/src/adapters/openlayers/edit/touchHandler.test.js +133 -0
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +94 -0
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +64 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexHitTest.js +74 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexHitTest.test.js +28 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexLayer.js +49 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexLayer.test.js +42 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexOps.js +100 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexOps.test.js +80 -0
- package/plugins/draw/src/adapters/openlayers/olDraw.js +40 -0
- package/plugins/draw/src/adapters/openlayers/olDraw.test.js +70 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapEngine.js +220 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapEngine.test.js +232 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapGeometry.js +198 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapGeometry.test.js +136 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapIndicator.js +81 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapIndicator.test.js +72 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapInteraction.js +57 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapInteraction.test.js +68 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapManager.js +99 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapManager.test.js +101 -0
- package/plugins/draw/src/adapters/openlayers/utils/geometryHelpers.js +103 -0
- package/plugins/draw/src/adapters/openlayers/utils/geometryHelpers.test.js +76 -0
- package/plugins/draw/src/adapters/openlayers/utils/olCoords.js +35 -0
- package/plugins/draw/src/adapters/openlayers/utils/olCoords.test.js +22 -0
- package/plugins/draw/src/adapters/openlayers/utils/sketchHelpers.js +22 -0
- package/plugins/draw/src/adapters/openlayers/utils/sketchHelpers.test.js +18 -0
- package/plugins/draw/src/adapters/openlayers/utils/touchTarget.js +8 -0
- package/plugins/draw/src/api/addFeature.js +22 -0
- package/plugins/draw/src/api/addFeature.test.js +41 -0
- package/plugins/draw/src/api/deleteFeature.js +11 -0
- package/plugins/draw/src/api/deleteFeature.test.js +24 -0
- package/plugins/draw/src/api/editFeature.js +54 -0
- package/plugins/draw/src/api/editFeature.test.js +134 -0
- package/plugins/draw/src/api/merge.js +30 -0
- package/plugins/draw/src/api/merge.test.js +57 -0
- package/plugins/draw/src/api/newLine.js +41 -0
- package/plugins/draw/src/api/newLine.test.js +93 -0
- package/plugins/draw/src/api/newPolygon.js +41 -0
- package/plugins/draw/src/api/newPolygon.test.js +93 -0
- package/plugins/draw/src/api/split.js +117 -0
- package/plugins/draw/src/api/split.test.js +204 -0
- package/plugins/draw/src/defaults.js +52 -0
- package/plugins/draw/src/defaults.test.js +18 -0
- package/plugins/draw/src/draw.scss +43 -0
- package/plugins/draw/src/events.js +237 -0
- package/plugins/draw/src/events.test.js +369 -0
- package/plugins/draw/src/index.js +10 -0
- package/plugins/draw/src/index.test.js +24 -0
- package/plugins/draw/src/manifest.js +170 -0
- package/plugins/draw/src/manifest.test.js +147 -0
- package/plugins/draw/src/reducer.js +69 -0
- package/plugins/draw/src/reducer.test.js +85 -0
- package/plugins/draw/src/utils/debounce.js +16 -0
- package/plugins/draw/src/utils/debounce.test.js +40 -0
- package/plugins/draw/src/utils/eventBus.js +36 -0
- package/plugins/draw/src/utils/eventBus.test.js +47 -0
- package/plugins/draw/src/utils/flattenStyleProperties.js +25 -0
- package/plugins/draw/src/utils/flattenStyleProperties.test.js +33 -0
- package/plugins/draw/src/utils/getValueForStyle.js +33 -0
- package/plugins/draw/src/utils/getValueForStyle.test.js +32 -0
- package/plugins/draw/src/utils/resolveColors.js +39 -0
- package/plugins/draw/src/utils/resolveColors.test.js +34 -0
- package/plugins/draw/src/utils/spatial.js +243 -0
- package/plugins/draw/src/utils/spatial.test.js +243 -0
- package/plugins/draw/src/utils/touchTarget.js +95 -0
- package/plugins/draw/src/utils/touchTarget.test.js +107 -0
- package/plugins/draw/src/utils/undoStack.js +31 -0
- package/plugins/draw/src/utils/undoStack.test.js +49 -0
- package/plugins/draw/src/validation/liveDrawChecks.js +120 -0
- package/plugins/draw/src/validation/liveDrawChecks.test.js +159 -0
- package/plugins/draw/src/validation/liveStroke.js +85 -0
- package/plugins/draw/src/validation/liveStroke.test.js +150 -0
- package/plugins/draw/src/validation/rules.areaError.test.js +12 -0
- package/plugins/draw/src/validation/rules.js +186 -0
- package/plugins/draw/src/validation/rules.test.js +120 -0
- package/plugins/draw/src/validation/validateGeometry.js +119 -0
- package/plugins/draw/src/validation/validateGeometry.test.js +200 -0
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/src/hooks/useInteractionHandlers.js +1 -1
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +1 -1
- package/plugins/interact/src/utils/buildStylesMap.js +1 -0
- package/plugins/search/dist/css/index.css +1 -317
- package/rollup.esm.mjs +35 -28
- package/sonar-project.properties +2 -2
- package/src/App/components/Attributions/Attributions.module.scss +1 -0
- package/src/App/components/Hints/Hints.module.scss +5 -4
- package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +1 -1
- package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +11 -0
- package/src/App/components/MoveControl/MoveControl.jsx +73 -9
- package/src/App/components/MoveControl/MoveControl.module.scss +12 -2
- package/src/App/components/MoveControl/MoveControl.test.jsx +136 -0
- package/src/App/hooks/useHintsAPI.js +67 -0
- package/src/App/hooks/useHintsAPI.test.js +145 -0
- package/src/App/renderer/PluginInits.jsx +4 -0
- package/src/App/renderer/PluginInits.test.jsx +7 -1
- package/src/InteractiveMap/InteractiveMap.js +20 -0
- package/src/InteractiveMap/InteractiveMap.test.js +7 -0
- package/src/config/events.js +4 -0
- package/src/scss/settings/_dimensions.scss +3 -0
- package/src/services/announcer.js +38 -3
- package/src/services/announcer.test.js +133 -1
- package/src/services/hints.js +3 -0
- package/src/services/hints.test.js +19 -0
- package/src/types.js +12 -0
- package/src/utils/detectInterfaceType.js +5 -1
- package/src/utils/isMac.js +15 -0
- package/src/utils/isMac.test.js +37 -0
- package/webpack.umd.mjs +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see im-draw-plugin.js.LICENSE.txt */
|
|
2
|
+
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[568],{278(e,t,n){n.d(t,{Et:()=>h,Gf:()=>c,Lr:()=>u,n1:()=>a,nv:()=>f,tR:()=>p,wi:()=>l,zX:()=>r,zx:()=>s});var r=6371008.8,i={centimeters:100*r,centimetres:100*r,degrees:360/(2*Math.PI),feet:3.28084*r,inches:39.37*r,kilometers:r/1e3,kilometres:r/1e3,meters:r,metres:r,miles:r/1609.344,millimeters:1e3*r,millimetres:1e3*r,nauticalmiles:r/1852,radians:1,yards:1.0936*r};function o(e,t,n={}){const r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function s(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!h(e[0])||!h(e[1]))throw new Error("coordinates must contain numbers");return o({type:"Point",coordinates:e},t,n)}function a(e,t,n={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return o({type:"Polygon",coordinates:e},t,n)}function l(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return o({type:"LineString",coordinates:e},t,n)}function u(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function c(e,t="kilometers"){const n=i[t];if(!n)throw new Error(t+" units is invalid");return e/n}function f(e){return e%(2*Math.PI)*180/Math.PI}function p(e){return e%360*Math.PI/180}function h(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}},850(e,t,n){function r(e,t,n){if(null!==e)for(var i,o,s,a,l,u,c,f,p=0,h=0,d=e.type,y="FeatureCollection"===d,g="Feature"===d,m=y?e.features.length:1,v=0;v<m;v++){l=(f=!!(c=y?e.features[v].geometry:g?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var b=0;b<l;b++){var E=0,w=0;if(null!==(a=f?c.geometries[b]:c)){u=a.coordinates;var S=a.type;switch(p=!n||"Polygon"!==S&&"MultiPolygon"!==S?0:1,S){case null:break;case"Point":if(!1===t(u,h,v,E,w))return!1;h++,E++;break;case"LineString":case"MultiPoint":for(i=0;i<u.length;i++){if(!1===t(u[i],h,v,E,w))return!1;h++,"MultiPoint"===S&&E++}"LineString"===S&&E++;break;case"Polygon":case"MultiLineString":for(i=0;i<u.length;i++){for(o=0;o<u[i].length-p;o++){if(!1===t(u[i][o],h,v,E,w))return!1;h++}"MultiLineString"===S&&E++,"Polygon"===S&&w++}"Polygon"===S&&E++;break;case"MultiPolygon":for(i=0;i<u.length;i++){for(w=0,o=0;o<u[i].length;o++){for(s=0;s<u[i][o].length-p;s++){if(!1===t(u[i][o][s],h,v,E,w))return!1;h++}w++}E++}break;case"GeometryCollection":for(i=0;i<a.geometries.length;i++)if(!1===r(a.geometries[i],t,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t,n){var r=n;return function(e,t){var n,r,i,o,s,a,l,u,c,f,p=0,h="FeatureCollection"===e.type,d="Feature"===e.type,y=h?e.features.length:1;for(n=0;n<y;n++){for(a=h?e.features[n].geometry:d?e.geometry:e,u=h?e.features[n].properties:d?e.properties:{},c=h?e.features[n].bbox:d?e.bbox:void 0,f=h?e.features[n].id:d?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,i=0;i<s;i++)if(null!==(o=l?a.geometries[i]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,u,c,f))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===t(o.geometries[r],p,u,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,u,c,f))return!1;p++}}(e,function(e,i,o,s,a){r=0===i&&void 0===n?e:t(r,e,i,o,s,a)}),r}n.d(t,{Fh:()=>r,jE:()=>i})},360(e,t,n){n.d(t,{k:()=>r});var r={CREATE:"create",EDIT_FINISH:"editfinish",CANCEL:"cancel",VERTEX_SELECTION:"vertexselection",VERTEX_CHANGE:"vertexchange",UNDO_CHANGE:"undochange",UPDATE:"update",GEOMETRY_CHANGE:"geometrychange",INTERFACE_TYPE_CHANGE:"interfacetypechange",PLACEMENT_BLOCKED:"placementblocked",VALIDITY_CHANGE:"validitychange",CAN_PLACE_CHANGE:"canplacechange"}},682(e,t,n){n.d(t,{$y:()=>f,F0:()=>l,WQ:()=>c,lm:()=>a,vf:()=>u});var r="rgba(29,112,184,1)",i="#ffffff",o="rgba(11,12,12,1)",s="rgba(212,53,28,0.5)",a={editStroke:{light:r,dark:i},editFill:{light:"rgba(29,112,184,0.1)",dark:"rgba(255,255,255,0.1)"},editVertex:{light:r,dark:i},editMidpoint:{light:r,dark:i},editHalo:{light:i,dark:o},editActive:{light:o,dark:i},splitInvalid:{light:r,dark:i},splitValid:{light:r,dark:i},invalidStroke:{light:r,dark:i},shapeStroke:"rgba(212,53,28,1)",shapeFill:s,snapVertex:s,snapMidpoint:"rgba(40,161,151,1)",snapEdge:"rgba(29,112,184,0.5)"},l={strokeWidth:2,vertexRadius:6,midpointRadius:4,vertexHaloRadius:8,midpointHaloRadius:6,touchTargetSize:48,touchIndicatorRadius:30},u={snapRadius:12},c={nudgeAmount:1,stepAmount:5},f={small:1,medium:1.5,large:2}},977(e,t,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function s(e,t,n){return(t=function(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.r(t),n.d(t,{manifest:()=>re});var a=new Set(["draw_polygon","draw_line"]),l={SET_MODE:function(e,t){return o(o({},e),{},{mode:t,numVertices:a.has(t)?0:e.numVertices,geometryValid:!1,canAddPoint:!0})},SET_ACTION:function(e,t){return o(o({},e),{},{action:t.name,actionValid:t.isValid})},SET_FEATURE:function(e,t){return o(o({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature})},SET_SELECTED_VERTEX_INDEX:function(e,t){return o(o({},e),{},{selectedVertexIndex:t.index,numVertices:t.numVertices})},TOGGLE_SNAP:function(e){return o(o({},e),{},{snap:!e.snap})},SET_HAS_SNAP_LAYERS:function(e,t){return o(o({},e),{},{hasSnapLayers:!!t})},SET_UNDO_STACK_LENGTH:function(e,t){return o(o({},e),{},{undoStackLength:t})},SET_GEOMETRY_VALID:function(e,t){return o(o({},e),{},{geometryValid:!!t})},SET_CAN_ADD_POINT:function(e,t){return o(o({},e),{},{canAddPoint:!!t})}},u=n(738),c={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_SET_MODE:"app:setmode",APP_REVERT_MODE:"app:revertmode",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_FEATURES:"map:setfeatures",MAP_SET_ACTIVE_FEATURE:"map:setactivefeature",MAP_SELECT_FEATURE:"map:selectfeature",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"};function f(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var l=r&&r.prototype instanceof a?r:a,u=Object.create(l.prototype);return p(u,"_invoke",function(n,r,i){var o,a,l,u=0,c=i||[],f=!1,p={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,a=0,l=e,p.n=n,s}};function h(n,r){for(a=n,l=r,t=0;!f&&u&&!i&&t<c.length;t++){var i,o=c[t],h=p.p,d=o[2];n>3?(i=d===r)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(a=0,p.v=r,p.n=o[1]):h<d&&(i=n<3||o[0]>r||r>d)&&(o[4]=n,o[5]=r,p.n=d,a=0))}if(i||n>1)return s;throw f=!0,r}return function(i,c,d){if(u>1)throw TypeError("Generator is already running");for(f&&1===c&&h(c,d),a=c,l=d;(t=a<2?e:l)||!f;){o||(a?a<3?(a>1&&(p.n=-1),h(a,l)):p.n=l:p.v=l);try{if(u=2,o){if(a||(i="next"),t=o[i]){if(!(t=t.call(o,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=e}else if((t=(f=p.n<0)?l:n.call(r,p))!==s)break}catch(t){o=e,a=1,l=t}finally{u=1}}return{value:t,done:f}}}(n,i,o),!0),u}var s={};function a(){}function l(){}function u(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(p(t={},r,function(){return this}),t),h=u.prototype=a.prototype=Object.create(c);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,p(e,i,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=u,p(h,"constructor",u),p(u,"constructor",l),l.displayName="GeneratorFunction",p(u,i,"GeneratorFunction"),p(h),p(h,i,"Generator"),p(h,r,function(){return this}),p(h,"toString",function(){return"[object Generator]"}),(f=function(){return{w:o,m:d}})()}function p(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}p=function(e,t,n,r){function o(t,n){p(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},p(e,t,n,r)}function h(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}var d=function(){var e,t=(e=f().m(function e(t,r){var i,o,s,a,l;return f().w(function(e){for(;;)switch(e.n){case 0:l=t.name,e.n="MapLibreProvider"===l?1:"OpenLayersProvider"===l?3:5;break;case 1:return e.n=2,n.e(356).then(n.bind(n,24));case 2:return i=e.v,o=i.MaplibreDrawAdapter,e.a(2,new o(t,r));case 3:return e.n=4,n.e(722).then(n.bind(n,854));case 4:return s=e.v,a=s.OLDrawAdapter,e.a(2,new a(t,r));case 5:throw new Error('No draw adapter available for map provider "'.concat(t.name,'"'));case 6:return e.a(2)}},e)}),function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(e){h(o,r,i,s,a,"next",e)}function a(e){h(o,r,i,s,a,"throw",e)}s(void 0)})});return function(e,n){return t.apply(this,arguments)}}(),y=n(360),g=n(520),m=n(9),v=n(682);function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach(function(t){S(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function S(e,t,n){return(t=function(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P="edit_vertex";function x(e){var t=e.appState,n=e.appConfig,r=e.mapState,i=e.pluginState,o=e.mapProvider,s=e.eventBus,a=e.hints,l=e.resetState,u=o.draw,c=function(e,t){return function(n){var r;e.emit("draw:geometryinvalid",n),n.reason&&(r=n.reason,!Object.values(m.PH).includes(r))&&t.show(n.reason)}}(s,a),f=i.feature,p=i.tempFeature,h=i.dispatch,d=null;return w(w({handleDone:function(){u.done()},handleCancel:function(){u.getMode()===P&&null!=p&&p.id&&u.add(f),d=null,u.cancel(),l(),s.emit("draw:cancelled",f)},handleUndo:function(){return u.undo()},handleDeleteVertex:function(){return u.deleteVertex()},handleSnap:function(){i.dispatch({type:"TOGGLE_SNAP"}),u.setSnapEnabled(!i.snap)},onCreate:function(e){var i=(0,g.$U)(e,{phase:"create",mode:u.getMode()},{onGeometryChange:u._geometryValidator}),o=i.valid,a=i.reason;if(!o)return d=e.id,c({feature:e,reason:a,phase:"create",mode:P}),void setTimeout(function(){return function(e,t){var n,r,i,o=e.draw,s=e.appState,a=e.appConfig,l=e.mapState,u=e.dispatch;o.changeMode(P,{container:null==s||null===(n=s.layoutRefs)||void 0===n||null===(n=n.viewportRef)||void 0===n?void 0:n.current,deleteVertexButtonId:"".concat(null==a?void 0:a.id,"-draw-delete-point"),undoButtonId:"".concat(null==a?void 0:a.id,"-draw-undo"),isPanEnabled:"keyboard"!==(null==s?void 0:s.interfaceType),interfaceType:null==s?void 0:s.interfaceType,scale:v.$y[null==l?void 0:l.mapSize],featureId:t,getSnapEnabled:function(){return o.isSnapEnabled()}});var c=o.get(t);u({type:"SET_FEATURE",payload:{feature:c,tempFeature:c}}),u({type:"SET_MODE",payload:P}),u({type:"SET_GEOMETRY_VALID",payload:!1}),null===(r=o.setGeometryValid)||void 0===r||r.call(o,!1),null===(i=o.setInvalid)||void 0===i||i.call(o,!0)}({draw:u,appState:t,appConfig:n,mapState:r,dispatch:h},e.id)},0);l(),setTimeout(function(){return u.changeMode("disabled")},0),s.emit("draw:created",e)},onEditFinish:function(e){l(),setTimeout(function(){return u.changeMode("disabled")},0),d&&e.id===d?(d=null,s.emit("draw:created",e)):s.emit("draw:edited",e)},onCancel:function(){}},function(e){var t=e.draw,n=e.pluginState,r=e.mapProvider,i=e.eventBus;return{onVertexSelection:function(e){n.dispatch({type:"SET_SELECTED_VERTEX_INDEX",payload:e}),r.activeMoveTarget=e.index>=0?function(e){return{move:function(t,n,r){return e.nudgeSelectedVertex(t,n,r)},label:"vertex"}}(t):null,i.emit("draw:vertexselection",e)},onVertexChange:function(e){n.dispatch({type:"SET_SELECTED_VERTEX_INDEX",payload:{index:-1,numVertices:e.numVertices}}),r.activeMoveTarget=null}}}({draw:u,pluginState:i,mapProvider:o,eventBus:s})),{},{onUndoChange:function(e){i.dispatch({type:"SET_UNDO_STACK_LENGTH",payload:e})},onUpdate:function(e){s.emit("draw:updated",e)},onGeometryChange:function(e){var t;if(null!=e&&e.phase){var n,r=u.getMode(),o={phase:e.phase,vertexIndex:e.vertexIndex,mode:r},s=(0,g.$U)(e.feature,o,{onGeometryChange:u._geometryValidator}),a=s.valid,l=s.reason;i.dispatch({type:"SET_GEOMETRY_VALID",payload:a}),null===(t=u.setGeometryValid)||void 0===t||t.call(u,a),r===P&&(null===(n=u.setInvalid)||void 0===n||n.call(u,!a)),a||c(w(w({reason:l},o),{},{feature:e.feature}))}},onPlacementBlocked:function(e){c(e)},onValidityChange:function(e){var t;i.dispatch({type:"SET_GEOMETRY_VALID",payload:e.valid}),null===(t=u.setGeometryValid)||void 0===t||t.call(u,e.valid)},onCanPlaceChange:function(e){i.dispatch({type:"SET_CAN_ADD_POINT",payload:e.canPlace})},onInterfaceTypeChange:function(e){s.emit("draw:interfacetypechange",{interfaceType:e.interfaceType})}})}function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,a=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return T(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var A=new Set(["stroke","fill","strokeWidth"]),C=function(e){if(!e)return{};for(var t={},n=0,r=Object.entries(e);n<r.length;n++){var i=_(r[n],2),o=i[0],s=i[1];if(A.has(o)&&"object"===O(s)&&null!==s){var a=Object.entries(s);a.length>0&&(t[o]=a[0][1]);for(var l=0,u=a;l<u.length;l++){var c=_(u[l],2),f=c[0],p=c[1];t["".concat(o).concat(f.charAt(0).toUpperCase()+f.slice(1))]=p}}else t[o]=s}return t};function k(e){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}var M=["stroke","fill","strokeWidth","properties","onGeometryChange"];function I(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?I(Object(n),!0).forEach(function(t){R(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):I(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function R(e,t,n){return(t=function(e){var t=function(e){if("object"!=k(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==k(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function N(e){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N(e)}var j=["stroke","fill","strokeWidth","properties","onGeometryChange"];function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function G(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach(function(t){F(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function F(e,t,n){return(t=function(e){var t=function(e){if("object"!=N(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=N(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==N(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function V(e){return V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},V(e)}var B=["stroke","fill","strokeWidth","properties"];function U(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?U(Object(n),!0).forEach(function(t){q(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):U(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function q(e,t,n){return(t=function(e){var t=function(e){if("object"!=V(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=V(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==V(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Y=n(704);function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var W="_splitter",$=function(e){var t,n,r,i,o=e.draw,s=(t=e.polygonFeature,n=e.feature,!(!(i=null===(r=n.geometry)||void 0===r?void 0:r.coordinates)||i.length<2||!(0,Y.ns)(t,{id:W,geometry:n.geometry})));return o.setDrawingPreviewProperty("splitter",s?"valid":"invalid"),s};function X(e){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},X(e)}function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?K(Object(n),!0).forEach(function(t){J(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function J(e,t,n){return(t=function(e){var t=function(e){if("object"!=X(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=X(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==X(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Q,ee="top-middle",te="undefined"!=typeof navigator&&/mac/i.test((null===(Q=navigator.userAgentData)||void 0===Q?void 0:Q.platform)||navigator.platform||"")?"<kbd>Command</kbd> + <kbd>Z</kbd>":"<kbd>Ctrl</kbd> + <kbd>Z</kbd>",ne=function(e){return{mobile:{slot:"actions",showLabel:e},tablet:{slot:"actions",showLabel:e},desktop:{slot:"actions",showLabel:e}}},re={reducer:{initialState:{mode:null,action:null,actionValid:!1,feature:null,tempFeature:null,selectedVertexIndex:-1,numVertices:null,geometryValid:!0,canAddPoint:!0,snap:!1,hasSnapLayers:!1,undoStackLength:0},actions:l},InitComponent:function(e){var t=e.appState,n=e.appConfig,r=e.mapState,i=e.pluginConfig,o=e.pluginState,s=e.services,a=e.mapProvider,l=e.buttonConfig,f=s.eventBus,p=s.hints,h=r.crossHair,g=["touch","keyboard"].includes(t.interfaceType);(0,u.useEffect)(function(){var e,n,s,l,u=null===(e=null===(n=i.includeModes)||void 0===n?void 0:n.includes(t.mode))||void 0===e||e,p=null!==(s=null===(l=i.excludeModes)||void 0===l?void 0:l.includes(t.mode))&&void 0!==s&&s;if(r.isMapReady&&u&&!p){var h=!0;return d(a,{mapStyle:r.mapStyle,snapLayers:i.snapLayers,pluginConfig:i,events:c,eventBus:f}).then(function(e){var t;h&&(a.draw=e,o.dispatch({type:"SET_HAS_SNAP_LAYERS",payload:(null===(t=i.snapLayers)||void 0===t?void 0:t.length)>0}),f.emit("draw:ready"))}),function(){var e;h=!1,null===(e=a.draw)||void 0===e||e.remove(),a.draw=null,a.activeMoveTarget=null}}},[r.isMapReady,t.mode]),(0,u.useEffect)(function(){if(["draw_polygon","draw_line"].includes(o.mode)&&g){var e=h.isVisible;return h.fixAtCenter(),function(){e||["touch","keyboard"].includes(t.interfaceType)||h.hide()}}},[o.mode,t.interfaceType]),(0,u.useEffect)(function(){["edit_vertex","draw_polygon","draw_line"].includes(o.mode)&&a.draw&&a.draw.setInterfaceType(t.interfaceType)},[t.interfaceType,o.mode]),(0,u.useEffect)(function(){if(a.draw)return function(e){var t=e.appState,n=e.appConfig,r=e.mapState,i=e.pluginState,o=e.mapProvider,s=e.buttonConfig,a=e.eventBus,l=e.hints,u=o.draw,c=x({appState:t,appConfig:n,mapState:r,pluginState:i,mapProvider:o,eventBus:a,hints:l,resetState:function(){i.dispatch({type:"SET_MODE",payload:null}),i.dispatch({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),o.activeMoveTarget=null}});return function(e,t){var n=e.drawDone,r=e.drawCancel,i=e.drawUndo,o=e.drawDeletePoint,s=e.drawSnap;n.onClick=t.handleDone,r.onClick=t.handleCancel,i.onClick=t.handleUndo,o&&(o.onClick=t.handleDeleteVertex),s&&(s.onClick=t.handleSnap)}(s,c),function(e,t){e.on(y.k.CREATE,t.onCreate),e.on(y.k.EDIT_FINISH,t.onEditFinish),e.on(y.k.CANCEL,t.onCancel),e.on(y.k.VERTEX_SELECTION,t.onVertexSelection),e.on(y.k.VERTEX_CHANGE,t.onVertexChange),e.on(y.k.UNDO_CHANGE,t.onUndoChange),e.on(y.k.UPDATE,t.onUpdate),e.on(y.k.GEOMETRY_CHANGE,t.onGeometryChange),e.on(y.k.PLACEMENT_BLOCKED,t.onPlacementBlocked),e.on(y.k.VALIDITY_CHANGE,t.onValidityChange),e.on(y.k.CAN_PLACE_CHANGE,t.onCanPlaceChange),e.on(y.k.INTERFACE_TYPE_CHANGE,t.onInterfaceTypeChange)}(u,c),function(){!function(e){var t=e.drawDone,n=e.drawCancel,r=e.drawUndo,i=e.drawDeletePoint,o=e.drawSnap;t.onClick=null,n.onClick=null,r.onClick=null,i&&(i.onClick=null),o&&(o.onClick=null)}(s),function(e,t){e.off(y.k.CREATE,t.onCreate),e.off(y.k.EDIT_FINISH,t.onEditFinish),e.off(y.k.CANCEL,t.onCancel),e.off(y.k.VERTEX_SELECTION,t.onVertexSelection),e.off(y.k.VERTEX_CHANGE,t.onVertexChange),e.off(y.k.UNDO_CHANGE,t.onUndoChange),e.off(y.k.UPDATE,t.onUpdate),e.off(y.k.GEOMETRY_CHANGE,t.onGeometryChange),e.off(y.k.PLACEMENT_BLOCKED,t.onPlacementBlocked),e.off(y.k.VALIDITY_CHANGE,t.onValidityChange),e.off(y.k.CAN_PLACE_CHANGE,t.onCanPlaceChange),e.off(y.k.INTERFACE_TYPE_CHANGE,t.onInterfaceTypeChange)}(u,c)}}({appState:t,appConfig:n,mapState:r,mapProvider:a,buttonConfig:l,pluginState:o,events:c,eventBus:f,hints:p})},[a,t,o])},buttons:[Z({id:"drawCancel",label:"Cancel",variant:"tertiary",exclusiveSlot:!0,hiddenWhen:function(e){return!e.pluginState.mode}},ne(!0)),Z({id:"drawAddPoint",label:"Add point",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.appState,n=e.pluginState;return!["draw_polygon","draw_line"].includes(n.mode)||"touch"!==t.interfaceType},enableWhen:function(e){return e.pluginState.canAddPoint}},ne(!0)),Z({id:"drawDone",label:"Done",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){var t=e.pluginState,n=t.mode,r=t.geometryValid;return["draw_polygon","draw_line","edit_vertex"].includes(n)&&r}},ne(!0)),{id:"drawMenu",label:function(e){return"edit_vertex"===e.pluginState.mode?"Edit actions":"Draw actions"},iconId:"menu",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},menuItems:[{id:"drawUndo",label:"Undo",iconId:"undo",hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){var t=e.pluginState;return["draw_polygon","draw_line"].includes(t.mode)?t.numVertices>0:t.undoStackLength>0}},{id:"drawSnap",label:"Snap to feature",iconId:"magnet",hiddenWhen:function(e){var t=e.pluginState;return!t.mode||!t.hasSnapLayers},pressedWhen:function(e){return!!e.pluginState.snap}},{id:"drawDeletePoint",label:"Delete point",iconId:"trash",enableWhen:function(e){var t,n=e.pluginState;return!(n.selectedVertexIndex<0)&&("Polygon"===(null===(t=n.feature)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type)?n.numVertices>3:n.numVertices>2)},hiddenWhen:function(e){return"edit_vertex"!==e.pluginState.mode}}],mobile:{slot:ee},tablet:{slot:ee},desktop:{slot:ee}}],keyboardShortcuts:[{id:"drawAddPoint",group:"Drawing",title:"Add point (draw)",command:"<kbd>Enter</kbd>"},{id:"drawSelectPoint",group:"Drawing",title:"Select nearest point (edit)",command:"<kbd>Spacebar</kbd>"},{id:"drawSelectAdjacentPoint",group:"Drawing",title:"Select adjacent point (edit)",command:"<kbd>Alt</kbd> + <kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> or <kbd>→</kbd>"},{id:"drawMovePoint",group:"Drawing",title:"Move point (edit)",command:"<kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> or <kbd>→</kbd>"},{id:"drawNudgePoint",group:"Drawing",title:"Nudge point (edit)",command:"<kbd>Shift</kbd> + <kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> or <kbd>→</kbd>"},{id:"drawDeletePoint",group:"Drawing",title:"Delete point (edit)",command:"<kbd>Delete</kbd>"},{id:"drawUndo",group:"Drawing",title:"Undo",command:te}],icons:[{id:"menu",svgContent:'<path d="m6 9 6 6 6-6"/>'},{id:"undo",svgContent:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/>'},{id:"magnet",svgContent:'<path d="m12 15 4 4"/><path d="M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z"/><path d="m5 8 4 4"/>'},{id:"trash",svgContent:'<path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>'}],api:{newPolygon:function(e,t){var n,r=e.appState,i=e.appConfig,o=e.pluginConfig,s=e.pluginState,a=e.mapState,l=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},f=s.dispatch,p=l.draw,h=u.eventBus;if(p){h.emit("draw:started",{mode:"draw_polygon"});var d=void 0===c.snapLayers?null!==(n=o.snapLayers)&&void 0!==n?n:null:c.snapLayers;p.setSnapLayers(d),f({type:"SET_HAS_SNAP_LAYERS",payload:(null==d?void 0:d.length)>0});var y=c.stroke,g=c.fill,m=c.strokeWidth,v=c.properties,b=c.onGeometryChange,E=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(c,M);p._geometryValidator=null!=b?b:o.onGeometryChange;var w=L(L({},v),C({stroke:y,fill:g,strokeWidth:m}));p.changeMode("draw_polygon",L(L({container:r.layoutRefs.viewportRef.current,addVertexButtonId:"".concat(i.id,"-draw-add-point"),interfaceType:r.interfaceType,crossHair:a.crossHair,getSnapEnabled:function(){return p.isSnapEnabled()},featureId:t},E),{},{properties:w})),f({type:"SET_MODE",payload:"draw_polygon"})}},newLine:function(e,t){var n,r=e.appState,i=e.appConfig,o=e.pluginConfig,s=e.pluginState,a=e.mapState,l=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},f=s.dispatch,p=l.draw,h=u.eventBus;if(p){h.emit("draw:started",{mode:"draw_line"});var d=void 0===c.snapLayers?null!==(n=o.snapLayers)&&void 0!==n?n:null:c.snapLayers;p.setSnapLayers(d),f({type:"SET_HAS_SNAP_LAYERS",payload:(null==d?void 0:d.length)>0});var y=c.stroke,g=c.fill,m=c.strokeWidth,v=c.properties,b=c.onGeometryChange,E=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(c,j);p._geometryValidator=null!=b?b:o.onGeometryChange;var w=G(G({},v),C({stroke:y,fill:g,strokeWidth:m}));p.changeMode("draw_line",G(G({container:r.layoutRefs.viewportRef.current,addVertexButtonId:"".concat(i.id,"-draw-add-point"),interfaceType:r.interfaceType,crossHair:a.crossHair,getSnapEnabled:function(){return p.isSnapEnabled()},featureId:t},E),{},{properties:w})),f({type:"SET_MODE",payload:"draw_line"})}},editFeature:function(e,t){var n,r,i,o=e.appState,s=e.appConfig,a=e.mapState,l=e.pluginConfig,u=e.pluginState,c=e.mapProvider,f=e.services,p=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},h=u.dispatch,d=c.draw,y=f.eventBus;if(!d)return!1;var m=d.get(t);if(!m)return!1;d._geometryValidator=null!==(n=p.onGeometryChange)&&void 0!==n?n:l.onGeometryChange,y.emit("draw:editstart",{mode:{LineString:"edit_line",Polygon:"edit_polygon"}[m.geometry.type]});var b=void 0===p.snapLayers?null!==(r=l.snapLayers)&&void 0!==r?r:null:p.snapLayers;d.setSnapLayers(b),h({type:"SET_HAS_SNAP_LAYERS",payload:(null==b?void 0:b.length)>0}),d.changeMode("edit_vertex",{container:o.layoutRefs.viewportRef.current,deleteVertexButtonId:"".concat(s.id,"-draw-delete-point"),undoButtonId:"".concat(s.id,"-draw-undo"),isPanEnabled:"keyboard"!==o.interfaceType,interfaceType:o.interfaceType,scale:v.$y[a.mapSize],featureId:t,getSnapEnabled:function(){return d.isSnapEnabled()}});var E=d.get(t);h({type:"SET_FEATURE",payload:{feature:E,tempFeature:E}}),h({type:"SET_MODE",payload:"edit_vertex"});var w=(0,g.$U)(E,{phase:"edit-start",mode:"edit_vertex"},{onGeometryChange:d._geometryValidator}).valid;return h({type:"SET_GEOMETRY_VALID",payload:w}),null===(i=d.setInvalid)||void 0===i||i.call(d,!w),!0},addFeature:function(e,t){var n=e.mapProvider,r=e.services,i=n.draw,o=r.eventBus;if(i){var s=t.stroke,a=t.fill,l=t.strokeWidth,u=t.properties,c=H(H({},function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,B)),{},{properties:H(H({},u),C({stroke:s,fill:a,strokeWidth:l}))});i.add(c),o.emit("draw:add",c)}},deleteFeature:function(e,t){var n=e.mapProvider,r=e.services,i=n.draw,o=r.eventBus;i&&(i.delete(t),o.emit("draw:delete",{featureId:t}))},split:function(e,t){var n,r=e.appState,i=e.appConfig,o=e.pluginState,s=e.mapState,a=e.mapProvider,l=e.services,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=o.dispatch,f=a.draw,p=l.eventBus;if(f){var h=f.get(t),d=f._geometryValidator;f._geometryValidator=function(e){var t=e.draw,n=e.dispatch,r=e.polygonFeature;return function(e){var i,o=e.feature,s=e.phase;if("preview"===s)i=$({draw:t,polygonFeature:r,feature:o});else{if(null==s||!s.startsWith("commit-"))return{valid:!0};i=function(e){var t=e.draw,n=e.dispatch,r=$({draw:t,polygonFeature:e.polygonFeature,feature:e.feature});return n({type:"SET_ACTION",payload:{name:"split",isValid:r}}),n({type:"SET_GEOMETRY_VALID",payload:r}),t.setGeometryValid(r),r}({draw:t,dispatch:n,polygonFeature:r,feature:o})}return i?{valid:!0}:{valid:!1,reason:"Line does not split the shape into two parts"}}}({draw:f,dispatch:c,polygonFeature:h});var g=["stroke-inactive.cold"].concat(function(e){if(Array.isArray(e))return z(e)}(n=u.snapLayers||[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e,t){if(e){if("string"==typeof e)return z(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(e,t):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());f.setSnapLayers(g),c({type:"SET_HAS_SNAP_LAYERS",payload:!0}),f.changeMode("draw_line",{container:r.layoutRefs.viewportRef.current,addVertexButtonId:"".concat(i.id,"-draw-add-point"),interfaceType:r.interfaceType,crossHair:null==s?void 0:s.crossHair,getSnapEnabled:function(){return f.isSnapEnabled()},featureId:W,properties:{splitter:"invalid"}});var m=function(){f._geometryValidator=d,f.off(y.k.CREATE,v),f.off(y.k.CANCEL,b)},v=function(e){m(),f.delete(W);var n=(0,Y.ns)(h,e);c({type:"SET_ACTION",payload:{name:"split",isValid:!!n}}),n&&p.emit("draw:split",{originalFeatureId:t,featureCollection:n})},b=function(){m()};f.on(y.k.CREATE,v),f.on(y.k.CANCEL,b),c({type:"SET_MODE",payload:"draw_line"}),c({type:"SET_ACTION",payload:{name:"split"}})}},merge:function(e,t){var n=e.mapProvider,r=e.services,i=n.draw,o=r.eventBus;if(!i)return null;var s=t.map(function(e){return i.get(e)}),a=(0,Y.OI)(s);return a&&o.emit("draw:merge",{originalFeatureIds:t,feature:a}),a}}}},704(e,t,n){function r(e){var t={type:"Feature"};return Object.keys(e).forEach(function(n){switch(n){case"type":case"properties":case"geometry":return;default:t[n]=e[n]}}),t.properties=i(e.properties),t.geometry=o(e.geometry),t}function i(e){var t={};return e?(Object.keys(e).forEach(function(n){var r=e[n];"object"==typeof r?null===r?t[n]=null:Array.isArray(r)?t[n]=r.map(function(e){return e}):t[n]=i(r):t[n]=r}),t):t}function o(e){var t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(function(e){return o(e)}),t):(t.coordinates=s(e.coordinates),t)}function s(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map(function(e){return s(e)})}n.d(t,{jK:()=>yt,DF:()=>dt,OI:()=>pt,cj:()=>gt,ns:()=>ft});function a(e){for(var t,n,r=function(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}(e),i=0,o=1;o<r.length;)t=n||r[0],i+=((n=r[o])[0]-t[0])*(n[1]+t[1]),o++;return i>0}function l(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var n=0;n<e.features.length&&!1!==t(e.features[n],n);n++);}function u(e,t){var n,r,i,o,s,a,l,u,c,f,p=0,h="FeatureCollection"===e.type,d="Feature"===e.type,y=h?e.features.length:1;for(n=0;n<y;n++){for(a=h?e.features[n].geometry:d?e.geometry:e,u=h?e.features[n].properties:d?e.properties:{},c=h?e.features[n].bbox:d?e.bbox:void 0,f=h?e.features[n].id:d?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,i=0;i<s;i++)if(null!==(o=l?a.geometries[i]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,u,c,f))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===t(o.geometries[r],p,u,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,u,c,f))return!1;p++}}function c(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function f(e,t){switch("Feature"===e.type?e.geometry.type:e.type){case"GeometryCollection":return u(e,function(e){f(e,t)}),e;case"LineString":return p(c(e),t),e;case"Polygon":return h(c(e),t),e;case"MultiLineString":return c(e).forEach(function(e){p(e,t)}),e;case"MultiPolygon":return c(e).forEach(function(e){h(e,t)}),e;case"Point":case"MultiPoint":return e}}function p(e,t){a(e)===t&&e.reverse()}function h(e,t){a(e[0])!==t&&e[0].reverse();for(var n=1;n<e.length;n++)a(e[n])===t&&e[n].reverse()}const d=function(e,t){if(!(n=t=t||{})||n.constructor!==Object)throw new Error("options is invalid");var n,i=t.reverse||!1,s=t.mutate||!1;if(!e)throw new Error("<geojson> is required");if("boolean"!=typeof i)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof s)throw new Error("<mutate> must be a boolean");!1===s&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return r(e);case"FeatureCollection":return function(e){var t={type:"FeatureCollection"};return Object.keys(e).forEach(function(n){switch(n){case"type":case"features":return;default:t[n]=e[n]}}),t.features=e.features.map(function(e){return r(e)}),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return o(e);default:throw new Error("unknown GeoJSON type")}}(e));var a=[];switch(e.type){case"GeometryCollection":return u(e,function(e){f(e,i)}),e;case"FeatureCollection":return l(e,function(e){l(f(e,i),function(e){a.push(e)})}),function(e,t){void 0===t&&(t={});var n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}(a)}return f(e,i)},y=11102230246251565e-32,g=134217729,m=(3+8*y)*y;function v(e,t,n,r,i){let o,s,a,l,u=t[0],c=r[0],f=0,p=0;c>u==c>-u?(o=u,u=t[++f]):(o=c,c=r[++p]);let h=0;if(f<e&&p<n)for(c>u==c>-u?(s=u+o,a=o-(s-u),u=t[++f]):(s=c+o,a=o-(s-c),c=r[++p]),o=s,0!==a&&(i[h++]=a);f<e&&p<n;)c>u==c>-u?(s=o+u,l=s-o,a=o-(s-l)+(u-l),u=t[++f]):(s=o+c,l=s-o,a=o-(s-l)+(c-l),c=r[++p]),o=s,0!==a&&(i[h++]=a);for(;f<e;)s=o+u,l=s-o,a=o-(s-l)+(u-l),u=t[++f],o=s,0!==a&&(i[h++]=a);for(;p<n;)s=o+c,l=s-o,a=o-(s-l)+(c-l),c=r[++p],o=s,0!==a&&(i[h++]=a);return 0===o&&0!==h||(i[h++]=o),h}function b(e){return new Float64Array(e)}const E=b(4),w=b(8),S=b(12),P=b(16),x=b(4);function O(e,t,n,r,i,o){const s=(t-o)*(n-i),a=(e-i)*(r-o),l=s-a,u=Math.abs(s+a);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,n,r,i,o,s){let a,l,u,c,f,p,h,d,y,b,O,_,T,A,C,k,M,I;const L=e-i,R=n-i,N=t-o,j=r-o;A=L*j,p=g*L,h=p-(p-L),d=L-h,p=g*j,y=p-(p-j),b=j-y,C=d*b-(A-h*y-d*y-h*b),k=N*R,p=g*N,h=p-(p-N),d=N-h,p=g*R,y=p-(p-R),b=R-y,M=d*b-(k-h*y-d*y-h*b),O=C-M,f=C-O,E[0]=C-(O+f)+(f-M),_=A+O,f=_-A,T=A-(_-f)+(O-f),O=T-k,f=T-O,E[1]=T-(O+f)+(f-k),I=_+O,f=I-_,E[2]=_-(I-f)+(O-f),E[3]=I;let D=function(e,t){let n=t[0];for(let e=1;e<4;e++)n+=t[e];return n}(0,E),G=22204460492503146e-32*s;if(D>=G||-D>=G)return D;if(f=e-L,a=e-(L+f)+(f-i),f=n-R,u=n-(R+f)+(f-i),f=t-N,l=t-(N+f)+(f-o),f=r-j,c=r-(j+f)+(f-o),0===a&&0===l&&0===u&&0===c)return D;if(G=11093356479670487e-47*s+m*Math.abs(D),D+=L*c+j*a-(N*u+R*l),D>=G||-D>=G)return D;A=a*j,p=g*a,h=p-(p-a),d=a-h,p=g*j,y=p-(p-j),b=j-y,C=d*b-(A-h*y-d*y-h*b),k=l*R,p=g*l,h=p-(p-l),d=l-h,p=g*R,y=p-(p-R),b=R-y,M=d*b-(k-h*y-d*y-h*b),O=C-M,f=C-O,x[0]=C-(O+f)+(f-M),_=A+O,f=_-A,T=A-(_-f)+(O-f),O=T-k,f=T-O,x[1]=T-(O+f)+(f-k),I=_+O,f=I-_,x[2]=_-(I-f)+(O-f),x[3]=I;const F=v(4,E,4,x,w);A=L*c,p=g*L,h=p-(p-L),d=L-h,p=g*c,y=p-(p-c),b=c-y,C=d*b-(A-h*y-d*y-h*b),k=N*u,p=g*N,h=p-(p-N),d=N-h,p=g*u,y=p-(p-u),b=u-y,M=d*b-(k-h*y-d*y-h*b),O=C-M,f=C-O,x[0]=C-(O+f)+(f-M),_=A+O,f=_-A,T=A-(_-f)+(O-f),O=T-k,f=T-O,x[1]=T-(O+f)+(f-k),I=_+O,f=I-_,x[2]=_-(I-f)+(O-f),x[3]=I;const V=v(F,w,4,x,S);A=a*c,p=g*a,h=p-(p-a),d=a-h,p=g*c,y=p-(p-c),b=c-y,C=d*b-(A-h*y-d*y-h*b),k=l*u,p=g*l,h=p-(p-l),d=l-h,p=g*u,y=p-(p-u),b=u-y,M=d*b-(k-h*y-d*y-h*b),O=C-M,f=C-O,x[0]=C-(O+f)+(f-M),_=A+O,f=_-A,T=A-(_-f)+(O-f),O=T-k,f=T-O,x[1]=T-(O+f)+(f-k),I=_+O,f=I-_,x[2]=_-(I-f)+(O-f),x[3]=I;const B=v(V,S,4,x,P);return P[B-1]}(e,t,n,r,i,o,u)}function _(e,t){var n,r,i,o,s,a,l,u,c,f=0,p=e[0],h=e[1],d=t.length;for(n=0;n<d;n++){r=0;var y=t[n],g=y.length-1;if((u=y[0])[0]!==y[g][0]&&u[1]!==y[g][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-p,s=u[1]-h;r<g;r++){if(a=(c=y[r+1])[0]-p,l=c[1]-h,0===s&&0===l){if(a<=0&&o>=0||o<=0&&a>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(0===(i=O(o,a,s,l,0,0)))return 0;(i>0&&l>0&&s<=0||i<0&&l<=0&&s>0)&&f++}u=c,s=l,o=a}}return f%2!=0}b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(8),b(8),b(8),b(4),b(8),b(8),b(8),b(12),b(192),b(192),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(8),b(8),b(8),b(8),b(8),b(8),b(8),b(8),b(8),b(4),b(4),b(4),b(8),b(16),b(16),b(16),b(32),b(32),b(48),b(64),b(1152),b(1152),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(4),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(24),b(1152),b(1152),b(1152),b(1152),b(1152),b(2304),b(2304),b(3456),b(5760),b(8),b(8),b(8),b(16),b(24),b(48),b(48),b(96),b(192),b(384),b(384),b(384),b(768),b(96),b(96),b(96),b(1152);const T=134217729;function A(e,t,n,r,i){let o,s,a,l,u=t[0],c=r[0],f=0,p=0;c>u==c>-u?(o=u,u=t[++f]):(o=c,c=r[++p]);let h=0;if(f<e&&p<n)for(c>u==c>-u?(s=u+o,a=o-(s-u),u=t[++f]):(s=c+o,a=o-(s-c),c=r[++p]),o=s,0!==a&&(i[h++]=a);f<e&&p<n;)c>u==c>-u?(s=o+u,l=s-o,a=o-(s-l)+(u-l),u=t[++f]):(s=o+c,l=s-o,a=o-(s-l)+(c-l),c=r[++p]),o=s,0!==a&&(i[h++]=a);for(;f<e;)s=o+u,l=s-o,a=o-(s-l)+(u-l),u=t[++f],o=s,0!==a&&(i[h++]=a);for(;p<n;)s=o+c,l=s-o,a=o-(s-l)+(c-l),c=r[++p],o=s,0!==a&&(i[h++]=a);return 0===o&&0!==h||(i[h++]=o),h}function C(e){return new Float64Array(e)}const k=C(4),M=C(8),I=C(12),L=C(16),R=C(4);function N(e,t,n,r,i,o){const s=(t-o)*(n-i),a=(e-i)*(r-o),l=s-a;if(0===s||0===a||s>0!=a>0)return l;const u=Math.abs(s+a);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,n,r,i,o,s){let a,l,u,c,f,p,h,d,y,g,m,v,b,E,w,S,P,x;const O=e-i,_=n-i,C=t-o,N=r-o;E=O*N,p=T*O,h=p-(p-O),d=O-h,p=T*N,y=p-(p-N),g=N-y,w=d*g-(E-h*y-d*y-h*g),S=C*_,p=T*C,h=p-(p-C),d=C-h,p=T*_,y=p-(p-_),g=_-y,P=d*g-(S-h*y-d*y-h*g),m=w-P,f=w-m,k[0]=w-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-S,f=b-m,k[1]=b-(m+f)+(f-S),x=v+m,f=x-v,k[2]=v-(x-f)+(m-f),k[3]=x;let j=function(e,t){let n=t[0];for(let e=1;e<4;e++)n+=t[e];return n}(0,k),D=22204460492503146e-32*s;if(j>=D||-j>=D)return j;if(f=e-O,a=e-(O+f)+(f-i),f=n-_,u=n-(_+f)+(f-i),f=t-C,l=t-(C+f)+(f-o),f=r-N,c=r-(N+f)+(f-o),0===a&&0===l&&0===u&&0===c)return j;if(D=11093356479670487e-47*s+33306690738754706e-32*Math.abs(j),j+=O*c+N*a-(C*u+_*l),j>=D||-j>=D)return j;E=a*N,p=T*a,h=p-(p-a),d=a-h,p=T*N,y=p-(p-N),g=N-y,w=d*g-(E-h*y-d*y-h*g),S=l*_,p=T*l,h=p-(p-l),d=l-h,p=T*_,y=p-(p-_),g=_-y,P=d*g-(S-h*y-d*y-h*g),m=w-P,f=w-m,R[0]=w-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-S,f=b-m,R[1]=b-(m+f)+(f-S),x=v+m,f=x-v,R[2]=v-(x-f)+(m-f),R[3]=x;const G=A(4,k,4,R,M);E=O*c,p=T*O,h=p-(p-O),d=O-h,p=T*c,y=p-(p-c),g=c-y,w=d*g-(E-h*y-d*y-h*g),S=C*u,p=T*C,h=p-(p-C),d=C-h,p=T*u,y=p-(p-u),g=u-y,P=d*g-(S-h*y-d*y-h*g),m=w-P,f=w-m,R[0]=w-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-S,f=b-m,R[1]=b-(m+f)+(f-S),x=v+m,f=x-v,R[2]=v-(x-f)+(m-f),R[3]=x;const F=A(G,M,4,R,I);E=a*c,p=T*a,h=p-(p-a),d=a-h,p=T*c,y=p-(p-c),g=c-y,w=d*g-(E-h*y-d*y-h*g),S=l*u,p=T*l,h=p-(p-l),d=l-h,p=T*u,y=p-(p-u),g=u-y,P=d*g-(S-h*y-d*y-h*g),m=w-P,f=w-m,R[0]=w-(m+f)+(f-P),v=E+m,f=v-E,b=E-(v-f)+(m-f),m=b-S,f=b-m,R[1]=b-(m+f)+(f-S),x=v+m,f=x-v,R[2]=v-(x-f)+(m-f),R[3]=x;const V=A(F,I,4,R,L);return L[V-1]}(e,t,n,r,i,o,u)}C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(8),C(8),C(8),C(4),C(8),C(8),C(8),C(12),C(192),C(192),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(8),C(8),C(8),C(8),C(8),C(8),C(8),C(8),C(8),C(4),C(4),C(4),C(8),C(16),C(16),C(16),C(32),C(32),C(48),C(64),C(1152),C(1152),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(4),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(24),C(1152),C(1152),C(1152),C(1152),C(1152),C(2304),C(2304),C(3456),C(5760),C(8),C(8),C(8),C(16),C(24),C(48),C(48),C(96),C(192),C(384),C(384),C(384),C(768),C(96),C(96),C(96),C(1152);var j=function(e,t,n,r,i){this.p1=e,this.p2=t,this.edgeType=n,this.originalIndex=r,this.polygonContourId=i,this.interiorRing=!1,this.minX=Math.min(e.p[0],t.p[0]),this.minY=Math.min(e.p[1],t.p[1]),this.maxX=Math.max(e.p[0],t.p[0]),this.maxY=Math.max(e.p[1],t.p[1]),this.intersectionPoints=[],this.nextEdge=null},D=function(e){this.p=e},G=function(e,t){this.id=e,this.rawCoords=t};function F(e,t){return!(e.maxX<t[0]||e.minX>t[2]||e.maxY<t[1]||e.minY>t[3])}var V=function(e,t,n,r){this.p=e,this.polylineEdge=t,this.polygonEdge=n,this.isHeadingIn=r,this.distanceFromPolylineEdgeStart=B(this.polylineEdge.p1.p,this.p),this.distanceFromPolygonEdgeStart=B(this.polygonEdge.p1.p,this.p),this.polygonEdge.intersectionPoints.push(this),this.polylineEdge.intersectionPoints.push(this),this.visitCount=0};function B(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*=n,r*=r,Math.sqrt(n+r)}function U(e,t){return e[0]*t[1]-e[1]*t[0]}function H(e,t){return e[0]*t[0]+e[1]*t[1]}function q(e,t,n){return[e[0]+t*n[0],e[1]+t*n[1]]}function Y(e,t,n){var r=[e.p2.p[0]-e.p1.p[0],e.p2.p[1]-e.p1.p[1]],i=[t.p2.p[0]-t.p1.p[0],t.p2.p[1]-t.p1.p[1]],o=[t.p1.p[0]-e.p1.p[0],t.p1.p[1]-e.p1.p[1]],s=U(r,i),a=s*s,l=H(r,r);if(a>0){var u=U(o,i)/s;if(u<0||u>1)return null;var c=U(o,r)/s;return c<0||c>1?null:0===u||1===u?n?null:[q(e.p1.p,u,r)]:0===c||1===c?n?null:[q(t.p1.p,c,i)]:[q(e.p1.p,u,r)]}var f=H(o,o);if((a=(s=U(o,r))*s)>1e-9*l*f)return null;var p=H(r,o)/l,h=p+H(r,i)/l,d=Math.min(p,h),y=Math.max(p,h);return d<=1&&y>=0?1===d?n?null:[q(e.p1.p,d>0?d:0,r)]:0===y?n?null:[q(e.p1.p,y<1?y:1,r)]:n&&0===d&&1===y?null:[q(e.p1.p,d>0?d:0,r),q(e.p1.p,y<1?y:1,r)]:null}function z(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.polygonContourId===t)return r}}function W(e,t){return t.find(function(t){return t.id===e.polygonContourId}).rawCoords}function $(e,t){for(var n=0;n<t.length;n++){var r=t[n];if(_(e[0],[r[0]]))return void r.push(e)}t.push([e])}function X(e,t){var n=e.polygonEdge;if(n.intersectionPoints.length>1&&n.intersectionPoints[n.intersectionPoints.length-1]!==e){var r=K(e,n.intersectionPoints),i=n.intersectionPoints[r+1];return t.push(i.p),i.incrementVisitCount(),i}for(var o=!0;o;){if(t.push(n.p2.p),null===(n=n.nextEdge))return e;n.intersectionPoints.length>0&&(o=!1)}return n.intersectionPoints[0].incrementVisitCount(),t.push(n.intersectionPoints[0].p),n.intersectionPoints[0]}function K(e,t){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return null}function Z(e,t){var n=e.polylineEdge;if(2===n.intersectionPoints.length){var r=n.intersectionPoints[n.intersectionPoints.length-1];if(r===e){var i=n.intersectionPoints[0];return t.push(i.p),i.incrementVisitCount(),i}return t.push(r.p),r.incrementVisitCount(),r}if(n.intersectionPoints.length>2&&n.intersectionPoints[0]!==e){var o=K(e,n.intersectionPoints),s=n.intersectionPoints[o-1];return t.push(s.p),s.incrementVisitCount(),s}for(var a=!0;a;){if(t.push(n.p1.p),void 0===(n=n.prevEdge).originalIndex)return e;n.intersectionPoints.length>0&&(a=!1)}if(void 0===n.originalIndex)return e;var l=n.intersectionPoints[n.intersectionPoints.length-1];return l.incrementVisitCount(),t.push(l.p),l}function J(e,t){var n=e.polylineEdge;if(n.intersectionPoints.length>1&&n.intersectionPoints[n.intersectionPoints.length-1]!==e){var r=K(e,n.intersectionPoints),i=n.intersectionPoints[r+1];return t.push(i.p),i.incrementVisitCount(),i}for(var o=!0;o;){if(t.push(n.p2.p),null===(n=n.nextEdge))return e;n.intersectionPoints.length>0&&(o=!1)}if(void 0===n)return e;var s=n.intersectionPoints[0];return s.incrementVisitCount(),t.push(s.p),s}V.prototype.incrementVisitCount=function(){this.visitCount=this.visitCount+1};var Q=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,ee=Math.ceil,te=Math.floor,ne="[BigNumber Error] ",re=ne+"Number primitive has more than 15 significant digits: ",ie=1e14,oe=14,se=9007199254740991,ae=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],le=1e7,ue=1e9;function ce(e){var t=0|e;return e>0||e===t?t:t-1}function fe(e){for(var t,n,r=1,i=e.length,o=e[0]+"";r<i;){for(t=e[r++]+"",n=oe-t.length;n--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function pe(e,t){var n,r,i=e.c,o=t.c,s=e.s,a=t.s,l=e.e,u=t.e;if(!s||!a)return null;if(n=i&&!i[0],r=o&&!o[0],n||r)return n?r?0:-a:s;if(s!=a)return s;if(n=s<0,r=l==u,!i||!o)return r?0:!i^n?1:-1;if(!r)return l>u^n?1:-1;for(a=(l=i.length)<(u=o.length)?l:u,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^n?1:-1;return l==u?0:l>u^n?1:-1}function he(e,t,n,r){if(e<t||e>n||e!==te(e))throw Error(ne+(r||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function de(e){var t=e.c.length-1;return ce(e.e/oe)==t&&e.c[t]%2!=0}function ye(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ge(e,t,n){var r,i;if(t<0){for(i=n+".";++t;i+=n);e=i+e}else if(++t>(r=e.length)){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var me=function e(t){var n,r,i,o,s,a,l,u,c,f,p=_.prototype={constructor:_,toString:null,valueOf:null},h=new _(1),d=20,y=4,g=-7,m=21,v=-1e7,b=1e7,E=!1,w=1,S=0,P={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},x="0123456789abcdefghijklmnopqrstuvwxyz",O=!0;function _(e,t){var n,o,s,a,l,u,c,f,p=this;if(!(p instanceof _))return new _(e,t);if(null==t){if(e&&!0===e._isBigNumber)return p.s=e.s,void(!e.c||e.e>b?p.c=p.e=null:e.e<v?p.c=[p.e=0]:(p.e=e.e,p.c=e.c.slice()));if((u="number"==typeof e)&&0*e==0){if(p.s=1/e<0?(e=-e,-1):1,e===~~e){for(a=0,l=e;l>=10;l/=10,a++);return void(a>b?p.c=p.e=null:(p.e=a,p.c=[e]))}f=String(e)}else{if(!Q.test(f=String(e)))return i(p,f,u);p.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(a=f.indexOf("."))>-1&&(f=f.replace(".","")),(l=f.search(/e/i))>0?(a<0&&(a=l),a+=+f.slice(l+1),f=f.substring(0,l)):a<0&&(a=f.length)}else{if(he(t,2,x.length,"Base"),10==t&&O)return k(p=new _(e),d+p.e+1,y);if(f=String(e),u="number"==typeof e){if(0*e!=0)return i(p,f,u,t);if(p.s=1/e<0?(f=f.slice(1),-1):1,_.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(re+e)}else p.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(n=x.slice(0,t),a=l=0,c=f.length;l<c;l++)if(n.indexOf(o=f.charAt(l))<0){if("."==o){if(l>a){a=c;continue}}else if(!s&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){s=!0,l=-1,a=0;continue}return i(p,String(e),u,t)}u=!1,(a=(f=r(f,t,10,p.s)).indexOf("."))>-1?f=f.replace(".",""):a=f.length}for(l=0;48===f.charCodeAt(l);l++);for(c=f.length;48===f.charCodeAt(--c););if(f=f.slice(l,++c)){if(c-=l,u&&_.DEBUG&&c>15&&(e>se||e!==te(e)))throw Error(re+p.s*e);if((a=a-l-1)>b)p.c=p.e=null;else if(a<v)p.c=[p.e=0];else{if(p.e=a,p.c=[],l=(a+1)%oe,a<0&&(l+=oe),l<c){for(l&&p.c.push(+f.slice(0,l)),c-=oe;l<c;)p.c.push(+f.slice(l,l+=oe));l=oe-(f=f.slice(l)).length}else l-=c;for(;l--;f+="0");p.c.push(+f)}}else p.c=[p.e=0]}function T(e,t,n,r){var i,o,s,a,l;if(null==n?n=y:he(n,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==t)l=fe(e.c),l=1==r||2==r&&(s<=g||s>=m)?ye(l,s):ge(l,s,"0");else if(o=(e=k(new _(e),t,n)).e,a=(l=fe(e.c)).length,1==r||2==r&&(t<=o||o<=g)){for(;a<t;l+="0",a++);l=ye(l,o)}else if(t-=s+(2===r&&o>s),l=ge(l,o,"0"),o+1>a){if(--t>0)for(l+=".";t--;l+="0");}else if((t+=o-a)>0)for(o+1==a&&(l+=".");t--;l+="0");return e.s<0&&i?"-"+l:l}function A(e,t){for(var n,r,i=1,o=new _(e[0]);i<e.length;i++)(!(r=new _(e[i])).s||(n=pe(o,r))===t||0===n&&o.s===t)&&(o=r);return o}function C(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*oe-1)>b?e.c=e.e=null:n<v?e.c=[e.e=0]:(e.e=n,e.c=t),e}function k(e,t,n,r){var i,o,s,a,l,u,c,f=e.c,p=ae;if(f){e:{for(i=1,a=f[0];a>=10;a/=10,i++);if((o=t-i)<0)o+=oe,s=t,l=f[u=0],c=te(l/p[i-s-1]%10);else if((u=ee((o+1)/oe))>=f.length){if(!r)break e;for(;f.length<=u;f.push(0));l=c=0,i=1,s=(o%=oe)-oe+1}else{for(l=a=f[u],i=1;a>=10;a/=10,i++);c=(s=(o%=oe)-oe+i)<0?0:te(l/p[i-s-1]%10)}if(r=r||t<0||null!=f[u+1]||(s<0?l:l%p[i-s-1]),r=n<4?(c||r)&&(0==n||n==(e.s<0?3:2)):c>5||5==c&&(4==n||r||6==n&&(o>0?s>0?l/p[i-s]:0:f[u-1])%10&1||n==(e.s<0?8:7)),t<1||!f[0])return f.length=0,r?(t-=e.e+1,f[0]=p[(oe-t%oe)%oe],e.e=-t||0):f[0]=e.e=0,e;if(0==o?(f.length=u,a=1,u--):(f.length=u+1,a=p[oe-o],f[u]=s>0?te(l/p[i-s]%p[s])*a:0),r)for(;;){if(0==u){for(o=1,s=f[0];s>=10;s/=10,o++);for(s=f[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(e.e++,f[0]==ie&&(f[0]=1));break}if(f[u]+=a,f[u]!=ie)break;f[u--]=0,a=1}for(o=f.length;0===f[--o];f.pop());}e.e>b?e.c=e.e=null:e.e<v&&(e.c=[e.e=0])}return e}function M(e){var t,n=e.e;return null===n?e.toString():(t=fe(e.c),t=n<=g||n>=m?ye(t,n):ge(t,n,"0"),e.s<0?"-"+t:t)}return _.clone=e,_.ROUND_UP=0,_.ROUND_DOWN=1,_.ROUND_CEIL=2,_.ROUND_FLOOR=3,_.ROUND_HALF_UP=4,_.ROUND_HALF_DOWN=5,_.ROUND_HALF_EVEN=6,_.ROUND_HALF_CEIL=7,_.ROUND_HALF_FLOOR=8,_.EUCLID=9,_.config=_.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(ne+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(he(n=e[t],0,ue,t),d=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(he(n=e[t],0,8,t),y=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((n=e[t])&&n.pop?(he(n[0],-ue,0,t),he(n[1],0,ue,t),g=n[0],m=n[1]):(he(n,-ue,ue,t),g=-(m=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if((n=e[t])&&n.pop)he(n[0],-ue,-1,t),he(n[1],1,ue,t),v=n[0],b=n[1];else{if(he(n,-ue,ue,t),!n)throw Error(ne+t+" cannot be zero: "+n);v=-(b=n<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(ne+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!n,Error(ne+"crypto unavailable");E=n}else E=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(he(n=e[t],0,9,t),w=n),e.hasOwnProperty(t="POW_PRECISION")&&(he(n=e[t],0,ue,t),S=n),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(ne+t+" not an object: "+n);P=n}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(ne+t+" invalid: "+n);O="0123456789"==n.slice(0,10),x=n}}return{DECIMAL_PLACES:d,ROUNDING_MODE:y,EXPONENTIAL_AT:[g,m],RANGE:[v,b],CRYPTO:E,MODULO_MODE:w,POW_PRECISION:S,FORMAT:P,ALPHABET:x}},_.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!_.DEBUG)return!0;var t,n,r=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(r)){if((1===o||-1===o)&&i>=-ue&&i<=ue&&i===te(i)){if(0===r[0]){if(0===i&&1===r.length)return!0;break e}if((t=(i+1)%oe)<1&&(t+=oe),String(r[0]).length==t){for(t=0;t<r.length;t++)if((n=r[t])<0||n>=ie||n!==te(n))break e;if(0!==n)return!0}}}else if(null===r&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(ne+"Invalid BigNumber: "+e)},_.maximum=_.max=function(){return A(arguments,-1)},_.minimum=_.min=function(){return A(arguments,1)},_.random=(o=9007199254740992,s=Math.random()*o&2097151?function(){return te(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,n,r,i,o,a=0,l=[],u=new _(h);if(null==e?e=d:he(e,0,ue),i=ee(e/oe),E)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));a<i;)(o=131072*t[a]+(t[a+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),t[a]=n[0],t[a+1]=n[1]):(l.push(o%1e14),a+=2);a=i/2}else{if(!crypto.randomBytes)throw E=!1,Error(ne+"crypto unavailable");for(t=crypto.randomBytes(i*=7);a<i;)(o=281474976710656*(31&t[a])+1099511627776*t[a+1]+4294967296*t[a+2]+16777216*t[a+3]+(t[a+4]<<16)+(t[a+5]<<8)+t[a+6])>=9e15?crypto.randomBytes(7).copy(t,a):(l.push(o%1e14),a+=7);a=i/7}if(!E)for(;a<i;)(o=s())<9e15&&(l[a++]=o%1e14);for(i=l[--a],e%=oe,i&&e&&(o=ae[oe-e],l[a]=te(i/o)*o);0===l[a];l.pop(),a--);if(a<0)l=[r=0];else{for(r=-1;0===l[0];l.splice(0,1),r-=oe);for(a=1,o=l[0];o>=10;o/=10,a++);a<oe&&(r-=oe-a)}return u.e=r,u.c=l,u}),_.sum=function(){for(var e=1,t=arguments,n=new _(t[0]);e<t.length;)n=n.plus(t[e++]);return n},r=function(){var e="0123456789";function t(e,t,n,r){for(var i,o,s=[0],a=0,l=e.length;a<l;){for(o=s.length;o--;s[o]*=t);for(s[0]+=r.indexOf(e.charAt(a++)),i=0;i<s.length;i++)s[i]>n-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(r,i,o,s,a){var l,u,c,f,p,h,g,m,v=r.indexOf("."),b=d,E=y;for(v>=0&&(f=S,S=0,r=r.replace(".",""),h=(m=new _(i)).pow(r.length-v),S=f,m.c=t(ge(fe(h.c),h.e,"0"),10,o,e),m.e=m.c.length),c=f=(g=t(r,i,o,a?(l=x,e):(l=e,x))).length;0==g[--f];g.pop());if(!g[0])return l.charAt(0);if(v<0?--c:(h.c=g,h.e=c,h.s=s,g=(h=n(h,m,b,E,o)).c,p=h.r,c=h.e),v=g[u=c+b+1],f=o/2,p=p||u<0||null!=g[u+1],p=E<4?(null!=v||p)&&(0==E||E==(h.s<0?3:2)):v>f||v==f&&(4==E||p||6==E&&1&g[u-1]||E==(h.s<0?8:7)),u<1||!g[0])r=p?ge(l.charAt(1),-b,l.charAt(0)):l.charAt(0);else{if(g.length=u,p)for(--o;++g[--u]>o;)g[u]=0,u||(++c,g=[1].concat(g));for(f=g.length;!g[--f];);for(v=0,r="";v<=f;r+=l.charAt(g[v++]));r=ge(r,c,l.charAt(0))}return r}}(),n=function(){function e(e,t,n){var r,i,o,s,a=0,l=e.length,u=t%le,c=t/le|0;for(e=e.slice();l--;)a=((i=u*(o=e[l]%le)+(r=c*o+(s=e[l]/le|0)*u)%le*le+a)/n|0)+(r/le|0)+c*s,e[l]=i%n;return a&&(e=[a].concat(e)),e}function t(e,t,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,o,s,a){var l,u,c,f,p,h,d,y,g,m,v,b,E,w,S,P,x,O=r.s==i.s?1:-1,T=r.c,A=i.c;if(!(T&&T[0]&&A&&A[0]))return new _(r.s&&i.s&&(T?!A||T[0]!=A[0]:A)?T&&0==T[0]||!A?0*O:O/0:NaN);for(g=(y=new _(O)).c=[],O=o+(u=r.e-i.e)+1,a||(a=ie,u=ce(r.e/oe)-ce(i.e/oe),O=O/oe|0),c=0;A[c]==(T[c]||0);c++);if(A[c]>(T[c]||0)&&u--,O<0)g.push(1),f=!0;else{for(w=T.length,P=A.length,c=0,O+=2,(p=te(a/(A[0]+1)))>1&&(A=e(A,p,a),T=e(T,p,a),P=A.length,w=T.length),E=P,v=(m=T.slice(0,P)).length;v<P;m[v++]=0);x=A.slice(),x=[0].concat(x),S=A[0],A[1]>=a/2&&S++;do{if(p=0,(l=t(A,m,P,v))<0){if(b=m[0],P!=v&&(b=b*a+(m[1]||0)),(p=te(b/S))>1)for(p>=a&&(p=a-1),d=(h=e(A,p,a)).length,v=m.length;1==t(h,m,d,v);)p--,n(h,P<d?x:A,d,a),d=h.length,l=1;else 0==p&&(l=p=1),d=(h=A.slice()).length;if(d<v&&(h=[0].concat(h)),n(m,h,v,a),v=m.length,-1==l)for(;t(A,m,P,v)<1;)p++,n(m,P<v?x:A,v,a),v=m.length}else 0===l&&(p++,m=[0]);g[c++]=p,m[0]?m[v++]=T[E]||0:(m=[T[E]],v=1)}while((E++<w||null!=m[0])&&O--);f=null!=m[0],g[0]||g.splice(0,1)}if(a==ie){for(c=1,O=g[0];O>=10;O/=10,c++);k(y,o+(y.e=c+u*oe-1)+1,s,f)}else y.e=u,y.r=+f;return y}}(),a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,n,r){var i,o=n?t:t.replace(f,"");if(c.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!n&&(o=o.replace(a,function(e,t,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=i?e:t}),r&&(i=r,o=o.replace(l,"$1").replace(u,"0.$1")),t!=o))return new _(o,i);if(_.DEBUG)throw Error(ne+"Not a"+(r?" base "+r:"")+" number: "+t);e.s=null}e.c=e.e=null},p.absoluteValue=p.abs=function(){var e=new _(this);return e.s<0&&(e.s=1),e},p.comparedTo=function(e,t){return pe(this,new _(e,t))},p.decimalPlaces=p.dp=function(e,t){var n,r,i,o=this;if(null!=e)return he(e,0,ue),null==t?t=y:he(t,0,8),k(new _(o),e+o.e+1,t);if(!(n=o.c))return null;if(r=((i=n.length-1)-ce(this.e/oe))*oe,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},p.dividedBy=p.div=function(e,t){return n(this,new _(e,t),d,y)},p.dividedToIntegerBy=p.idiv=function(e,t){return n(this,new _(e,t),0,1)},p.exponentiatedBy=p.pow=function(e,t){var n,r,i,o,s,a,l,u,c=this;if((e=new _(e)).c&&!e.isInteger())throw Error(ne+"Exponent not an integer: "+M(e));if(null!=t&&(t=new _(t)),s=e.e>14,!c.c||!c.c[0]||1==c.c[0]&&!c.e&&1==c.c.length||!e.c||!e.c[0])return u=new _(Math.pow(+M(c),s?e.s*(2-de(e)):+M(e))),t?u.mod(t):u;if(a=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new _(NaN);(r=!a&&c.isInteger()&&t.isInteger())&&(c=c.mod(t))}else{if(e.e>9&&(c.e>0||c.e<-1||(0==c.e?c.c[0]>1||s&&c.c[1]>=24e7:c.c[0]<8e13||s&&c.c[0]<=9999975e7)))return o=c.s<0&&de(e)?-0:0,c.e>-1&&(o=1/o),new _(a?1/o:o);S&&(o=ee(S/oe+2))}for(s?(n=new _(.5),a&&(e.s=1),l=de(e)):l=(i=Math.abs(+M(e)))%2,u=new _(h);;){if(l){if(!(u=u.times(c)).c)break;o?u.c.length>o&&(u.c.length=o):r&&(u=u.mod(t))}if(i){if(0===(i=te(i/2)))break;l=i%2}else if(k(e=e.times(n),e.e+1,1),e.e>14)l=de(e);else{if(0===(i=+M(e)))break;l=i%2}c=c.times(c),o?c.c&&c.c.length>o&&(c.c.length=o):r&&(c=c.mod(t))}return r?u:(a&&(u=h.div(u)),t?u.mod(t):o?k(u,S,y,void 0):u)},p.integerValue=function(e){var t=new _(this);return null==e?e=y:he(e,0,8),k(t,t.e+1,e)},p.isEqualTo=p.eq=function(e,t){return 0===pe(this,new _(e,t))},p.isFinite=function(){return!!this.c},p.isGreaterThan=p.gt=function(e,t){return pe(this,new _(e,t))>0},p.isGreaterThanOrEqualTo=p.gte=function(e,t){return 1===(t=pe(this,new _(e,t)))||0===t},p.isInteger=function(){return!!this.c&&ce(this.e/oe)>this.c.length-2},p.isLessThan=p.lt=function(e,t){return pe(this,new _(e,t))<0},p.isLessThanOrEqualTo=p.lte=function(e,t){return-1===(t=pe(this,new _(e,t)))||0===t},p.isNaN=function(){return!this.s},p.isNegative=function(){return this.s<0},p.isPositive=function(){return this.s>0},p.isZero=function(){return!!this.c&&0==this.c[0]},p.minus=function(e,t){var n,r,i,o,s=this,a=s.s;if(t=(e=new _(e,t)).s,!a||!t)return new _(NaN);if(a!=t)return e.s=-t,s.plus(e);var l=s.e/oe,u=e.e/oe,c=s.c,f=e.c;if(!l||!u){if(!c||!f)return c?(e.s=-t,e):new _(f?s:NaN);if(!c[0]||!f[0])return f[0]?(e.s=-t,e):new _(c[0]?s:3==y?-0:0)}if(l=ce(l),u=ce(u),c=c.slice(),a=l-u){for((o=a<0)?(a=-a,i=c):(u=l,i=f),i.reverse(),t=a;t--;i.push(0));i.reverse()}else for(r=(o=(a=c.length)<(t=f.length))?a:t,a=t=0;t<r;t++)if(c[t]!=f[t]){o=c[t]<f[t];break}if(o&&(i=c,c=f,f=i,e.s=-e.s),(t=(r=f.length)-(n=c.length))>0)for(;t--;c[n++]=0);for(t=ie-1;r>a;){if(c[--r]<f[r]){for(n=r;n&&!c[--n];c[n]=t);--c[n],c[r]+=ie}c[r]-=f[r]}for(;0==c[0];c.splice(0,1),--u);return c[0]?C(e,c,u):(e.s=3==y?-1:1,e.c=[e.e=0],e)},p.modulo=p.mod=function(e,t){var r,i,o=this;return e=new _(e,t),!o.c||!e.s||e.c&&!e.c[0]?new _(NaN):!e.c||o.c&&!o.c[0]?new _(o):(9==w?(i=e.s,e.s=1,r=n(o,e,0,3),e.s=i,r.s*=i):r=n(o,e,0,w),(e=o.minus(r.times(e))).c[0]||1!=w||(e.s=o.s),e)},p.multipliedBy=p.times=function(e,t){var n,r,i,o,s,a,l,u,c,f,p,h,d,y,g,m=this,v=m.c,b=(e=new _(e,t)).c;if(!(v&&b&&v[0]&&b[0]))return!m.s||!e.s||v&&!v[0]&&!b||b&&!b[0]&&!v?e.c=e.e=e.s=null:(e.s*=m.s,v&&b?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=ce(m.e/oe)+ce(e.e/oe),e.s*=m.s,(l=v.length)<(f=b.length)&&(d=v,v=b,b=d,i=l,l=f,f=i),i=l+f,d=[];i--;d.push(0));for(y=ie,g=le,i=f;--i>=0;){for(n=0,p=b[i]%g,h=b[i]/g|0,o=i+(s=l);o>i;)n=((u=p*(u=v[--s]%g)+(a=h*u+(c=v[s]/g|0)*p)%g*g+d[o]+n)/y|0)+(a/g|0)+h*c,d[o--]=u%y;d[o]=n}return n?++r:d.splice(0,1),C(e,d,r)},p.negated=function(){var e=new _(this);return e.s=-e.s||null,e},p.plus=function(e,t){var n,r=this,i=r.s;if(t=(e=new _(e,t)).s,!i||!t)return new _(NaN);if(i!=t)return e.s=-t,r.minus(e);var o=r.e/oe,s=e.e/oe,a=r.c,l=e.c;if(!o||!s){if(!a||!l)return new _(i/0);if(!a[0]||!l[0])return l[0]?e:new _(a[0]?r:0*i)}if(o=ce(o),s=ce(s),a=a.slice(),i=o-s){for(i>0?(s=o,n=l):(i=-i,n=a),n.reverse();i--;n.push(0));n.reverse()}for((i=a.length)-(t=l.length)<0&&(n=l,l=a,a=n,t=i),i=0;t;)i=(a[--t]=a[t]+l[t]+i)/ie|0,a[t]=ie===a[t]?0:a[t]%ie;return i&&(a=[i].concat(a),++s),C(e,a,s)},p.precision=p.sd=function(e,t){var n,r,i,o=this;if(null!=e&&e!==!!e)return he(e,1,ue),null==t?t=y:he(t,0,8),k(new _(o),e,t);if(!(n=o.c))return null;if(r=(i=n.length-1)*oe+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&o.e+1>r&&(r=o.e+1),r},p.shiftedBy=function(e){return he(e,-9007199254740991,se),this.times("1e"+e)},p.squareRoot=p.sqrt=function(){var e,t,r,i,o,s=this,a=s.c,l=s.s,u=s.e,c=d+4,f=new _("0.5");if(1!==l||!a||!a[0])return new _(!l||l<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(l=Math.sqrt(+M(s)))||l==1/0?(((t=fe(a)).length+u)%2==0&&(t+="0"),l=Math.sqrt(+t),u=ce((u+1)/2)-(u<0||u%2),r=new _(t=l==1/0?"5e"+u:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+u)):r=new _(l+""),r.c[0])for((l=(u=r.e)+c)<3&&(l=0);;)if(o=r,r=f.times(o.plus(n(s,o,c,1))),fe(o.c).slice(0,l)===(t=fe(r.c)).slice(0,l)){if(r.e<u&&--l,"9999"!=(t=t.slice(l-3,l+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(k(r,r.e+d+2,1),e=!r.times(r).eq(s));break}if(!i&&(k(o,o.e+d+2,0),o.times(o).eq(s))){r=o;break}c+=4,l+=4,i=1}return k(r,r.e+d+1,y,e)},p.toExponential=function(e,t){return null!=e&&(he(e,0,ue),e++),T(this,e,t,1)},p.toFixed=function(e,t){return null!=e&&(he(e,0,ue),e=e+this.e+1),T(this,e,t)},p.toFormat=function(e,t,n){var r,i=this;if(null==n)null!=e&&t&&"object"==typeof t?(n=t,t=null):e&&"object"==typeof e?(n=e,e=t=null):n=P;else if("object"!=typeof n)throw Error(ne+"Argument not an object: "+n);if(r=i.toFixed(e,t),i.c){var o,s=r.split("."),a=+n.groupSize,l=+n.secondaryGroupSize,u=n.groupSeparator||"",c=s[0],f=s[1],p=i.s<0,h=p?c.slice(1):c,d=h.length;if(l&&(o=a,a=l,l=o,d-=o),a>0&&d>0){for(o=d%a||a,c=h.substr(0,o);o<d;o+=a)c+=u+h.substr(o,a);l>0&&(c+=u+h.slice(o)),p&&(c="-"+c)}r=f?c+(n.decimalSeparator||"")+((l=+n.fractionGroupSize)?f.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):f):c}return(n.prefix||"")+r+(n.suffix||"")},p.toFraction=function(e){var t,r,i,o,s,a,l,u,c,f,p,d,g=this,m=g.c;if(null!=e&&(!(l=new _(e)).isInteger()&&(l.c||1!==l.s)||l.lt(h)))throw Error(ne+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+M(l));if(!m)return new _(g);for(t=new _(h),c=r=new _(h),i=u=new _(h),d=fe(m),s=t.e=d.length-g.e-1,t.c[0]=ae[(a=s%oe)<0?oe+a:a],e=!e||l.comparedTo(t)>0?s>0?t:c:l,a=b,b=1/0,l=new _(d),u.c[0]=0;f=n(l,t,0,1),1!=(o=r.plus(f.times(i))).comparedTo(e);)r=i,i=o,c=u.plus(f.times(o=c)),u=o,t=l.minus(f.times(o=t)),l=o;return o=n(e.minus(r),i,0,1),u=u.plus(o.times(c)),r=r.plus(o.times(i)),u.s=c.s=g.s,p=n(c,i,s*=2,y).minus(g).abs().comparedTo(n(u,r,s,y).minus(g).abs())<1?[c,i]:[u,r],b=a,p},p.toNumber=function(){return+M(this)},p.toPrecision=function(e,t){return null!=e&&he(e,1,ue),T(this,e,t,2)},p.toString=function(e){var t,n=this,i=n.s,o=n.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=g||o>=m?ye(fe(n.c),o):ge(fe(n.c),o,"0"):10===e&&O?t=ge(fe((n=k(new _(n),d+o+1,y)).c),n.e,"0"):(he(e,2,x.length,"Base"),t=r(ge(fe(n.c),o,"0"),10,e,i,!0)),i<0&&n.c[0]&&(t="-"+t)),t},p.valueOf=p.toJSON=function(){return M(this)},p._isBigNumber=!0,p[Symbol.toStringTag]="BigNumber",p[Symbol.for("nodejs.util.inspect.custom")]=p.valueOf,null!=t&&_.set(t),_}();const ve=me;var be=class{key;left=null;right=null;constructor(e){this.key=e}},Ee=class extends be{constructor(e){super(e)}},we=class{size=0;modificationCount=0;splayCount=0;splay(e){const t=this.root;if(null==t)return this.compare(e,e),-1;let n=null,r=null,i=null,o=null,s=t;const a=this.compare;let l;for(;;)if(l=a(s.key,e),l>0){let t=s.left;if(null==t)break;if(l=a(t.key,e),l>0&&(s.left=t.right,t.right=s,s=t,t=s.left,null==t))break;null==n?r=s:n.left=s,n=s,s=t}else{if(!(l<0))break;{let t=s.right;if(null==t)break;if(l=a(t.key,e),l<0&&(s.right=t.left,t.left=s,s=t,t=s.right,null==t))break;null==i?o=s:i.right=s,i=s,s=t}}return null!=i&&(i.right=s.left,s.left=o),null!=n&&(n.left=s.right,s.right=r),this.root!==s&&(this.root=s,this.splayCount++),l}splayMin(e){let t=e,n=t.left;for(;null!=n;){const e=n;t.left=e.right,e.right=t,t=e,n=t.left}return t}splayMax(e){let t=e,n=t.right;for(;null!=n;){const e=n;t.right=e.left,e.left=t,t=e,n=t.right}return t}_delete(e){if(null==this.root)return null;if(0!=this.splay(e))return null;let t=this.root;const n=t,r=t.left;if(this.size--,null==r)this.root=t.right;else{const e=t.right;t=this.splayMax(r),t.right=e,this.root=t}return this.modificationCount++,n}addNewRoot(e,t){this.size++,this.modificationCount++;const n=this.root;null!=n?(t<0?(e.left=n,e.right=n.right,n.right=null):(e.right=n,e.left=n.left,n.left=null),this.root=e):this.root=e}_first(){const e=this.root;return null==e?null:(this.root=this.splayMin(e),this.root)}_last(){const e=this.root;return null==e?null:(this.root=this.splayMax(e),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(e){return this.validKey(e)&&0==this.splay(e)}defaultCompare(){return(e,t)=>e<t?-1:e>t?1:0}wrap(){return{getRoot:()=>this.root,setRoot:e=>{this.root=e},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:e=>{this.splayCount=e},splay:e=>this.splay(e),has:e=>this.has(e)}}},Se=(Symbol.iterator,Symbol.toStringTag,class e extends we{root=null;compare;validKey;constructor(e,t){super(),this.compare=e??this.defaultCompare(),this.validKey=t??(e=>null!=e&&null!=e)}delete(e){return!!this.validKey(e)&&null!=this._delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){const t=this[Symbol.iterator]();let n;for(;n=t.next(),!n.done;)e(n.value,n.value,this)}add(e){const t=this.splay(e);return 0!=t&&this.addNewRoot(new Ee(e),t),this}addAndReturn(e){const t=this.splay(e);return 0!=t&&this.addNewRoot(new Ee(e),t),this.root.key}addAll(e){for(const t of e)this.add(t)}isEmpty(){return null==this.root}isNotEmpty(){return null!=this.root}single(){if(0==this.size)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(0==this.size)throw"Bad state: No element";return this._first().key}last(){if(0==this.size)throw"Bad state: No element";return this._last().key}lastBefore(e){if(null==e)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(e)<0)return this.root.key;let t=this.root.left;if(null==t)return null;let n=t.right;for(;null!=n;)t=n,n=t.right;return t.key}firstAfter(e){if(null==e)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(e)>0)return this.root.key;let t=this.root.right;if(null==t)return null;let n=t.left;for(;null!=n;)t=n,n=t.left;return t.key}retainAll(t){const n=new e(this.compare,this.validKey),r=this.modificationCount;for(const e of t){if(r!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(e)&&0==this.splay(e)&&n.add(this.root.key)}n.size!=this.size&&(this.root=n.root,this.size=n.size,this.modificationCount++)}lookup(e){return this.validKey(e)?0!=this.splay(e)?null:this.root.key:null}intersection(t){const n=new e(this.compare,this.validKey);for(const e of this)t.has(e)&&n.add(e);return n}difference(t){const n=new e(this.compare,this.validKey);for(const e of this)t.has(e)||n.add(e);return n}union(e){const t=this.clone();return t.addAll(e),t}clone(){const t=new e(this.compare,this.validKey);return t.size=this.size,t.root=this.copyNode(this.root),t}copyNode(e){if(null==e)return null;const t=new Ee(e.key);return function e(t,n){let r,i;do{if(r=t.left,i=t.right,null!=r){const t=new Ee(r.key);n.left=t,e(r,t)}if(null!=i){const e=new Ee(i.key);n.right=e,t=i,n=e}}while(null!=i)}(e,t),t}toSet(){return this.clone()}entries(){return new Oe(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[Symbol.iterator](){return new xe(this.wrap())}[Symbol.toStringTag]="[object Set]"}),Pe=class{tree;path=new Array;modificationCount=null;splayCount;constructor(e){this.tree=e,this.splayCount=e.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;const e=this.path[this.path.length-1];return this.getValue(e)}rebuildPath(e){this.path.splice(0,this.path.length),this.tree.splay(e),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(e){for(;null!=e;)this.path.push(e),e=e.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(null==this.modificationCount){this.modificationCount=this.tree.getModificationCount();let e=this.tree.getRoot();for(;null!=e;)this.path.push(e),e=e.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let e=this.path[this.path.length-1],t=e.right;if(null!=t){for(;null!=t;)this.path.push(t),t=t.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===e;)e=this.path.pop();return this.path.length>0}},xe=class extends Pe{getValue(e){return e.key}},Oe=class extends Pe{getValue(e){return[e.key,e.key]}},_e=e=>()=>e,Te=e=>{const t=e?(t,n)=>n.minus(t).abs().isLessThanOrEqualTo(e):_e(!1);return(e,n)=>t(e,n)?0:e.comparedTo(n)};function Ae(e){const t=e?(t,n,r,i,o)=>t.exponentiatedBy(2).isLessThanOrEqualTo(i.minus(n).exponentiatedBy(2).plus(o.minus(r).exponentiatedBy(2)).times(e)):_e(!1);return(e,n,r)=>{const i=e.x,o=e.y,s=r.x,a=r.y,l=o.minus(a).times(n.x.minus(s)).minus(i.minus(s).times(n.y.minus(a)));return t(l,i,o,s,a)?0:l.comparedTo(0)}}var Ce=e=>e,ke=e=>{if(e){const t=new Se(Te(e)),n=new Se(Te(e)),r=(e,t)=>t.addAndReturn(e),i=e=>({x:r(e.x,t),y:r(e.y,n)});return i({x:new ve(0),y:new ve(0)}),i}return Ce},Me=e=>({set:e=>{Ie=Me(e)},reset:()=>Me(e),compare:Te(e),snap:ke(e),orient:Ae(e)}),Ie=Me(),Le=(e,t)=>e.ll.x.isLessThanOrEqualTo(t.x)&&t.x.isLessThanOrEqualTo(e.ur.x)&&e.ll.y.isLessThanOrEqualTo(t.y)&&t.y.isLessThanOrEqualTo(e.ur.y),Re=(e,t)=>{if(t.ur.x.isLessThan(e.ll.x)||e.ur.x.isLessThan(t.ll.x)||t.ur.y.isLessThan(e.ll.y)||e.ur.y.isLessThan(t.ll.y))return null;const n=e.ll.x.isLessThan(t.ll.x)?t.ll.x:e.ll.x,r=e.ur.x.isLessThan(t.ur.x)?e.ur.x:t.ur.x;return{ll:{x:n,y:e.ll.y.isLessThan(t.ll.y)?t.ll.y:e.ll.y},ur:{x:r,y:e.ur.y.isLessThan(t.ur.y)?e.ur.y:t.ur.y}}},Ne=(e,t)=>e.x.times(t.y).minus(e.y.times(t.x)),je=(e,t)=>e.x.times(t.x).plus(e.y.times(t.y)),De=e=>je(e,e).sqrt(),Ge=(e,t,n)=>{const r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Ne(i,r).div(De(i)).div(De(r))},Fe=(e,t,n)=>{const r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return je(i,r).div(De(i)).div(De(r))},Ve=(e,t,n)=>t.y.isZero()?null:{x:e.x.plus(t.x.div(t.y).times(n.minus(e.y))),y:n},Be=(e,t,n)=>t.x.isZero()?null:{x:n,y:e.y.plus(t.y.div(t.x).times(n.minus(e.x)))},Ue=class e{point;isLeft;segment;otherSE;consumedBy;static compare(t,n){const r=e.comparePoints(t.point,n.point);return 0!==r?r:(t.point!==n.point&&t.link(n),t.isLeft!==n.isLeft?t.isLeft?1:-1:Ke.compare(t.segment,n.segment))}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}constructor(e,t){void 0===e.events?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw new Error("Tried to link already linked events");const t=e.point.events;for(let e=0,n=t.length;e<n;e++){const n=t[e];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){const e=this.point.events.length;for(let t=0;t<e;t++){const n=this.point.events[t];if(void 0===n.segment.consumedBy)for(let r=t+1;r<e;r++){const e=this.point.events[r];void 0===e.consumedBy&&n.otherSE.point.events===e.otherSE.point.events&&n.segment.consume(e.segment)}}}getAvailableLinkedEvents(){const e=[];for(let t=0,n=this.point.events.length;t<n;t++){const n=this.point.events[t];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&e.push(n)}return e}getLeftmostComparator(e){const t=new Map,n=n=>{const r=n.otherSE;t.set(n,{sine:Ge(this.point,e.point,r.point),cosine:Fe(this.point,e.point,r.point)})};return(e,r)=>{t.has(e)||n(e),t.has(r)||n(r);const{sine:i,cosine:o}=t.get(e),{sine:s,cosine:a}=t.get(r);return i.isGreaterThanOrEqualTo(0)&&s.isGreaterThanOrEqualTo(0)?o.isLessThan(a)?1:o.isGreaterThan(a)?-1:0:i.isLessThan(0)&&s.isLessThan(0)?o.isLessThan(a)?-1:o.isGreaterThan(a)?1:0:s.isLessThan(i)?-1:s.isGreaterThan(i)?1:0}}},He=class e{events;poly;_isExteriorRing;_enclosingRing;static factory(t){const n=[];for(let r=0,i=t.length;r<i;r++){const i=t[r];if(!i.isInResult()||i.ringOut)continue;let o=null,s=i.leftSE,a=i.rightSE;const l=[s],u=s.point,c=[];for(;o=s,s=a,l.push(s),s.point!==u;)for(;;){const t=s.getAvailableLinkedEvents();if(0===t.length){const e=l[0].point,t=l[l.length-1].point;throw new Error(`Unable to complete output ring starting at [${e.x}, ${e.y}]. Last matching segment found ends at [${t.x}, ${t.y}].`)}if(1===t.length){a=t[0].otherSE;break}let r=null;for(let e=0,t=c.length;e<t;e++)if(c[e].point===s.point){r=e;break}if(null!==r){const t=c.splice(r)[0],i=l.splice(t.index);i.unshift(i[0].otherSE),n.push(new e(i.reverse()));continue}c.push({index:l.length,point:s.point});const i=s.getLeftmostComparator(o);a=t.sort(i)[0].otherSE;break}n.push(new e(l))}return n}constructor(e){this.events=e;for(let t=0,n=e.length;t<n;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point;const t=[e];for(let n=1,r=this.events.length-1;n<r;n++){const r=this.events[n].point,i=this.events[n+1].point;0!==Ie.orient(r,e,i)&&(t.push(r),e=r)}if(1===t.length)return null;const n=t[0],r=t[1];0===Ie.orient(n,e,r)&&t.shift(),t.push(t[0]);const i=this.isExteriorRing()?1:-1,o=this.isExteriorRing()?0:t.length-1,s=this.isExteriorRing()?t.length:-1,a=[];for(let e=o;e!=s;e+=i)a.push([t[e].x.toNumber(),t[e].y.toNumber()]);return a}isExteriorRing(){if(void 0===this._isExteriorRing){const e=this.enclosingRing();this._isExteriorRing=!e||!e.isExteriorRing()}return this._isExteriorRing}enclosingRing(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let t=1,n=this.events.length;t<n;t++){const n=this.events[t];Ue.compare(e,n)>0&&(e=n)}let t=e.segment.prevInResult(),n=t?t.prevInResult():null;for(;;){if(!t)return null;if(!n)return t.ringOut;if(n.ringOut!==t.ringOut)return n.ringOut?.enclosingRing()!==t.ringOut?t.ringOut:t.ringOut?.enclosingRing();t=n.prevInResult(),n=t?t.prevInResult():null}}},qe=class{exteriorRing;interiorRings;constructor(e){this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){const e=this.exteriorRing.getGeom();if(null===e)return null;const t=[e];for(let e=0,n=this.interiorRings.length;e<n;e++){const n=this.interiorRings[e].getGeom();null!==n&&t.push(n)}return t}},Ye=class{rings;polys;constructor(e){this.rings=e,this.polys=this._composePolys(e)}getGeom(){const e=[];for(let t=0,n=this.polys.length;t<n;t++){const n=this.polys[t].getGeom();null!==n&&e.push(n)}return e}_composePolys(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];if(!r.poly)if(r.isExteriorRing())t.push(new qe(r));else{const e=r.enclosingRing();e?.poly||t.push(new qe(e)),e?.poly?.addInterior(r)}}return t}},ze=class{queue;tree;segments;constructor(e,t=Ke.compare){this.queue=e,this.tree=new Se(t),this.segments=[]}process(e){const t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.delete(e.otherSE):this.tree.delete(t),n;e.isLeft&&this.tree.add(t);let r=t,i=t;do{r=this.tree.lastBefore(r)}while(null!=r&&null!=r.consumedBy);do{i=this.tree.firstAfter(i)}while(null!=i&&null!=i.consumedBy);if(e.isLeft){let o=null;if(r){const e=r.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(o=e),!r.isAnEndpoint(e))){const t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}let s=null;if(i){const e=i.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(s=e),!i.isAnEndpoint(e))){const t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}if(null!==o||null!==s){let e=null;e=null===o?s:null===s||Ue.comparePoints(o,s)<=0?o:s,this.queue.delete(t.rightSE),n.push(t.rightSE);const r=t.split(e);for(let e=0,t=r.length;e<t;e++)n.push(r[e])}n.length>0?(this.tree.delete(t),n.push(e)):(this.segments.push(t),t.prev=r)}else{if(r&&i){const e=r.getIntersection(i);if(null!==e){if(!r.isAnEndpoint(e)){const t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}if(!i.isAnEndpoint(e)){const t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}}this.tree.delete(t)}return n}_splitSafely(e,t){this.tree.delete(e);const n=e.rightSE;this.queue.delete(n);const r=e.split(t);return r.push(n),void 0===e.consumedBy&&this.tree.add(e),r}},We=new class{type;numMultiPolys;run(e,t,n){We.type=e;const r=[new Qe(t,!0)];for(let e=0,t=n.length;e<t;e++)r.push(new Qe(n[e],!1));if(We.numMultiPolys=r.length,"difference"===We.type){const e=r[0];let t=1;for(;t<r.length;)null!==Re(r[t].bbox,e.bbox)?t++:r.splice(t,1)}if("intersection"===We.type)for(let e=0,t=r.length;e<t;e++){const t=r[e];for(let n=e+1,i=r.length;n<i;n++)if(null===Re(t.bbox,r[n].bbox))return[]}const i=new Se(Ue.compare);for(let e=0,t=r.length;e<t;e++){const t=r[e].getSweepEvents();for(let e=0,n=t.length;e<n;e++)i.add(t[e])}const o=new ze(i);let s=null;for(0!=i.size&&(s=i.first(),i.delete(s));s;){const e=o.process(s);for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0===n.consumedBy&&i.add(n)}0!=i.size?(s=i.first(),i.delete(s)):s=null}Ie.reset();const a=He.factory(o.segments);return new Ye(a).getGeom()}},$e=We,Xe=0,Ke=class e{id;leftSE;rightSE;rings;windings;ringOut;consumedBy;prev;_prevInResult;_beforeState;_afterState;_isInResult;static compare(e,t){const n=e.leftSE.point.x,r=t.leftSE.point.x,i=e.rightSE.point.x,o=t.rightSE.point.x;if(o.isLessThan(n))return 1;if(i.isLessThan(r))return-1;const s=e.leftSE.point.y,a=t.leftSE.point.y,l=e.rightSE.point.y,u=t.rightSE.point.y;if(n.isLessThan(r)){if(a.isLessThan(s)&&a.isLessThan(l))return 1;if(a.isGreaterThan(s)&&a.isGreaterThan(l))return-1;const n=e.comparePoint(t.leftSE.point);if(n<0)return 1;if(n>0)return-1;const r=t.comparePoint(e.rightSE.point);return 0!==r?r:-1}if(n.isGreaterThan(r)){if(s.isLessThan(a)&&s.isLessThan(u))return-1;if(s.isGreaterThan(a)&&s.isGreaterThan(u))return 1;const n=t.comparePoint(e.leftSE.point);if(0!==n)return n;const r=e.comparePoint(t.rightSE.point);return r<0?1:r>0?-1:1}if(s.isLessThan(a))return-1;if(s.isGreaterThan(a))return 1;if(i.isLessThan(o)){const n=t.comparePoint(e.rightSE.point);if(0!==n)return n}if(i.isGreaterThan(o)){const n=e.comparePoint(t.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(!i.eq(o)){const e=l.minus(s),t=i.minus(n),c=u.minus(a),f=o.minus(r);if(e.isGreaterThan(t)&&c.isLessThan(f))return 1;if(e.isLessThan(t)&&c.isGreaterThan(f))return-1}return i.isGreaterThan(o)?1:i.isLessThan(o)||l.isLessThan(u)?-1:l.isGreaterThan(u)?1:e.id<t.id?-1:e.id>t.id?1:0}constructor(e,t,n,r){this.id=++Xe,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=n,this.windings=r}static fromRing(t,n,r){let i,o,s;const a=Ue.comparePoints(t,n);if(a<0)i=t,o=n,s=1;else{if(!(a>0))throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);i=n,o=t,s=-1}const l=new Ue(i,!0),u=new Ue(o,!1);return new e(l,u,[r],[s])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return Ie.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){const t=this.bbox(),n=e.bbox(),r=Re(t,n);if(null===r)return null;const i=this.leftSE.point,o=this.rightSE.point,s=e.leftSE.point,a=e.rightSE.point,l=Le(t,s)&&0===this.comparePoint(s),u=Le(n,i)&&0===e.comparePoint(i),c=Le(t,a)&&0===this.comparePoint(a),f=Le(n,o)&&0===e.comparePoint(o);if(u&&l)return f&&!c?o:!f&&c?a:null;if(u)return c&&i.x.eq(a.x)&&i.y.eq(a.y)?null:i;if(l)return f&&o.x.eq(s.x)&&o.y.eq(s.y)?null:s;if(f&&c)return null;if(f)return o;if(c)return a;const p=((e,t,n,r)=>{if(t.x.isZero())return Be(n,r,e.x);if(r.x.isZero())return Be(e,t,n.x);if(t.y.isZero())return Ve(n,r,e.y);if(r.y.isZero())return Ve(e,t,n.y);const i=Ne(t,r);if(i.isZero())return null;const o={x:n.x.minus(e.x),y:n.y.minus(e.y)},s=Ne(o,t).div(i),a=Ne(o,r).div(i),l=e.x.plus(a.times(t.x)),u=n.x.plus(s.times(r.x)),c=e.y.plus(a.times(t.y)),f=n.y.plus(s.times(r.y));return{x:l.plus(u).div(2),y:c.plus(f).div(2)}})(i,this.vector(),s,e.vector());return null===p?null:Le(r,p)?Ie.snap(p):null}split(t){const n=[],r=void 0!==t.events,i=new Ue(t,!0),o=new Ue(t,!1),s=this.rightSE;this.replaceRightSE(o),n.push(o),n.push(i);const a=new e(i,s,this.rings.slice(),this.windings.slice());return Ue.comparePoints(a.leftSE.point,a.rightSE.point)>0&&a.swapEvents(),Ue.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),o.checkForConsuming()),n}swapEvents(){const e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,t=this.windings.length;e<t;e++)this.windings[e]*=-1}consume(t){let n=this,r=t;for(;n.consumedBy;)n=n.consumedBy;for(;r.consumedBy;)r=r.consumedBy;const i=e.compare(n,r);if(0!==i){if(i>0){const e=n;n=r,r=e}if(n.prev===r){const e=n;n=r,r=e}for(let e=0,t=r.rings.length;e<t;e++){const t=r.rings[e],i=r.windings[e],o=n.rings.indexOf(t);-1===o?(n.rings.push(t),n.windings.push(i)):n.windings[o]+=i}r.rings=null,r.windings=null,r.consumedBy=n,r.leftSE.consumedBy=n.leftSE,r.rightSE.consumedBy=n.rightSE}}prevInResult(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){const e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}afterState(){if(void 0!==this._afterState)return this._afterState;const e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};const t=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let e=0,r=this.rings.length;e<r;e++){const r=this.rings[e],i=this.windings[e],o=t.indexOf(r);-1===o?(t.push(r),n.push(i)):n[o]+=i}const i=[],o=[];for(let e=0,r=t.length;e<r;e++){if(0===n[e])continue;const r=t[e],s=r.poly;if(-1===o.indexOf(s))if(r.isExterior)i.push(s);else{-1===o.indexOf(s)&&o.push(s);const e=i.indexOf(r.poly);-1!==e&&i.splice(e,1)}}for(let e=0,t=i.length;e<t;e++){const t=i[e].multiPoly;-1===r.indexOf(t)&&r.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;const e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch($e.type){case"union":{const n=0===e.length,r=0===t.length;this._isInResult=n!==r;break}case"intersection":{let n,r;e.length<t.length?(n=e.length,r=t.length):(n=t.length,r=e.length),this._isInResult=r===$e.numMultiPolys&&n<r;break}case"xor":{const n=Math.abs(e.length-t.length);this._isInResult=n%2==1;break}case"difference":{const n=e=>1===e.length&&e[0].isSubject;this._isInResult=n(e)!==n(t);break}}return this._isInResult}},Ze=class{poly;isExterior;segments;bbox;constructor(e,t,n){if(!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=t,this.isExterior=n,this.segments=[],"number"!=typeof e[0][0]||"number"!=typeof e[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const r=Ie.snap({x:new ve(e[0][0]),y:new ve(e[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let t=1,n=e.length;t<n;t++){if("number"!=typeof e[t][0]||"number"!=typeof e[t][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const n=Ie.snap({x:new ve(e[t][0]),y:new ve(e[t][1])});n.x.eq(i.x)&&n.y.eq(i.y)||(this.segments.push(Ke.fromRing(i,n,this)),n.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.x),n.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.y),n.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.x),n.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.y),i=n)}r.x.eq(i.x)&&r.y.eq(i.y)||this.segments.push(Ke.fromRing(i,r,this))}getSweepEvents(){const e=[];for(let t=0,n=this.segments.length;t<n;t++){const n=this.segments[t];e.push(n.leftSE),e.push(n.rightSE)}return e}},Je=class{multiPoly;exteriorRing;interiorRings;bbox;constructor(e,t){if(!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new Ze(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,n=e.length;t<n;t++){const n=new Ze(e[t],this,!1);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.interiorRings.push(n)}this.multiPoly=t}getSweepEvents(){const e=this.exteriorRing.getSweepEvents();for(let t=0,n=this.interiorRings.length;t<n;t++){const n=this.interiorRings[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}},Qe=class{isSubject;polys;bbox;constructor(e,t){if(!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof e[0][0][0]&&(e=[e])}catch(e){}this.polys=[],this.bbox={ll:{x:new ve(Number.POSITIVE_INFINITY),y:new ve(Number.POSITIVE_INFINITY)},ur:{x:new ve(Number.NEGATIVE_INFINITY),y:new ve(Number.NEGATIVE_INFINITY)}};for(let t=0,n=e.length;t<n;t++){const n=new Je(e[t],this);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.polys.push(n)}this.isSubject=t}getSweepEvents(){const e=[];for(let t=0,n=this.polys.length;t<n;t++){const n=this.polys[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}};Ie.set;function et(e,t,n={}){const r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}Math.PI;var tt=function(e,t={}){const n=[];if(function(e,t){var n,r,i,o,s,a,l,u,c,f,p=0,h="FeatureCollection"===e.type,d="Feature"===e.type,y=h?e.features.length:1;for(n=0;n<y;n++){for(a=h?e.features[n].geometry:d?e.geometry:e,u=h?e.features[n].properties:d?e.properties:{},c=h?e.features[n].bbox:d?e.bbox:void 0,f=h?e.features[n].id:d?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,i=0;i<s;i++)if(null!==(o=l?a.geometries[i]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,u,c,f))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===t(o.geometries[r],p,u,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,u,c,f))return!1;p++}}(e,e=>{n.push(e.coordinates)}),n.length<2)throw new Error("Must have at least 2 geometries");const r=((e,...t)=>$e.run("union",e,t))(n[0],...n.slice(1));return 0===r.length?null:1===r.length?function(e,t,n={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return et({type:"Polygon",coordinates:e},t,n)}(r[0],t.properties):function(e,t,n={}){return et({type:"MultiPolygon",coordinates:e},t,n)}(r,t.properties)},nt=n(278);function rt(e){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rt(e)}function it(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,a=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||ut(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ot(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ot(Object(n),!0).forEach(function(t){at(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ot(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function at(e,t,n){return(t=function(e){var t=function(e){if("object"!=rt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=rt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==rt(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lt(e){return function(e){if(Array.isArray(e))return ct(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ut(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ut(e,t){if(e){if("string"==typeof e)return ct(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ct(e,t):void 0}}function ct(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var ft=function(e,t){var n,r,i,o,s=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,n=e.geometry.coordinates.map(function(e){return lt(e)}),r=n.length-1,i=function(e,n){return[e[0]+(e[0]-n[0])*t,e[1]+(e[1]-n[1])*t]},o=i(n[0],n[1]),s=i(n[r],n[r-1]);return n[0]=o,n[r]=s,(0,nt.wi)(n)}(t);try{o=function(e,t){var n=[],r=[],i=[],o=function(e,t,n,r,i){for(var o=0,s=[],a="Feature"===t.type?t.geometry:t,l="LineString"===a.type?[a.coordinates]:a.coordinates,u=0,c=0;c<l.length;c++){for(var f=l[c].length-1,p=new D(l[c][0]),h=null,d={nextEdge:null},y=0;y<f;y++){h=new D(l[c][y+1]),p.nextPoint=h,h.prevPoint=p;var g=new j(p,h,"polyline",u,null);r.push(g),d.nextEdge=g,g.prevEdge=d,i[0]=Math.min(i[0],p.p[0]),i[1]=Math.min(i[1],p.p[1]),i[2]=Math.max(i[2],p.p[0]),i[3]=Math.max(i[3],p.p[1]),p=h,u+=1,d=g}i[0]=Math.min(i[0],l[c][f][0]),i[1]=Math.min(i[1],l[c][f][1]),i[2]=Math.max(i[2],l[c][f][0]),i[3]=Math.max(i[3],l[c][f][1])}for(var m="Feature"===e.type?e.geometry:e,v="Polygon"===m.type?[m.coordinates]:m.coordinates,b=v.length,E=0;E<b;E++)for(var w=v[E].length,S=0;S<w;S++){o+=1;var P=v[E][S],x=P.length;s.push(new G(o,P));for(var O=new D(P[0]),_=O,T=void 0,A=null,C={nextEdge:null,prevEdge:null},k=null,M=1;M<x;M++)T=new D(P[M]),_.nextPoint=T,T.prevPoint=_,A=new j(_,T,"polygon",u,o),C.nextEdge=A,A.prevEdge=C,1===M&&(k=A),S>0&&(A.interiorRing=!0),A.intersectPolylineBbox=F(A,i),n.push(A),_=T,u+=1,C=A;A.nextEdge=k,k.prevEdge=A,T.nextPoint=O.nextPoint,O.prevPoint=T.prevPoint}return s}(d(e),t,r,i,[1/0,1/0,1/0,1/0]);if(function(e,t,n){var r,i,o,s=t.length,a=e.length;for(r=0;r<s;r++){var l=t[r];for(i=0;i<a;i++){var u=e[i];if(u.intersectPolylineBbox&&!(u.maxX<l.minX||u.minX>l.maxX||u.maxY<l.minY||u.minY>l.maxY)){var c=Y(l,u);if(null!==c)for(o=0;o<c.length;o++){var f=N(u.p1.p[0],u.p1.p[1],u.p2.p[0],u.p2.p[1],l.p1.p[0],l.p1.p[1]),p=new V(c[o],l,u,f>0);n.push(p)}}}}t.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolylineEdgeStart-t.distanceFromPolylineEdgeStart})}),e.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolygonEdgeStart-t.distanceFromPolygonEdgeStart})})}(r,i,n),0===n.length)return e;var s={};o.forEach(function(e){return s[e.id]=0}),n.forEach(function(e){var t=e.polygonEdge.polygonContourId;s[t]=s[t]+1});for(var a=0,l=[],u=null,c=0;c<i.length;c++){var f=i[c];if(f.intersectionPoints.length>0){u=f.intersectionPoints[0];break}}for(var p=u,h={visitCount:1};u!==h&&!(a>2*n.length);){if(a=a++,h.visitCount>=2){for(var y=!1,g=0;g<n.length;g++){var m=n[g];if(m.visitCount<2){p=m,y=!0;break}}if(!y)break}p.visitCount=p.visitCount+1;var v=[];l.push(v),v.push(p.p),p.visitCount=p.visitCount+1;var b=X(p,v),E=!1;if(b===(h=b)&&2===n.length)for(var w=0;w<n.length;w++)n[w].visitCount<2&&(E=!0);for(;b!==p||E;)(b=(b.isHeadingIn?J:Z)(b,v))!==p&&(b=X(b,v)),E=!1;if(h.visitCount>=2){for(var S=!1,P=0;P<n.length;P++){var x=n[P];if(x.visitCount<2){p=x,S=!0;break}}S&&(h=p)}p=h}for(var O=l.map(function(e){return[e]}),_=Object.keys(s),T=0;T<_.length;T++){var A=_[T];0===s[A]&&$(W(z(r,parseInt(A)),o),O)}return{type:"Feature",properties:{},geometry:{type:"MultiPolygon",coordinates:O}}}(e,s)}catch(e){return null}var a=[];if("MultiPolygon"!==o.geometry.type)return null;if(2!==o.geometry.coordinates.length)return null;a=o.geometry.coordinates.map(function(t){return(0,nt.n1)(t,e.properties)});var l=null!==(n=null!==(r=e.id)&&void 0!==r?r:null===(i=e.properties)||void 0===i?void 0:i.id)&&void 0!==n?n:"poly",u=a.map(function(t,n){return(0,nt.n1)(t.geometry.coordinates,st(st({},e.properties),{},{id:l}),{id:"".concat(l,"-").concat(n+1)})});return(0,nt.Lr)(u)},pt=function(e){var t,n,r,i,o;try{o=tt((0,nt.Lr)(e))}catch(e){return null}if("Polygon"!==(null===(t=o)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type))return null;var s=null!==(n=null!==(r=e[0].id)&&void 0!==r?r:null===(i=e[0].properties)||void 0===i?void 0:i.id)&&void 0!==n?n:"poly";return(0,nt.n1)(o.geometry.coordinates,st(st({},e[0].properties),{},{id:s}),{id:s})},ht=function(e,t){var n=it(e,2),r=n[0],i=n[1],o=it(t,2),s=o[0],a=o[1],l=function(e){return e*Math.PI/180},u=l(a-i),c=l(s-r),f=Math.pow(Math.sin(u/2),2)+Math.cos(l(i))*Math.cos(l(a))*Math.pow(Math.sin(c/2),2);return 12742e3*Math.atan2(Math.sqrt(f),Math.sqrt(1-f))},dt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e.length<=1)return!0;var n=e[e.length-1],r=e[e.length-2];return ht(n,r)>=t},yt=function(e){return e[0].length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,n=e[0];return n.length<=1||!(n.length<=3&&function(e,t){for(var n=0;n<e.length;n++)for(var r=n+1;r<e.length;r++)if(ht(e[n],e[r])<t)return!0;return!1}(n,t))}(e)},gt=function(e,t,n){var r=t.filter(function(t){var r=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);return("ArrowUp"===n?t[1]<=e[1]&&i>=r:"ArrowDown"===n?t[1]>e[1]&&i>=r:"ArrowLeft"===n?t[0]<=e[0]&&i<r:"ArrowRight"!==n||t[0]>e[0]&&i<r)&&JSON.stringify(t)!==JSON.stringify(e)});r.length||r.push(e);var i=r.map(function(t){return n=Math.abs(e[0]-t[0]),r=Math.abs(e[1]-t[1]),Math.sqrt(Math.pow(n,2)+Math.pow(r,2));var n,r}),o=r[i.indexOf(Math.min.apply(Math,lt(i)))];return t.findIndex(function(e){return JSON.stringify(e)===JSON.stringify(o)})}},9(e,t,n){n.d(t,{Oo:()=>O,PI:()=>x,n8:()=>c,PH:()=>S,Nk:()=>P});var r=n(278),i=n(850);function o(e){let t=0;if(e&&e.length>0){t+=Math.abs(l(e[0]));for(let n=1;n<e.length;n++)t-=Math.abs(l(e[n]))}return t}var s=r.zX*r.zX/2,a=Math.PI/180;function l(e){const t=e.length-1;if(t<=2)return 0;let n=0,r=0;for(;r<t;){const i=e[r],o=e[r+1===t?0:r+1],s=e[r+2>=t?(r+2)%t:r+2],l=i[0]*a,u=o[1]*a;n+=(s[0]*a-l)*Math.sin(u),r++}return n*s}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var c={Polygon:3,LineString:2},f=function(e){var t;return null!==(t=null==e?void 0:e.geometry)&&void 0!==t?t:e},p=function(e){var t=f(e);return"Polygon"===(null==t?void 0:t.type)?t:null},h=function(e){for(var t,n,r=null!==(t=null===(n=e.coordinates)||void 0===n?void 0:n[0])&&void 0!==t?t:[],i=r.filter(function(e,t){return 0===t||e[0]!==r[t-1][0]||e[1]!==r[t-1][1]});i.length>1&&i[0][0]===i[i.length-1][0]&&i[0][1]===i[i.length-1][1];)i.pop();return i},d=function(e){return[].concat(function(e){if(Array.isArray(e))return u(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[e[0]]);var t},y=function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])},g=function(e,t){return e>0&&t<0||e<0&&t>0},m=function(e,t,n,r){return 0===e&&function(e,t,n){return Math.min(e[0],n[0])<=t[0]&&t[0]<=Math.max(e[0],n[0])&&Math.min(e[1],n[1])<=t[1]&&t[1]<=Math.max(e[1],n[1])}(t,n,r)},v=function(e,t,n,r){var i=y(n,r,e),o=y(n,r,t),s=y(e,t,n),a=y(e,t,r);return!(!g(i,o)||!g(s,a))||m(i,n,e,r)||m(o,n,t,r)||m(s,e,n,t)||m(a,e,r,t)},b=function(e,t){for(var n=e.length,r=t?n:n-1,i=0;i<r;i++)for(var o=i+1;o<r;o++)if(!(o===i+1||t&&0===i&&o===r-1)&&v(e[i],e[(i+1)%n],e[o],e[(o+1)%n]))return!0;return!1},E=function(e){var t=p(e);if(!t)return{valid:!0};var n=h(t);return n.length<4?{valid:!0}:b(n,!0)?{valid:!1,reason:"Shape must not intersect itself"}:{valid:!0}},w=function(e){var t=p(e);if(!t)return{valid:!0};var n=h(t);if(n.length<c.Polygon)return{valid:!0};var r,s=0;try{r={type:"Feature",geometry:{type:"Polygon",coordinates:[d(n)]},properties:{}},s=(0,i.jE)(r,(e,t)=>e+function(e){let t,n=0;switch(e.type){case"Polygon":return o(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)n+=o(e.coordinates[t]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(t),0)}catch(e){return{valid:!0}}return s>0?{valid:!0}:{valid:!1,reason:"Shape must enclose an area"}},S={Polygon:"Shape needs at least 3 points",LineString:"Line needs at least 2 points"},P=[E,w,function(e){var t,n,r=f(e);return"Polygon"===(null==r?void 0:r.type)?h(r).length>=c.Polygon?{valid:!0}:{valid:!1,reason:S.Polygon}:"LineString"===(null==r?void 0:r.type)?(null!==(t=null===(n=r.coordinates)||void 0===n?void 0:n.length)&&void 0!==t?t:0)>=c.LineString?{valid:!0}:{valid:!1,reason:S.LineString}:{valid:!0}}],x=[E,w],O=[function(e){return function(e){var t=p(e);if(!t)return!1;var n=h(t);return!(n.length<4)&&b(n,!1)}(e)?{valid:!1,reason:"Shape must not intersect itself"}:{valid:!0}}]},520(e,t,n){n.d(t,{$U:()=>f,$b:()=>h,Uk:()=>d,dV:()=>p});var r=n(9);function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return(t=function(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var c=function(e){return void 0===e||!0===e?{valid:!0}:!1===e?{valid:!1,reason:null}:{valid:!1!==e.valid,reason:e.reason}},f=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i.rules,a=void 0===o?r.Nk:o,u=i.onGeometryChange,f=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=l(e))){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return o=e.done,e},e:function(e){s=!0,i=e},f:function(){try{o||null==t.return||t.return()}finally{if(s)throw i}}}}(a);try{for(f.s();!(t=f.n()).done;){var p=t.value,h=c(p(e,n));if(!h.valid)return h}}catch(e){f.e(e)}finally{f.f()}return"function"==typeof u?c(u(s({feature:e},n))):{valid:!0}},p={Polygon:"draw_polygon",LineString:"draw_line"},h=function(e){var t,n=e.placed,i=e.point,o=e.geometryType,a=e.onGeometryChange,c=[].concat(function(e){if(Array.isArray(e))return u(e)}(t=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||l(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[i]),h={type:"Feature",geometry:"Polygon"===o?{type:"Polygon",coordinates:[c]}:{type:"LineString",coordinates:c},properties:{}},d=p[o],y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.rules,o=void 0===i?r.Oo:i,a=n.onGeometryChange;return f(e,s(s({},t),{},{phase:"place"}),{rules:o,onGeometryChange:a})}(h,{mode:d,vertexIndex:n.length},{onGeometryChange:a}),g=y.valid,m=y.reason;return g?{valid:!0}:{valid:!1,blocked:{feature:h,reason:null!=m?m:null,phase:"place",mode:d,vertexIndex:n.length}}},d=function(e){var t,n,i,o,a,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=u.rules,p=void 0===c?r.PI:c,h=u.onGeometryChange,d=null!==(t=null==e||null===(n=e.geometry)||void 0===n?void 0:n.type)&&void 0!==t?t:null==e?void 0:e.type,y=null!==(i=r.n8[d])&&void 0!==i?i:0,g=(null!==(o=l.numVertices)&&void 0!==o?o:0)<y?[]:p;return f(e,s(s({},l),{},{phase:null!==(a=l.phase)&&void 0!==a?a:"preview"}),{rules:g,onGeometryChange:h})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.drawPlugin=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e].call(i.exports,i,i.exports,o),i.exports}o.m=r,o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>({356:"im-draw-ml-adapter",568:"im-draw-plugin",722:"im-draw-ol-adapter"}[e]+".js"),o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="defra.drawPlugin:",o.l=(r,n,i,a)=>{if(e[r])e[r].push(n);else{var u,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){u=l;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",o.nc&&u.setAttribute("nonce",o.nc),u.setAttribute("data-webpack",t+i),u.src=r),e[r]=[n];var s=(t,n)=>{u.onerror=u.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(e=>e(n)),t)return t(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=s.bind(null,u.onerror),u.onload=s.bind(null,u.onload),c&&document.head.appendChild(u)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={57:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=i);var a=o.p+o.u(t),u=new Error;o.l(a,r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",u.name="ChunkLoadError",u.type=i,u.request=a,n[1](u)}},"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[a,u,c]=r,f=0;if(a.some(t=>0!==e[t])){for(n in u)o.o(u,n)&&(o.m[n]=u[n]);c&&c(o)}for(t&&t(r);f<a.length;f++)i=a[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function u(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof f?n:f,p=Object.create(u.prototype);return c(p,"_invoke",function(r,n,o){var i,u,c,f=0,p=o||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,u=0,c=e,s.n=r,a}};function d(r,n){for(u=r,c=n,t=0;!l&&f&&!o&&t<p.length;t++){var o,i=p[t],d=s.p,b=i[2];r>3?(o=b===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(u=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,u=0))}if(o||r>1)return a;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,b),u=p,c=b;(t=u<2?e:c)||!l;){i||(u?u<3?(u>1&&(s.n=-1),d(u,c)):s.n=c:s.v=c);try{if(f=2,i){if(u||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,u<2&&(u=0)}else 1===u&&(t=i.return)&&t.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=e}else if((t=(l=s.n<0)?c:r.call(n,s))!==a)break}catch(t){i=e,u=1,c=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var a={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(c(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,c(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,c(d,"constructor",l),c(l,"constructor",p),p.displayName="GeneratorFunction",c(l,o,"GeneratorFunction"),c(d),c(d,o,"Generator"),c(d,n,function(){return this}),c(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:b}})()}function c(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,r,n){function i(t,r){c(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},c(e,t,r,n)}function f(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function p(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?p(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){var e,t;return l(l({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"draw",load:(e=u().m(function e(){var t;return u().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(568).then(o.bind(o,977));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){f(i,n,o,a,u,"next",e)}function u(e){f(i,n,o,a,u,"throw",e)}a(void 0)})},function(){return t.apply(this,arguments)})})}return o.d(i,{default:()=>d}),i.default})());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { EVENTS } from '../../../src/config/events.js'
|
|
3
|
+
import { loadDrawAdapter } from './adapters/loadDrawAdapter.js'
|
|
4
|
+
import { attachEvents } from './events.js'
|
|
5
|
+
|
|
6
|
+
export const DrawInit = ({ appState, appConfig, mapState, pluginConfig, pluginState, services, mapProvider, buttonConfig }) => {
|
|
7
|
+
const { eventBus, hints } = services
|
|
8
|
+
const { crossHair } = mapState
|
|
9
|
+
const isTouchOrKeyboard = ['touch', 'keyboard'].includes(appState.interfaceType)
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const inModeWhitelist = pluginConfig.includeModes?.includes(appState.mode) ?? true
|
|
13
|
+
const inExcludeModes = pluginConfig.excludeModes?.includes(appState.mode) ?? false
|
|
14
|
+
|
|
15
|
+
if (!mapState.isMapReady || !inModeWhitelist || inExcludeModes) {
|
|
16
|
+
return undefined
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let isMounted = true
|
|
20
|
+
|
|
21
|
+
loadDrawAdapter(mapProvider, {
|
|
22
|
+
mapStyle: mapState.mapStyle,
|
|
23
|
+
snapLayers: pluginConfig.snapLayers,
|
|
24
|
+
pluginConfig,
|
|
25
|
+
events: EVENTS,
|
|
26
|
+
eventBus
|
|
27
|
+
}).then(adapter => {
|
|
28
|
+
if (!isMounted) { return }
|
|
29
|
+
mapProvider.draw = adapter
|
|
30
|
+
pluginState.dispatch({ type: 'SET_HAS_SNAP_LAYERS', payload: pluginConfig.snapLayers?.length > 0 })
|
|
31
|
+
eventBus.emit('draw:ready')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
isMounted = false
|
|
36
|
+
mapProvider.draw?.remove()
|
|
37
|
+
mapProvider.draw = null
|
|
38
|
+
// Release MoveControl's D-pad if this plugin instance still held it.
|
|
39
|
+
mapProvider.activeMoveTarget = null
|
|
40
|
+
}
|
|
41
|
+
}, [mapState.isMapReady, appState.mode])
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (['draw_polygon', 'draw_line'].includes(pluginState.mode) && isTouchOrKeyboard) {
|
|
45
|
+
const wasAlreadyVisible = crossHair.isVisible
|
|
46
|
+
crossHair.fixAtCenter()
|
|
47
|
+
return () => {
|
|
48
|
+
// Only hide crosshair if it wasn't visible before drawing AND we're not currently
|
|
49
|
+
// in keyboard/touch mode (user might have switched input devices during drawing).
|
|
50
|
+
// This ensures crosshair stays visible if user switched to keyboard mid-drawing.
|
|
51
|
+
if (!wasAlreadyVisible && !['touch', 'keyboard'].includes(appState.interfaceType)) {
|
|
52
|
+
crossHair.hide()
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return undefined
|
|
57
|
+
}, [pluginState.mode, appState.interfaceType])
|
|
58
|
+
|
|
59
|
+
// Keep the active draw/edit session in sync with the global interface type so
|
|
60
|
+
// the touch offset target shows/hides, and the rubber band keeps following the
|
|
61
|
+
// map, immediately when the input device changes mid-session (e.g. the user
|
|
62
|
+
// starts drawing with the mouse then switches to touch and pans via MoveControl).
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!['edit_vertex', 'draw_polygon', 'draw_line'].includes(pluginState.mode) || !mapProvider.draw) {
|
|
65
|
+
return undefined
|
|
66
|
+
}
|
|
67
|
+
mapProvider.draw.setInterfaceType(appState.interfaceType)
|
|
68
|
+
return undefined
|
|
69
|
+
}, [appState.interfaceType, pluginState.mode])
|
|
70
|
+
|
|
71
|
+
// Attach events when plugin state or map provider changes
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!mapProvider.draw) {
|
|
74
|
+
return undefined
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return attachEvents({
|
|
78
|
+
appState,
|
|
79
|
+
appConfig,
|
|
80
|
+
mapState,
|
|
81
|
+
mapProvider,
|
|
82
|
+
buttonConfig,
|
|
83
|
+
pluginState,
|
|
84
|
+
events: EVENTS,
|
|
85
|
+
eventBus,
|
|
86
|
+
hints
|
|
87
|
+
})
|
|
88
|
+
}, [mapProvider, appState, pluginState])
|
|
89
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { render, act } from '@testing-library/react'
|
|
2
|
+
import { EVENTS } from '../../../src/config/events.js'
|
|
3
|
+
import { DrawInit } from './DrawInit.jsx'
|
|
4
|
+
import { loadDrawAdapter } from './adapters/loadDrawAdapter.js'
|
|
5
|
+
import { attachEvents } from './events.js'
|
|
6
|
+
|
|
7
|
+
jest.mock('./adapters/loadDrawAdapter.js', () => ({ loadDrawAdapter: jest.fn() }))
|
|
8
|
+
jest.mock('./events.js', () => ({ attachEvents: jest.fn(() => jest.fn()) }))
|
|
9
|
+
|
|
10
|
+
const makeProps = (overrides = {}) => {
|
|
11
|
+
const adapter = { remove: jest.fn(), setInterfaceType: jest.fn() }
|
|
12
|
+
loadDrawAdapter.mockResolvedValue(adapter)
|
|
13
|
+
|
|
14
|
+
const props = {
|
|
15
|
+
appState: { interfaceType: 'mouse', mode: null },
|
|
16
|
+
appConfig: { id: 'app' },
|
|
17
|
+
mapState: {
|
|
18
|
+
isMapReady: true,
|
|
19
|
+
mapStyle: { id: 'outdoor' },
|
|
20
|
+
crossHair: { isVisible: false, fixAtCenter: jest.fn(), hide: jest.fn() }
|
|
21
|
+
},
|
|
22
|
+
pluginConfig: { snapLayers: ['a'] },
|
|
23
|
+
pluginState: { dispatch: jest.fn(), mode: null },
|
|
24
|
+
services: { eventBus: { emit: jest.fn() } },
|
|
25
|
+
mapProvider: { draw: null },
|
|
26
|
+
buttonConfig: {},
|
|
27
|
+
...overrides
|
|
28
|
+
}
|
|
29
|
+
return { props, adapter }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const renderInit = async (props) => {
|
|
33
|
+
let result
|
|
34
|
+
await act(async () => { result = render(<DrawInit {...props} />) })
|
|
35
|
+
return result
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
beforeEach(() => jest.clearAllMocks())
|
|
39
|
+
|
|
40
|
+
describe('adapter lifecycle', () => {
|
|
41
|
+
test('loads the adapter and announces readiness when the map is ready', async () => {
|
|
42
|
+
const { props, adapter } = makeProps()
|
|
43
|
+
|
|
44
|
+
await renderInit(props)
|
|
45
|
+
|
|
46
|
+
expect(loadDrawAdapter).toHaveBeenCalledWith(props.mapProvider, expect.objectContaining({
|
|
47
|
+
mapStyle: props.mapState.mapStyle,
|
|
48
|
+
snapLayers: props.pluginConfig.snapLayers,
|
|
49
|
+
events: EVENTS,
|
|
50
|
+
eventBus: props.services.eventBus
|
|
51
|
+
}))
|
|
52
|
+
expect(props.mapProvider.draw).toBe(adapter)
|
|
53
|
+
expect(props.pluginState.dispatch).toHaveBeenCalledWith({ type: 'SET_HAS_SNAP_LAYERS', payload: true })
|
|
54
|
+
expect(props.services.eventBus.emit).toHaveBeenCalledWith('draw:ready')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('does not load when the map is not ready', async () => {
|
|
58
|
+
const { props } = makeProps({
|
|
59
|
+
mapState: { isMapReady: false, mapStyle: {}, crossHair: { isVisible: false, fixAtCenter: jest.fn(), hide: jest.fn() } }
|
|
60
|
+
})
|
|
61
|
+
await renderInit(props)
|
|
62
|
+
expect(loadDrawAdapter).not.toHaveBeenCalled()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('does not load when the app mode is excluded', async () => {
|
|
66
|
+
const { props } = makeProps({
|
|
67
|
+
appState: { interfaceType: 'mouse', mode: 'measure' },
|
|
68
|
+
pluginConfig: { snapLayers: [], excludeModes: ['measure'] }
|
|
69
|
+
})
|
|
70
|
+
await renderInit(props)
|
|
71
|
+
expect(loadDrawAdapter).not.toHaveBeenCalled()
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
test('does not load when the app mode is outside the include list', async () => {
|
|
75
|
+
const { props } = makeProps({
|
|
76
|
+
appState: { interfaceType: 'mouse', mode: 'other' },
|
|
77
|
+
pluginConfig: { snapLayers: [], includeModes: ['draw'] }
|
|
78
|
+
})
|
|
79
|
+
await renderInit(props)
|
|
80
|
+
expect(loadDrawAdapter).not.toHaveBeenCalled()
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
test('removes the adapter, clears the reference, and releases activeMoveTarget on unmount', async () => {
|
|
84
|
+
const { props, adapter } = makeProps()
|
|
85
|
+
const result = await renderInit(props)
|
|
86
|
+
expect(props.mapProvider.draw).toBe(adapter)
|
|
87
|
+
props.mapProvider.activeMoveTarget = { move: jest.fn(), label: 'vertex' }
|
|
88
|
+
|
|
89
|
+
await act(async () => { result.unmount() })
|
|
90
|
+
|
|
91
|
+
expect(adapter.remove).toHaveBeenCalled()
|
|
92
|
+
expect(props.mapProvider.draw).toBeNull()
|
|
93
|
+
expect(props.mapProvider.activeMoveTarget).toBeNull()
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
test('ignores a late-resolving adapter after unmount', async () => {
|
|
97
|
+
const { props, adapter } = makeProps()
|
|
98
|
+
let resolveAdapter
|
|
99
|
+
loadDrawAdapter.mockReturnValue(new Promise((resolve) => { resolveAdapter = resolve }))
|
|
100
|
+
|
|
101
|
+
let result
|
|
102
|
+
await act(async () => { result = render(<DrawInit {...props} />) })
|
|
103
|
+
await act(async () => { result.unmount() })
|
|
104
|
+
await act(async () => { resolveAdapter(adapter); await Promise.resolve() })
|
|
105
|
+
|
|
106
|
+
expect(props.mapProvider.draw).toBeNull()
|
|
107
|
+
expect(props.services.eventBus.emit).not.toHaveBeenCalledWith('draw:ready')
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
describe('crosshair', () => {
|
|
112
|
+
test('fixes the crosshair at centre while drawing on a touch interface', async () => {
|
|
113
|
+
const { props } = makeProps({
|
|
114
|
+
appState: { interfaceType: 'touch', mode: null },
|
|
115
|
+
pluginState: { dispatch: jest.fn(), mode: 'draw_polygon' }
|
|
116
|
+
})
|
|
117
|
+
await renderInit(props)
|
|
118
|
+
expect(props.mapState.crossHair.fixAtCenter).toHaveBeenCalled()
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test('leaves the crosshair alone when not drawing', async () => {
|
|
122
|
+
const { props } = makeProps({
|
|
123
|
+
appState: { interfaceType: 'touch', mode: null },
|
|
124
|
+
pluginState: { dispatch: jest.fn(), mode: 'edit_vertex' }
|
|
125
|
+
})
|
|
126
|
+
await renderInit(props)
|
|
127
|
+
expect(props.mapState.crossHair.fixAtCenter).not.toHaveBeenCalled()
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
test('hides the crosshair on cleanup when it was hidden before and the interface has left touch/keyboard', async () => {
|
|
131
|
+
const { props } = makeProps({
|
|
132
|
+
appState: { interfaceType: 'touch', mode: null },
|
|
133
|
+
pluginState: { dispatch: jest.fn(), mode: 'draw_polygon' }
|
|
134
|
+
})
|
|
135
|
+
const result = await renderInit(props)
|
|
136
|
+
expect(props.mapState.crossHair.fixAtCenter).toHaveBeenCalled()
|
|
137
|
+
|
|
138
|
+
// Switch away from touch/keyboard, then re-render so the crosshair effect's
|
|
139
|
+
// cleanup runs — it reads the (mutated) interface type and hides the crosshair.
|
|
140
|
+
props.appState.interfaceType = 'mouse'
|
|
141
|
+
await act(async () => { result.rerender(<DrawInit {...props} />) })
|
|
142
|
+
|
|
143
|
+
expect(props.mapState.crossHair.hide).toHaveBeenCalled()
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
describe('interface type sync', () => {
|
|
148
|
+
test.each(['edit_vertex', 'draw_polygon', 'draw_line'])('pushes the interface type to the adapter in %s mode', async (mode) => {
|
|
149
|
+
const { props, adapter } = makeProps({ pluginState: { dispatch: jest.fn(), mode } })
|
|
150
|
+
props.mapProvider.draw = adapter
|
|
151
|
+
await renderInit(props)
|
|
152
|
+
expect(adapter.setInterfaceType).toHaveBeenCalledWith('mouse')
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
test('does nothing outside draw/edit modes', async () => {
|
|
156
|
+
const { props, adapter } = makeProps({ pluginState: { dispatch: jest.fn(), mode: null } })
|
|
157
|
+
props.mapProvider.draw = adapter
|
|
158
|
+
await renderInit(props)
|
|
159
|
+
expect(adapter.setInterfaceType).not.toHaveBeenCalled()
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
describe('event attachment', () => {
|
|
164
|
+
test('attaches events when a draw adapter is present', async () => {
|
|
165
|
+
const { props, adapter } = makeProps()
|
|
166
|
+
props.mapProvider.draw = adapter
|
|
167
|
+
await renderInit(props)
|
|
168
|
+
expect(attachEvents).toHaveBeenCalledWith(expect.objectContaining({
|
|
169
|
+
mapProvider: props.mapProvider,
|
|
170
|
+
buttonConfig: props.buttonConfig,
|
|
171
|
+
pluginState: props.pluginState,
|
|
172
|
+
eventBus: props.services.eventBus,
|
|
173
|
+
events: EVENTS
|
|
174
|
+
}))
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
test('does not attach events without a draw adapter', async () => {
|
|
178
|
+
const { props } = makeProps({
|
|
179
|
+
mapState: { isMapReady: false, mapStyle: {}, crossHair: { isVisible: false, fixAtCenter: jest.fn(), hide: jest.fn() } }
|
|
180
|
+
})
|
|
181
|
+
await renderInit(props)
|
|
182
|
+
expect(attachEvents).not.toHaveBeenCalled()
|
|
183
|
+
})
|
|
184
|
+
})
|