@defra/interactive-map 0.0.23-alpha → 0.0.24-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/assets/images/light-raster-thumb.jpg +0 -0
  2. package/assets/images/outdoor-raster-thumb.jpg +0 -0
  3. package/assets/images/road-raster-thumb.jpg +0 -0
  4. package/docs/plugins/search.md +70 -0
  5. package/package.json +16 -2
  6. package/plugins/beta/draw-ml/dist/css/index.css +1 -21
  7. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  8. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  9. package/plugins/beta/draw-ml/src/api/editFeature.js +9 -4
  10. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +11 -3
  11. package/plugins/interact/src/hooks/useAttachEvents.test.js +3 -0
  12. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  13. package/plugins/search/dist/esm/index.js +1 -1
  14. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  15. package/plugins/search/dist/umd/index.js +1 -1
  16. package/plugins/search/src/Search.jsx +2 -1
  17. package/plugins/search/src/components/Form/Form.jsx +11 -7
  18. package/plugins/search/src/components/Form/Form.test.jsx +23 -1
  19. package/plugins/search/src/datasets.js +2 -2
  20. package/plugins/search/src/datasets.test.js +1 -1
  21. package/plugins/search/src/defaults.js +7 -1
  22. package/plugins/search/src/events/fetchSuggestions.js +13 -10
  23. package/plugins/search/src/events/fetchSuggestions.test.js +14 -1
  24. package/plugins/search/src/events/formHandlers.js +2 -4
  25. package/plugins/search/src/events/formHandlers.test.js +3 -3
  26. package/plugins/search/src/events/inputHandlers.js +1 -1
  27. package/plugins/search/src/events/inputHandlers.test.js +1 -1
  28. package/plugins/search/src/events/suggestionHandlers.js +2 -1
  29. package/plugins/search/src/events/suggestionHandlers.test.js +7 -1
  30. package/plugins/search/src/index.js +3 -7
  31. package/plugins/search/src/reducer.js +10 -5
  32. package/plugins/search/src/reducer.test.js +2 -1
  33. package/plugins/search/src/utils/parseOsNamesResults.js +3 -3
  34. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -0
  35. package/providers/beta/openlayers/dist/esm/index.js +1 -0
  36. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +2 -0
  37. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js.LICENSE.txt +1 -0
  38. package/providers/beta/openlayers/dist/umd/index.js +2 -0
  39. package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +1 -0
  40. package/providers/beta/openlayers/src/appEvents.js +50 -0
  41. package/providers/beta/openlayers/src/appEvents.test.js +140 -0
  42. package/providers/beta/openlayers/src/defaults.js +36 -0
  43. package/providers/beta/openlayers/src/index.js +21 -0
  44. package/providers/beta/openlayers/src/mapEvents.js +132 -0
  45. package/providers/beta/openlayers/src/mapEvents.test.js +197 -0
  46. package/providers/beta/openlayers/src/openlayersProvider.js +234 -0
  47. package/providers/beta/openlayers/src/openlayersProvider.test.js +331 -0
  48. package/providers/beta/openlayers/src/utils/spatial.js +142 -0
  49. package/providers/beta/openlayers/src/utils/spatial.test.js +117 -0
  50. package/providers/beta/openlayers/src/utils/zoom.js +26 -0
  51. package/providers/beta/openlayers/src/utils/zoom.test.js +23 -0
  52. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  53. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  54. package/providers/maplibre/src/utils/highlightFeatures.js +17 -7
  55. package/providers/maplibre/src/utils/highlightFeatures.test.js +17 -0
  56. package/providers/maplibre/src/utils/patternImages.js +14 -9
  57. package/providers/maplibre/src/utils/patternImages.test.js +2 -1
  58. package/rollup.esm.mjs +14 -3
  59. package/src/App/hooks/useFeatureItems.test.js +1 -0
  60. package/src/App/hooks/useLayoutMeasurements.test.js +0 -1
  61. package/src/App/hooks/useMarkersAPI.test.js +1 -0
  62. package/src/App/hooks/useModalPanelBehaviour.test.js +2 -1
  63. package/src/App/store/AppProvider.test.jsx +5 -0
  64. package/src/App/store/MapProvider.test.jsx +8 -1
  65. package/src/services/announcer.test.js +5 -7
  66. package/webpack.dev.mjs +6 -1
  67. package/webpack.umd.mjs +1 -0
@@ -6,19 +6,24 @@ import { getSnapInstance } from '../utils/snapHelpers.js'
6
6
  * @param {string} featureId - ID of the feature to edit
7
7
  * @param {object} options - Options including snapLayers
8
8
  */
9
- export const editFeature = ({ appState, appConfig, mapState, pluginConfig, pluginState, mapProvider }, featureId, options = {}) => {
9
+ export const editFeature = ({ appState, appConfig, mapState, pluginConfig, pluginState, mapProvider, services }, featureId, options = {}) => {
10
10
  const { dispatch } = pluginState
11
11
  const { draw, map } = mapProvider
12
+ const { eventBus } = services
12
13
 
13
14
  if (!draw) {
14
- return
15
+ return false
15
16
  }
16
17
 
17
18
  // Guard: feature must exist in draw before doing anything
18
- if (!draw.get(featureId)) {
19
- return
19
+ const existingFeature = draw.get(featureId)
20
+ if (!existingFeature) {
21
+ return false
20
22
  }
21
23
 
24
+ const editModeMap = { LineString: 'edit_line', Polygon: 'edit_polygon' }
25
+ eventBus.emit('draw:editstart', { mode: editModeMap[existingFeature.geometry.type] })
26
+
22
27
  // Determin snapLayers from pluginConfig or runtime config
23
28
  let snapLayers = null
24
29
  if (options.snapLayers === undefined) {
@@ -110,6 +110,11 @@ export const createDrawMode = (ParentMode, config) => {
110
110
  if (coords.length > 0) {
111
111
  coords[coords.length - 1] = [e.lngLat.lng, e.lngLat.lat]
112
112
  }
113
+ // For polygon: prevent duplicate-coordinate clicks from reaching ParentMode, which
114
+ // would trigger a changeMode chain and cause a runtime error on coords.length access
115
+ if (!finishOnInvalidClick && !validateClick(getFeature(state))) {
116
+ return
117
+ }
113
118
  }
114
119
  const coordsBefore = getCoords(getFeature(state)).length
115
120
  ParentMode.onClick.call(this, state, e)
@@ -154,15 +159,18 @@ export const createDrawMode = (ParentMode, config) => {
154
159
  this._simulateMouse('click', ParentMode.onClick, state)
155
160
  }
156
161
 
157
- // Push undo if a vertex was added
158
- if (getCoords(getFeature(state)).length > coordsBefore) {
162
+ // Push undo and update count if a vertex was added
163
+ const newCoords = getCoords(getFeature(state))
164
+ if (newCoords.length > coordsBefore) {
159
165
  this.pushDrawUndo(state)
166
+ this.dispatchVertexChange(newCoords)
160
167
  }
161
168
  },
162
169
 
163
170
  dispatchVertexChange (coords) {
171
+ // Subtract 1 to exclude the rubber-band vertex that mapbox-gl-draw always appends
164
172
  this.map.fire('draw.vertexchange', {
165
- numVertecies: coords.length
173
+ numVertecies: Math.max(0, coords.length - 1)
166
174
  })
167
175
  },
168
176
 
@@ -54,7 +54,10 @@ describe('useAttachEvents', () => {
54
54
  it('enables click handling after a macrotask', () => {
55
55
  jest.useFakeTimers()
56
56
  renderHook(() => useAttachEvents(props))
57
+ const { clickReadyRef } = attachEvents.mock.calls[0][0]
58
+ expect(clickReadyRef.current).toBe(false)
57
59
  act(() => jest.runAllTimers())
60
+ expect(clickReadyRef.current).toBe(true)
58
61
  jest.useRealTimers()
59
62
  })
60
63
 
@@ -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 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};
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 s from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/taggedTemplateLiteral";import o from"@babel/runtime/helpers/asyncToGenerator";var l={expanded:!1,showMarker:!0,placeholder:"Search",minSearchLength:3,maxSuggestions:8,noResultsMessage:"No results available",searchErrorMessage:"Sorry, there was a problem with search"};function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var h={TOGGLE_EXPANDED:(e,t)=>u(u({},e),{},{isExpanded:t,areSuggestionsVisible:t,hasFetchedSuggestions:!1,hasSearchError:!1}),SET_KEYBOARD_FOCUS_WITHIN:(e,t)=>u(u({},e),{},{hasKeyboardFocusWithin:t,areSuggestionsVisible:!0}),INPUT_BLUR:(e,t)=>u(u({},e),{},{hasKeyboardFocusWithin:!1,areSuggestionsVisible:e.areSuggestionsVisible&&"keyboard"!==t,selectedIndex:-1}),SET_VALUE:(e,t)=>u(u({},e),{},{value:t}),UPDATE_SUGGESTIONS:(e,t)=>u(u({},e),{},{suggestions:t.results,hasFetchedSuggestions:!0,hasSearchError:t.hasError}),SHOW_SUGGESTIONS:e=>u(u({},e),{},{areSuggestionsVisible:!0,hasFetchedSuggestions:!1,hasSearchError:!1}),HIDE_SUGGESTIONS:e=>u(u({},e),{},{areSuggestionsVisible:!1,hasFetchedSuggestions:!1,hasSearchError:!1}),SET_SELECTED:(e,t)=>u(u({},e),{},{selectedIndex:t,areSuggestionsVisible:t>=0})},d=e=>{var{id:t,isExpanded:a,onClick:s,buttonRef:i,searchIcon:o,showLabel:l}=e;return r("button",{"aria-label":"Open search",className:"im-c-map-button im-c-search-open-button",onClick:s,"aria-controls":"".concat(t,"-search-form"),ref:i,style:a?{display:"none"}:void 0,children:[o&&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:o}}),l&&n("span",{children:"Search"})]})},p=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,s)=>n("li",{id:"".concat(t,"-search-suggestion-").concat(s),className:"im-c-search-suggestions__item",role:"option","aria-selected":r.selectedIndex===s,"aria-setsize":r.suggestions.length,"aria-posinset":s+1,onClick:()=>a(e),children:n("span",{className:"im-c-search-suggestions__label",dangerouslySetInnerHTML:{__html:e.marked}})},e.id))})};function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}var f=(e,t,r)=>function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({display:e.expanded||t.isExpanded?"flex":void 0},"mobile"!==r.breakpoint&&(null==e?void 0:e.width)&&{width:e.width}),m=t=>{var{id:a,pluginState:s,pluginConfig:i,appState:o,inputRef:l,events:c,services:u,children:h}=t,{areSuggestionsVisible:d,hasFetchedSuggestions:g,hasSearchError:m,suggestions:y=[]}=s,{noResultsMessage:b,searchErrorMessage:E}=i;e(()=>{d&&g&&u.announce(((e,t,r,n)=>{if(t)return r;if(0===e)return n;var a=1===e?"result":"results";return"".concat(e," ").concat(a," available")})(y.length,m,E,b))},[y,g]);var w=["im-c-search-form",i.expanded&&"im-c-search-form--default-expanded","im-c-panel"].filter(Boolean).join(" "),v=d&&g&&(m||!y.length);return r("form",{id:"".concat(a,"-search-form"),role:"search",className:w,style:f(i,s,o),"aria-controls":"".concat(a,"-viewport"),onSubmit:e=>c.handleSubmit(e,o,s),children:[n("button",{type:"submit",style:{display:"none"},"aria-hidden":"true",tabIndex:-1,children:"Submit"}),r("div",{className:"im-c-search__input-container".concat(s.hasKeyboardFocusWithin?" im-c-search__input-container--keyboard-focus-within":""),children:[n("label",{htmlFor:"".concat(a,"-search"),className:"im-u-visually-hidden",children:i.placeholder}),n("input",{id:"".concat(a,"-search"),className:"im-c-search__input",type:"search",role:"combobox","aria-expanded":s.suggestionsVisible,"aria-controls":"".concat(a,"-search-suggestions"),"aria-activedescendant":s.selectedIndex>=0?"".concat(a,"-search-suggestion-").concat(s.selectedIndex):void 0,"aria-describedby":s.value?void 0:"".concat(a,"-search-hint"),"aria-autocomplete":"list",autoComplete:"off",placeholder:i.placeholder,name:"".concat(a,"-search"),spellCheck:!1,enterKeyHint:"search",value:s.value,onClick:c.handleInputClick,onChange:c.handleInputChange,onFocus:()=>c.handleInputFocus(o.interfaceType),onBlur:()=>c.handleInputBlur(o.interfaceType),onKeyDown:e=>c.handleInputKeyDown(e,s),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."}),h]}),v&&n("div",{className:"im-c-search__status","aria-hidden":"true",children:m?E:b}),n(p,{id:a,appState:o,pluginState:s,handleSuggestionClick:e=>c.handleSuggestionClick(e,o)})]})},y=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}})})},b=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 E=" ";class w{static get separator(){return E}static set separator(e){E=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,s=null,i=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),s=(60*e%60).toFixed(r),60==s&&(s=(0).toFixed(r),a++),a=("000"+a).slice(-3),s<10&&(s="0"+s),n=a+"°"+w.separator+s+"′";break;case"dms":case"deg+min+sec":a=Math.floor(e),s=Math.floor(3600*e/60)%60,i=(3600*e%60).toFixed(r),60==i&&(i=(0).toFixed(r),s++),60==s&&(s=0,a++),a=("000"+a).slice(-3),s=("00"+s).slice(-2),i<10&&(i="0"+i),n=a+"°"+w.separator+s+"′"+w.separator+i+"″"}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 v{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 v))throw new TypeError("v is not Vector3d object");return new v(this.x+e.x,this.y+e.y,this.z+e.z)}minus(e){if(!(e instanceof v))throw new TypeError("v is not Vector3d object");return new v(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 v(this.x*e,this.y*e,this.z*e)}dividedBy(e){if(isNaN(e))throw new TypeError(`invalid scalar value ‘${e}’`);return new v(this.x/e,this.y/e,this.z/e)}dot(e){if(!(e instanceof v))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 v))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 v(t,r,n)}negate(){return new v(-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 v(t,r,n)}angleTo(e,t=void 0){if(!(e instanceof v))throw new TypeError("v is not Vector3d object");if(!(t instanceof v||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 v))throw new TypeError("axis is not Vector3d object");const r=t.toRadians(),n=this.unit(),a=e.unit(),s=Math.sin(r),i=Math.cos(r),o=1-i,l=a.x,c=a.y,u=a.z,h=[[o*l*l+i,o*l*c-s*u,o*l*u+s*c],[o*l*c+s*u,o*c*c+i,o*c*u-s*l],[o*l*u-s*c,o*c*u+s*l,o*u*u+i]],d=[h[0][0]*n.x+h[0][1]*n.y+h[0][2]*n.z,h[1][0]*n.x+h[1][1]*n.y+h[1][2]*n.z,h[2][0]*n.x+h[2][1]*n.y+h[2][2]*n.z];return new v(d[0],d[1],d[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 S={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563}},O={WGS84:{ellipsoid:S.WGS84}};Object.freeze(S.WGS84),Object.freeze(O.WGS84);class N{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 S}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:S.WGS84,t=this.lat.toRadians(),r=this.lon.toRadians(),n=this.height,{a:a,f:s}=e,i=Math.sin(t),o=Math.cos(t),l=Math.sin(r),c=Math.cos(r),u=2*s-s*s,h=a/Math.sqrt(1-u*i*i);return new T((h+n)*o*c,(h+n)*o*l,(h*(1-u)+n)*i)}equals(e){if(!(e instanceof N))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 T extends v{constructor(e,t,r){super(e,t,r)}toLatLon(e=S.WGS84){if(!e||!e.a)throw new TypeError(`invalid ellipsoid ‘${e}’`);const{x:t,y:r,z:n}=this,{a:a,b:s,f:i}=e,o=2*i-i*i,l=o/(1-o),c=Math.sqrt(t*t+r*r),u=s*n/(a*c)*(1+l*s/Math.sqrt(c*c+n*n)),h=u/Math.sqrt(1+u*u),d=h/u,p=isNaN(d)?0:Math.atan2(n+l*s*h*h*h,c-o*a*d*d*d),g=Math.atan2(r,t),f=Math.sin(p),m=c*Math.cos(p)+n*f-a*a/(a/Math.sqrt(1-o*f*f));return new N(p.toDegrees(),g.toDegrees(),m)}toString(e=0){return`[${this.x.toFixed(e)},${this.y.toFixed(e)},${this.z.toFixed(e)}]`}}const _={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}},x={ED50:{ellipsoid:_.Intl1924,transform:[89.5,93.8,123.1,-1.2,0,0,.156]},ETRS89:{ellipsoid:_.GRS80,transform:[0,0,0,0,0,0,0]},Irl1975:{ellipsoid:_.AiryModified,transform:[-482.53,130.596,-564.557,-8.15,1.042,.214,.631]},NAD27:{ellipsoid:_.Clarke1866,transform:[8,-160,-176,0,0,0,0]},NAD83:{ellipsoid:_.GRS80,transform:[.9956,-1.9103,-.5215,-62e-5,.025915,.009426,.011599]},NTF:{ellipsoid:_.Clarke1880IGN,transform:[168,60,-320,0,0,0,0]},OSGB36:{ellipsoid:_.Airy1830,transform:[-446.448,125.157,-542.06,20.4894,-.1502,-.247,-.8421]},Potsdam:{ellipsoid:_.Bessel1841,transform:[-582,-105,-414,-8.3,1.04,.35,-3.08]},TokyoJapan:{ellipsoid:_.Bessel1841,transform:[148,-507,-685,0,0,0,0]},WGS72:{ellipsoid:_.WGS72,transform:[0,0,-4.5,-.22,0,0,.554]},WGS84:{ellipsoid:_.WGS84,transform:[0,0,0,0,0,0,0]}};Object.keys(_).forEach(e=>Object.freeze(_[e])),Object.keys(x).forEach(e=>{Object.freeze(x[e]),Object.freeze(x[e].transform)});class M extends N{constructor(e,t,r=0,n=x.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 _}static get datums(){return x}static parse(...e){let t=x.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 T{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||x.WGS84;if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);const r=super.toLatLon(t.ellipsoid);return new M(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!=x.WGS84||(t=this,r=e.transform),e==x.WGS84&&(t=this,r=this.datum.transform.map(e=>-e)),null==r&&(t=this.convertDatum(x.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],s=e[1],i=e[2],o=e[3]/1e6+1,l=(e[4]/3600).toRadians(),c=(e[5]/3600).toRadians(),u=(e[6]/3600).toRadians();return new D(a+t*o-r*u+n*c,s+t*u+r*o-n*l,i-t*c+r*l+n*o)}}const j={trueOrigin:{lat:49,lon:-2},scaleFactor:.9996012717,ellipsoid:M.ellipsoids.Airy1830};class R{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=M.datums.WGS84){const{easting:t,northing:r}=this,{a:n,b:a}=j.ellipsoid,s=j.trueOrigin.lat.toRadians(),i=j.trueOrigin.lon.toRadians(),o=-1e5,l=j.scaleFactor,c=1-a*a/(n*n),u=(n-a)/(n+a),h=u*u,d=u*u*u;let p=s,g=0;do{p=(r-o-g)/(n*l)+p;g=a*l*((1+u+5/4*h+5/4*d)*(p-s)-(3*u+3*u*u+21/8*d)*Math.sin(p-s)*Math.cos(p+s)+(15/8*h+15/8*d)*Math.sin(2*(p-s))*Math.cos(2*(p+s))-35/24*d*Math.sin(3*(p-s))*Math.cos(3*(p+s)))}while(Math.abs(r-o-g)>=1e-5);const f=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),E=y/b-1,w=Math.tan(p),v=w*w,S=v*v,O=1/f,N=y*y*y,T=N*y*y,_=t-4e5,x=_*_,D=x*_,R=x*x,P=D*x;p=p-w/(2*b*y)*x+w/(24*b*N)*(5+3*v+E-9*v*E)*R-w/(720*b*T)*(61+90*v+45*S)*(R*x);const k=i+O/y*_-O/(6*N)*(y/b+2*v)*D+O/(120*T)*(5+28*v+24*S)*P-O/(5040*(T*y*y))*(61+662*v+1320*S+720*(S*v))*(P*x);let C=new G(p.toDegrees(),k.toDegrees(),0,M.datums.OSGB36);return e!=M.datums.OSGB36&&(C=C.convertDatum(e),C=new G(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 R(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,s=19-5*Math.floor(r/5)-Math.floor(n/5);let i=e.slice(2).trim().split(/\s+/);if(1==i.length&&(i=[i[0].slice(0,i[0].length/2),i[0].slice(i[0].length/2)]),i[0].length!=i[1].length)throw new Error(`invalid grid reference ‘${e}’`);i[0]=i[0].padEnd(5,"0"),i[1]=i[1].padEnd(5,"0");const o=a+i[0],l=s+i[1];return new R(o,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 s=19-a-(19-a)%5+Math.floor((n+10)/5),i=5*(19-a)%25+n%5;s>7&&s++,i>7&&i++;const o=String.fromCharCode(s+"A".charCodeAt(0),i+"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"),`${o} ${t} ${r}`}}class G extends M{toOsGrid(){const e=this.datum==M.datums.OSGB36?this:this.convertDatum(M.datums.OSGB36),t=e.lat.toRadians(),r=e.lon.toRadians(),{a:n,b:a}=j.ellipsoid,s=j.trueOrigin.lat.toRadians(),i=j.trueOrigin.lon.toRadians(),o=j.scaleFactor,l=1-a*a/(n*n),c=(n-a)/(n+a),u=c*c,h=c*c*c,d=Math.cos(t),p=Math.sin(t),g=n*o/Math.sqrt(1-l*p*p),f=n*o*(1-l)/Math.pow(1-l*p*p,1.5),m=g/f-1,y=a*o*((1+c+5/4*u+5/4*h)*(t-s)-(3*c+3*c*c+21/8*h)*Math.sin(t-s)*Math.cos(t+s)+(15/8*u+15/8*h)*Math.sin(2*(t-s))*Math.cos(2*(t+s))-35/24*h*Math.sin(3*(t-s))*Math.cos(3*(t+s))),b=d*d*d,E=b*d*d,w=Math.tan(t)*Math.tan(t),v=w*w,S=r-i,O=S*S,N=O*S,T=N*S,_=T*S;let x=y+-1e5+g/2*p*d*O+g/24*p*b*(5-w+9*m)*T+g/720*p*E*(61-58*w+v)*(_*S),D=4e5+g*d*S+g/6*b*(g/f-w)*N+g/120*E*(5-18*w+v+14*m-58*w*m)*_;x=Number(x.toFixed(3)),D=Number(D.toFixed(3));try{return new R(D,x)}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 G(t.lat,t.lon,t.height,t.datum)}}var P;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 C(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}var L=500,I=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},A=(e,t)=>{var r,n,a,s,{MBR_XMIN:i,MBR_YMIN:o,MBR_XMAX:l,MBR_YMAX:c,GEOMETRY_X:u,GEOMETRY_Y:h}=t;if(null==i?(r=u-L,n=h-L,a=u+L,s=h+L):(r=i,n=o,a=l,s=c),"EPSG:27700"===e)return[r,n,a,s];if("EPSG:4326"===e){var d=new R(r,n).toLatLon(),p=new R(a,s).toLatLon();return[d.lon,d.lat,p.lon,p.lat].map(e=>Math.round(1e6*e)/1e6)}throw new Error("Unsupported CRS: ".concat(e))},$=(e,t)=>{var{GEOMETRY_X:r,GEOMETRY_Y:n}=t;if("EPSG:27700"===e)return[r,n];if("EPSG:4326"===e){var a=new R(r,n).toLatLon();return[Math.round(1e6*a.lon)/1e6,Math.round(1e6*a.lat)/1e6]}throw new Error("Unsupported CRS: ".concat(e))},F=function(e,t,r,n){var a,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:8;if(!e||e.error||0===(null===(a=e.header)||void 0===a?void 0:a.totalresults))return[];var o=e.results;return o=((e,t)=>{var r=t.toLowerCase().replace(/,/g,"").split(" ");return e.map(I).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}))})(o,t),o=((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)}))(o=(e=>Array.from(new Map(e.map(e=>[e.GAZETTEER_ENTRY.ID,e])).values()))(o),r),(o=o.slice(0,s)).map(e=>C(C({id:e.GAZETTEER_ENTRY.ID,bounds:A(n,e.GAZETTEER_ENTRY),point:$(n,e.GAZETTEER_ENTRY)},((e,t)=>{var r,n,a,s,{NAME1:o,COUNTY_UNITARY:l,DISTRICT_BOROUGH:c,POSTCODE_DISTRICT:u,LOCAL_TYPE:h}=t,d="".concat(["City","Postcode"].includes(h)?"":u+", ").concat("City"===h?"":l||c),p="".concat(o).concat(d?", "+d:"");return{text:p,marked:(r=p,n=e,a=n.replace(/\s+/g,"").split("").join(String.raw(P||(P=i(["s*"],["\\s*"])))),s=new RegExp("(".concat(a,")"),"i"),r.replace(s,"<mark>$1</mark>"))}})(t,e.GAZETTEER_ENTRY)),{},{type:"os-names"}))};var W=e=>{var{url:t,options:r}=e;return new Request(t,r)},U=function(){var e=o(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 s=e.buildRequest(t,()=>a);return s instanceof Request?s:W(s)}return W(r?yield r(a,t):a)});return function(t,r,n){return e.apply(this,arguments)}}(),B=function(){var e=o(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)),{error:!0};var a=yield n.json();return e.parseResults(a,r)}catch(t){return console.error("Network error for ".concat(e.label||"dataset",":"),t),{error:!0}}});return function(t,r,n){return e.apply(this,arguments)}}(),z=function(){var e=o(function*(e,t,r,n){var a=(e=>e.replaceAll(/[^a-zA-Z0-9\s\-.,]/g,"").trim())(e),s=t.filter(t=>{var r=!t.includeRegex||t.includeRegex.test(e),n=!!t.excludeRegex&&t.excludeRegex.test(a);return r&&!n}),i=[],o=!1;for(var l of s){var c=yield U(l,a,n),u=yield B(l,c,a);if(null!=u&&u.error?o=!0:null!=u&&u.length&&(i=[...i,...u]),l.exclusive&&i.length)break}return r({type:"UPDATE_SUGGESTIONS",payload:{results:i,hasError:o}}),{results:i,sanitisedValue:a}});return function(t,r,n,a){return e.apply(this,arguments)}}();function V(e){var{mapProvider:t,bounds:r,point:n,markers:a,showMarker:s,markerOptions:i}=e;t.fitToBounds(r),s&&a.add("search",n,i)}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:s,showMarker:i,markerOptions:o,viewportRef:l}=e,c=(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,c){var u;t({type:"SET_VALUE",payload:e.text}),t({type:"HIDE_SUGGESTIONS"}),t({type:"SET_SELECTED",payload:-1}),"mobile"===c.breakpoint&&(t({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close")),null===(u=l.current)||void 0===u||u.focus(),V({mapProvider:n,bounds:e.bounds,point:e.point,markers:s,showMarker:i,markerOptions:o}),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:s}=n;switch(e.key){case"ArrowDown":if(null==a||!a.length)return;if(e.preventDefault(),s<a.length-1){var i=s+1;r.announce(c(a,i)),t({type:"SET_SELECTED",payload:i}),t({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:!1})}break;case"ArrowUp":if(null==a||!a.length)return;e.preventDefault();var o=s>0?s-1:-1;r.announce(c(a,o)),t({type:"SET_SELECTED",payload:o}),t({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:o<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:s,searchContainerRef:i}=e,c=(t=t=>z(t,e.datasets,s,e.transformRequest),r=350,n=null,a=function(){for(var e=arguments.length,a=new Array(e),s=0;s<e;s++)a[s]=arguments[s];clearTimeout(n),n=setTimeout(()=>{t(...a)},r)},a.cancel=()=>{n&&(clearTimeout(n),n=null)},a),u=(e=>{var{dispatch:t,services:r,viewportRef:n,mapProvider:a,markers:s,datasets:i,transformRequest:c,showMarker:u,markerOptions:h}=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:{results:[],hasError:!1}}),t({type:"SET_VALUE",payload:""}),setTimeout(()=>n.current.focus(),0),s.remove("search"),r.eventBus.emit("search:clear"),r.eventBus.emit("search:close")},handleSubmit:(e,p,g)=>o(function*(){e.preventDefault();var{suggestions:o,selectedIndex:f,value:m}=g,y=null==m?void 0:m.trim();if(t({type:"SET_SELECTED",payload:-1}),t({type:"HIDE_SUGGESTIONS"}),f>=0){var b,E=o[f];return t({type:"SET_VALUE",payload:E.text}),null===(b=n.current)||void 0===b||b.focus(),V({mapProvider:a,bounds:E.bounds,point:E.point,markers:s,showMarker:u,markerOptions:h}),void r.eventBus.emit("search:match",H({query:E.text},E))}if(!((null==y?void 0:y.length)<l.minSearchLength)){var w=o;if(!o.length||y!==d){var{results:v,sanitisedValue:S}=yield z(y,i,t,c);w=v,d=S}if(w.length){var O;null===(O=n.current)||void 0===O||O.focus(),"mobile"===p.breakpoint&&(t({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close"));var N=w[0];V({mapProvider:a,bounds:N.bounds,point:N.point,markers:s,showMarker:u,markerOptions:h}),r.eventBus.emit("search:match",H({query:m},N))}}})()}})(e),h=(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<l.minSearchLength)return r.cancel(),t({type:"UPDATE_SUGGESTIONS",payload:{results:[],hasError:!1}}),void t({type:"HIDE_SUGGESTIONS"});t({type:"SHOW_SUGGESTIONS"}),r(n)}}})(X(X({},e),{},{debouncedFetchSuggestions:c})),d=Z(e);return X(X(X(X({},u),h),d),{},{handleOutside(t){i.current.contains(t.target)||(s({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,hasSearchError:!1,selectedIndex:-1},actions:h},controls:[{id:"search",mobile:{slot:"top-right",showLabel:!1},tablet:{slot:"top-left",showLabel:!1},desktop:{slot:"top-left",showLabel:!1},render:function(i){var o,{appConfig:l,iconRegistry:c,pluginState:u,pluginConfig:h,appState:p,mapState:g,services:f,mapProvider:E}=i,{id:w}=l,{interfaceType:v}=p,{expanded:S,customDatasets:O,osNamesURL:N,regions:T,maxSuggestions:_}=h,{dispatch:x,isExpanded:M,areSuggestionsVisible:D,suggestions:j}=u,R=(null==p||null===(o=p.controlConfig)||void 0===o||null===(o=o.search)||void 0===o?void 0:o[null==p?void 0:p.breakpoint].showLabel)||!1,G=c.close,P=c.search,k=t(null),C=t(null),L=t(null),I=p.layoutRefs.viewportRef,A=function(e){var{customDatasets:t=[],osNamesURL:r,crs:n,regions:a=["england","scotland","wales"],maxSuggestions:s}=e;return r?[{name:"osNames",urlTemplate:r,parseResults:(e,t)=>F(e,t,a,n,s),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:O,osNamesURL:N,regions:T,maxSuggestions:_,crs:E.crs}),$=t(null);if(!$.current){var{marker:W}=h,U=s(h,Q);$.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:x,datasets:A,services:f,mapProvider:E,viewportRef:I,searchContainerRef:k,markers:g.markers,markerOptions:W},U))}var B=$.current,z=M||!!(S&&D&&j.length);return e(()=>{var e;M&&(null===(e=L.current)||void 0===e||e.focus())},[M]),e(()=>{if(p.dispatch({type:"TOGGLE_HAS_EXCLUSIVE_CONTROL",payload:M}),z)return I.current.style.pointerEvents="none",document.addEventListener("focusin",B.handleOutside),document.addEventListener("pointerdown",B.handleOutside),()=>{I.current.style.pointerEvents="auto",document.removeEventListener("focusin",B.handleOutside),document.removeEventListener("pointerdown",B.handleOutside)}},[M,v,D,j]),r("div",{className:"im-c-search",ref:k,children:[!S&&n(d,{id:w,isExpanded:M,onClick:()=>B.handleOpenClick(p),buttonRef:C,searchIcon:P,showLabel:R}),r(m,{id:w,pluginState:u,pluginConfig:h,appState:p,inputRef:L,events:B,services:f,children:[n(y,{defaultExpanded:S,onClick:e=>B.handleCloseClick(e,C,p),closeIcon:G}),n(b,{defaultExpanded:S,onClick:e=>B.handleCloseClick(e,C,p),submitIcon:P})]})]})}}],icons:[{id:"search",svgContent:'<path d="m21 21-4.34-4.34"></path><circle cx="11" cy="11" r="8"></circle>'}]},re=Object.freeze({__proto__:null,manifest:te});export{l as D,re as m};
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/defineProperty";function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){r(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))})}return e}function o(){var r,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t.expanded&&(t.manifest={controls:[{id:"search",mobile:{slot:"banner"}}]}),n(n({showMarker:!0,placeholder:"Search"},t),{},{id:"search",load:(r=e(function*(){return(yield import(/* webpackChunkName: "im-search-plugin" */ "./im-search-plugin.js")).manifest}),function(){return r.apply(this,arguments)})})}export{o as default};
1
+ import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/defineProperty";import{D as t}from"./im-search-plugin.js";import"preact/compat";import"preact/jsx-runtime";import"@babel/runtime/helpers/objectWithoutProperties";import"@babel/runtime/helpers/taggedTemplateLiteral";function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach(function(t){r(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))})}return e}function i(){var r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return o(o(o(o({},t),n),n.expanded&&{manifest:{controls:[{id:"search",mobile:{slot:"banner"}}]}}),{},{id:"search",load:(r=e(function*(){return(yield import(/* webpackChunkName: "im-search-plugin" */ "./im-search-plugin.js").then(function(e){return e.m})).manifest}),function(){return r.apply(this,arguments)})})}export{i as default};
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see im-search-plugin.js.LICENSE.txt */
2
- "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[254],{335(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){a(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function a(t,e,r){return(e=function(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.r(e),r.d(e,{manifest:()=>Nt});var s={TOGGLE_EXPANDED:function(t,e){return i(i({},t),{},{isExpanded:e,areSuggestionsVisible:e,hasFetchedSuggestions:!1})},SET_KEYBOARD_FOCUS_WITHIN:function(t,e){return i(i({},t),{},{hasKeyboardFocusWithin:e,areSuggestionsVisible:!0})},INPUT_BLUR:function(t,e){return i(i({},t),{},{hasKeyboardFocusWithin:!1,areSuggestionsVisible:t.areSuggestionsVisible&&"keyboard"!==e,selectedIndex:-1})},SET_VALUE:function(t,e){return i(i({},t),{},{value:e})},UPDATE_SUGGESTIONS:function(t,e){return i(i({},t),{},{suggestions:e,hasFetchedSuggestions:!0})},SHOW_SUGGESTIONS:function(t){return i(i({},t),{},{areSuggestionsVisible:!0,hasFetchedSuggestions:!1})},HIDE_SUGGESTIONS:function(t){return i(i({},t),{},{areSuggestionsVisible:!1,hasFetchedSuggestions:!1})},SET_SELECTED:function(t,e){return i(i({},t),{},{selectedIndex:e,areSuggestionsVisible:e>=0})}},u=r(738),c=r(287),l=function(t){var e=t.id,r=t.isExpanded,n=t.onClick,o=t.buttonRef,i=t.searchIcon,a=t.showLabel;return(0,c.jsxs)("button",{"aria-label":"Open search",className:"im-c-map-button im-c-search-open-button",onClick:n,"aria-controls":"".concat(e,"-search-form"),ref:o,style:r?{display:"none"}:void 0,children:[i&&(0,c.jsx)("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:i}}),a&&(0,c.jsx)("span",{children:"Search"})]})},f=function(t){var e=t.id,r=t.pluginState,n=t.handleSuggestionClick;return(0,c.jsx)("ul",{id:"".concat(e,"-search-suggestions"),role:"listbox","aria-labelledby":"".concat(e,"-search"),className:"im-c-search-suggestions",style:r.areSuggestionsVisible&&r.suggestions.length?void 0:{display:"none"},children:r.suggestions.map(function(t,o){return(0,c.jsx)("li",{id:"".concat(e,"-search-suggestion-").concat(o),className:"im-c-search-suggestions__item",role:"option","aria-selected":r.selectedIndex===o,"aria-setsize":r.suggestions.length,"aria-posinset":o+1,onClick:function(){return n(t)},children:(0,c.jsx)("span",{className:"im-c-search-suggestions__label",dangerouslySetInnerHTML:{__html:t.marked}})},t.id)})})};function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function d(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function h(t,e,r){return(e=function(t){var e=function(t){if("object"!=p(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==p(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var y=function(t,e,r){return function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?d(Object(r),!0).forEach(function(e){h(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({display:t.expanded||e.isExpanded?"flex":void 0},"mobile"!==r.breakpoint&&(null==t?void 0:t.width)&&{width:t.width})},m=function(t){var e=t.id,r=t.pluginState,n=t.pluginConfig,o=t.appState,i=t.inputRef,a=t.events,s=t.services,l=t.children,p=r.areSuggestionsVisible,d=r.hasFetchedSuggestions,h=r.suggestions,m=void 0===h?[]:h;(0,u.useEffect)(function(){p&&d&&s.announce(function(t){if(0===t)return"No results available";var e=1===t?"result":"results";return"".concat(t," ").concat(e," available")}(m.length))},[m,d]);var b=["im-c-search-form",n.expanded&&"im-c-search-form--default-expanded","im-c-panel"].filter(Boolean).join(" "),g=p&&d&&!m.length;return(0,c.jsxs)("form",{id:"".concat(e,"-search-form"),role:"search",className:b,style:y(n,r,o),"aria-controls":"".concat(e,"-viewport"),onSubmit:function(t){return a.handleSubmit(t,o,r)},children:[(0,c.jsx)("button",{type:"submit",style:{display:"none"},"aria-hidden":"true",tabIndex:-1,children:"Submit"}),(0,c.jsxs)("div",{className:"im-c-search__input-container".concat(r.hasKeyboardFocusWithin?" im-c-search__input-container--keyboard-focus-within":""),children:[(0,c.jsx)("label",{htmlFor:"".concat(e,"-search"),className:"im-u-visually-hidden",children:n.placeholder}),(0,c.jsx)("input",{id:"".concat(e,"-search"),className:"im-c-search__input",type:"search",role:"combobox","aria-expanded":r.suggestionsVisible,"aria-controls":"".concat(e,"-search-suggestions"),"aria-activedescendant":r.selectedIndex>=0?"".concat(e,"-search-suggestion-").concat(r.selectedIndex):void 0,"aria-describedby":r.value?void 0:"".concat(e,"-search-hint"),"aria-autocomplete":"list",autoComplete:"off",placeholder:n.placeholder,name:"".concat(e,"-search"),spellCheck:!1,enterKeyHint:"search",value:r.value,onClick:a.handleInputClick,onChange:a.handleInputChange,onFocus:function(){return a.handleInputFocus(o.interfaceType)},onBlur:function(){return a.handleInputBlur(o.interfaceType)},onKeyDown:function(t){return a.handleInputKeyDown(t,r)},ref:i}),(0,c.jsx)("span",{id:"".concat(e,"-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."}),l]}),g&&(0,c.jsx)("div",{className:"im-c-search__status","aria-hidden":"true",children:"No results available"}),(0,c.jsx)(f,{id:e,appState:o,pluginState:r,handleSuggestionClick:function(t){return a.handleSuggestionClick(t,o)}})]})},b=function(t){var e=t.defaultExpanded,r=t.onClick,n=t.closeIcon;return(0,c.jsx)("button",{"aria-label":"Close search",className:"im-c-map-button im-c-search-close-button",type:"button",onClick:r,style:e?{display:"none"}:void 0,children:n&&(0,c.jsx)("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:n}})})},g=function(t){var e=t.defaultExpanded,r=t.submitIcon;return(0,c.jsx)("button",{"aria-label":"Search",className:"im-c-map-button im-c-search-submit-button",type:"submit",style:e?void 0:{display:"none"},children:r&&(0,c.jsx)("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 v=" ";class w{static get separator(){return v}static set separator(t){v=t}static parse(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Number(t);const e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;let r=null;switch(e.length){case 3:r=e[0]/1+e[1]/60+e[2]/3600;break;case 2:r=e[0]/1+e[1]/60;break;case 1:r=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(r=-r),Number(r)}static toDms(t,e="d",r=void 0){if(isNaN(t))return null;if("string"==typeof t&&""==t.trim())return null;if("boolean"==typeof t)return null;if(t==1/0)return null;if(null==t)return null;if(void 0===r)switch(e){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:e="d",r=4}t=Math.abs(t);let n=null,o=null,i=null,a=null;switch(e){default:case"d":case"deg":o=t.toFixed(r),o<100&&(o="0"+o),o<10&&(o="0"+o),n=o+"°";break;case"dm":case"deg+min":o=Math.floor(t),i=(60*t%60).toFixed(r),60==i&&(i=(0).toFixed(r),o++),o=("000"+o).slice(-3),i<10&&(i="0"+i),n=o+"°"+w.separator+i+"′";break;case"dms":case"deg+min+sec":o=Math.floor(t),i=Math.floor(3600*t/60)%60,a=(3600*t%60).toFixed(r),60==a&&(a=(0).toFixed(r),i++),60==i&&(i=0,o++),o=("000"+o).slice(-3),i=("00"+i).slice(-2),a<10&&(a="0"+a),n=o+"°"+w.separator+i+"′"+w.separator+a+"″"}return n}static toLat(t,e,r){const n=w.toDms(w.wrap90(t),e,r);return null===n?"–":n.slice(1)+w.separator+(t<0?"S":"N")}static toLon(t,e,r){const n=w.toDms(w.wrap180(t),e,r);return null===n?"–":n+w.separator+(t<0?"W":"E")}static toBrng(t,e,r){const n=w.toDms(w.wrap360(t),e,r);return null===n?"–":n.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(r.thousands,"⁜").replace(r.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",r.decimal).replace("⁜",r.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=w.wrap360(t);const r=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*r/360)%r*16/r]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t;return 1*Math.abs(((e-90)%360+360)%360-180)-90}static wrap180(t){if(-180<=t&&t<=180)return t;const e=360;return((360*t/e-180)%e+e)%e-180}static wrap360(t){if(0<=t&&t<360)return t;const e=360;return(360*t/e%e+e)%e}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const S=w;class E{constructor(t,e,r){if(isNaN(t)||isNaN(e)||isNaN(r))throw new TypeError(`invalid vector [${t},${e},${r}]`);this.x=Number(t),this.y=Number(e),this.z=Number(r)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}plus(t){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");return new E(this.x+t.x,this.y+t.y,this.z+t.z)}minus(t){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");return new E(this.x-t.x,this.y-t.y,this.z-t.z)}times(t){if(isNaN(t))throw new TypeError(`invalid scalar value ‘${t}’`);return new E(this.x*t,this.y*t,this.z*t)}dividedBy(t){if(isNaN(t))throw new TypeError(`invalid scalar value ‘${t}’`);return new E(this.x/t,this.y/t,this.z/t)}dot(t){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");return this.x*t.x+this.y*t.y+this.z*t.z}cross(t){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");const e=this.y*t.z-this.z*t.y,r=this.z*t.x-this.x*t.z,n=this.x*t.y-this.y*t.x;return new E(e,r,n)}negate(){return new E(-this.x,-this.y,-this.z)}unit(){const t=this.length;if(1==t)return this;if(0==t)return this;const e=this.x/t,r=this.y/t,n=this.z/t;return new E(e,r,n)}angleTo(t,e=void 0){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");if(!(e instanceof E||null==e))throw new TypeError("n is not Vector3d object");const r=null==e||this.cross(t).dot(e)>=0?1:-1,n=this.cross(t).length*r,o=this.dot(t);return Math.atan2(n,o)}rotateAround(t,e){if(!(t instanceof E))throw new TypeError("axis is not Vector3d object");const r=e.toRadians(),n=this.unit(),o=t.unit(),i=Math.sin(r),a=Math.cos(r),s=1-a,u=o.x,c=o.y,l=o.z,f=[[s*u*u+a,s*u*c-i*l,s*u*l+i*c],[s*u*c+i*l,s*c*c+a,s*c*l-i*u],[s*u*l-i*c,s*c*l+i*u,s*l*l+a]],p=[f[0][0]*n.x+f[0][1]*n.y+f[0][2]*n.z,f[1][0]*n.x+f[1][1]*n.y+f[1][2]*n.z,f[2][0]*n.x+f[2][1]*n.y+f[2][2]*n.z];return new E(p[0],p[1],p[2])}toString(t=3){return`[${this.x.toFixed(t)},${this.y.toFixed(t)},${this.z.toFixed(t)}]`}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const O=E,N={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563}},T={WGS84:{ellipsoid:N.WGS84}};Object.freeze(N.WGS84),Object.freeze(T.WGS84);class j{constructor(t,e,r=0){if(isNaN(t)||null==t)throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e)||null==e)throw new TypeError(`invalid lon ‘${e}’`);if(isNaN(r)||null==r)throw new TypeError(`invalid height ‘${r}’`);this._lat=S.wrap90(Number(t)),this._lon=S.wrap180(Number(e)),this._height=Number(r)}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?S.wrap90(S.parse(t)):S.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?S.wrap90(S.parse(t)):S.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${t}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(t){if(this._lon=isNaN(t)?S.wrap180(S.parse(t)):S.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?S.wrap180(S.parse(t)):S.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?S.wrap180(S.parse(t)):S.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}get height(){return this._height}set height(t){if(this._height=Number(t),isNaN(this._height))throw new TypeError(`invalid height ‘${t}’`)}get datum(){return this._datum}set datum(t){this._datum=t}static get ellipsoids(){return N}static get datums(){return T}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");let e,r,n;if("object"==typeof t[0]&&(1==t.length||!isNaN(parseFloat(t[1])))){const o=t[0];if("Point"==o.type&&Array.isArray(o.coordinates)?([r,e,n]=o.coordinates,n=n||0):(null!=o.latitude&&(e=o.latitude),null!=o.lat&&(e=o.lat),null!=o.longitude&&(r=o.longitude),null!=o.lng&&(r=o.lng),null!=o.lon&&(r=o.lon),null!=o.height&&(n=o.height),e=S.wrap90(S.parse(e)),r=S.wrap180(S.parse(r))),null!=t[1]&&(n=t[1]),isNaN(e)||isNaN(r))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if("string"==typeof t[0]&&2==t[0].split(",").length&&([e,r]=t[0].split(","),e=S.wrap90(S.parse(e)),r=S.wrap180(S.parse(r)),n=t[1]||0,isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t[0]}’`);if(null==e&&null==r&&([e,r]=t,e=S.wrap90(S.parse(e)),r=S.wrap180(S.parse(r)),n=t[2]||0,isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t.toString()}’`);return new this(e,r,n)}toCartesian(){const t=this.datum?this.datum.ellipsoid:this.referenceFrame?this.referenceFrame.ellipsoid:N.WGS84,e=this.lat.toRadians(),r=this.lon.toRadians(),n=this.height,{a:o,f:i}=t,a=Math.sin(e),s=Math.cos(e),u=Math.sin(r),c=Math.cos(r),l=2*i-i*i,f=o/Math.sqrt(1-l*a*a);return new _((f+n)*s*c,(f+n)*s*u,(f*(1-l)+n)*a)}equals(t){if(!(t instanceof j))throw new TypeError(`invalid point ‘${t}’`);return!(Math.abs(this.lat-t.lat)>Number.EPSILON||Math.abs(this.lon-t.lon)>Number.EPSILON||Math.abs(this.height-t.height)>Number.EPSILON||this.datum!=t.datum||this.referenceFrame!=t.referenceFrame||this.epoch!=t.epoch)}toString(t="d",e=void 0,r=null){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);const n=(this.height>=0?" +":" ")+this.height.toFixed(r)+"m";return"n"==t?(null==e&&(e=4),`${this.lat.toFixed(e)}, ${this.lon.toFixed(e)}${null==r?"":n}`):`${S.toLat(this.lat,t,e)}, ${S.toLon(this.lon,t,e)}${null==r?"":n}`}}class _ extends O{constructor(t,e,r){super(t,e,r)}toLatLon(t=N.WGS84){if(!t||!t.a)throw new TypeError(`invalid ellipsoid ‘${t}’`);const{x:e,y:r,z:n}=this,{a:o,b:i,f:a}=t,s=2*a-a*a,u=s/(1-s),c=Math.sqrt(e*e+r*r),l=i*n/(o*c)*(1+u*i/Math.sqrt(c*c+n*n)),f=l/Math.sqrt(1+l*l),p=f/l,d=isNaN(p)?0:Math.atan2(n+u*i*f*f*f,c-s*o*p*p*p),h=Math.atan2(r,e),y=Math.sin(d),m=c*Math.cos(d)+n*y-o*o/(o/Math.sqrt(1-s*y*y));return new j(d.toDegrees(),h.toDegrees(),m)}toString(t=0){return`[${this.x.toFixed(t)},${this.y.toFixed(t)},${this.z.toFixed(t)}]`}}const x={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}},P={ED50:{ellipsoid:x.Intl1924,transform:[89.5,93.8,123.1,-1.2,0,0,.156]},ETRS89:{ellipsoid:x.GRS80,transform:[0,0,0,0,0,0,0]},Irl1975:{ellipsoid:x.AiryModified,transform:[-482.53,130.596,-564.557,-8.15,1.042,.214,.631]},NAD27:{ellipsoid:x.Clarke1866,transform:[8,-160,-176,0,0,0,0]},NAD83:{ellipsoid:x.GRS80,transform:[.9956,-1.9103,-.5215,-62e-5,.025915,.009426,.011599]},NTF:{ellipsoid:x.Clarke1880IGN,transform:[168,60,-320,0,0,0,0]},OSGB36:{ellipsoid:x.Airy1830,transform:[-446.448,125.157,-542.06,20.4894,-.1502,-.247,-.8421]},Potsdam:{ellipsoid:x.Bessel1841,transform:[-582,-105,-414,-8.3,1.04,.35,-3.08]},TokyoJapan:{ellipsoid:x.Bessel1841,transform:[148,-507,-685,0,0,0,0]},WGS72:{ellipsoid:x.WGS72,transform:[0,0,-4.5,-.22,0,0,.554]},WGS84:{ellipsoid:x.WGS84,transform:[0,0,0,0,0,0,0]}};Object.keys(x).forEach(t=>Object.freeze(x[t])),Object.keys(P).forEach(t=>{Object.freeze(P[t]),Object.freeze(P[t].transform)});class k extends j{constructor(t,e,r=0,n=P.WGS84){if(!n||null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(t,e,r),this._datum=n}get datum(){return this._datum}static get ellipsoids(){return x}static get datums(){return P}static parse(...t){let e=P.WGS84;if((4==t.length||3==t.length&&"object"==typeof t[2])&&(e=t.pop()),!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);const r=super.parse(...t);return r._datum=e,r}convertDatum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);return this.toCartesian().convertDatum(t).toLatLon()}toCartesian(){const t=super.toCartesian();return new G(t.x,t.y,t.z,this.datum)}}class G extends _{constructor(t,e,r,n=void 0){if(n&&null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(t,e,r),n&&(this._datum=n)}get datum(){return this._datum}set datum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);this._datum=t}toLatLon(t=void 0){t&&(console.info("datum parameter to Cartesian_Datum.toLatLon is deprecated: set datum before calling toLatLon()"),this.datum=t);const e=this.datum||P.WGS84;if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);const r=super.toLatLon(e.ellipsoid);return new k(r.lat,r.lon,r.height,this.datum)}convertDatum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);if(!this.datum)throw new TypeError("cartesian coordinate has no datum");let e=null,r=null;null!=this.datum&&this.datum!=P.WGS84||(e=this,r=t.transform),t==P.WGS84&&(e=this,r=this.datum.transform.map(t=>-t)),null==r&&(e=this.convertDatum(P.WGS84),r=t.transform);const n=e.applyTransform(r);return n.datum=t,n}applyTransform(t){const{x:e,y:r,z:n}=this,o=t[0],i=t[1],a=t[2],s=t[3]/1e6+1,u=(t[4]/3600).toRadians(),c=(t[5]/3600).toRadians(),l=(t[6]/3600).toRadians();return new G(o+e*s-r*l+n*c,i+e*l+r*s-n*u,a-e*c+r*u+n*s)}}const D={trueOrigin:{lat:49,lon:-2},falseOrigin:{easting:-4e5,northing:1e5},scaleFactor:.9996012717,ellipsoid:k.ellipsoids.Airy1830};class M{constructor(t,e){if(this.easting=Number(t),this.northing=Number(e),isNaN(t)||this.easting<0||this.easting>7e5)throw new RangeError(`invalid easting ‘${t}’`);if(isNaN(e)||this.northing<0||this.northing>13e5)throw new RangeError(`invalid northing ‘${e}’`)}toLatLon(t=k.datums.WGS84){const{easting:e,northing:r}=this,{a:n,b:o}=D.ellipsoid,i=D.trueOrigin.lat.toRadians(),a=D.trueOrigin.lon.toRadians(),s=-D.falseOrigin.easting,u=-D.falseOrigin.northing,c=D.scaleFactor,l=1-o*o/(n*n),f=(n-o)/(n+o),p=f*f,d=f*f*f;let h=i,y=0;do{h=(r-u-y)/(n*c)+h,y=o*c*((1+f+5/4*p+5/4*d)*(h-i)-(3*f+3*f*f+21/8*d)*Math.sin(h-i)*Math.cos(h+i)+(15/8*p+15/8*d)*Math.sin(2*(h-i))*Math.cos(2*(h+i))-35/24*d*Math.sin(3*(h-i))*Math.cos(3*(h+i)))}while(Math.abs(r-u-y)>=1e-5);const m=Math.cos(h),b=Math.sin(h),g=n*c/Math.sqrt(1-l*b*b),v=n*c*(1-l)/Math.pow(1-l*b*b,1.5),w=g/v-1,S=Math.tan(h),E=S*S,O=E*E,N=1/m,T=g*g*g,j=T*g*g,_=e-s,x=_*_,P=x*_,G=x*x,M=P*x;h=h-S/(2*v*g)*x+S/(24*v*T)*(5+3*E+w-9*E*w)*G-S/(720*v*j)*(61+90*E+45*O)*(G*x);const A=a+N/g*_-N/(6*T)*(g/v+2*E)*P+N/(120*j)*(5+28*E+24*O)*M-N/(j*g*g*5040)*(61+662*E+1320*O+O*E*720)*(M*x);let C=new R(h.toDegrees(),A.toDegrees(),0,k.datums.OSGB36);return t!=k.datums.OSGB36&&(C=C.convertDatum(t),C=new R(C.lat,C.lon,C.height,C.datum)),C}static parse(t){let e=(t=String(t).trim()).match(/^(\d+),\s*(\d+)$/);if(e)return new M(e[1],e[2]);if(e=t.match(/^[HNST][ABCDEFGHJKLMNOPQRSTUVWXYZ]\s*[0-9]+\s*[0-9]+$/i),!e)throw new Error(`invalid grid reference ‘${t}’`);let r=t.toUpperCase().charCodeAt(0)-"A".charCodeAt(0),n=t.toUpperCase().charCodeAt(1)-"A".charCodeAt(0);r>7&&r--,n>7&&n--;const o=(r-2)%5*5+n%5,i=19-5*Math.floor(r/5)-Math.floor(n/5);let a=t.slice(2).trim().split(/\s+/);if(1==a.length&&(a=[a[0].slice(0,a[0].length/2),a[0].slice(a[0].length/2)]),a[0].length!=a[1].length)throw new Error(`invalid grid reference ‘${t}’`);a[0]=a[0].padEnd(5,"0"),a[1]=a[1].padEnd(5,"0");const s=o+a[0],u=i+a[1];return new M(s,u)}toString(t=10){if(![0,2,4,6,8,10,12,14,16].includes(Number(t)))throw new RangeError(`invalid precision ‘${t}’`);let{easting:e,northing:r}=this;if(0==t){const t={useGrouping:!1,minimumIntegerDigits:6,maximumFractionDigits:3};return`${e.toLocaleString("en",t)},${r.toLocaleString("en",t)}`}const n=Math.floor(e/1e5),o=Math.floor(r/1e5);let i=19-o-(19-o)%5+Math.floor((n+10)/5),a=5*(19-o)%25+n%5;i>7&&i++,a>7&&a++;const s=String.fromCharCode(i+"A".charCodeAt(0),a+"A".charCodeAt(0));return e=Math.floor(e%1e5/Math.pow(10,5-t/2)),r=Math.floor(r%1e5/Math.pow(10,5-t/2)),e=e.toString().padStart(t/2,"0"),r=r.toString().padStart(t/2,"0"),`${s} ${e} ${r}`}}class R extends k{toOsGrid(){const t=this.datum==k.datums.OSGB36?this:this.convertDatum(k.datums.OSGB36),e=t.lat.toRadians(),r=t.lon.toRadians(),{a:n,b:o}=D.ellipsoid,i=D.trueOrigin.lat.toRadians(),a=D.trueOrigin.lon.toRadians(),s=-D.falseOrigin.easting,u=-D.falseOrigin.northing,c=D.scaleFactor,l=1-o*o/(n*n),f=(n-o)/(n+o),p=f*f,d=f*f*f,h=Math.cos(e),y=Math.sin(e),m=n*c/Math.sqrt(1-l*y*y),b=n*c*(1-l)/Math.pow(1-l*y*y,1.5),g=m/b-1,v=o*c*((1+f+5/4*p+5/4*d)*(e-i)-(3*f+3*f*f+21/8*d)*Math.sin(e-i)*Math.cos(e+i)+(15/8*p+15/8*d)*Math.sin(2*(e-i))*Math.cos(2*(e+i))-35/24*d*Math.sin(3*(e-i))*Math.cos(3*(e+i))),w=h*h*h,S=w*h*h,E=Math.tan(e)*Math.tan(e),O=E*E,N=r-a,T=N*N,j=T*N,_=j*N,x=_*N;let P=v+u+m/2*y*h*T+m/24*y*w*(5-E+9*g)*_+m/720*y*S*(61-58*E+O)*(x*N),G=s+m*h*N+m/6*w*(m/b-E)*j+m/120*S*(5-18*E+O+14*g-58*E*g)*x;P=Number(P.toFixed(3)),G=Number(G.toFixed(3));try{return new M(G,P)}catch(e){throw new Error(`${e.message} from (${t.lat.toFixed(6)},${t.lon.toFixed(6)}).toOsGrid()`)}}convertDatum(t){const e=super.convertDatum(t);return new R(e.lat,e.lon,e.height,e.datum)}}function A(t){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}var C;function I(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function L(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?I(Object(r),!0).forEach(function(e){$(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function $(t,e,r){return(e=function(t){var e=function(t){if("object"!=A(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=A(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==A(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var F=500,W=function(t){var e=t.GAZETTEER_ENTRY,r="eng"===e.NAME2_LANG?e.NAME2:e.NAME1;return t.GAZETTEER_ENTRY.NAME1=r,t.GAZETTEER_ENTRY.NAME1_LANG="eng",t},U=function(t,e){var r,n,o,i,a=e.MBR_XMIN,s=e.MBR_YMIN,u=e.MBR_XMAX,c=e.MBR_YMAX,l=e.GEOMETRY_X,f=e.GEOMETRY_Y;if(null==a?(r=l-F,n=f-F,o=l+F,i=f+F):(r=a,n=s,o=u,i=c),"EPSG:27700"===t)return[r,n,o,i];if("EPSG:4326"===t){var p=new M(r,n).toLatLon(),d=new M(o,i).toLatLon();return[p.lon,p.lat,d.lon,d.lat].map(function(t){return Math.round(1e6*t)/1e6})}throw new Error("Unsupported CRS: ".concat(t))},B=function(t,e){var r=e.GEOMETRY_X,n=e.GEOMETRY_Y;if("EPSG:27700"===t)return[r,n];if("EPSG:4326"===t){var o=new M(r,n).toLatLon();return[Math.round(1e6*o.lon)/1e6,Math.round(1e6*o.lat)/1e6]}throw new Error("Unsupported CRS: ".concat(t))};function z(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function V(t){return function(t){if(Array.isArray(t))return q(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||H(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Y(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=H(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function H(t,e){if(t){if("string"==typeof t)return q(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(t,e):void 0}}function q(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Z(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return K(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,s=0,u=t,p.n=r,a}};function d(r,n){for(s=r,u=n,e=0;!f&&c&&!o&&e<l.length;e++){var o,i=l[e],d=p.p,h=i[2];r>3?(o=h===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,p.v=n,p.n=i[1]):d<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,p.n=h,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,h){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,h),s=l,u=h;(e=s<2?t:u)||!f;){i||(s?s<3?(s>1&&(p.n=-1),d(s,u)):p.n=u:p.v=u);try{if(c=2,i){if(s||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(K(e={},n,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,K(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,K(f,"constructor",c),K(c,"constructor",u),u.displayName="GeneratorFunction",K(c,o,"GeneratorFunction"),K(f),K(f,o,"Generator"),K(f,n,function(){return this}),K(f,"toString",function(){return"[object Generator]"}),(Z=function(){return{w:i,m:p}})()}function K(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}K=function(t,e,r,n){function i(e,r){K(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},K(t,e,r,n)}function X(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function J(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){X(i,n,o,a,s,"next",t)}function s(t){X(i,n,o,a,s,"throw",t)}a(void 0)})}}var Q=function(t){return t.replace(/[^a-zA-Z0-9\s\-.,]/g,"").trim()},tt=function(t){var e=t.url,r=t.options;return new Request(e,r)},et=function(){var t=J(Z().m(function t(e,r,n){var o,i,a,s;return Z().w(function(t){for(;;)switch(t.n){case 0:if(i={url:null===(o=e.urlTemplate)||void 0===o?void 0:o.replace("{query}",encodeURIComponent(r)),options:{method:"GET"}},!e.buildRequest){t.n=1;break}return a=e.buildRequest(r,function(){return i}),t.a(2,a instanceof Request?a:tt(a));case 1:if(!n){t.n=3;break}return s=tt,t.n=2,n(i,r);case 2:return t.a(2,s(t.v));case 3:return t.a(2,tt(i))}},t)}));return function(e,r,n){return t.apply(this,arguments)}}(),rt=function(){var t=J(Z().m(function t(e,r,n){var o,i,a;return Z().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,fetch(r);case 1:if((o=t.v).ok){t.n=2;break}return console.error("Fetch error for ".concat(e.label||"dataset",": ").concat(o.status)),t.a(2,null);case 2:return t.n=3,o.json();case 3:return i=t.v,t.a(2,e.parseResults(i,n));case 4:return t.p=4,a=t.v,console.error("Network error for ".concat(e.label||"dataset",":"),a),t.a(2,null)}},t,null,[[0,4]])}));return function(e,r,n){return t.apply(this,arguments)}}(),nt=function(){var t=J(Z().m(function t(e,r,n,o){var i,a,s,u,c,l,f,p,d;return Z().w(function(t){for(;;)switch(t.p=t.n){case 0:i=Q(e),a=r.filter(function(t){var r=!t.includeRegex||t.includeRegex.test(e),n=!!t.excludeRegex&&t.excludeRegex.test(i);return r&&!n}),s=[],u=Y(a),t.p=1,u.s();case 2:if((c=u.n()).done){t.n=6;break}return l=c.value,t.n=3,et(l,i,o);case 3:return f=t.v,t.n=4,rt(l,f,i);case 4:if(null==(p=t.v)||!p.length){t.n=5;break}if(s=[].concat(V(s),V(p)),!l.exclusive){t.n=5;break}return t.a(3,6);case 5:t.n=2;break;case 6:t.n=8;break;case 7:t.p=7,d=t.v,u.e(d);case 8:return t.p=8,u.f(),t.f(8);case 9:return n({type:"UPDATE_SUGGESTIONS",payload:s}),t.a(2,{results:s,sanitisedValue:i})}},t,null,[[1,7,8,9]])}));return function(e,r,n,o){return t.apply(this,arguments)}}();function ot(t){var e=t.mapProvider,r=t.bounds,n=t.point,o=t.markers,i=t.showMarker,a=t.markerOptions;e.fitToBounds(r),i&&o.add("search",n,a)}function it(t){return it="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},it(t)}function at(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return st(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,s=0,u=t,p.n=r,a}};function d(r,n){for(s=r,u=n,e=0;!f&&c&&!o&&e<l.length;e++){var o,i=l[e],d=p.p,h=i[2];r>3?(o=h===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,p.v=n,p.n=i[1]):d<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,p.n=h,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,h){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,h),s=l,u=h;(e=s<2?t:u)||!f;){i||(s?s<3?(s>1&&(p.n=-1),d(s,u)):p.n=u:p.v=u);try{if(c=2,i){if(s||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(st(e={},n,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,st(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,st(f,"constructor",c),st(c,"constructor",u),u.displayName="GeneratorFunction",st(c,o,"GeneratorFunction"),st(f),st(f,o,"Generator"),st(f,n,function(){return this}),st(f,"toString",function(){return"[object Generator]"}),(at=function(){return{w:i,m:p}})()}function st(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}st=function(t,e,r,n){function i(e,r){st(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},st(t,e,r,n)}function ut(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ct(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ut(Object(r),!0).forEach(function(e){lt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ut(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function lt(t,e,r){return(e=function(t){var e=function(t){if("object"!=it(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=it(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==it(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ft(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function pt(t){return pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pt(t)}function dt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ht(t,e,r){return(e=function(t){var e=function(t){if("object"!=pt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=pt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function yt(t){return yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yt(t)}function mt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function bt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?mt(Object(r),!0).forEach(function(e){gt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):mt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function gt(t,e,r){return(e=function(t){var e=function(t){if("object"!=yt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vt(t){var e,r,n,o=t.dispatch,i=t.searchContainerRef,a=(e=function(e){return nt(e,t.datasets,o,t.transformRequest)},r=null,n=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(function(){e.apply(void 0,n)},350)},n.cancel=function(){r&&(clearTimeout(r),r=null)},n),s=function(t){var e=t.dispatch,r=t.services,n=t.viewportRef,o=t.mapProvider,i=t.markers,a=t.datasets,s=t.transformRequest,u=t.showMarker,c=t.markerOptions,l="";return{handleOpenClick:function(){e({type:"TOGGLE_EXPANDED",payload:!0}),r.eventBus.emit("search:open")},handleCloseClick:function(t,n){e({type:"TOGGLE_EXPANDED",payload:!1}),e({type:"UPDATE_SUGGESTIONS",payload:[]}),e({type:"SET_VALUE",payload:""}),setTimeout(function(){return n.current.focus()},0),i.remove("search"),r.eventBus.emit("search:clear"),r.eventBus.emit("search:close")},handleSubmit:function(t,f,p){return(d=at().m(function d(){var h,y,m,b,g,v,w,S,E,O,N,T;return at().w(function(d){for(;;)switch(d.n){case 0:if(t.preventDefault(),h=p.suggestions,y=p.selectedIndex,m=p.value,b=null==m?void 0:m.trim(),e({type:"SET_SELECTED",payload:-1}),e({type:"HIDE_SUGGESTIONS"}),!(y>=0)){d.n=1;break}return v=h[y],e({type:"SET_VALUE",payload:v.text}),null===(g=n.current)||void 0===g||g.focus(),ot({mapProvider:o,bounds:v.bounds,point:v.point,markers:i,showMarker:u,markerOptions:c}),r.eventBus.emit("search:match",ct({query:v.text},v)),d.a(2);case 1:if(!((null==b?void 0:b.length)<3)){d.n=2;break}return d.a(2);case 2:if(w=h,h.length&&b===l){d.n=4;break}return d.n=3,nt(b,a,e,s);case 3:S=d.v,E=S.results,O=S.sanitisedValue,w=E,l=O;case 4:w.length&&("keyboard"===f.interfaceType&&(null===(N=n.current)||void 0===N||N.focus()),"mobile"===f.breakpoint&&(e({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close")),T=w[0],ot({mapProvider:o,bounds:T.bounds,point:T.point,markers:i,showMarker:u,markerOptions:c}),r.eventBus.emit("search:match",ct({query:m},T)));case 5:return d.a(2)}},d)}),function(){var t=this,e=arguments;return new Promise(function(r,n){var o=d.apply(t,e);function i(t){ft(o,r,n,i,a,"next",t)}function a(t){ft(o,r,n,i,a,"throw",t)}i(void 0)})})();var d}}}(t),u=function(t){var e=t.dispatch,r=t.debouncedFetchSuggestions;return{handleInputClick:function(){e({type:"SHOW_SUGGESTIONS"})},handleInputFocus:function(t){e({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:"keyboard"===t})},handleInputBlur:function(t){e({type:"INPUT_BLUR",payload:t})},handleInputChange:function(t){var n=t.target.value;if(e({type:"SET_VALUE",payload:n}),n.length<3)return r.cancel(),e({type:"UPDATE_SUGGESTIONS",payload:[]}),void e({type:"HIDE_SUGGESTIONS"});e({type:"SHOW_SUGGESTIONS"}),r(n)}}}(bt(bt({},t),{},{debouncedFetchSuggestions:a})),c=function(t){var e=t.dispatch,r=t.services,n=t.mapProvider,o=t.markers,i=t.showMarker,a=t.markerOptions,s=function(t,e){var r;return e>=0?"".concat(null===(r=t[e])||void 0===r?void 0:r.text,". ").concat(e+1," of ").concat(t.length," is highlighted"):"".concat(t.length," suggestions available")};return{handleSuggestionClick:function(t,s){e({type:"SET_VALUE",payload:t.text}),e({type:"HIDE_SUGGESTIONS"}),e({type:"SET_SELECTED",payload:-1}),"mobile"===s.breakpoint&&(e({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close")),ot({mapProvider:n,bounds:t.bounds,point:t.point,markers:o,showMarker:i,markerOptions:a}),r.eventBus.emit("search:match",function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?dt(Object(r),!0).forEach(function(e){ht(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):dt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({query:t.text},t))},handleInputKeyDown:function(t,n){var o=n.suggestions,i=n.selectedIndex;switch(t.key){case"ArrowDown":if(null==o||!o.length)return;if(t.preventDefault(),i<o.length-1){var a=i+1;r.announce(s(o,a)),e({type:"SET_SELECTED",payload:a}),e({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:!1})}break;case"ArrowUp":if(null==o||!o.length)return;t.preventDefault();var u=i>0?i-1:-1;r.announce(s(o,u)),e({type:"SET_SELECTED",payload:u}),e({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:u<0});break;case"Escape":t.preventDefault(),e({type:"HIDE_SUGGESTIONS"}),e({type:"SET_SELECTED",payload:-1})}}}}(t);return bt(bt(bt(bt({},s),u),c),{},{handleOutside:function(e){i.current.contains(e.target)||(o({type:"TOGGLE_EXPANDED",payload:!1}),t.services.eventBus.emit("search:close"))}})}function wt(t){return wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wt(t)}var St=["marker"];function Et(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Ot(t,e,r){return(e=function(t){var e=function(t){if("object"!=wt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=wt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Nt={reducer:{initialState:{isExpanded:!1,hasKeyboardFocusWithin:!1,value:"",suggestions:[],areSuggestionsVisible:!1,hasFetchedSuggestions:!1,selectedIndex:-1},actions:s},controls:[{id:"search",mobile:{slot:"top-right",showLabel:!1},tablet:{slot:"top-left",showLabel:!1},desktop:{slot:"top-left",showLabel:!1},render:function(t){var e,r=t.appConfig,n=t.iconRegistry,o=t.pluginState,i=t.pluginConfig,a=t.appState,s=t.mapState,f=t.services,p=t.mapProvider,d=r.id,h=a.interfaceType,y=i.expanded,v=i.customDatasets,w=i.osNamesURL,S=i.regions,E=o.dispatch,O=o.isExpanded,N=o.areSuggestionsVisible,T=o.suggestions,j=(null==a||null===(e=a.controlConfig)||void 0===e||null===(e=e.search)||void 0===e?void 0:e[null==a?void 0:a.breakpoint].showLabel)||!1,_=n.close,x=n.search,P=(0,u.useRef)(null),k=(0,u.useRef)(null),G=(0,u.useRef)(null),D=a.layoutRefs.viewportRef,M=function(t){var e,r=t.customDatasets,n=void 0===r?[]:r,o=t.osNamesURL,i=t.crs,a=t.regions,s=void 0===a?["england","scotland","wales"]:a;return o?[].concat([{name:"osNames",urlTemplate:o,parseResults:function(t,e){return function(t,e,r,n){var o;if(!t||t.error||0===(null===(o=t.header)||void 0===o?void 0:o.totalresults))return[];var i=t.results;return i=function(t,e){var r=e.toLowerCase().replace(/,/g,"").split(" ");return t.map(W).filter(function(t){return r.some(function(r){return t.GAZETTEER_ENTRY.NAME1.toLowerCase().includes(r)||(n=(n=e).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,e),i=function(t,e){return t.filter(function(t){var r,n=null==t||null===(r=t.GAZETTEER_ENTRY)||void 0===r||null===(r=r.COUNTRY)||void 0===r?void 0:r.toLowerCase();return n&&e.includes(n)})}(i=function(t){return Array.from(new Map(t.map(function(t){return[t.GAZETTEER_ENTRY.ID,t]})).values())}(i),r),(i=i.slice(0,8)).map(function(t){return L(L({id:t.GAZETTEER_ENTRY.ID,bounds:U(n,t.GAZETTEER_ENTRY),point:B(n,t.GAZETTEER_ENTRY)},function(t,e){var r,n,o,i,a,s,u=e.NAME1,c=e.COUNTY_UNITARY,l=e.DISTRICT_BOROUGH,f=e.POSTCODE_DISTRICT,p=e.LOCAL_TYPE,d="".concat(["City","Postcode"].includes(p)?"":f+", ").concat("City"===p?"":c||l),h="".concat(u).concat(d?", "+d:"");return{text:h,marked:(r=h,n=t,a=n.replace(/\s+/g,"").split("").join(String.raw(C||(o=["s*"],(i=["\\s*"])||(i=o.slice(0)),C=Object.freeze(Object.defineProperties(o,{raw:{value:Object.freeze(i)}}))))),s=new RegExp("(".concat(a,")"),"i"),r.replace(s,"<mark>$1</mark>"))}}(e,t.GAZETTEER_ENTRY)),{},{type:"os-names"})})}(t,e,s,i)},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}],function(t){if(Array.isArray(t))return z(t)}(e=n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return z(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?z(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):n}({customDatasets:v,osNamesURL:w,regions:S,crs:p.crs}),R=(0,u.useRef)(null);if(!R.current){var A=i.marker,I=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],-1===e.indexOf(r)&&{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(i,St);R.current=vt(function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Et(Object(r),!0).forEach(function(e){Ot(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Et(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({dispatch:E,datasets:M,services:f,mapProvider:p,viewportRef:D,searchContainerRef:P,markers:s.markers,markerOptions:A},I))}var $=R.current,F=O||!!(y&&N&&T.length);return(0,u.useEffect)(function(){var t;O&&(null===(t=G.current)||void 0===t||t.focus())},[O]),(0,u.useEffect)(function(){if(a.dispatch({type:"TOGGLE_HAS_EXCLUSIVE_CONTROL",payload:O}),F)return D.current.style.pointerEvents="none",document.addEventListener("focusin",$.handleOutside),document.addEventListener("pointerdown",$.handleOutside),function(){D.current.style.pointerEvents="auto",document.removeEventListener("focusin",$.handleOutside),document.removeEventListener("pointerdown",$.handleOutside)}},[O,h,N,T]),(0,c.jsxs)("div",{className:"im-c-search",ref:P,children:[!y&&(0,c.jsx)(l,{id:d,isExpanded:O,onClick:function(){return $.handleOpenClick(a)},buttonRef:k,searchIcon:x,showLabel:j}),(0,c.jsxs)(m,{id:d,pluginState:o,pluginConfig:i,appState:a,inputRef:G,events:$,services:f,children:[(0,c.jsx)(b,{defaultExpanded:y,onClick:function(t){return $.handleCloseClick(t,k,a)},closeIcon:_}),(0,c.jsx)(g,{defaultExpanded:y,onClick:function(t){return $.handleCloseClick(t,k,a)},submitIcon:x})]})]})}}],icons:[{id:"search",svgContent:'<path d="m21 21-4.34-4.34"></path><circle cx="11" cy="11" r="8"></circle>'}]}}}]);
2
+ "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[254],{70(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){a(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function a(t,e,r){return(e=function(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.r(e),r.d(e,{manifest:()=>Tt});var s={TOGGLE_EXPANDED:function(t,e){return i(i({},t),{},{isExpanded:e,areSuggestionsVisible:e,hasFetchedSuggestions:!1,hasSearchError:!1})},SET_KEYBOARD_FOCUS_WITHIN:function(t,e){return i(i({},t),{},{hasKeyboardFocusWithin:e,areSuggestionsVisible:!0})},INPUT_BLUR:function(t,e){return i(i({},t),{},{hasKeyboardFocusWithin:!1,areSuggestionsVisible:t.areSuggestionsVisible&&"keyboard"!==e,selectedIndex:-1})},SET_VALUE:function(t,e){return i(i({},t),{},{value:e})},UPDATE_SUGGESTIONS:function(t,e){return i(i({},t),{},{suggestions:e.results,hasFetchedSuggestions:!0,hasSearchError:e.hasError})},SHOW_SUGGESTIONS:function(t){return i(i({},t),{},{areSuggestionsVisible:!0,hasFetchedSuggestions:!1,hasSearchError:!1})},HIDE_SUGGESTIONS:function(t){return i(i({},t),{},{areSuggestionsVisible:!1,hasFetchedSuggestions:!1,hasSearchError:!1})},SET_SELECTED:function(t,e){return i(i({},t),{},{selectedIndex:e,areSuggestionsVisible:e>=0})}},u=r(738),c=r(287),l=function(t){var e=t.id,r=t.isExpanded,n=t.onClick,o=t.buttonRef,i=t.searchIcon,a=t.showLabel;return(0,c.jsxs)("button",{"aria-label":"Open search",className:"im-c-map-button im-c-search-open-button",onClick:n,"aria-controls":"".concat(e,"-search-form"),ref:o,style:r?{display:"none"}:void 0,children:[i&&(0,c.jsx)("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:i}}),a&&(0,c.jsx)("span",{children:"Search"})]})},f=function(t){var e=t.id,r=t.pluginState,n=t.handleSuggestionClick;return(0,c.jsx)("ul",{id:"".concat(e,"-search-suggestions"),role:"listbox","aria-labelledby":"".concat(e,"-search"),className:"im-c-search-suggestions",style:r.areSuggestionsVisible&&r.suggestions.length?void 0:{display:"none"},children:r.suggestions.map(function(t,o){return(0,c.jsx)("li",{id:"".concat(e,"-search-suggestion-").concat(o),className:"im-c-search-suggestions__item",role:"option","aria-selected":r.selectedIndex===o,"aria-setsize":r.suggestions.length,"aria-posinset":o+1,onClick:function(){return n(t)},children:(0,c.jsx)("span",{className:"im-c-search-suggestions__label",dangerouslySetInnerHTML:{__html:t.marked}})},t.id)})})};function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function h(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function d(t,e,r){return(e=function(t){var e=function(t){if("object"!=p(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==p(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var y=function(t,e,r){return function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?h(Object(r),!0).forEach(function(e){d(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({display:t.expanded||e.isExpanded?"flex":void 0},"mobile"!==r.breakpoint&&(null==t?void 0:t.width)&&{width:t.width})},m=function(t){var e=t.id,r=t.pluginState,n=t.pluginConfig,o=t.appState,i=t.inputRef,a=t.events,s=t.services,l=t.children,p=r.areSuggestionsVisible,h=r.hasFetchedSuggestions,d=r.hasSearchError,m=r.suggestions,b=void 0===m?[]:m,g=n.noResultsMessage,v=n.searchErrorMessage;(0,u.useEffect)(function(){p&&h&&s.announce(function(t,e,r,n){if(e)return r;if(0===t)return n;var o=1===t?"result":"results";return"".concat(t," ").concat(o," available")}(b.length,d,v,g))},[b,h]);var w=["im-c-search-form",n.expanded&&"im-c-search-form--default-expanded","im-c-panel"].filter(Boolean).join(" "),S=p&&h&&(d||!b.length);return(0,c.jsxs)("form",{id:"".concat(e,"-search-form"),role:"search",className:w,style:y(n,r,o),"aria-controls":"".concat(e,"-viewport"),onSubmit:function(t){return a.handleSubmit(t,o,r)},children:[(0,c.jsx)("button",{type:"submit",style:{display:"none"},"aria-hidden":"true",tabIndex:-1,children:"Submit"}),(0,c.jsxs)("div",{className:"im-c-search__input-container".concat(r.hasKeyboardFocusWithin?" im-c-search__input-container--keyboard-focus-within":""),children:[(0,c.jsx)("label",{htmlFor:"".concat(e,"-search"),className:"im-u-visually-hidden",children:n.placeholder}),(0,c.jsx)("input",{id:"".concat(e,"-search"),className:"im-c-search__input",type:"search",role:"combobox","aria-expanded":r.suggestionsVisible,"aria-controls":"".concat(e,"-search-suggestions"),"aria-activedescendant":r.selectedIndex>=0?"".concat(e,"-search-suggestion-").concat(r.selectedIndex):void 0,"aria-describedby":r.value?void 0:"".concat(e,"-search-hint"),"aria-autocomplete":"list",autoComplete:"off",placeholder:n.placeholder,name:"".concat(e,"-search"),spellCheck:!1,enterKeyHint:"search",value:r.value,onClick:a.handleInputClick,onChange:a.handleInputChange,onFocus:function(){return a.handleInputFocus(o.interfaceType)},onBlur:function(){return a.handleInputBlur(o.interfaceType)},onKeyDown:function(t){return a.handleInputKeyDown(t,r)},ref:i}),(0,c.jsx)("span",{id:"".concat(e,"-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."}),l]}),S&&(0,c.jsx)("div",{className:"im-c-search__status","aria-hidden":"true",children:d?v:g}),(0,c.jsx)(f,{id:e,appState:o,pluginState:r,handleSuggestionClick:function(t){return a.handleSuggestionClick(t,o)}})]})},b=function(t){var e=t.defaultExpanded,r=t.onClick,n=t.closeIcon;return(0,c.jsx)("button",{"aria-label":"Close search",className:"im-c-map-button im-c-search-close-button",type:"button",onClick:r,style:e?{display:"none"}:void 0,children:n&&(0,c.jsx)("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:n}})})},g=function(t){var e=t.defaultExpanded,r=t.submitIcon;return(0,c.jsx)("button",{"aria-label":"Search",className:"im-c-map-button im-c-search-submit-button",type:"submit",style:e?void 0:{display:"none"},children:r&&(0,c.jsx)("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 v=" ";class w{static get separator(){return v}static set separator(t){v=t}static parse(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Number(t);const e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;let r=null;switch(e.length){case 3:r=e[0]/1+e[1]/60+e[2]/3600;break;case 2:r=e[0]/1+e[1]/60;break;case 1:r=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(r=-r),Number(r)}static toDms(t,e="d",r=void 0){if(isNaN(t))return null;if("string"==typeof t&&""==t.trim())return null;if("boolean"==typeof t)return null;if(t==1/0)return null;if(null==t)return null;if(void 0===r)switch(e){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:e="d",r=4}t=Math.abs(t);let n=null,o=null,i=null,a=null;switch(e){default:case"d":case"deg":o=t.toFixed(r),o<100&&(o="0"+o),o<10&&(o="0"+o),n=o+"°";break;case"dm":case"deg+min":o=Math.floor(t),i=(60*t%60).toFixed(r),60==i&&(i=(0).toFixed(r),o++),o=("000"+o).slice(-3),i<10&&(i="0"+i),n=o+"°"+w.separator+i+"′";break;case"dms":case"deg+min+sec":o=Math.floor(t),i=Math.floor(3600*t/60)%60,a=(3600*t%60).toFixed(r),60==a&&(a=(0).toFixed(r),i++),60==i&&(i=0,o++),o=("000"+o).slice(-3),i=("00"+i).slice(-2),a<10&&(a="0"+a),n=o+"°"+w.separator+i+"′"+w.separator+a+"″"}return n}static toLat(t,e,r){const n=w.toDms(w.wrap90(t),e,r);return null===n?"–":n.slice(1)+w.separator+(t<0?"S":"N")}static toLon(t,e,r){const n=w.toDms(w.wrap180(t),e,r);return null===n?"–":n+w.separator+(t<0?"W":"E")}static toBrng(t,e,r){const n=w.toDms(w.wrap360(t),e,r);return null===n?"–":n.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(r.thousands,"⁜").replace(r.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",r.decimal).replace("⁜",r.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=w.wrap360(t);const r=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*r/360)%r*16/r]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t;return 1*Math.abs(((e-90)%360+360)%360-180)-90}static wrap180(t){if(-180<=t&&t<=180)return t;const e=360;return((360*t/e-180)%e+e)%e-180}static wrap360(t){if(0<=t&&t<360)return t;const e=360;return(360*t/e%e+e)%e}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const S=w;class E{constructor(t,e,r){if(isNaN(t)||isNaN(e)||isNaN(r))throw new TypeError(`invalid vector [${t},${e},${r}]`);this.x=Number(t),this.y=Number(e),this.z=Number(r)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}plus(t){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");return new E(this.x+t.x,this.y+t.y,this.z+t.z)}minus(t){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");return new E(this.x-t.x,this.y-t.y,this.z-t.z)}times(t){if(isNaN(t))throw new TypeError(`invalid scalar value ‘${t}’`);return new E(this.x*t,this.y*t,this.z*t)}dividedBy(t){if(isNaN(t))throw new TypeError(`invalid scalar value ‘${t}’`);return new E(this.x/t,this.y/t,this.z/t)}dot(t){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");return this.x*t.x+this.y*t.y+this.z*t.z}cross(t){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");const e=this.y*t.z-this.z*t.y,r=this.z*t.x-this.x*t.z,n=this.x*t.y-this.y*t.x;return new E(e,r,n)}negate(){return new E(-this.x,-this.y,-this.z)}unit(){const t=this.length;if(1==t)return this;if(0==t)return this;const e=this.x/t,r=this.y/t,n=this.z/t;return new E(e,r,n)}angleTo(t,e=void 0){if(!(t instanceof E))throw new TypeError("v is not Vector3d object");if(!(e instanceof E||null==e))throw new TypeError("n is not Vector3d object");const r=null==e||this.cross(t).dot(e)>=0?1:-1,n=this.cross(t).length*r,o=this.dot(t);return Math.atan2(n,o)}rotateAround(t,e){if(!(t instanceof E))throw new TypeError("axis is not Vector3d object");const r=e.toRadians(),n=this.unit(),o=t.unit(),i=Math.sin(r),a=Math.cos(r),s=1-a,u=o.x,c=o.y,l=o.z,f=[[s*u*u+a,s*u*c-i*l,s*u*l+i*c],[s*u*c+i*l,s*c*c+a,s*c*l-i*u],[s*u*l-i*c,s*c*l+i*u,s*l*l+a]],p=[f[0][0]*n.x+f[0][1]*n.y+f[0][2]*n.z,f[1][0]*n.x+f[1][1]*n.y+f[1][2]*n.z,f[2][0]*n.x+f[2][1]*n.y+f[2][2]*n.z];return new E(p[0],p[1],p[2])}toString(t=3){return`[${this.x.toFixed(t)},${this.y.toFixed(t)},${this.z.toFixed(t)}]`}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const O=E,N={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563}},T={WGS84:{ellipsoid:N.WGS84}};Object.freeze(N.WGS84),Object.freeze(T.WGS84);class j{constructor(t,e,r=0){if(isNaN(t)||null==t)throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e)||null==e)throw new TypeError(`invalid lon ‘${e}’`);if(isNaN(r)||null==r)throw new TypeError(`invalid height ‘${r}’`);this._lat=S.wrap90(Number(t)),this._lon=S.wrap180(Number(e)),this._height=Number(r)}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?S.wrap90(S.parse(t)):S.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?S.wrap90(S.parse(t)):S.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${t}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(t){if(this._lon=isNaN(t)?S.wrap180(S.parse(t)):S.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?S.wrap180(S.parse(t)):S.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?S.wrap180(S.parse(t)):S.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}get height(){return this._height}set height(t){if(this._height=Number(t),isNaN(this._height))throw new TypeError(`invalid height ‘${t}’`)}get datum(){return this._datum}set datum(t){this._datum=t}static get ellipsoids(){return N}static get datums(){return T}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");let e,r,n;if("object"==typeof t[0]&&(1==t.length||!isNaN(parseFloat(t[1])))){const o=t[0];if("Point"==o.type&&Array.isArray(o.coordinates)?([r,e,n]=o.coordinates,n=n||0):(null!=o.latitude&&(e=o.latitude),null!=o.lat&&(e=o.lat),null!=o.longitude&&(r=o.longitude),null!=o.lng&&(r=o.lng),null!=o.lon&&(r=o.lon),null!=o.height&&(n=o.height),e=S.wrap90(S.parse(e)),r=S.wrap180(S.parse(r))),null!=t[1]&&(n=t[1]),isNaN(e)||isNaN(r))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if("string"==typeof t[0]&&2==t[0].split(",").length&&([e,r]=t[0].split(","),e=S.wrap90(S.parse(e)),r=S.wrap180(S.parse(r)),n=t[1]||0,isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t[0]}’`);if(null==e&&null==r&&([e,r]=t,e=S.wrap90(S.parse(e)),r=S.wrap180(S.parse(r)),n=t[2]||0,isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t.toString()}’`);return new this(e,r,n)}toCartesian(){const t=this.datum?this.datum.ellipsoid:this.referenceFrame?this.referenceFrame.ellipsoid:N.WGS84,e=this.lat.toRadians(),r=this.lon.toRadians(),n=this.height,{a:o,f:i}=t,a=Math.sin(e),s=Math.cos(e),u=Math.sin(r),c=Math.cos(r),l=2*i-i*i,f=o/Math.sqrt(1-l*a*a);return new x((f+n)*s*c,(f+n)*s*u,(f*(1-l)+n)*a)}equals(t){if(!(t instanceof j))throw new TypeError(`invalid point ‘${t}’`);return!(Math.abs(this.lat-t.lat)>Number.EPSILON||Math.abs(this.lon-t.lon)>Number.EPSILON||Math.abs(this.height-t.height)>Number.EPSILON||this.datum!=t.datum||this.referenceFrame!=t.referenceFrame||this.epoch!=t.epoch)}toString(t="d",e=void 0,r=null){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);const n=(this.height>=0?" +":" ")+this.height.toFixed(r)+"m";return"n"==t?(null==e&&(e=4),`${this.lat.toFixed(e)}, ${this.lon.toFixed(e)}${null==r?"":n}`):`${S.toLat(this.lat,t,e)}, ${S.toLon(this.lon,t,e)}${null==r?"":n}`}}class x extends O{constructor(t,e,r){super(t,e,r)}toLatLon(t=N.WGS84){if(!t||!t.a)throw new TypeError(`invalid ellipsoid ‘${t}’`);const{x:e,y:r,z:n}=this,{a:o,b:i,f:a}=t,s=2*a-a*a,u=s/(1-s),c=Math.sqrt(e*e+r*r),l=i*n/(o*c)*(1+u*i/Math.sqrt(c*c+n*n)),f=l/Math.sqrt(1+l*l),p=f/l,h=isNaN(p)?0:Math.atan2(n+u*i*f*f*f,c-s*o*p*p*p),d=Math.atan2(r,e),y=Math.sin(h),m=c*Math.cos(h)+n*y-o*o/(o/Math.sqrt(1-s*y*y));return new j(h.toDegrees(),d.toDegrees(),m)}toString(t=0){return`[${this.x.toFixed(t)},${this.y.toFixed(t)},${this.z.toFixed(t)}]`}}const _={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}},P={ED50:{ellipsoid:_.Intl1924,transform:[89.5,93.8,123.1,-1.2,0,0,.156]},ETRS89:{ellipsoid:_.GRS80,transform:[0,0,0,0,0,0,0]},Irl1975:{ellipsoid:_.AiryModified,transform:[-482.53,130.596,-564.557,-8.15,1.042,.214,.631]},NAD27:{ellipsoid:_.Clarke1866,transform:[8,-160,-176,0,0,0,0]},NAD83:{ellipsoid:_.GRS80,transform:[.9956,-1.9103,-.5215,-62e-5,.025915,.009426,.011599]},NTF:{ellipsoid:_.Clarke1880IGN,transform:[168,60,-320,0,0,0,0]},OSGB36:{ellipsoid:_.Airy1830,transform:[-446.448,125.157,-542.06,20.4894,-.1502,-.247,-.8421]},Potsdam:{ellipsoid:_.Bessel1841,transform:[-582,-105,-414,-8.3,1.04,.35,-3.08]},TokyoJapan:{ellipsoid:_.Bessel1841,transform:[148,-507,-685,0,0,0,0]},WGS72:{ellipsoid:_.WGS72,transform:[0,0,-4.5,-.22,0,0,.554]},WGS84:{ellipsoid:_.WGS84,transform:[0,0,0,0,0,0,0]}};Object.keys(_).forEach(t=>Object.freeze(_[t])),Object.keys(P).forEach(t=>{Object.freeze(P[t]),Object.freeze(P[t].transform)});class k extends j{constructor(t,e,r=0,n=P.WGS84){if(!n||null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(t,e,r),this._datum=n}get datum(){return this._datum}static get ellipsoids(){return _}static get datums(){return P}static parse(...t){let e=P.WGS84;if((4==t.length||3==t.length&&"object"==typeof t[2])&&(e=t.pop()),!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);const r=super.parse(...t);return r._datum=e,r}convertDatum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);return this.toCartesian().convertDatum(t).toLatLon()}toCartesian(){const t=super.toCartesian();return new G(t.x,t.y,t.z,this.datum)}}class G extends x{constructor(t,e,r,n=void 0){if(n&&null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(t,e,r),n&&(this._datum=n)}get datum(){return this._datum}set datum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);this._datum=t}toLatLon(t=void 0){t&&(console.info("datum parameter to Cartesian_Datum.toLatLon is deprecated: set datum before calling toLatLon()"),this.datum=t);const e=this.datum||P.WGS84;if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);const r=super.toLatLon(e.ellipsoid);return new k(r.lat,r.lon,r.height,this.datum)}convertDatum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);if(!this.datum)throw new TypeError("cartesian coordinate has no datum");let e=null,r=null;null!=this.datum&&this.datum!=P.WGS84||(e=this,r=t.transform),t==P.WGS84&&(e=this,r=this.datum.transform.map(t=>-t)),null==r&&(e=this.convertDatum(P.WGS84),r=t.transform);const n=e.applyTransform(r);return n.datum=t,n}applyTransform(t){const{x:e,y:r,z:n}=this,o=t[0],i=t[1],a=t[2],s=t[3]/1e6+1,u=(t[4]/3600).toRadians(),c=(t[5]/3600).toRadians(),l=(t[6]/3600).toRadians();return new G(o+e*s-r*l+n*c,i+e*l+r*s-n*u,a-e*c+r*u+n*s)}}const M={trueOrigin:{lat:49,lon:-2},falseOrigin:{easting:-4e5,northing:1e5},scaleFactor:.9996012717,ellipsoid:k.ellipsoids.Airy1830};class R{constructor(t,e){if(this.easting=Number(t),this.northing=Number(e),isNaN(t)||this.easting<0||this.easting>7e5)throw new RangeError(`invalid easting ‘${t}’`);if(isNaN(e)||this.northing<0||this.northing>13e5)throw new RangeError(`invalid northing ‘${e}’`)}toLatLon(t=k.datums.WGS84){const{easting:e,northing:r}=this,{a:n,b:o}=M.ellipsoid,i=M.trueOrigin.lat.toRadians(),a=M.trueOrigin.lon.toRadians(),s=-M.falseOrigin.easting,u=-M.falseOrigin.northing,c=M.scaleFactor,l=1-o*o/(n*n),f=(n-o)/(n+o),p=f*f,h=f*f*f;let d=i,y=0;do{d=(r-u-y)/(n*c)+d,y=o*c*((1+f+5/4*p+5/4*h)*(d-i)-(3*f+3*f*f+21/8*h)*Math.sin(d-i)*Math.cos(d+i)+(15/8*p+15/8*h)*Math.sin(2*(d-i))*Math.cos(2*(d+i))-35/24*h*Math.sin(3*(d-i))*Math.cos(3*(d+i)))}while(Math.abs(r-u-y)>=1e-5);const m=Math.cos(d),b=Math.sin(d),g=n*c/Math.sqrt(1-l*b*b),v=n*c*(1-l)/Math.pow(1-l*b*b,1.5),w=g/v-1,S=Math.tan(d),E=S*S,O=E*E,N=1/m,T=g*g*g,j=T*g*g,x=e-s,_=x*x,P=_*x,G=_*_,R=P*_;d=d-S/(2*v*g)*_+S/(24*v*T)*(5+3*E+w-9*E*w)*G-S/(720*v*j)*(61+90*E+45*O)*(G*_);const A=a+N/g*x-N/(6*T)*(g/v+2*E)*P+N/(120*j)*(5+28*E+24*O)*R-N/(j*g*g*5040)*(61+662*E+1320*O+O*E*720)*(R*_);let C=new D(d.toDegrees(),A.toDegrees(),0,k.datums.OSGB36);return t!=k.datums.OSGB36&&(C=C.convertDatum(t),C=new D(C.lat,C.lon,C.height,C.datum)),C}static parse(t){let e=(t=String(t).trim()).match(/^(\d+),\s*(\d+)$/);if(e)return new R(e[1],e[2]);if(e=t.match(/^[HNST][ABCDEFGHJKLMNOPQRSTUVWXYZ]\s*[0-9]+\s*[0-9]+$/i),!e)throw new Error(`invalid grid reference ‘${t}’`);let r=t.toUpperCase().charCodeAt(0)-"A".charCodeAt(0),n=t.toUpperCase().charCodeAt(1)-"A".charCodeAt(0);r>7&&r--,n>7&&n--;const o=(r-2)%5*5+n%5,i=19-5*Math.floor(r/5)-Math.floor(n/5);let a=t.slice(2).trim().split(/\s+/);if(1==a.length&&(a=[a[0].slice(0,a[0].length/2),a[0].slice(a[0].length/2)]),a[0].length!=a[1].length)throw new Error(`invalid grid reference ‘${t}’`);a[0]=a[0].padEnd(5,"0"),a[1]=a[1].padEnd(5,"0");const s=o+a[0],u=i+a[1];return new R(s,u)}toString(t=10){if(![0,2,4,6,8,10,12,14,16].includes(Number(t)))throw new RangeError(`invalid precision ‘${t}’`);let{easting:e,northing:r}=this;if(0==t){const t={useGrouping:!1,minimumIntegerDigits:6,maximumFractionDigits:3};return`${e.toLocaleString("en",t)},${r.toLocaleString("en",t)}`}const n=Math.floor(e/1e5),o=Math.floor(r/1e5);let i=19-o-(19-o)%5+Math.floor((n+10)/5),a=5*(19-o)%25+n%5;i>7&&i++,a>7&&a++;const s=String.fromCharCode(i+"A".charCodeAt(0),a+"A".charCodeAt(0));return e=Math.floor(e%1e5/Math.pow(10,5-t/2)),r=Math.floor(r%1e5/Math.pow(10,5-t/2)),e=e.toString().padStart(t/2,"0"),r=r.toString().padStart(t/2,"0"),`${s} ${e} ${r}`}}class D extends k{toOsGrid(){const t=this.datum==k.datums.OSGB36?this:this.convertDatum(k.datums.OSGB36),e=t.lat.toRadians(),r=t.lon.toRadians(),{a:n,b:o}=M.ellipsoid,i=M.trueOrigin.lat.toRadians(),a=M.trueOrigin.lon.toRadians(),s=-M.falseOrigin.easting,u=-M.falseOrigin.northing,c=M.scaleFactor,l=1-o*o/(n*n),f=(n-o)/(n+o),p=f*f,h=f*f*f,d=Math.cos(e),y=Math.sin(e),m=n*c/Math.sqrt(1-l*y*y),b=n*c*(1-l)/Math.pow(1-l*y*y,1.5),g=m/b-1,v=o*c*((1+f+5/4*p+5/4*h)*(e-i)-(3*f+3*f*f+21/8*h)*Math.sin(e-i)*Math.cos(e+i)+(15/8*p+15/8*h)*Math.sin(2*(e-i))*Math.cos(2*(e+i))-35/24*h*Math.sin(3*(e-i))*Math.cos(3*(e+i))),w=d*d*d,S=w*d*d,E=Math.tan(e)*Math.tan(e),O=E*E,N=r-a,T=N*N,j=T*N,x=j*N,_=x*N;let P=v+u+m/2*y*d*T+m/24*y*w*(5-E+9*g)*x+m/720*y*S*(61-58*E+O)*(_*N),G=s+m*d*N+m/6*w*(m/b-E)*j+m/120*S*(5-18*E+O+14*g-58*E*g)*_;P=Number(P.toFixed(3)),G=Number(G.toFixed(3));try{return new R(G,P)}catch(e){throw new Error(`${e.message} from (${t.lat.toFixed(6)},${t.lon.toFixed(6)}).toOsGrid()`)}}convertDatum(t){const e=super.convertDatum(t);return new D(e.lat,e.lon,e.height,e.datum)}}function A(t){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}var C;function I(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function L(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?I(Object(r),!0).forEach(function(e){$(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function $(t,e,r){return(e=function(t){var e=function(t){if("object"!=A(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=A(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==A(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var F=500,W=function(t){var e=t.GAZETTEER_ENTRY,r="eng"===e.NAME2_LANG?e.NAME2:e.NAME1;return t.GAZETTEER_ENTRY.NAME1=r,t.GAZETTEER_ENTRY.NAME1_LANG="eng",t},U=function(t,e){var r,n,o,i,a=e.MBR_XMIN,s=e.MBR_YMIN,u=e.MBR_XMAX,c=e.MBR_YMAX,l=e.GEOMETRY_X,f=e.GEOMETRY_Y;if(null==a?(r=l-F,n=f-F,o=l+F,i=f+F):(r=a,n=s,o=u,i=c),"EPSG:27700"===t)return[r,n,o,i];if("EPSG:4326"===t){var p=new R(r,n).toLatLon(),h=new R(o,i).toLatLon();return[p.lon,p.lat,h.lon,h.lat].map(function(t){return Math.round(1e6*t)/1e6})}throw new Error("Unsupported CRS: ".concat(t))},B=function(t,e){var r=e.GEOMETRY_X,n=e.GEOMETRY_Y;if("EPSG:27700"===t)return[r,n];if("EPSG:4326"===t){var o=new R(r,n).toLatLon();return[Math.round(1e6*o.lon)/1e6,Math.round(1e6*o.lat)/1e6]}throw new Error("Unsupported CRS: ".concat(t))};function z(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function V(t){return function(t){if(Array.isArray(t))return q(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||H(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Y(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=H(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function H(t,e){if(t){if("string"==typeof t)return q(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(t,e):void 0}}function q(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Z(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return K(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,r){return i=e,s=0,u=t,p.n=r,a}};function h(r,n){for(s=r,u=n,e=0;!f&&c&&!o&&e<l.length;e++){var o,i=l[e],h=p.p,d=i[2];r>3?(o=d===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=r<2&&h<i[1])?(s=0,p.v=n,p.n=i[1]):h<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,d){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,d),s=l,u=d;(e=s<2?t:u)||!f;){i||(s?s<3?(s>1&&(p.n=-1),h(s,u)):p.n=u:p.v=u);try{if(c=2,i){if(s||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(K(e={},n,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,K(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,K(f,"constructor",c),K(c,"constructor",u),u.displayName="GeneratorFunction",K(c,o,"GeneratorFunction"),K(f),K(f,o,"Generator"),K(f,n,function(){return this}),K(f,"toString",function(){return"[object Generator]"}),(Z=function(){return{w:i,m:p}})()}function K(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}K=function(t,e,r,n){function i(e,r){K(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},K(t,e,r,n)}function X(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function J(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){X(i,n,o,a,s,"next",t)}function s(t){X(i,n,o,a,s,"throw",t)}a(void 0)})}}var Q=function(t){return t.replaceAll(/[^a-zA-Z0-9\s\-.,]/g,"").trim()},tt=function(t){var e=t.url,r=t.options;return new Request(e,r)},et=function(){var t=J(Z().m(function t(e,r,n){var o,i,a,s;return Z().w(function(t){for(;;)switch(t.n){case 0:if(i={url:null===(o=e.urlTemplate)||void 0===o?void 0:o.replace("{query}",encodeURIComponent(r)),options:{method:"GET"}},!e.buildRequest){t.n=1;break}return a=e.buildRequest(r,function(){return i}),t.a(2,a instanceof Request?a:tt(a));case 1:if(!n){t.n=3;break}return s=tt,t.n=2,n(i,r);case 2:return t.a(2,s(t.v));case 3:return t.a(2,tt(i))}},t)}));return function(e,r,n){return t.apply(this,arguments)}}(),rt=function(){var t=J(Z().m(function t(e,r,n){var o,i,a;return Z().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,fetch(r);case 1:if((o=t.v).ok){t.n=2;break}return console.error("Fetch error for ".concat(e.label||"dataset",": ").concat(o.status)),t.a(2,{error:!0});case 2:return t.n=3,o.json();case 3:return i=t.v,t.a(2,e.parseResults(i,n));case 4:return t.p=4,a=t.v,console.error("Network error for ".concat(e.label||"dataset",":"),a),t.a(2,{error:!0})}},t,null,[[0,4]])}));return function(e,r,n){return t.apply(this,arguments)}}(),nt=function(){var t=J(Z().m(function t(e,r,n,o){var i,a,s,u,c,l,f,p,h,d;return Z().w(function(t){for(;;)switch(t.p=t.n){case 0:i=Q(e),a=r.filter(function(t){var r=!t.includeRegex||t.includeRegex.test(e),n=!!t.excludeRegex&&t.excludeRegex.test(i);return r&&!n}),s=[],u=!1,c=Y(a),t.p=1,c.s();case 2:if((l=c.n()).done){t.n=6;break}return f=l.value,t.n=3,et(f,i,o);case 3:return p=t.v,t.n=4,rt(f,p,i);case 4:if(null!=(h=t.v)&&h.error?u=!0:null!=h&&h.length&&(s=[].concat(V(s),V(h))),!f.exclusive||!s.length){t.n=5;break}return t.a(3,6);case 5:t.n=2;break;case 6:t.n=8;break;case 7:t.p=7,d=t.v,c.e(d);case 8:return t.p=8,c.f(),t.f(8);case 9:return n({type:"UPDATE_SUGGESTIONS",payload:{results:s,hasError:u}}),t.a(2,{results:s,sanitisedValue:i})}},t,null,[[1,7,8,9]])}));return function(e,r,n,o){return t.apply(this,arguments)}}();function ot(t){var e=t.mapProvider,r=t.bounds,n=t.point,o=t.markers,i=t.showMarker,a=t.markerOptions;e.fitToBounds(r),i&&o.add("search",n,a)}var it=r(604);function at(t){return at="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},at(t)}function st(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return ut(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,r){return i=e,s=0,u=t,p.n=r,a}};function h(r,n){for(s=r,u=n,e=0;!f&&c&&!o&&e<l.length;e++){var o,i=l[e],h=p.p,d=i[2];r>3?(o=d===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=r<2&&h<i[1])?(s=0,p.v=n,p.n=i[1]):h<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,d){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,d),s=l,u=d;(e=s<2?t:u)||!f;){i||(s?s<3?(s>1&&(p.n=-1),h(s,u)):p.n=u:p.v=u);try{if(c=2,i){if(s||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=i.return)&&e.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(ut(e={},n,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,ut(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,ut(f,"constructor",c),ut(c,"constructor",u),u.displayName="GeneratorFunction",ut(c,o,"GeneratorFunction"),ut(f),ut(f,o,"Generator"),ut(f,n,function(){return this}),ut(f,"toString",function(){return"[object Generator]"}),(st=function(){return{w:i,m:p}})()}function ut(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}ut=function(t,e,r,n){function i(e,r){ut(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},ut(t,e,r,n)}function ct(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function lt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ct(Object(r),!0).forEach(function(e){ft(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ct(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function ft(t,e,r){return(e=function(t){var e=function(t){if("object"!=at(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=at(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==at(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pt(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function dt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function yt(t,e,r){return(e=function(t){var e=function(t){if("object"!=ht(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ht(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ht(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function mt(t){return mt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mt(t)}function bt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function gt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?bt(Object(r),!0).forEach(function(e){vt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):bt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function vt(t,e,r){return(e=function(t){var e=function(t){if("object"!=mt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=mt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function wt(t){var e,r,n,o=t.dispatch,i=t.searchContainerRef,a=(e=function(e){return nt(e,t.datasets,o,t.transformRequest)},r=null,n=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(function(){e.apply(void 0,n)},350)},n.cancel=function(){r&&(clearTimeout(r),r=null)},n),s=function(t){var e=t.dispatch,r=t.services,n=t.viewportRef,o=t.mapProvider,i=t.markers,a=t.datasets,s=t.transformRequest,u=t.showMarker,c=t.markerOptions,l="";return{handleOpenClick:function(){e({type:"TOGGLE_EXPANDED",payload:!0}),r.eventBus.emit("search:open")},handleCloseClick:function(t,n){e({type:"TOGGLE_EXPANDED",payload:!1}),e({type:"UPDATE_SUGGESTIONS",payload:{results:[],hasError:!1}}),e({type:"SET_VALUE",payload:""}),setTimeout(function(){return n.current.focus()},0),i.remove("search"),r.eventBus.emit("search:clear"),r.eventBus.emit("search:close")},handleSubmit:function(t,f,p){return(h=st().m(function h(){var d,y,m,b,g,v,w,S,E,O,N,T;return st().w(function(h){for(;;)switch(h.n){case 0:if(t.preventDefault(),d=p.suggestions,y=p.selectedIndex,m=p.value,b=null==m?void 0:m.trim(),e({type:"SET_SELECTED",payload:-1}),e({type:"HIDE_SUGGESTIONS"}),!(y>=0)){h.n=1;break}return v=d[y],e({type:"SET_VALUE",payload:v.text}),null===(g=n.current)||void 0===g||g.focus(),ot({mapProvider:o,bounds:v.bounds,point:v.point,markers:i,showMarker:u,markerOptions:c}),r.eventBus.emit("search:match",lt({query:v.text},v)),h.a(2);case 1:if(!((null==b?void 0:b.length)<it.z.minSearchLength)){h.n=2;break}return h.a(2);case 2:if(w=d,d.length&&b===l){h.n=4;break}return h.n=3,nt(b,a,e,s);case 3:S=h.v,E=S.results,O=S.sanitisedValue,w=E,l=O;case 4:w.length&&(null===(N=n.current)||void 0===N||N.focus(),"mobile"===f.breakpoint&&(e({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close")),T=w[0],ot({mapProvider:o,bounds:T.bounds,point:T.point,markers:i,showMarker:u,markerOptions:c}),r.eventBus.emit("search:match",lt({query:m},T)));case 5:return h.a(2)}},h)}),function(){var t=this,e=arguments;return new Promise(function(r,n){var o=h.apply(t,e);function i(t){pt(o,r,n,i,a,"next",t)}function a(t){pt(o,r,n,i,a,"throw",t)}i(void 0)})})();var h}}}(t),u=function(t){var e=t.dispatch,r=t.debouncedFetchSuggestions;return{handleInputClick:function(){e({type:"SHOW_SUGGESTIONS"})},handleInputFocus:function(t){e({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:"keyboard"===t})},handleInputBlur:function(t){e({type:"INPUT_BLUR",payload:t})},handleInputChange:function(t){var n=t.target.value;if(e({type:"SET_VALUE",payload:n}),n.length<it.z.minSearchLength)return r.cancel(),e({type:"UPDATE_SUGGESTIONS",payload:{results:[],hasError:!1}}),void e({type:"HIDE_SUGGESTIONS"});e({type:"SHOW_SUGGESTIONS"}),r(n)}}}(gt(gt({},t),{},{debouncedFetchSuggestions:a})),c=function(t){var e=t.dispatch,r=t.services,n=t.mapProvider,o=t.markers,i=t.showMarker,a=t.markerOptions,s=t.viewportRef,u=function(t,e){var r;return e>=0?"".concat(null===(r=t[e])||void 0===r?void 0:r.text,". ").concat(e+1," of ").concat(t.length," is highlighted"):"".concat(t.length," suggestions available")};return{handleSuggestionClick:function(t,u){var c;e({type:"SET_VALUE",payload:t.text}),e({type:"HIDE_SUGGESTIONS"}),e({type:"SET_SELECTED",payload:-1}),"mobile"===u.breakpoint&&(e({type:"TOGGLE_EXPANDED",payload:!1}),r.eventBus.emit("search:close")),null===(c=s.current)||void 0===c||c.focus(),ot({mapProvider:n,bounds:t.bounds,point:t.point,markers:o,showMarker:i,markerOptions:a}),r.eventBus.emit("search:match",function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?dt(Object(r),!0).forEach(function(e){yt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):dt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({query:t.text},t))},handleInputKeyDown:function(t,n){var o=n.suggestions,i=n.selectedIndex;switch(t.key){case"ArrowDown":if(null==o||!o.length)return;if(t.preventDefault(),i<o.length-1){var a=i+1;r.announce(u(o,a)),e({type:"SET_SELECTED",payload:a}),e({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:!1})}break;case"ArrowUp":if(null==o||!o.length)return;t.preventDefault();var s=i>0?i-1:-1;r.announce(u(o,s)),e({type:"SET_SELECTED",payload:s}),e({type:"SET_KEYBOARD_FOCUS_WITHIN",payload:s<0});break;case"Escape":t.preventDefault(),e({type:"HIDE_SUGGESTIONS"}),e({type:"SET_SELECTED",payload:-1})}}}}(t);return gt(gt(gt(gt({},s),u),c),{},{handleOutside:function(e){i.current.contains(e.target)||(o({type:"TOGGLE_EXPANDED",payload:!1}),t.services.eventBus.emit("search:close"))}})}function St(t){return St="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},St(t)}var Et=["marker"];function Ot(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Nt(t,e,r){return(e=function(t){var e=function(t){if("object"!=St(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=St(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==St(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Tt={reducer:{initialState:{isExpanded:!1,hasKeyboardFocusWithin:!1,value:"",suggestions:[],areSuggestionsVisible:!1,hasFetchedSuggestions:!1,hasSearchError:!1,selectedIndex:-1},actions:s},controls:[{id:"search",mobile:{slot:"top-right",showLabel:!1},tablet:{slot:"top-left",showLabel:!1},desktop:{slot:"top-left",showLabel:!1},render:function(t){var e,r=t.appConfig,n=t.iconRegistry,o=t.pluginState,i=t.pluginConfig,a=t.appState,s=t.mapState,f=t.services,p=t.mapProvider,h=r.id,d=a.interfaceType,y=i.expanded,v=i.customDatasets,w=i.osNamesURL,S=i.regions,E=i.maxSuggestions,O=o.dispatch,N=o.isExpanded,T=o.areSuggestionsVisible,j=o.suggestions,x=(null==a||null===(e=a.controlConfig)||void 0===e||null===(e=e.search)||void 0===e?void 0:e[null==a?void 0:a.breakpoint].showLabel)||!1,_=n.close,P=n.search,k=(0,u.useRef)(null),G=(0,u.useRef)(null),M=(0,u.useRef)(null),R=a.layoutRefs.viewportRef,D=function(t){var e,r=t.customDatasets,n=void 0===r?[]:r,o=t.osNamesURL,i=t.crs,a=t.regions,s=void 0===a?["england","scotland","wales"]:a,u=t.maxSuggestions;return o?[].concat([{name:"osNames",urlTemplate:o,parseResults:function(t,e){return function(t,e,r,n){var o,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:8;if(!t||t.error||0===(null===(o=t.header)||void 0===o?void 0:o.totalresults))return[];var a=t.results;return a=function(t,e){var r=e.toLowerCase().replace(/,/g,"").split(" ");return t.map(W).filter(function(t){return r.some(function(r){return t.GAZETTEER_ENTRY.NAME1.toLowerCase().includes(r)||(n=(n=e).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})})}(a,e),a=function(t,e){return t.filter(function(t){var r,n=null==t||null===(r=t.GAZETTEER_ENTRY)||void 0===r||null===(r=r.COUNTRY)||void 0===r?void 0:r.toLowerCase();return n&&e.includes(n)})}(a=function(t){return Array.from(new Map(t.map(function(t){return[t.GAZETTEER_ENTRY.ID,t]})).values())}(a),r),(a=a.slice(0,i)).map(function(t){return L(L({id:t.GAZETTEER_ENTRY.ID,bounds:U(n,t.GAZETTEER_ENTRY),point:B(n,t.GAZETTEER_ENTRY)},function(t,e){var r,n,o,i,a,s,u=e.NAME1,c=e.COUNTY_UNITARY,l=e.DISTRICT_BOROUGH,f=e.POSTCODE_DISTRICT,p=e.LOCAL_TYPE,h="".concat(["City","Postcode"].includes(p)?"":f+", ").concat("City"===p?"":c||l),d="".concat(u).concat(h?", "+h:"");return{text:d,marked:(r=d,n=t,a=n.replace(/\s+/g,"").split("").join(String.raw(C||(o=["s*"],(i=["\\s*"])||(i=o.slice(0)),C=Object.freeze(Object.defineProperties(o,{raw:{value:Object.freeze(i)}}))))),s=new RegExp("(".concat(a,")"),"i"),r.replace(s,"<mark>$1</mark>"))}}(e,t.GAZETTEER_ENTRY)),{},{type:"os-names"})})}(t,e,s,i,u)},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}],function(t){if(Array.isArray(t))return z(t)}(e=n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return z(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?z(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):n}({customDatasets:v,osNamesURL:w,regions:S,maxSuggestions:E,crs:p.crs}),A=(0,u.useRef)(null);if(!A.current){var I=i.marker,$=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],-1===e.indexOf(r)&&{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(i,Et);A.current=wt(function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ot(Object(r),!0).forEach(function(e){Nt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ot(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({dispatch:O,datasets:D,services:f,mapProvider:p,viewportRef:R,searchContainerRef:k,markers:s.markers,markerOptions:I},$))}var F=A.current,V=N||!!(y&&T&&j.length);return(0,u.useEffect)(function(){var t;N&&(null===(t=M.current)||void 0===t||t.focus())},[N]),(0,u.useEffect)(function(){if(a.dispatch({type:"TOGGLE_HAS_EXCLUSIVE_CONTROL",payload:N}),V)return R.current.style.pointerEvents="none",document.addEventListener("focusin",F.handleOutside),document.addEventListener("pointerdown",F.handleOutside),function(){R.current.style.pointerEvents="auto",document.removeEventListener("focusin",F.handleOutside),document.removeEventListener("pointerdown",F.handleOutside)}},[N,d,T,j]),(0,c.jsxs)("div",{className:"im-c-search",ref:k,children:[!y&&(0,c.jsx)(l,{id:h,isExpanded:N,onClick:function(){return F.handleOpenClick(a)},buttonRef:G,searchIcon:P,showLabel:x}),(0,c.jsxs)(m,{id:h,pluginState:o,pluginConfig:i,appState:a,inputRef:M,events:F,services:f,children:[(0,c.jsx)(b,{defaultExpanded:y,onClick:function(t){return F.handleCloseClick(t,G,a)},closeIcon:_}),(0,c.jsx)(g,{defaultExpanded:y,onClick:function(t){return F.handleCloseClick(t,G,a)},submitIcon:P})]})]})}}],icons:[{id:"search",svgContent:'<path d="m21 21-4.34-4.34"></path><circle cx="11" cy="11" r="8"></circle>'}]}}}]);
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.searchPlugin=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat},287(e){e.exports=preactJsxRuntime}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>"im-search-plugin.js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="defra.searchPlugin:",o.l=(r,n,i,a)=>{if(e[r])e[r].push(n);else{var c,u;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){c=l;break}}c||(u=!0,(c=document.createElement("script")).charset="utf-8",o.nc&&c.setAttribute("nonce",o.nc),c.setAttribute("data-webpack",t+i),c.src=r),e[r]=[n];var s=(t,n)=>{c.onerror=c.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach(e=>e(n)),t)return t(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=s.bind(null,c.onerror),c.onload=s.bind(null,c.onload),u&&document.head.appendChild(c)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={57:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=i);var a=o.p+o.u(t),c=new Error;o.l(a,r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",c.name="ChunkLoadError",c.type=i,c.request=a,n[1](c)}},"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[a,c,u]=r,f=0;if(a.some(t=>0!==e[t])){for(n in c)o.o(c,n)&&(o.m[n]=c[n]);u&&u(o)}for(t&&t(r);f<a.length;f++)i=a[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function c(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof f?n:f,p=Object.create(c.prototype);return u(p,"_invoke",function(r,n,o){var i,c,u,f=0,p=o||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,s.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!l&&f&&!o&&t<p.length;t++){var o,i=p[t],d=s.p,b=i[2];r>3?(o=b===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,c=0))}if(o||r>1)return a;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,b),c=p,u=b;(t=c<2?e:u)||!l;){i||(c?c<3?(c>1&&(s.n=-1),d(c,u)):s.n=u:s.v=u);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(l=s.n<0)?u:r.call(n,s))!==a)break}catch(t){i=e,c=1,u=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var a={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(u(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,u(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,u(d,"constructor",l),u(l,"constructor",p),p.displayName="GeneratorFunction",u(l,o,"GeneratorFunction"),u(d),u(d,o,"Generator"),u(d,n,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(c=function(){return{w:i,m:b}})()}function u(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}u=function(e,t,r,n){function i(t,r){u(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},u(e,t,r,n)}function f(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r.expanded&&(r.manifest={controls:[{id:"search",mobile:{slot:"banner"}}]}),l(l({showMarker:!0,placeholder:"Search"},r),{},{id:"search",load:(e=c().m(function e(){var t;return c().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(254).then(o.bind(o,335));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){f(i,n,o,a,c,"next",e)}function c(e){f(i,n,o,a,c,"throw",e)}a(void 0)})},function(){return t.apply(this,arguments)})})}return o.d(i,{default:()=>d}),i.default})());
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.searchPlugin=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat},287(e){e.exports=preactJsxRuntime},604(e,t,r){r.d(t,{z:()=>n});var n={expanded:!1,showMarker:!0,placeholder:"Search",minSearchLength:3,maxSuggestions:8,noResultsMessage:"No results available",searchErrorMessage:"Sorry, there was a problem with search"}}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>"im-search-plugin.js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="defra.searchPlugin:",o.l=(r,n,i,a)=>{if(e[r])e[r].push(n);else{var c,u;if(void 0!==i)for(var f=document.getElementsByTagName("script"),s=0;s<f.length;s++){var l=f[s];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){c=l;break}}c||(u=!0,(c=document.createElement("script")).charset="utf-8",o.nc&&c.setAttribute("nonce",o.nc),c.setAttribute("data-webpack",t+i),c.src=r),e[r]=[n];var p=(t,n)=>{c.onerror=c.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach(e=>e(n)),t)return t(n)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=p.bind(null,c.onerror),c.onload=p.bind(null,c.onload),u&&document.head.appendChild(c)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={57:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=i);var a=o.p+o.u(t),c=new Error;o.l(a,r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",c.name="ChunkLoadError",c.type=i,c.request=a,n[1](c)}},"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[a,c,u]=r,f=0;if(a.some(t=>0!==e[t])){for(n in c)o.o(c,n)&&(o.m[n]=c[n]);u&&u(o)}for(t&&t(r);f<a.length;f++)i=a[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};o.d(i,{default:()=>b});var a=o(604);function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function u(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,s=Object.create(u.prototype);return f(s,"_invoke",function(r,n,o){var i,c,u,f=0,s=o||[],l=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,p.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!l&&f&&!o&&t<s.length;t++){var o,i=s[t],d=p.p,b=i[2];r>3?(o=b===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,p.v=n,p.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,p.n=b,c=0))}if(o||r>1)return a;throw l=!0,n}return function(o,s,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===s&&d(s,b),c=s,u=b;(t=c<2?e:u)||!l;){i||(c?c<3?(c>1&&(p.n=-1),d(c,u)):p.n=u:p.v=u);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(l=p.n<0)?u:r.call(n,p))!==a)break}catch(t){i=e,c=1,u=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),s}var a={};function c(){}function s(){}function l(){}t=Object.getPrototypeOf;var p=[][n]?t(t([][n]())):(f(t={},n,function(){return this}),t),d=l.prototype=c.prototype=Object.create(p);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,f(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=l,f(d,"constructor",l),f(l,"constructor",s),s.displayName="GeneratorFunction",f(l,o,"GeneratorFunction"),f(d),f(d,o,"Generator"),f(d,n,function(){return this}),f(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:b}})()}function f(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}f=function(e,t,r,n){function i(t,r){f(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},f(e,t,r,n)}function s(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}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 p(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){d(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}function d(e,t,r){return(t=function(e){var t=function(e){if("object"!=c(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return p(p(p(p({},a.z),r),r.expanded&&{manifest:{controls:[{id:"search",mobile:{slot:"banner"}}]}}),{},{id:"search",load:(e=u().m(function e(){var t;return u().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(254).then(o.bind(o,70));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){s(i,n,o,a,c,"next",e)}function c(e){s(i,n,o,a,c,"throw",e)}a(void 0)})},function(){return t.apply(this,arguments)})})}return i.default})());
@@ -10,7 +10,7 @@ import { attachEvents } from './events/index.js'
10
10
  export function Search ({ appConfig, iconRegistry, pluginState, pluginConfig, appState, mapState, services, mapProvider }) {
11
11
  const { id } = appConfig
12
12
  const { interfaceType } = appState
13
- const { expanded: defaultExpanded, customDatasets, osNamesURL, regions } = pluginConfig
13
+ const { expanded: defaultExpanded, customDatasets, osNamesURL, regions, maxSuggestions } = pluginConfig
14
14
  const { dispatch, isExpanded, areSuggestionsVisible, suggestions } = pluginState
15
15
  const showLabel = appState?.controlConfig?.search?.[appState?.breakpoint].showLabel || false
16
16
  const closeIcon = iconRegistry.close
@@ -25,6 +25,7 @@ export function Search ({ appConfig, iconRegistry, pluginState, pluginConfig, ap
25
25
  customDatasets,
26
26
  osNamesURL,
27
27
  regions,
28
+ maxSuggestions,
28
29
  crs: mapProvider.crs
29
30
  })
30
31