@defra/interactive-map 0.0.21-alpha → 0.0.23-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/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/button-definition.md +39 -0
- package/docs/api/context.md +4 -4
- package/docs/api/map-style-config.md +11 -2
- package/docs/api/marker-config.md +38 -7
- package/docs/api/panel-definition.md +7 -3
- package/docs/api/symbol-config.md +10 -26
- package/docs/api/symbol-registry.md +28 -13
- package/docs/api.md +65 -4
- package/docs/assets/css/{docusaurus.css → docusaurus.scss} +18 -12
- package/docs/assets/images/toggle-marker-label.jpg +0 -0
- package/docs/examples/index.mdx +12 -0
- package/docs/examples/toggle-marker-label.mdx +89 -0
- package/docs/plugins/datasets.md +39 -1
- package/docs/plugins/interact.md +4 -11
- package/docusaurus.config.cjs +2 -1
- package/package.json +10 -12
- package/plugins/beta/datasets/dist/adapters/maplibre/esm/im-datasets-ml-adapter.js +1 -0
- package/plugins/beta/datasets/dist/css/index.css +2 -2
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/maplibre/im-datasets-maplibre-adapter.js +2 -0
- package/plugins/beta/datasets/dist/umd/maplibre/im-datasets-plugin.js +2 -0
- package/plugins/beta/datasets/dist/umd/maplibre/index.js +2 -0
- package/plugins/beta/datasets/src/adapters/maplibre/index.js +1 -1
- package/plugins/beta/datasets/src/adapters/maplibre/layerBuilders.js +5 -5
- package/plugins/beta/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +24 -29
- package/plugins/beta/datasets/src/adapters/maplibre/patternImages.js +2 -2
- package/plugins/beta/datasets/src/adapters/maplibre/symbolImages.js +3 -3
- package/plugins/beta/datasets/src/components/KeySvg.jsx +2 -2
- package/plugins/beta/datasets/src/components/KeySvgPattern.jsx +1 -2
- package/plugins/beta/datasets/src/components/svgProperties.js +2 -2
- package/plugins/beta/datasets/src/index.maplibre.umd.js +23 -0
- package/plugins/beta/datasets/src/panels/Key.module.scss +2 -2
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.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/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/index.js +1 -1
- package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/src/manifest.js +1 -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/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +23 -55
- package/plugins/interact/src/InteractInit.test.js +58 -80
- package/plugins/interact/src/defaults.js +1 -3
- package/plugins/interact/src/hooks/useAttachEvents.js +46 -0
- package/plugins/interact/src/hooks/useAttachEvents.test.js +65 -0
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +47 -0
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +54 -0
- package/plugins/interact/src/hooks/useHighlightSync.js +30 -8
- package/plugins/interact/src/hooks/useHighlightSync.test.js +127 -80
- package/plugins/interact/src/hooks/useInteractionHandlers.js +18 -17
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +22 -61
- package/plugins/interact/src/hooks/useMapItemList.js +187 -0
- package/plugins/interact/src/hooks/useMapItemList.test.js +584 -0
- package/plugins/interact/src/index.js +0 -2
- package/plugins/interact/src/index.test.js +0 -2
- package/plugins/interact/src/manifest.js +37 -6
- package/plugins/interact/src/reducer.js +8 -4
- package/plugins/interact/src/reducer.test.js +18 -3
- package/plugins/interact/src/utils/buildStylesMap.js +21 -10
- package/plugins/interact/src/utils/buildStylesMap.test.js +29 -29
- package/plugins/interact/src/utils/spatial.js +0 -15
- package/plugins/interact/src/utils/spatial.test.js +1 -13
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/src/components/CloseButton/CloseButton.module.scss +2 -0
- package/plugins/search/src/components/OpenButton/OpenButton.jsx +1 -1
- package/plugins/search/src/components/OpenButton/OpenButton.module.scss +3 -0
- package/plugins/search/src/search.scss +1 -0
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/src/esriProvider.js +4 -0
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +7 -1
- package/providers/maplibre/src/index.test.js +15 -2
- package/providers/maplibre/src/mapEvents.js +11 -5
- package/providers/maplibre/src/mapEvents.test.js +14 -3
- package/providers/maplibre/src/maplibreProvider.js +18 -11
- package/providers/maplibre/src/maplibreProvider.test.js +43 -36
- package/providers/maplibre/src/utils/highlightFeatures.js +102 -57
- package/providers/maplibre/src/utils/highlightFeatures.test.js +162 -51
- package/providers/maplibre/src/utils/maplibreFixes.js +10 -0
- package/providers/maplibre/src/utils/maplibreFixes.test.js +31 -0
- package/providers/maplibre/src/utils/patternImages.js +10 -12
- package/providers/maplibre/src/utils/patternImages.test.js +145 -167
- package/providers/maplibre/src/utils/rasteriseToImageData.js +1 -4
- package/providers/maplibre/src/utils/rasteriseToImageData.test.js +23 -24
- package/providers/maplibre/src/utils/symbolImages.js +23 -86
- package/providers/maplibre/src/utils/symbolImages.test.js +60 -105
- package/rollup.esm.mjs +1 -1
- package/src/App/components/Actions/Actions.module.scss +1 -0
- package/src/App/components/Actions/Actions.test.jsx +17 -4
- package/src/App/components/Hints/Hints.jsx +52 -0
- package/src/App/components/Hints/Hints.module.scss +37 -0
- package/src/App/components/Hints/Hints.test.jsx +104 -0
- package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +57 -19
- package/src/App/components/KeyboardHelp/KeyboardHelp.module.scss +10 -0
- package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +140 -31
- package/src/App/components/Markers/LabelMarker.jsx +14 -0
- package/src/App/components/Markers/LabelMarker.test.jsx +36 -0
- package/src/App/components/Markers/Markers.jsx +44 -75
- package/src/App/components/Markers/Markers.module.scss +58 -0
- package/src/App/components/Markers/Markers.test.jsx +90 -113
- package/src/App/components/Markers/SymbolLabelMarker.jsx +43 -0
- package/src/App/components/Markers/SymbolLabelMarker.test.jsx +56 -0
- package/src/App/components/Markers/SymbolMarker.jsx +31 -0
- package/src/App/components/Markers/SymbolMarker.test.jsx +72 -0
- package/src/App/components/Panel/Panel.jsx +1 -1
- package/src/App/components/Panel/Panel.module.scss +1 -0
- package/src/App/components/PopupMenu/PopupMenu.test.jsx +117 -1
- package/src/App/components/PopupMenu/usePopupMenu.js +132 -85
- package/src/App/components/Tabs/Tabs.jsx +68 -0
- package/src/App/components/Tabs/Tabs.module.scss +57 -0
- package/src/App/components/Tabs/Tabs.test.jsx +121 -0
- package/src/App/components/Tooltip/Tooltip.module.scss +1 -1
- package/src/App/components/Viewport/Features.jsx +35 -0
- package/src/App/components/Viewport/Features.module.scss +31 -0
- package/src/App/components/Viewport/Features.test.jsx +124 -0
- package/src/App/components/Viewport/MapController.jsx +1 -1
- package/src/App/components/Viewport/MapStatus.jsx +0 -4
- package/src/App/components/Viewport/Viewport.jsx +35 -29
- package/src/App/components/Viewport/Viewport.module.scss +7 -21
- package/src/App/components/Viewport/Viewport.test.jsx +108 -65
- package/src/App/controls/keyboardActions.js +9 -3
- package/src/App/controls/keyboardActions.test.js +122 -87
- package/src/App/controls/keyboardShortcuts.js +1 -14
- package/src/App/hooks/useFeatureFocus.js +199 -0
- package/src/App/hooks/useFeatureFocus.test.js +635 -0
- package/src/App/hooks/useFeatureItems.js +30 -0
- package/src/App/hooks/useFeatureItems.test.js +97 -0
- package/src/App/hooks/useFocusVisible.js +4 -7
- package/src/App/hooks/useFocusVisible.test.js +6 -6
- package/src/App/hooks/useKeyboardHint.js +9 -34
- package/src/App/hooks/useKeyboardHint.test.js +34 -84
- package/src/App/hooks/useKeyboardShortcuts.js +8 -5
- package/src/App/hooks/useKeyboardShortcuts.test.js +16 -12
- package/src/App/hooks/useLayoutMeasurements.js +10 -4
- package/src/App/hooks/useLayoutMeasurements.test.js +30 -0
- package/src/App/hooks/useMapURLSync.js +3 -3
- package/src/App/hooks/useMapURLSync.test.js +20 -3
- package/src/App/hooks/useMarkerCursor.js +33 -0
- package/src/App/hooks/useMarkerCursor.test.js +87 -0
- package/src/App/hooks/useMarkersAPI.js +32 -9
- package/src/App/hooks/useMarkersAPI.test.js +162 -94
- package/src/App/layout/Layout.jsx +2 -0
- package/src/App/layout/Layout.test.jsx +3 -0
- package/src/App/registry/keyboardShortcutRegistry.js +3 -2
- package/src/App/registry/keyboardShortcutRegistry.test.js +6 -8
- package/src/App/renderer/mapButtons.js +5 -1
- package/src/App/renderer/mapButtons.test.js +37 -1
- package/src/App/store/ServiceProvider.jsx +4 -1
- package/src/App/store/ServiceProvider.test.jsx +11 -0
- package/src/App/store/appActionsMap.js +5 -1
- package/src/App/store/appActionsMap.test.js +13 -0
- package/src/App/store/appReducer.js +1 -0
- package/src/App/store/mapActionsMap.js +2 -1
- package/src/InteractiveMap/InteractiveMap.js +13 -1
- package/src/InteractiveMap/InteractiveMap.test.js +6 -4
- package/src/InteractiveMap/behaviourController.js +1 -2
- package/src/InteractiveMap/buttonManager.js +1 -3
- package/src/InteractiveMap/buttonManager.test.js +16 -8
- package/src/InteractiveMap/domStateManager.js +2 -3
- package/src/InteractiveMap/historyManager.js +4 -3
- package/src/config/appConfig.js +3 -1
- package/src/config/appConfig.test.js +4 -0
- package/src/config/defaults.js +3 -2
- package/src/config/events.js +8 -0
- package/src/config/mapTheme.js +8 -4
- package/src/config/mergeConfig.js +8 -2
- package/src/config/mergeConfig.test.js +19 -0
- package/src/config/symbolConfig.js +23 -16
- package/src/scss/main.scss +3 -0
- package/src/scss/tools/_border-focus.scss +0 -1
- package/src/services/eventBus.js +15 -0
- package/src/services/eventBus.test.js +11 -0
- package/src/services/hints.js +47 -0
- package/src/services/hints.test.js +110 -0
- package/src/services/patternRegistry.js +69 -1
- package/src/services/patternRegistry.test.js +112 -1
- package/src/services/reverseGeocode.js +4 -0
- package/src/services/reverseGeocode.test.js +11 -1
- package/src/services/symbolRegistry.js +152 -17
- package/src/services/symbolRegistry.test.js +141 -31
- package/src/types.js +93 -16
- package/src/utils/constrainKeyboardFocus.js +5 -5
- package/src/utils/detectInterfaceType.js +27 -5
- package/src/utils/detectInterfaceType.test.js +29 -3
- package/src/utils/mapStateSync.js +2 -2
- package/src/utils/mapStateSync.test.js +18 -0
- package/src/utils/patternUtils.js +4 -67
- package/src/utils/patternUtils.test.js +1 -123
- package/src/utils/symbolUtils.js +11 -13
- package/src/utils/symbolUtils.test.js +18 -26
- package/webpack.dev.mjs +4 -0
- package/webpack.umd.mjs +9 -6
- package/plugins/beta/datasets/adapters/maplibre/dist/esm/im-datasets-ml-adapter.js +0 -1
- package/plugins/beta/datasets/adapters/maplibre/dist/umd/im-datasets-ml-adapter.js +0 -2
- package/plugins/beta/datasets/adapters/maplibre/dist/umd/index.js +0 -1
- package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +0 -2
- package/plugins/beta/datasets/dist/umd/index.js +0 -2
- package/plugins/interact/dist/css/index.css +0 -1
- package/plugins/interact/src/interact.scss +0 -24
- /package/plugins/beta/datasets/{adapters/maplibre/dist → dist/adapters/maplibre}/esm/index.js +0 -0
- /package/plugins/beta/datasets/{adapters/maplibre/dist/umd/im-datasets-ml-adapter.js.LICENSE.txt → dist/umd/maplibre/im-datasets-maplibre-adapter.js.LICENSE.txt} +0 -0
- /package/plugins/beta/datasets/dist/umd/{im-datasets-plugin.js.LICENSE.txt → maplibre/im-datasets-plugin.js.LICENSE.txt} +0 -0
- /package/plugins/beta/datasets/dist/umd/{index.js.LICENSE.txt → maplibre/index.js.LICENSE.txt} +0 -0
|
@@ -4,12 +4,12 @@ const initialState = {
|
|
|
4
4
|
marker: null,
|
|
5
5
|
interactionModes: null,
|
|
6
6
|
multiSelect: false,
|
|
7
|
-
contiguous: false,
|
|
8
7
|
deselectOnClickOutside: false,
|
|
9
8
|
selectedFeatures: [],
|
|
10
9
|
selectedMarkers: [],
|
|
11
10
|
selectionBounds: null,
|
|
12
|
-
closeOnAction: true // Done or Cancel
|
|
11
|
+
closeOnAction: true, // Done or Cancel
|
|
12
|
+
listboxActiveItem: null // { featureId, layerId, idProperty, geometry } | null — ring shown but no selectionchange
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const enable = (state, payload) => {
|
|
@@ -26,7 +26,8 @@ const disable = (state) => {
|
|
|
26
26
|
enabled: false,
|
|
27
27
|
selectedFeatures: [],
|
|
28
28
|
selectedMarkers: [],
|
|
29
|
-
selectionBounds: null
|
|
29
|
+
selectionBounds: null,
|
|
30
|
+
listboxActiveItem: null
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -107,6 +108,8 @@ const clearSelectedFeatures = (state) => {
|
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
const setListboxActive = (state, payload) => ({ ...state, listboxActiveItem: payload ?? null })
|
|
112
|
+
|
|
110
113
|
/**
|
|
111
114
|
* Explicitly select a marker. Has no effect if already selected.
|
|
112
115
|
* In single-select mode, clears selectedFeatures and replaces the selection.
|
|
@@ -148,7 +151,8 @@ const actions = {
|
|
|
148
151
|
UPDATE_SELECTED_BOUNDS: updateSelectedBounds,
|
|
149
152
|
CLEAR_SELECTED_FEATURES: clearSelectedFeatures,
|
|
150
153
|
SELECT_MARKER: selectMarker,
|
|
151
|
-
UNSELECT_MARKER: unselectMarker
|
|
154
|
+
UNSELECT_MARKER: unselectMarker,
|
|
155
|
+
SET_LISTBOX_ACTIVE: setListboxActive
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
export {
|
|
@@ -8,12 +8,12 @@ describe('initialState', () => {
|
|
|
8
8
|
marker: null,
|
|
9
9
|
interactionModes: null,
|
|
10
10
|
multiSelect: false,
|
|
11
|
-
contiguous: false,
|
|
12
11
|
deselectOnClickOutside: false,
|
|
13
12
|
selectedFeatures: [],
|
|
14
13
|
selectedMarkers: [],
|
|
15
14
|
selectionBounds: null,
|
|
16
|
-
closeOnAction: true
|
|
15
|
+
closeOnAction: true,
|
|
16
|
+
listboxActiveItem: null
|
|
17
17
|
})
|
|
18
18
|
})
|
|
19
19
|
})
|
|
@@ -189,6 +189,20 @@ describe('CLEAR_SELECTED_FEATURES action', () => {
|
|
|
189
189
|
})
|
|
190
190
|
})
|
|
191
191
|
|
|
192
|
+
describe('SET_LISTBOX_ACTIVE action', () => {
|
|
193
|
+
it('sets listboxActiveItem to the payload value', () => {
|
|
194
|
+
const payload = { featureId: 'f1', layerId: 'l1' }
|
|
195
|
+
const result = actions.SET_LISTBOX_ACTIVE(initialState, payload)
|
|
196
|
+
expect(result.listboxActiveItem).toEqual(payload)
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
it('sets listboxActiveItem to null when payload is null', () => {
|
|
200
|
+
const state = { ...initialState, listboxActiveItem: { featureId: 'f1' } }
|
|
201
|
+
const result = actions.SET_LISTBOX_ACTIVE(state, null)
|
|
202
|
+
expect(result.listboxActiveItem).toBeNull()
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
|
|
192
206
|
describe('SELECT_MARKER action', () => {
|
|
193
207
|
it('adds a marker in single-select mode, clearing selectedFeatures', () => {
|
|
194
208
|
const state = { ...initialState, selectedFeatures: [{ featureId: 'f1' }], selectedMarkers: [] }
|
|
@@ -236,7 +250,8 @@ describe('actions object', () => {
|
|
|
236
250
|
'UPDATE_SELECTED_BOUNDS',
|
|
237
251
|
'CLEAR_SELECTED_FEATURES',
|
|
238
252
|
'SELECT_MARKER',
|
|
239
|
-
'UNSELECT_MARKER'
|
|
253
|
+
'UNSELECT_MARKER',
|
|
254
|
+
'SET_LISTBOX_ACTIVE'
|
|
240
255
|
])
|
|
241
256
|
Object.values(actions).forEach(fn => expect(typeof fn).toBe('function'))
|
|
242
257
|
})
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { getValueForStyle } from '../../../../src/utils/getValueForStyle.js'
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { THEME_COLORS } from '../../../../src/config/mapTheme.js'
|
|
3
|
+
import { SELECTED_STROKE_WIDTH, ACTIVE_STROKE_WIDTH } from '../../../../src/config/symbolConfig.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Builds a map of layerId → resolved highlight style for the given data layers.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* layer
|
|
8
|
+
* Colour resolution order (both active and selection strokes):
|
|
9
|
+
* layer override → mapStyle override → mapColorScheme scheme default
|
|
10
10
|
*
|
|
11
11
|
* @param {Object[]} dataLayers
|
|
12
12
|
* @param {Object} mapStyle - Current map style config
|
|
13
|
-
* @returns {Object} layerId → {
|
|
13
|
+
* @returns {Object} layerId → {
|
|
14
|
+
* stroke: string, — active (keyboard cursor) line colour
|
|
15
|
+
* selectionStroke: string, — committed-selection line colour
|
|
16
|
+
* fill: string, — committed-selection fill colour (transparent when not set)
|
|
17
|
+
* strokeWidth: number — line-width applied to all highlight line layers (both active and selected states)
|
|
18
|
+
* }
|
|
14
19
|
*/
|
|
15
20
|
export const buildStylesMap = (dataLayers, mapStyle) => {
|
|
16
21
|
const stylesMap = {}
|
|
@@ -19,17 +24,23 @@ export const buildStylesMap = (dataLayers, mapStyle) => {
|
|
|
19
24
|
return stylesMap
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
const
|
|
27
|
+
const scheme = THEME_COLORS[mapStyle.mapColorScheme] ?? THEME_COLORS.light
|
|
28
|
+
const schemeActiveColor = mapStyle.activeColor ?? scheme.activeColor
|
|
29
|
+
const schemeSelectedColor = mapStyle.selectedColor ?? scheme.selectedColor
|
|
23
30
|
|
|
24
31
|
dataLayers.forEach(layer => {
|
|
25
|
-
const
|
|
32
|
+
const activeStroke = layer.activeStroke || schemeActiveColor
|
|
33
|
+
const selectionStroke = layer.selectedStroke || schemeSelectedColor
|
|
26
34
|
const fill = layer.selectedFill || 'transparent'
|
|
27
|
-
const strokeWidth = layer.selectedStrokeWidth ||
|
|
35
|
+
const strokeWidth = layer.selectedStrokeWidth || SELECTED_STROKE_WIDTH
|
|
36
|
+
const activeStrokeWidth = strokeWidth + ACTIVE_STROKE_WIDTH // ACTIVE_STROKE_WIDTH is the total overhang (extends SELECTED_STROKE_WIDTH each side)
|
|
28
37
|
|
|
29
38
|
stylesMap[layer.layerId] = {
|
|
30
|
-
stroke: getValueForStyle(
|
|
39
|
+
stroke: getValueForStyle(activeStroke, mapStyle.id),
|
|
40
|
+
selectionStroke: getValueForStyle(selectionStroke, mapStyle.id),
|
|
31
41
|
fill: getValueForStyle(fill, mapStyle.id),
|
|
32
|
-
strokeWidth
|
|
42
|
+
strokeWidth,
|
|
43
|
+
activeStrokeWidth
|
|
33
44
|
}
|
|
34
45
|
})
|
|
35
46
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { buildStylesMap } from './buildStylesMap.js'
|
|
2
|
-
import {
|
|
2
|
+
import { THEME_COLORS } from '../../../../src/config/mapTheme.js'
|
|
3
|
+
import { SELECTED_STROKE_WIDTH, ACTIVE_STROKE_WIDTH } from '../../../../src/config/symbolConfig.js'
|
|
3
4
|
import { getValueForStyle } from '../../../../src/utils/getValueForStyle.js'
|
|
4
5
|
|
|
5
6
|
jest.mock('../../../../src/utils/getValueForStyle.js', () => ({
|
|
6
7
|
getValueForStyle: jest.fn((value) => value)
|
|
7
8
|
}))
|
|
8
9
|
|
|
10
|
+
const CUSTOM_STROKE_WIDTH = 5
|
|
11
|
+
|
|
9
12
|
describe('buildStylesMap', () => {
|
|
10
13
|
beforeEach(() => {
|
|
11
14
|
jest.clearAllMocks()
|
|
@@ -17,54 +20,51 @@ describe('buildStylesMap', () => {
|
|
|
17
20
|
expect(buildStylesMap([], { id: 'default' })).toEqual({})
|
|
18
21
|
})
|
|
19
22
|
|
|
20
|
-
it('builds correct stylesMap with
|
|
23
|
+
it('builds correct stylesMap with layer overrides', () => {
|
|
21
24
|
const dataLayers = [
|
|
22
|
-
{ layerId: 'custom1', selectedStroke: 'red', selectedFill: 'blue', selectedStrokeWidth:
|
|
23
|
-
{ layerId: 'custom2' } // uses defaults
|
|
25
|
+
{ layerId: 'custom1', activeStroke: 'yellow', selectedStroke: 'red', selectedFill: 'blue', selectedStrokeWidth: CUSTOM_STROKE_WIDTH }
|
|
24
26
|
]
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const result = buildStylesMap(dataLayers, mapStyle)
|
|
28
|
-
|
|
29
|
-
// Layer-specific values
|
|
27
|
+
const result = buildStylesMap(dataLayers, { id: 'default-style' })
|
|
30
28
|
expect(result.custom1).toEqual({
|
|
31
|
-
stroke: '
|
|
29
|
+
stroke: 'yellow',
|
|
30
|
+
selectionStroke: 'red',
|
|
32
31
|
fill: 'blue',
|
|
33
|
-
strokeWidth:
|
|
32
|
+
strokeWidth: CUSTOM_STROKE_WIDTH,
|
|
33
|
+
activeStrokeWidth: CUSTOM_STROKE_WIDTH + ACTIVE_STROKE_WIDTH
|
|
34
34
|
})
|
|
35
|
+
})
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
expect(result.
|
|
37
|
+
it('falls back to scheme defaults when no layer or mapStyle overrides', () => {
|
|
38
|
+
const dataLayers = [{ layerId: 'layer1' }]
|
|
39
|
+
const result = buildStylesMap(dataLayers, { id: 'default-style' })
|
|
40
|
+
expect(result.layer1.stroke).toBe(THEME_COLORS.light.activeColor)
|
|
41
|
+
expect(result.layer1.selectionStroke).toBe(THEME_COLORS.light.selectedColor)
|
|
42
|
+
expect(result.layer1.fill).toBe('transparent')
|
|
43
|
+
expect(result.layer1.strokeWidth).toBe(SELECTED_STROKE_WIDTH)
|
|
40
44
|
})
|
|
41
45
|
|
|
42
|
-
it('uses mapStyle.
|
|
46
|
+
it('uses mapStyle.activeColor and selectedColor when provided', () => {
|
|
43
47
|
const dataLayers = [{ layerId: 'layer1' }]
|
|
44
|
-
const mapStyle = { id: 'test', selectedColor: '#336699' }
|
|
48
|
+
const mapStyle = { id: 'test', activeColor: '#00ff00', selectedColor: '#336699' }
|
|
45
49
|
const result = buildStylesMap(dataLayers, mapStyle)
|
|
46
|
-
expect(result.layer1.stroke).toBe('#
|
|
47
|
-
expect(result.layer1.
|
|
50
|
+
expect(result.layer1.stroke).toBe('#00ff00')
|
|
51
|
+
expect(result.layer1.selectionStroke).toBe('#336699')
|
|
48
52
|
})
|
|
49
53
|
|
|
50
|
-
it('uses scheme
|
|
54
|
+
it('uses dark scheme defaults when mapColorScheme is dark', () => {
|
|
51
55
|
const dataLayers = [{ layerId: 'layer1' }]
|
|
52
|
-
|
|
53
|
-
expect(
|
|
56
|
+
const result = buildStylesMap(dataLayers, { id: 'dark', mapColorScheme: 'dark' })
|
|
57
|
+
expect(result.layer1.stroke).toBe(THEME_COLORS.dark.activeColor)
|
|
58
|
+
expect(result.layer1.selectionStroke).toBe(THEME_COLORS.dark.selectedColor)
|
|
54
59
|
})
|
|
55
60
|
|
|
56
61
|
it('calls getValueForStyle for stroke and fill with mapStyle.id', () => {
|
|
57
62
|
const dataLayers = [
|
|
58
|
-
{ layerId: 'layer1',
|
|
63
|
+
{ layerId: 'layer1', activeStroke: 'strokeVal', selectedFill: 'fillVal' }
|
|
59
64
|
]
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
buildStylesMap(dataLayers, mapStyle)
|
|
63
|
-
|
|
65
|
+
buildStylesMap(dataLayers, { id: 'mapStyleId' })
|
|
64
66
|
expect(getValueForStyle).toHaveBeenCalledWith('strokeVal', 'mapStyleId')
|
|
65
67
|
expect(getValueForStyle).toHaveBeenCalledWith('fillVal', 'mapStyleId')
|
|
66
|
-
|
|
67
|
-
// Ensure strokeWidth is not passed to getValueForStyle
|
|
68
68
|
const numberCalls = getValueForStyle.mock.calls.filter(call => typeof call[0] === 'number')
|
|
69
69
|
expect(numberCalls).toHaveLength(0)
|
|
70
70
|
})
|
|
@@ -41,20 +41,6 @@ function isContiguousWithAny (feature, features) {
|
|
|
41
41
|
return features.some(f => !booleanDisjoint(toTurfGeometry(f), toTurfGeometry(feature)))
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
* Check if a single polygon/multipolygon feature can be split.
|
|
46
|
-
*
|
|
47
|
-
* @param {Array} features - Array of features
|
|
48
|
-
* @returns {boolean} True if exactly one polygon or multipolygon feature
|
|
49
|
-
*/
|
|
50
|
-
function canSplitFeatures (features) {
|
|
51
|
-
if (features.length !== 1) {
|
|
52
|
-
return false
|
|
53
|
-
}
|
|
54
|
-
const type = features[0].geometry?.type
|
|
55
|
-
return type === 'Polygon' || type === 'MultiPolygon'
|
|
56
|
-
}
|
|
57
|
-
|
|
58
44
|
/**
|
|
59
45
|
* Check if all features form a single contiguous group (can be merged).
|
|
60
46
|
* Uses flood-fill to find connected components.
|
|
@@ -94,6 +80,5 @@ function areAllContiguous (features) {
|
|
|
94
80
|
export {
|
|
95
81
|
toTurfGeometry,
|
|
96
82
|
isContiguousWithAny,
|
|
97
|
-
canSplitFeatures,
|
|
98
83
|
areAllContiguous
|
|
99
84
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toTurfGeometry, isContiguousWithAny,
|
|
1
|
+
import { toTurfGeometry, isContiguousWithAny, areAllContiguous } from './spatial.js'
|
|
2
2
|
import { polygon, multiPolygon, lineString, multiLineString, point, multiPoint } from '@turf/helpers'
|
|
3
3
|
|
|
4
4
|
describe('toTurfGeometry', () => {
|
|
@@ -61,18 +61,6 @@ describe('isContiguousWithAny', () => {
|
|
|
61
61
|
})
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
describe('canSplitFeatures', () => {
|
|
65
|
-
it.each([
|
|
66
|
-
[[{ geometry: { type: 'Polygon' } }], true],
|
|
67
|
-
[[{ geometry: { type: 'MultiPolygon' } }], true],
|
|
68
|
-
[[{ geometry: { type: 'LineString' } }], false],
|
|
69
|
-
[[], false],
|
|
70
|
-
[[{ geometry: { type: 'Polygon' } }, { geometry: { type: 'Polygon' } }], false]
|
|
71
|
-
])('returns expected result for %j', (features, expected) => {
|
|
72
|
-
expect(canSplitFeatures(features)).toBe(expected)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
64
|
describe('areAllContiguous', () => {
|
|
77
65
|
const poly = (coords) => ({ geometry: { type: 'Polygon', coordinates: [coords] } })
|
|
78
66
|
const A = poly([[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.im-c-search-form{display:none;padding:0;min-height:auto;border-radius:0}.im-c-search-form:before{border-radius:0;box-shadow:none}.im-o-app--mobile .im-c-search-form{position:absolute;left:0;top:0;right:0;height:auto;overflow:visible;filter:var(--search-drop-shadow)}.im-o-app--tablet .im-c-search-form,.im-o-app--desktop .im-c-search-form{position:relative;overflow:visible;border-radius:var(--button-border-radius);box-shadow:none;filter:var(--search-drop-shadow)}.im-o-app--tablet .im-c-search-form:before,.im-o-app--desktop .im-c-search-form:before{border-radius:var(--button-border-radius)}.im-o-app--tablet .im-c-search-form .im-c-search-suggestions,.im-o-app--desktop .im-c-search-form .im-c-search-suggestions{position:absolute;top:calc(100% + 1px);left:0;right:0;z-index:1}.im-c-search__status{position:absolute;top:100%;left:0;right:0;padding:var(--divider-gap) calc(var(--divider-gap) + 2px);background-color:var(--background-color);border-top:1px solid var(--button-hover-color);border-bottom-left-radius:var(--button-border-radius);border-bottom-right-radius:var(--button-border-radius)}.im-o-app--mobile .im-c-search-form--default-expanded{position:relative;margin:calc(-1*var(--primary-gap)) calc(-1*var(--primary-gap)) 0}.im-o-app--mobile .im-c-search-form--default-expanded .im-c-search-suggestions{position:absolute;top:100%;width:100%;left:0}.im-c-search-close-button:before{box-shadow:none}.im-c-search-close-button[data-focus-visible=true]{z-index:1}.im-c-search-submit-button:before{box-shadow:none}.im-c-search-submit-button[data-focus-visible=true]{z-index:1}.im-c-search-suggestions{max-height:calc(100vh - 66px);overflow-y:auto;scroll-padding:0;margin:0;padding:0;background-color:var(--background-color);list-style:none}.im-c-search-suggestions__item{margin:0;padding:calc(var(--divider-gap) + 2px) var(--primary-gap);position:relative;color:var(--secondary-text-color);border-top:1px solid var(--button-hover-color);cursor:pointer}.im-c-search-suggestions__item mark{font-weight:bold;color:var(--foreground-color);background-color:rgba(0,0,0,0);pointer-events:none}@media(hover: hover)and (pointer: fine){.im-c-search-suggestions__item:hover:not([aria-selected=true]){background-color:var(--button-hover-color)}}.im-c-search-suggestions__item[aria-selected=true]{background-color:var(--button-hover-color)}.im-c-search-suggestions__item[aria-selected=true] mark{color:var(--fixed-foreground-color)}.im-c-search-suggestions__item:hover:not([aria-selected=true]) .im-c-search-suggestions__label{text-decoration:underline;text-underline-offset:2px;text-decoration-thickness:2px;text-decoration-color:var(--foreground-color);text-decoration-skip-ink:none}.im-c-search-suggestions__item[aria-selected=true] .im-c-search-suggestions__label{outline:3px solid rgba(0,0,0,0);color:var(--focus-border-color);background-color:var(--focus-outline-color);box-shadow:0 -2px var(--focus-outline-color),0 4px var(--focus-border-color);text-decoration:none}.im-c-search-suggestions__label{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.im-o-app--mobile .im-c-search-form--default-expanded .im-c-search-suggestions{box-shadow:var(--panel-box-shadow);clip-path:inset(0px 0px -20px 0px)}.im-o-app--tablet .im-c-search-suggestions,.im-o-app--desktop .im-c-search-suggestions{border-bottom-left-radius:var(--button-border-radius);border-bottom-right-radius:var(--button-border-radius)}.im-o-app--tablet .im-c-search-suggestions__item,.im-o-app--desktop .im-c-search-suggestions__item{padding:var(--divider-gap) calc(var(--divider-gap) + 2px)}:root{--search-drop-shadow: drop-shadow(0 -2px 20px rgba(0,0,0,.1)) drop-shadow(0 0 12px rgba(0,0,0,.1))}.im-c-search__input-container{display:flex;position:relative;flex:1 1 auto;min-height:auto;height:var(--button-size)}.im-c-search__input-container:before{content:"";z-index:1;position:absolute;top:-1px;right:-1px;bottom:-1px;left:-1px;border-radius:var(--button-border-radius);border:2px solid var(--foreground-color);pointer-events:none}.im-c-search__input-container:after{position:absolute;content:"";pointer-events:none;z-index:99;top:-1px;right:-1px;bottom:-1px;left:-1px;border:var(--focus-border-width) solid var(--focus-border-color);outline:var(--focus-outline-width) solid var(--focus-outline-color);border-radius:calc(var(--button-border-radius) - 2px);opacity:0}@media(prefers-reduced-motion: no-preference){.im-c-search__input-container:after{transition:opacity var(--duration) ease}}.im-o-app .im-c-search__input{width:100%;color:var(--foreground-color);background-color:rgba(0,0,0,0);font-size:1rem;border:0;padding:var(--divider-gap) calc(var(--divider-gap) + 2px);outline:0}.im-o-app .im-c-search__input:focus{outline:3px solid rgba(0,0,0,0);box-shadow:none}.im-o-app .im-c-search__input::placeholder{color:var(--foreground-color)}.im-o-app .im-c-search__input::-webkit-search-cancel-button{-webkit-appearance:none;appearance:none;display:none}.im-o-app .im-c-search__input::-moz-search-clear{display:none}.im-c-search__hint{display:none}.im-o-app--exclusive-control .im-o-app__top .im-c-button-wrapper,.im-o-app--exclusive-control .im-o-app__right .im-c-button-wrapper{opacity:0;z-index:-1}.im-o-app--exclusive-control .im-o-app__left-top .im-c-panel,.im-o-app--exclusive-control .im-o-app__left-bottom .im-c-panel,.im-o-app--exclusive-control .im-o-app__right-top .im-c-panel,.im-o-app--exclusive-control .im-o-app__right-bottom .im-c-panel{opacity:0;z-index:-1}.im-o-app--mobile .im-c-search__input-container{margin:var(--primary-gap)}.im-c-search__input-container--keyboard-focus-within:after{opacity:1}
|
|
1
|
+
.im-c-search-form{display:none;padding:0;min-height:auto;border-radius:0}.im-c-search-form:before{border-radius:0;box-shadow:none}.im-o-app--mobile .im-c-search-form{position:absolute;left:0;top:0;right:0;height:auto;overflow:visible;filter:var(--search-drop-shadow)}.im-o-app--tablet .im-c-search-form,.im-o-app--desktop .im-c-search-form{position:relative;overflow:visible;border-radius:var(--button-border-radius);box-shadow:none;filter:var(--search-drop-shadow)}.im-o-app--tablet .im-c-search-form:before,.im-o-app--desktop .im-c-search-form:before{border-radius:var(--button-border-radius)}.im-o-app--tablet .im-c-search-form .im-c-search-suggestions,.im-o-app--desktop .im-c-search-form .im-c-search-suggestions{position:absolute;top:calc(100% + 1px);left:0;right:0;z-index:1}.im-c-search__status{position:absolute;top:100%;left:0;right:0;padding:var(--divider-gap) calc(var(--divider-gap) + 2px);background-color:var(--background-color);border-top:1px solid var(--button-hover-color);border-bottom-left-radius:var(--button-border-radius);border-bottom-right-radius:var(--button-border-radius)}.im-o-app--mobile .im-c-search-form--default-expanded{position:relative;margin:calc(-1*var(--primary-gap)) calc(-1*var(--primary-gap)) 0}.im-o-app--mobile .im-c-search-form--default-expanded .im-c-search-suggestions{position:absolute;top:100%;width:100%;left:0}.im-c-search-open-button{position:relative}.im-c-search-close-button{position:relative}.im-c-search-close-button:before{box-shadow:none}.im-c-search-close-button[data-focus-visible=true]{z-index:1}.im-c-search-submit-button:before{box-shadow:none}.im-c-search-submit-button[data-focus-visible=true]{z-index:1}.im-c-search-suggestions{max-height:calc(100vh - 66px);overflow-y:auto;scroll-padding:0;margin:0;padding:0;background-color:var(--background-color);list-style:none}.im-c-search-suggestions__item{margin:0;padding:calc(var(--divider-gap) + 2px) var(--primary-gap);position:relative;color:var(--secondary-text-color);border-top:1px solid var(--button-hover-color);cursor:pointer}.im-c-search-suggestions__item mark{font-weight:bold;color:var(--foreground-color);background-color:rgba(0,0,0,0);pointer-events:none}@media(hover: hover)and (pointer: fine){.im-c-search-suggestions__item:hover:not([aria-selected=true]){background-color:var(--button-hover-color)}}.im-c-search-suggestions__item[aria-selected=true]{background-color:var(--button-hover-color)}.im-c-search-suggestions__item[aria-selected=true] mark{color:var(--fixed-foreground-color)}.im-c-search-suggestions__item:hover:not([aria-selected=true]) .im-c-search-suggestions__label{text-decoration:underline;text-underline-offset:2px;text-decoration-thickness:2px;text-decoration-color:var(--foreground-color);text-decoration-skip-ink:none}.im-c-search-suggestions__item[aria-selected=true] .im-c-search-suggestions__label{outline:3px solid rgba(0,0,0,0);color:var(--focus-border-color);background-color:var(--focus-outline-color);box-shadow:0 -2px var(--focus-outline-color),0 4px var(--focus-border-color);text-decoration:none}.im-c-search-suggestions__label{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.im-o-app--mobile .im-c-search-form--default-expanded .im-c-search-suggestions{box-shadow:var(--panel-box-shadow);clip-path:inset(0px 0px -20px 0px)}.im-o-app--tablet .im-c-search-suggestions,.im-o-app--desktop .im-c-search-suggestions{border-bottom-left-radius:var(--button-border-radius);border-bottom-right-radius:var(--button-border-radius)}.im-o-app--tablet .im-c-search-suggestions__item,.im-o-app--desktop .im-c-search-suggestions__item{padding:var(--divider-gap) calc(var(--divider-gap) + 2px)}:root{--search-drop-shadow: drop-shadow(0 -2px 20px rgba(0,0,0,.1)) drop-shadow(0 0 12px rgba(0,0,0,.1))}.im-c-search__input-container{display:flex;position:relative;flex:1 1 auto;min-height:auto;height:var(--button-size)}.im-c-search__input-container:before{content:"";z-index:1;position:absolute;top:-1px;right:-1px;bottom:-1px;left:-1px;border-radius:var(--button-border-radius);border:2px solid var(--foreground-color);pointer-events:none}.im-c-search__input-container:after{position:absolute;content:"";pointer-events:none;z-index:99;top:-1px;right:-1px;bottom:-1px;left:-1px;border:var(--focus-border-width) solid var(--focus-border-color);outline:var(--focus-outline-width) solid var(--focus-outline-color);border-radius:calc(var(--button-border-radius) - 2px);opacity:0}@media(prefers-reduced-motion: no-preference){.im-c-search__input-container:after{transition:opacity var(--duration) ease}}.im-o-app .im-c-search__input{width:100%;color:var(--foreground-color);background-color:rgba(0,0,0,0);font-size:1rem;border:0;padding:var(--divider-gap) calc(var(--divider-gap) + 2px);outline:0}.im-o-app .im-c-search__input:focus{outline:3px solid rgba(0,0,0,0);box-shadow:none}.im-o-app .im-c-search__input::placeholder{color:var(--foreground-color)}.im-o-app .im-c-search__input::-webkit-search-cancel-button{-webkit-appearance:none;appearance:none;display:none}.im-o-app .im-c-search__input::-moz-search-clear{display:none}.im-c-search__hint{display:none}.im-o-app--exclusive-control .im-o-app__top .im-c-button-wrapper,.im-o-app--exclusive-control .im-o-app__right .im-c-button-wrapper{opacity:0;z-index:-1}.im-o-app--exclusive-control .im-o-app__left-top .im-c-panel,.im-o-app--exclusive-control .im-o-app__left-bottom .im-c-panel,.im-o-app--exclusive-control .im-o-app__right-top .im-c-panel,.im-o-app--exclusive-control .im-o-app__right-bottom .im-c-panel{opacity:0;z-index:-1}.im-o-app--mobile .im-c-search__input-container{margin:var(--primary-gap)}.im-c-search__input-container--keyboard-focus-within:after{opacity:1}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as e,useRef as t}from"preact/compat";import{jsxs as r,jsx as n}from"preact/jsx-runtime";import a from"@babel/runtime/helpers/defineProperty";import i from"@babel/runtime/helpers/objectWithoutProperties";import o from"@babel/runtime/helpers/taggedTemplateLiteral";import s from"@babel/runtime/helpers/asyncToGenerator";function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var u={TOGGLE_EXPANDED:(e,t)=>c(c({},e),{},{isExpanded:t,areSuggestionsVisible:t,hasFetchedSuggestions:!1}),SET_KEYBOARD_FOCUS_WITHIN:(e,t)=>c(c({},e),{},{hasKeyboardFocusWithin:t,areSuggestionsVisible:!0}),INPUT_BLUR:(e,t)=>c(c({},e),{},{hasKeyboardFocusWithin:!1,areSuggestionsVisible:e.areSuggestionsVisible&&"keyboard"!==t,selectedIndex:-1}),SET_VALUE:(e,t)=>c(c({},e),{},{value:t}),UPDATE_SUGGESTIONS:(e,t)=>c(c({},e),{},{suggestions:t,hasFetchedSuggestions:!0}),SHOW_SUGGESTIONS:e=>c(c({},e),{},{areSuggestionsVisible:!0,hasFetchedSuggestions:!1}),HIDE_SUGGESTIONS:e=>c(c({},e),{},{areSuggestionsVisible:!1,hasFetchedSuggestions:!1}),SET_SELECTED:(e,t)=>c(c({},e),{},{selectedIndex:t,areSuggestionsVisible:t>=0})},d=e=>{var{id:t,isExpanded:a,onClick:i,buttonRef:o,searchIcon:s,showLabel:l}=e;return r("button",{"aria-label":"Open search",className:"im-c-map-button",onClick:i,"aria-controls":"".concat(t,"-search-form"),ref:o,style:a?{display:"none"}:void 0,children:[s&&n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:s}}),l&&n("span",{children:"Search"})]})},h=e=>{var{id:t,pluginState:r,handleSuggestionClick:a}=e;return n("ul",{id:"".concat(t,"-search-suggestions"),role:"listbox","aria-labelledby":"".concat(t,"-search"),className:"im-c-search-suggestions",style:r.areSuggestionsVisible&&r.suggestions.length?void 0:{display:"none"},children:r.suggestions.map((e,i)=>n("li",{id:"".concat(t,"-search-suggestion-").concat(i),className:"im-c-search-suggestions__item",role:"option","aria-selected":r.selectedIndex===i,"aria-setsize":r.suggestions.length,"aria-posinset":i+1,onClick:()=>a(e),children:n("span",{className:"im-c-search-suggestions__label",dangerouslySetInnerHTML:{__html:e.marked}})},e.id))})};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}var f=(e,t,r)=>function(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){a(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}({display:e.expanded||t.isExpanded?"flex":void 0},"mobile"!==r.breakpoint&&(null==e?void 0:e.width)&&{width:e.width}),g=t=>{var{id:a,pluginState:i,pluginConfig:o,appState:s,inputRef:l,events:c,services:u,children:d}=t,{areSuggestionsVisible:p,hasFetchedSuggestions:g,suggestions:m=[]}=i;e(()=>{p&&g&&u.announce((e=>{if(0===e)return"No results available";var t=1===e?"result":"results";return"".concat(e," ").concat(t," available")})(m.length))},[m,g]);var y=["im-c-search-form",o.expanded&&"im-c-search-form--default-expanded","im-c-panel"].filter(Boolean).join(" "),b=p&&g&&!m.length;return r("form",{id:"".concat(a,"-search-form"),role:"search",className:y,style:f(o,i,s),"aria-controls":"".concat(a,"-viewport"),onSubmit:e=>c.handleSubmit(e,s,i),children:[n("button",{type:"submit",style:{display:"none"},"aria-hidden":"true",tabIndex:-1,children:"Submit"}),r("div",{className:"im-c-search__input-container".concat(i.hasKeyboardFocusWithin?" im-c-search__input-container--keyboard-focus-within":""),children:[n("label",{htmlFor:"".concat(a,"-search"),className:"im-u-visually-hidden",children:o.placeholder}),n("input",{id:"".concat(a,"-search"),className:"im-c-search__input",type:"search",role:"combobox","aria-expanded":i.suggestionsVisible,"aria-controls":"".concat(a,"-search-suggestions"),"aria-activedescendant":i.selectedIndex>=0?"".concat(a,"-search-suggestion-").concat(i.selectedIndex):void 0,"aria-describedby":i.value?void 0:"".concat(a,"-search-hint"),"aria-autocomplete":"list",autoComplete:"off",placeholder:o.placeholder,name:"".concat(a,"-search"),spellCheck:!1,enterKeyHint:"search",value:i.value,onClick:c.handleInputClick,onChange:c.handleInputChange,onFocus:()=>c.handleInputFocus(s.interfaceType),onBlur:()=>c.handleInputBlur(s.interfaceType),onKeyDown:e=>c.handleInputKeyDown(e,i),ref:l}),n("span",{id:"".concat(a,"-search-hint"),className:"im-c-search__hint",children:"When search results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."}),d]}),b&&n("div",{className:"im-c-search__status","aria-hidden":"true",children:"No results available"}),n(h,{id:a,appState:s,pluginState:i,handleSuggestionClick:e=>c.handleSuggestionClick(e,s)})]})},m=e=>{var{defaultExpanded:t,onClick:r,closeIcon:a}=e;return n("button",{"aria-label":"Close search",className:"im-c-map-button im-c-search-close-button",type:"button",onClick:r,style:t?{display:"none"}:void 0,children:a&&n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:a}})})},y=e=>{var{defaultExpanded:t,submitIcon:r}=e;return n("button",{"aria-label":"Search",className:"im-c-map-button im-c-search-submit-button",type:"submit",style:t?void 0:{display:"none"},children:r&&n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:r}})})};let b=" ";class w{static get separator(){return b}static set separator(e){b=e}static parse(e){if(!isNaN(parseFloat(e))&&isFinite(e))return Number(e);const t=String(e).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==t[t.length-1]&&t.splice(t.length-1),""==t)return NaN;let r=null;switch(t.length){case 3:r=t[0]/1+t[1]/60+t[2]/3600;break;case 2:r=t[0]/1+t[1]/60;break;case 1:r=t[0];break;default:return NaN}return/^-|[WS]$/i.test(e.trim())&&(r=-r),Number(r)}static toDms(e,t="d",r=void 0){if(isNaN(e))return null;if("string"==typeof e&&""==e.trim())return null;if("boolean"==typeof e)return null;if(e==1/0)return null;if(null==e)return null;if(void 0===r)switch(t){case"d":case"deg":r=4;break;case"dm":case"deg+min":r=2;break;case"dms":case"deg+min+sec":r=0;break;default:t="d",r=4}e=Math.abs(e);let n=null,a=null,i=null,o=null;switch(t){default:case"d":case"deg":a=e.toFixed(r),a<100&&(a="0"+a),a<10&&(a="0"+a),n=a+"°";break;case"dm":case"deg+min":a=Math.floor(e),i=(60*e%60).toFixed(r),60==i&&(i=(0).toFixed(r),a++),a=("000"+a).slice(-3),i<10&&(i="0"+i),n=a+"°"+w.separator+i+"′";break;case"dms":case"deg+min+sec":a=Math.floor(e),i=Math.floor(3600*e/60)%60,o=(3600*e%60).toFixed(r),60==o&&(o=(0).toFixed(r),i++),60==i&&(i=0,a++),a=("000"+a).slice(-3),i=("00"+i).slice(-2),o<10&&(o="0"+o),n=a+"°"+w.separator+i+"′"+w.separator+o+"″"}return n}static toLat(e,t,r){const n=w.toDms(w.wrap90(e),t,r);return null===n?"–":n.slice(1)+w.separator+(e<0?"S":"N")}static toLon(e,t,r){const n=w.toDms(w.wrap180(e),t,r);return null===n?"–":n+w.separator+(e<0?"W":"E")}static toBrng(e,t,r){const n=w.toDms(w.wrap360(e),t,r);return null===n?"–":n.replace("360","0")}static fromLocale(e){const t=123456.789.toLocaleString(),r={thousands:t.slice(3,4),decimal:t.slice(7,8)};return e.replace(r.thousands,"⁜").replace(r.decimal,".").replace("⁜",",")}static toLocale(e){const t=123456.789.toLocaleString(),r={thousands:t.slice(3,4),decimal:t.slice(7,8)};return e.replace(/,([0-9])/,"⁜$1").replace(".",r.decimal).replace("⁜",r.thousands)}static compassPoint(e,t=3){if(![1,2,3].includes(Number(t)))throw new RangeError(`invalid precision ‘${t}’`);e=w.wrap360(e);const r=4*2**(t-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(e*r/360)%r*16/r]}static wrap90(e){if(-90<=e&&e<=90)return e;const t=e,r=360;return 1*Math.abs(((t-90)%r+r)%r-180)-90}static wrap180(e){if(-180<=e&&e<=180)return e;const t=360;return((360*e/t-180)%t+t)%t-180}static wrap360(e){if(0<=e&&e<360)return e;const t=360;return(360*e/t%t+t)%t}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};class E{constructor(e,t,r){if(isNaN(e)||isNaN(t)||isNaN(r))throw new TypeError(`invalid vector [${e},${t},${r}]`);this.x=Number(e),this.y=Number(t),this.z=Number(r)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}plus(e){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");return new E(this.x+e.x,this.y+e.y,this.z+e.z)}minus(e){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");return new E(this.x-e.x,this.y-e.y,this.z-e.z)}times(e){if(isNaN(e))throw new TypeError(`invalid scalar value ‘${e}’`);return new E(this.x*e,this.y*e,this.z*e)}dividedBy(e){if(isNaN(e))throw new TypeError(`invalid scalar value ‘${e}’`);return new E(this.x/e,this.y/e,this.z/e)}dot(e){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");return this.x*e.x+this.y*e.y+this.z*e.z}cross(e){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");const t=this.y*e.z-this.z*e.y,r=this.z*e.x-this.x*e.z,n=this.x*e.y-this.y*e.x;return new E(t,r,n)}negate(){return new E(-this.x,-this.y,-this.z)}unit(){const e=this.length;if(1==e)return this;if(0==e)return this;const t=this.x/e,r=this.y/e,n=this.z/e;return new E(t,r,n)}angleTo(e,t=void 0){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");if(!(t instanceof E||null==t))throw new TypeError("n is not Vector3d object");const r=null==t||this.cross(e).dot(t)>=0?1:-1,n=this.cross(e).length*r,a=this.dot(e);return Math.atan2(n,a)}rotateAround(e,t){if(!(e instanceof E))throw new TypeError("axis is not Vector3d object");const r=t.toRadians(),n=this.unit(),a=e.unit(),i=Math.sin(r),o=Math.cos(r),s=1-o,l=a.x,c=a.y,u=a.z,d=[[s*l*l+o,s*l*c-i*u,s*l*u+i*c],[s*l*c+i*u,s*c*c+o,s*c*u-i*l],[s*l*u-i*c,s*c*u+i*l,s*u*u+o]],h=[d[0][0]*n.x+d[0][1]*n.y+d[0][2]*n.z,d[1][0]*n.x+d[1][1]*n.y+d[1][2]*n.z,d[2][0]*n.x+d[2][1]*n.y+d[2][2]*n.z];return new E(h[0],h[1],h[2])}toString(e=3){return`[${this.x.toFixed(e)},${this.y.toFixed(e)},${this.z.toFixed(e)}]`}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const v={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563}},O={WGS84:{ellipsoid:v.WGS84}};Object.freeze(v.WGS84),Object.freeze(O.WGS84);class S{constructor(e,t,r=0){if(isNaN(e)||null==e)throw new TypeError(`invalid lat ‘${e}’`);if(isNaN(t)||null==t)throw new TypeError(`invalid lon ‘${t}’`);if(isNaN(r)||null==r)throw new TypeError(`invalid height ‘${r}’`);this._lat=w.wrap90(Number(e)),this._lon=w.wrap180(Number(t)),this._height=Number(r)}get lat(){return this._lat}get latitude(){return this._lat}set lat(e){if(this._lat=isNaN(e)?w.wrap90(w.parse(e)):w.wrap90(Number(e)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${e}’`)}set latitude(e){if(this._lat=isNaN(e)?w.wrap90(w.parse(e)):w.wrap90(Number(e)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${e}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(e){if(this._lon=isNaN(e)?w.wrap180(w.parse(e)):w.wrap180(Number(e)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${e}’`)}set lng(e){if(this._lon=isNaN(e)?w.wrap180(w.parse(e)):w.wrap180(Number(e)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${e}’`)}set longitude(e){if(this._lon=isNaN(e)?w.wrap180(w.parse(e)):w.wrap180(Number(e)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${e}’`)}get height(){return this._height}set height(e){if(this._height=Number(e),isNaN(this._height))throw new TypeError(`invalid height ‘${e}’`)}get datum(){return this._datum}set datum(e){this._datum=e}static get ellipsoids(){return v}static get datums(){return O}static parse(...e){if(0==e.length)throw new TypeError("invalid (empty) point");let t,r,n;if("object"==typeof e[0]&&(1==e.length||!isNaN(parseFloat(e[1])))){const a=e[0];if("Point"==a.type&&Array.isArray(a.coordinates)?([r,t,n]=a.coordinates,n=n||0):(null!=a.latitude&&(t=a.latitude),null!=a.lat&&(t=a.lat),null!=a.longitude&&(r=a.longitude),null!=a.lng&&(r=a.lng),null!=a.lon&&(r=a.lon),null!=a.height&&(n=a.height),t=w.wrap90(w.parse(t)),r=w.wrap180(w.parse(r))),null!=e[1]&&(n=e[1]),isNaN(t)||isNaN(r))throw new TypeError(`invalid point ‘${JSON.stringify(e[0])}’`)}if("string"==typeof e[0]&&2==e[0].split(",").length&&([t,r]=e[0].split(","),t=w.wrap90(w.parse(t)),r=w.wrap180(w.parse(r)),n=e[1]||0,isNaN(t)||isNaN(r)))throw new TypeError(`invalid point ‘${e[0]}’`);if(null==t&&null==r&&([t,r]=e,t=w.wrap90(w.parse(t)),r=w.wrap180(w.parse(r)),n=e[2]||0,isNaN(t)||isNaN(r)))throw new TypeError(`invalid point ‘${e.toString()}’`);return new this(t,r,n)}toCartesian(){const e=this.datum?this.datum.ellipsoid:this.referenceFrame?this.referenceFrame.ellipsoid:v.WGS84,t=this.lat.toRadians(),r=this.lon.toRadians(),n=this.height,{a:a,f:i}=e,o=Math.sin(t),s=Math.cos(t),l=Math.sin(r),c=Math.cos(r),u=2*i-i*i,d=a/Math.sqrt(1-u*o*o);return new N((d+n)*s*c,(d+n)*s*l,(d*(1-u)+n)*o)}equals(e){if(!(e instanceof S))throw new TypeError(`invalid point ‘${e}’`);return!(Math.abs(this.lat-e.lat)>Number.EPSILON)&&(!(Math.abs(this.lon-e.lon)>Number.EPSILON)&&(!(Math.abs(this.height-e.height)>Number.EPSILON)&&(this.datum==e.datum&&(this.referenceFrame==e.referenceFrame&&this.epoch==e.epoch))))}toString(e="d",t=void 0,r=null){if(!["d","dm","dms","n"].includes(e))throw new RangeError(`invalid format ‘${e}’`);const n=(this.height>=0?" +":" ")+this.height.toFixed(r)+"m";if("n"==e){null==t&&(t=4);return`${this.lat.toFixed(t)}, ${this.lon.toFixed(t)}${null==r?"":n}`}return`${w.toLat(this.lat,e,t)}, ${w.toLon(this.lon,e,t)}${null==r?"":n}`}}class N extends E{constructor(e,t,r){super(e,t,r)}toLatLon(e=v.WGS84){if(!e||!e.a)throw new TypeError(`invalid ellipsoid ‘${e}’`);const{x:t,y:r,z:n}=this,{a:a,b:i,f:o}=e,s=2*o-o*o,l=s/(1-s),c=Math.sqrt(t*t+r*r),u=i*n/(a*c)*(1+l*i/Math.sqrt(c*c+n*n)),d=u/Math.sqrt(1+u*u),h=d/u,p=isNaN(h)?0:Math.atan2(n+l*i*d*d*d,c-s*a*h*h*h),f=Math.atan2(r,t),g=Math.sin(p),m=c*Math.cos(p)+n*g-a*a/(a/Math.sqrt(1-s*g*g));return new S(p.toDegrees(),f.toDegrees(),m)}toString(e=0){return`[${this.x.toFixed(e)},${this.y.toFixed(e)},${this.z.toFixed(e)}]`}}const T={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563},Airy1830:{a:6377563.396,b:6356256.909,f:1/299.3249646},AiryModified:{a:6377340.189,b:6356034.448,f:1/299.3249646},Bessel1841:{a:6377397.155,b:6356078.962818,f:1/299.1528128},Clarke1866:{a:6378206.4,b:6356583.8,f:1/294.978698214},Clarke1880IGN:{a:6378249.2,b:6356515,f:1/293.466021294},GRS80:{a:6378137,b:6356752.31414,f:1/298.257222101},Intl1924:{a:6378388,b:6356911.946,f:1/297},WGS72:{a:6378135,b:6356750.5,f:1/298.26}},_={ED50:{ellipsoid:T.Intl1924,transform:[89.5,93.8,123.1,-1.2,0,0,.156]},ETRS89:{ellipsoid:T.GRS80,transform:[0,0,0,0,0,0,0]},Irl1975:{ellipsoid:T.AiryModified,transform:[-482.53,130.596,-564.557,-8.15,1.042,.214,.631]},NAD27:{ellipsoid:T.Clarke1866,transform:[8,-160,-176,0,0,0,0]},NAD83:{ellipsoid:T.GRS80,transform:[.9956,-1.9103,-.5215,-62e-5,.025915,.009426,.011599]},NTF:{ellipsoid:T.Clarke1880IGN,transform:[168,60,-320,0,0,0,0]},OSGB36:{ellipsoid:T.Airy1830,transform:[-446.448,125.157,-542.06,20.4894,-.1502,-.247,-.8421]},Potsdam:{ellipsoid:T.Bessel1841,transform:[-582,-105,-414,-8.3,1.04,.35,-3.08]},TokyoJapan:{ellipsoid:T.Bessel1841,transform:[148,-507,-685,0,0,0,0]},WGS72:{ellipsoid:T.WGS72,transform:[0,0,-4.5,-.22,0,0,.554]},WGS84:{ellipsoid:T.WGS84,transform:[0,0,0,0,0,0,0]}};Object.keys(T).forEach(e=>Object.freeze(T[e])),Object.keys(_).forEach(e=>{Object.freeze(_[e]),Object.freeze(_[e].transform)});class x extends S{constructor(e,t,r=0,n=_.WGS84){if(!n||null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(e,t,r),this._datum=n}get datum(){return this._datum}static get ellipsoids(){return T}static get datums(){return _}static parse(...e){let t=_.WGS84;if((4==e.length||3==e.length&&"object"==typeof e[2])&&(t=e.pop()),!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);const r=super.parse(...e);return r._datum=t,r}convertDatum(e){if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);return this.toCartesian().convertDatum(e).toLatLon()}toCartesian(){const e=super.toCartesian();return new D(e.x,e.y,e.z,this.datum)}}class D extends N{constructor(e,t,r,n=void 0){if(n&&null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(e,t,r),n&&(this._datum=n)}get datum(){return this._datum}set datum(e){if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);this._datum=e}toLatLon(e=void 0){e&&(console.info("datum parameter to Cartesian_Datum.toLatLon is deprecated: set datum before calling toLatLon()"),this.datum=e);const t=this.datum||_.WGS84;if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);const r=super.toLatLon(t.ellipsoid);return new x(r.lat,r.lon,r.height,this.datum)}convertDatum(e){if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);if(!this.datum)throw new TypeError("cartesian coordinate has no datum");let t=null,r=null;null!=this.datum&&this.datum!=_.WGS84||(t=this,r=e.transform),e==_.WGS84&&(t=this,r=this.datum.transform.map(e=>-e)),null==r&&(t=this.convertDatum(_.WGS84),r=e.transform);const n=t.applyTransform(r);return n.datum=e,n}applyTransform(e){const{x:t,y:r,z:n}=this,a=e[0],i=e[1],o=e[2],s=e[3]/1e6+1,l=(e[4]/3600).toRadians(),c=(e[5]/3600).toRadians(),u=(e[6]/3600).toRadians();return new D(a+t*s-r*u+n*c,i+t*u+r*s-n*l,o-t*c+r*l+n*s)}}const j={trueOrigin:{lat:49,lon:-2},scaleFactor:.9996012717,ellipsoid:x.ellipsoids.Airy1830};class M{constructor(e,t){if(this.easting=Number(e),this.northing=Number(t),isNaN(e)||this.easting<0||this.easting>7e5)throw new RangeError(`invalid easting ‘${e}’`);if(isNaN(t)||this.northing<0||this.northing>13e5)throw new RangeError(`invalid northing ‘${t}’`)}toLatLon(e=x.datums.WGS84){const{easting:t,northing:r}=this,{a:n,b:a}=j.ellipsoid,i=j.trueOrigin.lat.toRadians(),o=j.trueOrigin.lon.toRadians(),s=-1e5,l=j.scaleFactor,c=1-a*a/(n*n),u=(n-a)/(n+a),d=u*u,h=u*u*u;let p=i,f=0;do{p=(r-s-f)/(n*l)+p;f=a*l*((1+u+5/4*d+5/4*h)*(p-i)-(3*u+3*u*u+21/8*h)*Math.sin(p-i)*Math.cos(p+i)+(15/8*d+15/8*h)*Math.sin(2*(p-i))*Math.cos(2*(p+i))-35/24*h*Math.sin(3*(p-i))*Math.cos(3*(p+i)))}while(Math.abs(r-s-f)>=1e-5);const g=Math.cos(p),m=Math.sin(p),y=n*l/Math.sqrt(1-c*m*m),b=n*l*(1-c)/Math.pow(1-c*m*m,1.5),w=y/b-1,E=Math.tan(p),v=E*E,O=v*v,S=1/g,N=y*y*y,T=N*y*y,_=t-4e5,D=_*_,M=D*_,G=D*D,P=M*D;p=p-E/(2*b*y)*D+E/(24*b*N)*(5+3*v+w-9*v*w)*G-E/(720*b*T)*(61+90*v+45*O)*(G*D);const k=o+S/y*_-S/(6*N)*(y/b+2*v)*M+S/(120*T)*(5+28*v+24*O)*P-S/(5040*(T*y*y))*(61+662*v+1320*O+720*(O*v))*(P*D);let C=new R(p.toDegrees(),k.toDegrees(),0,x.datums.OSGB36);return e!=x.datums.OSGB36&&(C=C.convertDatum(e),C=new R(C.lat,C.lon,C.height,C.datum)),C}static parse(e){let t=(e=String(e).trim()).match(/^(\d+),\s*(\d+)$/);if(t)return new M(t[1],t[2]);if(t=e.match(/^[HNST][ABCDEFGHJKLMNOPQRSTUVWXYZ]\s*[0-9]+\s*[0-9]+$/i),!t)throw new Error(`invalid grid reference ‘${e}’`);let r=e.toUpperCase().charCodeAt(0)-"A".charCodeAt(0),n=e.toUpperCase().charCodeAt(1)-"A".charCodeAt(0);r>7&&r--,n>7&&n--;const a=(r-2)%5*5+n%5,i=19-5*Math.floor(r/5)-Math.floor(n/5);let o=e.slice(2).trim().split(/\s+/);if(1==o.length&&(o=[o[0].slice(0,o[0].length/2),o[0].slice(o[0].length/2)]),o[0].length!=o[1].length)throw new Error(`invalid grid reference ‘${e}’`);o[0]=o[0].padEnd(5,"0"),o[1]=o[1].padEnd(5,"0");const s=a+o[0],l=i+o[1];return new M(s,l)}toString(e=10){if(![0,2,4,6,8,10,12,14,16].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);let{easting:t,northing:r}=this;if(0==e){const e={useGrouping:!1,minimumIntegerDigits:6,maximumFractionDigits:3};return`${t.toLocaleString("en",e)},${r.toLocaleString("en",e)}`}const n=Math.floor(t/1e5),a=Math.floor(r/1e5);let i=19-a-(19-a)%5+Math.floor((n+10)/5),o=5*(19-a)%25+n%5;i>7&&i++,o>7&&o++;const s=String.fromCharCode(i+"A".charCodeAt(0),o+"A".charCodeAt(0));return t=Math.floor(t%1e5/Math.pow(10,5-e/2)),r=Math.floor(r%1e5/Math.pow(10,5-e/2)),t=t.toString().padStart(e/2,"0"),r=r.toString().padStart(e/2,"0"),`${s} ${t} ${r}`}}class R extends x{toOsGrid(){const e=this.datum==x.datums.OSGB36?this:this.convertDatum(x.datums.OSGB36),t=e.lat.toRadians(),r=e.lon.toRadians(),{a:n,b:a}=j.ellipsoid,i=j.trueOrigin.lat.toRadians(),o=j.trueOrigin.lon.toRadians(),s=j.scaleFactor,l=1-a*a/(n*n),c=(n-a)/(n+a),u=c*c,d=c*c*c,h=Math.cos(t),p=Math.sin(t),f=n*s/Math.sqrt(1-l*p*p),g=n*s*(1-l)/Math.pow(1-l*p*p,1.5),m=f/g-1,y=a*s*((1+c+5/4*u+5/4*d)*(t-i)-(3*c+3*c*c+21/8*d)*Math.sin(t-i)*Math.cos(t+i)+(15/8*u+15/8*d)*Math.sin(2*(t-i))*Math.cos(2*(t+i))-35/24*d*Math.sin(3*(t-i))*Math.cos(3*(t+i))),b=h*h*h,w=b*h*h,E=Math.tan(t)*Math.tan(t),v=E*E,O=r-o,S=O*O,N=S*O,T=N*O,_=T*O;let D=y+-1e5+f/2*p*h*S+f/24*p*b*(5-E+9*m)*T+f/720*p*w*(61-58*E+v)*(_*O),R=4e5+f*h*O+f/6*b*(f/g-E)*N+f/120*w*(5-18*E+v+14*m-58*E*m)*_;D=Number(D.toFixed(3)),R=Number(R.toFixed(3));try{return new M(R,D)}catch(t){throw new Error(`${t.message} from (${e.lat.toFixed(6)},${e.lon.toFixed(6)}).toOsGrid()`)}}convertDatum(e){const t=super.convertDatum(e);return new R(t.lat,t.lon,t.height,t.datum)}}var G;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 k(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){a(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}var C=500,L=e=>{var t=e.GAZETTEER_ENTRY,r="eng"===t.NAME2_LANG?t.NAME2:t.NAME1;return e.GAZETTEER_ENTRY.NAME1=r,e.GAZETTEER_ENTRY.NAME1_LANG="eng",e},I=(e,t)=>{var r,n,a,i,{MBR_XMIN:o,MBR_YMIN:s,MBR_XMAX:l,MBR_YMAX:c,GEOMETRY_X:u,GEOMETRY_Y:d}=t;if(null==o?(r=u-C,n=d-C,a=u+C,i=d+C):(r=o,n=s,a=l,i=c),"EPSG:27700"===e)return[r,n,a,i];if("EPSG:4326"===e){var h=new M(r,n).toLatLon(),p=new M(a,i).toLatLon();return[h.lon,h.lat,p.lon,p.lat].map(e=>Math.round(1e6*e)/1e6)}throw new Error("Unsupported CRS: ".concat(e))},A=(e,t)=>{var{GEOMETRY_X:r,GEOMETRY_Y:n}=t;if("EPSG:27700"===e)return[r,n];if("EPSG:4326"===e){var a=new M(r,n).toLatLon();return[Math.round(1e6*a.lon)/1e6,Math.round(1e6*a.lat)/1e6]}throw new Error("Unsupported CRS: ".concat(e))},$=(e,t,r,n)=>{var a;if(!e||e.error||0===(null===(a=e.header)||void 0===a?void 0:a.totalresults))return[];var i=e.results;return i=((e,t)=>{var r=t.toLowerCase().replace(/,/g,"").split(" ");return e.map(L).filter(e=>r.some(r=>{return e.GAZETTEER_ENTRY.NAME1.toLowerCase().includes(r)||(n=(n=t).replace(/\s/g,""),/^(([A-Z]{1,2}\d[A-Z\d]?|ASCN|STHL|TDCU|BBND|[BFS]IQQ|PCRN|TKCA) ?\d[A-Z]{2}|BFPO ?\d{1,4}|(KY\d|MSR|VG|AI)[ -]?\d{4}|[A-Z]{2} ?\d{2}|GE ?CX|GIR ?0A{2}|SAN ?TA1)$/i.test(n));var n}))})(i,t),i=((e,t)=>e.filter(e=>{var r,n=null==e||null===(r=e.GAZETTEER_ENTRY)||void 0===r||null===(r=r.COUNTRY)||void 0===r?void 0:r.toLowerCase();return n&&t.includes(n)}))(i=(e=>Array.from(new Map(e.map(e=>[e.GAZETTEER_ENTRY.ID,e])).values()))(i),r),(i=i.slice(0,8)).map(e=>k(k({id:e.GAZETTEER_ENTRY.ID,bounds:I(n,e.GAZETTEER_ENTRY),point:A(n,e.GAZETTEER_ENTRY)},((e,t)=>{var r,n,a,i,{NAME1:s,COUNTY_UNITARY:l,DISTRICT_BOROUGH:c,POSTCODE_DISTRICT:u,LOCAL_TYPE:d}=t,h="".concat(["City","Postcode"].includes(d)?"":u+", ").concat("City"===d?"":l||c),p="".concat(s).concat(h?", "+h:"");return{text:p,marked:(r=p,n=e,a=n.replace(/\s+/g,"").split("").join(String.raw(G||(G=o(["s*"],["\\s*"])))),i=new RegExp("(".concat(a,")"),"i"),r.replace(i,"<mark>$1</mark>"))}})(t,e.GAZETTEER_ENTRY)),{},{type:"os-names"}))};var F=e=>{var{url:t,options:r}=e;return new Request(t,r)},W=function(){var e=s(function*(e,t,r){var n,a={url:null===(n=e.urlTemplate)||void 0===n?void 0:n.replace("{query}",encodeURIComponent(t)),options:{method:"GET"}};if(e.buildRequest){var i=e.buildRequest(t,()=>a);return i instanceof Request?i:F(i)}return F(r?yield r(a,t):a)});return function(t,r,n){return e.apply(this,arguments)}}(),U=function(){var e=s(function*(e,t,r){try{var n=yield fetch(t);if(!n.ok)return console.error("Fetch error for ".concat(e.label||"dataset",": ").concat(n.status)),null;var a=yield n.json();return e.parseResults(a,r)}catch(t){return console.error("Network error for ".concat(e.label||"dataset",":"),t),null}});return function(t,r,n){return e.apply(this,arguments)}}(),B=function(){var e=s(function*(e,t,r,n){var a=(e=>e.replace(/[^a-zA-Z0-9\s\-.,]/g,"").trim())(e),i=t.filter(t=>{var r=!t.includeRegex||t.includeRegex.test(e),n=!!t.excludeRegex&&t.excludeRegex.test(a);return r&&!n}),o=[];for(var s of i){var l=yield W(s,a,n),c=yield U(s,l,a);if(null!=c&&c.length&&(o=[...o,...c],s.exclusive))break}return r({type:"UPDATE_SUGGESTIONS",payload:o}),{results:o,sanitisedValue:a}});return function(t,r,n,a){return e.apply(this,arguments)}}();function z(e){var{mapProvider:t,bounds:r,point:n,markers:a,showMarker:i,markerOptions:o}=e;t.fitToBounds(r),i&&a.add("search",n,o)}var V=3;function Y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function H(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Y(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}var Z=e=>{var{dispatch:t,services:r,mapProvider:n,markers:i,showMarker:o,markerOptions:s}=e,l=(e,t)=>{var r;return t>=0?"".concat(null===(r=e[t])||void 0===r?void 0:r.text,". ").concat(t+1," of ").concat(e.length," is highlighted"):"".concat(e.length," suggestions available")};return{handleSuggestionClick(e,l){t({type:"SET_VALUE",payload:e.text}),t({type:"HIDE_SUGGESTIONS"}),t({type:"SET_SELECTED",payload:-1}),"mobile"===l.breakpoint&&(t({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close")),z({mapProvider:n,bounds:e.bounds,point:e.point,markers:i,showMarker:o,markerOptions:s}),r.eventBus.emit("search:match",function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?q(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):q(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({query:e.text},e))},handleInputKeyDown(e,n){var{suggestions:a,selectedIndex:i}=n;switch(e.key){case"ArrowDown":if(null==a||!a.length)return;if(e.preventDefault(),i<a.length-1){var o=i+1;r.announce(l(a,o)),t({type:"SET_SELECTED",payload:o}),t({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:!1})}break;case"ArrowUp":if(null==a||!a.length)return;e.preventDefault();var s=i>0?i-1:-1;r.announce(l(a,s)),t({type:"SET_SELECTED",payload:s}),t({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:s<0});break;case"Escape":e.preventDefault(),t({type:"HIDE_SUGGESTIONS"}),t({type:"SET_SELECTED",payload:-1})}}}};function K(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function X(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function J(e){var t,r,n,a,{dispatch:i,searchContainerRef:o}=e,l=(t=t=>B(t,e.datasets,i,e.transformRequest),r=350,n=null,a=function(){for(var e=arguments.length,a=new Array(e),i=0;i<e;i++)a[i]=arguments[i];clearTimeout(n),n=setTimeout(()=>{t(...a)},r)},a.cancel=()=>{n&&(clearTimeout(n),n=null)},a),c=(e=>{var{dispatch:t,services:r,viewportRef:n,mapProvider:a,markers:i,datasets:o,transformRequest:l,showMarker:c,markerOptions:u}=e,d="";return{handleOpenClick(){t({type:"TOGGLE_EXPANDED",payload:!0}),r.eventBus.emit("search:open")},handleCloseClick(e,n){t({type:"TOGGLE_EXPANDED",payload:!1}),t({type:"UPDATE_SUGGESTIONS",payload:[]}),t({type:"SET_VALUE",payload:""}),setTimeout(()=>n.current.focus(),0),i.remove("search"),r.eventBus.emit("search:clear"),r.eventBus.emit("search:close")},handleSubmit:(e,h,p)=>s(function*(){e.preventDefault();var{suggestions:s,selectedIndex:f,value:g}=p,m=null==g?void 0:g.trim();if(t({type:"SET_SELECTED",payload:-1}),t({type:"HIDE_SUGGESTIONS"}),f>=0){var y,b=s[f];return t({type:"SET_VALUE",payload:b.text}),null===(y=n.current)||void 0===y||y.focus(),z({mapProvider:a,bounds:b.bounds,point:b.point,markers:i,showMarker:c,markerOptions:u}),void r.eventBus.emit("search:match",H({query:b.text},b))}if(!((null==m?void 0:m.length)<V)){var w=s;if(!s.length||m!==d){var{results:E,sanitisedValue:v}=yield B(m,o,t,l);w=E,d=v}if(w.length){var O;"keyboard"===h.interfaceType&&(null===(O=n.current)||void 0===O||O.focus()),"mobile"===h.breakpoint&&(t({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close"));var S=w[0];z({mapProvider:a,bounds:S.bounds,point:S.point,markers:i,showMarker:c,markerOptions:u}),r.eventBus.emit("search:match",H({query:g},S))}}})()}})(e),u=(e=>{var{dispatch:t,debouncedFetchSuggestions:r}=e;return{handleInputClick(){t({type:"SHOW_SUGGESTIONS"})},handleInputFocus(e){t({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:"keyboard"===e})},handleInputBlur(e){t({type:"INPUT_BLUR",payload:e})},handleInputChange(e){var n=e.target.value;if(t({type:"SET_VALUE",payload:n}),n.length<V)return r.cancel(),t({type:"UPDATE_SUGGESTIONS",payload:[]}),void t({type:"HIDE_SUGGESTIONS"});t({type:"SHOW_SUGGESTIONS"}),r(n)}}})(X(X({},e),{},{debouncedFetchSuggestions:l})),d=Z(e);return X(X(X(X({},c),u),d),{},{handleOutside(t){o.current.contains(t.target)||(i({type:"TOGGLE_EXPANDED",payload:!1}),e.services.eventBus.emit("search:close"))}})}var Q=["marker"];function ee(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}var te={reducer:{initialState:{isExpanded:!1,hasKeyboardFocusWithin:!1,value:"",suggestions:[],areSuggestionsVisible:!1,hasFetchedSuggestions:!1,selectedIndex:-1},actions:u},controls:[{id:"search",mobile:{slot:"top-right",showLabel:!1},tablet:{slot:"top-left",showLabel:!1},desktop:{slot:"top-left",showLabel:!1},render:function(o){var s,{appConfig:l,iconRegistry:c,pluginState:u,pluginConfig:h,appState:p,mapState:f,services:b,mapProvider:w}=o,{id:E}=l,{interfaceType:v}=p,{expanded:O,customDatasets:S,osNamesURL:N,regions:T}=h,{dispatch:_,isExpanded:x,areSuggestionsVisible:D,suggestions:j}=u,M=(null==p||null===(s=p.controlConfig)||void 0===s||null===(s=s.search)||void 0===s?void 0:s[null==p?void 0:p.breakpoint].showLabel)||!1,R=c.close,G=c.search,P=t(null),k=t(null),C=t(null),L=p.layoutRefs.viewportRef,I=function(e){var{customDatasets:t=[],osNamesURL:r,crs:n,regions:a=["england","scotland","wales"]}=e;return r?[{name:"osNames",urlTemplate:r,parseResults:(e,t)=>$(e,t,a,n),includeRegex:/[a-zA-Z0-9]/,excludeRegex:/^(?:[a-z]{2}\s*(?:\d{3}\s*\d{3}|\d{4}\s*\d{4}|\d{5}\s*\d{5})|\d+\s*,?\s*\d+)$/i},...t]:t}({customDatasets:S,osNamesURL:N,regions:T,crs:w.crs}),A=t(null);if(!A.current){var{marker:F}=h,W=i(h,Q);A.current=J(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ee(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({dispatch:_,datasets:I,services:b,mapProvider:w,viewportRef:L,searchContainerRef:P,markers:f.markers,markerOptions:F},W))}var U=A.current,B=x||!!(O&&D&&j.length);return e(()=>{var e;x&&(null===(e=C.current)||void 0===e||e.focus())},[x]),e(()=>{if(p.dispatch({type:"TOGGLE_HAS_EXCLUSIVE_CONTROL",payload:x}),B)return L.current.style.pointerEvents="none",document.addEventListener("focusin",U.handleOutside),document.addEventListener("pointerdown",U.handleOutside),()=>{L.current.style.pointerEvents="auto",document.removeEventListener("focusin",U.handleOutside),document.removeEventListener("pointerdown",U.handleOutside)}},[x,v,D,j]),r("div",{className:"im-c-search",ref:P,children:[!O&&n(d,{id:E,isExpanded:x,onClick:()=>U.handleOpenClick(p),buttonRef:k,searchIcon:G,showLabel:M}),r(g,{id:E,pluginState:u,pluginConfig:h,appState:p,inputRef:C,events:U,services:b,children:[n(m,{defaultExpanded:O,onClick:e=>U.handleCloseClick(e,k,p),closeIcon:R}),n(y,{defaultExpanded:O,onClick:e=>U.handleCloseClick(e,k,p),submitIcon:G})]})]})}}],icons:[{id:"search",svgContent:'<path d="m21 21-4.34-4.34"></path><circle cx="11" cy="11" r="8"></circle>'}]};export{te as manifest};
|
|
1
|
+
import{useEffect as e,useRef as t}from"preact/compat";import{jsxs as r,jsx as n}from"preact/jsx-runtime";import a from"@babel/runtime/helpers/defineProperty";import i from"@babel/runtime/helpers/objectWithoutProperties";import o from"@babel/runtime/helpers/taggedTemplateLiteral";import s from"@babel/runtime/helpers/asyncToGenerator";function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var u={TOGGLE_EXPANDED:(e,t)=>c(c({},e),{},{isExpanded:t,areSuggestionsVisible:t,hasFetchedSuggestions:!1}),SET_KEYBOARD_FOCUS_WITHIN:(e,t)=>c(c({},e),{},{hasKeyboardFocusWithin:t,areSuggestionsVisible:!0}),INPUT_BLUR:(e,t)=>c(c({},e),{},{hasKeyboardFocusWithin:!1,areSuggestionsVisible:e.areSuggestionsVisible&&"keyboard"!==t,selectedIndex:-1}),SET_VALUE:(e,t)=>c(c({},e),{},{value:t}),UPDATE_SUGGESTIONS:(e,t)=>c(c({},e),{},{suggestions:t,hasFetchedSuggestions:!0}),SHOW_SUGGESTIONS:e=>c(c({},e),{},{areSuggestionsVisible:!0,hasFetchedSuggestions:!1}),HIDE_SUGGESTIONS:e=>c(c({},e),{},{areSuggestionsVisible:!1,hasFetchedSuggestions:!1}),SET_SELECTED:(e,t)=>c(c({},e),{},{selectedIndex:t,areSuggestionsVisible:t>=0})},d=e=>{var{id:t,isExpanded:a,onClick:i,buttonRef:o,searchIcon:s,showLabel:l}=e;return r("button",{"aria-label":"Open search",className:"im-c-map-button im-c-search-open-button",onClick:i,"aria-controls":"".concat(t,"-search-form"),ref:o,style:a?{display:"none"}:void 0,children:[s&&n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:s}}),l&&n("span",{children:"Search"})]})},h=e=>{var{id:t,pluginState:r,handleSuggestionClick:a}=e;return n("ul",{id:"".concat(t,"-search-suggestions"),role:"listbox","aria-labelledby":"".concat(t,"-search"),className:"im-c-search-suggestions",style:r.areSuggestionsVisible&&r.suggestions.length?void 0:{display:"none"},children:r.suggestions.map((e,i)=>n("li",{id:"".concat(t,"-search-suggestion-").concat(i),className:"im-c-search-suggestions__item",role:"option","aria-selected":r.selectedIndex===i,"aria-setsize":r.suggestions.length,"aria-posinset":i+1,onClick:()=>a(e),children:n("span",{className:"im-c-search-suggestions__label",dangerouslySetInnerHTML:{__html:e.marked}})},e.id))})};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}var f=(e,t,r)=>function(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){a(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}({display:e.expanded||t.isExpanded?"flex":void 0},"mobile"!==r.breakpoint&&(null==e?void 0:e.width)&&{width:e.width}),g=t=>{var{id:a,pluginState:i,pluginConfig:o,appState:s,inputRef:l,events:c,services:u,children:d}=t,{areSuggestionsVisible:p,hasFetchedSuggestions:g,suggestions:m=[]}=i;e(()=>{p&&g&&u.announce((e=>{if(0===e)return"No results available";var t=1===e?"result":"results";return"".concat(e," ").concat(t," available")})(m.length))},[m,g]);var y=["im-c-search-form",o.expanded&&"im-c-search-form--default-expanded","im-c-panel"].filter(Boolean).join(" "),b=p&&g&&!m.length;return r("form",{id:"".concat(a,"-search-form"),role:"search",className:y,style:f(o,i,s),"aria-controls":"".concat(a,"-viewport"),onSubmit:e=>c.handleSubmit(e,s,i),children:[n("button",{type:"submit",style:{display:"none"},"aria-hidden":"true",tabIndex:-1,children:"Submit"}),r("div",{className:"im-c-search__input-container".concat(i.hasKeyboardFocusWithin?" im-c-search__input-container--keyboard-focus-within":""),children:[n("label",{htmlFor:"".concat(a,"-search"),className:"im-u-visually-hidden",children:o.placeholder}),n("input",{id:"".concat(a,"-search"),className:"im-c-search__input",type:"search",role:"combobox","aria-expanded":i.suggestionsVisible,"aria-controls":"".concat(a,"-search-suggestions"),"aria-activedescendant":i.selectedIndex>=0?"".concat(a,"-search-suggestion-").concat(i.selectedIndex):void 0,"aria-describedby":i.value?void 0:"".concat(a,"-search-hint"),"aria-autocomplete":"list",autoComplete:"off",placeholder:o.placeholder,name:"".concat(a,"-search"),spellCheck:!1,enterKeyHint:"search",value:i.value,onClick:c.handleInputClick,onChange:c.handleInputChange,onFocus:()=>c.handleInputFocus(s.interfaceType),onBlur:()=>c.handleInputBlur(s.interfaceType),onKeyDown:e=>c.handleInputKeyDown(e,i),ref:l}),n("span",{id:"".concat(a,"-search-hint"),className:"im-c-search__hint",children:"When search results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."}),d]}),b&&n("div",{className:"im-c-search__status","aria-hidden":"true",children:"No results available"}),n(h,{id:a,appState:s,pluginState:i,handleSuggestionClick:e=>c.handleSuggestionClick(e,s)})]})},m=e=>{var{defaultExpanded:t,onClick:r,closeIcon:a}=e;return n("button",{"aria-label":"Close search",className:"im-c-map-button im-c-search-close-button",type:"button",onClick:r,style:t?{display:"none"}:void 0,children:a&&n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:a}})})},y=e=>{var{defaultExpanded:t,submitIcon:r}=e;return n("button",{"aria-label":"Search",className:"im-c-map-button im-c-search-submit-button",type:"submit",style:t?void 0:{display:"none"},children:r&&n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:r}})})};let b=" ";class w{static get separator(){return b}static set separator(e){b=e}static parse(e){if(!isNaN(parseFloat(e))&&isFinite(e))return Number(e);const t=String(e).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==t[t.length-1]&&t.splice(t.length-1),""==t)return NaN;let r=null;switch(t.length){case 3:r=t[0]/1+t[1]/60+t[2]/3600;break;case 2:r=t[0]/1+t[1]/60;break;case 1:r=t[0];break;default:return NaN}return/^-|[WS]$/i.test(e.trim())&&(r=-r),Number(r)}static toDms(e,t="d",r=void 0){if(isNaN(e))return null;if("string"==typeof e&&""==e.trim())return null;if("boolean"==typeof e)return null;if(e==1/0)return null;if(null==e)return null;if(void 0===r)switch(t){case"d":case"deg":r=4;break;case"dm":case"deg+min":r=2;break;case"dms":case"deg+min+sec":r=0;break;default:t="d",r=4}e=Math.abs(e);let n=null,a=null,i=null,o=null;switch(t){default:case"d":case"deg":a=e.toFixed(r),a<100&&(a="0"+a),a<10&&(a="0"+a),n=a+"°";break;case"dm":case"deg+min":a=Math.floor(e),i=(60*e%60).toFixed(r),60==i&&(i=(0).toFixed(r),a++),a=("000"+a).slice(-3),i<10&&(i="0"+i),n=a+"°"+w.separator+i+"′";break;case"dms":case"deg+min+sec":a=Math.floor(e),i=Math.floor(3600*e/60)%60,o=(3600*e%60).toFixed(r),60==o&&(o=(0).toFixed(r),i++),60==i&&(i=0,a++),a=("000"+a).slice(-3),i=("00"+i).slice(-2),o<10&&(o="0"+o),n=a+"°"+w.separator+i+"′"+w.separator+o+"″"}return n}static toLat(e,t,r){const n=w.toDms(w.wrap90(e),t,r);return null===n?"–":n.slice(1)+w.separator+(e<0?"S":"N")}static toLon(e,t,r){const n=w.toDms(w.wrap180(e),t,r);return null===n?"–":n+w.separator+(e<0?"W":"E")}static toBrng(e,t,r){const n=w.toDms(w.wrap360(e),t,r);return null===n?"–":n.replace("360","0")}static fromLocale(e){const t=123456.789.toLocaleString(),r={thousands:t.slice(3,4),decimal:t.slice(7,8)};return e.replace(r.thousands,"⁜").replace(r.decimal,".").replace("⁜",",")}static toLocale(e){const t=123456.789.toLocaleString(),r={thousands:t.slice(3,4),decimal:t.slice(7,8)};return e.replace(/,([0-9])/,"⁜$1").replace(".",r.decimal).replace("⁜",r.thousands)}static compassPoint(e,t=3){if(![1,2,3].includes(Number(t)))throw new RangeError(`invalid precision ‘${t}’`);e=w.wrap360(e);const r=4*2**(t-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(e*r/360)%r*16/r]}static wrap90(e){if(-90<=e&&e<=90)return e;const t=e,r=360;return 1*Math.abs(((t-90)%r+r)%r-180)-90}static wrap180(e){if(-180<=e&&e<=180)return e;const t=360;return((360*e/t-180)%t+t)%t-180}static wrap360(e){if(0<=e&&e<360)return e;const t=360;return(360*e/t%t+t)%t}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};class E{constructor(e,t,r){if(isNaN(e)||isNaN(t)||isNaN(r))throw new TypeError(`invalid vector [${e},${t},${r}]`);this.x=Number(e),this.y=Number(t),this.z=Number(r)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}plus(e){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");return new E(this.x+e.x,this.y+e.y,this.z+e.z)}minus(e){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");return new E(this.x-e.x,this.y-e.y,this.z-e.z)}times(e){if(isNaN(e))throw new TypeError(`invalid scalar value ‘${e}’`);return new E(this.x*e,this.y*e,this.z*e)}dividedBy(e){if(isNaN(e))throw new TypeError(`invalid scalar value ‘${e}’`);return new E(this.x/e,this.y/e,this.z/e)}dot(e){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");return this.x*e.x+this.y*e.y+this.z*e.z}cross(e){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");const t=this.y*e.z-this.z*e.y,r=this.z*e.x-this.x*e.z,n=this.x*e.y-this.y*e.x;return new E(t,r,n)}negate(){return new E(-this.x,-this.y,-this.z)}unit(){const e=this.length;if(1==e)return this;if(0==e)return this;const t=this.x/e,r=this.y/e,n=this.z/e;return new E(t,r,n)}angleTo(e,t=void 0){if(!(e instanceof E))throw new TypeError("v is not Vector3d object");if(!(t instanceof E||null==t))throw new TypeError("n is not Vector3d object");const r=null==t||this.cross(e).dot(t)>=0?1:-1,n=this.cross(e).length*r,a=this.dot(e);return Math.atan2(n,a)}rotateAround(e,t){if(!(e instanceof E))throw new TypeError("axis is not Vector3d object");const r=t.toRadians(),n=this.unit(),a=e.unit(),i=Math.sin(r),o=Math.cos(r),s=1-o,l=a.x,c=a.y,u=a.z,d=[[s*l*l+o,s*l*c-i*u,s*l*u+i*c],[s*l*c+i*u,s*c*c+o,s*c*u-i*l],[s*l*u-i*c,s*c*u+i*l,s*u*u+o]],h=[d[0][0]*n.x+d[0][1]*n.y+d[0][2]*n.z,d[1][0]*n.x+d[1][1]*n.y+d[1][2]*n.z,d[2][0]*n.x+d[2][1]*n.y+d[2][2]*n.z];return new E(h[0],h[1],h[2])}toString(e=3){return`[${this.x.toFixed(e)},${this.y.toFixed(e)},${this.z.toFixed(e)}]`}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const v={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563}},O={WGS84:{ellipsoid:v.WGS84}};Object.freeze(v.WGS84),Object.freeze(O.WGS84);class S{constructor(e,t,r=0){if(isNaN(e)||null==e)throw new TypeError(`invalid lat ‘${e}’`);if(isNaN(t)||null==t)throw new TypeError(`invalid lon ‘${t}’`);if(isNaN(r)||null==r)throw new TypeError(`invalid height ‘${r}’`);this._lat=w.wrap90(Number(e)),this._lon=w.wrap180(Number(t)),this._height=Number(r)}get lat(){return this._lat}get latitude(){return this._lat}set lat(e){if(this._lat=isNaN(e)?w.wrap90(w.parse(e)):w.wrap90(Number(e)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${e}’`)}set latitude(e){if(this._lat=isNaN(e)?w.wrap90(w.parse(e)):w.wrap90(Number(e)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${e}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(e){if(this._lon=isNaN(e)?w.wrap180(w.parse(e)):w.wrap180(Number(e)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${e}’`)}set lng(e){if(this._lon=isNaN(e)?w.wrap180(w.parse(e)):w.wrap180(Number(e)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${e}’`)}set longitude(e){if(this._lon=isNaN(e)?w.wrap180(w.parse(e)):w.wrap180(Number(e)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${e}’`)}get height(){return this._height}set height(e){if(this._height=Number(e),isNaN(this._height))throw new TypeError(`invalid height ‘${e}’`)}get datum(){return this._datum}set datum(e){this._datum=e}static get ellipsoids(){return v}static get datums(){return O}static parse(...e){if(0==e.length)throw new TypeError("invalid (empty) point");let t,r,n;if("object"==typeof e[0]&&(1==e.length||!isNaN(parseFloat(e[1])))){const a=e[0];if("Point"==a.type&&Array.isArray(a.coordinates)?([r,t,n]=a.coordinates,n=n||0):(null!=a.latitude&&(t=a.latitude),null!=a.lat&&(t=a.lat),null!=a.longitude&&(r=a.longitude),null!=a.lng&&(r=a.lng),null!=a.lon&&(r=a.lon),null!=a.height&&(n=a.height),t=w.wrap90(w.parse(t)),r=w.wrap180(w.parse(r))),null!=e[1]&&(n=e[1]),isNaN(t)||isNaN(r))throw new TypeError(`invalid point ‘${JSON.stringify(e[0])}’`)}if("string"==typeof e[0]&&2==e[0].split(",").length&&([t,r]=e[0].split(","),t=w.wrap90(w.parse(t)),r=w.wrap180(w.parse(r)),n=e[1]||0,isNaN(t)||isNaN(r)))throw new TypeError(`invalid point ‘${e[0]}’`);if(null==t&&null==r&&([t,r]=e,t=w.wrap90(w.parse(t)),r=w.wrap180(w.parse(r)),n=e[2]||0,isNaN(t)||isNaN(r)))throw new TypeError(`invalid point ‘${e.toString()}’`);return new this(t,r,n)}toCartesian(){const e=this.datum?this.datum.ellipsoid:this.referenceFrame?this.referenceFrame.ellipsoid:v.WGS84,t=this.lat.toRadians(),r=this.lon.toRadians(),n=this.height,{a:a,f:i}=e,o=Math.sin(t),s=Math.cos(t),l=Math.sin(r),c=Math.cos(r),u=2*i-i*i,d=a/Math.sqrt(1-u*o*o);return new N((d+n)*s*c,(d+n)*s*l,(d*(1-u)+n)*o)}equals(e){if(!(e instanceof S))throw new TypeError(`invalid point ‘${e}’`);return!(Math.abs(this.lat-e.lat)>Number.EPSILON)&&(!(Math.abs(this.lon-e.lon)>Number.EPSILON)&&(!(Math.abs(this.height-e.height)>Number.EPSILON)&&(this.datum==e.datum&&(this.referenceFrame==e.referenceFrame&&this.epoch==e.epoch))))}toString(e="d",t=void 0,r=null){if(!["d","dm","dms","n"].includes(e))throw new RangeError(`invalid format ‘${e}’`);const n=(this.height>=0?" +":" ")+this.height.toFixed(r)+"m";if("n"==e){null==t&&(t=4);return`${this.lat.toFixed(t)}, ${this.lon.toFixed(t)}${null==r?"":n}`}return`${w.toLat(this.lat,e,t)}, ${w.toLon(this.lon,e,t)}${null==r?"":n}`}}class N extends E{constructor(e,t,r){super(e,t,r)}toLatLon(e=v.WGS84){if(!e||!e.a)throw new TypeError(`invalid ellipsoid ‘${e}’`);const{x:t,y:r,z:n}=this,{a:a,b:i,f:o}=e,s=2*o-o*o,l=s/(1-s),c=Math.sqrt(t*t+r*r),u=i*n/(a*c)*(1+l*i/Math.sqrt(c*c+n*n)),d=u/Math.sqrt(1+u*u),h=d/u,p=isNaN(h)?0:Math.atan2(n+l*i*d*d*d,c-s*a*h*h*h),f=Math.atan2(r,t),g=Math.sin(p),m=c*Math.cos(p)+n*g-a*a/(a/Math.sqrt(1-s*g*g));return new S(p.toDegrees(),f.toDegrees(),m)}toString(e=0){return`[${this.x.toFixed(e)},${this.y.toFixed(e)},${this.z.toFixed(e)}]`}}const T={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563},Airy1830:{a:6377563.396,b:6356256.909,f:1/299.3249646},AiryModified:{a:6377340.189,b:6356034.448,f:1/299.3249646},Bessel1841:{a:6377397.155,b:6356078.962818,f:1/299.1528128},Clarke1866:{a:6378206.4,b:6356583.8,f:1/294.978698214},Clarke1880IGN:{a:6378249.2,b:6356515,f:1/293.466021294},GRS80:{a:6378137,b:6356752.31414,f:1/298.257222101},Intl1924:{a:6378388,b:6356911.946,f:1/297},WGS72:{a:6378135,b:6356750.5,f:1/298.26}},_={ED50:{ellipsoid:T.Intl1924,transform:[89.5,93.8,123.1,-1.2,0,0,.156]},ETRS89:{ellipsoid:T.GRS80,transform:[0,0,0,0,0,0,0]},Irl1975:{ellipsoid:T.AiryModified,transform:[-482.53,130.596,-564.557,-8.15,1.042,.214,.631]},NAD27:{ellipsoid:T.Clarke1866,transform:[8,-160,-176,0,0,0,0]},NAD83:{ellipsoid:T.GRS80,transform:[.9956,-1.9103,-.5215,-62e-5,.025915,.009426,.011599]},NTF:{ellipsoid:T.Clarke1880IGN,transform:[168,60,-320,0,0,0,0]},OSGB36:{ellipsoid:T.Airy1830,transform:[-446.448,125.157,-542.06,20.4894,-.1502,-.247,-.8421]},Potsdam:{ellipsoid:T.Bessel1841,transform:[-582,-105,-414,-8.3,1.04,.35,-3.08]},TokyoJapan:{ellipsoid:T.Bessel1841,transform:[148,-507,-685,0,0,0,0]},WGS72:{ellipsoid:T.WGS72,transform:[0,0,-4.5,-.22,0,0,.554]},WGS84:{ellipsoid:T.WGS84,transform:[0,0,0,0,0,0,0]}};Object.keys(T).forEach(e=>Object.freeze(T[e])),Object.keys(_).forEach(e=>{Object.freeze(_[e]),Object.freeze(_[e].transform)});class x extends S{constructor(e,t,r=0,n=_.WGS84){if(!n||null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(e,t,r),this._datum=n}get datum(){return this._datum}static get ellipsoids(){return T}static get datums(){return _}static parse(...e){let t=_.WGS84;if((4==e.length||3==e.length&&"object"==typeof e[2])&&(t=e.pop()),!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);const r=super.parse(...e);return r._datum=t,r}convertDatum(e){if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);return this.toCartesian().convertDatum(e).toLatLon()}toCartesian(){const e=super.toCartesian();return new D(e.x,e.y,e.z,this.datum)}}class D extends N{constructor(e,t,r,n=void 0){if(n&&null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(e,t,r),n&&(this._datum=n)}get datum(){return this._datum}set datum(e){if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);this._datum=e}toLatLon(e=void 0){e&&(console.info("datum parameter to Cartesian_Datum.toLatLon is deprecated: set datum before calling toLatLon()"),this.datum=e);const t=this.datum||_.WGS84;if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);const r=super.toLatLon(t.ellipsoid);return new x(r.lat,r.lon,r.height,this.datum)}convertDatum(e){if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);if(!this.datum)throw new TypeError("cartesian coordinate has no datum");let t=null,r=null;null!=this.datum&&this.datum!=_.WGS84||(t=this,r=e.transform),e==_.WGS84&&(t=this,r=this.datum.transform.map(e=>-e)),null==r&&(t=this.convertDatum(_.WGS84),r=e.transform);const n=t.applyTransform(r);return n.datum=e,n}applyTransform(e){const{x:t,y:r,z:n}=this,a=e[0],i=e[1],o=e[2],s=e[3]/1e6+1,l=(e[4]/3600).toRadians(),c=(e[5]/3600).toRadians(),u=(e[6]/3600).toRadians();return new D(a+t*s-r*u+n*c,i+t*u+r*s-n*l,o-t*c+r*l+n*s)}}const j={trueOrigin:{lat:49,lon:-2},scaleFactor:.9996012717,ellipsoid:x.ellipsoids.Airy1830};class M{constructor(e,t){if(this.easting=Number(e),this.northing=Number(t),isNaN(e)||this.easting<0||this.easting>7e5)throw new RangeError(`invalid easting ‘${e}’`);if(isNaN(t)||this.northing<0||this.northing>13e5)throw new RangeError(`invalid northing ‘${t}’`)}toLatLon(e=x.datums.WGS84){const{easting:t,northing:r}=this,{a:n,b:a}=j.ellipsoid,i=j.trueOrigin.lat.toRadians(),o=j.trueOrigin.lon.toRadians(),s=-1e5,l=j.scaleFactor,c=1-a*a/(n*n),u=(n-a)/(n+a),d=u*u,h=u*u*u;let p=i,f=0;do{p=(r-s-f)/(n*l)+p;f=a*l*((1+u+5/4*d+5/4*h)*(p-i)-(3*u+3*u*u+21/8*h)*Math.sin(p-i)*Math.cos(p+i)+(15/8*d+15/8*h)*Math.sin(2*(p-i))*Math.cos(2*(p+i))-35/24*h*Math.sin(3*(p-i))*Math.cos(3*(p+i)))}while(Math.abs(r-s-f)>=1e-5);const g=Math.cos(p),m=Math.sin(p),y=n*l/Math.sqrt(1-c*m*m),b=n*l*(1-c)/Math.pow(1-c*m*m,1.5),w=y/b-1,E=Math.tan(p),v=E*E,O=v*v,S=1/g,N=y*y*y,T=N*y*y,_=t-4e5,D=_*_,M=D*_,G=D*D,P=M*D;p=p-E/(2*b*y)*D+E/(24*b*N)*(5+3*v+w-9*v*w)*G-E/(720*b*T)*(61+90*v+45*O)*(G*D);const k=o+S/y*_-S/(6*N)*(y/b+2*v)*M+S/(120*T)*(5+28*v+24*O)*P-S/(5040*(T*y*y))*(61+662*v+1320*O+720*(O*v))*(P*D);let C=new R(p.toDegrees(),k.toDegrees(),0,x.datums.OSGB36);return e!=x.datums.OSGB36&&(C=C.convertDatum(e),C=new R(C.lat,C.lon,C.height,C.datum)),C}static parse(e){let t=(e=String(e).trim()).match(/^(\d+),\s*(\d+)$/);if(t)return new M(t[1],t[2]);if(t=e.match(/^[HNST][ABCDEFGHJKLMNOPQRSTUVWXYZ]\s*[0-9]+\s*[0-9]+$/i),!t)throw new Error(`invalid grid reference ‘${e}’`);let r=e.toUpperCase().charCodeAt(0)-"A".charCodeAt(0),n=e.toUpperCase().charCodeAt(1)-"A".charCodeAt(0);r>7&&r--,n>7&&n--;const a=(r-2)%5*5+n%5,i=19-5*Math.floor(r/5)-Math.floor(n/5);let o=e.slice(2).trim().split(/\s+/);if(1==o.length&&(o=[o[0].slice(0,o[0].length/2),o[0].slice(o[0].length/2)]),o[0].length!=o[1].length)throw new Error(`invalid grid reference ‘${e}’`);o[0]=o[0].padEnd(5,"0"),o[1]=o[1].padEnd(5,"0");const s=a+o[0],l=i+o[1];return new M(s,l)}toString(e=10){if(![0,2,4,6,8,10,12,14,16].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);let{easting:t,northing:r}=this;if(0==e){const e={useGrouping:!1,minimumIntegerDigits:6,maximumFractionDigits:3};return`${t.toLocaleString("en",e)},${r.toLocaleString("en",e)}`}const n=Math.floor(t/1e5),a=Math.floor(r/1e5);let i=19-a-(19-a)%5+Math.floor((n+10)/5),o=5*(19-a)%25+n%5;i>7&&i++,o>7&&o++;const s=String.fromCharCode(i+"A".charCodeAt(0),o+"A".charCodeAt(0));return t=Math.floor(t%1e5/Math.pow(10,5-e/2)),r=Math.floor(r%1e5/Math.pow(10,5-e/2)),t=t.toString().padStart(e/2,"0"),r=r.toString().padStart(e/2,"0"),`${s} ${t} ${r}`}}class R extends x{toOsGrid(){const e=this.datum==x.datums.OSGB36?this:this.convertDatum(x.datums.OSGB36),t=e.lat.toRadians(),r=e.lon.toRadians(),{a:n,b:a}=j.ellipsoid,i=j.trueOrigin.lat.toRadians(),o=j.trueOrigin.lon.toRadians(),s=j.scaleFactor,l=1-a*a/(n*n),c=(n-a)/(n+a),u=c*c,d=c*c*c,h=Math.cos(t),p=Math.sin(t),f=n*s/Math.sqrt(1-l*p*p),g=n*s*(1-l)/Math.pow(1-l*p*p,1.5),m=f/g-1,y=a*s*((1+c+5/4*u+5/4*d)*(t-i)-(3*c+3*c*c+21/8*d)*Math.sin(t-i)*Math.cos(t+i)+(15/8*u+15/8*d)*Math.sin(2*(t-i))*Math.cos(2*(t+i))-35/24*d*Math.sin(3*(t-i))*Math.cos(3*(t+i))),b=h*h*h,w=b*h*h,E=Math.tan(t)*Math.tan(t),v=E*E,O=r-o,S=O*O,N=S*O,T=N*O,_=T*O;let D=y+-1e5+f/2*p*h*S+f/24*p*b*(5-E+9*m)*T+f/720*p*w*(61-58*E+v)*(_*O),R=4e5+f*h*O+f/6*b*(f/g-E)*N+f/120*w*(5-18*E+v+14*m-58*E*m)*_;D=Number(D.toFixed(3)),R=Number(R.toFixed(3));try{return new M(R,D)}catch(t){throw new Error(`${t.message} from (${e.lat.toFixed(6)},${e.lon.toFixed(6)}).toOsGrid()`)}}convertDatum(e){const t=super.convertDatum(e);return new R(t.lat,t.lon,t.height,t.datum)}}var G;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 k(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){a(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}var C=500,L=e=>{var t=e.GAZETTEER_ENTRY,r="eng"===t.NAME2_LANG?t.NAME2:t.NAME1;return e.GAZETTEER_ENTRY.NAME1=r,e.GAZETTEER_ENTRY.NAME1_LANG="eng",e},I=(e,t)=>{var r,n,a,i,{MBR_XMIN:o,MBR_YMIN:s,MBR_XMAX:l,MBR_YMAX:c,GEOMETRY_X:u,GEOMETRY_Y:d}=t;if(null==o?(r=u-C,n=d-C,a=u+C,i=d+C):(r=o,n=s,a=l,i=c),"EPSG:27700"===e)return[r,n,a,i];if("EPSG:4326"===e){var h=new M(r,n).toLatLon(),p=new M(a,i).toLatLon();return[h.lon,h.lat,p.lon,p.lat].map(e=>Math.round(1e6*e)/1e6)}throw new Error("Unsupported CRS: ".concat(e))},A=(e,t)=>{var{GEOMETRY_X:r,GEOMETRY_Y:n}=t;if("EPSG:27700"===e)return[r,n];if("EPSG:4326"===e){var a=new M(r,n).toLatLon();return[Math.round(1e6*a.lon)/1e6,Math.round(1e6*a.lat)/1e6]}throw new Error("Unsupported CRS: ".concat(e))},$=(e,t,r,n)=>{var a;if(!e||e.error||0===(null===(a=e.header)||void 0===a?void 0:a.totalresults))return[];var i=e.results;return i=((e,t)=>{var r=t.toLowerCase().replace(/,/g,"").split(" ");return e.map(L).filter(e=>r.some(r=>{return e.GAZETTEER_ENTRY.NAME1.toLowerCase().includes(r)||(n=(n=t).replace(/\s/g,""),/^(([A-Z]{1,2}\d[A-Z\d]?|ASCN|STHL|TDCU|BBND|[BFS]IQQ|PCRN|TKCA) ?\d[A-Z]{2}|BFPO ?\d{1,4}|(KY\d|MSR|VG|AI)[ -]?\d{4}|[A-Z]{2} ?\d{2}|GE ?CX|GIR ?0A{2}|SAN ?TA1)$/i.test(n));var n}))})(i,t),i=((e,t)=>e.filter(e=>{var r,n=null==e||null===(r=e.GAZETTEER_ENTRY)||void 0===r||null===(r=r.COUNTRY)||void 0===r?void 0:r.toLowerCase();return n&&t.includes(n)}))(i=(e=>Array.from(new Map(e.map(e=>[e.GAZETTEER_ENTRY.ID,e])).values()))(i),r),(i=i.slice(0,8)).map(e=>k(k({id:e.GAZETTEER_ENTRY.ID,bounds:I(n,e.GAZETTEER_ENTRY),point:A(n,e.GAZETTEER_ENTRY)},((e,t)=>{var r,n,a,i,{NAME1:s,COUNTY_UNITARY:l,DISTRICT_BOROUGH:c,POSTCODE_DISTRICT:u,LOCAL_TYPE:d}=t,h="".concat(["City","Postcode"].includes(d)?"":u+", ").concat("City"===d?"":l||c),p="".concat(s).concat(h?", "+h:"");return{text:p,marked:(r=p,n=e,a=n.replace(/\s+/g,"").split("").join(String.raw(G||(G=o(["s*"],["\\s*"])))),i=new RegExp("(".concat(a,")"),"i"),r.replace(i,"<mark>$1</mark>"))}})(t,e.GAZETTEER_ENTRY)),{},{type:"os-names"}))};var F=e=>{var{url:t,options:r}=e;return new Request(t,r)},W=function(){var e=s(function*(e,t,r){var n,a={url:null===(n=e.urlTemplate)||void 0===n?void 0:n.replace("{query}",encodeURIComponent(t)),options:{method:"GET"}};if(e.buildRequest){var i=e.buildRequest(t,()=>a);return i instanceof Request?i:F(i)}return F(r?yield r(a,t):a)});return function(t,r,n){return e.apply(this,arguments)}}(),U=function(){var e=s(function*(e,t,r){try{var n=yield fetch(t);if(!n.ok)return console.error("Fetch error for ".concat(e.label||"dataset",": ").concat(n.status)),null;var a=yield n.json();return e.parseResults(a,r)}catch(t){return console.error("Network error for ".concat(e.label||"dataset",":"),t),null}});return function(t,r,n){return e.apply(this,arguments)}}(),B=function(){var e=s(function*(e,t,r,n){var a=(e=>e.replace(/[^a-zA-Z0-9\s\-.,]/g,"").trim())(e),i=t.filter(t=>{var r=!t.includeRegex||t.includeRegex.test(e),n=!!t.excludeRegex&&t.excludeRegex.test(a);return r&&!n}),o=[];for(var s of i){var l=yield W(s,a,n),c=yield U(s,l,a);if(null!=c&&c.length&&(o=[...o,...c],s.exclusive))break}return r({type:"UPDATE_SUGGESTIONS",payload:o}),{results:o,sanitisedValue:a}});return function(t,r,n,a){return e.apply(this,arguments)}}();function z(e){var{mapProvider:t,bounds:r,point:n,markers:a,showMarker:i,markerOptions:o}=e;t.fitToBounds(r),i&&a.add("search",n,o)}var V=3;function Y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function H(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Y(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}var Z=e=>{var{dispatch:t,services:r,mapProvider:n,markers:i,showMarker:o,markerOptions:s}=e,l=(e,t)=>{var r;return t>=0?"".concat(null===(r=e[t])||void 0===r?void 0:r.text,". ").concat(t+1," of ").concat(e.length," is highlighted"):"".concat(e.length," suggestions available")};return{handleSuggestionClick(e,l){t({type:"SET_VALUE",payload:e.text}),t({type:"HIDE_SUGGESTIONS"}),t({type:"SET_SELECTED",payload:-1}),"mobile"===l.breakpoint&&(t({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close")),z({mapProvider:n,bounds:e.bounds,point:e.point,markers:i,showMarker:o,markerOptions:s}),r.eventBus.emit("search:match",function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?q(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):q(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({query:e.text},e))},handleInputKeyDown(e,n){var{suggestions:a,selectedIndex:i}=n;switch(e.key){case"ArrowDown":if(null==a||!a.length)return;if(e.preventDefault(),i<a.length-1){var o=i+1;r.announce(l(a,o)),t({type:"SET_SELECTED",payload:o}),t({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:!1})}break;case"ArrowUp":if(null==a||!a.length)return;e.preventDefault();var s=i>0?i-1:-1;r.announce(l(a,s)),t({type:"SET_SELECTED",payload:s}),t({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:s<0});break;case"Escape":e.preventDefault(),t({type:"HIDE_SUGGESTIONS"}),t({type:"SET_SELECTED",payload:-1})}}}};function K(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function X(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function J(e){var t,r,n,a,{dispatch:i,searchContainerRef:o}=e,l=(t=t=>B(t,e.datasets,i,e.transformRequest),r=350,n=null,a=function(){for(var e=arguments.length,a=new Array(e),i=0;i<e;i++)a[i]=arguments[i];clearTimeout(n),n=setTimeout(()=>{t(...a)},r)},a.cancel=()=>{n&&(clearTimeout(n),n=null)},a),c=(e=>{var{dispatch:t,services:r,viewportRef:n,mapProvider:a,markers:i,datasets:o,transformRequest:l,showMarker:c,markerOptions:u}=e,d="";return{handleOpenClick(){t({type:"TOGGLE_EXPANDED",payload:!0}),r.eventBus.emit("search:open")},handleCloseClick(e,n){t({type:"TOGGLE_EXPANDED",payload:!1}),t({type:"UPDATE_SUGGESTIONS",payload:[]}),t({type:"SET_VALUE",payload:""}),setTimeout(()=>n.current.focus(),0),i.remove("search"),r.eventBus.emit("search:clear"),r.eventBus.emit("search:close")},handleSubmit:(e,h,p)=>s(function*(){e.preventDefault();var{suggestions:s,selectedIndex:f,value:g}=p,m=null==g?void 0:g.trim();if(t({type:"SET_SELECTED",payload:-1}),t({type:"HIDE_SUGGESTIONS"}),f>=0){var y,b=s[f];return t({type:"SET_VALUE",payload:b.text}),null===(y=n.current)||void 0===y||y.focus(),z({mapProvider:a,bounds:b.bounds,point:b.point,markers:i,showMarker:c,markerOptions:u}),void r.eventBus.emit("search:match",H({query:b.text},b))}if(!((null==m?void 0:m.length)<V)){var w=s;if(!s.length||m!==d){var{results:E,sanitisedValue:v}=yield B(m,o,t,l);w=E,d=v}if(w.length){var O;"keyboard"===h.interfaceType&&(null===(O=n.current)||void 0===O||O.focus()),"mobile"===h.breakpoint&&(t({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close"));var S=w[0];z({mapProvider:a,bounds:S.bounds,point:S.point,markers:i,showMarker:c,markerOptions:u}),r.eventBus.emit("search:match",H({query:g},S))}}})()}})(e),u=(e=>{var{dispatch:t,debouncedFetchSuggestions:r}=e;return{handleInputClick(){t({type:"SHOW_SUGGESTIONS"})},handleInputFocus(e){t({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:"keyboard"===e})},handleInputBlur(e){t({type:"INPUT_BLUR",payload:e})},handleInputChange(e){var n=e.target.value;if(t({type:"SET_VALUE",payload:n}),n.length<V)return r.cancel(),t({type:"UPDATE_SUGGESTIONS",payload:[]}),void t({type:"HIDE_SUGGESTIONS"});t({type:"SHOW_SUGGESTIONS"}),r(n)}}})(X(X({},e),{},{debouncedFetchSuggestions:l})),d=Z(e);return X(X(X(X({},c),u),d),{},{handleOutside(t){o.current.contains(t.target)||(i({type:"TOGGLE_EXPANDED",payload:!1}),e.services.eventBus.emit("search:close"))}})}var Q=["marker"];function ee(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}var te={reducer:{initialState:{isExpanded:!1,hasKeyboardFocusWithin:!1,value:"",suggestions:[],areSuggestionsVisible:!1,hasFetchedSuggestions:!1,selectedIndex:-1},actions:u},controls:[{id:"search",mobile:{slot:"top-right",showLabel:!1},tablet:{slot:"top-left",showLabel:!1},desktop:{slot:"top-left",showLabel:!1},render:function(o){var s,{appConfig:l,iconRegistry:c,pluginState:u,pluginConfig:h,appState:p,mapState:f,services:b,mapProvider:w}=o,{id:E}=l,{interfaceType:v}=p,{expanded:O,customDatasets:S,osNamesURL:N,regions:T}=h,{dispatch:_,isExpanded:x,areSuggestionsVisible:D,suggestions:j}=u,M=(null==p||null===(s=p.controlConfig)||void 0===s||null===(s=s.search)||void 0===s?void 0:s[null==p?void 0:p.breakpoint].showLabel)||!1,R=c.close,G=c.search,P=t(null),k=t(null),C=t(null),L=p.layoutRefs.viewportRef,I=function(e){var{customDatasets:t=[],osNamesURL:r,crs:n,regions:a=["england","scotland","wales"]}=e;return r?[{name:"osNames",urlTemplate:r,parseResults:(e,t)=>$(e,t,a,n),includeRegex:/[a-zA-Z0-9]/,excludeRegex:/^(?:[a-z]{2}\s*(?:\d{3}\s*\d{3}|\d{4}\s*\d{4}|\d{5}\s*\d{5})|\d+\s*,?\s*\d+)$/i},...t]:t}({customDatasets:S,osNamesURL:N,regions:T,crs:w.crs}),A=t(null);if(!A.current){var{marker:F}=h,W=i(h,Q);A.current=J(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ee(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({dispatch:_,datasets:I,services:b,mapProvider:w,viewportRef:L,searchContainerRef:P,markers:f.markers,markerOptions:F},W))}var U=A.current,B=x||!!(O&&D&&j.length);return e(()=>{var e;x&&(null===(e=C.current)||void 0===e||e.focus())},[x]),e(()=>{if(p.dispatch({type:"TOGGLE_HAS_EXCLUSIVE_CONTROL",payload:x}),B)return L.current.style.pointerEvents="none",document.addEventListener("focusin",U.handleOutside),document.addEventListener("pointerdown",U.handleOutside),()=>{L.current.style.pointerEvents="auto",document.removeEventListener("focusin",U.handleOutside),document.removeEventListener("pointerdown",U.handleOutside)}},[x,v,D,j]),r("div",{className:"im-c-search",ref:P,children:[!O&&n(d,{id:E,isExpanded:x,onClick:()=>U.handleOpenClick(p),buttonRef:k,searchIcon:G,showLabel:M}),r(g,{id:E,pluginState:u,pluginConfig:h,appState:p,inputRef:C,events:U,services:b,children:[n(m,{defaultExpanded:O,onClick:e=>U.handleCloseClick(e,k,p),closeIcon:R}),n(y,{defaultExpanded:O,onClick:e=>U.handleCloseClick(e,k,p),submitIcon:G})]})]})}}],icons:[{id:"search",svgContent:'<path d="m21 21-4.34-4.34"></path><circle cx="11" cy="11" r="8"></circle>'}]};export{te as manifest};
|