@defra/interactive-map 0.0.6-alpha → 0.0.7-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 (61) hide show
  1. package/dist/css/index.css +1 -1
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/umd/im-core.js +1 -1
  4. package/docs/api.md +10 -5
  5. package/package.json +56 -4
  6. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +2 -0
  7. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js.LICENSE.txt +1 -0
  8. package/plugins/beta/draw-es/dist/esm/index.js +2 -0
  9. package/plugins/beta/draw-es/dist/esm/index.js.LICENSE.txt +1 -0
  10. package/plugins/beta/draw-ml/dist/css/index.css +1 -1
  11. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  12. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  13. package/plugins/beta/draw-ml/src/DrawInit.jsx +15 -0
  14. package/plugins/beta/draw-ml/src/api/deleteFeature.js +4 -4
  15. package/plugins/beta/draw-ml/src/api/editFeature.js +10 -5
  16. package/plugins/beta/draw-ml/src/draw.scss +1 -0
  17. package/plugins/beta/draw-ml/src/events.js +2 -0
  18. package/plugins/beta/draw-ml/src/manifest.js +18 -43
  19. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +35 -1
  20. package/plugins/beta/draw-ml/src/modes/editVertexMode.js +17 -1
  21. package/plugins/interact/dist/css/index.css +1 -1
  22. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  23. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  24. package/plugins/interact/src/defaults.js +1 -0
  25. package/plugins/interact/src/events.js +6 -1
  26. package/plugins/interact/src/events.test.js +19 -5
  27. package/plugins/interact/src/hooks/useInteractionHandlers.js +7 -2
  28. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +28 -0
  29. package/plugins/interact/src/interact.scss +1 -0
  30. package/plugins/interact/src/manifest.js +22 -16
  31. package/plugins/interact/src/manifest.test.js +1 -1
  32. package/plugins/interact/src/reducer.js +1 -0
  33. package/plugins/interact/src/reducer.test.js +1 -0
  34. package/providers/beta/esri/dist/css/im-esri-provider.css +1 -0
  35. package/providers/beta/esri/dist/esm/im-esri-provider.js +2 -0
  36. package/providers/beta/esri/dist/esm/im-esri-provider.js.LICENSE.txt +1 -0
  37. package/providers/beta/esri/dist/esm/index.js +2 -0
  38. package/providers/beta/esri/dist/esm/index.js.LICENSE.txt +1 -0
  39. package/providers/beta/esri/src/esriProvider.js +12 -0
  40. package/providers/beta/esri/src/mapEvents.js +2 -2
  41. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  42. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  43. package/providers/maplibre/src/maplibreProvider.js +11 -1
  44. package/providers/maplibre/src/utils/highlightFeatures.js +6 -2
  45. package/src/App/components/Actions/Actions.jsx +2 -1
  46. package/src/App/components/Actions/Actions.module.scss +14 -0
  47. package/src/App/components/Actions/Actions.test.jsx +2 -2
  48. package/src/App/components/MapButton/MapButton.module.scss +19 -6
  49. package/src/App/components/PopupMenu/PopupMenu.jsx +69 -14
  50. package/src/App/components/PopupMenu/PopupMenu.module.scss +70 -7
  51. package/src/App/components/PopupMenu/PopupMenu.test.jsx +102 -16
  52. package/src/App/hooks/useButtonStateEvaluator.js +2 -2
  53. package/src/App/hooks/useInterfaceAPI.js +26 -32
  54. package/src/App/registry/pluginRegistry.js +2 -2
  55. package/src/App/renderer/mapButtons.js +6 -1
  56. package/src/App/renderer/mapButtons.test.js +20 -0
  57. package/src/App/store/MapProvider.jsx +2 -2
  58. package/src/App/store/mapActionsMap.js +3 -2
  59. package/src/App/store/mapReducer.js +1 -0
  60. package/src/scss/settings/_dimensions.scss +1 -0
  61. package/webpack.esm.mjs +19 -10
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see im-maplibre-provider.js.LICENSE.txt */
2
- "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[772],{809(t,e,n){n.r(e),n.d(e,{default:()=>nt});var r=400,a=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"];function o(t){var e=t.getCanvas();e.removeAttribute("role"),e.setAttribute("tabindex",-1),e.removeAttribute("aria-label"),e.style.display="block"}function i(t){var e=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){var n=t.getCanvas();if(n&&(this.target===n||n.contains(this.target)))return}e.call(this)}}var l=function(t,e){var n=null,r=function(){for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];clearTimeout(n),n=setTimeout(function(){t.apply(void 0,a)},e)};return r.cancel=function(){n&&(clearTimeout(n),n=null)},r};function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function u(t){var e=t.map,n=t.events,r=t.eventBus,a=t.getCenter,o=t.getZoom,i=t.getBounds,u=t.getResolution,c=[],h=[],f=function(){var t=o();return{center:a(),bounds:i(),resolution:u(),zoom:t,isAtMaxZoom:e.getMaxZoom()<=t,isAtMinZoom:e.getMinZoom()>=t}},p=function(t,e){return r.emit(t,e)},y=function(){return p(n.MAP_LOADED)};e.on("load",y),c.push(["load",y]),e.once("idle",function(){return p(n.MAP_FIRST_IDLE,f())});var d=function(){return p(n.MAP_MOVE_START)};e.on("movestart",d),c.push(["movestart",d]);var g=l(function(){p(n.MAP_MOVE_END,f())},500);e.on("moveend",g),c.push(["moveend",g]),h.push(g);var v,m,b=(v=function(){p(n.MAP_MOVE,f())},m=0,function(){var t=Date.now();t-m>=10&&(m=t,v.apply(void 0,arguments))});e.on("zoom",b),c.push(["zoom",b]),h.push(b);var M=function(){return p(n.MAP_RENDER)};e.on("render",M),c.push(["render",M]);var w=l(function(){p(n.MAP_DATA_CHANGE,f())},500);e.on("styledata",w),c.push(["styledata",w]),h.push(w);var S=function(){return p(n.MAP_STYLE_CHANGE)};e.on("style.load",S),c.push(["style.load",S]);var x=function(t){return p(n.MAP_CLICK,{point:t.point,coords:[t.lngLat.lng,t.lngLat.lat]})};return e.on("click",x),c.push(["click",x]),{remove:function(){h.forEach(function(t){return t.cancel()}),c.forEach(function(t){var n,r,a=(r=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(n,r)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}(n,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=a[0],i=a[1];return e.off(o,i)})}}}function c(t){var e=t.map,n=t.events,r=t.eventBus,a=function(t){e.setStyle(t.url,{diff:!1})},o=function(t){e.setPixelRatio(t)};return r.on(n.MAP_SET_STYLE,a),r.on(n.MAP_SET_PIXEL_RATIO,o),{remove:function(){r.off(n.MAP_SET_STYLE,a),r.off(n.MAP_SET_PIXEL_RATIO,o)}}}let h=" ";class f{static get separator(){return h}static set separator(t){h=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 n=null;switch(e.length){case 3:n=e[0]/1+e[1]/60+e[2]/3600;break;case 2:n=e[0]/1+e[1]/60;break;case 1:n=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(n=-n),Number(n)}static toDms(t,e="d",n=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===n)switch(e){case"d":case"deg":n=4;break;case"dm":case"deg+min":n=2;break;case"dms":case"deg+min+sec":n=0;break;default:e="d",n=4}t=Math.abs(t);let r=null,a=null,o=null,i=null;switch(e){default:case"d":case"deg":a=t.toFixed(n),a<100&&(a="0"+a),a<10&&(a="0"+a),r=a+"°";break;case"dm":case"deg+min":a=Math.floor(t),o=(60*t%60).toFixed(n),60==o&&(o=(0).toFixed(n),a++),a=("000"+a).slice(-3),o<10&&(o="0"+o),r=a+"°"+f.separator+o+"′";break;case"dms":case"deg+min+sec":a=Math.floor(t),o=Math.floor(3600*t/60)%60,i=(3600*t%60).toFixed(n),60==i&&(i=(0).toFixed(n),o++),60==o&&(o=0,a++),a=("000"+a).slice(-3),o=("00"+o).slice(-2),i<10&&(i="0"+i),r=a+"°"+f.separator+o+"′"+f.separator+i+"″"}return r}static toLat(t,e,n){const r=f.toDms(f.wrap90(t),e,n);return null===r?"–":r.slice(1)+f.separator+(t<0?"S":"N")}static toLon(t,e,n){const r=f.toDms(f.wrap180(t),e,n);return null===r?"–":r+f.separator+(t<0?"W":"E")}static toBrng(t,e,n){const r=f.toDms(f.wrap360(t),e,n);return null===r?"–":r.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),n={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(n.thousands,"⁜").replace(n.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),n={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",n.decimal).replace("⁜",n.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=f.wrap360(t);const n=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*n/360)%n*16/n]}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 p=f,y=Math.PI;class d{constructor(t,e){if(isNaN(t))throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e))throw new TypeError(`invalid lon ‘${e}’`);this._lat=p.wrap90(Number(t)),this._lon=p.wrap180(Number(e))}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?p.wrap90(p.parse(t)):p.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?p.wrap90(p.parse(t)):p.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)?p.wrap180(p.parse(t)):p.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?p.wrap180(p.parse(t)):p.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?p.wrap180(p.parse(t)):p.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");if(null===t[0]||null===t[1])throw new TypeError("invalid (null) point");let e,n;if(2==t.length&&([e,n]=t,e=p.wrap90(p.parse(e)),n=p.wrap180(p.parse(n)),isNaN(e)||isNaN(n)))throw new TypeError(`invalid point ‘${t.toString()}’`);if(1==t.length&&"string"==typeof t[0]&&([e,n]=t[0].split(","),e=p.wrap90(p.parse(e)),n=p.wrap180(p.parse(n)),isNaN(e)||isNaN(n)))throw new TypeError(`invalid point ‘${t[0]}’`);if(1==t.length&&"object"==typeof t[0]){const r=t[0];if("Point"==r.type&&Array.isArray(r.coordinates)?[n,e]=r.coordinates:(null!=r.latitude&&(e=r.latitude),null!=r.lat&&(e=r.lat),null!=r.longitude&&(n=r.longitude),null!=r.lng&&(n=r.lng),null!=r.lon&&(n=r.lon),e=p.wrap90(p.parse(e)),n=p.wrap180(p.parse(n))),isNaN(e)||isNaN(n))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if(isNaN(e)||isNaN(n))throw new TypeError(`invalid point ‘${t.toString()}’`);return new d(e,n)}distanceTo(t,e=6371e3){if(t instanceof d||(t=d.parse(t)),isNaN(e))throw new TypeError(`invalid radius ‘${e}’`);const n=e,r=this.lat.toRadians(),a=this.lon.toRadians(),o=t.lat.toRadians(),i=o-r,l=t.lon.toRadians()-a,s=Math.sin(i/2)*Math.sin(i/2)+Math.cos(r)*Math.cos(o)*Math.sin(l/2)*Math.sin(l/2);return n*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}initialBearingTo(t){if(t instanceof d||(t=d.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),n=t.lat.toRadians(),r=(t.lon-this.lon).toRadians(),a=Math.cos(e)*Math.sin(n)-Math.sin(e)*Math.cos(n)*Math.cos(r),o=Math.sin(r)*Math.cos(n),i=Math.atan2(o,a).toDegrees();return p.wrap360(i)}finalBearingTo(t){t instanceof d||(t=d.parse(t));const e=t.initialBearingTo(this)+180;return p.wrap360(e)}midpointTo(t){t instanceof d||(t=d.parse(t));const e=this.lat.toRadians(),n=this.lon.toRadians(),r=t.lat.toRadians(),a=(t.lon-this.lon).toRadians(),o=Math.cos(e),i=Math.sin(e),l={x:o+Math.cos(r)*Math.cos(a),y:0+Math.cos(r)*Math.sin(a),z:i+Math.sin(r)},s=Math.atan2(l.z,Math.sqrt(l.x*l.x+l.y*l.y)),u=n+Math.atan2(l.y,l.x),c=s.toDegrees(),h=u.toDegrees();return new d(c,h)}intermediatePointTo(t,e){if(t instanceof d||(t=d.parse(t)),this.equals(t))return new d(this.lat,this.lon);const n=this.lat.toRadians(),r=this.lon.toRadians(),a=t.lat.toRadians(),o=t.lon.toRadians(),i=a-n,l=o-r,s=Math.sin(i/2)*Math.sin(i/2)+Math.cos(n)*Math.cos(a)*Math.sin(l/2)*Math.sin(l/2),u=2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)),c=Math.sin((1-e)*u)/Math.sin(u),h=Math.sin(e*u)/Math.sin(u),f=c*Math.cos(n)*Math.cos(r)+h*Math.cos(a)*Math.cos(o),p=c*Math.cos(n)*Math.sin(r)+h*Math.cos(a)*Math.sin(o),y=c*Math.sin(n)+h*Math.sin(a),g=Math.atan2(y,Math.sqrt(f*f+p*p)),v=Math.atan2(p,f),m=g.toDegrees(),b=v.toDegrees();return new d(m,b)}destinationPoint(t,e,n=6371e3){const r=t/n,a=Number(e).toRadians(),o=this.lat.toRadians(),i=this.lon.toRadians(),l=Math.sin(o)*Math.cos(r)+Math.cos(o)*Math.sin(r)*Math.cos(a),s=Math.asin(l),u=Math.sin(a)*Math.sin(r)*Math.cos(o),c=Math.cos(r)-Math.sin(o)*l,h=i+Math.atan2(u,c),f=s.toDegrees(),p=h.toDegrees();return new d(f,p)}static intersection(t,e,n,r){if(t instanceof d||(t=d.parse(t)),n instanceof d||(n=d.parse(n)),isNaN(e))throw new TypeError(`invalid brng1 ‘${e}’`);if(isNaN(r))throw new TypeError(`invalid brng2 ‘${r}’`);const a=t.lat.toRadians(),o=t.lon.toRadians(),i=n.lat.toRadians(),l=n.lon.toRadians(),s=Number(e).toRadians(),u=Number(r).toRadians(),c=i-a,h=l-o,f=2*Math.asin(Math.sqrt(Math.sin(c/2)*Math.sin(c/2)+Math.cos(a)*Math.cos(i)*Math.sin(h/2)*Math.sin(h/2)));if(Math.abs(f)<Number.EPSILON)return new d(t.lat,t.lon);const p=(Math.sin(i)-Math.sin(a)*Math.cos(f))/(Math.sin(f)*Math.cos(a)),g=(Math.sin(a)-Math.sin(i)*Math.cos(f))/(Math.sin(f)*Math.cos(i)),v=Math.acos(Math.min(Math.max(p,-1),1)),m=Math.acos(Math.min(Math.max(g,-1),1)),b=s-(Math.sin(l-o)>0?v:2*y-v),M=(Math.sin(l-o)>0?2*y-m:m)-u;if(0==Math.sin(b)&&0==Math.sin(M))return null;if(Math.sin(b)*Math.sin(M)<0)return null;const w=-Math.cos(b)*Math.cos(M)+Math.sin(b)*Math.sin(M)*Math.cos(f),S=Math.atan2(Math.sin(f)*Math.sin(b)*Math.sin(M),Math.cos(M)+Math.cos(b)*w),x=Math.asin(Math.min(Math.max(Math.sin(a)*Math.cos(S)+Math.cos(a)*Math.sin(S)*Math.cos(s),-1),1)),N=o+Math.atan2(Math.sin(s)*Math.sin(S)*Math.cos(a),Math.cos(S)-Math.sin(a)*Math.sin(x)),P=x.toDegrees(),O=N.toDegrees();return new d(P,O)}crossTrackDistanceTo(t,e,n=6371e3){t instanceof d||(t=d.parse(t)),e instanceof d||(e=d.parse(e));const r=n;if(this.equals(t))return 0;const a=t.distanceTo(this,r)/r,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(a)*Math.sin(o-i))*r}alongTrackDistanceTo(t,e,n=6371e3){t instanceof d||(t=d.parse(t)),e instanceof d||(e=d.parse(e));const r=n;if(this.equals(t))return 0;const a=t.distanceTo(this,r)/r,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians(),l=Math.asin(Math.sin(a)*Math.sin(o-i));return Math.acos(Math.cos(a)/Math.abs(Math.cos(l)))*Math.sign(Math.cos(i-o))*r}maxLatitude(t){const e=Number(t).toRadians(),n=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(n))).toDegrees()}static crossingParallels(t,e,n){if(t.equals(e))return null;const r=Number(n).toRadians(),a=t.lat.toRadians(),o=t.lon.toRadians(),i=e.lat.toRadians(),l=e.lon.toRadians()-o,s=Math.sin(a)*Math.cos(i)*Math.cos(r)*Math.sin(l),u=Math.sin(a)*Math.cos(i)*Math.cos(r)*Math.cos(l)-Math.cos(a)*Math.sin(i)*Math.cos(r),c=Math.cos(a)*Math.cos(i)*Math.sin(r)*Math.sin(l);if(c*c>s*s+u*u)return null;const h=Math.atan2(-u,s),f=Math.acos(c/Math.sqrt(s*s+u*u)),y=o+h+f,d=(o+h-f).toDegrees(),g=y.toDegrees();return{lon1:p.wrap180(d),lon2:p.wrap180(g)}}rhumbDistanceTo(t,e=6371e3){t instanceof d||(t=d.parse(t));const n=e,r=this.lat.toRadians(),a=t.lat.toRadians(),o=a-r;let i=Math.abs(t.lon-this.lon).toRadians();Math.abs(i)>y&&(i=i>0?-(2*y-i):2*y+i);const l=Math.log(Math.tan(a/2+y/4)/Math.tan(r/2+y/4)),s=Math.abs(l)>1e-11?o/l:Math.cos(r);return Math.sqrt(o*o+s*s*i*i)*n}rhumbBearingTo(t){if(t instanceof d||(t=d.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),n=t.lat.toRadians();let r=(t.lon-this.lon).toRadians();Math.abs(r)>y&&(r=r>0?-(2*y-r):2*y+r);const a=Math.log(Math.tan(n/2+y/4)/Math.tan(e/2+y/4)),o=Math.atan2(r,a).toDegrees();return p.wrap360(o)}rhumbDestinationPoint(t,e,n=6371e3){const r=this.lat.toRadians(),a=this.lon.toRadians(),o=Number(e).toRadians(),i=t/n,l=i*Math.cos(o);let s=r+l;Math.abs(s)>y/2&&(s=s>0?y-s:-y-s);const u=Math.log(Math.tan(s/2+y/4)/Math.tan(r/2+y/4)),c=Math.abs(u)>1e-11?l/u:Math.cos(r),h=a+i*Math.sin(o)/c,f=s.toDegrees(),p=h.toDegrees();return new d(f,p)}rhumbMidpointTo(t){t instanceof d||(t=d.parse(t));const e=this.lat.toRadians();let n=this.lon.toRadians();const r=t.lat.toRadians(),a=t.lon.toRadians();Math.abs(a-n)>y&&(n+=2*y);const o=(e+r)/2,i=Math.tan(y/4+e/2),l=Math.tan(y/4+r/2),s=Math.tan(y/4+o/2);let u=((a-n)*Math.log(s)+n*Math.log(l)-a*Math.log(i))/Math.log(l/i);isFinite(u)||(u=(n+a)/2);const c=o.toDegrees(),h=u.toDegrees();return new d(c,h)}static areaOf(t,e=6371e3){const n=e,r=t[0].equals(t[t.length-1]);r||t.push(t[0]);const a=t.length-1;let o=0;for(let e=0;e<a;e++){const n=t[e].lat.toRadians(),r=t[e+1].lat.toRadians(),a=(t[e+1].lon-t[e].lon).toRadians();o+=2*Math.atan2(Math.tan(a/2)*(Math.tan(n/2)+Math.tan(r/2)),1+Math.tan(n/2)*Math.tan(r/2))}(function(t){let e=0,n=t[0].initialBearingTo(t[1]);for(let r=0;r<t.length-1;r++){const a=t[r].initialBearingTo(t[r+1]),o=t[r].finalBearingTo(t[r+1]);e+=(a-n+540)%360-180,e+=(o-a+540)%360-180,n=o}return e+=(t[0].initialBearingTo(t[1])-n+540)%360-180,Math.abs(e)<90})(t)&&(o=Math.abs(o)-2*y);const i=Math.abs(o*n*n);return r||t.pop(),i}equals(t){return t instanceof d||(t=d.parse(t)),!(Math.abs(this.lat-t.lat)>Number.EPSILON||Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e=void 0){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);return"n"==t?(null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`):`${p.toLat(this.lat,t,e)}, ${p.toLon(this.lon,t,e)}`}}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return v(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var m=function(t,e){var n=g(t,2),r=n[0],a=n[1],o=g(e,2),i=o[0],l=o[1],s=new d(a,r),u=new d(l,i);return s.distanceTo(u)},b=function(t){var e=1609.344,n=t/e;if(n<.5/e)return"".concat(Math.round(t),"m");if(n<10){var r=Number.parseFloat(n.toFixed(1)),a=1===r?"mile":"miles";return"".concat(r," ").concat(a)}var o=Math.round(n),i=1===o?"mile":"miles";return"".concat(o," ").concat(i)};function M(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return w(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function S(t){return S="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},S(t)}function x(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function N(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?x(Object(n),!0).forEach(function(e){P(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function P(t,e,n){return(e=function(t){var e=function(t){if("object"!=S(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==S(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function O(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var E="highlighted-label";function j(t,e){if("number"==typeof t)return t;if(!Array.isArray(t)||"interpolate"!==t[0])return function(t,e){var n=t.stops;if(n.length<2)return n.length>0?n[0][1]:0;for(var r=n[0],a=n[n.length-1],o=1;o<n.length;o++){var i=n[o];if(i[0]>e){a=i,r=n[o-1];break}r=n[o-1],a=i}var l=M(r,2),s=l[0],u=l[1],c=M(a,2),h=c[0],f=c[1];return e<=s?u:e>=h?f:u+(e-s)/(h-s)*(f-u)}(t,e);var n,r=function(t){if(Array.isArray(t))return t}(n=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||function(t,e){if(t){if("string"==typeof t)return O(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(t,e):void 0}}(n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),a=r[2],o=O(r).slice(3);if("zoom"!==a[0])throw new Error("Only zoom-based expressions supported");for(var i=0;i<o.length-2;i+=2){var l=o[i],s=o[i+1],u=o[i+2],c=o[i+3];if(e<=l)return s;if(e<=u)return s+(e-l)/(u-l)*(c-s)}return o[o.length-1]}function A(t,e){if(e.highlightLayerId&&t.getLayer(e.highlightLayerId)){try{t.removeLayer(e.highlightLayerId)}catch(t){}e.highlightLayerId=null,e.highlightedExpr=null}}function T(t,e,n){var r,a,o,i;if(null!=e&&null!==(r=e.feature)&&void 0!==r&&r.layer){A(t,n);var l=e.feature,s=e.layer;n.highlightLayerId="highlight-".concat(s.id);var u=l.id,c=l.type,h=l.properties,f=l.geometry;t.getSource(E).setData({id:u,type:c,properties:h,geometry:f}),n.highlightedExpr=s.layout["text-size"];var p=t.getZoom(),y=(a=s,o=1.5*j(n.highlightedExpr,p),i=n.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"},{id:"highlight-".concat(a.id),type:a.type,source:E,layout:N(N({},a.layout),{},{"text-size":o,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90}),paint:N(N({},a.paint),{},{"text-color":i.text,"text-halo-color":i.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1})});t.addLayer(y),t.moveLayer(n.highlightLayerId)}}function R(t){t.getSource(E)||t.addSource(E,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function L(t){t.getStyle().layers.filter(function(t){var e;return"line"===(null===(e=t.layout)||void 0===e?void 0:e["symbol-placement"])}).forEach(function(e){return t.setLayoutProperty(e.id,"symbol-placement","line-center")})}function D(t,e,n,r){var a={isDarkStyle:"dark"===e,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function o(){var e=t.getStyle().layers.filter(function(t){return"symbol"===t.type}),n=t.queryRenderedFeatures({layers:e.map(function(t){return t.id})});a.labels=function(t,e,n){return e.flatMap(function(e){var r,a,o,i,l="string"==typeof(a=null===(r=e.layout)||void 0===r?void 0:r["text-field"])?null===(o=/^{(.+)}$/.exec(a))||void 0===o?void 0:o[1]:Array.isArray(a)?null===(i=a.find(function(t){return Array.isArray(t)&&"get"===t[0]}))||void 0===i?void 0:i[1]:null;return l?n.filter(function(t){var n;return t.layer.id===e.id&&(null===(n=t.properties)||void 0===n?void 0:n[l])}).map(function(n){return function(t,e,n,r){var a=function(t){var e=t.type,n=t.coordinates;if("Point"===e)return n;if("MultiPoint"===e)return n[0];if(e.includes("LineString")){var r="LineString"===e?n:n[0];return[(r[0][0]+r[r.length-1][0])/2,(r[0][1]+r[r.length-1][1])/2]}if(e.includes("Polygon")){var a="Polygon"===e?n[0]:n[0][0],o=a.reduce(function(t,e){return[t[0]+e[0],t[1]+e[1]]},[0,0]);return[o[0]/a.length,o[1]/a.length]}return null}(t.geometry);if(!a)return null;var o=r.project({lng:a[0],lat:a[1]});return{text:t.properties[n],x:o.x,y:o.y,feature:t,layer:e}}(n,e,l,t)}).filter(Boolean):[]})}(t,e,n)}function i(){if(o(),!a.labels.length)return null;var e=t.project(t.getCenter()),n=function(t,e){var n;return null===(n=t.reduce(function(t,n){var r=Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2);return!t||r<t.dist?{label:n,dist:r}:t},null))||void 0===n?void 0:n.label}(a.labels,e);return n&&(a.currentPixel={x:n.x,y:n.y}),T(t,n,a),"".concat(n.text," (").concat(n.layer.id,")")}return L(t),R(t),null==r||r.on(n.MAP_SET_STYLE,function(e){t.once("styledata",function(){return t.once("idle",function(){L(t),R(t),a.isDarkStyle="dark"===(null==e?void 0:e.mapColorScheme)})})}),t.on("zoom",function(){if(a.highlightLayerId&&a.highlightedExpr){var e=j(a.highlightedExpr,t.getZoom());t.setLayoutProperty(a.highlightLayerId,"text-size",1.5*e)}}),function(t){t.getStyle().layers.filter(function(t){return"symbol"===t.type}).forEach(function(e){t.setPaintProperty(e.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(t),{refreshLabels:o,highlightNextLabel:function(e){if(o(),!a.labels.length)return null;if(!a.currentPixel)return i();var n=function(t,e){if(!e.currentPixel)return null;var n=e.labels.map(function(t,e){return{pixel:[t.x,t.y],index:e}}).filter(function(t){return t.pixel[0]!==e.currentPixel.x||t.pixel[1]!==e.currentPixel.y});if(!n.length)return null;var r=n.map(function(t){return t.pixel}),a=function(t,e,n){var r=g(e,2),a=r[0],o=r[1],i=n.filter(function(e){var n=g(e,2),r=n[0],i=n[1];return(r!==a||i!==o)&&function(t,e,n){switch(t){case"ArrowUp":return n<0&&Math.abs(n)>=Math.abs(e);case"ArrowDown":return n>0&&Math.abs(n)>=Math.abs(e);case"ArrowLeft":return e<0&&Math.abs(e)>Math.abs(n);case"ArrowRight":return e>0&&Math.abs(e)>Math.abs(n);default:return!1}}(t,r-a,i-o)});if(!i.length)return n.findIndex(function(t){return t[0]===a&&t[1]===o});var l=-1,s=1/0;return i.forEach(function(t){var e=t[0]-a,r=t[1]-o,i=e*e+r*r;i<s&&(s=i,l=n.indexOf(t))}),l}(t,[e.currentPixel.x,e.currentPixel.y],r);return(null==a||a<0||a>=n.length)&&(a=0),e.labels[n[a].index]}(e,a);return n?(a.currentPixel={x:n.x,y:n.y},T(t,n,a),"".concat(n.text," (").concat(n.layer.id,")")):null},highlightLabelAtCenter:i,clearHighlightedLabel:function(){return A(t,a)}}}function k(t){return k="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},k(t)}function _(t){return function(t){if(Array.isArray(t))return B(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||I(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 I(t,e){if(t){if("string"==typeof t)return B(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?B(t,e):void 0}}function B(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function C(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function F(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?C(Object(n),!0).forEach(function(e){$(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function $(t,e,n){return(e=function(t){var e=function(t){if("object"!=k(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==k(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var z=function(t,e,n,r,a,o,i){t.getLayer(e)||t.addLayer(F(F({id:e,type:n,source:r},a&&{"source-layer":a}),{},{paint:o})),Object.entries(o).forEach(function(n){var r,a,o=(a=2,function(t){if(Array.isArray(t))return t}(r=n)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(r,a)||I(r,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],l=o[1];t.setPaintProperty(e,i,l)}),t.setFilter(e,i)};function q(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Z(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Z(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Z(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var W=function(t,e,n){var r=Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2);if(0===r)return Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2);var a=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/r;return a=Math.max(0,Math.min(1,a)),Math.pow(t.x-(e.x+a*(n.x-e.x)),2)+Math.pow(t.y-(e.y+a*(n.y-e.y)),2)},G=["container","padding","mapStyle","center","zoom","bounds","pixelRatio"];function H(t){return H="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},H(t)}function U(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function o(n,r,a,o){var s=r&&r.prototype instanceof l?r:l,u=Object.create(s.prototype);return Y(u,"_invoke",function(n,r,a){var o,l,s,u=0,c=a||[],h=!1,f={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,n){return o=e,l=0,s=t,f.n=n,i}};function p(n,r){for(l=n,s=r,e=0;!h&&u&&!a&&e<c.length;e++){var a,o=c[e],p=f.p,y=o[2];n>3?(a=y===r)&&(s=o[(l=o[4])?5:(l=3,3)],o[4]=o[5]=t):o[0]<=p&&((a=n<2&&p<o[1])?(l=0,f.v=r,f.n=o[1]):p<y&&(a=n<3||o[0]>r||r>y)&&(o[4]=n,o[5]=r,f.n=y,l=0))}if(a||n>1)return i;throw h=!0,r}return function(a,c,y){if(u>1)throw TypeError("Generator is already running");for(h&&1===c&&p(c,y),l=c,s=y;(e=l<2?t:s)||!h;){o||(l?l<3?(l>1&&(f.n=-1),p(l,s)):f.n=s:f.v=s);try{if(u=2,o){if(l||(a="next"),e=o[a]){if(!(e=e.call(o,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,l<2&&(l=0)}else 1===l&&(e=o.return)&&e.call(o),l<2&&(s=TypeError("The iterator does not provide a '"+a+"' method"),l=1);o=t}else if((e=(h=f.n<0)?s:n.call(r,f))!==i)break}catch(e){o=t,l=1,s=e}finally{u=1}}return{value:e,done:h}}}(n,a,o),!0),u}var i={};function l(){}function s(){}function u(){}e=Object.getPrototypeOf;var c=[][r]?e(e([][r]())):(Y(e={},r,function(){return this}),e),h=u.prototype=l.prototype=Object.create(c);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,Y(t,a,"GeneratorFunction")),t.prototype=Object.create(h),t}return s.prototype=u,Y(h,"constructor",u),Y(u,"constructor",s),s.displayName="GeneratorFunction",Y(u,a,"GeneratorFunction"),Y(h),Y(h,a,"Generator"),Y(h,r,function(){return this}),Y(h,"toString",function(){return"[object Generator]"}),(U=function(){return{w:o,m:f}})()}function Y(t,e,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(t){a=0}Y=function(t,e,n,r){function o(e,n){Y(t,e,function(t){return this._invoke(e,n,t)})}e?a?a(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},Y(t,e,n,r)}function V(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function J(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?V(Object(n),!0).forEach(function(e){K(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function K(t,e,n){return(e=et(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X(t,e){if(null==t)return{};var n,r,a=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;n[r]=t[r]}return n}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(a[n]=t[n])}return a}function Q(t,e,n,r,a,o,i){try{var l=t[o](i),s=l.value}catch(t){return void n(t)}l.done?e(s):Promise.resolve(s).then(r,a)}function tt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,et(r.key),r)}}function et(t){var e=function(t){if("object"!=H(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=H(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==H(e)?e:e+""}var nt=function(){return t=function t(e){var n=e.mapFramework,r=e.mapProviderConfig,o=void 0===r?{}:r,i=e.events,l=e.eventBus;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.maplibreModule=n,this.events=i,this.eventBus=l,this.capabilities={supportedShortcuts:a,supportsMapSizes:!0},Object.assign(this,o)},e=[{key:"initMap",value:(n=U().m(function t(e){var n,r,a,l,s,h,f,p,y,d,g,v,m=this;return U().w(function(t){for(;;)switch(t.n){case 0:n=e.container,r=e.padding,a=e.mapStyle,l=e.center,s=e.zoom,h=e.bounds,f=e.pixelRatio,p=X(e,G),y=this.maplibreModule.Map,d=this.events,g=this.eventBus,(v=new y(J(J({},p),{},{container:n,style:null==a?void 0:a.url,pixelRatio:f,padding:r,center:l,zoom:s,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1}))).touchZoomRotate.disableRotation(),this.map=v,this.map.setPadding(r),h&&v.fitBounds(h,{duration:0}),i(v),o(v),u({map:v,events:d,eventBus:g,getCenter:this.getCenter.bind(this),getZoom:this.getZoom.bind(this),getBounds:this.getBounds.bind(this),getResolution:this.getResolution.bind(this)}),c({map:v,events:d,eventBus:g}),v.on("load",function(){m.labelNavigator=D(v,null==a?void 0:a.mapColorScheme,d,g)}),this.eventBus.emit(d.MAP_READY,{map:v});case 1:return t.a(2)}},t,this)}),l=function(){var t=this,e=arguments;return new Promise(function(r,a){var o=n.apply(t,e);function i(t){Q(o,r,a,i,l,"next",t)}function l(t){Q(o,r,a,i,l,"throw",t)}i(void 0)})},function(t){return l.apply(this,arguments)})},{key:"destroyMap",value:function(){var t,e;null===(t=this.mapEvents)||void 0===t||t.remove(),null===(e=this.appEvents)||void 0===e||e.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}},{key:"setView",value:function(t){var e=t.center,n=t.zoom;this.map.flyTo({center:e||this.getCenter(),zoom:n||this.getZoom(),duration:r})}},{key:"zoomIn",value:function(t){this.map.easeTo({zoom:this.getZoom()+t,duration:r})}},{key:"zoomOut",value:function(t){this.map.easeTo({zoom:this.getZoom()-t,duration:r})}},{key:"panBy",value:function(t){this.map.panBy(t,{duration:r})}},{key:"fitToBounds",value:function(t){this.map.fitBounds(t,{duration:r})}},{key:"setPadding",value:function(t){this.map.setPadding(t)}},{key:"updateHighlightedFeatures",value:function(t,e){return function(t){var e=t.LngLatBounds,n=t.map,r=t.selectedFeatures,a=t.stylesMap;if(!n)return null;var o=function(t,e){var n={};return null==e||e.forEach(function(e){var r=e.featureId,a=e.layerId,o=e.idProperty,i=e.geometry,l=t.getLayer(a);if(l){var s=l.source;n[s]||(n[s]={ids:new Set,idProperty:o,layerId:a,hasFillGeometry:!1}),!i||"Polygon"!==i.type&&"MultiPolygon"!==i.type||(n[s].hasFillGeometry=!0),n[s].ids.add(r)}}),n}(n,r),i=[],l=new Set(Object.keys(o)),s=n._highlightedSources||new Set;return function(t,e,n){e.forEach(function(e){if(!n.has(e)){var r="highlight-".concat(e);["".concat(r,"-fill"),"".concat(r,"-line")].forEach(function(e){t.getLayer(e)&&t.setFilter(e,["==","id",""])})}})}(n,s,l),n._highlightedSources=l,l.forEach(function(t){var e=o[t],r=e.ids,l=e.idProperty,s=e.layerId,u=e.hasFillGeometry,c=n.getLayer(s),h=c.sourceLayer,f=u?"fill":c.type,p="highlight-".concat(t),y=a[s],d=y.stroke,g=y.strokeWidth,v=y.fill,m=["in",l?["get",l]:["id"],["literal",_(r)]],b={"line-color":d,"line-width":g};"fill"===f&&(z(n,"".concat(p,"-fill"),"fill",t,h,{"fill-color":v},m),z(n,"".concat(p,"-line"),"line",t,h,b,m)),"line"===f&&(n.getLayer("".concat(p,"-fill"))&&n.setFilter("".concat(p,"-fill"),["==","id",""]),z(n,"".concat(p,"-line"),"line",t,h,b,m)),i.push.apply(i,_(n.queryRenderedFeatures({layers:[s]}).filter(function(t){var e;return r.has(l?null===(e=t.properties)||void 0===e?void 0:e[l]:t.id)})))}),function(t,e){if(!e.length)return null;var n=new t;return e.forEach(function(t){var e=function(t){return"number"==typeof t[0]?n.extend(t):t.forEach(e)};e(t.geometry.coordinates)}),[n.getWest(),n.getSouth(),n.getEast(),n.getNorth()]}(e,i)}({LngLatBounds:this.maplibreModule.LngLatBounds,map:this.map,selectedFeatures:t,stylesMap:e})}},{key:"highlightNextLabel",value:function(t){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.highlightNextLabel(t))||null}},{key:"highlightLabelAtCenter",value:function(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.highlightLabelAtCenter())||null}},{key:"clearHighlightedLabel",value:function(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.clearHighlightedLabel())||null}},{key:"getCenter",value:function(){var t=this.map.getCenter();return[Number(t.lng.toFixed(7)),Number(t.lat.toFixed(7))]}},{key:"getZoom",value:function(){return Number(this.map.getZoom().toFixed(7))}},{key:"getBounds",value:function(){return this.map.getBounds().toArray().flat(1)}},{key:"getFeaturesAtPoint",value:function(t,e){return function(t,e){var n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).radius,r=void 0===n?10:n,a=[[e.x-r,e.y-r],[e.x+r,e.y+r]],o=t.queryRenderedFeatures(a);if(0===o.length)return[];var i=[];o.forEach(function(t){!1===i.includes(t.layer.id)&&i.push(t.layer.id)});for(var l=new Set,s=[],u=o.length-1;u>=0;u--){var c=o[u],h=void 0===c.id?JSON.stringify(c.properties):c.id;!1===l.has(h)&&(l.add(h),s.push(c))}var f=t.unproject(e),p=[f.lng,f.lat];return s.map(function(n){var r=0,a=n.geometry.type,o=function(t,e,n){var r=n.coordinates,a=n.type,o=1/0,i=function(e){return t.project(e)},l=function(t){for(var n=0;n<t.length-1;n++){var r=W(e,i(t[n]),i(t[n+1]));r<o&&(o=r)}};if("Point"===a){var s=i(r);o=Math.pow(e.x-s.x,2)+Math.pow(e.y-s.y,2)}else"LineString"===a||"MultiPoint"===a?"LineString"===a?l(r):r.forEach(function(t){var n=i(t),r=Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2);r<o&&(o=r)}):"Polygon"===a||"MultiLineString"===a?r.forEach(l):"MultiPolygon"===a&&r.forEach(function(t){return t.forEach(l)});return o}(t,e,n.geometry);if(r+=1e6*i.indexOf(n.layer.id),a.includes("Polygon")){var l=("Polygon"===a?[n.geometry.coordinates]:n.geometry.coordinates).some(function(t){return function(t,e){for(var n=q(t,2),r=n[0],a=n[1],o=!1,i=0,l=e.length-1;i<e.length;l=i,i++){var s=q(e[i],2),u=s[0],c=s[1],h=q(e[l],2),f=h[0],p=h[1];c>a!=p>a&&r<(f-u)*(a-c)/(p-c)+u&&(o=!o)}return o}(p,t[0])});!0===l?r-=5e5:r+=1e5}return{f:n,score:r+=o}}).sort(function(t,e){return t.score-e.score}).map(function(t){return t.f})}(this.map,t,e)}},{key:"getAreaDimensions",value:function(){return function(t){var e,n,r,a;if(t&&"function"==typeof t.getWest)e=t.getWest(),n=t.getSouth(),r=t.getEast(),a=t.getNorth();else{if(!Array.isArray(t)||2!==t.length)return"";var o=g(t,2),i=g(o[0],2);e=i[0],n=i[1];var l=g(o[1],2);r=l[0],a=l[1]}var s=m([e,n],[r,n]),u=m([e,n],[e,a]),c=b(s),h=b(u);return"".concat(h," by ").concat(c)}((t=this.maplibreModule.LngLatBounds,e=this.map,n=e.getContainer().getBoundingClientRect(),r=n.width,a=n.height,o=e.getPadding(),i=[o.left,a-o.bottom],l=[r-o.right,o.top],new t(e.unproject(i),e.unproject(l))));var t,e,n,r,a,o,i,l}},{key:"getCardinalMove",value:function(t,e){return function(t,e){var n=g(t,2),r=n[0],a=n[1],o=g(e,2),i=o[0],l=o[1],s=l-a,u=i-r,c=[];if(Math.abs(s)>1e-4){var h=Math.round(m([r,a],[r,l]));c.push("".concat(s>0?"north":"south"," ").concat(b(h)))}if(Math.abs(u)>1e-4){var f=Math.round(m([r,a],[i,a]));c.push("".concat(u>0?"east":"west"," ").concat(b(f)))}return c.join(", ")}(t,e)}},{key:"getResolution",value:function(){return t=this.map.getCenter(),e=this.map.getZoom(),n=t.lat,r=Math.pow(2,e),40075016.686*Math.cos(n*Math.PI/180)/(512*r);var t,e,n,r}},{key:"mapToScreen",value:function(t){return this.map.project(t)}},{key:"screenToMap",value:function(t){var e=this.map.unproject([t.x,t.y]);return[e.lng,e.lat]}}],e&&tt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,l}()}}]);
2
+ "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[772],{809(t,e,n){n.r(e),n.d(e,{default:()=>nt});var r=400,a=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"];function o(t){var e=t.getCanvas();e.removeAttribute("role"),e.setAttribute("tabindex",-1),e.removeAttribute("aria-label"),e.style.display="block"}function i(t){var e=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){var n=t.getCanvas();if(n&&(this.target===n||n.contains(this.target)))return}e.call(this)}}var l=function(t,e){var n=null,r=function(){for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];clearTimeout(n),n=setTimeout(function(){t.apply(void 0,a)},e)};return r.cancel=function(){n&&(clearTimeout(n),n=null)},r};function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function u(t){var e=t.map,n=t.events,r=t.eventBus,a=t.getCenter,o=t.getZoom,i=t.getBounds,u=t.getResolution,c=[],h=[],f=function(){var t=o();return{center:a(),bounds:i(),resolution:u(),zoom:t,isAtMaxZoom:e.getMaxZoom()<=t,isAtMinZoom:e.getMinZoom()>=t}},p=function(t,e){return r.emit(t,e)},d=function(){return p(n.MAP_LOADED)};e.on("load",d),c.push(["load",d]),e.once("idle",function(){return p(n.MAP_FIRST_IDLE,f())});var y=function(){return p(n.MAP_MOVE_START)};e.on("movestart",y),c.push(["movestart",y]);var g=l(function(){p(n.MAP_MOVE_END,f())},500);e.on("moveend",g),c.push(["moveend",g]),h.push(g);var v,m,b=(v=function(){p(n.MAP_MOVE,f())},m=0,function(){var t=Date.now();t-m>=10&&(m=t,v.apply(void 0,arguments))});e.on("zoom",b),c.push(["zoom",b]),h.push(b);var M=function(){return p(n.MAP_RENDER)};e.on("render",M),c.push(["render",M]);var w=l(function(){p(n.MAP_DATA_CHANGE,f())},500);e.on("styledata",w),c.push(["styledata",w]),h.push(w);var S=function(){return p(n.MAP_STYLE_CHANGE)};e.on("style.load",S),c.push(["style.load",S]);var x=function(t){return p(n.MAP_CLICK,{point:t.point,coords:[t.lngLat.lng,t.lngLat.lat]})};return e.on("click",x),c.push(["click",x]),{remove:function(){h.forEach(function(t){return t.cancel()}),c.forEach(function(t){var n,r,a=(r=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(n,r)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}(n,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=a[0],i=a[1];return e.off(o,i)})}}}function c(t){var e=t.map,n=t.events,r=t.eventBus,a=function(t){e.setStyle(t.url,{diff:!1})},o=function(t){e.setPixelRatio(t)};return r.on(n.MAP_SET_STYLE,a),r.on(n.MAP_SET_PIXEL_RATIO,o),{remove:function(){r.off(n.MAP_SET_STYLE,a),r.off(n.MAP_SET_PIXEL_RATIO,o)}}}let h=" ";class f{static get separator(){return h}static set separator(t){h=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 n=null;switch(e.length){case 3:n=e[0]/1+e[1]/60+e[2]/3600;break;case 2:n=e[0]/1+e[1]/60;break;case 1:n=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(n=-n),Number(n)}static toDms(t,e="d",n=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===n)switch(e){case"d":case"deg":n=4;break;case"dm":case"deg+min":n=2;break;case"dms":case"deg+min+sec":n=0;break;default:e="d",n=4}t=Math.abs(t);let r=null,a=null,o=null,i=null;switch(e){default:case"d":case"deg":a=t.toFixed(n),a<100&&(a="0"+a),a<10&&(a="0"+a),r=a+"°";break;case"dm":case"deg+min":a=Math.floor(t),o=(60*t%60).toFixed(n),60==o&&(o=(0).toFixed(n),a++),a=("000"+a).slice(-3),o<10&&(o="0"+o),r=a+"°"+f.separator+o+"′";break;case"dms":case"deg+min+sec":a=Math.floor(t),o=Math.floor(3600*t/60)%60,i=(3600*t%60).toFixed(n),60==i&&(i=(0).toFixed(n),o++),60==o&&(o=0,a++),a=("000"+a).slice(-3),o=("00"+o).slice(-2),i<10&&(i="0"+i),r=a+"°"+f.separator+o+"′"+f.separator+i+"″"}return r}static toLat(t,e,n){const r=f.toDms(f.wrap90(t),e,n);return null===r?"–":r.slice(1)+f.separator+(t<0?"S":"N")}static toLon(t,e,n){const r=f.toDms(f.wrap180(t),e,n);return null===r?"–":r+f.separator+(t<0?"W":"E")}static toBrng(t,e,n){const r=f.toDms(f.wrap360(t),e,n);return null===r?"–":r.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),n={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(n.thousands,"⁜").replace(n.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),n={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",n.decimal).replace("⁜",n.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=f.wrap360(t);const n=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*n/360)%n*16/n]}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 p=f,d=Math.PI;class y{constructor(t,e){if(isNaN(t))throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e))throw new TypeError(`invalid lon ‘${e}’`);this._lat=p.wrap90(Number(t)),this._lon=p.wrap180(Number(e))}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?p.wrap90(p.parse(t)):p.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?p.wrap90(p.parse(t)):p.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)?p.wrap180(p.parse(t)):p.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?p.wrap180(p.parse(t)):p.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?p.wrap180(p.parse(t)):p.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");if(null===t[0]||null===t[1])throw new TypeError("invalid (null) point");let e,n;if(2==t.length&&([e,n]=t,e=p.wrap90(p.parse(e)),n=p.wrap180(p.parse(n)),isNaN(e)||isNaN(n)))throw new TypeError(`invalid point ‘${t.toString()}’`);if(1==t.length&&"string"==typeof t[0]&&([e,n]=t[0].split(","),e=p.wrap90(p.parse(e)),n=p.wrap180(p.parse(n)),isNaN(e)||isNaN(n)))throw new TypeError(`invalid point ‘${t[0]}’`);if(1==t.length&&"object"==typeof t[0]){const r=t[0];if("Point"==r.type&&Array.isArray(r.coordinates)?[n,e]=r.coordinates:(null!=r.latitude&&(e=r.latitude),null!=r.lat&&(e=r.lat),null!=r.longitude&&(n=r.longitude),null!=r.lng&&(n=r.lng),null!=r.lon&&(n=r.lon),e=p.wrap90(p.parse(e)),n=p.wrap180(p.parse(n))),isNaN(e)||isNaN(n))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if(isNaN(e)||isNaN(n))throw new TypeError(`invalid point ‘${t.toString()}’`);return new y(e,n)}distanceTo(t,e=6371e3){if(t instanceof y||(t=y.parse(t)),isNaN(e))throw new TypeError(`invalid radius ‘${e}’`);const n=e,r=this.lat.toRadians(),a=this.lon.toRadians(),o=t.lat.toRadians(),i=o-r,l=t.lon.toRadians()-a,s=Math.sin(i/2)*Math.sin(i/2)+Math.cos(r)*Math.cos(o)*Math.sin(l/2)*Math.sin(l/2);return n*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}initialBearingTo(t){if(t instanceof y||(t=y.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),n=t.lat.toRadians(),r=(t.lon-this.lon).toRadians(),a=Math.cos(e)*Math.sin(n)-Math.sin(e)*Math.cos(n)*Math.cos(r),o=Math.sin(r)*Math.cos(n),i=Math.atan2(o,a).toDegrees();return p.wrap360(i)}finalBearingTo(t){t instanceof y||(t=y.parse(t));const e=t.initialBearingTo(this)+180;return p.wrap360(e)}midpointTo(t){t instanceof y||(t=y.parse(t));const e=this.lat.toRadians(),n=this.lon.toRadians(),r=t.lat.toRadians(),a=(t.lon-this.lon).toRadians(),o=Math.cos(e),i=Math.sin(e),l={x:o+Math.cos(r)*Math.cos(a),y:0+Math.cos(r)*Math.sin(a),z:i+Math.sin(r)},s=Math.atan2(l.z,Math.sqrt(l.x*l.x+l.y*l.y)),u=n+Math.atan2(l.y,l.x),c=s.toDegrees(),h=u.toDegrees();return new y(c,h)}intermediatePointTo(t,e){if(t instanceof y||(t=y.parse(t)),this.equals(t))return new y(this.lat,this.lon);const n=this.lat.toRadians(),r=this.lon.toRadians(),a=t.lat.toRadians(),o=t.lon.toRadians(),i=a-n,l=o-r,s=Math.sin(i/2)*Math.sin(i/2)+Math.cos(n)*Math.cos(a)*Math.sin(l/2)*Math.sin(l/2),u=2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)),c=Math.sin((1-e)*u)/Math.sin(u),h=Math.sin(e*u)/Math.sin(u),f=c*Math.cos(n)*Math.cos(r)+h*Math.cos(a)*Math.cos(o),p=c*Math.cos(n)*Math.sin(r)+h*Math.cos(a)*Math.sin(o),d=c*Math.sin(n)+h*Math.sin(a),g=Math.atan2(d,Math.sqrt(f*f+p*p)),v=Math.atan2(p,f),m=g.toDegrees(),b=v.toDegrees();return new y(m,b)}destinationPoint(t,e,n=6371e3){const r=t/n,a=Number(e).toRadians(),o=this.lat.toRadians(),i=this.lon.toRadians(),l=Math.sin(o)*Math.cos(r)+Math.cos(o)*Math.sin(r)*Math.cos(a),s=Math.asin(l),u=Math.sin(a)*Math.sin(r)*Math.cos(o),c=Math.cos(r)-Math.sin(o)*l,h=i+Math.atan2(u,c),f=s.toDegrees(),p=h.toDegrees();return new y(f,p)}static intersection(t,e,n,r){if(t instanceof y||(t=y.parse(t)),n instanceof y||(n=y.parse(n)),isNaN(e))throw new TypeError(`invalid brng1 ‘${e}’`);if(isNaN(r))throw new TypeError(`invalid brng2 ‘${r}’`);const a=t.lat.toRadians(),o=t.lon.toRadians(),i=n.lat.toRadians(),l=n.lon.toRadians(),s=Number(e).toRadians(),u=Number(r).toRadians(),c=i-a,h=l-o,f=2*Math.asin(Math.sqrt(Math.sin(c/2)*Math.sin(c/2)+Math.cos(a)*Math.cos(i)*Math.sin(h/2)*Math.sin(h/2)));if(Math.abs(f)<Number.EPSILON)return new y(t.lat,t.lon);const p=(Math.sin(i)-Math.sin(a)*Math.cos(f))/(Math.sin(f)*Math.cos(a)),g=(Math.sin(a)-Math.sin(i)*Math.cos(f))/(Math.sin(f)*Math.cos(i)),v=Math.acos(Math.min(Math.max(p,-1),1)),m=Math.acos(Math.min(Math.max(g,-1),1)),b=s-(Math.sin(l-o)>0?v:2*d-v),M=(Math.sin(l-o)>0?2*d-m:m)-u;if(0==Math.sin(b)&&0==Math.sin(M))return null;if(Math.sin(b)*Math.sin(M)<0)return null;const w=-Math.cos(b)*Math.cos(M)+Math.sin(b)*Math.sin(M)*Math.cos(f),S=Math.atan2(Math.sin(f)*Math.sin(b)*Math.sin(M),Math.cos(M)+Math.cos(b)*w),x=Math.asin(Math.min(Math.max(Math.sin(a)*Math.cos(S)+Math.cos(a)*Math.sin(S)*Math.cos(s),-1),1)),N=o+Math.atan2(Math.sin(s)*Math.sin(S)*Math.cos(a),Math.cos(S)-Math.sin(a)*Math.sin(x)),P=x.toDegrees(),O=N.toDegrees();return new y(P,O)}crossTrackDistanceTo(t,e,n=6371e3){t instanceof y||(t=y.parse(t)),e instanceof y||(e=y.parse(e));const r=n;if(this.equals(t))return 0;const a=t.distanceTo(this,r)/r,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(a)*Math.sin(o-i))*r}alongTrackDistanceTo(t,e,n=6371e3){t instanceof y||(t=y.parse(t)),e instanceof y||(e=y.parse(e));const r=n;if(this.equals(t))return 0;const a=t.distanceTo(this,r)/r,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians(),l=Math.asin(Math.sin(a)*Math.sin(o-i));return Math.acos(Math.cos(a)/Math.abs(Math.cos(l)))*Math.sign(Math.cos(i-o))*r}maxLatitude(t){const e=Number(t).toRadians(),n=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(n))).toDegrees()}static crossingParallels(t,e,n){if(t.equals(e))return null;const r=Number(n).toRadians(),a=t.lat.toRadians(),o=t.lon.toRadians(),i=e.lat.toRadians(),l=e.lon.toRadians()-o,s=Math.sin(a)*Math.cos(i)*Math.cos(r)*Math.sin(l),u=Math.sin(a)*Math.cos(i)*Math.cos(r)*Math.cos(l)-Math.cos(a)*Math.sin(i)*Math.cos(r),c=Math.cos(a)*Math.cos(i)*Math.sin(r)*Math.sin(l);if(c*c>s*s+u*u)return null;const h=Math.atan2(-u,s),f=Math.acos(c/Math.sqrt(s*s+u*u)),d=o+h+f,y=(o+h-f).toDegrees(),g=d.toDegrees();return{lon1:p.wrap180(y),lon2:p.wrap180(g)}}rhumbDistanceTo(t,e=6371e3){t instanceof y||(t=y.parse(t));const n=e,r=this.lat.toRadians(),a=t.lat.toRadians(),o=a-r;let i=Math.abs(t.lon-this.lon).toRadians();Math.abs(i)>d&&(i=i>0?-(2*d-i):2*d+i);const l=Math.log(Math.tan(a/2+d/4)/Math.tan(r/2+d/4)),s=Math.abs(l)>1e-11?o/l:Math.cos(r);return Math.sqrt(o*o+s*s*i*i)*n}rhumbBearingTo(t){if(t instanceof y||(t=y.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),n=t.lat.toRadians();let r=(t.lon-this.lon).toRadians();Math.abs(r)>d&&(r=r>0?-(2*d-r):2*d+r);const a=Math.log(Math.tan(n/2+d/4)/Math.tan(e/2+d/4)),o=Math.atan2(r,a).toDegrees();return p.wrap360(o)}rhumbDestinationPoint(t,e,n=6371e3){const r=this.lat.toRadians(),a=this.lon.toRadians(),o=Number(e).toRadians(),i=t/n,l=i*Math.cos(o);let s=r+l;Math.abs(s)>d/2&&(s=s>0?d-s:-d-s);const u=Math.log(Math.tan(s/2+d/4)/Math.tan(r/2+d/4)),c=Math.abs(u)>1e-11?l/u:Math.cos(r),h=a+i*Math.sin(o)/c,f=s.toDegrees(),p=h.toDegrees();return new y(f,p)}rhumbMidpointTo(t){t instanceof y||(t=y.parse(t));const e=this.lat.toRadians();let n=this.lon.toRadians();const r=t.lat.toRadians(),a=t.lon.toRadians();Math.abs(a-n)>d&&(n+=2*d);const o=(e+r)/2,i=Math.tan(d/4+e/2),l=Math.tan(d/4+r/2),s=Math.tan(d/4+o/2);let u=((a-n)*Math.log(s)+n*Math.log(l)-a*Math.log(i))/Math.log(l/i);isFinite(u)||(u=(n+a)/2);const c=o.toDegrees(),h=u.toDegrees();return new y(c,h)}static areaOf(t,e=6371e3){const n=e,r=t[0].equals(t[t.length-1]);r||t.push(t[0]);const a=t.length-1;let o=0;for(let e=0;e<a;e++){const n=t[e].lat.toRadians(),r=t[e+1].lat.toRadians(),a=(t[e+1].lon-t[e].lon).toRadians();o+=2*Math.atan2(Math.tan(a/2)*(Math.tan(n/2)+Math.tan(r/2)),1+Math.tan(n/2)*Math.tan(r/2))}(function(t){let e=0,n=t[0].initialBearingTo(t[1]);for(let r=0;r<t.length-1;r++){const a=t[r].initialBearingTo(t[r+1]),o=t[r].finalBearingTo(t[r+1]);e+=(a-n+540)%360-180,e+=(o-a+540)%360-180,n=o}return e+=(t[0].initialBearingTo(t[1])-n+540)%360-180,Math.abs(e)<90})(t)&&(o=Math.abs(o)-2*d);const i=Math.abs(o*n*n);return r||t.pop(),i}equals(t){return t instanceof y||(t=y.parse(t)),!(Math.abs(this.lat-t.lat)>Number.EPSILON||Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e=void 0){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);return"n"==t?(null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`):`${p.toLat(this.lat,t,e)}, ${p.toLon(this.lon,t,e)}`}}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return v(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var m=function(t,e){var n=g(t,2),r=n[0],a=n[1],o=g(e,2),i=o[0],l=o[1],s=new y(a,r),u=new y(l,i);return s.distanceTo(u)},b=function(t){var e=1609.344,n=t/e;if(n<.5/e)return"".concat(Math.round(t),"m");if(n<10){var r=Number.parseFloat(n.toFixed(1)),a=1===r?"mile":"miles";return"".concat(r," ").concat(a)}var o=Math.round(n),i=1===o?"mile":"miles";return"".concat(o," ").concat(i)};function M(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return w(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function S(t){return S="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},S(t)}function x(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function N(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?x(Object(n),!0).forEach(function(e){P(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function P(t,e,n){return(e=function(t){var e=function(t){if("object"!=S(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==S(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function O(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var E="highlighted-label";function A(t,e){if("number"==typeof t)return t;if(!Array.isArray(t)||"interpolate"!==t[0])return function(t,e){var n=t.stops;if(n.length<2)return n.length>0?n[0][1]:0;for(var r=n[0],a=n[n.length-1],o=1;o<n.length;o++){var i=n[o];if(i[0]>e){a=i,r=n[o-1];break}r=n[o-1],a=i}var l=M(r,2),s=l[0],u=l[1],c=M(a,2),h=c[0],f=c[1];return e<=s?u:e>=h?f:u+(e-s)/(h-s)*(f-u)}(t,e);var n,r=function(t){if(Array.isArray(t))return t}(n=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||function(t,e){if(t){if("string"==typeof t)return O(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(t,e):void 0}}(n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),a=r[2],o=O(r).slice(3);if("zoom"!==a[0])throw new Error("Only zoom-based expressions supported");for(var i=0;i<o.length-2;i+=2){var l=o[i],s=o[i+1],u=o[i+2],c=o[i+3];if(e<=l)return s;if(e<=u)return s+(e-l)/(u-l)*(c-s)}return o[o.length-1]}function j(t,e){if(e.highlightLayerId&&t.getLayer(e.highlightLayerId)){try{t.removeLayer(e.highlightLayerId)}catch(t){}e.highlightLayerId=null,e.highlightedExpr=null}}function T(t,e,n){var r,a,o,i;if(null!=e&&null!==(r=e.feature)&&void 0!==r&&r.layer){j(t,n);var l=e.feature,s=e.layer;n.highlightLayerId="highlight-".concat(s.id);var u=l.id,c=l.type,h=l.properties,f=l.geometry;t.getSource(E).setData({id:u,type:c,properties:h,geometry:f}),n.highlightedExpr=s.layout["text-size"];var p=t.getZoom(),d=(a=s,o=1.5*A(n.highlightedExpr,p),i=n.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"},{id:"highlight-".concat(a.id),type:a.type,source:E,layout:N(N({},a.layout),{},{"text-size":o,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90}),paint:N(N({},a.paint),{},{"text-color":i.text,"text-halo-color":i.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1})});t.addLayer(d),t.moveLayer(n.highlightLayerId)}}function R(t){t.getSource(E)||t.addSource(E,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function L(t){t.getStyle().layers.filter(function(t){var e;return"line"===(null===(e=t.layout)||void 0===e?void 0:e["symbol-placement"])}).forEach(function(e){return t.setLayoutProperty(e.id,"symbol-placement","line-center")})}function k(t,e,n,r){var a={isDarkStyle:"dark"===e,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function o(){var e=t.getStyle().layers.filter(function(t){return"symbol"===t.type}),n=t.queryRenderedFeatures({layers:e.map(function(t){return t.id})});a.labels=function(t,e,n){return e.flatMap(function(e){var r,a,o,i,l="string"==typeof(a=null===(r=e.layout)||void 0===r?void 0:r["text-field"])?null===(o=/^{(.+)}$/.exec(a))||void 0===o?void 0:o[1]:Array.isArray(a)?null===(i=a.find(function(t){return Array.isArray(t)&&"get"===t[0]}))||void 0===i?void 0:i[1]:null;return l?n.filter(function(t){var n;return t.layer.id===e.id&&(null===(n=t.properties)||void 0===n?void 0:n[l])}).map(function(n){return function(t,e,n,r){var a=function(t){var e=t.type,n=t.coordinates;if("Point"===e)return n;if("MultiPoint"===e)return n[0];if(e.includes("LineString")){var r="LineString"===e?n:n[0];return[(r[0][0]+r[r.length-1][0])/2,(r[0][1]+r[r.length-1][1])/2]}if(e.includes("Polygon")){var a="Polygon"===e?n[0]:n[0][0],o=a.reduce(function(t,e){return[t[0]+e[0],t[1]+e[1]]},[0,0]);return[o[0]/a.length,o[1]/a.length]}return null}(t.geometry);if(!a)return null;var o=r.project({lng:a[0],lat:a[1]});return{text:t.properties[n],x:o.x,y:o.y,feature:t,layer:e}}(n,e,l,t)}).filter(Boolean):[]})}(t,e,n)}function i(){if(o(),!a.labels.length)return null;var e=t.project(t.getCenter()),n=function(t,e){var n;return null===(n=t.reduce(function(t,n){var r=Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2);return!t||r<t.dist?{label:n,dist:r}:t},null))||void 0===n?void 0:n.label}(a.labels,e);return n&&(a.currentPixel={x:n.x,y:n.y}),T(t,n,a),"".concat(n.text," (").concat(n.layer.id,")")}return L(t),R(t),null==r||r.on(n.MAP_SET_STYLE,function(e){t.once("styledata",function(){return t.once("idle",function(){L(t),R(t),a.isDarkStyle="dark"===(null==e?void 0:e.mapColorScheme)})})}),t.on("zoom",function(){if(a.highlightLayerId&&a.highlightedExpr){var e=A(a.highlightedExpr,t.getZoom());t.setLayoutProperty(a.highlightLayerId,"text-size",1.5*e)}}),function(t){t.getStyle().layers.filter(function(t){return"symbol"===t.type}).forEach(function(e){t.setPaintProperty(e.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(t),{refreshLabels:o,highlightNextLabel:function(e){if(o(),!a.labels.length)return null;if(!a.currentPixel)return i();var n=function(t,e){if(!e.currentPixel)return null;var n=e.labels.map(function(t,e){return{pixel:[t.x,t.y],index:e}}).filter(function(t){return t.pixel[0]!==e.currentPixel.x||t.pixel[1]!==e.currentPixel.y});if(!n.length)return null;var r=n.map(function(t){return t.pixel}),a=function(t,e,n){var r=g(e,2),a=r[0],o=r[1],i=n.filter(function(e){var n=g(e,2),r=n[0],i=n[1];return(r!==a||i!==o)&&function(t,e,n){switch(t){case"ArrowUp":return n<0&&Math.abs(n)>=Math.abs(e);case"ArrowDown":return n>0&&Math.abs(n)>=Math.abs(e);case"ArrowLeft":return e<0&&Math.abs(e)>Math.abs(n);case"ArrowRight":return e>0&&Math.abs(e)>Math.abs(n);default:return!1}}(t,r-a,i-o)});if(!i.length)return n.findIndex(function(t){return t[0]===a&&t[1]===o});var l=-1,s=1/0;return i.forEach(function(t){var e=t[0]-a,r=t[1]-o,i=e*e+r*r;i<s&&(s=i,l=n.indexOf(t))}),l}(t,[e.currentPixel.x,e.currentPixel.y],r);return(null==a||a<0||a>=n.length)&&(a=0),e.labels[n[a].index]}(e,a);return n?(a.currentPixel={x:n.x,y:n.y},T(t,n,a),"".concat(n.text," (").concat(n.layer.id,")")):null},highlightLabelAtCenter:i,clearHighlightedLabel:function(){return j(t,a)}}}function D(t){return D="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},D(t)}function I(t){return function(t){if(Array.isArray(t))return B(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_(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 _(t,e){if(t){if("string"==typeof t)return B(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?B(t,e):void 0}}function B(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function C(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function F(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?C(Object(n),!0).forEach(function(e){$(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function $(t,e,n){return(e=function(t){var e=function(t){if("object"!=D(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==D(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var z=function(t,e,n,r,a,o,i){t.getLayer(e)||t.addLayer(F(F({id:e,type:n,source:r},a&&{"source-layer":a}),{},{paint:o})),Object.entries(o).forEach(function(n){var r,a,o=(a=2,function(t){if(Array.isArray(t))return t}(r=n)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(r,a)||_(r,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],l=o[1];t.setPaintProperty(e,i,l)}),t.setFilter(e,i)};function q(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,l=[],s=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);s=!0);}catch(t){u=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Z(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Z(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Z(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var W=function(t,e,n){var r=Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2);if(0===r)return Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2);var a=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/r;return a=Math.max(0,Math.min(1,a)),Math.pow(t.x-(e.x+a*(n.x-e.x)),2)+Math.pow(t.y-(e.y+a*(n.y-e.y)),2)},G=["container","padding","mapStyle","center","zoom","bounds","pixelRatio"];function H(t){return H="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},H(t)}function U(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function o(n,r,a,o){var s=r&&r.prototype instanceof l?r:l,u=Object.create(s.prototype);return V(u,"_invoke",function(n,r,a){var o,l,s,u=0,c=a||[],h=!1,f={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,n){return o=e,l=0,s=t,f.n=n,i}};function p(n,r){for(l=n,s=r,e=0;!h&&u&&!a&&e<c.length;e++){var a,o=c[e],p=f.p,d=o[2];n>3?(a=d===r)&&(s=o[(l=o[4])?5:(l=3,3)],o[4]=o[5]=t):o[0]<=p&&((a=n<2&&p<o[1])?(l=0,f.v=r,f.n=o[1]):p<d&&(a=n<3||o[0]>r||r>d)&&(o[4]=n,o[5]=r,f.n=d,l=0))}if(a||n>1)return i;throw h=!0,r}return function(a,c,d){if(u>1)throw TypeError("Generator is already running");for(h&&1===c&&p(c,d),l=c,s=d;(e=l<2?t:s)||!h;){o||(l?l<3?(l>1&&(f.n=-1),p(l,s)):f.n=s:f.v=s);try{if(u=2,o){if(l||(a="next"),e=o[a]){if(!(e=e.call(o,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,l<2&&(l=0)}else 1===l&&(e=o.return)&&e.call(o),l<2&&(s=TypeError("The iterator does not provide a '"+a+"' method"),l=1);o=t}else if((e=(h=f.n<0)?s:n.call(r,f))!==i)break}catch(e){o=t,l=1,s=e}finally{u=1}}return{value:e,done:h}}}(n,a,o),!0),u}var i={};function l(){}function s(){}function u(){}e=Object.getPrototypeOf;var c=[][r]?e(e([][r]())):(V(e={},r,function(){return this}),e),h=u.prototype=l.prototype=Object.create(c);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,V(t,a,"GeneratorFunction")),t.prototype=Object.create(h),t}return s.prototype=u,V(h,"constructor",u),V(u,"constructor",s),s.displayName="GeneratorFunction",V(u,a,"GeneratorFunction"),V(h),V(h,a,"Generator"),V(h,r,function(){return this}),V(h,"toString",function(){return"[object Generator]"}),(U=function(){return{w:o,m:f}})()}function V(t,e,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(t){a=0}V=function(t,e,n,r){function o(e,n){V(t,e,function(t){return this._invoke(e,n,t)})}e?a?a(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},V(t,e,n,r)}function Y(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function J(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Y(Object(n),!0).forEach(function(e){K(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function K(t,e,n){return(e=et(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X(t,e){if(null==t)return{};var n,r,a=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;n[r]=t[r]}return n}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(a[n]=t[n])}return a}function Q(t,e,n,r,a,o,i){try{var l=t[o](i),s=l.value}catch(t){return void n(t)}l.done?e(s):Promise.resolve(s).then(r,a)}function tt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,et(r.key),r)}}function et(t){var e=function(t){if("object"!=H(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=H(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==H(e)?e:e+""}var nt=function(){return t=function t(e){var n=e.mapFramework,r=e.mapProviderConfig,o=void 0===r?{}:r,i=e.events,l=e.eventBus;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.maplibreModule=n,this.events=i,this.eventBus=l,this.capabilities={supportedShortcuts:a,supportsMapSizes:!0},Object.assign(this,o)},e=[{key:"initMap",value:(n=U().m(function t(e){var n,r,a,l,s,h,f,p,d,y,g,v,m=this;return U().w(function(t){for(;;)switch(t.n){case 0:n=e.container,r=e.padding,a=e.mapStyle,l=e.center,s=e.zoom,h=e.bounds,f=e.pixelRatio,p=X(e,G),d=this.maplibreModule.Map,y=this.events,g=this.eventBus,(v=new d(J(J({},p),{},{container:n,style:null==a?void 0:a.url,pixelRatio:f,padding:r,center:l,zoom:s,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1}))).touchZoomRotate.disableRotation(),this.map=v,this.map.setPadding(r),h&&v.fitBounds(h,{duration:0}),i(v),o(v),u({map:v,events:y,eventBus:g,getCenter:this.getCenter.bind(this),getZoom:this.getZoom.bind(this),getBounds:this.getBounds.bind(this),getResolution:this.getResolution.bind(this)}),c({map:v,events:y,eventBus:g}),v.on("load",function(){m.labelNavigator=k(v,null==a?void 0:a.mapColorScheme,y,g)}),this.eventBus.emit(y.MAP_READY,this.getMapAPI());case 1:return t.a(2)}},t,this)}),l=function(){var t=this,e=arguments;return new Promise(function(r,a){var o=n.apply(t,e);function i(t){Q(o,r,a,i,l,"next",t)}function l(t){Q(o,r,a,i,l,"throw",t)}i(void 0)})},function(t){return l.apply(this,arguments)})},{key:"getMapAPI",value:function(){return{map:this.map,crs:this.crs,fitToBounds:this.fitToBounds.bind(this),setView:this.setView.bind(this)}}},{key:"destroyMap",value:function(){var t,e;null===(t=this.mapEvents)||void 0===t||t.remove(),null===(e=this.appEvents)||void 0===e||e.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}},{key:"setView",value:function(t){var e=t.center,n=t.zoom;this.map.flyTo({center:e||this.getCenter(),zoom:n||this.getZoom(),duration:r})}},{key:"zoomIn",value:function(t){this.map.easeTo({zoom:this.getZoom()+t,duration:r})}},{key:"zoomOut",value:function(t){this.map.easeTo({zoom:this.getZoom()-t,duration:r})}},{key:"panBy",value:function(t){this.map.panBy(t,{duration:r})}},{key:"fitToBounds",value:function(t){this.map.fitBounds(t,{duration:r})}},{key:"setPadding",value:function(t){this.map.setPadding(t)}},{key:"updateHighlightedFeatures",value:function(t,e){return function(t){var e=t.LngLatBounds,n=t.map,r=t.selectedFeatures,a=t.stylesMap;if(!n)return null;var o=function(t,e){var n={};return null==e||e.forEach(function(e){var r=e.featureId,a=e.layerId,o=e.idProperty,i=e.geometry,l=t.getLayer(a);if(l){var s=l.source;n[s]||(n[s]={ids:new Set,fillIds:new Set,idProperty:o,layerId:a,hasFillGeometry:!1}),!i||"Polygon"!==i.type&&"MultiPolygon"!==i.type||(n[s].hasFillGeometry=!0,n[s].fillIds.add(r)),n[s].ids.add(r)}}),n}(n,r),i=[],l=new Set(Object.keys(o)),s=n._highlightedSources||new Set;return function(t,e,n){e.forEach(function(e){if(!n.has(e)){var r="highlight-".concat(e);["".concat(r,"-fill"),"".concat(r,"-line")].forEach(function(e){t.getLayer(e)&&t.setFilter(e,["==","id",""])})}})}(n,s,l),n._highlightedSources=l,l.forEach(function(t){var e=o[t],r=e.ids,l=e.fillIds,s=e.idProperty,u=e.layerId,c=e.hasFillGeometry,h=n.getLayer(u),f=h.sourceLayer,p=c?"fill":h.type,d="highlight-".concat(t),y=a[u],g=y.stroke,v=y.strokeWidth,m=y.fill,b=s?["get",s]:["id"],M=["in",b,["literal",I(r)]],w=["in",b,["literal",I(l)]],S={"line-color":g,"line-width":v};"fill"===p&&(z(n,"".concat(d,"-fill"),"fill",t,f,{"fill-color":m},w),z(n,"".concat(d,"-line"),"line",t,f,S,M)),"line"===p&&(n.getLayer("".concat(d,"-fill"))&&n.setFilter("".concat(d,"-fill"),["==","id",""]),z(n,"".concat(d,"-line"),"line",t,f,S,M)),i.push.apply(i,I(n.queryRenderedFeatures({layers:[u]}).filter(function(t){var e;return r.has(s?null===(e=t.properties)||void 0===e?void 0:e[s]:t.id)})))}),function(t,e){if(!e.length)return null;var n=new t;return e.forEach(function(t){var e=function(t){return"number"==typeof t[0]?n.extend(t):t.forEach(e)};e(t.geometry.coordinates)}),[n.getWest(),n.getSouth(),n.getEast(),n.getNorth()]}(e,i)}({LngLatBounds:this.maplibreModule.LngLatBounds,map:this.map,selectedFeatures:t,stylesMap:e})}},{key:"highlightNextLabel",value:function(t){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.highlightNextLabel(t))||null}},{key:"highlightLabelAtCenter",value:function(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.highlightLabelAtCenter())||null}},{key:"clearHighlightedLabel",value:function(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.clearHighlightedLabel())||null}},{key:"getCenter",value:function(){var t=this.map.getCenter();return[Number(t.lng.toFixed(7)),Number(t.lat.toFixed(7))]}},{key:"getZoom",value:function(){return Number(this.map.getZoom().toFixed(7))}},{key:"getBounds",value:function(){return this.map.getBounds().toArray().flat(1)}},{key:"getFeaturesAtPoint",value:function(t,e){return function(t,e){var n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).radius,r=void 0===n?10:n,a=[[e.x-r,e.y-r],[e.x+r,e.y+r]],o=t.queryRenderedFeatures(a);if(0===o.length)return[];var i=[];o.forEach(function(t){!1===i.includes(t.layer.id)&&i.push(t.layer.id)});for(var l=new Set,s=[],u=o.length-1;u>=0;u--){var c=o[u],h=void 0===c.id?JSON.stringify(c.properties):c.id;!1===l.has(h)&&(l.add(h),s.push(c))}var f=t.unproject(e),p=[f.lng,f.lat];return s.map(function(n){var r=0,a=n.geometry.type,o=function(t,e,n){var r=n.coordinates,a=n.type,o=1/0,i=function(e){return t.project(e)},l=function(t){for(var n=0;n<t.length-1;n++){var r=W(e,i(t[n]),i(t[n+1]));r<o&&(o=r)}};if("Point"===a){var s=i(r);o=Math.pow(e.x-s.x,2)+Math.pow(e.y-s.y,2)}else"LineString"===a||"MultiPoint"===a?"LineString"===a?l(r):r.forEach(function(t){var n=i(t),r=Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2);r<o&&(o=r)}):"Polygon"===a||"MultiLineString"===a?r.forEach(l):"MultiPolygon"===a&&r.forEach(function(t){return t.forEach(l)});return o}(t,e,n.geometry);if(r+=1e6*i.indexOf(n.layer.id),a.includes("Polygon")){var l=("Polygon"===a?[n.geometry.coordinates]:n.geometry.coordinates).some(function(t){return function(t,e){for(var n=q(t,2),r=n[0],a=n[1],o=!1,i=0,l=e.length-1;i<e.length;l=i,i++){var s=q(e[i],2),u=s[0],c=s[1],h=q(e[l],2),f=h[0],p=h[1];c>a!=p>a&&r<(f-u)*(a-c)/(p-c)+u&&(o=!o)}return o}(p,t[0])});!0===l?r-=5e5:r+=1e5}return{f:n,score:r+=o}}).sort(function(t,e){return t.score-e.score}).map(function(t){return t.f})}(this.map,t,e)}},{key:"getAreaDimensions",value:function(){return function(t){var e,n,r,a;if(t&&"function"==typeof t.getWest)e=t.getWest(),n=t.getSouth(),r=t.getEast(),a=t.getNorth();else{if(!Array.isArray(t)||2!==t.length)return"";var o=g(t,2),i=g(o[0],2);e=i[0],n=i[1];var l=g(o[1],2);r=l[0],a=l[1]}var s=m([e,n],[r,n]),u=m([e,n],[e,a]),c=b(s),h=b(u);return"".concat(h," by ").concat(c)}((t=this.maplibreModule.LngLatBounds,e=this.map,n=e.getContainer().getBoundingClientRect(),r=n.width,a=n.height,o=e.getPadding(),i=[o.left,a-o.bottom],l=[r-o.right,o.top],new t(e.unproject(i),e.unproject(l))));var t,e,n,r,a,o,i,l}},{key:"getCardinalMove",value:function(t,e){return function(t,e){var n=g(t,2),r=n[0],a=n[1],o=g(e,2),i=o[0],l=o[1],s=l-a,u=i-r,c=[];if(Math.abs(s)>1e-4){var h=Math.round(m([r,a],[r,l]));c.push("".concat(s>0?"north":"south"," ").concat(b(h)))}if(Math.abs(u)>1e-4){var f=Math.round(m([r,a],[i,a]));c.push("".concat(u>0?"east":"west"," ").concat(b(f)))}return c.join(", ")}(t,e)}},{key:"getResolution",value:function(){return t=this.map.getCenter(),e=this.map.getZoom(),n=t.lat,r=Math.pow(2,e),40075016.686*Math.cos(n*Math.PI/180)/(512*r);var t,e,n,r}},{key:"mapToScreen",value:function(t){return this.map.project(t)}},{key:"screenToMap",value:function(t){var e=this.map.unproject([t.x,t.y]);return[e.lng,e.lat]}}],e&&tt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,l}()}}]);
@@ -100,7 +100,17 @@ export default class MapLibreProvider {
100
100
  this.labelNavigator = createMapLabelNavigator(map, mapStyle?.mapColorScheme, events, eventBus)
101
101
  })
102
102
 
103
- this.eventBus.emit(events.MAP_READY, { map })
103
+ this.eventBus.emit(events.MAP_READY, this.getMapAPI())
104
+ }
105
+
106
+ /** Returns the public API exposed via the map:ready event. */
107
+ getMapAPI () {
108
+ return {
109
+ map: this.map,
110
+ crs: this.crs,
111
+ fitToBounds: this.fitToBounds.bind(this),
112
+ setView: this.setView.bind(this)
113
+ }
104
114
  }
105
115
 
106
116
  /** Destroy the map and clean up resources. */
@@ -13,6 +13,7 @@ const groupFeaturesBySource = (map, selectedFeatures) => {
13
13
  if (!featuresBySource[sourceId]) {
14
14
  featuresBySource[sourceId] = {
15
15
  ids: new Set(),
16
+ fillIds: new Set(),
16
17
  idProperty,
17
18
  layerId,
18
19
  hasFillGeometry: false
@@ -22,6 +23,7 @@ const groupFeaturesBySource = (map, selectedFeatures) => {
22
23
  // Track whether any selected feature on this source is a polygon
23
24
  if (geometry && (geometry.type === 'Polygon' || geometry.type === 'MultiPolygon')) {
24
25
  featuresBySource[sourceId].hasFillGeometry = true
26
+ featuresBySource[sourceId].fillIds.add(featureId)
25
27
  }
26
28
 
27
29
  featuresBySource[sourceId].ids.add(featureId)
@@ -95,7 +97,7 @@ export function updateHighlightedFeatures({ LngLatBounds, map, selectedFeatures,
95
97
 
96
98
  // Apply highlights for current sources
97
99
  currentSources.forEach(sourceId => {
98
- const { ids, idProperty, layerId, hasFillGeometry } = featuresBySource[sourceId]
100
+ const { ids, fillIds, idProperty, layerId, hasFillGeometry } = featuresBySource[sourceId]
99
101
  const baseLayer = map.getLayer(layerId)
100
102
  const srcLayer = baseLayer.sourceLayer
101
103
 
@@ -107,11 +109,13 @@ export function updateHighlightedFeatures({ LngLatBounds, map, selectedFeatures,
107
109
  // Use ['id'] for feature.id, ['get', idProperty] for properties
108
110
  const idExpression = idProperty ? ['get', idProperty] : ['id']
109
111
  const filter = ['in', idExpression, ['literal', [...ids]]]
112
+ const fillFilter = ['in', idExpression, ['literal', [...fillIds]]]
110
113
 
111
114
  const linePaint = { 'line-color': stroke, 'line-width': strokeWidth }
112
115
 
113
116
  if (geom === 'fill') {
114
- applyHighlightLayer(map, `${base}-fill`, 'fill', sourceId, srcLayer, { 'fill-color': fill }, filter)
117
+ // Only apply fill highlight to polygon features, not to any co-selected line features
118
+ applyHighlightLayer(map, `${base}-fill`, 'fill', sourceId, srcLayer, { 'fill-color': fill }, fillFilter)
115
119
  applyHighlightLayer(map, `${base}-line`, 'line', sourceId, srcLayer, linePaint, filter)
116
120
  }
117
121
 
@@ -17,11 +17,12 @@ export const Actions = ({ children }) => {
17
17
  const className = [
18
18
  'im-c-panel',
19
19
  'im-c-actions',
20
+ !visibleChild && 'im-c-actions--hidden',
20
21
  isBottomSlotUsed && 'im-c-actions--border-top'
21
22
  ].filter(Boolean).join(' ')
22
23
 
23
24
  return (
24
- <div className={className} style={visibleChild ? undefined : { display: 'none' }}>
25
+ <div className={className}>
25
26
  {children}
26
27
  </div>
27
28
  )
@@ -4,6 +4,20 @@
4
4
  justify-content: center;
5
5
  gap: calc(var(--divider-gap) / 2);
6
6
  padding: var(--panel-margin);
7
+ max-height: 200px;
8
+
9
+ @media (prefers-reduced-motion: no-preference) {
10
+ transition: max-height var(--duration) ease, opacity var(--duration) ease,
11
+ padding-top var(--duration) ease, padding-bottom var(--duration) ease;
12
+ }
13
+
14
+ &--hidden {
15
+ max-height: 0;
16
+ overflow: hidden;
17
+ opacity: 0;
18
+ padding-top: 0;
19
+ padding-bottom: 0;
20
+ }
7
21
 
8
22
  .im-c-button-wrapper--wide {
9
23
  display: flex;
@@ -54,7 +54,7 @@ describe('Actions component', () => {
54
54
  </Actions>
55
55
  )
56
56
  const container = screen.getByTestId('child1').closest('.im-c-actions')
57
- expect(container).toHaveStyle('display: none')
57
+ expect(container).toHaveClass('im-c-actions--hidden')
58
58
  })
59
59
 
60
60
  it('shows the container when at least one child is visible', () => {
@@ -65,6 +65,6 @@ describe('Actions component', () => {
65
65
  </Actions>
66
66
  )
67
67
  const container = screen.getByTestId('child1').closest('.im-c-actions')
68
- expect(container).not.toHaveStyle('display: none')
68
+ expect(container).not.toHaveClass('im-c-actions--hidden')
69
69
  })
70
70
  })
@@ -94,6 +94,10 @@
94
94
  svg + span {
95
95
  padding-left: 0;
96
96
  }
97
+
98
+ &::before {
99
+ box-shadow: none;
100
+ }
97
101
  }
98
102
 
99
103
  @media (hover: hover) and (pointer: fine) {
@@ -102,10 +106,6 @@
102
106
  }
103
107
  }
104
108
 
105
- .im-c-map-button--primary::before {
106
- box-shadow: none;
107
- }
108
-
109
109
  .im-c-map-button--tertiary {
110
110
  border: 1px solid var(--tertiary-button-border-color);
111
111
  box-shadow: var(--tertiary-button-box-shadow);
@@ -118,10 +118,23 @@
118
118
  svg + span {
119
119
  padding-left: 0;
120
120
  }
121
+
122
+ &::before {
123
+ box-shadow: none;
124
+ }
121
125
  }
122
126
 
123
- .im-c-map-button--tertiary::before {
124
- box-shadow: none;
127
+ .im-c-map-button--touch {
128
+ background-color: var(--map-overlay-foreground-color);
129
+ color: var(--map-overlay-halo-color);
130
+
131
+ width: var(--touch-button-size);
132
+ height: var(--touch-button-size);
133
+ border-radius: 100%;
134
+
135
+ &::before {
136
+ box-shadow: none;
137
+ }
125
138
  }
126
139
 
127
140
  .im-o-app__right {
@@ -111,17 +111,69 @@ export const PopupMenu = ({ popupMenuId, buttonId, instigatorId, pluginId, start
111
111
  setIndex(vis[nextPos])
112
112
  }
113
113
 
114
+ /**
115
+ * Helper: Invoke a menu item's action via buttonConfig or item.onClick.
116
+ * @param {Event} e - The triggering event
117
+ * @param {Object} item - The item to activate
118
+ */
119
+ const activateItem = (e, item) => {
120
+ const menuItemConfig = buttonConfig[item.id]
121
+ if (typeof menuItemConfig?.onClick === 'function') {
122
+ menuItemConfig.onClick(e, evaluateProp(ctx => ctx, pluginId))
123
+ } else if (typeof item.onClick === 'function') {
124
+ item.onClick(e.nativeEvent)
125
+ } else {
126
+ // No action
127
+ }
128
+ // For keyboard events, also dispatch a synthetic click so native window listeners fire
129
+ // (e.g. editVertexMode.onButtonClick for delete/undo in edit_vertex mode).
130
+ // Marked with _fromKeyboardActivation so handleItemClick ignores it and only the
131
+ // window listener handles it — preventing double-activation.
132
+ if (e.nativeEvent instanceof KeyboardEvent) {
133
+ const el = document.getElementById(`${id}-${stringToKebab(item.id)}`)
134
+ if (el) {
135
+ const click = new MouseEvent('click', { bubbles: true, cancelable: true })
136
+ click._fromKeyboardActivation = true
137
+ el.dispatchEvent(click)
138
+ }
139
+ }
140
+ }
141
+
114
142
  /**
115
143
  * Helper: Handle Enter key press.
116
- * Calls onClick on selected item (by index), then closes menu and returns focus to instigator.
144
+ * Closes menu, returns focus to instigator, then activates the selected item if enabled.
117
145
  * @param {KeyboardEvent} e
118
146
  * The Enter keydown event
119
147
  */
120
148
  const handleEnter = (e) => {
121
149
  e.preventDefault()
150
+ const item = items[index]
151
+ if (item && !disabledButtons.has(item.id)) {
152
+ activateItem(e, item)
153
+ }
122
154
  instigator.focus()
123
155
  setIsOpen(false)
124
- items[index]?.onClick(e.nativeEvent)
156
+ }
157
+
158
+ /**
159
+ * Helper: Handle Space key press.
160
+ * For menuitemcheckbox: activates item only (menu stays open).
161
+ * For menuitem: closes menu, returns focus to instigator, then activates item.
162
+ * @param {KeyboardEvent} e
163
+ * The Space keydown event
164
+ */
165
+ const handleSpace = (e) => {
166
+ e.preventDefault()
167
+ const item = items[index]
168
+ if (!item || disabledButtons.has(item.id)) {
169
+ return
170
+ }
171
+ const isCheckbox = item.isPressed !== undefined || item.pressedWhen
172
+ activateItem(e, item)
173
+ if (!isCheckbox) {
174
+ instigator.focus()
175
+ setIsOpen(false)
176
+ }
125
177
  }
126
178
 
127
179
  /**
@@ -160,6 +212,9 @@ export const PopupMenu = ({ popupMenuId, buttonId, instigatorId, pluginId, start
160
212
  if (e.key === 'Enter') {
161
213
  handleEnter(e)
162
214
  }
215
+ if (e.key === ' ') {
216
+ handleSpace(e)
217
+ }
163
218
  }
164
219
 
165
220
  /**
@@ -177,21 +232,21 @@ export const PopupMenu = ({ popupMenuId, buttonId, instigatorId, pluginId, start
177
232
 
178
233
  /**
179
234
  * Helper: Handle item click.
180
- * Looks up buttonConfig[item.id] to decide which onClick to call (item's or buttonConfig's).
181
- * Closes menu after invoking onClick.
235
+ * Closes menu and activates the item; does nothing if the item is disabled.
182
236
  * @param {React.MouseEvent} e
183
237
  * React synthetic event from the LI click
184
238
  * @param {Object} item
185
239
  * The clicked item object with {id, label, onClick, ...}
186
240
  */
187
241
  const handleItemClick = (e, item) => {
188
- const menuItemConfig = buttonConfig[item.id]
189
- setIsOpen(false)
190
- if (typeof menuItemConfig?.onClick !== 'function') {
191
- item.onClick?.(e.nativeEvent)
242
+ if (e.nativeEvent._fromKeyboardActivation) {
192
243
  return
193
244
  }
194
- menuItemConfig.onClick(e, evaluateProp(ctx => ctx, pluginId))
245
+ if (disabledButtons.has(item.id)) {
246
+ return
247
+ }
248
+ setIsOpen(false)
249
+ activateItem(e, item)
195
250
  }
196
251
 
197
252
  useEffect(() => {
@@ -219,7 +274,7 @@ export const PopupMenu = ({ popupMenuId, buttonId, instigatorId, pluginId, start
219
274
  <ul // NOSONAR
220
275
  ref={menuRef}
221
276
  id={popupMenuId}
222
- className='fm-c-popup-menu'
277
+ className='im-c-popup-menu'
223
278
  role='menu' // NOSONAR
224
279
  tabIndex='-1'
225
280
  aria-labelledby={instigatorKey}
@@ -230,15 +285,15 @@ export const PopupMenu = ({ popupMenuId, buttonId, instigatorId, pluginId, start
230
285
  <li // NOSONAR
231
286
  key={item.id}
232
287
  id={`${id}-${stringToKebab(items[i].id)}`}
233
- className={`fm-c-popup-menu__item${index === i ? ' fm-c-popup-menu__item--selected' : ''}`}
234
- role='menuitem' // NOSONAR
288
+ className={`im-c-popup-menu__item${index === i ? ' im-c-popup-menu__item--selected' : ''}`}
289
+ role={items[i].isPressed !== undefined || items[i].pressedWhen ? 'menuitemcheckbox' : 'menuitem'} // NOSONAR
235
290
  aria-disabled={disabledButtons.has(items[i].id) || undefined} // NOSONAR
236
- aria-pressed={(items[i].isPressed !== undefined || items[i].pressedWhen) ? pressedButtons.has(items[i].id) : undefined} // NOSONAR
291
+ aria-checked={(items[i].isPressed !== undefined || items[i].pressedWhen) ? pressedButtons.has(items[i].id) : undefined} // NOSONAR
237
292
  style={hiddenButtons.has(items[i].id) ? { display: 'none' } : undefined}
238
293
  onClick={(e) => handleItemClick(e, items[i])} // NOSONAR
239
294
  >
240
295
  {(item.iconId || item.iconSvgContent) && <Icon id={item.iconId} svgContent={item.iconSvgContent} />}
241
- <span className='fm-c-popup-menu__item-label'>{item.label}</span>
296
+ <span className='im-c-popup-menu__item-label'>{item.label}</span>
242
297
  </li>
243
298
  ))}
244
299
  </ul>
@@ -6,7 +6,7 @@
6
6
 
7
7
  // 1. Base styles
8
8
 
9
- .fm-c-popup-menu {
9
+ .im-c-popup-menu {
10
10
  @include tools.border-focus-base(
11
11
  $is-inset: false,
12
12
  $type: button
@@ -20,8 +20,9 @@
20
20
  }
21
21
 
22
22
  // 2. Elements
23
- .fm-c-popup-menu__item {
23
+ .im-c-popup-menu__item {
24
24
  display: flex;
25
+ position: relative;
25
26
  align-items: center;
26
27
  padding: var(--divider-gap);
27
28
  border-top: 1px solid var(--button-hover-color);
@@ -34,13 +35,13 @@
34
35
  border-top: 0;
35
36
  }
36
37
 
37
- &:hover:not(.fm-c-popup-menu__item--selected) {
38
+ &:hover:not(.im-c-popup-menu__item--selected) {
38
39
  @media (hover: hover) and (pointer: fine) {
39
40
  background-color: var(--button-hover-color);
40
41
  }
41
42
  }
42
43
 
43
- &:hover:not(.fm-c-popup-menu__item--selected) .fm-c-popup-menu__item-label {
44
+ &:hover:not(.im-c-popup-menu__item--selected) .im-c-popup-menu__item-label {
44
45
  text-decoration: underline;
45
46
  text-underline-offset: 2px;
46
47
  text-decoration-thickness: 2px;
@@ -52,18 +53,80 @@
52
53
  background-color: var(--button-hover-color);
53
54
  }
54
55
 
55
- &--selected .fm-c-popup-menu__item-label {
56
+ &--selected .im-c-popup-menu__item-label {
56
57
  @include tools.link-focus;
57
58
  }
58
59
 
59
60
  svg + span {
60
- margin-left: var(--button-icon-label-offset);
61
+ margin-left: calc(var(--button-icon-label-offset) + 3px);
61
62
  white-space: nowrap;
62
63
  }
64
+
65
+ &[aria-disabled="true"] .im-c-popup-menu__item-label,
66
+ &[aria-disabled="true"] svg {
67
+ opacity: 0.5;
68
+ }
69
+ }
70
+
71
+ .im-c-popup-menu__item[role="menuitemcheckbox"] {
72
+ padding-right: 75px;
73
+
74
+ &::before {
75
+ content: '';
76
+ position: absolute;
77
+ border: 1px solid var(--foreground-color);
78
+ left: auto;
79
+ top: 12px;
80
+ right: 12px;
81
+ width: 20px;
82
+ height: 20px;
83
+ opacity: 0.2;
84
+ }
85
+
86
+ &::after {
87
+ content: '';
88
+ position: absolute;
89
+ top: 17px;
90
+ left: auto;
91
+ right: 16px;
92
+ width: 12px;
93
+ height: 6.5px;
94
+ border: solid;
95
+ border-width: 0 0 3px 3px;
96
+ transform: rotate(-45deg);
97
+ opacity: 0;
98
+ }
99
+
100
+ &[aria-checked="true"]::before {
101
+ top: 10px;
102
+ right: 10px;
103
+ width: 24px;
104
+ height: 24px;
105
+ border-width: 2px;
106
+ opacity: 1;
107
+ }
108
+
109
+ &[aria-checked="true"]::after {
110
+ opacity: 1;
111
+ }
112
+ }
113
+
114
+ .im-c-popup-menu__item[role="menuitemcheckbox"]:hover::before,
115
+ .im-c-popup-menu__item--selected[role="menuitemcheckbox"]::before,
116
+ .im-c-popup-menu__item--selected[role="menuitemcheckbox"][aria-checked="true"]::before {
117
+ top: 10px;
118
+ right: 10px;
119
+ width: 24px;
120
+ height: 24px;
121
+ border-width: 4px;
122
+ outline: 3px solid transparent;
123
+ outline-offset: 1px;
124
+ box-shadow: 0 0 0 3px #ffdd00;
125
+ opacity: 1;
63
126
  }
64
127
 
65
128
  // 3. Modifiers
66
- .im-o-app__actions .fm-c-popup-menu {
129
+ .im-o-app__actions .im-c-popup-menu {
67
130
  left: 50%;
68
131
  transform: translateX(-50%);
69
132
  bottom: calc(100% + (var(--primary-gap) * 2));