@tomtom-org/maps-sdk 0.57.0 → 0.58.0

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.
@@ -1,2 +1,2 @@
1
- import{isEmpty as e,isEqual as t,isNil as i,mapValues as r,omit as s,omitBy as o,remove as a}from"lodash-es";import{DEFAULT_COMMON_BASE_URL as n,MILE_IN_METERS as l,TomTomConfig as c,bboxCenter as h,bboxFromCoordsArray as u,bboxFromGeoJSON as d,formatDistance as p,formatDuration as y,generateId as f,generateTomTomHeaders as m,getPosition as g,iconToTrafficIncidentCategory as _,indexedMagnitudes as b,isProxyCredentialsMode as L,mergeFromGlobal as S,poiCategoriesToID as I,trafficIncidentToIconCategory as A}from"@tomtom-org/maps-sdk/core";import{bearing as E,booleanPointInPolygon as v,difference as R,featureCollection as T,hexGrid as w,mask as C,squareGrid as O}from"@turf/turf";import{Map as M,getRTLTextPluginStatus as N,getVersion as x,setRTLTextPlugin as D,setWorkerCount as F}from"maplibre-gl";var k=class{constructor(e,t){this.userEventsInstance=e,this.moduleEventsInstance=t}where(e,t){return this.userEventsInstance.where(e,t)}on(e,t){return"config-change"===e?this.moduleEventsInstance.on("config-change",t):"shown-features"===e?this.moduleEventsInstance.on("shown-features",t):this.userEventsInstance.on(e,t)}off(e){"config-change"===e||"shown-features"===e?this.moduleEventsInstance.off(e):this.userEventsInstance.off(e)}},P=(e,t)=>e?t?(...i)=>e(...i)&&t(...i):e:t,U=(e,t)=>{if(!e)return t;if(!t)return e;const i=P(e.layerFilter,t.layerFilter),r=P(e.featureMatches,t.featureMatches);return i||r?{layerFilter:i,featureMatches:r}:void 0},H=(e,t)=>t?.layerFilter?e._layerSpecs.filter(t.layerFilter):e._layerSpecs,W=["on","off","where"],G=(e,t)=>{const i=e.find(e=>W.includes(e));if(i)throw new Error(`${t} uses the reserved event scope name "${i}". Reserved: ${W.join(", ")}.`)},B=e=>{if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!B(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}},V=e=>"$type"===e?["geometry-type"]:"$id"===e?["id"]:["get",e],z=e=>"$type"===e||("$id"===e?["!=",["id"],null]:["has",e]),j=(e,t)=>!!t.length&&["in",V(e),["literal",t]],$=e=>{const t=e[0];if(e.length<=1)return"any"!==t;const i=e[1],r=e.slice(2),s=e.slice(1);switch(t){case"has":return z(i);case"!has":return["!",z(i)];case"==":case"!=":return(null===r[0]?((e,t)=>{if("$id"!==t&&"$type"!==t)return"=="===e?["all",["has",t],["==",["get",t],null]]:["any",["!",["has",t]],["!=",["get",t],null]]})(t,i):void 0)??[t,V(i),r[0]];case">":case">=":case"<":case"<=":return((e,t,i)=>["all",["==",["typeof",V(t)],typeof i],[e,V(t),i]])(t,i,r[0]);case"in":return j(i,r);case"!in":return["!",j(i,r)];case"all":return["all",...s.map(e=>K(e))];case"any":return["any",...s.map(e=>K(e))];case"none":return["!",["any",...s.map(e=>K(e))]];default:return!0}},K=e=>B(e)?e:$(e),Y=e=>e?.length?1===e.length?e[0]:["any",...e]:null,q=(e,t,i)=>{if(1===i.length)return["only"===t?"==":"!=",["get",e],i[0]];const r=["in",["get",e],["literal",i]];return"only"===t?r:["!",r]},Z=(e,t,i)=>q(e,t.show,i?t.values.map(i):t.values),X=/* @__PURE__ */new WeakMap,J=(e,t,i)=>{void 0!==i?e.set(t,i):e.delete(t)},Q=class e{constructor(e){this.byLayer=/* @__PURE__ */new Map,this.mapLibreMap=e.mapLibreMap,e.addStyleChangeHandler({onStyleAboutToChange:()=>this.byLayer.clear(),priority:Number.NEGATIVE_INFINITY})}static for(t){let i=X.get(t);return i||(i=new e(t),X.set(t,i)),i}setTransform(e,t,i){this.contribute(e,({transforms:e})=>J(e,t,i))}setClause(e,t,i){this.contribute(e,({clauses:e})=>J(e,t,i))}contribute(e,t){if(!this.mapLibreMap.getLayer(e))return;let i=this.byLayer.get(e);i||(i={styleFilter:this.mapLibreMap.getFilter(e),transforms:/* @__PURE__ */new Map,clauses:/* @__PURE__ */new Map},this.byLayer.set(e,i)),t(i),this.apply(e,i)}apply(e,t){const i=[...t.transforms.values()].reduce((e,t)=>t(e),t.styleFilter),r=((e,t)=>{if(!t.length)return e;const i=null==e?t:[...t,K(e)];return 1===i.length?i[0]:["all",...i]})(i,[...t.clauses.values()]);this.mapLibreMap.setFilter(e,r??null,{validate:!1})}},ee=class{constructor(e,t){this.configChangeHandlers=e,this.shownFeaturesHandlers=t}on(e,t){if("config-change"===e){const e=t;return this.configChangeHandlers.push(e),()=>{const t=this.configChangeHandlers.indexOf(e);-1!==t&&this.configChangeHandlers.splice(t,1)}}const i=t;return this.shownFeaturesHandlers.push(i),()=>{const e=this.shownFeaturesHandlers.indexOf(i);-1!==e&&this.shownFeaturesHandlers.splice(e,1)}}off(e){"config-change"===e?this.configChangeHandlers.length=0:this.shownFeaturesHandlers.length=0}},te=["road_category","road_subcategory","relative_speed","left_hand_traffic","road_closure","absolute_speed","part_of_two_way_road","openlr","display_class"],ie=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{roadCategory:t?.road_category,leftHandTraffic:Boolean(t?.left_hand_traffic),roadClosure:Boolean(t?.road_closure),relativeSpeed:t?.relative_speed,...t?.road_subcategory&&{roadSubcategory:t.road_subcategory},...t?.absolute_speed&&{absoluteSpeed:t.absolute_speed},...t?.part_of_two_way_road&&{partOfTwoWayRoad:Boolean(t.part_of_two_way_road)},...t?.openlr&&{openlr:t.openlr},...t?.display_class&&{displayClass:t.display_class}}}},re=["icon_category","left_hand_traffic","magnitude_of_delay","road_category","road_subcategory","id","description","delay","part_of_two_way_road","start_time","end_time","probability_of_occurrence","number_of_reports","last_report_time","average_speed_kmph","openlr","time_validity","display_class"],se=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{id:t.id??f(),description:t?.description_0??"",category:_(t?.icon_category_0),magnitudeOfDelay:b[t?.magnitude_of_delay],roadCategory:t?.road_category,roadSubcategory:t?.road_subcategory,leftHandTraffic:Boolean(t?.left_hand_traffic),...t?.delay&&{delayInSeconds:t.delay},...t?.part_of_two_way_road&&{partOfTwoWayRoad:Boolean(t.part_of_two_way_road)},...t?.start_time&&{startTime:new Date(t.start_time)},...t?.end_time&&{endTime:new Date(t.end_time)},...t?.probability_of_occurrence&&{probabilityOfOccurrence:t.probability_of_occurrence},...t?.number_of_reports&&{numberOfReports:t.number_of_reports},...t?.last_report_time&&{lastReportTime:new Date(t.last_report_time)},...t?.average_speed_kmph&&{averageSpeedKmph:t.average_speed_kmph},...t?.openlr&&{openlr:t.openlr},...t?.time_validity&&{timeValidity:t.time_validity},...t?.display_class&&{displayClass:t.display_class},...t?.point_type&&{pointType:t.point_type}}}},oe=e=>{const t=e%360;return t<0?t+360:t},ae=(e,t,i)=>Math.min(Math.max(t,e),i),ne=e=>!e.some(Number.isNaN),le=e=>Number.parseInt(e.padEnd(2,e),16)/255,ce=(e,t)=>ae(t?e/100:e,0,1),he=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,ue=/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,de=e=>{const t=ue.exec(e);if(!t)return;const[,i,r,s,o,a,n,l,c]=t,h=[r||" ",o||" ",n].join("");if(" "!==h&&" /"!==h&&",,"!==h&&",,,"!==h)return;const u=[+i,ae(+s,0,100),ae(+a,0,100),l?ce(+l,c):1];return ne(u)?(([e,t,i,r])=>{const s=oe(e),o=t/100,a=i/100,n=e=>{const t=(e+s/30)%12,i=o*Math.min(a,1-a);return a-i*Math.max(-1,Math.min(t-3,9-t,1))};return[n(0),n(8),n(4),r]})(u):void 0},pe=e=>{const t=e.toLowerCase().trim();if("transparent"===t)return[0,0,0,0];const i=Se[t];if(i){const[e,t,r]=i;return[e/255,t/255,r/255,1]}return t.startsWith("#")?(e=>{if(!/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e))return;const t=e.length<6?1:2;return[le(e.slice(1,1+t)),le(e.slice(1+t,1+2*t)),le(e.slice(1+2*t,1+3*t)),le(e.slice(1+3*t)||"ff")]})(t):t.startsWith("rgb")?(e=>{const t=he.exec(e);if(!t)return;const[,i,r,s,o,a,n,l,c,h,u,d]=t,p=[s||" ",n||" ",h].join("");if(" "!==p&&" /"!==p&&",,"!==p&&",,,"!==p)return;const y=[r,a,c].join(""),f="%%%"===y?100:""===y?255:0;if(!f)return;const m=[ae(+i/f,0,1),ae(+o/f,0,1),ae(+l/f,0,1),u?ce(+u,d):1];return ne(m)?m:void 0})(t):de(t)},ye=e=>{const t=pe(e);return t&&(([e,t,i,r])=>{const s=Math.max(e,t,i),o=Math.min(e,t,i),a=(s+o)/2,n=s-o;if(0===n)return[0,0,100*a,r];const l=n/(1-Math.abs(2*a-1));let c;return c=s===e?(t-i)/n%6:s===t?(i-e)/n+2:(e-t)/n+4,[oe(60*c),100*l,100*a,r]})(t)},fe=e=>"string"==typeof e&&void 0!==ye(e),me=(e,t)=>{const i=ye(e),r=ye(t);if(i&&r)return{hue:i[1]<1||r[1]<1?0:r[0]-i[0],saturation:r[1]-i[1],lightness:r[2]-i[2],alpha:r[3]-i[3]}},ge=(e,t)=>{const i=ye(e);if(i)return(([e,t,i,r])=>{const s=Math.round(oe(e)),o=Math.round(ae(t,0,100)),a=Math.round(ae(i,0,100));return r<1?`hsla(${s}, ${o}%, ${a}%, ${Math.round(100*r)/100})`:`hsl(${s}, ${o}%, ${a}%)`})([i[0]+t.hue,i[1]+t.saturation,i[2]+t.lightness,ae(i[3]+t.alpha,0,1)])},_e=e=>{const t=pe(e);if(!t)return;const i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*i(t[0])+.7152*i(t[1])+.0722*i(t[2])},be=(e,t)=>{const i=pe(e);if(!i)return;const r=1-t;return Le(i.slice(0,3).map(e=>255*e*r))},Le=e=>`#${e.map(e=>Math.round(ae(e,0,255)).toString(16).padStart(2,"0")).join("")}`,Se={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Ie=e=>/* @__PURE__ */new Error(`Trying to ${e} while it is not in the map style. Did you exclude it when loading the map?`),Ae="pinCategories",Ee=e=>`${Ae}:${e}`,ve=()=>"undefined"!=typeof document&&"undefined"!=typeof DOMParser&&"undefined"!=typeof btoa,Re=e=>{if(!ve())return;const t=document.createElement("img");return t.src=`data:image/svg+xml;base64,${btoa((new XMLSerializer).serializeToString(e))}`,t},Te=e=>(new DOMParser).parseFromString(e,"image/svg+xml").documentElement,we=e=>((e,t)=>(t?.fillColor&&e.querySelector("#background")?.setAttribute("fill",t.fillColor),t?.outlineColor&&e.querySelector("#outline")?.setAttribute("fill",t.outlineColor),void 0!==t?.outlineOpacity&&e.querySelector("#outline")?.setAttribute("fill-opacity",t.outlineOpacity.toString()),e))(Te('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path id="background" d="M63.95 137.516c6.556-12.737 19.098-21.09 30.828-29.388C110.046 97.324 120 79.603 120 59.574 120 26.671 93.138 0 60 0S0 26.671 0 59.574c0 20.029 9.954 37.75 25.22 48.55 11.734 8.302 24.274 16.652 30.83 29.388 1.706 3.316 6.194 3.316 7.9 0z"\n fill="#1988cf"/>\n <path id="outline" d="M91.298 103.272C105.052 93.544 114 77.596 114 59.574c0-29.61-24.176-53.617-54-53.617S6 29.964 6 59.574c0 18.022 8.95 33.97 22.7 43.698l2.27 1.601c10.172 7.153 21.922 15.423 29.03 27.416 7.104-11.993 18.858-20.259 29.03-27.416l2.268-1.601zm1.468 6.274c-11.13 7.845-22.632 15.957-28.816 27.966-1.706 3.316-6.194 3.316-7.9 0-6.182-12.009-17.686-20.121-28.816-27.966l-2.016-1.422C9.954 97.324 0 79.603 0 59.574 0 26.671 26.862 0 60 0s60 26.671 60 59.574c0 20.029-9.954 37.75-25.222 48.55l-2.016 1.422z"\n fill-opacity=".3"/>\n</svg>\n'),e),Ce=async e=>{e.mapReady||(await e.mapLibreMap.once("styledata"),await Ce(e))},Oe=e=>{const t=globalThis.__DEMOS_PROXY_ENSURE_SESSION__;return"function"!=typeof t?e:t().then(()=>e,()=>e)},Me=e=>{const t=e.commonBaseURL??n,i=t!==n,r=L(e);return(s,o)=>{const a=((e,t,i,r)=>{if(!i)return e;try{const i=new URL(e);return"api.tomtom.com"===(s=i.hostname)||s.endsWith(".api.tomtom.com")?(r&&i.searchParams.delete("key"),t+i.pathname+i.search+i.hash):e}catch{return e}var s})(s,t,i,r),n=i&&a.startsWith(t),l=r&&n;let c=!1;try{const e=new URL(s).hostname;c="tomtom.com"===e||e.endsWith(".tomtom.com")}catch{c=!1}if(!c&&!n)return{url:a};if("Image"===o)return l?Oe({url:a,credentials:"include"}):{url:a};const h=new URL(a);(e=>{e.pathname.includes("incidents")?e.searchParams.set("tags",re.join(",")):e.pathname.includes("flow")&&e.searchParams.set("tags",te.join(","))})(h);const u={url:h.toString(),headers:{...m(e)}};return l?(u.credentials="include",Oe(u)):u}},Ne=(e,t,i)=>{const r=e.id;e.maxzoom===t.maxzoom&&e.minzoom===t.minzoom||i.setLayerZoomRange(r,e.minzoom??i.getMinZoom(),e.maxzoom??i.getMaxZoom()),i.setFilter(r,e.filter,{validate:!1});for(const s of Object.keys(t.layout??{}))e.layout?.[s]||i.setLayoutProperty(r,s,void 0,{validate:!1});for(const s of Object.keys(t.paint??{}))e.paint?.[s]||i.setPaintProperty(r,s,void 0,{validate:!1});for(const[s,o]of Object.entries(e.paint??{}))i.setPaintProperty(r,s,o,{validate:!1});for(const[s,o]of Object.entries(e.layout??{}))i.setLayoutProperty(r,s,o,{validate:!1})},xe=(e,t,i,r)=>{const s=e.reduce((e,t)=>({...e,[t.id]:t}),{}),o=t.reduce((e,t)=>({...e,[t.id]:t}),{}),a=[],n=[],l=[],c=[];Object.keys(s).forEach(e=>{o[e]?(l.push(s[e]),c.push(o[e])):a.push(e)}),Object.keys(o).forEach(e=>{s[e]||n.push(e)});const h=i._layerSpecs;n.forEach(e=>{r.removeLayer(e);for(let t=0;t<h.length;t++)if(h[t].id===e){h.splice(t,1);break}});const u=a.map(e=>({...s[e],source:i.source.id}));u.length&&(h.push(...u),ke(u,r)),i._updateSourceAndLayerIDs(),((e,t,i,r)=>{const s=/* @__PURE__ */new Set,o=e=>{if(!r.getLayer(e.id))return;Fe(r,e.id,e.beforeID),s.add(e.id);const t=i.find(t=>t.id===e.id);t&&(t.beforeID=e.beforeID)};e.forEach((e,i)=>{e.beforeID!==t[i].beforeID&&o(e)});const a=()=>e.filter(e=>!s.has(e.id)&&void 0!==e.beforeID&&s.has(e.beforeID));for(let n=a();n.length;n=a())n.forEach(o)})(l,c,h,r),((e,t,i)=>{e.forEach((e,r)=>Ne(e,t[r],i))})(l,c,r)},De=(e,t)=>t&&e.getLayer(t)?t:void 0,Fe=(e,t,i)=>{e.moveLayer(t,De(e,i))},ke=(e,t)=>{const i=/* @__PURE__ */new Set,r=e=>{t.getLayer(e.id)||t.addLayer({...e,layout:{...e.layout,visibility:"none"}},e.beforeID),i.add(e.id)},s={};for(e.forEach(e=>{e.beforeID?i.has(e.beforeID)||t.getLayer(e.beforeID)?(i.add(e.beforeID),r(e)):s[e.beforeID]?s[e.beforeID].push(e):s[e.beforeID]=[e]:r(e)});Object.keys(s).length>0;){const e=Object.keys(s).filter(e=>i.has(e));if(!e.length)return void console.error(`Some layers cannot be added. Check for non-existing layers, or circular beforeID dependencies for the following: ${JSON.stringify(Object.keys(s))}`);e.forEach(e=>{s[e].forEach(e=>r(e)),delete s[e]})}},Pe=(e,t)=>{switch(typeof e){case"undefined":return{type:"standard",include:[t]};case"string":return{type:"standard",id:e,include:[t]};default:if("standard"===e.type)return e.include?{...e,include:[...e.include,t]}:{...e,include:[t]};throw(e=>/* @__PURE__ */new Error(`The custom map style has no '${e}' part and the SDK cannot add one to it. Style-owned modules work on a custom style only when it already ships the matching source (e.g. built with Map Maker with that part enabled) — or switch to a standard style.`))(t)}},Ue=async(e,t,i)=>{if(!e.mapLibreMap.getSource(t)){const r=e.mapLibreMap;r.isStyleLoaded()||await r.once("idle"),await e.setStyle(Pe(e.getStyle(),i)),await(async(e,t)=>{e.mapLibreMap.getSource(t)&&e.mapLibreMap.isSourceLoaded(t)||await e.mapLibreMap.once("sourcedata")})(e,t)}},He=async(e,t,i,r,s)=>{if(!i)return void console.warn(`addOrUpdateImage called with empty image for ID ${t}`);const o=i=>{const o=r.hasImage(t);o&&"add-or-update"==e?r.updateImage(t,i):o||r.addImage(t,i,s)},a=e=>{e.complete?e.naturalWidth>0?o(e):console.warn(`Failed to load image for ID ${t}`):(e.onload=()=>o(e),e.onerror=()=>console.warn(`Failed to load image for ID ${t}`))};if("string"==typeof i)if(i.includes("<svg"))a(Re(Te(i)));else try{o((await r.loadImage(i)).data)}catch(n){console.warn(`Failed to load image for ID ${t}`,n)}else a(i)},We=e=>{switch(e){case"standardDark":case"drivingDark":case"monoDark":case"satellite":return"dark";default:return"light"}},Ge=e=>{if("string"==typeof e)return We(e);const t=Be(e);if(t)return t;const i=e;return i?.id?We(i.id):"light"},Be=e=>Ve(e)?e.lightDarkTheme:void 0,Ve=e=>"object"==typeof e&&"custom"===e?.type,ze=e=>{if("string"==typeof e)return void 0===_e(e)?void 0:e;if(Array.isArray(e))for(const t of e){const e=ze(t);if(e)return e}},je=class e{constructor(e){this.options=e,this.sources=e.sourcesWithLayers}where(t,i){return new e({...this.options,config:i??this.options.config,scope:U(this.options.scope,this.resolveScope(t))})}resolveScope(e){if("function"==typeof e){const t=e,i=this.options.mapping;return{featureMatches:i?e=>t(i(e)):e=>t(e)}}const t=this.options.scopeResolver;if(!t)throw new Error("This module supports only feature predicates in events.where().");return t(e)}on(e,t){const{eventProxy:i,config:r,owner:s,scope:o}=this.options,a=this.toRegisteredHandler(t),n=[];for(const l of this.sources)i.addEventHandler(l,a,e,{config:r,owner:s,scope:o}),n.push(l);return()=>{for(const t of n)i.removeHandler(t,e,a)}}toRegisteredHandler(e){const{mapping:t,scope:i}=this.options,r=i?.featureMatches;if(!t&&!r)return e;const s=e=>t?t(e):e;return r?(t,i,o,a)=>{const n=(o.length?o:[t]).filter(e=>r(e));if(!n.length)return;const l=n.map(s);e(l[0],i,l,a)}:(t,i,r,o)=>e(s(t),i,r.map(s),o)}off(e){for(const t of this.sources)this.options.eventProxy.remove(t,e,this.options.owner)}},$e=class e{static{this.instanceCounters=/* @__PURE__ */new WeakMap}constructor(t,i){this._initializing=!0,this.configChangeHandlers=[],this.moduleReady=!1;const r=new.target,s=e.instanceCounters.get(r)??-1;this.instanceIndex=s+1,e.instanceCounters.set(r,this.instanceIndex),this.tomtomMap=t,this.eventsProxy=t._eventsProxy,this.mapLibreMap=t.mapLibreMap,this.filterComposer=Q.for(t),this.initSourcesWithLayers(i),this.applyConfig(i),this.tomtomMap.addStyleChangeHandler({onStyleAboutToChange:()=>{this.moduleReady=!1},onStyleChanged:({resetState:e})=>e?this.resetOnNewStyle():this.restoreDataAndConfig(),priority:this.styleChangePriority()}),this._initializing=!1}styleChangePriority(){return 0}initSourcesWithLayers(e,t){this.moduleReady=!1,this.sourcesWithLayers=this._initSourcesWithLayers(e,t),this._sourceAndLayerIDs=Object.fromEntries(Object.entries(this.sourcesWithLayers).map(([e,t])=>[e,t.sourceAndLayerIDs])),t&&this.eventsProxy.updateIfRegistered(this.sourcesWithLayers,this),this.tomtomMap.mapReady&&(this.moduleReady=!0)}async waitUntilModuleReady(){await Ce(this.tomtomMap),this.moduleReady||await new Promise(e=>{const t=setInterval(()=>{this.tomtomMap.mapReady&&this.moduleReady&&(clearInterval(t),e())},200)})}applyConfig(e){this.config=this._applyConfig(e),this.emitConfigChange()}updateConfig(e){this.applyConfig({...this.config,...e})}emitConfigChange(){if(!this._initializing)for(const e of this.configChangeHandlers)e(this.config)}resetConfig(){this.applyConfig(void 0)}restoreDataAndConfig(){this.moduleReady=!1,this.restoreDataAndConfigImpl()}resetOnNewStyle(){this.moduleReady=!1,this.config=void 0,this.discardShownData(),this.initSourcesWithLayers(void 0,!0),this.config=this._applyConfig(void 0),this.emitConfigChange()}discardShownData(){}restoreDataAndConfigImpl(){this.initSourcesWithLayers(this.config,!0),this._applyConfig(this.config)}getConfig(){return this.config&&{...this.config}}get sourceAndLayerIDs(){return this._sourceAndLayerIDs}userEvents(e,t={}){return new je({eventProxy:this.eventsProxy,sourcesWithLayers:e.map(e=>this.sourcesWithLayers[e]).filter(e=>!!e),owner:this,config:this.config?.events,mapping:t.mapping,scopeResolver:t.scopeResolver})}lifecycleEvents(){return new ee(this.configChangeHandlers,[])}moduleEvents(e,t={}){return new k(this.userEvents(e,t),this.lifecycleEvents())}moduleEventsWithShown(e,t,i={}){return new k(this.userEvents(e,i),new ee(this.configChangeHandlers,t))}buildEvents(e,t){return G(Object.keys(t),this.constructor.name),Object.assign(e,t)}},Ke=class extends $e{},Ye=class extends $e{},qe=class{constructor(){this.interactiveLayerIDs=[],this.handlers={click:{},contextmenu:{},hover:{},"hover-move":{},"long-hover":{}},this.findHandlers=(e,t,i)=>t&&e.flatMap(e=>{const r=this.handlers[e][t]??[];return i?r.filter(e=>!e.scope?.featureMatches||e.scope.featureMatches(i)):r})||[]}ensureInteractiveLayerIDsAdded(e){for(const t of e)this.interactiveLayerIDs.includes(t)||this.interactiveLayerIDs.push(t)}releaseUnusedInteractiveLayerIDs(e){a(this.interactiveLayerIDs,t=>e.has(t)&&!this.hasHandlerForLayer(t))}indexHandler(e,t){const i=this.handlers[t];for(const r of e.layerIDs)i[r]??=[],i[r].push(e)}unindexHandlers(e,t){const i=this.handlers[t],r=/* @__PURE__ */new Set;for(const s of e)for(const t of s.layerIDs){r.add(t);const s=i[t];s&&(a(s,t=>e.has(t)),s.length||delete i[t])}return r}dropHandlers(e,t,i){const r=e.source.id,s=/* @__PURE__ */new Set;for(const o of Object.values(this.handlers[t]))for(const e of o)e.sourceWithLayers.source.id===r&&i(e)&&s.add(e);s.size&&this.releaseUnusedInteractiveLayerIDs(this.unindexHandlers(s,t))}addEventHandler(e,t,i,r){const s=new Set(H(e,r.scope).map(e=>e.id));this.ensureInteractiveLayerIDsAdded(s),this.indexHandler({...r,sourceWithLayers:e,layerIDs:s,fn:t},i)}removeHandler(e,t,i){this.dropHandlers(e,t,e=>e.fn===i)}remove(e,t,i){this.dropHandlers(e,t,e=>e.owner===i)}removeAll(){this.interactiveLayerIDs=[],this.handlers={click:{},contextmenu:{},hover:{},"hover-move":{},"long-hover":{}}}hasHandlerForLayer(e){return Object.values(this.handlers).some(t=>!!t[e]?.length)}sourceWithLayersFor(e){if(e)for(const t of Object.values(this.handlers)){const i=t[e];if(i?.length)return i[0].sourceWithLayers}}updateIfRegistered(e,t){const i=new Map(Object.values(e).map(e=>[e.source.id,e]));for(const r of Object.keys(this.handlers)){const e=/* @__PURE__ */new Set;for(const o of Object.values(this.handlers[r]))for(const r of o)r.owner===t&&i.has(r.sourceWithLayers.source.id)&&e.add(r);if(!e.size)continue;const s=this.unindexHandlers(e,r);for(const t of e){const e=i.get(t.sourceWithLayers.source.id);t.sourceWithLayers=e,t.layerIDs=new Set(H(e,t.scope).map(e=>e.id)),this.ensureInteractiveLayerIDsAdded(t.layerIDs),this.indexHandler(t,r)}this.releaseUnusedInteractiveLayerIDs(s)}}},Ze=e=>{const t=e.properties?.id;return"string"==typeof t||"number"==typeof t?t:e.id},Xe=(e,t)=>{if(null!=t)for(let i=0;i<e.length;i++)if(Ze(e[i])===t)return{feature:e[i],index:i}};var Je,Qe,et,tt=e=>(function(e){if(i(e))throw new Error(`${e} must not be null/undefined. Something went wrong with its initialization.`)}(e),e),it=class{constructor(e,t,i){this.id=e,this.spec=t,this.runtimeSource=i}ensureAddedToMap(e){this.runtimeSource||(!e.getSource(this.id)&&this.spec&&e.addSource(this.id,this.spec),this.runtimeSource=e.getSource(this.id))}},rt=class{constructor(e,t,i){this.map=e,this.source=t,this._layerSpecs=i,this._updateSourceAndLayerIDs()}get mapRemoved(){return!0===this.map._removed}isAnyLayerVisible(e){return this.getLayerSpecs(e).some(e=>this.isLayerVisible(e))}areAllLayersVisible(e){return this.getLayerSpecs(e).every(e=>this.isLayerVisible(e))}getLayerSpecs(e){return e?this._layerSpecs.filter(e):this._layerSpecs}_updateSourceAndLayerIDs(){this._sourceAndLayerIDs={sourceID:this.source.id,layerIDs:this._layerSpecs.map(e=>e.id)}}isLayerVisible(e){return!this.mapRemoved&&(!!this.map.getLayer(e.id)&&"none"!==this.map.getLayoutProperty(e.id,"visibility"))}setLayersVisible(e,t){if(!this.mapRemoved)for(const i of this.getLayerSpecs(t))this.map.getLayer(i.id)&&this.map.setLayoutProperty(i.id,"visibility",e?"visible":"none",{validate:!1})}get sourceAndLayerIDs(){return this._sourceAndLayerIDs}},st=(e,t)=>e.getStyle().layers.filter(e=>t.includes(e?.source)),ot=class extends rt{constructor(e,t,i){let r=st(e,[t.id]);i&&(r=r.filter(i)),super(e,new it(t.id,e.getStyle().sources[t.id],t),r)}},at=class extends rt{constructor(e,t,i,r){super(e,new it(t,i),r.map(e=>({...e,source:t})))}ensureLayersAddedToMap(){if(!this.mapRemoved)for(const e of this._layerSpecs)this.map.getLayer(e.id)||this.map.addLayer(e,e.beforeID)}ensureAddedToMapWithVisibility(e,t){this.mapRemoved||(this.source.ensureAddedToMap(this.map),t&&(this.ensureLayersAddedToMap(),this.setLayersVisible(e)))}},nt={type:"FeatureCollection",features:[]},lt=class extends at{constructor(e,t,i,r=!0,s){super(e,t,s?.cluster?{type:"geojson",data:nt,...s}:{type:"geojson",data:nt,promoteId:"id",...s??{}},i),this.shownFeatures=nt,this.ensureAddedToMapWithVisibility(!1,r)}show(e,{automaticVisibility:t=!0}={}){this.shownFeatures=e,this.mapRemoved||(tt(this.source.runtimeSource).setData(e),t&&this.setLayersVisible(!!e.features.length))}findById(e){return Xe(this.shownFeatures.features,e)}clear(){this.show(nt)}findFeature(e){return"index"in e?this.shownFeatures.features[e.index]:"id"in e?this.findById(e.id)?.feature:void 0}putEventState(e){if("put"===(e.mode??"put"))for(const i of this.shownFeatures.features)i.properties?.eventState===e.state&&delete i.properties.eventState;const t=this.findFeature(e);t&&(t.properties={...t.properties,eventState:e.state}),!1!==e.show&&this.show(this.shownFeatures,{automaticVisibility:!1})}cleanEventState(e){const t=this.findFeature(e);t?.properties?.eventState&&(delete t?.properties?.eventState,!1!==e?.show&&this.show(this.shownFeatures,{automaticVisibility:!1}))}cleanEventStates(e){let t=!1;for(const i of this.shownFeatures.features)e?.states&&!e.states.includes(i.properties?.eventState)||(delete i.properties?.eventState,t=!0);!1!==e?.show&&t&&this.show(this.shownFeatures,{automaticVisibility:!1})}},ct=e=>"click"===e||"contextmenu"===e,ht=(e,t,i,r="updateInProps")=>{const{feature:o,index:a}=Xe(i,t)||{};if(o&&(!ct(o.properties?.eventState)||ct(e))){const t={...o,properties:"updateInProps"===r?{...o?.properties,eventState:e}:s(o?.properties,"eventState")};return i.splice(a,1,t),a}},ut=(e,t,r)=>{const s=[...r.shownFeatures.features],o=ht(e,Ze(t),s,"removeFromProps");i(o)||r.show({...r.shownFeatures,features:s},{automaticVisibility:!1})},dt=(e,t,i,r,s)=>{if(t&&r instanceof lt){const n=[...r.shownFeatures.features];return ht(e,Ze(t),n),!i||(a=t,(o=i)&&a&&o.id===a.id)||(s===r?ht(e,Ze(i),n,"removeFromProps"):s instanceof lt&&ut(e,i,s)),void r.show({...r.shownFeatures,features:n},{automaticVisibility:!1})}var o,a;i&&s instanceof lt&&ut(e,i,s)},pt=[],yt={precisionMode:"box",paddingBoxPx:5,cursorOnHover:"pointer",cursorOnMouseDown:"grabbing",cursorOnMap:"default",longHoverDelayAfterMapMoveMS:800,longHoverDelayOnStillMapMS:300},ft=class extends qe{constructor(e,t={}){super(),this.enabled=!0,this.firstDelayedHoverSinceMapMove=!0,this.mouseMoveFrameRequested=!1,this.map=e,this.mapCanvas=e.getCanvas(),this.config={...yt,...t},this.mapCanvas.style.cursor=this.config.cursorOnMap,this.lastCursorStyle=this.config.cursorOnMap,this.listenToEvents()}listenToEvents(){this.map.on("mousemove",e=>this.onMouseMove(e)),this.map.on("movestart",()=>this.onMouseStart()),this.map.on("mouseout",()=>this.onMouseOut()),this.map.on("mouseover",e=>this.onMouseMove(e)),this.map.on("mousedown",()=>this.onMouseDown()),this.map.on("mouseup",()=>this.onMouseUp()),this.map.on("click",e=>this.onMapClick("click",e)),this.map.on("contextmenu",e=>this.onMapClick("contextmenu",e))}enable(e){this.enabled=e,e||(this.clearLongHoverTimeout(),this.pendingMouseMove=void 0)}toPaddedBounds(e){const t=this.config.paddingBoxPx;return[[e.x-t,e.y+t],[e.x+t,e.y-t]]}isEnabled(){return this.enabled&&!this.map.isMoving()}toCallerFeatures(e,t,i){const r=i?e.filter(e=>i.has(e.layer.id)):e,s=(e=>{const t=/* @__PURE__ */new Set,i=[];for(const r of e){const e=Ze(r);if(void 0===e){i.push(r);continue}const s=`${r.source} ${e}`;t.has(s)||(t.add(s),i.push(r))}return i})((o=r,a=t?.source,a?o.filter(e=>e.source===a):o));var o,a;const n=this.sourceWithLayersFor(t?.layer.id);return n instanceof lt?s.map(e=>n.findById(Ze(e))?.feature??e):s}callerFeaturesFor(e,t,i,r){return e.scope?.layerFilter?this.toCallerFeatures(t,i,e.layerIDs):r}getRenderedFeatures(e){if(!this.interactiveLayerIDs.length)return[];const t={layers:this.interactiveLayerIDs,validate:!1},i=this.config.precisionMode,r="point-then-box"===i||"point"===i?this.map.queryRenderedFeatures(e,t):[];return r.length||"point"===i?r:this.map.queryRenderedFeatures(this.toPaddedBounds(e),t)}clearLongHoverTimeout(){window.clearTimeout(this.longHoverTimeoutHandlerID)}restartLongHoverTimeout(){this.clearLongHoverTimeout(),this.longHoverTimeoutHandlerID=window.setTimeout(()=>this.handleLongHoverTimeout(),this.firstDelayedHoverSinceMapMove?this.config.longHoverDelayAfterMapMoveMS:this.config.longHoverDelayOnStillMapMS)}handleLongHoverTimeout(){if(this.firstDelayedHoverSinceMapMove=!1,this.hoveringSourceWithLayers){dt("long-hover",this.hoveringFeature,void 0,this.hoveringSourceWithLayers,void 0);const e=this.findHandlers(["long-hover"],this.hoveringFeature?.layer.id);if(e.length){const t=this.hoveringFeatures??pt,i=this.hoveringFeature,r=this.toCallerFeatures(t,i);for(const s of e){const e=this.callerFeaturesFor(s,t,i,r);s.fn(e[0],this.hoveringLngLat,e,s.sourceWithLayers)}}}}onMouseStart(){this.firstDelayedHoverSinceMapMove=!0,this.clearLongHoverTimeout()}onMouseOut(){this.clearLongHoverTimeout()}onMouseDown(){this.lastCursorStyle=this.mapCanvas.style.cursor,this.mapCanvas.style.cursor=this.config.cursorOnMouseDown}onMouseUp(){this.mapCanvas.style.cursor=this.lastCursorStyle}onMouseMove(e){this.pendingMouseMove=e,this.mouseMoveFrameRequested||(this.mouseMoveFrameRequested=!0,requestAnimationFrame(()=>{this.mouseMoveFrameRequested=!1;const e=this.pendingMouseMove;this.pendingMouseMove=void 0,e&&this.handleMouseMove(e)}))}handleMouseMove(e){if(!this.isEnabled())return;this.hoveringFeatures=this.getRenderedFeatures(e.point);const[t]=this.hoveringFeatures;if(t&&!this.hasHandlerForLayer(t.layer.id))return;const{hoverChanged:i,mouseInMotionOverHoveredFeature:r}=((e,t,i,r)=>{if(t){if(!r)return{hoverChanged:!0};if(t.id&&t.id!==r.id||t.properties.id&&t.properties.id!==r.properties.id||t.source!==r.source||t.layer.id!==r.layer.id)return{hoverChanged:!0};if(i&&(e.x-i.x!=0||e.y-i.y!=0))return{mouseInMotionOverHoveredFeature:!0}}else if(r)return{hoverChanged:!0};return{}})(e.point,t,this.hoveringPoint,this.hoveringFeature);if(!i&&!r)return;const s=this.hoveringFeature,o=this.hoveringSourceWithLayers;let a;this.hoveringLngLat=e.lngLat,this.hoveringPoint=e.point,this.hoveringFeature=t,this.hoveringSourceWithLayers=this.sourceWithLayersFor(t?.layer.id),i&&(a=this.dispatchHoverEnter(e,s,o)),r&&this.dispatchHoverMove(e,a),this.restartLongHoverTimeout()}dispatchHoverEnter(e,t,i){const r=this.hoveringFeature?.layer.id,s=this.findHandlers(["hover","hover-move","long-hover","click","contextmenu"],r,this.hoveringFeature)?.[0];this.updateHoverCursor(s?.config),dt("hover",this.hoveringFeature,t,this.hoveringSourceWithLayers,i);const o=this.findHandlers(["hover"],r);if(!o.length)return;const a=this.toCallerFeatures(this.hoveringFeatures??pt,this.hoveringFeature);return this.dispatchToHandlers(o,e,this.hoveringFeature,a),a}dispatchHoverMove(e,t){const i=this.findHandlers(["hover-move"],this.hoveringFeature?.layer.id);if(!i.length)return;const r=this.hoveringFeature,s=t??this.toCallerFeatures(this.hoveringFeatures??pt,r);this.dispatchToHandlers(i,e,r,s)}dispatchToHandlers(e,t,i,r){for(const s of e){const e=this.callerFeaturesFor(s,this.hoveringFeatures??pt,i,r);s.fn(e[0],t.lngLat,e,s.sourceWithLayers)}}updateHoverCursor(e){this.hoveringFeature?this.mapCanvas.style.cursor=e?.cursorOnHover??this.config.cursorOnHover:this.mapCanvas.style.cursor=this.config.cursorOnMap}onMapClick(e,t){if(!this.isEnabled())return;const i=this.getRenderedFeatures(t.point),r=this.lastClickedFeature;this.lastClickedFeature=i[0];const s=this.lastClickedSourceWithLayers,o=this.findHandlers([e],this.lastClickedFeature?.layer.id);if(this.lastClickedSourceWithLayers=o[0]?.sourceWithLayers,dt(e,this.lastClickedFeature,r,this.lastClickedSourceWithLayers,s),o.length){const e=this.lastClickedFeature,r=this.toCallerFeatures(i,e);for(const s of o){const o=this.callerFeaturesFor(s,i,e,r);s.fn(o[0],t.lngLat,o,s.sourceWithLayers)}}}},mt=(e,t,i,r,s,o)=>({id:e,kind:t,description:i,default:r,current:s??r,overridden:void 0!==s,...o}),gt=e=>Object.fromEntries(e.filter(e=>e.overridden).map(e=>[e.id,e.current])),_t="Noto-Bold",bt="Noto-Regular",Lt="Noto-Medium",St="NotoSans-MediumItalic",It=["interpolate",["linear"],["zoom"],10,14,18,16],At=[bt,St,_t,Lt],Et=.8,vt=["interpolate",["linear"],["zoom"],8,.6,22,Et],Rt={country:"Places - Country name",lowestPlaceLabel:"Places - Village / Hamlet",poi:"POI",lowestLabel:"Borders - Treaty label",lowestRoadLine:"Tunnel - Railway outline",lowestBuilding:"Buildings - Underground"},Tt="vectorTiles",wt="hillshade",Ct="hillshade-terrain",Ot="vectorTiles",Mt="vectorTilesIncidents",Nt="vectorTilesFlow",xt=/* @__PURE__ */new WeakMap,Dt=async(e,t,i,r)=>{let s=xt.get(e);s||(s=/* @__PURE__ */new Map,xt.set(e,s));const o=s.get(t);if(o){const e=await o;return r?.(e),e}const a=Promise.resolve().then(i);s.set(t,a);try{return await a}catch(n){throw s.delete(t),n}},Ft=["POI","POI - Micro"],kt={NATIVE_RESERVATION:"aboriginal_land",AIRPORT:"airport",AMUSEMENT_PARK:"amusement_park",ATM:"atm",BANK:"bank",BAR:"bar",BEACH:"beach_resort",ACCESS_GATEWAY:"border_control",FRONTIER_CROSSING:"border_control",BUS_STOP:"bus_station",CAFE:"cafe",CAFE_PUB:"cafe",CAMPING_GROUND:"camping_ground",RENT_A_CAR_FACILITY:"car_rental",CASINO:"casino_and_gambling",CEMETERY:"cemetery",ELECTRIC_VEHICLE_STATION:"charging_location",CINEMA:"cinema",MOVIE_THEATER:"cinema",HEALTH_CARE_SERVICE:"clinic",CLOTHING_SHOP:"clothing_shop",COFFEE_SHOP:"coffee_shop",COLLEGE_OR_UNIVERSITY:"college_or_university",COLLEGE_UNIVERSITY:"college_or_university",AGRICULTURE:"commercial_area",BUSINESS_PARK:"commercial_area",COMMERCIAL_BUILDING:"commercial_area",COMPANY:"commercial_area",RESIDENTIAL_ACCOMMODATION:"commercial_area",EXHIBITION_CONVENTION_CENTER:"conference_center",CLUB_ASSOCIATION:"consumer_service",PUBLIC_AMENITY:"consumer_service",WELFARE_ORGANIZATION:"consumer_service",COURTHOUSE:"courthouse",COMMUNITY_CENTER:"cultural_center",CULTURAL_CENTER:"cultural_center",DENTIST:"dentist",DEPARTMENT_STORE:"department_store",DOCTOR:"doctor",EMERGENCY_MEDICAL_SERVICE:"emergency_ward_entrance",EMERGENCY_ROOM:"emergency_ward_entrance",FAST_FOOD:"fast_food",FERRY_TERMINAL:"ferry_terminal",FIRE_STATION_BRIGADE:"fire_station",FITNESS_CLUB_CENTER:"fitness_center",WINERY:"food_and_drinks_shop",CURRENCY_EXCHANGE:"foreign_exchange",EXCHANGE:"foreign_exchange",GAS_STATION:"fuel_station",GOLD_EXCHANGE:"gold_exchange",GOLF_COURSE:"golf_course",EMBASSY:"government_office",GOVERNMENT_OFFICE:"government_office",HELIPAD_HELICOPTER_LANDING:"heliport_or_helipad",HISTORIC_SITE:"historic_site",HOLIDAY_RENTAL:"holiday_home",GENERAL_HOSPITAL_AND_POLYCLINIC:"hospital",HOSPITAL:"hospital",HOTEL_MOTEL:"hotel_or_motel",ICE_SKATING_RINK:"ice_rink",INDUSTRIAL_BUILDING:"industrial_area",PORT_WAREHOUSE_FACILITY:"industrial_area",PRIMARY_RESOURCE_UTILITY:"industrial_area",GEOGRAPHIC_FEATURE:"landmark",SHOPPING_CENTER:"mall",MANUFACTURING_FACILITY:"manufacturing_facility",MARINA:"marina",MARKET:"marketplace",MEDIA_FACILITY:"media_facility",MOUNTAIN_PASS:"mountain_pass",MUSEUM:"museum",NON_GOVERNMENTAL_ORGANIZATION:"ngo_office",CONCERT_HALL:"nightlife",ENTERTAINMENT:"nightlife",NIGHTLIFE:"nightlife",PARK_RECREATION_AREA:"park_and_recreation_area",TRAIL_SYSTEM:"park_and_recreation_area",LEISURE_CENTER:"park_and_recreation_facility",WATER_SPORT:"park_and_recreation_facility",OPEN_PARKING_AREA:"parking_facility",PARKING_GARAGE:"parking_facility",PHARMACY:"pharmacy",POLICE_STATION:"police_station",POST_OFFICE:"post_office",PRISON_CORRECTIONAL_FACILITY:"prison",PROTECTED_AREA:"protected_land",PUB:"pub",LIBRARY:"public_library",PUBLIC_TRANSPORT_STOP:"public_transport_stop",RAILWAY_STATION:"railway_station",CHURCH:"religious_site",GURUDWARA:"religious_site",MOSQUE:"religious_site",PAGODA:"religious_site",PLACE_OF_WORSHIP:"religious_site",SYNAGOG:"religious_site",TEMPLE:"religious_site",RENT_A_CAR_PARKING:"rental_car_parking",RESEARCH_FACILITY:"research_facility",REST_AREA:"rest_and_service_area",RESTAURANT:"restaurant",RESTAURANT_AREA:"restaurant",SCHOOL:"school_or_kindergarten",SHOP:"shop_or_store",ADVENTURE_SPORTS_FACILITY:"sport_facility",SPORTS_CENTER:"sport_facility",TENNIS_COURT:"sport_facility",STADIUM:"stadium",SUPERMARKETS_HYPERMARKETS:"supermarket",SWIMMING_POOL:"swimming_pool",TAXI_STAND:"taxi_stand",OPERA_HOUSE:"theater",THEATER:"theater",TOLL_GATE:"toll_booth",TOURIST_ATTRACTION:"tourist_attraction",TOURIST_INFORMATION_OFFICE:"tourist_information",TRUCK_STOP:"truck_stop",AUTOMOTIVE_DEALER:"vehicle_dealer",MOTORING_ORGANIZATION_OFFICE:"vehicle_inspection",TRAFFIC_CONTROL_DEPARTMENT:"vehicle_inspection",TRANSPORT_AUTHORITY_VEHICLE_REGISTRATION:"vehicle_inspection",REPAIR_FACILITY:"vehicle_repair",CAR_WASH:"vehicle_wash",VETERINARIAN:"veterinary",HILL:"viewpoint",MOUNTAIN_PEAK:"viewpoint",SCENIC_PANORAMIC_VIEW:"viewpoint",WEIGH_STATION:"weighbridge",AQUATIC_ZOO:"zoo_or_aquarium",ARBORETA_BOTANICAL_GARDENS:"zoo_or_aquarium",ZOOS_ARBORETA_BOTANICAL_GARDEN:"zoo_or_aquarium"},Pt={...kt,AIRFIELD:"airport",AIRLINE_ACCESS:"airport",PRIVATE_AIRPORT:"airport",PUBLIC_AIRPORT:"airport",ANIMAL_SHELTER:"animal_shelter",DIVERSIFIED_FINANCIALS:"bank",COCKTAIL_BAR:"bar",BEACH_CLUB:"beach_resort",SECURED_ENTRANCE:"border_control",INTERNET_CAFE:"cafe",CAFETERIA:"cafeteria",CARAVAN_SITE:"camping_ground",RECREATIONAL_CAMPING_GROUND:"camping_ground",REST_CAMP:"camping_ground",MAUSOLEUM_GRAVE:"cemetery",CHILD_CARE_FACILITY:"childcare",PRE_SCHOOL:"childcare",DRIVE_IN_MOVIES:"cinema",CHILDRENS_CLOTHES:"clothing_shop",MENS_CLOTHING:"clothing_shop",SPECIALTY_CLOTHING_SHOP:"clothing_shop",WOMENS_CLOTHING:"clothing_shop",JUNIOR_COLLEGE_COMMUNITY_COLLEGE:"college_or_university",COMEDY_CLUB:"comedy_club",ADVERTISING_COMPANY:"commercial_area",AGRICULTURAL_TECHNOLOGY:"commercial_area",AIRLINE_COMPANY:"commercial_area",APARTMENT_RENTAL:"commercial_area",AUTOMOBILE_COMPANY:"commercial_area",BUILDING:"commercial_area",BUSINESS_SERVICES:"commercial_area",BUS_CHARTER_COMPANY:"commercial_area",CABLE_TELEPHONE_COMPANY:"commercial_area",CLEANING_SERVICES:"commercial_area",COMPUTER_DATA_SERVICES:"commercial_area",CONSTRUCTION_COMPANY:"commercial_area",DELIVERY_SERVICE:"commercial_area",ELECTRONICS_COMPANY:"commercial_area",EQUIPMENT_RENTAL:"commercial_area",FARM:"commercial_area",FLATS_APARTMENT_COMPLEX:"commercial_area",HORTICULTURE:"commercial_area",IMPORT_EXPORT_AND_DISTRIBUTION:"commercial_area",INSURANCE_COMPANY:"commercial_area",INVESTMENT_ADVISOR:"commercial_area",LEGAL_SERVICES:"commercial_area",MINING_COMPANY:"commercial_area",MOVING_STORAGE_COMPANY:"commercial_area",OIL_NATURAL_GAS:"commercial_area",PHARMACEUTICAL_COMPANY:"commercial_area",PRIMARY_PRODUCER:"commercial_area",PUBLISHING_TECHNOLOGIES:"commercial_area",REAL_ESTATE_AGENT:"commercial_area",REAL_ESTATE_COMPANY:"commercial_area",RETIREMENT_COMMUNITY:"commercial_area",SERVICE_COMPANY:"commercial_area",SOFTWARE_COMPANY:"commercial_area",TAX_SERVICES:"commercial_area",TELECOMMUNICATIONS:"commercial_area",TRANSPORT_COMPANY:"commercial_area",TRAVEL_AGENT:"commercial_area",WEDDING_SERVICES:"commercial_area",PUBLIC_CALL_BOX:"consumer_service",PUBLIC_TOILET:"consumer_service",GENERAL_PRACTITIONER:"doctor",SPECIALIST:"doctor",AMBULANCE_UNIT:"emergency_ward_entrance",ROAD_RESCUE:"emergency_ward_entrance",MICROBREWERY:"food_and_drinks_shop",BATTLEFIELD:"historic_site",MEMORIAL:"historic_site",BUNGALOW_RENTAL:"holiday_home",CHALET_RENTAL:"holiday_home",COTTAGE_RENTAL:"holiday_home",VILLA_RENTAL:"holiday_home",HORSE_RIDING_CENTER:"horse_riding",BLOOD_BANK:"hospital",HOSPITAL_FOR_WOMEN_AND_CHILDREN:"hospital",HOSPITAL_OF_CHINESE_MEDICINE:"hospital",SPECIAL_HOSPITAL:"hospital",B_B_GUEST_HOUSE:"hotel_or_motel",CABINS_LODGES:"hotel_or_motel",HOSTEL:"hotel_or_motel",HOTEL:"hotel_or_motel",MOTEL:"hotel_or_motel",RESORT:"hotel_or_motel",ICE_CREAM_PARLOR:"ice_cream_shop",ICE_HOCKEY_ARENA:"ice_rink",CHEMICAL_COMPANY:"industrial_area",MECHANICAL_ENGINEERING:"industrial_area",QUARRY:"industrial_area",YOGURT_JUICE_BAR:"juice_bar",ARCH:"landmark",BAY:"landmark",BRIDGE:"landmark",CAPE:"landmark",COVE:"landmark",DAM:"landmark",DUNE:"landmark",ISLAND:"landmark",LOCALE:"landmark",MARSH:"landmark",MONUMENT:"landmark",OASIS:"landmark",OBSERVATORY:"landmark",PARKWAY:"landmark",PLAIN_FLAT:"landmark",PLATEAU:"landmark",RAPIDS:"landmark",REEF:"landmark",RESERVOIR:"landmark",RIVER_CROSSING:"landmark",ROCKS:"landmark",STATUE:"landmark",TOWER:"landmark",TUNNEL:"landmark",VALLEY:"landmark",WATER_HOLE:"landmark",WELL:"landmark",AUTOMOBILE_MANUFACTURING:"manufacturing_facility",MANUFACTURING_COMPANY:"manufacturing_facility",FARMERS_MARKET:"marketplace",FOOD_MARKET:"marketplace",INFORMAL_MARKET:"marketplace",PUBLIC_MARKET:"marketplace",MILITARY_AIRPORT:"military_airfield",FUNERAL_SERVICE_MORTUARIES:"mourning_facility",AMUSEMENT_PLACE:"nightlife",BETTING_STATION:"nightlife",CABARET_THEATER:"nightlife",DISCO_CLUB:"nightlife",FAIRGROUND:"nightlife",JAZZ_CLUB:"nightlife",KARAOKE_CLUB:"nightlife",MUSIC_CENTER:"nightlife",ADVENTURE_VEHICLE_TRAIL:"park_and_recreation_area",FISHING_HUNTING_AREA:"park_and_recreation_area",FOREST_AREA:"park_and_recreation_area",HIKING_TRAIL:"park_and_recreation_area",HISTORICAL_PARK:"park_and_recreation_area",HORSE_RIDING_TRAIL:"park_and_recreation_area",MOUNTAIN_BIKE_TRAIL:"park_and_recreation_area",PARK:"park_and_recreation_area",PICNIC_AREA:"park_and_recreation_area",RECREATION_AREA:"park_and_recreation_area",ROCK_CLIMBING_TRAIL:"park_and_recreation_area",WILDERNESS_AREA:"park_and_recreation_area",OPEN_CAR_PARKING_AREA:"parking_facility",BEAUTY_SALON:"personal_care_service",HAIRDRESSER:"personal_care_service",NAIL_SALON:"personal_care_service",PERSONAL_CARE_FACILITY:"personal_care_service",PERSONAL_SERVICE:"personal_care_service",SAUNA_SOLARIUM_MASSAGE:"personal_care_service",DRUG_STORE:"pharmacy",MARIJUANA_DISPENSARY:"pharmacy",MEDICINAL_MARIJUANA_DISPENSARY:"pharmacy",RECREATIONAL_MARIJUANA_DISPENSARY:"pharmacy",PLANETARIUM:"planetarium",COURIER_DROP_BOX:"post_depot",BUS_LINES:"public_transport_stop",PASSENGER_TRANSPORT_TICKET_OFFICE:"public_transport_stop",STREETCAR_STOP:"public_transport_stop",SUBWAY_STATION:"public_transport_stop",INTERNATIONAL_RAILROAD_STATION:"railway_station",NATIONAL_RAILROAD_STATION:"railway_station",STATION_ACCESS:"railway_station",URBAN_STATION:"railway_station",AFGHAN_RESTAURANT:"restaurant",AFRICAN_RESTAURANT:"restaurant",AMERICAN_RESTAURANT:"restaurant",ARABIAN_RESTAURANT:"restaurant",ARMENIAN_RESTAURANT:"restaurant",ASIAN_RESTAURANT:"restaurant",AUSTRALIAN_RESTAURANT:"restaurant",AUSTRIAN_RESTAURANT:"restaurant",BANQUET_ROOMS:"restaurant",BARBECUE_RESTAURANT:"restaurant",BASQUE_RESTAURANT:"restaurant",BELGIAN_RESTAURANT:"restaurant",BISTRO:"restaurant",BOLIVIAN_RESTAURANT:"restaurant",BRAZILIAN_RESTAURANT:"restaurant",BRITISH_RESTAURANT:"restaurant",BUFFET_RESTAURANT:"restaurant",BULGARIAN_RESTAURANT:"restaurant",BURMESE_RESTAURANT:"restaurant",CALIFORNIAN_RESTAURANT:"restaurant",CAMBODIAN_RESTAURANT:"restaurant",CANADIAN_RESTAURANT:"restaurant",CARIBBEAN_RESTAURANT:"restaurant",CATERING_SERVICES:"restaurant",CHICKEN_RESTAURANT:"restaurant",CHINESE_RESTAURANT:"restaurant",COLOMBIAN_RESTAURANT:"restaurant",CORSICAN_RESTAURANT:"restaurant",CREOLE_RESTAURANT:"restaurant",CREPERIE:"restaurant",CUBAN_RESTAURANT:"restaurant",CZECH_RESTAURANT:"restaurant",DANISH_RESTAURANT:"restaurant",DINNER_THEATER:"restaurant",DONGBEI_RESTAURANT:"restaurant",DOUGHNUT_RESTAURANT:"restaurant",DUTCH_RESTAURANT:"restaurant",EGYPTIAN_RESTAURANT:"restaurant",ENGLISH_RESTAURANT:"restaurant",ETHIOPIAN_RESTAURANT:"restaurant",FINNISH_RESTAURANT:"restaurant",FONDUE_RESTAURANT:"restaurant",FRENCH_RESTAURANT:"restaurant",FUSION_RESTAURANT:"restaurant",GERMAN_RESTAURANT:"restaurant",GREEK_RESTAURANT:"restaurant",GRILL_RESTAURANT:"restaurant",HAMBURGER_RESTAURANT:"restaurant",HAWAIIAN_RESTAURANT:"restaurant",HOT_POT_RESTAURANT:"restaurant",HUNAN_RESTAURANT:"restaurant",HUNGARIAN_RESTAURANT:"restaurant",INDIAN_RESTAURANT:"restaurant",INDONESIAN_RESTAURANT:"restaurant",INTERNATIONAL_RESTAURANT:"restaurant",IRANIAN_RESTAURANT:"restaurant",IRISH_RESTAURANT:"restaurant",ISRAELI_RESTAURANT:"restaurant",ITALIAN_RESTAURANT:"restaurant",JAMAICAN_RESTAURANT:"restaurant",JAPANESE_RESTAURANT:"restaurant",JEWISH_RESTAURANT:"restaurant",KOREAN_RESTAURANT:"restaurant",KOSHER_RESTAURANT:"restaurant",LATIN_AMERICAN_RESTAURANT:"restaurant",LEBANESE_RESTAURANT:"restaurant",MEDITERRANEAN_RESTAURANT:"restaurant",MEXICAN_RESTAURANT:"restaurant",MIDDLE_EASTERN_RESTAURANT:"restaurant",MONGOLIAN_RESTAURANT:"restaurant",MOROCCAN_RESTAURANT:"restaurant",NEPALESE_RESTAURANT:"restaurant",NORWEGIAN_RESTAURANT:"restaurant",ORGANIC_FOOD_RESTAURANT:"restaurant",ORIENTAL_RESTAURANT:"restaurant",PAKISTANI_RESTAURANT:"restaurant",PERUVIAN_RESTAURANT:"restaurant",PHILIPPINE_RESTAURANT:"restaurant",PIZZERIA:"restaurant",POLISH_RESTAURANT:"restaurant",POLYNESIAN_RESTAURANT:"restaurant",PORTUGUESE_RESTAURANT:"restaurant",PUB_FOOD:"restaurant",RUSSIAN_RESTAURANT:"restaurant",SALAD_BAR:"restaurant",SANDWICH_RESTAURANT:"restaurant",SCANDINAVIAN_RESTAURANT:"restaurant",SEAFOOD:"restaurant",SHANDONG_RESTAURANT:"restaurant",SICHUAN_RESTAURANT:"restaurant",SNACKS_RESTAURANT:"restaurant",SOUL_FOOD:"restaurant",SOUP_RESTAURANT:"restaurant",SPANISH_RESTAURANT:"restaurant",STEAK_HOUSE:"restaurant",SUSHI_RESTAURANT:"restaurant",SWEDISH_RESTAURANT:"restaurant",SWISS_RESTAURANT:"restaurant",SYRIAN_RESTAURANT:"restaurant",TAIWANESE_RESTAURANT:"restaurant",TAKEOUT_FOOD:"restaurant",TAPAS_RESTAURANT:"restaurant",TEPPANYAKI_RESTAURANT:"restaurant",THAI_RESTAURANT:"restaurant",TIBETAN_RESTAURANT:"restaurant",TUNISIAN_RESTAURANT:"restaurant",TURKISH_RESTAURANT:"restaurant",VEGETARIAN_RESTAURANT:"restaurant",VENEZUELAN_RESTAURANT:"restaurant",VIETNAMESE_RESTAURANT:"restaurant",WESTERN_RESTAURANT:"restaurant",ART_SCHOOL:"school_or_kindergarten",DANCE_STUDIO_SCHOOL:"school_or_kindergarten",DRIVING_SCHOOL:"school_or_kindergarten",HIGH_SCHOOL:"school_or_kindergarten",LANGUAGE_SCHOOL:"school_or_kindergarten",MIDDLE_SCHOOL:"school_or_kindergarten",PRIMARY_SCHOOL:"school_or_kindergarten",SENIOR_HIGH_SCHOOL:"school_or_kindergarten",VOCATIONAL_SCHOOL:"school_or_kindergarten",AGRICULTURAL_SUPPLIES:"shop_or_store",ANTIQUE_ART_SHOP:"shop_or_store",BAGS_LEATHERWEAR:"shop_or_store",BAKERY:"shop_or_store",BEAUTY_SUPPLIES:"shop_or_store",BOATING_EQUIPMENT_ACCESSORIES:"shop_or_store",BOOK_SHOP:"shop_or_store",BUTCHER:"shop_or_store",CAMERAS_PHOTOGRAPHY:"shop_or_store",CARPET_FLOOR_COVERINGS:"shop_or_store",CHRISTMAS_HOLIDAY_SHOP:"shop_or_store",COMPUTER_COMPUTER_SUPPLIES:"shop_or_store",CONSTRUCTION_MATERIAL_EQUIPMENT:"shop_or_store",CONSUMER_ELECTRONICS:"shop_or_store",CONVENIENCE_STORE:"shop_or_store",CURTAINS_TEXTILES:"shop_or_store",C_DS_DVD_VIDEOS:"shop_or_store",DELICATESSEN:"shop_or_store",DO_IT_YOURSELF_CENTERS:"shop_or_store",DRIVE_THROUGH_BOTTLE_SHOP:"shop_or_store",DRY_CLEANER:"shop_or_store",ELECTRICAL_APPLIANCES_SHOP:"shop_or_store",FACTORY_OUTLET:"shop_or_store",FISHMONGER:"shop_or_store",FLORISTS:"shop_or_store",FOOTWEAR_SHOE_REPAIRS:"shop_or_store",FURNITURE_HOME_FURNISHINGS:"shop_or_store",GARDEN_CENTERS_SERVICES:"shop_or_store",GIFTS_CARDS_NOVELTIES_SOUVENIRS:"shop_or_store",GLASSWARE_CERAMIC_SHOP:"shop_or_store",GLASS_WINDOWS_STORE:"shop_or_store",GREENGROCER:"shop_or_store",GROCERY_STORE:"shop_or_store",HARDWARE_STORE:"shop_or_store",HOBBY_SHOP:"shop_or_store",HOUSE_GARDEN_FURNITURE_FITTINGS:"shop_or_store",JEWELRY_CLOCKS_WATCHES:"shop_or_store",KITCHENS_BATHROOMS:"shop_or_store",LAUNDRY:"shop_or_store",LIGHTING_SHOPS:"shop_or_store",LOCAL_SPECIALITIES_SHOP:"shop_or_store",LOTTERY_SHOP:"shop_or_store",MEDICAL_SUPPLIES_EQUIPMENT:"shop_or_store",MOBILE_PHONE_SHOP:"shop_or_store",MUSIC_INSTRUMENTS_STORE:"shop_or_store",NEWSAGENTS_TOBACCONISTS:"shop_or_store",OFFICE_EQUIPMENT:"shop_or_store",OPTICIAN:"shop_or_store",OTHER_FOOD_SHOPS:"shop_or_store",PAINTING_DECORATING:"shop_or_store",PAWN_SHOP:"shop_or_store",PET_SUPPLIES:"shop_or_store",PHOTOCOPY_SHOP:"shop_or_store",PHOTO_LAB_DEVELOPMENT:"shop_or_store",RECYCLING_SHOP:"shop_or_store",RETAIL_OUTLET:"shop_or_store",SECURITY_PRODUCTS:"shop_or_store",SHOPPING_SERVICE:"shop_or_store",SPECIALTY_FOODS:"shop_or_store",SPORTS_EQUIPMENT_CLOTHING:"shop_or_store",TAILOR_SHOP:"shop_or_store",TOYS_GAMES_SHOP:"shop_or_store",VARIETY_STORE:"shop_or_store",VIDEO_RENTAL_SHOP:"shop_or_store",WHOLESALE_CLUB:"shop_or_store",WINE_SPIRITS:"shop_or_store",ATHLETICS_TRACK:"sport_facility",BASEBALL_PARK:"sport_facility",BASKETBALL_ARENA:"sport_facility",BOWLING_CENTER:"sport_facility",CRICKET_GROUND:"sport_facility",HOCKEY_CLUB:"sport_facility",HORSE_RACING_TRACK:"sport_facility",RACE_TRACK:"sport_facility",RUGBY_GROUND:"sport_facility",SNOOKER_POOL_BILLIARD:"sport_facility",THEMATIC_SPORT_CENTER:"sport_facility",FOOTBALL_STADIUM:"stadium",MOTOR_RACING_STADIUM:"stadium",MULTI_PURPOSE_STADIUM:"stadium",NETBALL_STADIUM:"stadium",SOCCER_STADIUM:"stadium",STOCK_EXCHANGE:"stock_exchange",TAXI_LIMOUSINE_SHUTTLE_SERVICE:"taxi_stand",TEA_HOUSE:"tea_house",AMPHITHEATER:"theater",CAVE:"tourist_attraction",MINERAL_HOT_SPRINGS:"tourist_attraction",NATURAL_TOURIST_ATTRACTION:"tourist_attraction",BOAT_LAUNCHING_RAMP:"transport_access",HARBOR:"transport_access",YACHT_BASIN:"transport_access",ATV_DEALER:"vehicle_dealer",BOAT_DEALER:"vehicle_dealer",BUS_DEALER:"vehicle_dealer",CAR_DEALER:"vehicle_dealer",MOTORCYCLE_DEALER:"vehicle_dealer",RECREATIONAL_VEHICLE_DEALER:"vehicle_dealer",TRUCK_DEALER:"vehicle_dealer",VAN_DEALER:"vehicle_dealer",ROAD_TRAFFIC_CONTROL_CENTER:"vehicle_inspection",BODYSHOP:"vehicle_repair",CAR_GLASS_REPLACEMENT_SHOP:"vehicle_repair",CAR_REPAIR_AND_SERVICE:"vehicle_repair",HOME_APPLIANCE_REPAIR:"vehicle_repair",MOTORCYCLE_REPAIR:"vehicle_repair",TIRE_SERVICE:"vehicle_repair",TRUCK_REPAIR_AND_SERVICE:"vehicle_repair",ANIMAL_SERVICES:"veterinary",RIDGE:"viewpoint",OTHER_WINTER_SPORT:"winter_sports",SKI_RESORT:"winter_sports",WILDLIFE_PARK:"zoo_or_aquarium",ZOO:"zoo_or_aquarium"},Ut=e=>Pt[e],Ht=Array.from(new Set(Object.values(Pt))),Wt={bar:"eat_and_drink",cafe:"eat_and_drink",cafeteria:"eat_and_drink",coffee_shop:"eat_and_drink",fast_food:"eat_and_drink",ice_cream_shop:"eat_and_drink",juice_bar:"eat_and_drink",pub:"eat_and_drink",restaurant:"eat_and_drink",tea_house:"eat_and_drink",clothing_shop:"shopping",department_store:"shopping",food_and_drinks_shop:"shopping",mall:"shopping",marketplace:"shopping",shop_or_store:"shopping",supermarket:"shopping",atm:"finance",bank:"finance",foreign_exchange:"finance",gold_exchange:"finance",stock_exchange:"finance",camping_ground:"lodging",holiday_home:"lodging",hotel_or_motel:"lodging",airport:"transport",bus_station:"transport",ferry_terminal:"transport",heliport_or_helipad:"transport",marina:"transport",public_transport_stop:"transport",railway_station:"transport",taxi_stand:"transport",transport_access:"transport",border_control:"driving",car_rental:"driving",charging_location:"driving",fuel_station:"driving",rest_and_service_area:"driving",toll_booth:"driving",truck_stop:"driving",vehicle_dealer:"driving",vehicle_inspection:"driving",vehicle_repair:"driving",vehicle_wash:"driving",weighbridge:"driving",parking_facility:"parking",rental_car_parking:"parking",clinic:"healthcare",dentist:"healthcare",doctor:"healthcare",emergency_ward_entrance:"healthcare",hospital:"healthcare",pharmacy:"healthcare",veterinary:"healthcare",childcare:"education",college_or_university:"education",research_facility:"education",school_or_kindergarten:"education",cultural_center:"cultural",historic_site:"cultural",museum:"cultural",planetarium:"cultural",theater:"cultural",amusement_park:"leisure",beach_resort:"leisure",casino_and_gambling:"leisure",cinema:"leisure",comedy_club:"leisure",nightlife:"leisure",park_and_recreation_facility:"leisure",tourist_attraction:"leisure",tourist_information:"leisure",zoo_or_aquarium:"leisure",fitness_center:"sport",golf_course:"sport",horse_riding:"sport",ice_rink:"sport",sport_facility:"sport",stadium:"sport",swimming_pool:"sport",winter_sports:"sport",aboriginal_land:"outdoor",landmark:"outdoor",mountain_pass:"outdoor",park_and_recreation_area:"outdoor",viewpoint:"outdoor",protected_land:"protected",cemetery:"public",courthouse:"public",fire_station:"public",government_office:"public",police_station:"public",post_depot:"public",post_office:"public",prison:"public",public_library:"public",military_airfield:"military",religious_site:"religion",animal_shelter:"business",commercial_area:"business",conference_center:"business",consumer_service:"business",industrial_area:"business",manufacturing_facility:"business",media_facility:"business",mourning_facility:"business",ngo_office:"business",personal_care_service:"business"},Gt=e=>{const t=Ut(e);return t?Wt[t]:void 0},Bt="title",Vt="iconID",zt=.7,jt="default_place",$t="poi-parking-micro",Kt={"icon-image":["get",Vt],"icon-anchor":"bottom","icon-size":vt,"icon-allow-overlap":!0,"icon-padding":0},Yt={"icon-translate":[0,5],"icon-translate-anchor":"viewport"},qt={"text-optional":!0,"text-font":[_t],"text-field":["get",Bt],"text-justify":"auto","text-variable-anchor":["top","left","right"],"text-variable-anchor-offset":["top",[0,zt],"left",[1.4,-1.4],"right",[-1.4,-1.4]],"text-size":It,"text-padding":5},Zt={"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"},Xt={type:"symbol",layout:{...Kt,...qt},paint:{...Yt,...Zt}},Jt=(e,t)=>`${e}-${t}`,Qt=(e,t)=>t?`${t}-${e}`:e,ei=["has","point_count"],ti=["!",ei],ii="clusterBaseMapIconIDs",ri=["all",ei,["==",["index-of",",",["get",ii]],-1]],si=["all",ei,[">=",["index-of",",",["get",ii]],0]],oi=[12,-14],ai={[ii]:(Je="baseMapIconID",Qe=ii,[["case",["==",["get",Qe],null],["accumulated"],["==",["accumulated"],null],["get",Qe],[">=",["index-of",["concat",",",["get",Qe],","],["concat",",",["accumulated"],","]],0],["accumulated"],["concat",["accumulated"],",",["get",Qe]]],["get",Je]])},ni=e=>{const t=["match",e];for(const i of Ht){const e=`poi-${i}`;t.push(e,["image",e])}return t.push(["image",$t]),t},li=(e,t)=>{if(!e)return;const i=(e=>{try{if("string"==typeof e){if(e.includes("<svg")){const t=Te(e),i=t.getAttribute("viewBox");if(i){const e=i.split(/\s+/);if(4===e.length)return{width:Number.parseFloat(e[2]),height:Number.parseFloat(e[3])}}const r=t.getAttribute("width"),s=t.getAttribute("height");if(r&&s)return{width:Number.parseFloat(r),height:Number.parseFloat(s)}}return null}return e.complete&&e.naturalWidth>0?{width:e.naturalWidth,height:e.naturalHeight}:null}catch(t){return console.warn("Failed to extract image dimensions:",t),null}})(e);if(!i)return;const r="base-map"===t||"circle-icon"===t,s=r?54:140,o=r?54:120;return{heightScale:i.height/s,widthScale:i.width/o}},ci=e=>{const t=["case"];for(const[i,r]of e)0===r.x&&0===r.y||t.push(["==",["get",Vt],i],["literal",[r.x,r.y]]);if(1!==t.length)return t.push(["literal",[0,0]]),t},hi=e=>Boolean(e&&"availability"in e&&e.availability),ui=e=>"ELECTRIC_VEHICLE_STATION"===e.properties.poi?.categories?.[0]&&hi(e.properties.chargingPark),di=e=>{const t=e.properties.chargingPark;if(hi(t)){const e=t.availability.chargingPointAvailability,i=e.statusCounts.Available??0;return{availableCount:i,totalCount:e.count,ratio:i/e.count}}},pi=(e,t)=>`${e}/${t}`,yi=e=>di(e)?.ratio??0,fi=e=>["case",[">=",["get","evAvailabilityRatio"],e?.threshold??0],"green","red"],mi=e=>Math.round(1e4*e)/1e4,gi=(e,t,i,r)=>{const s=void 0!==r;return{top:s?[0,r]:[0,mi(e)],left:s?[r,mi(i)]:[mi(t),mi(i)],right:s?[-r,mi(i)]:[-mi(t),mi(i)]}},_i=(e,t,i,r)=>{const s=(e=>{if(!e)return Et;if("number"==typeof e)return e;if(Array.isArray(e)){const t=e.at(-1);if("number"==typeof t)return t}if("object"==typeof e&&"stops"in e){const t=e.stops;if(Array.isArray(t)&&t.length>0){const e=t.at(-1);if(Array.isArray(e)&&"number"==typeof e[1])return e[1]}}return Et})(e)/Et,o="base-map"===i||"circle-icon"===i;if(o&&void 0!==r)return{"text-offset":[r,r]};const a=1.4*s,n=gi(zt*s,a,o?0:-a,r),l=["top",n.top,"left",n.left,"right",n.right];if(0===t.size)return{"text-variable-anchor-offset":l};const c=["case"];for(const[h,u]of t.entries()){const e=(o?1.4:zt)*u.heightScale*s,t=1.4*u.widthScale*s,i=gi(e,t,o?0:-t,r);c.push(["==",["get",Vt],h],["literal",["top",i.top,"left",i.left,"right",i.right]])}return c.push(["literal",l]),{"text-variable-anchor-offset":c}},bi=(e,t,i,r,s)=>{const o=t?.text,a=t?.layers?.[i],n=s&&s.size>0,l={...e.layout},c=n||void 0!==o?.offset||"circle-icon"===t?.theme;c&&(delete l["text-offset"],delete l["text-variable-anchor-offset"],delete l["text-radial-offset"]);const h={...l,...a?.layout,...o?.size&&{"text-size":o.size},...o?.font&&{"text-font":o.font},...void 0!==r&&{"text-field":r}};if(c){const e={...h,..._i(h["icon-size"],s??/* @__PURE__ */new Map,t?.theme,o?.offset)},r="micro"!==i&&s&&ci([...s].map(([e,{offset:t}])=>[e,t]));return r?{...e,"icon-offset":r}:e}return h},Li=(e,t,i,r)=>{const s=t?.text,o=t?.layers?.[i],{textColor:a,haloColor:n}=(e=>({textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}))(r),l=e.paint??{};return{...l,...void 0===l["text-color"]&&{"text-color":a},...void 0===l["text-halo-color"]&&{"text-halo-color":n},...s?.color&&{"text-color":s.color},...s?.haloColor&&{"text-halo-color":s.haloColor},...s?.haloWidth&&{"text-halo-width":s.haloWidth},...o?.paint}},Si=["in",["get","eventState"],["literal",["click","contextmenu"]]],Ii=e=>JSON.parse(JSON.stringify(e)?.replaceAll("name",Bt)),Ai=(e,t)=>e.getStyle().layers.find(e=>e.id===t)??{},Ei=e=>({filter:["!",Si],type:"symbol",paint:e.paint,layout:e.layout?s(e.layout,"visibility"):void 0}),vi=e=>{const t=Ei(Ai(e,"POI")),i=t.layout?.["text-size"];return{...t,layout:{...t.layout,"icon-image":["get",Vt],"text-field":["get",Bt],...i&&{"text-size":Ii(i)}}}},Ri=e=>{const t=Ei(Ai(e,"POI - Micro"));return{...t,minzoom:0,layout:{...t.layout,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{...t.paint,"icon-opacity":1}}},Ti=e=>{const t=Ai(e,"POI").layout??{};return{...Xt,layout:{...Xt.layout,"icon-anchor":"center",...void 0!==t["icon-size"]&&{"icon-size":t["icon-size"]},...void 0!==t["icon-padding"]&&{"icon-padding":t["icon-padding"]}},paint:{...Xt.paint,"icon-translate":[0,0]}}},wi=["has","eventState"],Ci={type:"symbol",layout:{visibility:"none"}},Oi={type:"circle",layout:{visibility:"none"}},Mi="#3f9cd9",Ni={...Xt,filter:["!",wi]},xi={...Xt,filter:wi,layout:{...Xt.layout,"icon-size":["interpolate",["linear"],["zoom"],8,.8,22,1],"text-allow-overlap":!0},paint:{...Xt.paint,"text-color":Mi}},Di=e=>({...e,filter:wi,layout:{...e.layout,"text-allow-overlap":!0},paint:{...e.paint,"text-color":Mi}}),Fi=(e,t,i,r,s)=>{const o=t?.text,a=t?.layers?.[i],n=!0===t?.evAvailability?.enabled,l=o?.title&&"function"!=typeof o?.title?o.title:n?((e,t)=>t?["case",["has","evAvailabilityText"],["format",["get",Bt],{},"\n",{},["get","evAvailabilityText"],{"font-scale":1.1,"text-color":fi(e?.evAvailability)}],["get",Bt]]:["get",Bt])(t,n):void 0;return{...e,...a,layout:bi(e,t,i,l,s),paint:Li(e,t,i,r)}},ki=(e,t,i,r)=>{const s=((e,t)=>{const i=/* @__PURE__ */new Map,r=e?.icon?.categoryIcons??[];for(const s of r)if(s.image){const r=li(s.image,e?.theme),o=void 0!==s.offsetX||void 0!==s.offsetY;if(void 0===r&&!o)continue;const a={heightScale:r?.heightScale??1,widthScale:r?.widthScale??1,offset:{x:s.offsetX??0,y:s.offsetY??0}},n=Jt(s.id,t);if(i.set(n,a),s.availabilityLevel){const e=Jt(`${s.id}-${s.availabilityLevel}`,t);i.set(e,a)}}return i})(e,r);let o,a,n=Ci,l=Ci,c=Oi,h=Ci,u=Oi,d=Ci;if("base-map"===e?.theme)o={...vi(t),minzoom:10},n=Ri(t),a=(e=>Di(vi(e)))(t);else if("circle-icon"===e?.theme)o=(e=>({...Ti(e),filter:["!",wi]}))(t),a=(e=>Di(Ti(e)))(t);else if("pin-clustered"===e?.theme){o={...Ni,filter:["all",ti,["!",wi]]},a={...xi,filter:["all",ti,wi]};const e=Ri(t);n={...e,filter:e.filter?["all",ti,e.filter]:ti},l={type:"symbol",filter:ri,layout:{"icon-image":ni(["get",ii]),"icon-size":1,"icon-allow-overlap":!0,"icon-ignore-placement":!0}},c={type:"circle",filter:ri,paint:{"circle-radius":11,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5,"circle-translate":oi,"circle-translate-anchor":"viewport"}},h={type:"symbol",filter:ri,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[_t],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF","text-translate":oi,"text-translate-anchor":"viewport"}},u={type:"circle",filter:si,paint:{"circle-radius":15,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5}},d={type:"symbol",filter:si,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[_t],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF"}}}else o=Ni,a=xi;return{micro:{...Fi(n,e,"micro",i,s),beforeID:Rt.lowestPlaceLabel},main:{...Fi(o,e,"main",i,s),beforeID:"selected"},selected:Fi(a,e,"selected",i,s),cluster:{...l,...e?.layers?.cluster,beforeID:"clusterBadge"},clusterBadge:{...c,...e?.layers?.clusterBadge,beforeID:"clusterCount"},clusterCount:{...h,...e?.layers?.clusterCount,beforeID:"clusterMixedBadge"},clusterMixedBadge:{...u,...e?.layers?.clusterMixedBadge,beforeID:"clusterMixedCount"},clusterMixedCount:{...d,...e?.layers?.clusterMixedCount},...e?.layers?.additional}},Pi=e=>{if(ve())return Re(we(e))},Ui=(e,t)=>"string"!=typeof e?e:t.features.find(t=>t.id===e),Hi=/* @__PURE__ */new Set([7339002,8099002,7369004,7321003,7376006,9362003,9362004,9160004,9376007,7315015,9376006,9376002,7315078,7315149,9376005,7372003,9352045,9352032,9361048,9902003,9378005,7383004,9910004,7320002,9362016,7320003,9362025,9942002,9942003,7380005,9663003,9361021,9379009,9379004,7315147,9376003,9160002,9160003,9352008,9361006,7389004,9910006]),Wi=e=>e.properties.poi?.name??e.properties.address.freeformAddress,Gi=(e,t,i)=>{if("pin"===t||"pin-clustered"===t)return(e=>{if(e)return Hi.has(e)?Ee(e.toString()):Ee(e.toString().substring(0,4))})(I[e])??i;{const t=Ut(e);return t?`poi-${t}`:i}},Bi=(e,t,i={})=>{const r=i.theme??"pin",s=((e,t)=>e.icon?.default||"base-map"!==(e.theme??"pin")?Jt(jt,t):$t)(i,t),o=i.icon?.mapping;if(o)return"imageID"===o.to?o.fn(e):Gi(o.fn(e),r,s);const a=e.properties.poi?.categories?.[0],n=((e,t,i,r,s)=>{if(!r.evAvailability?.enabled||!ui(e))return;const o=yi(e)>=(r.evAvailability.threshold??.3)?"available":"occupied",a=r.icon?.categoryIcons&&r.icon.categoryIcons.length>0,n=r.icon?.categoryIcons?.find(e=>e.id===t&&e.availabilityLevel===o);return n?Jt(`${n.id}-${o}`,i):a||"pin"!==s?void 0:Ee(`7309-${o}`)})(e,a,t,i,r);if(n)return n;const l=i.icon?.categoryIcons?.find(e=>e.id===a);return l?Jt(l.id,t):Gi(a,r,s)},Vi=(e,t)=>{const i=t?.icon?.mapping;return"poiCategory"===i?.to?i.fn(e):e.properties.poi?.categories?.[0]},zi=(e,t)=>{const i=Vi(e,t);return i&&Ut(i)},ji=(e,t)=>{const i=Vi(e,t);return i&&Gt(i)},$i=e=>Array.isArray(e)?{type:"FeatureCollection",features:e}:"Feature"===e.type?{type:"FeatureCollection",features:[e]}:e,Ki=(e,t,i)=>{if(!0!==t?.enabled)return e;let r=!1,s=!1;for(const o of i.features)if("ELECTRIC_VEHICLE_STATION"===o.properties.poi?.categories?.[0]&&(r=!0,ui(o))){s=!0;break}return r&&!s&&console.warn("PlacesModule: evAvailability is enabled but no availability data found. Did you call getPlacesWithEVAvailability()?"),{...e,evAvailabilityText:e=>ui(e)?((e,t)=>{const i=di(e);return i?(t?.formatText??pi)(i.availableCount,i.totalCount):""})(e,t):"",evAvailabilityRatio:e=>ui(e)?yi(e):0}},Yi=(e,t)=>{const i=zi(e,t);return i?`poi-${i}`:$t},qi=(e,t,i={})=>{const r=$i(e),s=!0===i.evAvailability?.enabled?Ki(i.extraFeatureProps,i.evAvailability,r):i.extraFeatureProps;return{...r,features:r.features.map(e=>{const r="function"==typeof i?.text?.title?i?.text?.title(e):Wi(e),o=s?Object.fromEntries(Object.entries(s).map(([t,i])=>[t,"function"==typeof i?i(e):i])):{},a=e.id??f();return{...e,id:a,geometry:{...e.geometry,bbox:e.bbox},properties:{...e.properties,id:a,title:r,iconID:Bi(e,t,i),...("base-map"===i?.theme||"pin-clustered"===i?.theme)&&{category:zi(e,i),group:ji(e,i)},..."pin-clustered"===i?.theme&&{baseMapIconID:Yi(e,i)},...o}}})}},Zi=class e extends Ke{static async create(t,i){return await Ce(t),new e(t,i)}constructor(e,t){super(e,t),this.currentClusterMode=!1,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){t||(this.sourceID=`places-${this.instanceIndex}`,this.unclusteredSourceID=`places-${this.instanceIndex}-unclustered`,this.connectionSourceID=`places-connections-${this.instanceIndex}`,this.layerIDPrefix=this.sourceID,this.defaultPlaceIconID=Jt(jt,this.instanceIndex),this.shownConnections=[]),this.layerSpecs=this.buildLayerSpecs(e);const i=this.buildClusterOptions(e);this.currentClusterMode=!0===i?.cluster;const r=this.partitionSpecsForSources(this.layerSpecs),s=new lt(this.mapLibreMap,this.sourceID,r.clusteredSpecs,!1,i);let o;r.unclusteredSpecs.length>0&&(o=new lt(this.mapLibreMap,this.unclusteredSourceID,r.unclusteredSpecs,!1)),ke([...s._layerSpecs,...o?._layerSpecs??[]],this.mapLibreMap),this.connectionLayerSpecs=this.buildConnectionLayerSpecs(e);const a=new lt(this.mapLibreMap,this.connectionSourceID,Object.values(this.connectionLayerSpecs),!1);return ke(a._layerSpecs,this.mapLibreMap),o?{places:s,placesUnclustered:o,connections:a}:{places:s,connections:a}}partitionSpecsForSources(e){if(!this.currentClusterMode)return{clusteredSpecs:Object.values(e),unclusteredSpecs:[]};const t=[],i=[];for(const[r,s]of Object.entries(e))"micro"===r?t.push(s):i.push(s);return{clusteredSpecs:i,unclusteredSpecs:t}}buildLayerSpecs(e){const t=ki(e,this.tomtomMap.mapLibreMap,this.tomtomMap.styleLightDarkTheme,this.instanceIndex),i=new Set(Object.keys(t));return Object.fromEntries(Object.entries(t).map(([e,t])=>{const r=t.beforeID;return[e,{...t,id:`${this.layerIDPrefix}-${e}`,...r&&i.has(r)?{beforeID:`${this.layerIDPrefix}-${r}`}:{}}]}))}buildClusterOptions(e){if("pin-clustered"===e?.theme)return{cluster:!0,clusterRadius:60,clusterProperties:ai}}buildConnectionLayerSpecs(e){const t=((e,t,i="light")=>{const r=(e=>({lineColor:"dark"===e?"#5AB6F0":"#3f9cd9",labelColor:"dark"===e?"#A9D6F5":"#1a5f8a",labelHaloColor:"dark"===e?"#1a1a1a":"#ffffff"}))(i),s=e?.layers?.line,o=e?.layers?.label,a={type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":t??r.lineColor,"line-width":1.5,"line-dasharray":[2,2],"line-opacity":.9}},n=(l=t??r.labelColor,c=r.labelHaloColor,{type:"symbol",layout:{"symbol-placement":"line-center","text-field":["get","label"],"text-size":12,"text-offset":[0,-1],"text-allow-overlap":!1,"text-ignore-placement":!1,"text-keep-upright":!0},paint:{"text-color":l,"text-halo-color":c,"text-halo-width":1.5}});var l,c;return{line:{...a,...s,layout:{...a.layout,...s?.layout},paint:{...a.paint,...s?.paint}},label:{...n,...o,layout:{...n.layout,...o?.layout},paint:{...n.paint,...o?.paint}}}})(e?.connections,void 0,this.tomtomMap.styleLightDarkTheme),i=`${this.layerIDPrefix}-connection-line`,r=`${this.layerIDPrefix}-connection-label`,s=Rt.lowestLabel;return{line:{...t.line,id:i,beforeID:s},label:{...t.label,id:r,beforeID:s}}}_applyConfig(e){return this.updateLayersAndData(e),e}discardShownData(){this.shownConnections=[]}restoreDataAndConfigImpl(){const e=this.sourcesWithLayers.places.shownFeatures,t=this.shownConnections;this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config),this.show(e),t.length&&this.showConnections(t)}applyTheme(e){this.applyConfigPart({theme:e})}applyIconConfig(e){this.applyConfigPart({icon:e})}applyTextConfig(e){this.applyConfigPart({text:e})}applyConfigPart(e){const t={...this.config,...e};this.updateLayersAndData(t),this.config=t,this.emitConfigChange()}applyExtraFeatureProps(e){const t={...this.config,extraFeatureProps:e};this.updateData(t),this.config=t,this.emitConfigChange()}updateLayersAndData(e){if(this.setupImages(e),!0===this.buildClusterOptions(e)?.cluster!==this.currentClusterMode)return void this.rebuildSourcesAndLayers(e);const t=this.buildLayerSpecs(e),i=this.currentClusterMode?this.partitionSpecsForSources(t):{clusteredSpecs:Object.values(t),unclusteredSpecs:[]},r=this.currentClusterMode?this.partitionSpecsForSources(this.layerSpecs):{clusteredSpecs:Object.values(this.layerSpecs),unclusteredSpecs:[]};xe(i.clusteredSpecs,r.clusteredSpecs,this.sourcesWithLayers.places,this.mapLibreMap),this.sourcesWithLayers.placesUnclustered&&i.unclusteredSpecs.length>0&&xe(i.unclusteredSpecs,r.unclusteredSpecs,this.sourcesWithLayers.placesUnclustered,this.mapLibreMap),this.layerSpecs=t,this.applyPlacesVisibility(),this.updateData(e),this.updateConnectionLayersAndData(e)}rebuildSourcesAndLayers(e){const t=this.sourcesWithLayers.places.shownFeatures,i=this.shownConnections;for(const s of Object.values(this.layerSpecs))this.mapLibreMap.getLayer(s.id)&&this.mapLibreMap.removeLayer(s.id);for(const s of Object.values(this.connectionLayerSpecs))this.mapLibreMap.getLayer(s.id)&&this.mapLibreMap.removeLayer(s.id);this.mapLibreMap.getSource(this.sourceID)&&this.mapLibreMap.removeSource(this.sourceID),this.mapLibreMap.getSource(this.unclusteredSourceID)&&this.mapLibreMap.removeSource(this.unclusteredSourceID),this.mapLibreMap.getSource(this.connectionSourceID)&&this.mapLibreMap.removeSource(this.connectionSourceID),this.initSourcesWithLayers(e,!0),this.setupImages(e);const r=qi(t,this.instanceIndex,e);this.sourcesWithLayers.places.show(r,{automaticVisibility:!1}),this.sourcesWithLayers.placesUnclustered?.show(r,{automaticVisibility:!1}),this.applyPlacesVisibility(),i.length&&(this.shownConnections=[...i],this.updateConnectionsData(e))}updateConnectionLayersAndData(e){const t=this.buildConnectionLayerSpecs(e),i=this.sourcesWithLayers.connections;xe(Object.values(t),Object.values(this.connectionLayerSpecs),i,this.mapLibreMap),this.connectionLayerSpecs=t,this.updateConnectionsData(e)}updateConnectionsData(e){const t=this.sourcesWithLayers.places.shownFeatures;this.sourcesWithLayers.connections.show(((e,t,i={})=>{const r=i.connections?.label,s=[];for(const o of e){const e=Ui(o.from,t),i=Ui(o.to,t);if(!e||!i)continue;const a=o.id??f(),n=r?r(o):"";s.push({type:"Feature",id:a,geometry:{type:"LineString",coordinates:[e.geometry.coordinates,i.geometry.coordinates]},properties:{id:a,fromId:"string"==typeof o.from?o.from:e.id,toId:"string"==typeof o.to?o.to:i.id,label:n}})}return{type:"FeatureCollection",features:s}})(this.shownConnections,t,e))}applyPlacesVisibility(){const e=this.sourcesWithLayers.places.shownFeatures.features.length?"visible":"none";for(const t of Object.values(this.layerSpecs))"none"!==t.layout?.visibility&&this.mapLibreMap.setLayoutProperty(t.id,"visibility",e,{validate:!1})}setupImages(e){if(e?.icon){for(const t of e.icon.categoryIcons??[]){const e=t.availabilityLevel?`${t.id}-${t.availabilityLevel}`:t.id;He("if-not-in-sprite",Jt(e,this.instanceIndex),t.image,this.mapLibreMap,{pixelRatio:t.pixelRatio??2})}e.icon.default&&(e.icon.default.image&&He("if-not-in-sprite",this.defaultPlaceIconID,e.icon.default.image.image,this.mapLibreMap,{pixelRatio:e.icon.default.image.pixelRatio??2}),e.icon.default.style&&He("if-not-in-sprite",this.defaultPlaceIconID,Pi(e.icon.default.style),this.mapLibreMap,{pixelRatio:2}))}else He("if-not-in-sprite",this.defaultPlaceIconID,Pi(),this.mapLibreMap,{pixelRatio:2})}updateData(e){const t=qi(this.sourcesWithLayers.places.shownFeatures,this.instanceIndex,e);this.sourcesWithLayers.places.source.runtimeSource?.setData(t),this.sourcesWithLayers.placesUnclustered?.source.runtimeSource?.setData(t)}async show(e){await this.waitUntilModuleReady(),this.clearConnectionsSync();const t=qi(e,this.instanceIndex,this.config);this.sourcesWithLayers.places.show(t,{automaticVisibility:!1}),this.sourcesWithLayers.placesUnclustered?.show(t,{automaticVisibility:!1}),this.applyPlacesVisibility();for(const i of this.shownFeaturesHandlers)i({places:e})}async clear(){await this.waitUntilModuleReady(),this.clearConnectionsSync(),this.sourcesWithLayers.places.clear(),this.sourcesWithLayers.placesUnclustered?.clear()}async showConnections(e){await this.waitUntilModuleReady(),this.shownConnections=[...e],this.updateConnectionsData(this.config);for(const t of this.shownFeaturesHandlers)t({connections:e})}async clearConnections(){await this.waitUntilModuleReady(),this.clearConnectionsSync()}clearConnectionsSync(){this.shownConnections=[],this.sourcesWithLayers.connections?.clear()}getShown(){return{places:this.sourcesWithLayers.places.shownFeatures,connections:[...this.shownConnections]}}putEventState(e){this.sourcesWithLayers.places.putEventState(e)}cleanEventState(e){this.sourcesWithLayers.places.cleanEventState(e)}cleanEventStates(e){this.sourcesWithLayers.places.cleanEventStates(e)}get events(){const e=["places","placesUnclustered"];return this.buildEvents(this.moduleEventsWithShown([...e,"connections"],this.shownFeaturesHandlers),{places:this.userEvents(e),connections:this.userEvents(["connections"])})}},Xi=["pin","circle-icon","base-map","pin-clustered"],Ji={FOOD_DRINKS_GROUP:["RESTAURANT","FAST_FOOD","CAFE_PUB","PUB","WINERY","PUB_FOOD","SOUL_FOOD","DELICATESSEN"],SHOPPING_GROUP:["SHOP","SHOPPING_CENTER","CLOTHING_SHOP","MARKET","FOOD_MARKET","SUPERMARKETS_HYPERMARKETS","DEPARTMENT_STORE","CONVENIENCE_STORE","GROCERY_STORE","HARDWARE_STORE","ELECTRICAL_APPLIANCES_SHOP"],TRANSPORTATION_GROUP:["AIRPORT","FERRY_TERMINAL","HELIPAD_HELICOPTER_LANDING","PUBLIC_TRANSPORT_STOP","RAILWAY_STATION","BUS_STOP","TAXI_STAND"],HEALTH_GROUP:["DOCTOR","EMERGENCY_MEDICAL_SERVICE","EMERGENCY_ROOM","HEALTH_CARE_SERVICE","HOSPITAL","PHARMACY","DENTIST","WELFARE_ORGANIZATION"],PARKING_GROUP:["PARKING_GARAGE","OPEN_PARKING_AREA"],HOLIDAY_TOURISM_GROUP:["AMUSEMENT_PARK","BEACH","HOLIDAY_RENTAL","GEOGRAPHIC_FEATURE","TOURIST_ATTRACTION","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK","MUSEUM","SCENIC_PANORAMIC_VIEW","TOURIST_INFORMATION_OFFICE"],EV_CHARGING_STATIONS_GROUP:["ELECTRIC_VEHICLE_STATION"],GAS_STATIONS_GROUP:["GAS_STATION"],ACCOMMODATION_GROUP:["CAMPING_GROUND","HOTEL_MOTEL","HOLIDAY_RENTAL"],ENTERTAINMENT_GROUP:["CINEMA","THEATER","MOVIE_THEATER","NIGHTLIFE","CONCERT_HALL","ENTERTAINMENT","CLUB_ASSOCIATION","CASINO"],SPORTS_LEISURE_GROUP:["SPORTS_CENTER","WATER_SPORT","SWIMMING_POOL","GOLF_COURSE","STADIUM","BEACH","ICE_SKATING_RINK","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK"],EDUCATION_GROUP:["SCHOOL","COLLEGE_UNIVERSITY","LIBRARY","CULTURAL_CENTER"],GOVERNMENT_GROUP:["GOVERNMENT_OFFICE","COURTHOUSE","EMBASSY","FIRE_STATION_BRIGADE","POLICE_STATION"]},Qi=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{id:String(t?.id),name:t?.name,category:t?.category,group:t?.group,priority:t?.priority}}},er=e=>{const t=e.flatMap(e=>e in Ji?Ji[e].map(Ut):[Ut(e)]);return[...new Set(t.filter(e=>!i(e)))]},tr="pois.categories",ir=class e extends Ye{static async get(t,i){return await Ce(t),Dt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Tt);if(!t)throw Ie(`init ${e.name} with source ID ${Tt}`);return{poi:new ot(this.mapLibreMap,t,e=>Ft.includes(e.id))}}_applyConfig(e){return e&&!i(e.visible)?this._setVisible(e.visible,!1):this._initializing||this.isVisible()||this._setVisible(!0,!1),this._filterCategories(e?.filters?.categories,!1),e}isVisible(){return this.sourcesWithLayers.poi.isAnyLayerVisible()}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.poi.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}filterCategories(e){this._filterCategories(e)}_filterCategories(e,t=!0){if(e){if(this.tomtomMap.mapReady){const t=q("category",e.show,er(e.values));this.filterComposer.setClause(Rt.poi,tr,t)}t&&(this.config={...this.config,filters:{categories:e}})}else this.categoriesFilter&&(t&&(this.config={...this.config,filters:{categories:{show:"all_except",values:[]}}}),this.tomtomMap.mapReady&&this.filterComposer.setClause(Rt.poi,tr,void 0));this.categoriesFilter=e,t&&this.emitConfigChange()}getShown(){return{poi:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.poi.sourceAndLayerIDs.layerIDs,validate:!1}).map(Qi)}}get events(){return this.moduleEvents(["poi"],{mapping:Qi})}},rr=e=>"source"in e&&"string"==typeof e.source?e.source:void 0,sr=(e,t)=>!e||void 0!==t&&e.includes(t),or=(e,t,i)=>sr(e.metadataGroups,(e=>{const t=e.metadata;if(t&&"object"==typeof t&&"group"in t){const e=t.group;return"string"==typeof e?e:void 0}})(t))&&sr(e.layerTypes,t.type)&&sr(e.sources,rr(t))&&sr(e.sourceTypes,((e,t)=>{const i=rr(e);return void 0===i?void 0:t?.[i]?.type})(t,i))&&sr(e.sourceLayers,(e=>"source-layer"in e&&"string"==typeof e["source-layer"]?e["source-layer"]:void 0)(t))&&((e,t)=>{const i=t.id.toLowerCase(),r=e=>i.includes(e.toLowerCase());return!(e.idIncludes&&!e.idIncludes.some(r)||e.idExcludes?.some(r))})(e,t),ar=(e,t,i)=>e.some(e=>or(e,t,i)),nr=["land","water","buildings2D","roads","railways","ferries","borders","buildings3D","natureLabels","roadLabels","roadShields","houseNumbers","smallerTownLabels","stateLabels","cityLabels","allPlaceLabels","capitalLabels","countryLabels"],lr={land:{metadataGroups:["area","background"]},water:{metadataGroups:["water"]},natureLabels:{metadataGroups:["label"]},roads:{metadataGroups:["road","road_area","transit_area"],idExcludes:["railway","subway","aerialway","ferry"]},railways:{metadataGroups:["road"],layerTypes:["line"],idIncludes:["railway","subway","aerialway"]},ferries:{metadataGroups:["road"],layerTypes:["line"],idIncludes:["ferry"]},buildings2D:{metadataGroups:["building"],layerTypes:["fill","line"]},buildings3D:{metadataGroups:["area_3d","building"],layerTypes:["fill-extrusion"]},borders:{metadataGroups:["border","border_label"]},roadLabels:{metadataGroups:["road_label"],idExcludes:["shield"]},roadShields:{metadataGroups:["road_label"],idIncludes:["shield"]},houseNumbers:{metadataGroups:["address_point_label"]},allPlaceLabels:{metadataGroups:["places_label"]},smallerTownLabels:{metadataGroups:["places_label"],idIncludes:["neighbourhood","village","hamlet","town"]},cityLabels:{metadataGroups:["places_label"],idIncludes:["city"]},capitalLabels:{metadataGroups:["places_label"],idIncludes:["capital"]},stateLabels:{metadataGroups:["places_label"],idIncludes:["state"]},countryLabels:{metadataGroups:["places_label"],idIncludes:["country"]}},cr=(e,t)=>or(lr[e],t),hr=e=>lr[e],ur=e=>{const t=e.mode,i=e.names;return"include"===t?e=>i.some(t=>cr(t,e)):"exclude"===t?e=>!i.some(t=>cr(t,e)):(console.error("Unrecognized layer group mode:",t),()=>!0)},dr=e=>!Ft.includes(e.id),pr=class e extends Ye{static async get(t,i){return await Ce(t),Dt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Ot);if(!t)throw Ie(`init ${e.name} with source ID ${Ot}`);const i=new ot(this.mapLibreMap,t,dr);return this.layersByGroup=void 0,{vectorTiles:i}}_applyConfig(e){return e&&!i(e.visible)?this._setVisible(e.visible,void 0,!1):this._initializing||this.isVisible()||this._setVisible(!0,void 0,!1),e?.layerGroupsVisibility&&this._setVisible(e.layerGroupsVisibility.visible,{layerGroups:e.layerGroupsVisibility},!1),e?{...this.config,...e}:void 0}isVisible(e){return this.sourcesWithLayers.vectorTiles.isAnyLayerVisible(e?.layerGroups&&ur(e.layerGroups))}setVisible(e,t){this._setVisible(e,t)}_setVisible(e,t,i=!0){i&&(t?.layerGroups?this.config={...this.config,layerGroupsVisibility:{...t.layerGroups,visible:e}}:(delete this.config?.layerGroupsVisibility,this.config={...this.config,visible:e})),this.tomtomMap.mapReady&&this.sourcesWithLayers.vectorTiles.setLayersVisible(e,t?.layerGroups&&ur(t.layerGroups)),i&&this.emitConfigChange()}getLayers(){return r(this.groupedLayers(),e=>[...e])}getLayerIds(e){return[...this.groupedLayers()[e]]}groupedLayers(){return this.layersByGroup??=(e=>{const t=Object.fromEntries(nr.map(e=>[e,[]]));for(const i of e)for(const e of nr)cr(e,i)&&t[e].push(i.id);return t})(this.sourcesWithLayers.vectorTiles._layerSpecs),this.layersByGroup}get events(){return this.moduleEvents(["vectorTiles"],{scopeResolver:yr})}},yr=e=>({layerFilter:ur(e.layerGroups),featureMatches:e.features}),fr=class e extends Ke{static async create(t,i){return await Ce(t),mr(i),new e(t,i)}constructor(e,t){super(e,t),this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=e??this.initialConfig;t||(this.lastShown={}),this.resolveIDs(i),this.registerImages(i);const r={};for(const s of Object.keys(i.sources)){const e=this.resolvedSourceIDs[s],t=this.resolvedLayerSpecs[s],o=i.sources[s].cluster;r[s]=new lt(this.mapLibreMap,e,t,!0,o)}return r}registerImages(e){if(e.images)for(const[t,i]of Object.entries(e.images))this.mapLibreMap.hasImage(t)||this.mapLibreMap.addImage(t,i.image,i.options)}resolveIDs(e){const t={},i={};for(const r of Object.keys(e.sources)){const s=e.sources[r],o=s.sourceID??`custom-geojson-${this.instanceIndex}-${String(r)}`;t[r]=o,i[r]=s.layers.map((e,t)=>({...e,id:e.id??`${o}-layer-${t}`}))}this.resolvedSourceIDs=t,this.resolvedLayerSpecs=i}_applyConfig(e){if(!e)return this._applyConfig(this.initialConfig);this.initialConfig??=e;const t=this.config,i=t?this.resolvedLayerSpecs:void 0;return this.resolveIDs(e),this.registerImages(e),t&&i&&this.updateLayersForExistingSources(i),void 0!==e.visible&&this.applyVisibility(e.visible),e}updateLayersForExistingSources(e){for(const t of Object.keys(this.resolvedLayerSpecs)){const i=e[t],r=this.resolvedLayerSpecs[t],s=this.sourcesWithLayers[t];if(!i||!s)continue;xe(r,i,s,this.mapLibreMap);const o=[];for(const e of s._layerSpecs)this.mapLibreMap.getLayer(e.id)||o.push(e);o.length>0&&(ke(o,this.mapLibreMap),s.shownFeatures.features.length>0&&s.setLayersVisible(!0))}}applyVisibility(e){for(const t of Object.keys(this.sourcesWithLayers))this.sourcesWithLayers[t].setLayersVisible(e)}discardShownData(){this.lastShown={}}restoreDataAndConfigImpl(){const e=Object.keys(this.lastShown);this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config);for(const t of e){const e=this.lastShown[t];e&&this.showOnSource(t,e)}}async show(e,t){if(await this.waitUntilModuleReady(),void 0!==t)this.showOnSource(t,e);else for(const i of Object.keys(this.sourcesWithLayers))this.showOnSource(i,e)}showOnSource(e,t){const i=gr(t);this.lastShown[e]=i,this.sourcesWithLayers[e].show(i);for(const r of this.shownFeaturesHandlers)r({sourceName:e,data:i})}async clear(e){if(await this.waitUntilModuleReady(),void 0!==e)return this.sourcesWithLayers[e].clear(),void delete this.lastShown[e];for(const t of Object.keys(this.sourcesWithLayers))this.sourcesWithLayers[t].clear(),delete this.lastShown[t]}getShown(){const e={};for(const t of Object.keys(this.sourcesWithLayers))e[t]=this.sourcesWithLayers[t].shownFeatures;return e}setVisible(e){this.config={...this.config,visible:e},this.applyVisibility(e),this.emitConfigChange()}get events(){const e=Object.keys(this.sourcesWithLayers),t={};for(const i of e)t[i]=this.userEvents([i]);return this.buildEvents(this.moduleEventsWithShown(e,this.shownFeaturesHandlers),t)}},mr=e=>{if(!e.sources||0===Object.keys(e.sources).length)throw new Error("CustomGeoJSONModule requires at least one source in config.sources.");G(Object.keys(e.sources),"CustomGeoJSONModule source");for(const[t,i]of Object.entries(e.sources))if(!i.layers||0===i.layers.length)throw new Error(`CustomGeoJSONModule source "${t}" requires at least one layer.`)},gr=e=>{let t=!1;for(const i of e.features)if(null==i.id||i.properties?.id!==i.id){t=!0;break}return t?{...e,features:e.features.map((e,t)=>{const i=e.id??e.properties?.id??t;return{...e,id:i,properties:{...e.properties,id:i}}})}:e},_r="#0A3653",br="#555555",Lr=e=>({defaultColor:"dark"===e?"#5FA8D8":_r,textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}),Sr=(e,t,r,s=_r)=>{const o=r?.fill,a=r?.line,n=((e=_r)=>({type:"fill",paint:{"fill-color":["coalesce",["get","color"],e],"fill-opacity":["case",["==",["get","theme"],"outline"],0,.15],"fill-antialias":!1}}))(s),l=((e=_r)=>({type:"line",paint:{"line-color":["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],br],["coalesce",["get","color"],e]],"line-opacity":["case",["==",["get","theme"],"outline"],.9,1],"line-width":["case",["==",["get","theme"],"outline"],5,2]}}))(s),c={...n,id:e,paint:{...n.paint,...!i(o?.opacity)&&{"fill-opacity":o?.opacity},...o?.color&&{"fill-color":["get","color"]}}},h=a?.layer;return[c,{...l,...h,id:t,...h?.layout&&{layout:{...l.layout,...h.layout}},paint:{...l.paint,...h?.paint,...!i(a?.color)&&{"line-color":a?.color},...!i(a?.width)&&{"line-width":a?.width},...!i(a?.opacity)&&{"line-opacity":a?.opacity}}}]},Ir=(e,t,i="light")=>{const r=t?.textConfig,{textColor:s,haloColor:o}=Lr(i);return{type:"symbol",id:e,layout:{"text-field":["get","title"],...r?.textField&&{"text-field":r.textField},"text-padding":5,"text-size":15,"text-font":[_t],"symbol-placement":"point"},paint:{"text-color":s,"text-halo-color":o,"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"}}},Ar=(e,t,r="light")=>{const s=t?.lineLabelConfig,o=s?.minZoom??3,{textColor:a,haloColor:n}=Lr(r);return{type:"symbol",id:e,minzoom:o,layout:{"text-field":["get","title"],"symbol-placement":"line","text-size":s?.textSize??15,"text-font":[_t],"symbol-spacing":s?.symbolSpacing??200,"text-keep-upright":!0,"text-offset":s?.textOffset??[0,1]},paint:{"text-color":s?.textColor??a,"text-halo-color":s?.textHaloColor??n,"text-halo-width":s?.textHaloWidth??2,...!i(s?.textOpacity)&&{"text-opacity":s?.textOpacity}}}},Er={warm:["#793F0D","#AC703D","#C38E63","#E49969","#E5AE86","#EEC5A9","#6E7649","#9D9754","#C7C397","#B4A851","#DFD27C","#E7E3B5","#846D74","#B7A6AD","#D3C9CE"],browns:["#edc4b3","#e6b8a2","#deab90","#d69f7e","#cd9777","#c38e70","#b07d62","#9d6b53","#8a5a44","#774936"],cold:["#344464","#548ca4","#549cac","#2c445c","#a4ccd4","#acbccc","#b4c4d4","#acd4cc","#5c8ca4"],fadedBlues:["#152033","#1d2d44","#2e455d","#3e5c76","#4c6884","#597491","#67809e","#6e86a5","#7b91ad","#879bb4"],blues:["#03045e","#023e8a","#0077b6","#0096c7","#00b4d8","#48cae4","#90e0ef","#ade8f4","#caf0f8"],greens:["#004b23","#006400","#007200","#008000","#38b000","#70e000","#9ef01a","#ccff33"],fadedGreenToBlue:["#d9ed92","#b5e48c","#99d98c","#76c893","#52b69a","#34a0a4","#168aad","#1a759f","#1e6091","#184e77"],blueToRed:["#033270","#1368aa","#4091c9","#9dcee2","#fedfd4","#f29479","#f26a4f","#ef3c2d","#cb1b16","#65010c"],greenToYellow:["#007f5f","#2b9348","#55a630","#80b918","#aacc00","#bfd200","#d4d700","#dddf00","#eeef20","#ffff3f"],pastel:["#fec5bb","#fcd5ce","#fae1dd","#f8edeb","#e8e8e4","#d8e2dc","#ece4db","#ffe5d9","#ffd7ba","#fec89a"],retro:["#f94144","#f3722c","#f8961e","#f9844a","#f9c74f","#90be6d","#43aa8b","#4d908e","#577590","#277da1"],contrastRetro:["#001219","#005f73","#0a9396","#94d2bd","#e9d8a6","#ee9b00","#ca6702","#bb3e03","#ae2012","#9b2226"],fadedRainbow:["#ffadad","#ffd6a5","#fdffb6","#caffbf","#9bf6ff","#a0c4ff","#bdb2ff","#ffc6ff","#fffffc"],pastelRainbow:["#54478c","#2c699a","#048ba8","#0db39e","#16db93","#83e377","#b9e769","#efea5a","#f1c453","#f29e4c"]},vr=Object.keys(Er),Rr=(e,t)=>"light"===t?e:e.map(e=>{const t=(e=>{const t=e.replace("#","");return 6!==t.length?.5:Number.parseInt(t.slice(0,2),16)/255*.299+Number.parseInt(t.slice(2,4),16)/255*.587+Number.parseInt(t.slice(4,6),16)/255*.114})(e);return t>.6?be(e,.3)??e:t<.22?((e,t)=>{const i=pe(e);if(i)return Le(i.slice(0,3).map(e=>255*(e+(1-e)*t)))})(e,.4)??e:e}),Tr=(e,t={},i="light")=>({...e,features:e.features.map((e,r)=>{const s=(e.properties??{}).theme??t.theme,o="inverted"===s?(e=>{const t=C(e);return{...e,geometry:t.geometry}})(e):e,a=o.properties??{},n=a.title??((e,t)=>t.textConfig?.textField?t.textConfig.textField:e.properties?.address?.freeformAddress)(o,t),l=a.color??((e,t,i)=>{const r=e?.fill?.color;if("string"==typeof r&&Er[r]){const e=Rr(Er[r],i);return e[t%e.length]}return r})(t,r,i);return{...o,properties:{...o.properties,...s&&{theme:s},...n&&{title:n},...l&&{color:l},id:a.id??f()}}})}),wr=e=>{const t=e.features.map(e=>{let t;if(e.properties?.placeCoordinates)t=e.properties?.placeCoordinates;else if("MultiPolygon"===e.geometry.type){const i=(e=>e.flat().reduce((e,t)=>t.length>e.length?t:e,[]))(e.geometry.coordinates),r=u(i);t=r&&h(r)||null}else t=e.geometry.coordinates.flat();const i=e.id??e.properties?.id??f();return{type:"Feature",id:i,geometry:{type:"Point",coordinates:t},properties:{...e.properties,id:i}}});return{type:"FeatureCollection",bbox:e.bbox,features:t}},Cr=class e extends Ke{static async create(t,i){return await Ce(t),new e(t,i)}constructor(e,t){super(e,t),this.lineLabelLayerSpecs=null,this.lastRawInput=null,this.shownFeaturesHandlers=[]}get lightDark(){return this.tomtomMap.styleLightDarkTheme}get defaultColor(){return Lr(this.lightDark).defaultColor}_initSourcesWithLayers(e,t){if(!t){this.sourceID=`geometry-${this.instanceIndex}`,this.titleSourceID=`geometryTitle-${this.instanceIndex}`;const e=`geometry-${this.instanceIndex}`;this.fillLayerID=`${e}_Fill`,this.outlineLayerID=`${e}_Outline`,this.lineLabelLayerID=`${e}_LineLabel`,this.titleLayerID=`${e}_Title`}const[i,r]=Sr(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),s=Ir(this.titleLayerID,e,this.lightDark);this.titleLayerSpecs=s,this.geometryFillLayerSpecs=i,this.geometryOutlineLayerSpecs=r;const o=void 0===e?.lineLabelConfig?null:Ar(this.lineLabelLayerID,e,this.lightDark);return this.lineLabelLayerSpecs=o,{geometry:new lt(this.mapLibreMap,this.sourceID,[{...i},{...r},...o?[o]:[]]),geometryLabel:new lt(this.mapLibreMap,this.titleSourceID,[s])}}_applyConfig(e){return(e?.textConfig||e?.fill||e?.line)&&this.updateLayerAndData(e),(e?.beforeLayerConfig||e?.fill?.beforeLayerConfig||e?.line?.beforeLayerConfig)&&this.applyBeforeLayerConfig(e),e}resolveBeforeID(e){return"top"===e?this.titleLayerID:Rt[e]}moveLayersBefore(e,t){for(const i of e)Fe(this.mapLibreMap,i,t)}get fillLayerIDs(){return[this.fillLayerID]}get lineLayerIDs(){return this.lineLabelLayerSpecs?[this.outlineLayerID,this.lineLabelLayerID]:[this.outlineLayerID]}moveBeforeLayer(e){this.config={...this.config,beforeLayerConfig:e},this.applyBeforeLayerConfig(this.config),this.emitConfigChange()}applyBeforeLayerConfig(e){const t=e?.beforeLayerConfig,i=e=>{if(void 0!==t)return"string"==typeof t?t:t[e]??t.all},r=e?.fill?.beforeLayerConfig??i("fill"),s=e?.line?.beforeLayerConfig??i("line");void 0!==r&&this.moveLayersBefore(this.fillLayerIDs,this.resolveBeforeID(r)),void 0!==s&&this.moveLayersBefore(this.lineLayerIDs,this.resolveBeforeID(s))}applyTextConfig(e){const t={...this.config,textConfig:e};this.updateLayerAndData(t),this.sourcesWithLayers.geometryLabel.show(wr(this.sourcesWithLayers.geometry.shownFeatures)),this.config=t,this.emitConfigChange()}updateLayerAndData(e){const[t,i]=Sr(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),r=Ir(this.titleLayerID,e,this.lightDark);if(Ne(t,this.geometryFillLayerSpecs,this.mapLibreMap),Ne(i,this.geometryOutlineLayerSpecs,this.mapLibreMap),Ne(r,this.titleLayerSpecs,this.mapLibreMap),this.geometryFillLayerSpecs=t,this.geometryOutlineLayerSpecs=i,this.titleLayerSpecs=r,this.lineLabelLayerSpecs){const t=Ar(this.lineLabelLayerID,e,this.lightDark);Ne(t,this.lineLabelLayerSpecs,this.mapLibreMap),this.lineLabelLayerSpecs=t}}discardShownData(){this.lastRawInput=null}restoreDataAndConfigImpl(){const e=this.lastRawInput;this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config),e&&this.show(e)}async show(e){await this.waitUntilModuleReady(),this.lastRawInput=e;const{transformFeaturesForDisplay:t}=this.config??{},i=t?t(e):e,r=this.sourcesWithLayers.geometry;r.show(Tr(i,this.config,this.lightDark)),this.sourcesWithLayers.geometryLabel.show(wr(r.shownFeatures));for(const s of this.shownFeaturesHandlers)s(e)}async clear(){await this.waitUntilModuleReady(),this.sourcesWithLayers.geometry.clear(),this.sourcesWithLayers.geometryLabel.clear()}getShown(){return{geometry:this.sourcesWithLayers.geometry.shownFeatures,geometryLabel:this.sourcesWithLayers.geometryLabel.shownFeatures}}get events(){return this.buildEvents(this.moduleEventsWithShown(["geometry","geometryLabel"],this.shownFeaturesHandlers),{geometry:this.userEvents(["geometry"]),geometryLabel:this.userEvents(["geometryLabel"])})}},Or={timeMinutes:"min",distanceKM:"km",remainingChargeCPT:"% remaining",spentChargePCT:"% spent",spentFuelLiters:"L"},Mr=(e,t,i="filled")=>{const r=e.map((e,r)=>({...e,properties:{...e.properties,title:t[r],theme:i}}));return"inverted"===i?(e=>[...e.map((t,i)=>{const r=0===i?C(t):R(T([e[i-1],t])),{title:s,theme:o,...a}=t.properties??{};return{...t,geometry:r?.geometry??t.geometry,properties:a}}),...e.map(e=>({...e,id:void 0,properties:{...e.properties,theme:"filled"}}))])(r):r},Nr=(e,t="filled",i)=>{const r=e.features,s=r.map((e,t)=>{if(i)return i(e,t);const r=e.properties?.budget;return void 0!==r?.value&&r?.type?`${r.value} ${Or[r.type]??r.type}`:String(t+1)});return{type:"FeatureCollection",...e.bbox&&{bbox:e.bbox},features:Mr(r,s,t)}},xr=(e="fadedRainbow",t="lowestLabel")=>({beforeLayerConfig:t,line:{width:["case",["==",["get","theme"],"outline"],5,1],color:["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],br],"grey"],opacity:["case",["==",["get","theme"],"outline"],.9,1]},fill:{color:e,opacity:["case",["==",["get","theme"],"outline"],0,.6]},lineLabelConfig:{}}),Dr=(e="fadedRainbow",t,i,r)=>{const s=xr(e,i),o=e=>Nr(e,t,r);return"inverted"!==t?{...s,transformFeaturesForDisplay:o}:{...s,line:{...s.line,opacity:["case",["==",["get","theme"],"filled"],1,0]},fill:{...s.fill,opacity:["case",["==",["get","theme"],"filled"],0,.6]},lineLabelConfig:{textOpacity:["case",["==",["get","theme"],"filled"],1,0],textOffset:["case",["==",["get","theme"],"filled"],["literal",[0,-1]],["literal",[0,1]]]},transformFeaturesForDisplay:o}},Fr=["filled","outline","inverted"],kr=["standardLight","standardDark","drivingLight","drivingDark","monoLight","monoDark","satellite"],Pr=["trafficIncidents","trafficFlow","hillshade"],Ur="standardLight",Hr="0.6.0-0",Wr={standardLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_light"},standardDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_dark"},drivingLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_light"},drivingDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_dark"},monoLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_mono-light"},monoDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_mono-dark"},satellite:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_satellite"}},Gr={standardLight:"basic_street-light",standardDark:"basic_street-dark",drivingLight:"basic_street-light-driving",drivingDark:"basic_street-dark-driving",monoLight:"basic_mono-light",monoDark:"basic_mono-dark",satellite:"basic_street-satellite"},Br=(e,t,i)=>{const r=e.id??"standardLight",s=e.version??"0.6.0-0",o=new URL(`${t}/maps/orbis/assets/styles/${s}/style.json`);o.searchParams.set("apiVersion","1"),i&&o.searchParams.set("key",i),o.searchParams.set("map",Gr[r]);for(const a of e.include??Pr)o.searchParams.append(a,Wr[r][a]);return o.toString()},Vr=e=>{const t=e.style,i=e.commonBaseURL,r=e.apiKey;if("string"==typeof t)return Br({id:t},i,r);if("standard"===t?.type)return Br(t,i,r);if("custom"===t?.type){if(void 0!==t.url)return((e,t)=>{const i=new URL(e);return i.searchParams.has("key")?console.warn("The style URL is coming with an API key parameter which takes priority. If you want to use the SDK configured API key, remove the key param from the style URL"):t&&i.searchParams.set("key",t),i.toString()})(t.url,r);if(void 0===t.json)/* @__PURE__ */throw new Error("A custom map style takes exactly one of 'url' or 'json', and this one carries neither. Give the URL the style is served from, or the style specification itself.");return t.json}return Br({id:Ur},i,r)},zr="#1A2024",jr="#F1F3F5",$r=(e,t)=>{const i=e?.color??("dark"===t?jr:zr),r=_e(i),s=void 0!==r&&r>.4?zr:jr;return{plaque:i,text:e?.textColor??s}},Kr="stopDuration",Yr=[["coalesce",["get",Kr],""],{"text-color":"#727C85","text-font":["literal",[bt]]}],qr=["has",Kr],Zr="#36A8F0",Xr="#105287",Jr="#ABAFB3",Qr="#3C4956",es="#727C85",ts=["interpolate",["linear"],["zoom"],1,3,5,4,10,7,18,10],is=["==",["get","routeState"],"selected"],rs=["==",["get","routeState"],"deselected"],ss=["interpolate",["linear"],["zoom"],1,5,5,6,10,10,18,14],os={s:["interpolate",["linear"],["zoom"],1,2,5,3,10,5,18,7],m:ts,l:["interpolate",["linear"],["zoom"],1,5,5,6,10,11,18,15]},as={s:["interpolate",["linear"],["zoom"],1,4,5,5,10,8,18,11],m:ss,l:["interpolate",["linear"],["zoom"],1,7,5,9,10,14,18,19]},ns={s:["interpolate",["linear"],["zoom"],8,.45,22,.6],m:["interpolate",["linear"],["zoom"],8,.6,22,.8],l:["interpolate",["linear"],["zoom"],8,.75,22,1]},ls=e=>os[e??"m"],cs=e=>as[e??"m"],hs=e=>ns[e??"m"],us={s:["interpolate",["linear"],["zoom"],1,8,5,9,10,12,18,15],m:["interpolate",["linear"],["zoom"],1,9,5,11,10,15,18,20],l:["interpolate",["linear"],["zoom"],1,12,5,14,10,19,18,24]},ds=e=>us[e??"m"],ps={s:["interpolate",["linear"],["zoom"],16,8,22,12],m:["interpolate",["linear"],["zoom"],16,12,22,17],l:["interpolate",["linear"],["zoom"],16,17,22,24]},ys={s:["interpolate",["linear"],["zoom"],16,10,22,14],m:["interpolate",["linear"],["zoom"],16,14,22,20],l:["interpolate",["linear"],["zoom"],16,20,22,28]},fs=e=>ps[e??"m"],ms=e=>ys[e??"m"],gs="#AD0000",_s="#FB2D09",bs="#FFC105",Ls="#f58240",Ss="#000000",Is="#C7D2D8",As="rgba(190, 39, 27, 1)",Es="rgba(137, 150, 168, 1)",vs=e=>!1===e?.visible?"":e?.title??["format",["get","title"],{},"\n",{},["get","chargingPower"],{}," • ",{},...Yr],Rs=e=>{const t=ci(((e=[])=>{const t=/* @__PURE__ */new Map;for(const i of e){if(!i.image)continue;const e={x:i.offsetX??0,y:i.offsetY??0};0===e.x&&0===e.y||t.set(i.id,e)}return t})(e?.icon?.customIcons));return{...Xt,filter:is,minzoom:4,layout:{...Xt.layout,"text-field":vs(e?.text),...t&&{"icon-offset":t}},paint:{...Xt.paint}}},Ts=$r(void 0,"light"),ws="route-country-crossing-plaque",Cs="routeCountryCrossing",Os=["interpolate",["linear"],["zoom"],5,11,12,13],Ms=["case",[">",["get","bearing"],180],["-",["get","bearing"],270],["-",["get","bearing"],90]],Ns=(e,t,i)=>{const r=void 0!==e?Jt(ws,e):ws,s="route"===t?.alignment;return{type:"symbol",filter:is,minzoom:t?.minzoom??4,layout:{"symbol-placement":"point","icon-image":r,"icon-text-fit":"both","icon-text-fit-padding":[4,8,4,8],"icon-rotation-alignment":s?"map":"viewport","text-rotation-alignment":s?"map":"viewport",...s&&{"icon-rotate":Ms,"text-rotate":Ms},"text-field":["get","label"],"text-font":[_t],"text-size":Os,"text-allow-overlap":!0,"icon-allow-overlap":!0,...!1===t?.visible&&{visibility:"none"}},paint:{"text-color":i?.text??Ts.text}}},xs={filter:is,minzoom:16},Ds={"line-cap":"round"},Fs=e=>({...xs,type:"line",layout:Ds,paint:{"line-width":ms(e),"line-color":"grey"}}),ks=e=>({...xs,type:"line",layout:Ds,paint:{"line-width":fs(e),"line-color":"white"}}),Ps="instruction-arrow",Us={...xs,type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":Ps,"icon-rotation-alignment":"map","icon-rotate":["get","lastPointBearingDegrees"],"icon-size":["interpolate",["linear"],["zoom"],16,1,22,2]}},Hs={filter:is,type:"line",layout:{"line-join":"round"},paint:{"line-color":"#6dc4ed"}},Ws={filter:is,type:"symbol",minzoom:6,maxzoom:16.5,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-image":"poi-ferry_terminal","icon-size":["interpolate",["linear"],["zoom"],6,.8,16.5,1],"icon-ignore-placement":!0}},Gs={type:"line",layout:{"line-join":"round","line-cap":"round","line-sort-key":["get","index"]}},Bs=e=>({...Gs,filter:rs,paint:{"line-color":Qr,"line-width":cs(e)}}),Vs=e=>({...Gs,filter:rs,paint:{"line-color":Jr,"line-width":ls(e)}}),zs=(e,t)=>({...Gs,filter:is,paint:{"line-color":t??"#105287","line-width":cs(e)}}),js=(e,t)=>({...Gs,filter:is,paint:{"line-color":t??"#36A8F0","line-width":ls(e)}}),$s={type:"symbol",layout:{"symbol-placement":"line","icon-image":"roads-arrow-white","icon-rotate":180}},Ks="selected-route-summary-popup",Ys="deselected-route-summary-popup",qs={filter:is,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#BEBFFA"}},Zs={filter:is,type:"symbol",minzoom:4,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-image":"poi-toll_plaza","icon-size":["interpolate",["linear"],["zoom"],4,.8,16.5,1]}},Xs=["match",["get","magnitudeOfDelay"],"minor",Ls,"moderate",_s,"major",gs,"indefinite","#666666",Ss],Js={type:"line",layout:{"line-cap":"round"},paint:{"line-color":["match",["get","magnitudeOfDelay"],"minor",bs,"moderate",_s,"major",gs,Is]}},Qs={type:"line",filter:["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],layout:{"line-join":"round"},paint:{"line-color":["match",["get","magnitudeOfDelay"],"unknown",As,Es],"line-dasharray":[1.5,1]}},eo={filter:is,type:"symbol",minzoom:6,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-ignore-placement":!0}},to={...eo,filter:["all",["has","jamIconID"],eo.filter],layout:{...eo.layout,"icon-image":["get","jamIconID"],"icon-anchor":"bottom-left","text-anchor":"bottom-left","text-field":["get","title"],"text-font":[_t],"text-offset":[3.9,-1.4],"text-size":13},paint:{...eo.paint,"text-color":Xs,"text-halo-color":"#FFFFFF","text-halo-width":1}},io={...eo,filter:["all",["has","causeIconID"],eo.filter],layout:{...eo.layout,"icon-image":["get","causeIconID"],"icon-anchor":"bottom-right"},paint:{...eo.paint}},ro={filter:is,type:"line",layout:{"line-join":"round"},paint:{"line-color":"#000000","line-opacity":.3}},so={filter:is,type:"line",layout:{"line-join":"round"},paint:{"line-color":Xr}},oo={filter:is,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":Zr}},ao=["carpool","carTrain","importantRoadStretch","lowEmissionZone","motorway","pedestrian","speedLimit","tollVignette","unpaved","urban"],no=["ferry","tollRoad","traffic","tunnel","vehicleRestricted"],lo=[...ao,...no],co=["visible","color","opacity","width","style","pattern","icon"],ho={carpool:{sourceKey:"carpoolSections",visible:!1,style:"halo",pattern:"solid",knobs:co},carTrain:{sourceKey:"carTrainSections",visible:!0,style:"halo",pattern:"dashed",knobs:co},importantRoadStretch:{sourceKey:"importantRoadStretchSections",visible:!1,style:"halo",pattern:"solid",knobs:co},lowEmissionZone:{sourceKey:"lowEmissionZoneSections",visible:!0,style:"halo",pattern:"solid",knobs:co},motorway:{sourceKey:"motorwaySections",visible:!1,style:"halo",pattern:"solid",knobs:co},pedestrian:{sourceKey:"pedestrianSections",visible:!1,style:"halo",pattern:"dashed",knobs:co},speedLimit:{sourceKey:"speedLimitSections",visible:!0,knobs:["visible","sign"]},tollVignette:{sourceKey:"tollVignetteSections",visible:!0,style:"halo",pattern:"dashed",knobs:co},unpaved:{sourceKey:"unpavedSections",visible:!1,style:"halo",pattern:"dashed",knobs:co},urban:{sourceKey:"urbanSections",visible:!1,style:"halo",pattern:"solid",knobs:co},ferry:{sourceKey:"ferries",visible:!0,style:"inline",pattern:"solid",knobs:co},tollRoad:{sourceKey:"tollRoads",visible:!0,style:"halo",pattern:"solid",knobs:co},traffic:{sourceKey:"incidents",visible:!0,style:"inline",pattern:"solid",knobs:["visible","opacity","width","style"]},tunnel:{sourceKey:"tunnels",visible:!0,style:"inline",pattern:"solid",knobs:co},vehicleRestricted:{sourceKey:"vehicleRestricted",visible:!0,style:"inline",pattern:"dotted",knobs:co}},uo=(e,t)=>ho[e].knobs.includes(t),po=e=>ho[e],yo=e=>ho[e].visible,fo=e=>uo(e,"sign"),mo=(ao.filter(e=>!fo(e)),e=>ho[e].sourceKey),go={carpool:{color:"#6D4AC7",opacity:.55},carTrain:{color:"#8A5A2B",opacity:.6},importantRoadStretch:{color:"#C7761F",opacity:.6},lowEmissionZone:{color:"#2E8B57",opacity:.5},motorway:{color:"#1F6FB2",opacity:.4},pedestrian:{color:"#B23F86",opacity:.6},tollVignette:{color:"#8C6B1F",opacity:.55},unpaved:{color:"#7A6A54",opacity:.6},urban:{color:"#7E8C8E",opacity:.3}},_o={solid:void 0,dashed:[2,1.5],dotted:[0,1.5]},bo=(e,t)=>t?.visible??ho[e].visible,Lo=(e,t)=>uo(e,"style")&&t?.style||po(e).style,So={halo:"routeDeselectedOutline",inline:"routeLineArrows"},Io=(e,t)=>{const i=Lo(e,t);return i&&So[i]},Ao=(e,t,i,r,s="principal")=>{const o=i?.width??r,a={...t.paint,"line-width":"halo"===Lo(e,i)?ds(o):ls(o)};if(i?.color&&uo(e,"color")){const e="outline"===s?be(i.color,.4):i.color;e&&(a["line-color"]=e)}return void 0!==i?.opacity&&uo(e,"opacity")&&(a["line-opacity"]=i.opacity),"principal"===s&&uo(e,"pattern")&&((e,t,i)=>{const r=i?.pattern??po(e).pattern,s=r&&_o[r];s?t["line-dasharray"]=s:delete t["line-dasharray"]})(e,a,i),{...t,layout:{...t.layout,...!bo(e,i)&&{visibility:"none"}},paint:a}},Eo=(e,t,i)=>{const r=uo(e,"icon")?i?.icon:void 0;return{...t,layout:{...t.layout,...r&&{"icon-image":r.image,"icon-size":r.size??1,...r.placement&&{"symbol-placement":"along"===r.placement?"line":"line-center"}},...!bo(e,i)&&{visibility:"none"}}}},vo=(e,t,i)=>Ao(e,{filter:is,type:"line",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":go[e].color,"line-opacity":go[e].opacity}},t,i),Ro=["interpolate",["linear"],["zoom"],10,.5,16,.7],To=["interpolate",["linear"],["zoom"],10,9,16,13],wo=["-",["get","startPointIndex"],["get","endPointIndex"]],Co=["case",["==",["get","signFace"],"plaque"],["literal",[0,.55]],["literal",[0,0]]],Oo=e=>e?.sign?.placement??"atChange",Mo=(e,t)=>{return{filter:is,type:"symbol",minzoom:t?.sign?.minzoom??10,layout:{...(i=Oo(t),"atChange"===i?{"symbol-placement":"point"}:{"symbol-placement":"line","symbol-spacing":260}),"icon-image":["get","signImageID"],"icon-size":Ro,"icon-rotation-alignment":"viewport","text-field":["get","signLabel"],"text-font":[_t],"text-size":To,"text-offset":Co,"text-rotation-alignment":"viewport","symbol-sort-key":wo,...!bo(e,t)&&{visibility:"none"}},paint:{"text-color":["get","signNumeralsColor"]}};var i},No=(e,t)=>`routeSection${e.charAt(0).toUpperCase()+e.slice(1)}${t}`,xo=e=>No(e,"Sign"),Do="traffic-clear",Fo="traffic-major",ko="traffic-moderate",Po="traffic-minor",Uo=["has","formattedTraffic"],Ho=e=>{const t=void 0!==e?Jt(Ks,e):Ks,i=void 0!==e?Jt(Ys,e):Ys,r=void 0!==e?Jt(Do,e):Do,s=void 0!==e?Jt(Fo,e):Fo,o=void 0!==e?Jt(ko,e):ko,a=void 0!==e?Jt(Po,e):Po;return{type:"symbol",layout:{"icon-image":["case",is,t,i],"symbol-placement":"point","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport","symbol-sort-key":["case",is,0,1],"icon-text-fit":"both","icon-text-fit-padding":[10,5,5,10],"text-font":[Lt],"text-size":13,"icon-padding":0,"text-justify":"left","text-line-height":1.5,"text-field":["format",["get","formattedDuration"],{"text-font":["literal",[_t]],"text-color":["case",is,"black",es]},["concat","\t\t",["get","formattedDistance"]],{"text-color":es},["case",Uo,"\n",""],{},["image",["case",Uo,["match",["get","magnitudeOfDelay"],"major",s,"moderate",o,"minor",a,r],""]],{},["case",Uo,["concat"," ",["get","formattedTraffic"]],""],{"text-font":["literal",[_t]],"text-color":Xs}]},paint:{"icon-translate":[0,-35],"text-translate":[0,-35]}}},Wo=Ho(),Go="start",Bo="middle",Vo="finish",zo="stopDisplayIndex",jo="waypointStart",$o="waypointStop",Ko="waypointFinish",Yo=["format",["coalesce",["get",Bt],""],{},["case",["all",["has",Bt],qr],"\n",""],{},...Yr],qo={"text-field":["get",zo],"text-font":[_t],"text-size":["interpolate",["linear"],["zoom"],13,14,18,16],"text-offset":[0,-1.6],"icon-anchor":"bottom","text-allow-overlap":!0},Zo={type:"symbol",paint:{...Yt,"text-color":"#ffffff"},layout:{...Kt,...qo,"symbol-sort-key":["abs",["-",["get","index"],1e3]]}},Xo={type:"symbol",paint:{...Zt,"text-color":"black","text-halo-width":1.5,"text-halo-color":"#ffffff"},layout:{...qt,"text-field":Yo,"text-anchor":"top","text-offset":[0,.4]}},Jo=(e,t)=>e&&t&&(e.startsWith("route")||e.startsWith("waypoint"))?`${t}-${e}`:e,Qo=(e,t)=>e&&t?Object.fromEntries(Object.entries(e).map(([e,i])=>[e,i?.beforeID?{...i,beforeID:Jo(i.beforeID,t)}:i])):e,ea=(e,t)=>t?{...e,...t,...t.paint&&{paint:{...e.paint,...t.paint}},...t.layout&&{layout:{...e.layout,...t.layout}}}:e,ta=(e,t)=>e&&void 0!==t?`${e}-${t}`:e,ia=(e={},t,i,r="light")=>{const s=e.layers,o=s?.sections,a=e.theme?.mainColor,n=a?be(a,.4):void 0,l=e.theme?.routeWidth,c=e.theme?.waypointSize,h=hs(c),u=e.sections,d=(e,i,r)=>({...Ao(e,i,u?.[e],l,r?.role),beforeID:Jo(r?.beforeID??Io(e,u?.[e]),t)}),p=(e,i,r)=>({...Eo(e,i,u?.[e]),beforeID:Jo(r,t)}),y=Object.fromEntries(ao.map(e=>{const i=u?.[e],r=(e=>No(e,"Line"))(e),s=(e=>No(e,"Symbol"))(e),a=o?.[e];if(fo(e)){const r=xo(e);return[e,{[r]:ea(Mo(e,i),a?.[r]),...Qo(a?.additional,t)}]}const n=i&&((e,t)=>{if(t.icon&&uo(e,"icon"))return Eo(e,{filter:is,type:"symbol",layout:{"symbol-placement":"line-center","icon-allow-overlap":!0,"icon-rotation-alignment":"viewport"}},t)})(e,i);return[e,{[r]:ea({...vo(e,i,l),beforeID:Jo(Io(e,i),t)},a?.[r]),...n&&{[s]:ea({...n,beforeID:Rt.lowestLabel},a?.[s])},...Qo(a?.additional,t)}]}));return{mainLines:{routeLineArrows:ea({...$s,beforeID:Rt.lowestLabel},s?.mainLines?.routeLineArrows),routeLine:ea({...js(l,a),beforeID:Jo("routeIncidentBackgroundLine",t)},s?.mainLines?.routeLine),routeOutline:ea({...zs(l,n),beforeID:Jo("routeLine",t)},s?.mainLines?.routeOutline),routeDeselectedLine:ea({...Vs(l),beforeID:Jo("routeOutline",t)},s?.mainLines?.routeDeselectedLine),routeDeselectedOutline:ea({...Bs(l),beforeID:Jo("routeDeselectedLine",t)},s?.mainLines?.routeDeselectedOutline),...Qo(s?.mainLines?.additional,t)},waypoints:{routeWaypointSymbol:ea({...Zo,layout:{...Zo.layout,"icon-size":h},beforeID:Jo("routeSummaryBubbleSymbol",t)},s?.waypoints?.routeWaypointSymbol),routeWaypointLabel:ea({...Xo,beforeID:Jo("routeWaypointSymbol",t)},s?.waypoints?.routeWaypointLabel),...Qo(s?.waypoints?.additional,t)},chargingStops:{routeChargingStopSymbol:ea({...Rs(e.chargingStops),beforeID:Jo("routeWaypointSymbol",t)},s?.chargingStops?.routeChargingStopSymbol),...Qo(s?.chargingStops?.additional,t)},sections:{...y,traffic:{routeIncidentJamSymbol:ea(p("traffic",to,"routeChargingStopSymbol"),o?.traffic?.routeIncidentJamSymbol),routeIncidentCauseSymbol:ea(p("traffic",io,"routeChargingStopSymbol"),o?.traffic?.routeIncidentCauseSymbol),routeIncidentBackgroundLine:ea(d("traffic",Js,{beforeID:"routeIncidentDashedLine"}),o?.traffic?.routeIncidentBackgroundLine),routeIncidentDashedLine:ea(d("traffic",Qs),o?.traffic?.routeIncidentDashedLine),...Qo(o?.traffic?.additional,t)},ferry:{routeFerryLine:ea(d("ferry",Hs),o?.ferry?.routeFerryLine),routeFerrySymbol:ea(p("ferry",Ws,"routeIncidentJamSymbol"),o?.ferry?.routeFerrySymbol),...Qo(o?.ferry?.additional,t)},tollRoad:{routeTollRoadOutline:ea(d("tollRoad",qs),o?.tollRoad?.routeTollRoadOutline),routeTollRoadSymbol:ea(p("tollRoad",Zs,"routeChargingStopSymbol"),o?.tollRoad?.routeTollRoadSymbol),...Qo(o?.tollRoad?.additional,t)},tunnel:{routeTunnelLine:ea(d("tunnel",ro),o?.tunnel?.routeTunnelLine),...Qo(o?.tunnel?.additional,t)},vehicleRestricted:{routeVehicleRestrictedBackgroundLine:ea(d("vehicleRestricted",so,{beforeID:"routeVehicleRestrictedForegroundLine",role:"outline"}),o?.vehicleRestricted?.routeVehicleRestrictedBackgroundLine),routeVehicleRestrictedForegroundLine:ea(d("vehicleRestricted",oo),o?.vehicleRestricted?.routeVehicleRestrictedForegroundLine),...Qo(o?.vehicleRestricted?.additional,t)}},instructionLines:{routeInstructionLine:ea({...ks(l),beforeID:Rt.lowestLabel},s?.instructionLines?.routeInstructionLine),routeInstructionOutline:ea({...Fs(l),beforeID:Jo("routeInstructionLine",t)},s?.instructionLines?.routeInstructionOutline),...Qo(s?.instructionLines?.additional,t)},instructionArrows:{routeInstructionArrowSymbol:ea({...Us,beforeID:Jo("routeInstructionLine",t),...void 0!==i&&{layout:{...Us.layout,"icon-image":ta(Us.layout?.["icon-image"],i)}}},s?.instructionArrows?.routeInstructionArrowSymbol),...Qo(s?.instructionArrows?.additional,t)},summaryBubbles:{routeSummaryBubbleSymbol:ea(void 0===i?Wo:Ho(i),s?.summaryBubbles?.routeSummaryBubbleSymbol),...Qo(s?.summaryBubbles?.additional,t)},countryCrossings:{[Cs]:ea({...Ns(i,e.countryCrossings,$r(e.countryCrossings,r)),beforeID:Jo("routeWaypointSymbol",t)},s?.countryCrossings?.[Cs]),...Qo(s?.countryCrossings?.additional,t)}}},ra=ia();ve()&&(et=Re(Te('<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">\n <path d="M1.562 40.569L25 1.562l23.438 39.007L25 27.566 1.562 40.569z" fill="#fff"/>\n <path d="M25.369.107c.782.429.506.167.917.682l23.438 39.007c.79 1.316-.671 2.829-2.014 2.085L25 29.281l-22.71 12.6c-1.343.744-2.804-.769-2.014-2.085L23.714.789c.461-.694.9-.682 1.656-.682zM25 1.562L1.562 40.569 25 27.566l23.438 13.003L25 1.562z"\n fill="gray"/>\n</svg>\n')));var sa,oa=e=>{if(!ve())return;const t=Te('<svg xmlns="http://www.w3.org/2000/svg" width="160" height="65">\n <g filter="url(#A)">\n <rect id="pin" x="81.899" y="47" width="10" height="10" rx="2" transform="rotate(45 81.899 47)"/>\n <rect id="bubble" x="10" y="10" width="140" height="45" rx="12"/>\n </g>\n <defs>\n <filter id="A">\n <feDropShadow dx="0" dy="2" stdDeviation="4" flood-opacity=".3"/>\n </filter>\n </defs>\n</svg>\n');return t.querySelector("#bubble")?.setAttribute("fill",e),t.querySelector("#pin")?.setAttribute("fill",e),Re(t)},aa={pixelRatio:2,stretchX:[[20,45],[100,130]],stretchY:[[20,35]],content:[10,10,130,45]},na={pixelRatio:2,stretchX:[[30,110]],stretchY:[[25,35]],content:[10,10,130,50]},la=e=>{if(!ve())return;const t=Te('<svg xmlns="http://www.w3.org/2000/svg" width="140" height="60">\n <g filter="url(#shadow)">\n <rect id="plaque" x="10" y="10" width="120" height="40" rx="8"/>\n </g>\n <defs>\n <filter id="shadow">\n <feDropShadow dx="0" dy="2" stdDeviation="3" flood-opacity=".35"/>\n </filter>\n </defs>\n</svg>\n');return t.querySelector("#plaque")?.setAttribute("fill",e),Re(t)},ca={whiteDisc:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><circle cx="23" cy="23" r="19.5" fill="#fff" stroke="#D0021B" stroke-width="5"/></svg>\n',yellowDisc:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><circle cx="23" cy="23" r="19.5" fill="#FFCE00" stroke="#D0021B" stroke-width="5"/></svg>\n',plaque:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><rect x="7" y="3" width="32" height="40" rx="2" fill="#fff" stroke="#1A2024" stroke-width="2"/><text x="23" y="13" fill="#1A2024" font-family="sans-serif" font-size="7" font-weight="bold" text-anchor="middle">SPEED</text><text x="23" y="21" fill="#1A2024" font-family="sans-serif" font-size="7" font-weight="bold" text-anchor="middle">LIMIT</text></svg>\n'},ha=e=>{if(ve())return Re(Te(ca[e]))},ua=e=>{if(!ve())return;const t=Te('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">\n <g id="main">\n <path fill-rule="evenodd"\n d="M11.389 4H9.025a.86.86 0 0 0-.517.173l-.001-.001a.5.5 0 0 1-.464.059l-.028-.011a.5.5 0 0 1-.129-.83A1.86 1.86 0 0 1 9.025 3h2.364a2 2 0 0 1 1.789 1.106l1.02 2.04c.471.176.802.63.802 1.156v.803c0 .543 0 .815-.071 1.038a1.5 1.5 0 0 1-.914.953c-.219.08-.491.092-1.034.114l-1.481.062v-.166-.803a2.23 2.23 0 0 0-1.055-1.897l-.74-1.479 2.326.033h.955l-.703-1.406A1 1 0 0 0 11.389 4zM12 8.4a1 1 0 1 1 2 0 .5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5z"/>\n <path d="M11.833 11.115c0-.109.089-.198.198-.198h1.979c.109 0 .198.089.198.198 0 .328-.266.594-.594.594h-1.187c-.328 0-.594-.266-.594-.594z"/>\n <path fill-rule="evenodd"\n d="M1.802 8.146C1.331 8.321 1 8.776 1 9.302v.803c0 .543 0 .815.071 1.038a1.5 1.5 0 0 0 .914.953c.219.08.491.092 1.034.114l2.731.114 2.731-.114c.543-.023.814-.034 1.034-.114a1.5 1.5 0 0 0 .914-.953c.071-.223.071-.494.071-1.038v-.803c0-.526-.331-.98-.802-1.156l-1.02-2.04A2 2 0 0 0 6.889 5H4.611a2 2 0 0 0-1.789 1.106l-1.02 2.04zM6.889 6H4.611a1 1 0 0 0-.894.553l-.703 1.406h.955 3.563.955l-.703-1.406A1 1 0 0 0 6.889 6zM2 10.4a1 1 0 1 1 2 0 .5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zm6.5-1a1 1 0 0 0-1 1 .5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5 1 1 0 0 0-1-1z"/>\n <path d="M1.792 13.115c0-.109.089-.198.198-.198h1.979c.109 0 .198.089.198.198 0 .328-.266.594-.594.594H2.385c-.328 0-.594-.266-.594-.594zm5.739-.198c-.109 0-.198.089-.198.198 0 .328.266.594.594.594h1.188c.328 0 .594-.266.594-.594 0-.109-.089-.198-.198-.198h-1.98z"/>\n </g>\n</svg>\n'),i=t.querySelector("#main");return i.setAttribute("transform","scale(2)"),i.setAttribute("fill",e),Re(t)},da=(e,t)=>{if(!ve())return;const i=we(t);return e&&i.appendChild(e),Re(i)},pa=e=>{if(ve())return da(Te('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path d="M63.734 86.383c-1.404.026-2.78-.393-3.93-1.197s-2.01-1.949-2.46-3.271l-3.15-9.339c-1.093-3.403-3.748-6.089-7.154-7.238L37.5 62.21c-2.742-.902-4.567-3.477-4.5-6.345-.058-2.874 1.761-5.457 4.5-6.388l36-11.886c2.461-.88 5.213-.27 7.062 1.567s2.466 4.571 1.578 7.015L70.17 81.918c-.938 2.719-3.54 4.526-6.436 4.469h0z"\n fill="#f4f5f6"/>\n</svg>\n'),e)},ya=e=>{if(ve())return da(Te('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path d="M33 83.404a2.99 2.99 0 0 1-3-2.978V44.681a2.99 2.99 0 1 1 6 0v35.745a2.99 2.99 0 0 1-3 2.978zm48-38.723H39v17.872h42V44.681zm3.878 37.851a3.02 3.02 0 0 0 4.244 0c.561-.559.878-1.317.878-2.106V44.681a2.99 2.99 0 1 0-6 0v35.745c0 .789.317 1.547.878 2.106z"\n fill="#f4f5f6"/>\n</svg>\n'),e)},fa=(e={},t)=>Object.entries(e).map(([e,i])=>({...i,id:Qt(e,t)})),ma=(e={},t)=>({...Object.fromEntries(ao.map(i=>[mo(i),fa(e.sections?.[i],t)])),mainLines:fa(e.mainLines,t),waypoints:fa(e.waypoints,t),chargingStops:fa(e?.chargingStops,t),ferries:fa(e.sections?.ferry,t),incidents:fa(e.sections?.traffic,t),tollRoads:fa(e.sections?.tollRoad,t),tunnels:fa(e.sections?.tunnel,t),vehicleRestricted:fa(e.sections?.vehicleRestricted,t),instructionLines:fa(e.instructionLines,t),instructionArrows:fa(e.instructionArrows,t),summaryBubbles:fa(e.summaryBubbles,t),countryCrossings:fa(e.countryCrossings,t)}),ga=(e,t,i,r)=>{const s=c.instance.get().displayUnits,o=e?.displayUnits;return{...e,...o?{}:{displayUnits:s},layers:ia(e,t,i,r)}},_a=(e,t)=>{const i=e[t-1]??e[t],r=e[t+1]??e[t];return i===r?0:(E(i,r)+360)%360},ba=(e,t,i,r)=>{const s=f();return{type:"Feature",id:s,geometry:{type:"Point",coordinates:i[t.startPointIndex]},properties:{id:s,fromCountryCode:e.countryCodeISO2,toCountryCode:t.countryCodeISO2,label:`${e.countryCodeISO2} → ${t.countryCodeISO2}`,bearing:_a(i,t.startPointIndex),fromSectionStartPointIndex:e.startPointIndex,toSectionStartPointIndex:t.startPointIndex,routeState:r.routeState,routeIndex:r.index}}},La=e=>{const t=e.properties.sections.country;if(!t?.length)return[];const i=[...t].sort((e,t)=>e.startPointIndex-t.startPointIndex),r=e.geometry.coordinates;return i.slice(1).flatMap((t,s)=>r[t.startPointIndex]?[ba(i[s],t,r,e.properties)]:[])},Sa=e=>({type:"FeatureCollection",features:e.features.flatMap(La)}),Ia=(e,t)=>{const i=t?.chargingStops?.icon;if(i?.mapping){const t=i.mapping;switch(t.basedOn){case"chargingSpeed":if(e.properties.chargingConnectionInfo?.chargingSpeed)return t.value[e.properties.chargingConnectionInfo?.chargingSpeed];break;case"custom":return t.fn(e)}}return Ee("7309")},Aa=e=>{const t=e.properties;return t.chargingParkName??t.chargingParkOperatorName},Ea=e=>e.categories.includes("jam"),va=e=>{const t=(e=>{if(Ea(e))return y(e.delayInSeconds)})(e),i=((e,t)=>Ea(e)?`traffic-jam-${e.magnitudeOfDelay??"unknown"}-${(e=>e?.length?e.length<6?"small":e.length<8?"medium":"large":"collapsed")(t)}`:null)(e,t),r=(e=>{const t=e.categories.find(e=>"jam"!==e);return t?(e=>{switch(e){case"accident":return"traffic-incidents-accident";case"roadworks":return"traffic-incidents-roadworks";case"road-closed":return"traffic-incidents-road_closed";case"lane-closed":case"narrow-lanes":return"traffic-incidents-lane_closed";case"danger":case"animals-on-road":return"traffic-incidents-danger";case"broken-down-vehicle":return"traffic-incidents-broken_down_vehicle";case"wind":return"traffic-incidents-wind";case"fog":return"traffic-incidents-fog";case"rain":return"traffic-incidents-rain";case"frost":return"traffic-incidents-frost";case"flooding":return"traffic-incidents-flooding";default:return null}})(t):null})(e);return{...e,...i&&{jamIconID:i},...r&&{causeIconID:r},...t&&{title:t}}},Ra=(e,t,i)=>{let r;switch(t){case"start":r=jo;break;case"finish":r=Ko;break;default:r=$o}return void 0!==i?Jt(r,i):r},Ta=(e,t,i,r)=>({type:"FeatureCollection",features:e.map((s,o)=>{if(!s)return null;const a=(e=>{return Array.isArray(e)?{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{}}:"Point"===e.type?{type:"Feature",geometry:t=e,properties:{},...t.bbox&&{bbox:t.bbox}}:e;var t})(s),n=((e,t)=>0===e?Go:e<t-1?Bo:Vo)(o,e.length),l=(e=>{const t=e?.properties;return t?.poi?.name??t?.address?.freeformAddress??void 0})(a),c=a.id??f(),h=y(a.properties.pauseDurationSeconds,r);return{...a,..."main-when-available"===t?.entryPoints&&{geometry:{type:"Point",coordinates:g(a,{useEntryPoint:"main-when-available"})}},id:c,properties:{...a.properties,id:c,index:o,indexType:n,...l&&{title:l},...h&&{stopDuration:h},iconID:Ra(0,n,i),..."middle"===n&&{stopDisplayIndex:o}}}}).filter(e=>e)}),wa=(e,t,i)=>({type:"FeatureCollection",features:e.features.flatMap(e=>((e,t,i)=>e.properties.sections[t]?.map(t=>{const r=t.id??f();return{type:"Feature",id:r,geometry:{type:"LineString",coordinates:e.geometry.coordinates.slice(t.startPointIndex,t.endPointIndex+1)},properties:{...i?i(t,e.properties):t,routeState:e.properties.routeState,routeIndex:e.properties.index,id:r}}})||[])(e,t,i))}),Ca=(e,t)=>t.show(((e,t)=>({...t,features:t.features.map(t=>({...t,properties:{...t.properties,routeState:e.features[t.properties.routeIndex||0].properties.routeState}}))}))(e,t.shownFeatures)),Oa=(e,t=0)=>{const i="features"in e?e:{type:"FeatureCollection",features:[e]};return{...i,features:i.features.map((e,i)=>{const r=e.id??f();return{...e,id:r,properties:{...e.properties,id:r,routeState:i===t?"selected":"deselected"}}})}},Ma=(e,t)=>e.some(e=>e.magnitudeOfDelay===t),Na=(e,t)=>({type:"FeatureCollection",features:e.features.map(e=>{const i=e.properties.summary,r=e.geometry.coordinates,s=y(i.trafficDelayInSeconds,t?.time),o=(e=>{const t=e.properties.sections.traffic;if(t?.length)return Ma(t,"major")?"major":Ma(t,"moderate")?"moderate":Ma(t,"minor")?"minor":void 0})(e),a=e.id??f();return{type:"Feature",id:a,geometry:{type:"Point",coordinates:r[Math.round(r.length/2)]},properties:{id:a,routeIndex:e.properties.index,routeState:e.properties.routeState,formattedDistance:p(i.lengthInMeters,t?.distance),...o&&{magnitudeOfDelay:o},...s&&{formattedTraffic:s},formattedDuration:y(i.travelTimeInSeconds,t?.time)}}})}),xa={GBR:{unit:"mph"},LBR:{unit:"mph"},MMR:{unit:"mph"},USA:{face:"plaque",unit:"mph"},SWE:{face:"yellowDisc"},FIN:{face:"yellowDisc"},ISL:{face:"yellowDisc"},JPN:{numerals:"#0B5FA5"}},Da={metric:{},imperial_uk:{unit:"mph"},imperial_us:{face:"plaque",unit:"mph"}},Fa={whiteDisc:"routeSpeedLimitWhiteDisc",yellowDisc:"routeSpeedLimitYellowDisc",plaque:"routeSpeedLimitPlaque"},ka=(e,t)=>"mph"===t?5*Math.round(1e3*e/l/5):e,Pa=class e extends Ke{static async create(t,i){return await Ce(t),new e(t,i)}constructor(e,t){super(e,t),this.shownFeaturesHandlers=[]}createSourcesWithLayers(e){const t=Jt("routes",this.instanceIndex);return{...Object.fromEntries(ao.map(i=>{const r=mo(i);return[r,new lt(this.mapLibreMap,`${t}-${r}`,e[r],!1)]})),mainLines:new lt(this.mapLibreMap,`${t}-mainLines`,e.mainLines,!1),waypoints:new lt(this.mapLibreMap,`${t}-waypoints`,e.waypoints,!1),incidents:new lt(this.mapLibreMap,`${t}-incidents`,e.incidents,!1),ferries:new lt(this.mapLibreMap,`${t}-ferries`,e.ferries,!1),chargingStops:new lt(this.mapLibreMap,`${t}-chargingStops`,e.chargingStops,!1),tollRoads:new lt(this.mapLibreMap,`${t}-tollRoads`,e.tollRoads,!1),tunnels:new lt(this.mapLibreMap,`${t}-tunnels`,e.tunnels,!1),vehicleRestricted:new lt(this.mapLibreMap,`${t}-vehicleRestricted`,e.vehicleRestricted,!1),instructionLines:new lt(this.mapLibreMap,`${t}-instructionLines`,e.instructionLines,!1),instructionArrows:new lt(this.mapLibreMap,`${t}-instructionArrows`,e.instructionArrows,!1),summaryBubbles:new lt(this.mapLibreMap,`${t}-summaryBubbles`,e.summaryBubbles,!1),countryCrossings:new lt(this.mapLibreMap,`${t}-countryCrossings`,e.countryCrossings,!1)}}_initSourcesWithLayers(e,t){t||(this.layerIDPrefix=Jt("routes",this.instanceIndex)),this.layersSpecs=ma(ga(e,this.layerIDPrefix,this.instanceIndex,this.tomtomMap.styleLightDarkTheme).layers,this.layerIDPrefix);const i=this.createSourcesWithLayers(this.layersSpecs);ke(Object.values(i).flatMap(e=>e._layerSpecs),this.mapLibreMap);const r={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},s={pixelRatio:2},o=Jt(jo,this.instanceIndex),a=Jt($o,this.instanceIndex),n=Jt(Ko,this.instanceIndex),l=Jt(Ps,this.instanceIndex),c=Jt(Ks,this.instanceIndex),h=Jt(Ys,this.instanceIndex),u=Jt(Do,this.instanceIndex),d=Jt(Fo,this.instanceIndex),p=Jt(ko,this.instanceIndex),y=Jt(Po,this.instanceIndex);this.addImageIfNotExisting(o,pa(r),s),this.addImageIfNotExisting(a,da(void 0,r),s),this.addImageIfNotExisting(n,ya(r),s),this.addImageIfNotExisting(l,et,s),this.addImageIfNotExisting(c,oa("white"),aa),this.addImageIfNotExisting(h,oa("#EEEEEE"),aa);for(const[f,m]of Object.entries(Fa))this.addImageIfNotExisting(Jt(m,this.instanceIndex),ha(f),s);this.appliedCrossingColors=void 0,this.addImageIfNotExisting(Jt(ws,this.instanceIndex),la(this.crossingColors(this.config).plaque),{...s,...na}),this.addImageIfNotExisting(u,ua(Ss),s),this.addImageIfNotExisting(d,ua(gs),s),this.addImageIfNotExisting(p,ua(_s),s),this.addImageIfNotExisting(y,ua(Ls),s);for(const f of e?.chargingStops?.icon?.customIcons??[])this.addImageIfNotExisting(f.id,f.image,{pixelRatio:f.pixelRatio??2});return i}_applyConfig(e){const i=ga(e,this.layerIDPrefix,this.instanceIndex,this.tomtomMap.styleLightDarkTheme),r=!t(this.config?.displayUnits,i.displayUnits);if(this.config){const t=ma(i.layers,this.layerIDPrefix);Object.keys(t).forEach(e=>{const i=e;xe(t[i],this.layersSpecs[i],this.sourcesWithLayers[i],this.mapLibreMap)});const s=Object.values(this.sourcesWithLayers);ke(s.flatMap(e=>e._layerSpecs),this.mapLibreMap),this.reshowSpeedLimitSigns(i,r),s.forEach(e=>e.setLayersVisible(!!e.shownFeatures.features.length)),this.applySectionVisibility(e),this.applySignPriority(e),this.layersSpecs=t}if(e?.theme?.mainColor!==this.config?.theme?.mainColor){const t={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},i={pixelRatio:2};He("add-or-update",Jt(jo,this.instanceIndex),pa(t),this.mapLibreMap,i),He("add-or-update",Jt($o,this.instanceIndex),da(void 0,t),this.mapLibreMap,i),He("add-or-update",Jt(Ko,this.instanceIndex),ya(t),this.mapLibreMap,i)}const s=!1!==i.summaryBubbles?.visible,o=!t(this.config?.summaryBubbles?.visible,i.summaryBubbles?.visible),a=this.sourcesWithLayers.summaryBubbles.shownFeatures.features.length>0,n=this.sourcesWithLayers.mainLines.shownFeatures.features.length>0;return!s&&o?this.sourcesWithLayers.summaryBubbles.clear():s&&(o&&n||r&&a)&&this.sourcesWithLayers.summaryBubbles.show(Na(this.sourcesWithLayers.mainLines.shownFeatures,i.displayUnits)),this.applyCountryCrossingConfig(i),i}showSpeedLimitSections(e,t){var i,r;this.sourcesWithLayers.speedLimitSections.show(wa(e,"speedLimit",(i=this.instanceIndex,r={unit:t?.sections?.speedLimit?.sign?.unit,displayUnits:t?.displayUnits},(e,t)=>{const s=(o=e.startPointIndex,a=t?.sections.country,a?.find(e=>o>=e.startPointIndex&&o<=e.endPointIndex)?.countryCodeISO3);var o,a;const n=s?xa[s]??{}:Da[r?.displayUnits?.distance?.type??"metric"],l=n.face??"whiteDisc",c=r?.unit??n.unit??"km/h";return{...e,signImageID:Jt(Fa[l],i),signLabel:String(ka(e.maxSpeedLimitInKmh,c)),signFace:l,signNumeralsColor:n.numerals??"#1A2024"}})))}crossingColors(e){return $r(e?.countryCrossings,this.tomtomMap.styleLightDarkTheme)}applyCountryCrossingConfig(e){const i=!1!==e.countryCrossings?.visible,r=!t(this.config?.countryCrossings?.visible,e.countryCrossings?.visible);!i&&r?this.sourcesWithLayers.countryCrossings.clear():i&&r&&this.sourcesWithLayers.countryCrossings.show(Sa(this.sourcesWithLayers.mainLines.shownFeatures));const s=this.crossingColors(e);if(t(this.appliedCrossingColors,s))return;this.appliedCrossingColors=s,He("add-or-update",Jt(ws,this.instanceIndex),la(s.plaque),this.mapLibreMap,na);const o=Qt(Cs,this.layerIDPrefix);this.mapLibreMap.getLayer(o)&&this.mapLibreMap.setPaintProperty(o,"text-color",s.text,{validate:!1})}reshowSpeedLimitSigns(e,i){t(this.config?.sections?.speedLimit?.sign?.unit,e.sections?.speedLimit?.sign?.unit)&&!i||this.sourcesWithLayers.speedLimitSections.shownFeatures.features.length&&this.showSpeedLimitSections(this.sourcesWithLayers.mainLines.shownFeatures,e)}applySectionVisibility(e){for(const t of lo){const i=this.sourcesWithLayers[mo(t)],r=!!i.shownFeatures.features.length;i.setLayersVisible(r&&bo(t,e?.sections?.[t]))}}signLayerID(e){if(fo(e))return Qt(xo(e),this.layerIDPrefix)}applySignPriority(e){for(const t of ao){const i=this.signLayerID(t);if(!i||!this.mapLibreMap.getLayer(i))continue;const r=e?.sections?.[t];this.mapLibreMap.moveLayer(i,this.signAnchorLayerID(i,r))}}signAnchorLayerID(e,t){const i=(e=>e?.sign?.priority??("atChange"===Oo(e)?"belowRouteIcons":"belowMapLabels"))(t);if("aboveRouteIcons"===i)return;const r=this.mapLibreMap.getStyle().layers;if("belowMapLabels"===i)return Rt.lowestLabel;const s=r.findIndex(e=>e.id===Rt.lowestLabel);return r.find((t,i)=>"symbol"===t.type&&t.id!==e&&i>s&&(!this.layerIDPrefix||t.id.startsWith(this.layerIDPrefix)))?.id}discardShownData(){}restoreDataAndConfigImpl(){const e=Object.fromEntries(Object.entries(this.sourcesWithLayers).map(([e,t])=>[e,t.shownFeatures]));this.initSourcesWithLayers(this.config,!0),this._applyConfig(this.config);for(const t of Object.keys(e))this.sourcesWithLayers[t].show(e[t]);this.applySectionVisibility(this.config)}addImageIfNotExisting(e,t,i){He("if-not-in-sprite",e,t,this.mapLibreMap,i)}async showRoutes(e,t){const i=Oa(e,t?.selectedIndex);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(i),this.sourcesWithLayers.vehicleRestricted.show(wa(i,"vehicleRestricted")),this.sourcesWithLayers.incidents.show(wa(i,"traffic",va)),this.sourcesWithLayers.chargingStops.show(((e,t)=>{const i=[];if(!1!==t?.chargingStops?.visible)for(const r of e.features)for(const e of r.properties.sections.leg){const s=e.summary.chargingInformationAtEndOfLeg;if(s){const o=s.properties,a=y(e.summary.stopTimeInSeconds??o.chargingTimeInSeconds,t?.displayUnits?.time);i.push({...s,properties:{...s.properties,id:s.properties.chargingParkId??f(),iconID:Ia(s,t),title:Aa(s),chargingPower:`${o.chargingConnectionInfo?.chargingPowerInkW} kW`,chargingDuration:y(o.chargingTimeInSeconds,t?.displayUnits?.time),...a&&{stopDuration:a},routeState:r.properties.routeState,routeIndex:r.properties.index}})}}return{type:"FeatureCollection",features:i}})(i,this.config)),this.sourcesWithLayers.ferries.show(wa(i,"ferry")),this.sourcesWithLayers.tunnels.show(wa(i,"tunnel")),this.sourcesWithLayers.tollRoads.show(wa(i,"tollRoad"));for(const r of ao)fo(r)||this.sourcesWithLayers[mo(r)].show(wa(i,r));this.showSpeedLimitSections(i,this.config),this.applySectionVisibility(this.config),this.applySignPriority(this.config),this.sourcesWithLayers.instructionLines.show((e=>({type:"FeatureCollection",features:e.features.flatMap((e,t)=>e.properties.guidance?.instructions?.filter(e=>e.routePath?.length).map(i=>({type:"Feature",geometry:{type:"LineString",coordinates:i.routePath.map(e=>e.point)},properties:{...i,id:f(),routeIndex:t,routeState:e.properties.routeState}}))||[])}))(i)),this.sourcesWithLayers.instructionArrows.show((e=>({type:"FeatureCollection",features:e.features.flatMap((e,t)=>e.properties.guidance?.instructions?.filter(e=>e.routePath?.length&&e.routePath.length>1).map(i=>{const r=[i.routePath[i.routePath.length-2]?.point,i.routePath[i.routePath.length-1]?.point];return{type:"Feature",geometry:{type:"Point",coordinates:r[1]},properties:{...i,id:f(),routeIndex:t,routeState:e.properties.routeState,lastPointBearingDegrees:E(r[0],r[1])}}})||[])}))(i)),!1!==this.config?.countryCrossings?.visible?this.sourcesWithLayers.countryCrossings.show(Sa(i)):this.sourcesWithLayers.countryCrossings.clear(),!1!==this.config?.summaryBubbles?.visible?this.sourcesWithLayers.summaryBubbles.show(Na(i,this.config?.displayUnits)):this.sourcesWithLayers.summaryBubbles.clear();for(const r of this.shownFeaturesHandlers)r({routes:e})}async clearRoutes(){await this.waitUntilModuleReady();for(const e of Object.keys(this.sourcesWithLayers))"waypoints"!==e&&this.sourcesWithLayers[e].clear()}async selectRoute(e){const t=Oa(this.sourcesWithLayers.mainLines.shownFeatures,e);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(t),Ca(t,this.sourcesWithLayers.chargingStops),Ca(t,this.sourcesWithLayers.vehicleRestricted),Ca(t,this.sourcesWithLayers.incidents),Ca(t,this.sourcesWithLayers.ferries),Ca(t,this.sourcesWithLayers.tollRoads);for(const i of ao)Ca(t,this.sourcesWithLayers[mo(i)]);Ca(t,this.sourcesWithLayers.tunnels),Ca(t,this.sourcesWithLayers.instructionLines),Ca(t,this.sourcesWithLayers.instructionArrows),Ca(t,this.sourcesWithLayers.summaryBubbles),Ca(t,this.sourcesWithLayers.countryCrossings),this.applySectionVisibility(this.config)}async showWaypoints(e){const t=Array.isArray(e)?Ta(e,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time):Ta(e.features,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time);await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.show(t),this.applySignPriority(this.config);for(const i of this.shownFeaturesHandlers)i({waypoints:e})}async clearWaypoints(){await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.clear()}getShown(){return{mainLines:this.sourcesWithLayers.mainLines.shownFeatures,waypoints:this.sourcesWithLayers.waypoints.shownFeatures,incidents:this.sourcesWithLayers.incidents.shownFeatures,ferries:this.sourcesWithLayers.ferries.shownFeatures,chargingStops:this.sourcesWithLayers.chargingStops.shownFeatures,tollRoads:this.sourcesWithLayers.tollRoads.shownFeatures,...Object.fromEntries(ao.map(e=>[mo(e),this.sourcesWithLayers[mo(e)].shownFeatures])),tunnels:this.sourcesWithLayers.tunnels.shownFeatures,vehicleRestricted:this.sourcesWithLayers.vehicleRestricted.shownFeatures,instructionLines:this.sourcesWithLayers.instructionLines.shownFeatures,instructionArrows:this.sourcesWithLayers.instructionArrows.shownFeatures,summaryBubbles:this.sourcesWithLayers.summaryBubbles.shownFeatures,countryCrossings:this.sourcesWithLayers.countryCrossings.shownFeatures}}get events(){const e=Object.fromEntries(ao.map(e=>[mo(e),this.userEvents([mo(e)])]));return this.buildEvents(this.moduleEventsWithShown(["mainLines","waypoints","chargingStops","summaryBubbles","countryCrossings","incidents","vehicleRestricted","ferries","tollRoads","tunnels","instructionLines",...ao.map(mo)],this.shownFeaturesHandlers),{...e,mainLines:this.userEvents(["mainLines"]),waypoints:this.userEvents(["waypoints"]),chargingStops:this.userEvents(["chargingStops"]),summaryBubbles:this.userEvents(["summaryBubbles"]),countryCrossings:this.userEvents(["countryCrossings"],{mapping:e=>((e,t)=>{const i=e.properties,r=t.features[i.routeIndex]?.properties.sections.country??[],s=e=>r.find(t=>t.startPointIndex===e);return{type:"Feature",id:e.id,geometry:e.geometry,properties:{...i,fromSection:s(i.fromSectionStartPointIndex),toSection:s(i.toSectionStartPointIndex)}}})(e,this.sourcesWithLayers.mainLines.shownFeatures)}),incidents:this.userEvents(["incidents"]),vehicleRestricted:this.userEvents(["vehicleRestricted"]),ferries:this.userEvents(["ferries"]),tollRoads:this.userEvents(["tollRoads"]),tunnels:this.userEvents(["tunnels"]),instructionLines:this.userEvents(["instructionLines"])})}getLayerToRenderLinesUnder(){return Rt.lowestLabel}},Ua={fill:["fill-color","fill-outline-color"],line:["line-color"],"fill-extrusion":["fill-extrusion-color"]},Ha=e=>t=>({layers:[{...t,layerTypes:[e]}],properties:[...Ua[e]]}),Wa=Ha("fill"),Ga=Ha("line"),Ba=Ha("fill-extrusion"),Va=(e,t)=>({metadataGroups:["road"],layerTypes:["line"],idIncludes:e,...t&&{idExcludes:t}}),za=Va(["road line","road outline","under construction"],["tarmac"]),ja=Va(["motorway","primary road","major road"]),$a=Va(["secondary road","tertiary road","street","minor road","link road","restricted","service road"],["outline"]),Ka=Va(["secondary road outline","tertiary road outline","street outline","minor road outline","link road outline","tarmac outline"]),Ya=Va(["railway","subway","track","path","aerialway"],["outline"]),qa={metadataGroups:["places_label","road_label","label","address_point_label","border_label"],layerTypes:["symbol"],idExcludes:["shield","exit","water","river"]},Za={land:{description:"Map background and other bare-land features, influences admin borders/labels. Also used to derive all map colours if undefined.",anchor:{layers:[{layerTypes:["background"]}],property:"background-color"},targets:[{layers:[{layerTypes:["background"]}],properties:["background-color"]},Wa({metadataGroups:["area"],idIncludes:["earth cover","landcover"]}),Wa({metadataGroups:["road_area"]}),Wa({metadataGroups:["transit_area"]}),Ga({metadataGroups:["transit_area"]})]},water:{description:"Waterbodies, waterways and other water features. Also influences glaciers, water labels and ferry lines.",anchor:{layers:[{metadataGroups:["water"],layerTypes:["fill"],idIncludes:["fill"]}],property:"fill-color"},targets:[Wa({metadataGroups:["water"]}),Ga({metadataGroups:["water"]}),{layers:[{metadataGroups:["label"],layerTypes:["symbol"],idIncludes:["water","river"]}],properties:["text-color","text-halo-color"]},Ga({metadataGroups:["road"],idIncludes:["ferry"]})]},vegetation:{description:"Forests and other land cover such as grass and shrubland. Also influences earth cover vegetation at smaller scales.",anchor:{layers:[{metadataGroups:["area"],layerTypes:["fill"],idIncludes:["landcover"]}],property:"fill-color"},targets:[Wa({metadataGroups:["area"],idIncludes:["landcover","earth cover"]})]},park:{description:"City parks and sport/recreation grounds. Also influences National Parks and other protected areas at smaller scales.",anchor:{layers:[{metadataGroups:["area"],layerTypes:["fill"],idIncludes:["protected"]}],property:"fill-color"},targets:[Wa({metadataGroups:["area"],idIncludes:["protected","outdoor","sport","landuse"]}),Ga({metadataGroups:["border"],idIncludes:["overlays"]})]},artificial:{description:"Built-up-areas and man-made features such as landuse grounds and buildings. Also influences railways.",anchor:{layers:[{metadataGroups:["area"],layerTypes:["fill"],idIncludes:["built-up"]}],property:"fill-color"},targets:[Wa({metadataGroups:["area"],idIncludes:["built-up","landuse","parking"]}),Wa({metadataGroups:["building","transit_area","road_area"]}),Ga({metadataGroups:["building","transit_area"]}),Ba({metadataGroups:["area_3d","building"]}),Ga(Ya)]},roadMajor:{description:"Most important road classes, from motorways & trunks to primary roads. Also influences outline and tunnel colours.",anchor:{layers:[Va(["motorway & trunk"],["outline"])],property:"line-color",roadClass:"major"},targets:[Ga(ja),{layers:[za],properties:["line-color"],roadClass:"major"}]},road:{description:"Less important road classes, from secondary/tertiary to streets and service roads. Also influences tunnel colours.",anchor:{layers:[Va(["secondary road"],["outline"])],property:"line-color"},targets:[Ga($a),{layers:[Va(["road line","under construction"])],properties:["line-color"],roadClass:"minor"}]},roadOutline:{description:"Road outlines for secondary/tertiary roads and minor classes. Also influences road labels and all other outline colours.",anchor:{layers:[Va(["secondary road outline"])],property:"line-color"},targets:[Ga(Ka),{layers:[Va(["road outline"],["tarmac"])],properties:["line-color"],roadClass:"minor"}]},label:{description:"Labels for capitals and other populated places/admin areas. Also influences border styling and all other label colours.",anchor:{layers:[{metadataGroups:["places_label"],layerTypes:["symbol"],idIncludes:["city"]}],property:"text-color"},targets:[{layers:[qa],properties:["text-color"]},Ga({metadataGroups:["border"],idIncludes:["country","state","treaty","disputed"]})]},labelOutline:{description:"Outlines for populated places and admin area labels. Also influences border outlines and all other label halos.",anchor:{layers:[{metadataGroups:["places_label"],layerTypes:["symbol"],idIncludes:["city"]}],property:"text-halo-color"},targets:[{layers:[qa],properties:["text-halo-color"]},Ga({metadataGroups:["border"],idIncludes:["background"]})]}},Xa=Object.keys(Za),Ja=e=>e in Za,Qa={min:.5,max:1.5,step:.1},en={min:.5,max:2,step:.1},tn={sourceTypes:["vector"],layerTypes:["symbol"]},rn={sources:["vectorTiles"],sourceLayers:["poi"],layerTypes:["symbol"]},sn={...hr("roads"),layerTypes:["line"]},on=e=>(t,i)=>({sources:[e],layerTypes:["line"],idIncludes:[i?`${t} outline`:t],...i?{}:{idExcludes:["outline"]}}),an=on(Nt),nn=on(Mt),ln=(e,t,i=Qa)=>({kind:"factor",description:e,range:i,appliesTo:"any-style",mechanisms:t}),cn=(e,t)=>({kind:"toggle",description:e,appliesTo:"tomtom-styles",mechanisms:[{type:"visibility",layers:t}]}),hn=(e,t,i,r)=>({kind:"color",description:e,appliesTo:"tomtom-styles",mechanisms:[{type:"color",property:t,layers:i,shades:r}]}),un={layerTypes:["hillshade"]},dn=/* @__PURE__ */new Set(["buildings2D","buildings3D"]),pn=Object.fromEntries(nr.filter(e=>!(e=>dn.has(e))(e)).map(e=>[`basemap.${e}`,cn(`The base-map layer group '${e}' (the same as BaseMapModule's).`,[hr(e)])])),yn=e=>({kind:"color",description:Za[e].description,appliesTo:"tomtom-styles",mechanisms:[{type:"mapColor",color:e}]}),fn=e=>(t,i)=>hn(t,"line-color",[e(i,!1)],[e(i,!0)]),mn=fn(an),gn=fn(nn),_n={"labels.sizeFactor":ln("Size of every base-map text label (places, roads, POIs, house numbers).",[{type:"scale",property:"text-size",layers:[tn]}]),"symbols.sizeFactor":ln("Size of every base-map icon (POI icons, route shields, road arrows).",[{type:"scale",property:"icon-size",layers:[tn]}]),"roads.widthFactor":ln("Width of all road lines, keeping the hierarchy motorway → path.",[{type:"scale",property:"line-width",layers:[sn]}]),"pois.sizeFactor":ln("Size of the base-map POI icons and their labels.",[{type:"scale",property:"icon-size",layers:[rn]},{type:"scale",property:"text-size",layers:[rn]}]),"pois.minZoom":{kind:"number",description:"Zoom level from which base-map POIs appear (the style default is 6).",range:{min:3,max:18,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"minZoom",layers:[{...rn,idExcludes:["micro"]}]}]},"pois.zoomShift":{kind:"number",description:"Shifts the zoom at which each POI appears: positive = later and sparser, negative = earlier and denser.",range:{min:-3,max:3,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"zoomOffset",layers:[rn]}]},"pois.labelColor":hn("Text colour of base-map POI labels (replaces the per-category colours).","text-color",[rn]),"pois.labelOutlineColor":hn("Halo colour of base-map POI labels.","text-halo-color",[rn]),"pois.microMarkers":cn("The small dot markers for low-priority POIs at high zoom.",[{...rn,idIncludes:["micro"]}]),"roads.exitNumbers":cn("Motorway exit number badges.",[{metadataGroups:["road_label"],layerTypes:["symbol"],idIncludes:["exit"]}]),"roads.shields":cn("Route shields along roads.",[{metadataGroups:["road_label"],layerTypes:["symbol"],idIncludes:["shield"]}]),"roads.arrows":cn("One-way arrows drawn on roads.",[{metadataGroups:["road"],layerTypes:["symbol"],idIncludes:["arrow"]}]),"roads.restricted":cn("Dashed marking of roads with restricted access.",[{metadataGroups:["road"],layerTypes:["line"],idIncludes:["restricted"]}]),"roads.underConstruction":cn("Roads under construction.",[{metadataGroups:["road"],layerTypes:["line"],idIncludes:["construction"]}]),"buildings.footprints":cn("2D building footprints, shadows and outlines.",[{metadataGroups:["building"],layerTypes:["fill","line"]}]),"buildings.3d":cn("Extruded 3D buildings (hidden by default in the standard styles).",[{metadataGroups:["area_3d","building"],layerTypes:["fill-extrusion"]}]),"traffic.flow.freeColor":mn("Traffic flow colour for free-flowing roads.","free flow"),"traffic.flow.slowColor":mn("Traffic flow colour for slow traffic.","slow flow"),"traffic.flow.queueingColor":mn("Traffic flow colour for queueing traffic.","queueing flow"),"traffic.flow.stationaryColor":mn("Traffic flow colour for stationary traffic.","stationary flow"),"traffic.flow.closedColor":hn("Traffic flow colour for closed roads.","line-color",[an("closed road",!0)]),"traffic.flow.widthFactor":ln("Width of the traffic flow tubes.",[{type:"scale",property:"line-width",layers:[{sources:[Nt],layerTypes:["line"]}]}],en),"traffic.incidents.minorColor":gn("Traffic incident tube colour for minor delays.","minor jam"),"traffic.incidents.moderateColor":gn("Traffic incident tube colour for moderate delays.","moderate jam"),"traffic.incidents.majorColor":gn("Traffic incident tube colour for major delays.","major jam"),"traffic.incidents.closedColor":hn("Traffic incident tube colour for closed roads.","line-color",[nn("closed road",!0)]),"traffic.incidents.widthFactor":ln("Width of the traffic incident tubes.",[{type:"scale",property:"line-width",layers:[{sources:[Mt],layerTypes:["line"]}]}],en),"colors.land":yn("land"),"colors.water":yn("water"),"colors.vegetation":yn("vegetation"),"colors.park":yn("park"),"colors.artificial":yn("artificial"),"colors.roadMajor":yn("roadMajor"),"colors.road":yn("road"),"colors.roadOutline":yn("roadOutline"),"colors.label":yn("label"),"colors.labelOutline":yn("labelOutline"),...pn,"hillshade.method":{kind:"enum",description:"How the relief is shaded: standard (one light), basic, igor (softer), combined, or multidirectional (four lights).",options:["standard","basic","igor","combined","multidirectional"],appliesTo:"tomtom-styles",mechanisms:[{type:"paintLiteral",property:"hillshade-method",layers:[un]}]},"hillshade.lightDirection":{kind:"number",description:"Direction the light comes from, in degrees clockwise from north (335 is the cartographic default).",range:{min:0,max:359,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"paintLiteral",property:"hillshade-illumination-direction",layers:[un]}]},"hillshade.exaggeration":{kind:"number",description:"Strength of the shading (0 = flat). The standard styles ramp it to zero by zoom 13; setting it replaces the ramp with a constant.",range:{min:0,max:1,step:.05},appliesTo:"tomtom-styles",mechanisms:[{type:"paintLiteral",property:"hillshade-exaggeration",layers:[un]}]},"hillshade.maxZoom":{kind:"number",description:"Zoom level up to which the shading is drawn (the standard styles stop at 13; 22 keeps it at every zoom).",range:{min:10,max:22,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"maxZoom",layers:[un]}]},"hillshade.shadowColor":hn("Colour of the shaded slopes.","hillshade-shadow-color",[un]),"hillshade.highlightColor":hn("Colour of the lit slopes.","hillshade-highlight-color",[un]),"hillshade.accentColor":hn("Colour accentuating the steepest terrain.","hillshade-accent-color",[un]),"view.projection":{kind:"enum",description:"How the map is drawn: flat Mercator or a globe. The globe flattens to Mercator between zoom 11 and 12 by design.",options:["mercator","globe"],appliesTo:"any-style",mechanisms:[{type:"projection"}]},"view.sky":{kind:"toggle",description:"A sky with atmosphere behind the globe and above a tilted flat map. Without it MapLibre draws a fully transparent sky, so a globe arrives with no atmosphere.",appliesTo:"any-style",mechanisms:[{type:"sky"}]},"view.skyColor":{kind:"color",description:"Colour of the sky (and of the atmosphere halo around the globe). Defaults to a daylit blue on a light style and a night blue on a dark one.",appliesTo:"any-style",mechanisms:[{type:"sky"}]},"view.horizonColor":{kind:"color",description:"Colour of the sky at the horizon. Defaults with the style theme, so a dark map gets a dim horizon rather than a white one.",appliesTo:"any-style",mechanisms:[{type:"sky"}]},"view.spaceColor":{kind:"color",description:"Colour behind the map, which a globe leaves visible around the planet. The map canvas is transparent, so without this the page background shows through. Defaults with the style theme: white on a light style, near-black on a dark one.",appliesTo:"any-style",mechanisms:[{type:"space"}]}},bn=Object.keys(_n),Ln=bn.filter(e=>"color"===_n[e].kind),Sn="styling.layers",In=class{constructor(e,t){this.registry=e,this.query=t}get layerIds(){return this.registry.resolve(this.query)}setPaint(e){for(const[t,i]of Object.entries(e))this.registry.override(this.query,{kind:"paint",property:t,value:i});return this}setLayout(e){for(const[t,i]of Object.entries(e))this.registry.override(this.query,{kind:"layout",property:t,value:i});return this}setFilter(e){return this.registry.overrideFilter(this.query,e),this}setVisible(e){return this.setLayout({visibility:e?"visible":"none"})}reset(){return this.registry.reset(this.query),this}},An=class{constructor(e,t,i){this.mapLibreMap=e,this.filterComposer=t,this.warn=i,this.layers=[],this.sources={},this.properties=/* @__PURE__ */new Map,this.filters=/* @__PURE__ */new Map}index(e,t){this.layers=e,this.sources=t}clear(){this.properties.clear(),this.filters.clear()}resolve(e){const t=En(e),i=this.layers.filter(e=>t.every(t=>or(t,e,this.sources))).map(e=>e.id);return 0===i.length&&this.warn(`query:${JSON.stringify(e)}`,`layers.query(${JSON.stringify(e)}) matches no layer in the loaded style; the edit will have no effect.`),i}override(e,t){const i=`${t.kind}:${t.property}`;for(const r of this.resolve(e)){const e=this.properties.get(r)??/* @__PURE__ */new Map,s=e.get(i);e.set(i,{override:t,before:s?s.before:this.read(r,t)}),this.properties.set(r,e),this.write(r,t)}}overrideFilter(e,t){for(const i of this.resolve(e))this.filters.set(i,t),this.filterComposer.setTransform(i,Sn,()=>t)}reset(e){for(const t of this.resolve(e)){for(const{override:e,before:i}of this.properties.get(t)?.values()??[])this.write(t,{...e,value:i});this.properties.delete(t),this.filters.delete(t)&&this.filterComposer.setTransform(t,Sn,void 0)}}reapply(){for(const[e,i]of this.properties)if(this.mapLibreMap.getLayer(e))for(const r of i.values()){const i=this.read(e,r.override);t(i,r.override.value)||(r.before=i),this.write(e,r.override)}for(const[e,t]of this.filters)this.filterComposer.setTransform(e,Sn,()=>t)}read(e,{kind:t,property:i}){const r=this.mapLibreMap;return"paint"===t?r.getPaintProperty(e,i):r.getLayoutProperty(e,i)}write(e,{kind:t,property:i,value:r}){if(!this.mapLibreMap.getLayer(e))return;const s=this.mapLibreMap,o={validate:!1};"paint"===t?s.setPaintProperty(e,i,r,o):s.setLayoutProperty(e,i,r,o)}},En=({group:e,...t})=>[t,...e?[hr(e)]:[]],vn={"data-viz":{name:"Data visualisation",description:"A quiet base for your own data on top: fewer labels and markers, thinner roads, no badges competing with the overlay.",settings:{"labels.sizeFactor":.9,"symbols.sizeFactor":.9,"roads.widthFactor":.8,"roads.exitNumbers":!1,"roads.shields":!1,"roads.arrows":!1,"pois.microMarkers":!1,"pois.minZoom":14,"buildings.3d":!1}},"night-driving":{name:"Night driving",description:"Bigger labels and shields, wider roads and traffic tubes, POIs out of the way until close up.",settings:{"labels.sizeFactor":1.2,"symbols.sizeFactor":1.2,"roads.widthFactor":1.2,"roads.exitNumbers":!0,"roads.shields":!0,"roads.arrows":!0,"pois.minZoom":13,"pois.microMarkers":!1,"traffic.flow.widthFactor":1.3,"buildings.3d":!1}},minimal:{name:"Minimal",description:"The bare map: land, water, roads and the main place names. Everything decorative off.",settings:{"labels.sizeFactor":.9,"roads.exitNumbers":!1,"roads.shields":!1,"roads.arrows":!1,"roads.restricted":!1,"roads.underConstruction":!1,"buildings.footprints":!1,"buildings.3d":!1,"pois.microMarkers":!1,"pois.minZoom":16}},globe:{name:"Globe",description:"A globe with an atmosphere for the zoomed-out view; flattens to Mercator as you zoom in.",settings:{"view.projection":"globe","view.sky":!0}}},Rn=Object.keys(vn),Tn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&Array.isArray(e.stops),wn=(e,t)=>"number"==typeof e?(e=>Math.round(1e3*e)/1e3)(e*t):Tn(e)?Cn(e,t):Array.isArray(e)?"interpolate"===e[0]||"step"===e[0]?On(e,t):(e=>JSON.stringify(e).includes('"zoom"'))(e)?void 0:["*",t,e]:void 0,Cn=(e,t)=>{const i=[];for(const[r,s]of e.stops){const e=wn(s,t);if(void 0===e)return;i.push([r,e])}return{...e,stops:i}},On=(e,t)=>{const i=[...e];for(let r="interpolate"===e[0]?4:2;r<i.length;r+=2){const e=wn(i[r],t);if(void 0===e)return;i[r]=e}return i},Mn=(e,t)=>{let i=!1;const r=e=>Array.isArray(e)?"-"===e[0]&&3===e.length&&Array.isArray(e[1])&&"zoom"===e[1][0]&&"number"==typeof e[2]?(i=!0,["-",["zoom"],e[2]+t]):e.map(r):e;return{filter:r(e),patched:i}},Nn=/* @__PURE__ */new Set(["motorway","trunk","primary"]),xn=e=>(Array.isArray(e)?e:[e]).some(e=>"string"==typeof e&&Nn.has(e))?"major":"minor",Dn=(e,t,i=void 0)=>{if((e=>{const t="string"==typeof e?ye(e):void 0;return void 0!==t&&t[3]>0})(e))return t(e,i);if(Array.isArray(e)){if("match"===(r=e)[0]&&Array.isArray(r[1])&&"get"===r[1][0]&&("category"===r[1][1]||"road_category"===r[1][1])){const i=[e[0],e[1]];for(let r=2;r<e.length-1;r+=2)i.push(e[r],Dn(e[r+1],t,xn(e[r])));return i.push(Dn(e[e.length-1],t,"minor")),i}return e.map(e=>Dn(e,t,i))}var r;return Tn(e)?{...e,stops:e.stops.map(([e,r])=>[e,Dn(r,t,i)])}:e},Fn=(e,t=()=>!0)=>{let i;for(const{literal:r,roadClass:s}of(e=>{const t=[];return Dn(e,(e,i)=>(t.push({literal:e,roadClass:i}),e)),t})(e)){if(!t(s))continue;const e=ye(r)?.[1]??0;(!i||e>i.saturation)&&(i={literal:r,saturation:e})}return i?.literal},kn=(e,t)=>{const i=ye(e),r=ye(t);if(!i||!r)return;const s=i[1]<8||r[1]<8;if(!s&&(o=i[0],a=r[0],Math.abs((o-a+540)%360-180)>40))return;var o,a;const n=me(e,t);return n&&(s?{...n,hue:0}:n)},Pn={minZoom:"minzoom",maxZoom:"maxzoom"},Un=/* @__PURE__ */new Set(["text-size","icon-size","visibility"]),Hn=/* @__PURE__ */new Set(["line-width","fill-color","fill-outline-color","line-color","text-color","text-halo-color","fill-extrusion-color","background-color","hillshade-shadow-color","hillshade-highlight-color","hillshade-accent-color","hillshade-method","hillshade-illumination-direction","hillshade-exaggeration"]),Wn={"text-size":16,"icon-size":1,"line-width":1,visibility:"visible",minzoom:0,maxzoom:24,"hillshade-method":"standard","hillshade-illumination-direction":335,"hillshade-exaggeration":.5,"hillshade-shadow-color":"#000000","hillshade-highlight-color":"#FFFFFF","hillshade-accent-color":"#000000"},Gn=(e,t)=>`${e}|${t}`,Bn={light:{"sky-color":"#88c6fc","horizon-color":"#ffffff","sky-horizon-blend":.8,"atmosphere-blend":.8,"fog-color":"#ffffff","fog-ground-blend":.5,"horizon-fog-blend":.8},dark:{"sky-color":"#0a1626","horizon-color":"#2b4a72","sky-horizon-blend":.8,"atmosphere-blend":.8,"fog-color":"#0a1626","fog-ground-blend":.5,"horizon-fog-blend":.8}},Vn={light:"#ffffff",dark:"#0a1626"},zn=/* @__PURE__ */new Set(["","transparent","rgba(0, 0, 0, 0)"]),jn={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0},$n=class e extends Ye{static async get(t,i){return await Ce(t),Dt(t,e,()=>new e(t,i),i&&(e=>e.updateConfig(i)))}constructor(e,t){super(e,t)}styleChangePriority(){return 100}_initSourcesWithLayers(){return this.indexStyle(this.mapLibreMap.getStyle()),this.refreshSpace(this.config??{}),{}}_applyConfig(e){const t=Xn(e),i=/* @__PURE__ */new Set([...Zn(this.config),...Zn(t)]),r=this.reindexed?i:[...i].filter(e=>this.config?.[e]!==t[e]);this.reindexed=!1;for(const s of r)this.refreshKnob(s,t);return this.tomtomMap.mapReady&&this.layerOverrides.reapply(),Object.keys(t).length?t:void 0}discardShownData(){this.layerOverrides.clear()}get layers(){return{query:e=>new In(this.layerOverrides,e)}}describe(){return{knobs:bn.map(e=>this.describeKnob(e)),presets:Rn.map(e=>({id:e,...vn[e],settings:{...vn[e].settings}}))}}applyPreset(e,t={}){const i=vn[e];if(!i)throw new Error(`Unknown styling preset '${e}'. Known presets: ${Rn.join(", ")}.`);t.merge?this.updateConfig(i.settings):this.applyConfig({...i.settings})}get(e){return this.assertKnob(e),this.config?.[e]??this.defaultOf(e)}set(e,t){this.assertKnob(e),this.validate(e,t),this.config={...this.config,[e]:t},this.refreshKnob(e,this.config),this.emitConfigChange()}reset(e){if(void 0===e)return void this.resetConfig();this.assertKnob(e);const{[e]:t,...i}=this.config??{};this.config=Object.keys(i).length?i:void 0,this.refreshKnob(e,this.config??{}),this.emitConfigChange()}setMapColors(e){const t={};for(const[i,r]of Object.entries(e)){if(!Ja(i))throw new Error(`Unknown map colour '${i}'. Known colours: ${Xa.join(", ")}.`);if(void 0===r)continue;const e=Kn(i);this.validate(e,r),t[e]=r}this.updateConfig(t)}exportStyle(){return structuredClone(this.mapLibreMap.getStyle())}get events(){return this.moduleEvents([])}indexStyle(e){const t=e?.layers??[];this.originalValues=/* @__PURE__ */new Map,this.styleSources=e?.sources??{},this.resolved=/* @__PURE__ */new Map,this.scaleKnobsByTarget=/* @__PURE__ */new Map,this.mapColorTargetsByKey=/* @__PURE__ */new Map,this.mapColorTargetsByKnob=/* @__PURE__ */new Map,this.mapColorAnchors=/* @__PURE__ */new Map,this.warned=/* @__PURE__ */new Set,this.reindexed=!0,this.layerOverrides??=new An(this.mapLibreMap,this.filterComposer,(e,t)=>this.warnOnce(e,t)),this.layerOverrides.index(t,this.styleSources),this.mapLevelState={projection:e?.projection?.type??"mercator",sky:e?.sky};for(const i of bn){const e=_n[i],r=e.mechanisms.map(e=>this.resolveMechanism(i,e,t)),s=new Set(r.flatMap(e=>e.layerIds)).size;this.resolved.set(i,{definition:e,mechanisms:r,targets:s}),0===s&&this.warnOnce(i,`knob '${i}' matches no layer in the loaded style (curated for style version ${Hr}); it will have no effect.`)}}resolveMechanism(e,t,i){if("mapColor"===t.type)return{mechanism:t,layerIds:this.resolveMapColor(t.color,i),shadeLayerIds:[]};if(!("layers"in t))return{mechanism:t,layerIds:["\0map"],shadeLayerIds:[]};const r=i.filter(e=>ar(t.layers,e,this.styleSources));let s,o=[];switch(t.type){case"scale":s=r.filter(e=>this.capture(e,t.property)).map(e=>e.id);for(const i of s){const r=Gn(i,t.property);this.scaleKnobsByTarget.set(r,[...this.scaleKnobsByTarget.get(r)??[],e])}break;case"color":{s=r.filter(e=>this.capture(e,t.property)).map(e=>e.id);const e=t.shades??[];o=i.filter(t=>ar(e,t,this.styleSources)).filter(e=>this.capture(e,t.property)).map(e=>e.id);break}case"visibility":s=r.filter(e=>this.capture(e,"visibility")).map(e=>e.id);break;case"minZoom":case"maxZoom":s=r.map(e=>e.id);for(const e of r)this.capture(e,"minzoom"),this.capture(e,"maxzoom");break;case"paintLiteral":s=r.map(e=>e.id);for(const e of r)this.capture(e,t.property);break;case"zoomOffset":s=r.filter(e=>Mn(Qn(e),0).patched).map(e=>e.id)}return{mechanism:t,layerIds:s,shadeLayerIds:o}}capture(e,t){const i=el(e,t);return void 0!==i&&(this.originalValues.set(Gn(e.id,t),i),!0)}originalValueOf(e,t){return this.originalValues.get(Gn(e,t))}resolveMapColor(e,t){const i=Kn(e),r=Za[e],s=[];for(const l of r.targets)for(const e of t.filter(e=>ar(l.layers,e,this.styleSources)))for(const t of l.properties){if(!this.capture(e,t))continue;const r={knobId:i,layerId:e.id,property:t,owns:Yn(l)};s.push(r);const o=Gn(e.id,t);this.mapColorTargetsByKey.set(o,[...this.mapColorTargetsByKey.get(o)??[],r])}this.mapColorTargetsByKnob.set(i,s);const{anchor:o}=r,a=t.find(e=>ar(o.layers,e,this.styleSources)&&void 0!==el(e,o.property)),n=a&&Fn(el(a,o.property),Yn({roadClass:o.roadClass}));return n&&this.mapColorAnchors.set(i,n),n?[...new Set(s.map(e=>e.layerId))]:[]}refreshKnob(e,t){const i=this.resolved.get(e);if(i&&this.tomtomMap.mapReady)for(const r of i.mechanisms)this.refreshMechanism(e,r,t)}refreshMechanism(e,{mechanism:t,layerIds:i,shadeLayerIds:r},s){switch(t.type){case"color":this.refreshColor(t.property,i,r,s[e]);break;case"projection":this.refreshProjection(s);break;case"sky":this.refreshSky(s);break;case"space":this.refreshSpace(s);break;case"mapColor":for(const{layerId:t,property:i}of this.mapColorTargetsByKnob.get(e)??[])this.refreshMapColorProperty(t,i,s);break;default:for(const r of i)this.refreshLayer(t,r,s[e],s)}}refreshLayer(e,t,i,r){switch(e.type){case"scale":this.refreshScaledProperty(t,e.property,r);break;case"visibility":this.refreshVisibility(t,i);break;case"minZoom":case"maxZoom":this.refreshZoomBound(t,Pn[e.type],i);break;case"paintLiteral":this.setProperty(t,e.property,i??this.originalValueOf(t,e.property));break;case"zoomOffset":this.refreshZoomOffset(t,i)}}refreshSpace(e){const t=this.mapLibreMap.getContainer();this.originalSpaceColor??=Jn(t),t.style.backgroundColor=e["view.spaceColor"]??this.defaultSpaceColor()}defaultSpaceColor(){return this.originalSpaceColor||Vn[this.tomtomMap.styleLightDarkTheme]}refreshMapColorProperty(e,t,i){const r=this.originalValueOf(e,t),s=[];for(const{knobId:o,owns:a}of this.mapColorTargetsByKey.get(Gn(e,t))??[]){const e=i[o],t=this.mapColorAnchors.get(o);"string"==typeof e&&t&&s.push({anchorColor:t,newColor:e,owns:a})}this.setProperty(e,t,s.length?((e,t)=>{const i=[...t].reverse();return Dn(e,(e,t)=>{for(const{anchorColor:r,newColor:s,owns:o}of i){if(o&&!o(t))continue;const i=kn(r,e);if(i)return ge(s,i)??e}return e})})(r,s):r)}refreshProjection(e){const t=e["view.projection"];this.mapLibreMap.setProjection({type:t??this.mapLevelState.projection})}refreshSky(e){const t=this.mapLevelState.sky,i=e["view.sky"]??this.defaultOf("view.sky"),r=Bn[this.tomtomMap.styleLightDarkTheme],s=i?{...r,...t,"sky-color":e["view.skyColor"]??t?.["sky-color"]??r["sky-color"],"horizon-color":e["view.horizonColor"]??t?.["horizon-color"]??r["horizon-color"]}:jn;this.mapLibreMap.setSky(s,{validate:!1})}refreshVisibility(e,t){void 0!==t?this.setProperty(e,"visibility",t?"visible":"none"):this.setProperty(e,"visibility",this.originalValueOf(e,"visibility"))}refreshZoomBound(e,t,i){if(!this.mapLibreMap.getLayer(e))return;const r={minzoom:this.styleZoomBound(e,"minzoom"),maxzoom:this.styleZoomBound(e,"maxzoom")};r[t]=i??r[t],this.mapLibreMap.setLayerZoomRange(e,r.minzoom,r.maxzoom)}styleZoomBound(e,t){return this.originalValueOf(e,t)??Wn[t]}refreshZoomOffset(e,t){this.filterComposer.setTransform(e,"styling.zoomShift",void 0===t?void 0:e=>Mn(e,t).filter)}refreshScaledProperty(e,t,i){const r=this.originalValueOf(e,t),s=(this.scaleKnobsByTarget.get(Gn(e,t))??[]).reduce((e,t)=>e*(i[t]??1),1);if(1===s)return void this.setProperty(e,t,r);const o=wn(r,s);void 0!==o?this.setProperty(e,t,o):this.warnOnce(`scale:${e}:${t}`,`cannot scale '${t}' of layer '${e}': the style gives it a value this knob cannot scale (a non-numeric value, or an expression holding a nested zoom term); leaving it as the style defines it.`)}refreshColor(e,t,i,r){for(const o of t)this.setProperty(o,e,r??this.originalValueOf(o,e));const s=t.map(t=>this.originalValueOf(t,e)).find(fe);for(const o of i){const t=this.originalValueOf(o,e);let i=t;if(void 0!==r){const e=fe(t)&&s&&me(s,t);i=(e&&ge(r,e))??r}this.setProperty(o,e,i)}}setProperty(e,t,i){if(!this.mapLibreMap.getLayer(e))return;const r=this.mapLibreMap;Un.has(t)?r.setLayoutProperty(e,t,i,{validate:!1}):Hn.has(t)&&r.setPaintProperty(e,t,i,{validate:!1})}describeKnob(e){const t=this.resolved.get(e),i=t?.definition??_n[e],r=t?.targets??0;return mt(e,i.kind,i.description,this.defaultOf(e),this.config?.[e],{...i.range&&{range:i.range},...i.options&&{options:i.options},available:r>0,appliesTo:i.appliesTo})}defaultOf(e){const t=this.resolved.get(e);if(!t)return;const{definition:i,mechanisms:r}=t;if("factor"===i.kind)return 1;const[s]=r,[o]=s?.layerIds??[];if(void 0!==o){if("mapColor"===s.mechanism.type)return this.mapColorAnchors.get(e);if(!("layers"in s.mechanism))return this.mapLevelDefaultOf(e);switch(s.mechanism.type){case"visibility":return"none"!==this.originalValueOf(o,"visibility");case"color":{const e=this.originalValueOf(o,s.mechanism.property);return fe(e)?e:void 0}case"minZoom":case"maxZoom":return this.styleZoomBound(o,Pn[s.mechanism.type]);case"paintLiteral":{const e=this.originalValueOf(o,s.mechanism.property);return"string"==typeof e||"number"==typeof e?e:void 0}case"zoomOffset":return 0;default:return}}}mapLevelDefaultOf(e){const{projection:t,sky:i}=this.mapLevelState;switch(e){case"view.projection":return"string"==typeof t?t:void 0;case"view.sky":return void 0!==i&&0!==i["atmosphere-blend"]&&"transparent"!==i["sky-color"];case"view.skyColor":return fe(i?.["sky-color"])?i["sky-color"]:Bn[this.tomtomMap.styleLightDarkTheme]["sky-color"];case"view.horizonColor":return fe(i?.["horizon-color"])?i["horizon-color"]:Bn[this.tomtomMap.styleLightDarkTheme]["horizon-color"];case"view.spaceColor":return this.defaultSpaceColor();default:return}}assertKnob(e){if(!(e in _n))throw new Error(`Unknown styling knob '${e}'. Call describe() for the catalogue of knob ids.`)}validate(e,t){const{kind:i,range:r,options:s}=_n[e];switch(i){case"toggle":if("boolean"!=typeof t)throw new RangeError(`Knob '${e}' expects true or false; got ${qn(t)}.`);break;case"enum":if("string"!=typeof t||!s?.includes(t))throw new RangeError(`Knob '${e}' expects one of ${s?.join(", ")}; got ${qn(t)}.`);break;case"color":if(!fe(t))throw new RangeError(`Knob '${e}' expects a CSS colour (#rrggbb, hsl(), rgb() or a named colour); got ${qn(t)}.`);break;default:if("number"!=typeof t||!Number.isFinite(t))throw new RangeError(`Knob '${e}' expects a number; got ${qn(t)}.`);if(r&&(t<r.min||t>r.max))throw new RangeError(`Knob '${e}' expects a number between ${r.min} and ${r.max}; got ${t}.`)}}warnOnce(e,t){this.warned.has(e)||(this.warned.add(e),console.warn(`[StylingModule] ${t}`))}},Kn=e=>`colors.${e}`,Yn=e=>"major"===e.roadClass?e=>"major"===e:"minor"===e.roadClass?e=>"major"!==e:()=>!0,qn=e=>"string"==typeof e?`'${e}'`:String(e),Zn=e=>Object.keys(e??{}).filter(e=>e in _n),Xn=e=>Object.fromEntries(Object.entries(e??{}).filter(([,e])=>void 0!==e)),Jn=e=>{const t=getComputedStyle(e).backgroundColor;return zn.has(t)?"":t},Qn=e=>"filter"in e?e.filter:void 0,el=(e,t)=>{const i="layout"in e?e.layout:void 0,r="paint"in e?e.paint:void 0;switch(t){case"text-size":return"symbol"===e.type&&void 0!==i?.["text-field"]?i["text-size"]??Wn["text-size"]:void 0;case"icon-size":return"symbol"===e.type&&void 0!==i?.["icon-image"]?i["icon-size"]??Wn["icon-size"]:void 0;case"line-width":return"line"===e.type?r?.["line-width"]??Wn["line-width"]:void 0;case"visibility":return i?.visibility??Wn.visibility;case"minzoom":return e.minzoom;case"maxzoom":return e.maxzoom;default:return tl(e,t,r)}},tl=(e,t,i)=>i?.[t]??("hillshade"===e.type&&(e=>e in Wn)(t)?Wn[t]:void 0),il=["factor","number","toggle","color","enum"],rl=["any-style","tomtom-styles"],sl=class{get styleLightDarkTheme(){return this._styleLightDarkTheme}constructor(e){var t;this.mapReady=!1,this.styleChangeHandlers=[],this.styleRequestSequence=0,this.setStyle=(e,t={})=>{const i={resetState:t.resetState??!1};this.mapReady=!1;const r=++this.styleRequestSequence,s=i.resetState?e:((e,t)=>t&&"object"==typeof t&&"standard"===t.type&&t.include&&("string"==typeof e||"standard"===e.type&&!e.include)?{type:"standard",id:"string"==typeof e?e:e.id,include:t.include}:e)(e,this._params.style);return this._params={...this._params,style:s},this._styleLightDarkTheme=Ge(s),this.applyStyle(i,r)},this.getStyle=()=>this._params.style,this._params=S(e),void 0===this._params.style&&(this._params={...this._params,style:Ur}),this._styleLightDarkTheme=Ge(this._params.style),this.ensureMapLibreCSSLoaded(),F(4),this.styleGivenToMapLibre=Vr(this._params),this.mapLibreMap=new M({validateStyle:!1,maxTileCacheZoomLevels:22,cancelPendingTileRequestsWhileZooming:!1,...(t=this._params).mapLibre,style:Vr(t),attributionControl:{compact:!1},transformRequest:Me(t)}),this.mapLibreMap.once("style.load",()=>{this.handleStyleData()}),this._eventsProxy=new ft(this.mapLibreMap,this._params?.events),this.loadRTLTextPlugin()}loadRTLTextPlugin(){setTimeout(()=>{["deferred","loaded"].includes(N())||D("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js",!0).catch(e=>console.error("Something went wrong when setting RTL plugin",e))})}ensureMapLibreCSSLoaded(){if("undefined"==typeof document)return;if(Array.from(document.querySelectorAll('link[rel="stylesheet"], style')).some(e=>e.textContent?.includes(".maplibregl-map")))return;const e=document.createElement("link");e.rel="stylesheet",e.href=`https://unpkg.com/maplibre-gl@${x()}/dist/maplibre-gl.css`,document.head.appendChild(e)}async applyStyle(e,t){if(await this.notifyHandlers("onStyleAboutToChange",e),this.isSuperseded(t))return;if(await(this.styleLoadInFlight?.catch(()=>{})),this.isSuperseded(t))return;const i=this.loadIntoMapLibre();this.styleLoadInFlight=i;try{await i}finally{this.styleLoadInFlight===i&&(this.styleLoadInFlight=void 0)}if(!this.isSuperseded(t))try{await this.handleStyleData(e)}catch(r){console.error(r)}}async loadIntoMapLibre(){const e=Vr(this._params);if(t(e,this.styleGivenToMapLibre))return;const i=this.styleGivenToMapLibre;this.styleGivenToMapLibre=e,await new Promise((t,r)=>{const s=()=>{this.mapLibreMap.off("error",o),t()},o=e=>{"sourceId"in e||(this.mapLibreMap.off("style.load",s),this.mapLibreMap.off("error",o),this.styleGivenToMapLibre=i,r(e.error instanceof Error?e.error:new Error(e.error.message)))};this.mapLibreMap.once("style.load",s),this.mapLibreMap.on("error",o),this.mapLibreMap.setStyle(e,{validate:!1})})}isSuperseded(e){return e!==this.styleRequestSequence}async notifyHandlers(e,t){const i=[...this.styleChangeHandlers].sort((e,t)=>(e.priority??0)-(t.priority??0));for(const s of i)try{await(s[e]?.(t))}catch(r){console.error(r)}}_setTomTomUserAgent(e){this._params={...this._params,"tomtom-user-agent":e},this.mapLibreMap.setTransformRequest(Me(this._params))}_setLanguage(e){this._params={...this._params,language:e};const t=e?.includes("-")?e.split("-")[0]:e;this.mapLibreMap.getStyle().layers.forEach(e=>{if("symbol"===e.type&&(e=>{const t=e.layout?.["text-field"]??"";return!!t&&("{name}"===t||2===t.length&&"name"===t[1]||3===t.length&&Array.isArray(t[1])&&"string"==typeof t[1][1]&&t[1][1].includes("name_")&&Array.isArray(t[2])&&t[2].includes("name"))})(e)){const i=t?["coalesce",["get",`name_${t}`],["get","name"]]:["get","name"];this.mapLibreMap.setLayoutProperty(e.id,"text-field",i,{validate:!1})}})}setLanguage(e){this.mapReady?this._setLanguage(e):this.mapLibreMap.once("styledata",()=>this.setLanguage(e))}getBBox(){return this.mapLibreMap.getBounds().toArray().flat()}async handleStyleData(e){for(const t of st(this.mapLibreMap,[Mt,Nt,wt]))this.mapLibreMap.setLayoutProperty(t.id,"visibility","none",{validate:!1});Ve(this._params.style)&&!Be(this._params.style)&&(this._styleLightDarkTheme=(e=>{const t=e?.layers?.find(e=>"background"===e?.type);if(!t)return;const i=ze(t.paint?.["background-color"]),r=void 0===i?void 0:_e(i);return void 0!==r?r<.35?"dark":"light":void 0})(this.mapLibreMap.getStyle())??this._styleLightDarkTheme),(async(e,t,i)=>{if(i.getSprite().some(e=>"pinCategories"===e.id))return;const r=new URLSearchParams;e.apiKey&&r.set("key",e.apiKey),r.set("poi",`poi_${t}`),r.set("apiVersion","1"),r.set("apiChannel","preview"),i.addSprite(Ae,`${e.commonBaseURL}/maps/orbis/assets/sprites/2.*/sprite?${r}`,{validate:!1})})(this._params,this._styleLightDarkTheme,this.mapLibreMap),this._params.language&&this._setLanguage(this._params.language),this.mapReady=!0,e&&await this.notifyHandlers("onStyleChanged",e)}addStyleChangeHandler(e){this.styleChangeHandlers.push(e);let t=!1;return()=>{if(t)return;t=!0;const i=this.styleChangeHandlers.indexOf(e);-1!==i&&this.styleChangeHandlers.splice(i,1)}}},ol=class e extends Ye{static async get(t,i){return await Ce(t),await Ue(t,wt,"hillshade"),Dt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(wt);if(!t)throw Ie(`init ${e.name} with source ID ${wt}`);const i=this.mapLibreMap.getTerrain();return"hillshade-terrain"!==i?.source&&(this.mapTerrain=i),{hillshade:new ot(this.mapLibreMap,t)}}_applyConfig(e){return this.showHillshade(e?.hillshade??!1),this.showElevation(e?.elevation,e?.elevationExaggeration??1),e}setHillshadeVisible(e){this.showHillshade(e),this.storeConfig({hillshade:e})}isHillshadeVisible(){return this.sourcesWithLayers.hillshade.isAnyLayerVisible()}setElevationEnabled(e){this.showElevation(e,this.config?.elevationExaggeration??1),this.storeConfig({elevation:e})}isElevationEnabled(){return null!==this.mapLibreMap.getTerrain()}setElevationExaggeration(e){this.showElevation(this.config?.elevation,e),this.storeConfig({elevationExaggeration:e})}get events(){return this.lifecycleEvents()}showHillshade(e){this.tomtomMap.mapReady&&this.sourcesWithLayers.hillshade.setLayersVisible(e)}showElevation(e,t){this.tomtomMap.mapReady&&(void 0===e?this.overridesMapTerrain&&this.mapLibreMap.setTerrain(this.mapTerrain):e?(new it(Ct,this.sourcesWithLayers.hillshade.source.spec).ensureAddedToMap(this.mapLibreMap),this.mapLibreMap.setTerrain({source:Ct,exaggeration:t})):this.mapLibreMap.setTerrain(null),this.overridesMapTerrain=void 0!==e)}storeConfig(e){this.config={...this.config,...e},this.emitConfigChange()}},al="#2dc653",nl="#f5a623",ll="#e03030",cl=()=>[{value:0,color:al},{value:50,color:nl},{value:100,color:ll}],hl=()=>[{value:0,color:ll},{value:50,color:nl},{value:100,color:al}],ul={visible:!0,displayMode:"hexgrid-3d",activeMetric:"congestionLevel",metricConfig:{congestionLevel:{color:{valueType:"raw",stops:cl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},speed:{color:{valueType:"relativeToPredefinedRangePCT",stops:hl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},travelTime:{color:{valueType:"relativeToPredefinedRangePCT",stops:cl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},freeFlowSpeed:{color:{valueType:"relativeToPredefinedRangePCT",stops:hl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},networkLength:{color:{valueType:"relativeToActualRangePCT",stops:cl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"currentRange"}}},regionPolygon:{fillOpacity:0,outlineOpacity:.5,outlineWidth:2,inverted:!1}},dl="#ffffff",pl=e=>"dark"===e?"#FFFFFF":"#000000",yl={trafficLight:[al,nl,ll],heat:["#2196F3","#FF9800","#F44336"],monochrome:["#e0e0e0","#888888","#1a1a1a"],viridis:["#fde725","#35b779","#31688e","#440154"],plasma:["#f0f921","#ed7953","#9c179e","#0d0887"]},fl={congestionLevel:{min:0,max:100},speed:{min:0,max:120},travelTime:{min:0,max:20},freeFlowSpeed:{min:0,max:120},networkLength:{min:0,max:5e3}},ml=e=>"speed"===e||"freeFlowSpeed"===e,gl=e=>e?.activeMetric??ul.activeMetric,_l=e=>{return"string"==typeof e?(t=yl[e]).map((e,i)=>({value:1===t.length?0:i/(t.length-1),color:e})):e.stops;var t},bl=e=>{if("top"!==e)return e?Rt[e]:Rt.lowestLabel},Ll=e=>{if("top"!==e)return e?Rt[e]:Rt.lowestPlaceLabel},Sl=(e,t,i)=>{const r=t??ul.metricConfig[e].color??"trafficLight",s=_l(r);let o;if("string"==typeof r){const{min:t,max:i}=fl[e],r=ml(e)?[...s].reverse().map(e=>e.color):s.map(e=>e.color);o=s.map(({value:e},s)=>[t+e*(i-t),r[s]])}else if("relativeToPredefinedRangePCT"===r.valueType){const{min:t,max:i}=fl[e];o=s.map(({value:e,color:r})=>[t+e/100*(i-t),r])}else if("relativeToActualRangePCT"===r.valueType){const{min:t,max:r}=i??fl[e];o=s.map(({value:e,color:i})=>[t+e/100*(r-t),i])}else o=s.map(({value:e,color:t})=>[e,t]);return["interpolate",["linear"],["get",e],...o.flatMap(([e,t])=>[e,t])]},Il=(e,t)=>{const i=t??ul.metricConfig[e].color??"trafficLight",r=_l(i);let s;if("string"==typeof i){const t=ml(e)?[...r].reverse().map(e=>e.color):r.map(e=>e.color);s=r.flatMap(({value:e},i)=>[.3+.7*e,t[i]])}else if("relativeToPredefinedRangePCT"===i.valueType||"relativeToActualRangePCT"===i.valueType)s=r.flatMap(({value:e,color:t})=>[.3+e/100*.7,t]);else{const e=Math.min(...r.map(e=>e.value)),t=Math.max(...r.map(e=>e.value))-e||1;s=r.flatMap(({value:i,color:r})=>[.3+(i-e)/t*.7,r])}return["interpolate",["linear"],["heatmap-density"],0,"rgba(0,0,0,0)",...s]},Al=(e,t,i)=>{const r=ul.metricConfig[e].height,s=t?.minHeightMeters??r.minHeightMeters??0;if("raw"===t?.scaleMode){const i=t.scaleFactor??1;if("speed"===e){const{max:t}=fl[e];return["max",s,["*",["-",t,["coalesce",["get","speed"],0]],i]]}return["max",s,["*",["coalesce",["get",e],0],i]]}const o=t?.maxHeightMeters??r.maxHeightMeters??1e3,{min:a,max:n}="currentRange"===(t?.scaleMode??r.scaleMode)?i??fl[e]:fl[e],l=n-a||1;return"speed"===e?["max",s,["*",["/",["-",n,["coalesce",["get","speed"],0]],l],o]]:["max",s,["*",["/",["-",["coalesce",["get",e],0],a],l],o]]},El=(e,t,i)=>{const r=gl(t),s=t?.metricConfig?.[r],{min:o,max:a}=i??fl[r];return{id:e,type:"heatmap",beforeID:bl(t?.beforeLayerConfig?.heatmap),paint:{"heatmap-weight":["interpolate",["linear"],["get",r],o,0,a,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],10,.5,14,2,16,4],"heatmap-color":Il(r,s?.color),"heatmap-radius":["interpolate",["linear"],["zoom"],4,1,8,3,12,35,14,80,16,100],"heatmap-opacity":["interpolate",["linear"],["zoom"],4,.8,13,.8,17,0]}}},vl=(e,t,i)=>{const r=gl(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:bl(t?.beforeLayerConfig?.hexgrid?.flat2D),paint:{"fill-color":Sl(r,s?.color,i),"fill-opacity":.6}}},Rl=(e,t,i)=>{const r=gl(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:Ll(t?.beforeLayerConfig?.hexgrid?.extrusion3D),paint:{"fill-extrusion-color":Sl(r,s?.color,i),"fill-extrusion-height":Al(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},Tl=(e,t,i)=>{const r=gl(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:bl(t?.beforeLayerConfig?.square?.flat2D),paint:{"fill-color":Sl(r,s?.color,i),"fill-opacity":.6}}},wl=(e,t,i)=>{const r=gl(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:Ll(t?.beforeLayerConfig?.square?.extrusion3D),paint:{"fill-extrusion-color":Sl(r,s?.color,i),"fill-extrusion-height":Al(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},Cl=e=>({...ul.regionPolygon,...e}),Ol=(e,t,i)=>{const{color:r,fillOpacity:s}=Cl(t?.regionPolygon);return{id:e,type:"fill",beforeID:bl(),paint:{"fill-color":r??pl(i),"fill-opacity":s}}},Ml=(e,t,i)=>{const{color:r,outlineOpacity:s,outlineWidth:o}=Cl(t?.regionPolygon);return{id:e,type:"line",beforeID:bl(),paint:{"line-color":r??pl(i),"line-opacity":s,"line-width":o}}},Nl=(e,t)=>({id:e,type:"line",beforeID:t,filter:["has","eventState"],paint:{"line-color":dl,"line-width":["case",Si,3,2],"line-opacity":["case",Si,1,.8]}}),xl=e=>({...e,filter:["has","eventState"],paint:{...e.paint,"fill-extrusion-color":["case",Si,dl,dl],"fill-extrusion-height":["+",e.paint?.["fill-extrusion-height"],.5],"fill-extrusion-opacity":.6}}),Dl=(e,t,i)=>xl(Rl(e,t,i)),Fl=(e,t,i)=>xl(wl(e,t,i)),kl=(e,t,i)=>((e,t,i)=>{const r=[];for(let s=0;s<e.length;s++){const o=e[s];if(!o)continue;const{congestionSum:a,speedSum:n,freeFlowSum:l,travelTimeSum:c,networkLengthSum:h,count:u}=o,d=`${i}-${s}`;r.push({type:"Feature",id:d,geometry:t.features[s].geometry,properties:{id:d,congestionLevel:Math.round(a/u),speed:Math.round(n/u),freeFlowSpeed:Math.round(l/u),travelTime:Math.round(c/u*10)/10,networkLength:Math.round(h/u)}})}return r})(((e,t)=>{const i=[];for(const r of e)for(let e=0;e<t.features.length;e++)if(v(r.tileCentre,t.features[e])){let t=i[e];void 0===t&&(t={congestionSum:0,speedSum:0,freeFlowSum:0,travelTimeSum:0,networkLengthSum:0,count:0},i[e]=t),t.congestionSum+=r.congestionLevel??0,t.speedSum+=r.speed??0,t.freeFlowSum+=r.freeFlowSpeed??0,t.travelTimeSum+=r.travelTime??0,t.networkLengthSum+=r.networkLength??0,t.count++;break}return i})(e,t),t,i),Pl=.005,Ul=(e,t,i,r)=>{const s=[];for(let o=0;o<e.features.length;o++){const a=e.features[o],n=a.properties?.tiledData?.tiles??[];if(0===n.length)continue;const l=d(a);if(!l)continue;const c=i([l[0]-Pl,l[1]-Pl,l[2]+Pl,l[3]+Pl],t);s.push(...kl(n,c,`${r}-${o}`))}return{type:"FeatureCollection",features:s}},Hl=class e extends Ke{static async create(t,i){return await Ce(t),new e(t,i??{})}constructor(e,t){super(e,t),this.lastAnalytics=null,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=this.instanceIndex,r=`area-analytics-heatmap-${i}`,s=`area-analytics-hexgrid-${i}`,o=`area-analytics-square-${i}`,a=`area-analytics-region-${i}`,n=`${r}-layer`,l=`${s}-fill`,c=`${s}-extrusion`,h=`${s}-outline`,u=`${s}-extrusion-highlight`,d=`${o}-fill`,p=`${o}-extrusion`,y=`${o}-outline`,f=`${o}-extrusion-highlight`,m=`${a}-fill`,g=`${a}-line`,_=this.lightDark;this.heatmapLayerSpec=El(n,e),this.hexFillLayerSpec=vl(l,e),this.hexExtrusionLayerSpec=Rl(c,e),this.squareFillLayerSpec=Tl(d,e),this.squareExtrusionLayerSpec=wl(p,e),this.regionFillLayerSpec=Ol(m,e,_),this.regionLineLayerSpec=Ml(g,e,_),this.hexOutlineLayerSpec=((e,t)=>Nl(e,bl(t?.beforeLayerConfig?.hexgrid?.flat2D)))(h,e),this.hexExtrusionHighlightLayerSpec=Dl(u,e),this.squareOutlineLayerSpec=((e,t)=>Nl(e,bl(t?.beforeLayerConfig?.square?.flat2D)))(y,e),this.squareExtrusionHighlightLayerSpec=Fl(f,e);const b={heatmap:new lt(this.mapLibreMap,r,[this.heatmapLayerSpec]),hexgrid:new lt(this.mapLibreMap,s,[this.hexFillLayerSpec,this.hexExtrusionLayerSpec]),square:new lt(this.mapLibreMap,o,[this.squareFillLayerSpec,this.squareExtrusionLayerSpec]),region:new lt(this.mapLibreMap,a,[this.regionFillLayerSpec,this.regionLineLayerSpec])};return this.addHighlightLayersToMap(s,o),b}_applyConfig(e){const t=this.config,i=void 0===e?void 0:t,r=e??{},s=r.metricConfig&&i?.metricConfig?{...i.metricConfig,...r.metricConfig}:r.metricConfig??i?.metricConfig,o=Object.keys(ul.metricConfig),a=Object.fromEntries(o.map(e=>[e,s?.[e]??ul.metricConfig[e]])),n={activeMetric:ul.activeMetric,displayMode:ul.displayMode,...i,...r,metricConfig:a};return this.config=n,this.applyLayerConfig(n),(n.regionPolygon||t?.regionPolygon)&&this.applyRegionConfig(n),n.beforeLayerConfig?this._moveBeforeLayer(n.beforeLayerConfig,!1):t?.beforeLayerConfig&&this.moveLayersToSpecPositions(),this.applyModeVisibility(),n}moveLayersToSpecPositions(){for(const e of[this.heatmapLayerSpec,this.hexFillLayerSpec,this.hexExtrusionLayerSpec,this.squareFillLayerSpec,this.squareExtrusionLayerSpec])Fe(this.mapLibreMap,e.id,e.beforeID)}discardShownData(){this.lastAnalytics=null}restoreDataAndConfigImpl(){const e=this.lastAnalytics;this.initSourcesWithLayers(this.config,!0),e?(!1===this.config?.visible&&this.setVisible(!1),this.show(e)):this.config&&this._applyConfig(this.config)}async show(e){await this.waitUntilModuleReady(),this.lastAnalytics=e,this.sourcesWithLayers.heatmap.show((e=>({type:"FeatureCollection",features:e.features.flatMap(e=>e.properties?.tiledData?.tiles??[]).map((e,t)=>{const[i,r]=e.tileCentre,s=`tile-${t}-${i}-${r}`;return{type:"Feature",id:s,geometry:{type:"Point",coordinates:[i,r]},properties:{id:s,speed:e.speed??0,freeFlowSpeed:e.freeFlowSpeed??0,congestionLevel:e.congestionLevel??0,travelTime:e.travelTime??0,networkLength:e.networkLength??0}}})}))(e),{automaticVisibility:!1}),this.sourcesWithLayers.hexgrid.show(((e,t=.25)=>Ul(e,t,(e,t)=>w(e,t,{units:"kilometers"}),"hex"))(e),{automaticVisibility:!1}),this.sourcesWithLayers.square.show(((e,t=.5)=>Ul(e,t,(e,t)=>O(e,t,{units:"kilometers"}),"square"))(e),{automaticVisibility:!1});const t=this.config?.regionPolygon?.inverted??ul.regionPolygon.inverted;this.sourcesWithLayers.region.show(this.buildRegionFC(e.features,t)),this.applyLayerConfig(this.config),this.applyModeVisibility();for(const i of this.shownFeaturesHandlers)i(e)}async clear(){await this.waitUntilModuleReady(),this.lastAnalytics=null,this.sourcesWithLayers.heatmap.clear(),this.sourcesWithLayers.hexgrid.clear(),this.sourcesWithLayers.square.clear(),this.sourcesWithLayers.region.clear()}setMode(e){e!==this.mode&&(this.config={...this.config,displayMode:e},this.applyModeVisibility(),this.emitConfigChange())}setMetric(e){e!==this.activeMetric&&(this.config={...this.config,activeMetric:e},this.applyLayerConfig(this.config),this.emitConfigChange())}setColor(e,t){const i=Object.keys(ul.metricConfig),r=t??i,s={...this.config?.metricConfig};if(void 0===e)for(const o of r){const{color:e,...t}=s[o]??{};s[o]=t}else if("string"==typeof e){const t=(e=>{const t=_l(e),i=e=>{const{min:i,max:r}=fl[e],s=ml(e)?[...t].reverse().map(e=>e.color):t.map(e=>e.color);return{valueType:"raw",stops:t.map(({value:e},t)=>({value:i+e*(r-i),color:s[t]}))}};return{congestionLevel:{color:i("congestionLevel")},speed:{color:i("speed")},travelTime:{color:i("travelTime")},freeFlowSpeed:{color:i("freeFlowSpeed")},networkLength:{color:i("networkLength")}}})(e);for(const e of r)s[e]={...s[e],...t[e]}}else for(const o of r)s[o]={...s[o],color:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}setHeight(e,t){const i=Object.keys(ul.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const o of r)s[o]={...s[o],height:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}filter(e,t){const i=Object.keys(ul.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const o of r)s[o]={...s[o],filters:e};this.config={...this.config,metricConfig:s},this.applyFiltersToLayers(),this.emitConfigChange()}clearFilter(e){this.filter(void 0,e)}setVisible(e){this.config={...this.config,visible:e},this.applyModeVisibility(),this.emitConfigChange()}isVisible(){return this.sourcesWithLayers.heatmap.isAnyLayerVisible()||this.sourcesWithLayers.hexgrid.isAnyLayerVisible()||this.sourcesWithLayers.square.isAnyLayerVisible()}getShown(){return{heatmap:this.sourcesWithLayers.heatmap.shownFeatures,hexgrid:this.sourcesWithLayers.hexgrid.shownFeatures,square:this.sourcesWithLayers.square.shownFeatures}}moveBeforeLayer(e){this._moveBeforeLayer(e)}_moveBeforeLayer(e,t=!0){const i=e=>"top"===e?void 0:Rt[e];void 0!==e.heatmap&&Fe(this.mapLibreMap,this.heatmapLayerSpec.id,i(e.heatmap)),void 0!==e.hexgrid?.flat2D&&Fe(this.mapLibreMap,this.hexFillLayerSpec.id,i(e.hexgrid.flat2D)),void 0!==e.hexgrid?.extrusion3D&&Fe(this.mapLibreMap,this.hexExtrusionLayerSpec.id,i(e.hexgrid.extrusion3D)),void 0!==e.square?.flat2D&&Fe(this.mapLibreMap,this.squareFillLayerSpec.id,i(e.square.flat2D)),void 0!==e.square?.extrusion3D&&Fe(this.mapLibreMap,this.squareExtrusionLayerSpec.id,i(e.square.extrusion3D)),t&&(this.config={...this.config,beforeLayerConfig:e})}get events(){return this.moduleEventsWithShown(["hexgrid","square","heatmap"],this.shownFeaturesHandlers)}get mode(){return this.config?.displayMode??ul.displayMode}get activeMetric(){return gl(this.config)}get lightDark(){return this.tomtomMap.styleLightDarkTheme}applyModeVisibility(){if(!1===this.config?.visible)return void this.hideAllDataLayers();const e=this.mode,t=this.sourcesWithLayers.heatmap.shownFeatures.features.length>0,i=this.sourcesWithLayers.hexgrid.shownFeatures.features.length>0,r=this.sourcesWithLayers.square.shownFeatures.features.length>0,s=this.sourcesWithLayers.region.shownFeatures.features.length>0;this.sourcesWithLayers.heatmap.setLayersVisible("heatmap"===e&&t),this.sourcesWithLayers.hexgrid.setLayersVisible("hexgrid-3d"===e&&i,e=>e.id===this.hexExtrusionLayerSpec.id),this.sourcesWithLayers.hexgrid.setLayersVisible("hexgrid-2d"===e&&i,e=>e.id===this.hexFillLayerSpec.id),this.sourcesWithLayers.square.setLayersVisible("square-3d"===e&&r,e=>e.id===this.squareExtrusionLayerSpec.id),this.sourcesWithLayers.square.setLayersVisible("square-2d"===e&&r,e=>e.id===this.squareFillLayerSpec.id),this.sourcesWithLayers.region.setLayersVisible(s),this.setHighlightLayerVisible(this.hexOutlineLayerSpec.id,"hexgrid-2d"===e&&i),this.setHighlightLayerVisible(this.hexExtrusionHighlightLayerSpec.id,"hexgrid-3d"===e&&i),this.setHighlightLayerVisible(this.squareOutlineLayerSpec.id,"square-2d"===e&&r),this.setHighlightLayerVisible(this.squareExtrusionHighlightLayerSpec.id,"square-3d"===e&&r)}hideAllDataLayers(){this.sourcesWithLayers.heatmap.setLayersVisible(!1),this.sourcesWithLayers.hexgrid.setLayersVisible(!1),this.sourcesWithLayers.square.setLayersVisible(!1),this.sourcesWithLayers.region.setLayersVisible(!1),this.setHighlightLayerVisible(this.hexOutlineLayerSpec.id,!1),this.setHighlightLayerVisible(this.hexExtrusionHighlightLayerSpec.id,!1),this.setHighlightLayerVisible(this.squareOutlineLayerSpec.id,!1),this.setHighlightLayerVisible(this.squareExtrusionHighlightLayerSpec.id,!1)}addHighlightLayersToMap(e,t){const i=(e,t)=>{this.mapLibreMap.getLayer(e.id)||this.mapLibreMap.addLayer({...e,source:t},De(this.mapLibreMap,e.beforeID)),this.mapLibreMap.setLayoutProperty(e.id,"visibility","none")};i(this.hexOutlineLayerSpec,e),i(this.hexExtrusionHighlightLayerSpec,e),i(this.squareOutlineLayerSpec,t),i(this.squareExtrusionHighlightLayerSpec,t)}setHighlightLayerVisible(e,t){this.mapLibreMap.getLayer(e)&&this.mapLibreMap.setLayoutProperty(e,"visibility",t?"visible":"none")}applyLayerConfig(e){const t=this.lastAnalytics?.properties.ranges?.[this.activeMetric],i=El(this.heatmapLayerSpec.id,e,t),r=vl(this.hexFillLayerSpec.id,e,t),s=Rl(this.hexExtrusionLayerSpec.id,e,t),o=Dl(this.hexExtrusionHighlightLayerSpec.id,e,t),a=Tl(this.squareFillLayerSpec.id,e,t),n=wl(this.squareExtrusionLayerSpec.id,e,t),l=Fl(this.squareExtrusionHighlightLayerSpec.id,e,t);Ne(i,this.heatmapLayerSpec,this.mapLibreMap),Ne(r,this.hexFillLayerSpec,this.mapLibreMap),Ne(s,this.hexExtrusionLayerSpec,this.mapLibreMap),Ne(o,this.hexExtrusionHighlightLayerSpec,this.mapLibreMap),Ne(a,this.squareFillLayerSpec,this.mapLibreMap),Ne(n,this.squareExtrusionLayerSpec,this.mapLibreMap),Ne(l,this.squareExtrusionHighlightLayerSpec,this.mapLibreMap),this.heatmapLayerSpec=i,this.hexFillLayerSpec=r,this.hexExtrusionLayerSpec=s,this.hexExtrusionHighlightLayerSpec=o,this.squareFillLayerSpec=a,this.squareExtrusionLayerSpec=n,this.squareExtrusionHighlightLayerSpec=l,this.applyFiltersToLayers()}applyRegionConfig(e){const t=this.lightDark,i=Ol(this.regionFillLayerSpec.id,e,t),r=Ml(this.regionLineLayerSpec.id,e,t);if(Ne(i,this.regionFillLayerSpec,this.mapLibreMap),Ne(r,this.regionLineLayerSpec,this.mapLibreMap),this.regionFillLayerSpec=i,this.regionLineLayerSpec=r,this.lastAnalytics){const t=e?.regionPolygon?.inverted??ul.regionPolygon.inverted;this.sourcesWithLayers.region.show(this.buildRegionFC(this.lastAnalytics.features,t))}}applyFiltersToLayers(){const e=this.activeMetric,t=this.config?.metricConfig?.[e]?.filters,i=[this.hexFillLayerSpec.id,this.hexExtrusionLayerSpec.id,this.squareFillLayerSpec.id,this.squareExtrusionLayerSpec.id];if(!t||void 0===t.min&&void 0===t.max){for(const e of i)this.mapLibreMap.setFilter(e,null);return}const r=[];void 0!==t.min&&r.push([">=",["get",e],t.min]),void 0!==t.max&&r.push(["<=",["get",e],t.max]);const s=1===r.length?r[0]:["any",...r];for(const o of i)this.mapLibreMap.setFilter(o,s)}buildRegionFC(e,t){return{type:"FeatureCollection",features:e.map((e,i)=>{const r=`traffic-area-analytics-region-${i}`,s=t?C(e).geometry:e.geometry;return{...e,id:r,geometry:s,properties:{id:r}}})}}},Wl=e=>e.length?1===e.length?e[0]:["all",...e]:null,Gl=(e,t)=>{e&&t.push(e)},Bl=(e,t,i)=>{e&&Gl(Z(t,e),i)},Vl=(e,t)=>{Bl(e.roadCategories,"road_category",t),Bl(e.roadSubCategories,"road_subcategory",t)},zl=e=>{const t=[];if(Vl(e,t),e.incidentCategories){const i=Z("icon_category_0",e.incidentCategories,A);Gl(i,t)}if(e.magnitudes){const i=Z("magnitude_of_delay",e.magnitudes,e=>b.indexOf(e));Gl(i,t)}return e.delays&&Gl((e=>{const t=[];if(e.mustHaveDelay&&e.minDelayMinutes){const i=60*e.minDelayMinutes;t.push([">=",["get","delay"],i])}else if(e.mustHaveDelay)t.push([">",["get","delay"],0]);else if(e.minDelayMinutes){const i=60*e.minDelayMinutes;t.push(["any",["!",["has","delay"]],["==",["get","delay"],0],[">=",["get","delay"],i]])}return Wl(t)})(e.delays),t),Wl(t)},jl=e=>{if(!e?.any?.length)return null;const t=e.any.map(zl).filter(e=>!i(e));return Y(t)},$l=e=>{const t=[];if(Vl(e,t),e.showRoadClosures){const i="only"===e.showRoadClosures?"==":"!=";t.push([i,["get","road_closure"],!0])}return Wl(t)},Kl=(e,t,i,r)=>{for(const s of t)i.setClause(s.id,r,e)},Yl="traffic.flow",ql=class e extends Ye{static async get(t,i){return await Ce(t),await Ue(t,Nt,"trafficFlow"),Dt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Nt);if(!t)throw Ie(`init ${e.name} with source ID ${Nt}`);return{trafficFlow:new ot(this.mapLibreMap,t)}}_applyConfig(e){return this._setVisible(e?.visible??!1,!1),this._filter(e?.filters,!1),e}getLayers(){return st(this.tomtomMap.mapLibreMap,[Nt])}filter(e){this._filter(e)}_filter(e,t=!0){if(this.tomtomMap.mapReady)if(e?.any?.length){const t=(e=>{if(!e?.any?.length)return null;const t=e.any.map($l).filter(e=>!i(e));return Y(t)})(e);t&&Kl(t,this.getLayers(),this.filterComposer,Yl)}else this.config?.filters?.any?.length&&Kl(void 0,this.getLayers(),this.filterComposer,Yl);t&&(this.config=o({...this.config,filters:e},i),this.emitConfigChange())}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficFlow.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}isVisible(){return this.sourcesWithLayers.trafficFlow.isAnyLayerVisible()}getShown(){return{trafficFlow:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.trafficFlow.sourceAndLayerIDs.layerIDs,validate:!1}).map(ie)}}get events(){return this.moduleEvents(["trafficFlow"],{mapping:ie})}},Zl="tt-traffic-incident-direction-chevron",Xl='<svg xmlns="http://www.w3.org/2000/svg" width="48" height="18" viewBox="0 0 48 18">\n<path d="M 18 4 L 30 9 L 18 14" fill="none" stroke="rgba(20, 30, 50, 0.5)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>\n<path d="M 18 4 L 30 9 L 18 14" fill="none" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>',Jl=["interpolate",["exponential",1.5],["zoom"],5,0,9,.96,13,2.1,19,10.8],Ql=["interpolate",["exponential",1.5],["zoom"],5,.75,9,1.96,13,3.6,19,13.8],ec=e=>["match",["get","magnitudeOfDelay"],"unknown",e.unknown,"minor",e.minor,"moderate",e.moderate,"major",e.major,"indefinite",e.indefinite,e.major],tc=["match",["get","magnitudeOfDelay"],"unknown","traffic-incidents-no_delay-pattern","indefinite","traffic-incidents-road_closed-pattern",""],ic=e=>"dark"===e?"#FFF":"#000",rc=["interpolate",["exponential",1.5],["zoom"],5,2.2,9,4.6,13,8.3,19,26],sc=["case",["==",["feature-state","focused"],!0],1,0],oc=(e,t)=>{if(null===t)return e;const[i,r,s,...o]=e;return[i,r,s,...o.map((e,i)=>i%2==1?["case",["==",["feature-state","focused"],!0],e*t,e]:e)]},ac=["in",["get","magnitudeOfDelay"],["literal",["minor","moderate","major"]]],nc=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],lc=(e,t,i,r)=>{const s=r?.widthScale??null,o=[];return null!==r&&o.push({id:`${e}-focus-halo`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":r.outlineColor,"line-width":rc,"line-blur":0,"line-opacity":sc},beforeID:t}),o.push({id:`${e}-outline`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":ec(i.outline),"line-width":oc(Ql,s)},beforeID:t},{id:`${e}-inner-solid`,type:"line",minzoom:6,filter:ac,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":ec(i.inner),"line-width":oc(Jl,s)},beforeID:t},{id:`${e}-inner-chevron`,type:"line",minzoom:12,filter:ac,layout:{"line-cap":"butt","line-join":"round"},paint:{"line-pattern":Zl,"line-width":oc(Jl,s)},beforeID:t},{id:`${e}-inner-pattern`,type:"line",minzoom:6,filter:nc,layout:{"line-cap":"round","line-join":"round"},paint:{"line-pattern":tc,"line-width":oc(Jl,s)},beforeID:t}),o},cc=["step",["zoom"],.7,14,.8,16,.9,18,1],hc=["step",["zoom"],12.6,14,14.4,16,16.2,18,18],uc=["match",["get","category"],"other","traffic-incidents-info","accident","traffic-incidents-accident","fog","traffic-incidents-fog","danger","traffic-incidents-roadworks","rain","traffic-incidents-rain","frost","traffic-incidents-frost","lane-closed","traffic-incidents-lane_closed","roadworks","traffic-incidents-roadworks","wind","traffic-incidents-wind","flooding","traffic-incidents-flooding","broken-down-vehicle","traffic-incidents-broken_down_vehicle",""],dc=["all",["!=",["get","magnitudeOfDelay"],"indefinite"],["any",["!",["has","delayInSeconds"]],["step",["zoom"],[">",["get","delayInSeconds"],900],14,[">",["get","delayInSeconds"],600],15,[">",["get","delayInSeconds"],300],16,!0]]],pc=["all",["==",["get","category"],"jam"],["!=",["get","magnitudeOfDelay"],"unknown"],["!=",["get","magnitudeOfDelay"],"indefinite"],["step",["zoom"],[">",["get","delayInSeconds"],900],13,[">",["get","delayInSeconds"],600],14,[">",["get","delayInSeconds"],300],15,!0]],yc=["==",["get","magnitudeOfDelay"],"indefinite"],fc=["concat","traffic-jam-",["get","magnitudeOfDelay"],["case",["<",["get","delayInSeconds"],600],"-small",["<",["get","delayInSeconds"],3600],"-medium","-large"]],mc=["case",["<=",["get","delayInSeconds"],60],"1 min",[">=",["get","delayInSeconds"],3600],["concat",["to-string",["floor",["/",["to-number",["get","delayInSeconds"]],3600]]]," hr ",["case",["==",["%",["round",["/",["to-number",["get","delayInSeconds"]],60]],60],0],"",["concat",["to-string",["round",["%",["/",["to-number",["get","delayInSeconds"]],60],60]]]," min"]]],["concat",["round",["/",["get","delayInSeconds"],60]]," min"]],gc=["case",["has","delayInSeconds"],["*",-1,["get","delayInSeconds"]],0],_c=(e,t)=>[{id:`${e}-incident-marker`,type:"symbol",minzoom:13,filter:dc,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":uc,"icon-size":cc,"symbol-sort-key":gc},beforeID:t},{id:`${e}-jam-marker`,type:"symbol",minzoom:12,filter:pc,layout:{"symbol-placement":"point","icon-anchor":"bottom-left","icon-offset":[2,3],"icon-image":fc,"icon-size":cc,"icon-padding":0,"text-anchor":"bottom-left","text-field":mc,"text-font":["NotoSans-CondensedBold"],"text-offset":[2.7,-.75],"text-size":hc,"symbol-sort-key":gc},paint:{"text-color":"hsl(210, 30%, 14%)"},beforeID:t},{id:`${e}-closed-road-marker`,type:"symbol",minzoom:12,filter:yc,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":"traffic-incidents-road_closed","icon-size":cc},beforeID:t}],bc=["unknown","minor","moderate","major","indefinite"],Lc={unknown:{outline:"TrafficIncidents - No delay outline",inner:"TrafficIncidents - No delay pattern"},minor:{outline:"TrafficIncidents - Minor jam outline",inner:"TrafficIncidents - Minor jam"},moderate:{outline:"TrafficIncidents - Moderate jam outline",inner:"TrafficIncidents - Moderate jam"},major:{outline:"TrafficIncidents - Major jam outline",inner:"TrafficIncidents - Major jam"},indefinite:{outline:"TrafficIncidents - Closed road outline",inner:"TrafficIncidents - Closed road pattern"}},Sc={unknown:"hsl(198, 20%, 54%)",minor:"hsl(45, 85%, 36%)",moderate:"hsl(9, 87%, 31%)",major:"hsl(0, 100%, 17%)",indefinite:"hsl(0, 100%, 34%)"},Ic={unknown:"hsl(198, 20%, 90%)",minor:"hsl(45, 100%, 51%)",moderate:"hsl(9, 97%, 51%)",major:"hsl(0, 100%, 34%)",indefinite:"hsl(197, 28%, 95%)"},Ac=(e,t,i)=>{if(!e||"object"!=typeof e)return;const r=e.paint;if(!r||"object"!=typeof r)return;const s=r["line-color"];if("string"==typeof s)return s;void 0!==s&&i.push(t)},Ec=e=>{if("top"!==e)return e?Rt[e]:Rt.lowestLabel},vc=class e extends Ke{static async create(t,i){return await Ce(t),new e(t,i??{})}constructor(e,t){super(e,t),this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=`traffic-incident-overlay-${this.instanceIndex}`,r=this.tomtomMap.styleLightDarkTheme,s=(()=>{if(ve())return sa||(sa=Re(Te(Xl))),sa})();s&&He("if-not-in-sprite",Zl,s,this.mapLibreMap);const o=Ec(e?.beforeLayerConfig),a=(e=>{const t=e.getStyle()?.layers??[],i=/* @__PURE__ */new Map;for(const o of t)i.set(o.id,o);const r={outline:{...Sc},inner:{...Ic}},s=[];for(const o of bc){const e=Lc[o],t=Ac(i.get(e.outline),e.outline,s),a=Ac(i.get(e.inner),e.inner,s);t&&(r.outline[o]=t),a&&(r.inner[o]=a)}return s.length>0&&console.warn("[TrafficIncidentOverlayModule] style layers have non-literal `line-color` (match/case/etc.); falling back to default colour for: "+s.join(", ")),r})(this.mapLibreMap),n=((e,t)=>!1===e?null:{outlineColor:e?.outlineColor??ic(t),widthScale:e?.widthScale??1.6})(e?.focus,r),l=[...lc(i,o,a,n),..._c(i,o)];return{incidents:new lt(this.mapLibreMap,i,l)}}_applyConfig(e){return!1===e?.visible?this.sourcesWithLayers.incidents.setLayersVisible(!1):this.sourcesWithLayers.incidents.setLayersVisible(!0),this.applyBeforeLayer(e?.beforeLayerConfig),e}applyBeforeLayer(e){const t=Ec(e);for(const i of this.sourcesWithLayers.incidents.sourceAndLayerIDs.layerIDs)Fe(this.mapLibreMap,i,t)}discardShownData(){this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null}restoreDataAndConfigImpl(){this.initSourcesWithLayers(this.config,!0),this.lastResult&&this.sourcesWithLayers.incidents.show(this.lastResult),this._applyConfig(this.config),null!==this.lastFocusIds&&this.lastFocusIds.length>0&&this.setFocus(this.lastFocusIds)}async show(e){await this.waitUntilModuleReady(),this.clearFeatureState(),this.lastFocusIds=null,this.lastResult=e,this.lastFeatureIds=e.features.map(e=>e.properties.id).filter(e=>"string"==typeof e),this.sourcesWithLayers.incidents.show(e);for(const t of this.shownFeaturesHandlers)t(e)}async clear(){await this.waitUntilModuleReady(),this.clearFeatureState(),this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null,this.sourcesWithLayers.incidents.clear()}setVisible(e){this.config={...this.config,visible:e},this.sourcesWithLayers.incidents.setLayersVisible(e),this.emitConfigChange()}isVisible(){return this.sourcesWithLayers.incidents.isAnyLayerVisible()}moveBeforeLayer(e){this.config={...this.config,beforeLayerConfig:e},this.applyBeforeLayer(e),this.emitConfigChange()}getShown(){return{incidents:this.sourcesWithLayers.incidents.shownFeatures}}get events(){return this.moduleEventsWithShown(["incidents"],this.shownFeaturesHandlers)}setFocus(e){if(null===e||0===e.length)return this.lastFocusIds=null,void this.clearFeatureState();if(0===this.lastFeatureIds.length)return;this.lastFocusIds=e;const t=new Set(e),i=this.sourcesWithLayers.incidents.sourceAndLayerIDs.sourceID;for(const r of this.lastFeatureIds)this.mapLibreMap.setFeatureState({source:i,id:r},{focused:t.has(r)})}clearFeatureState(){if(0===this.lastFeatureIds.length)return;const e=this.sourcesWithLayers.incidents.sourceAndLayerIDs.sourceID;for(const t of this.lastFeatureIds)this.mapLibreMap.removeFeatureState({source:e,id:t})}},Rc="traffic.incidents",Tc=class t extends Ye{static async get(e,i){return await Ce(e),await Ue(e,Mt,"trafficIncidents"),Dt(e,t,()=>new t(e,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const e=this.mapLibreMap.getSource(Mt);if(!e)throw Ie(`init ${t.name} with source ID ${Mt}`);return{trafficIncidents:new ot(this.mapLibreMap,e)}}_applyConfig(e){return this._setVisible(e?.visible??!1,{updateConfig:!1}),i(e?.icons?.visible)||this._setIconsVisible(e.icons.visible,!1),this._filter(e?.filters,e?.icons?.filters,!1),e}filter(e,t){this._filter(e,t)}_filter(e,t,r=!0){if(this.tomtomMap.mapReady){if(e?.any?.length){const i=jl(e);if(i){const e=t?this.getNonSymbolLayers():this.getLayers();Kl(i,e,this.filterComposer,Rc)}}else this.config?.filters?.any?.length&&Kl(void 0,this.getLayers(),this.filterComposer,Rc);if(t?.any?.length){const e=jl(t);e&&Kl(e,this.getSymbolLayers(),this.filterComposer,Rc)}}r&&(this.config=o({...this.config,filters:e,icons:{...this.config?.icons,filters:t}},i),this.emitConfigChange())}getLayers(){return st(this.tomtomMap.mapLibreMap,[Mt])}getSymbolLayers(){return this.getLayers().filter(e=>"symbol"===e.type)}getNonSymbolLayers(){return this.getLayers().filter(e=>"symbol"!=e.type)}setIconsVisible(e){this._setIconsVisible(e)}_setIconsVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficIncidents.setLayersVisible(e,e=>"symbol"===e.type),t&&(this.config={...this.config,icons:{...this.config?.icons,visible:e}},this.emitConfigChange())}setVisible(e){this._setVisible(e)}_setVisible(t,i){(i?.updateConfig??1)&&(delete this.config?.icons?.visible,this.config={...o({...this.config},e),visible:t},this.emitConfigChange()),this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficIncidents.setLayersVisible(t)}isVisible(){return this.sourcesWithLayers.trafficIncidents.isAnyLayerVisible()}anyIconLayersVisible(){return this.sourcesWithLayers.trafficIncidents?.isAnyLayerVisible(e=>"symbol"===e.type)}getShown(){return{trafficIncidents:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.trafficIncidents.sourceAndLayerIDs.layerIDs,validate:!1}).map(se)}}get events(){return this.moduleEvents(["trafficIncidents"],{mapping:se})}},wc=["motorway","motorway_link","trunk","trunk_link","primary","primary_link","secondary","secondary_link","tertiary","tertiary_link","street","service","track"],Cc=["unclassified","residential","living_street"],Oc=["parking","driveway","alley"],Mc=(e,t)=>({left:e.left-t.left,top:e.top-t.top,right:e.right-t.left,bottom:e.bottom-t.top}),Nc=(e,t,i)=>e.right<=0||e.left>=t||e.bottom<=0||e.top>=i,xc=(e,t,i,r)=>{e.top<=i-e.bottom?t.top=Math.max(t.top,e.bottom+r):t.bottom=Math.min(t.bottom,e.top-r)},Dc=(e,t,i,r)=>{e.left<=i-e.right?t.left=Math.max(t.left,e.right+r):t.right=Math.min(t.right,e.left-r)},Fc=(e,t,i,r,s)=>{const o=((e,t,i)=>({left:Math.max(0,e.left),top:Math.max(0,e.top),right:Math.min(t,e.right),bottom:Math.min(i,e.bottom)}))(e,i,r),a=e.left<=0&&e.right>=i,n=e.top<=0&&e.bottom>=r;if(a&&!n)return void xc(o,t,r,s);if(n&&!a)return void Dc(o,t,i,s);const l=e.left<=0,c=e.right>=i,h=e.top<=0,u=e.bottom>=r;!l&&!c||h||u?!h&&!u||l||c?((e,t,i,r,s)=>{const o=e.left,a=i-e.right,n=e.top,l=r-e.bottom,c=Math.min(o,a,n,l);c===o?t.left=Math.max(t.left,e.right+s):c===a?t.right=Math.min(t.right,e.left-s):c===n?t.top=Math.max(t.top,e.bottom+s):t.bottom=Math.min(t.bottom,e.top-s)})(o,t,i,r,s):Dc(o,t,i,s):xc(o,t,r,s)},kc=e=>"string"==typeof e?document.querySelector(e):e,Pc=e=>"mapLibreMap"in e?e.mapLibreMap:e,Uc=(e,t,i)=>{const r=Pc(e).getContainer().getBoundingClientRect(),{width:s,height:o}=r,a={left:i,top:i,right:s-i,bottom:o-i};for(const n of t){const e=kc(n);if(!e)continue;const t=e.getBoundingClientRect(),l=Mc(t,r);Nc(l,s,o)||Fc(l,a,s,o,i)}return a.left>=a.right||a.top>=a.bottom?null:{visibleAreaBounds:a,mapWidthPX:s,mapHeightPX:o}},Hc=e=>{const{map:t,surroundingElements:i,paddingPX:r=0}=e,s=Uc(t,i,r);if(!s)return null;const{visibleAreaBounds:o}=s,a=Pc(t),n=a.unproject([o.left,o.bottom]),l=a.unproject([o.right,o.top]);return[n.lng,n.lat,l.lng,l.lat]},Wc=e=>{const{map:t,surroundingElements:i}=e,r=Hc({map:t,surroundingElements:i});if(!r)return null;const[s,o,a,n]=r;return[(s+a)/2,(o+n)/2]},Gc=e=>{const{map:t,toBeContainedBBox:i,surroundingElements:r,paddingPX:s=0}=e,o=Uc(t,r,s);if(!o)return null;const{visibleAreaBounds:a,mapWidthPX:n,mapHeightPX:l}=o,c=a.left/n,h=a.right/n,u=a.top/l,d=h-c,p=a.bottom/l-u,[y,f,m,g]=i,_=(m-y)/d,b=(g-f)/p,L=y-c*_,S=g+u*b;return[L,S-b,L+_,S]};export{Ke as AbstractDataOwnedMapModule,$e as AbstractMapModule,rt as AbstractSourceWithLayers,Ye as AbstractStyleOwnedMapModule,at as AddedSourceWithLayers,Ot as BASE_MAP_SOURCE_ID,pr as BaseMapModule,k as CombinedEvents,fr as CustomGeoJSONModule,Hr as DEFAULT_STYLE_VERSION,It as DEFAULT_TEXT_SIZE,Jr as DESELECTED_FOREGROUND_COLOR,Qr as DESELECTED_OUTLINE_COLOR,rs as DESELECTED_ROUTE_FILTER,es as DESELECTED_SECONDARY_COLOR,ft as EventsProxy,Vo as FINISH_INDEX,lt as GeoJSONSourceWithLayers,Cr as GeometriesModule,wt as HILLSHADE_SOURCE_ID,Es as INDEFINITE_DELAY_DASH_COLOR,Q as LayerFilterComposer,In as LayerSelection,gs as MAJOR_DELAY_COLOR,_t as MAP_BOLD_FONT,St as MAP_ITALIC_FONT,Lt as MAP_MEDIUM_FONT,bt as MAP_REGULAR_FONT,Bo as MIDDLE_INDEX,bs as MINOR_DELAY_COLOR,Ls as MINOR_DELAY_LABEL_COLOR,_s as MODERATE_DELAY_COLOR,ee as ModuleEvents,Tt as POI_SOURCE_ID,ir as POIsModule,Zi as PlacesModule,Zr as ROUTE_LINE_FOREGROUND_COLOR,ts as ROUTE_LINE_FOREGROUND_WIDTH,Xr as ROUTE_LINE_OUTLINE_COLOR,ss as ROUTE_LINE_OUTLINE_WIDTH,Pa as RoutingModule,is as SELECTED_ROUTE_FILTER,Go as START_INDEX,zo as STOP_DISPLAY_INDEX,ot as StyleSourceWithLayers,$n as StylingModule,Ct as TERRAIN_SOURCE_ID,Nt as TRAFFIC_FLOW_SOURCE_ID,Mt as TRAFFIC_INCIDENTS_SOURCE_ID,ol as TerrainModule,sl as TomTomMap,it as TomTomMapSource,Hl as TrafficAreaAnalyticsModule,ql as TrafficFlowModule,vc as TrafficIncidentOverlayModule,Tc as TrafficIncidentsModule,Is as UNKNOWN_DELAY_BG_COLOR,Ss as UNKNOWN_DELAY_COLOR,As as UNKNOWN_DELAY_DASH_COLOR,je as UserEvents,Rr as adaptPaletteForTheme,G as assertNoReservedScopeNames,nr as baseMapLayerGroupNames,Ht as baseMapPOICategoryValues,no as bespokeSectionTypes,Wi as buildPlaceTitle,Mr as buildReachableRangeFeatures,ia as buildRoutingLayers,Gc as calculateFittingBBox,Hc as calculatePaddedBBox,Wc as calculatePaddedCenter,vr as colorPaletteIDs,Er as colorPalettes,U as combineEventScopes,ra as defaultRoutingLayers,lo as drawnSectionTypes,st as filterLayersBySources,Xe as findFeatureByRefId,ao as generatedSectionTypes,Fr as geometryThemes,Bi as getIconIDForPlace,fs as getInstructionLineWidth,ms as getInstructionOutlineWidth,ls as getLineForegroundWidth,cs as getLineOutlineWidth,ji as getPOIGroupForPlace,zi as getPOILayerCategoryForPlace,ds as getSectionHaloWidth,er as getStyleCategories,hs as getWaypointIconSize,mt as knob,gt as knobSettings,Xa as mapColorNames,kt as mapDisplayPoiCategoryMappings,At as mapFonts,Rt as mapStyleLayerIDs,pe as parseCssColor,Xi as placesThemes,Ji as poiCategoryGroups,Ft as poiLayerIDs,qi as preparePlacesForDisplay,Nr as prepareReachableRangesForDisplay,Dr as reachableRangeGeometryConfig,Ze as renderedRefId,W as reservedScopeNames,_l as resolveColorStops,wc as roadCategories,H as scopedLayerSpecs,yo as sectionDrawsByDefault,mo as sectionSourceKey,uo as sectionSupportsKnob,Oc as serviceRoadSubCategories,Dt as sharedInstance,kr as standardStyleIDs,Cc as streetRoadSubCategories,Pr as styleModules,Ln as stylingColorKnobIds,rl as stylingKnobAppliesTo,bn as stylingKnobIds,il as stylingKnobKinds,Rn as stylingPresetIds,xr as themedGeometryConfig,Ut as toBaseMapPOICategory,Gt as toBaseMapPOIGroup,$i as toPlaces};
1
+ import{isEmpty as e,isEqual as t,isNil as i,isUndefined as r,mapValues as s,omit as o,omitBy as a,remove as n}from"lodash-es";import{DEFAULT_COMMON_BASE_URL as l,MILE_IN_METERS as c,TomTomConfig as h,bboxCenter as u,bboxFromCoordsArray as d,bboxFromGeoJSON as p,formatDistance as y,formatDuration as f,generateId as m,generateTomTomHeaders as g,getPosition as _,iconToTrafficIncidentCategory as L,indexedMagnitudes as b,isProxyCredentialsMode as S,mergeFromGlobal as I,poiCategoriesToID as A,trafficIncidentToIconCategory as E}from"@tomtom-org/maps-sdk/core";import{clampRgb as v,differenceHueNaive as R,formatHex as T,formatHsl as C,interpolate as w,modeHsl as O,modeLrgb as M,modeRgb as N,parse as x,round as D,useMode as F,wcagLuminance as P}from"culori/fn";import{bearing as k,booleanPointInPolygon as U,difference as H,featureCollection as W,hexGrid as G,mask as B,squareGrid as V}from"@turf/turf";import{Map as z,getRTLTextPluginStatus as j,getVersion as $,setRTLTextPlugin as Y,setWorkerCount as K}from"maplibre-gl";var q=class{constructor(e,t){this.userEventsInstance=e,this.moduleEventsInstance=t}where(e,t){return this.userEventsInstance.where(e,t)}on(e,t){return"config-change"===e?this.moduleEventsInstance.on("config-change",t):"shown-features"===e?this.moduleEventsInstance.on("shown-features",t):this.userEventsInstance.on(e,t)}off(e){"config-change"===e||"shown-features"===e?this.moduleEventsInstance.off(e):this.userEventsInstance.off(e)}},Z=(e,t)=>e?t?(...i)=>e(...i)&&t(...i):e:t,X=(e,t)=>{if(!e)return t;if(!t)return e;const i=Z(e.layerFilter,t.layerFilter),r=Z(e.featureMatches,t.featureMatches);return i||r?{layerFilter:i,featureMatches:r}:void 0},J=(e,t)=>t?.layerFilter?e._layerSpecs.filter(t.layerFilter):e._layerSpecs,Q=["on","off","where"],ee=(e,t)=>{const i=e.find(e=>Q.includes(e));if(i)throw new Error(`${t} uses the reserved event scope name "${i}". Reserved: ${Q.join(", ")}.`)},te=e=>{if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!te(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}},ie=e=>"$type"===e?["geometry-type"]:"$id"===e?["id"]:["get",e],re=e=>"$type"===e||("$id"===e?["!=",["id"],null]:["has",e]),se=(e,t)=>!!t.length&&["in",ie(e),["literal",t]],oe=e=>{const t=e[0];if(e.length<=1)return"any"!==t;const i=e[1],r=e.slice(2),s=e.slice(1);switch(t){case"has":return re(i);case"!has":return["!",re(i)];case"==":case"!=":return(null===r[0]?((e,t)=>{if("$id"!==t&&"$type"!==t)return"=="===e?["all",["has",t],["==",["get",t],null]]:["any",["!",["has",t]],["!=",["get",t],null]]})(t,i):void 0)??[t,ie(i),r[0]];case">":case">=":case"<":case"<=":return((e,t,i)=>["all",["==",["typeof",ie(t)],typeof i],[e,ie(t),i]])(t,i,r[0]);case"in":return se(i,r);case"!in":return["!",se(i,r)];case"all":return["all",...s.map(e=>ae(e))];case"any":return["any",...s.map(e=>ae(e))];case"none":return["!",["any",...s.map(e=>ae(e))]];default:return!0}},ae=e=>te(e)?e:oe(e),ne=e=>e?.length?1===e.length?e[0]:["any",...e]:null,le=(e,t,i)=>{if(1===i.length)return["only"===t?"==":"!=",["get",e],i[0]];const r=["in",["get",e],["literal",i]];return"only"===t?r:["!",r]},ce=(e,t,i)=>le(e,t.show,i?t.values.map(i):t.values),he=/* @__PURE__ */new WeakMap,ue=(e,t,i)=>{void 0!==i?e.set(t,i):e.delete(t)},de=class e{constructor(e){this.byLayer=/* @__PURE__ */new Map,this.mapLibreMap=e.mapLibreMap,e.addStyleChangeHandler({onStyleAboutToChange:()=>this.byLayer.clear(),priority:Number.NEGATIVE_INFINITY})}static for(t){let i=he.get(t);return i||(i=new e(t),he.set(t,i)),i}setTransform(e,t,i){this.contribute(e,({transforms:e})=>ue(e,t,i))}setClause(e,t,i){this.contribute(e,({clauses:e})=>ue(e,t,i))}contribute(e,t){if(!this.mapLibreMap.getLayer(e))return;let i=this.byLayer.get(e);i||(i={styleFilter:this.mapLibreMap.getFilter(e),transforms:/* @__PURE__ */new Map,clauses:/* @__PURE__ */new Map},this.byLayer.set(e,i)),t(i),this.apply(e,i)}apply(e,t){const i=[...t.transforms.values()].reduce((e,t)=>t(e),t.styleFilter),r=((e,t)=>{if(!t.length)return e;const i=null==e?t:[...t,ae(e)];return 1===i.length?i[0]:["all",...i]})(i,[...t.clauses.values()]);this.mapLibreMap.setFilter(e,r??null,{validate:!1})}},pe=class{constructor(e,t){this.configChangeHandlers=e,this.shownFeaturesHandlers=t}on(e,t){if("config-change"===e){const e=t;return this.configChangeHandlers.push(e),()=>{const t=this.configChangeHandlers.indexOf(e);-1!==t&&this.configChangeHandlers.splice(t,1)}}const i=t;return this.shownFeaturesHandlers.push(i),()=>{const e=this.shownFeaturesHandlers.indexOf(i);-1!==e&&this.shownFeaturesHandlers.splice(e,1)}}off(e){"config-change"===e?this.configChangeHandlers.length=0:this.shownFeaturesHandlers.length=0}},ye=e=>/* @__PURE__ */new Error(`Trying to ${e} while it is not in the map style. Did you exclude it when loading the map?`),fe=["standardLight","standardDark","drivingLight","drivingDark","monoLight","monoDark","satellite"],me=["trafficIncidents","trafficFlow","hillshade"],ge="standardLight",_e="0.6.0-0",Le={standardLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_light"},standardDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_dark"},drivingLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_light"},drivingDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_dark"},monoLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_mono-light"},monoDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_mono-dark"},satellite:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_satellite"}},be={standardLight:"basic_street-light",standardDark:"basic_street-dark",drivingLight:"basic_street-light-driving",drivingDark:"basic_street-dark-driving",monoLight:"basic_mono-light",monoDark:"basic_mono-dark",satellite:"basic_street-satellite"},Se=(e,t,i)=>{const r=e.id??"standardLight",s=e.version??"0.6.0-0",o=new URL(`${t}/maps/orbis/assets/styles/${s}/style.json`);o.searchParams.set("apiVersion","1"),i&&o.searchParams.set("key",i),o.searchParams.set("map",be[r]);for(const a of e.include??me)o.searchParams.append(a,Le[r][a]);return o.toString()},Ie=e=>{const t=e.style,i=e.commonBaseURL,r=e.apiKey;if("string"==typeof t)return Se({id:t},i,r);if("standard"===t?.type)return Se(t,i,r);if("custom"===t?.type){if(void 0!==t.url)return((e,t)=>{const i=new URL(e);return i.searchParams.has("key")?console.warn("The style URL is coming with an API key parameter which takes priority. If you want to use the SDK configured API key, remove the key param from the style URL"):t&&i.searchParams.set("key",t),i.toString()})(t.url,r);if(void 0===t.json)/* @__PURE__ */throw new Error("A custom map style takes exactly one of 'url' or 'json', and this one carries neither. Give the URL the style is served from, or the style specification itself.");return t.json}return Se({id:ge},i,r)},Ae=F(N),Ee=F(O);F(M);var ve=D(2),Re={mode:"rgb",r:0,g:0,b:0},Te={mode:"rgb",r:1,g:1,b:1},Ce=/^(#|rgba?\(|hsla?\(|[a-z]+$)/,we=e=>{const t=e.trim().toLowerCase(),i=Ce.test(t)?x(t):void 0;return i&&v(i)},Oe=e=>{const t=we(e);if(!t)return;const{r:i,g:r,b:s,alpha:o=1}=Ae(t);return[i,r,s,o]},Me=e=>{const t=we(e);return t&&Ee(Ae(t))},Ne=e=>"string"==typeof e&&void 0!==we(e),xe=e=>C(De(e)),De=({h:e=0,s:t,l:i,alpha:r})=>({mode:"hsl",h:(Math.round(e)%360+360)%360,s:ve(t),l:ve(i),alpha:r}),Fe=e=>Math.min(Math.max(e,0),1),Pe=(e,t)=>{const i=Me(e),r=Me(t);if(i&&r)return{h:i.s<.01||r.s<.01?0:(r.h??0)-(i.h??0),s:r.s-i.s,l:r.l-i.l,alpha:(r.alpha??1)-(i.alpha??1)}},ke=(e,t)=>{const i=Me(e);if(i)return xe({h:(i.h??0)+t.h,s:void 0===i.h?i.s:i.s+t.s,l:i.l+t.l,alpha:Fe((i.alpha??1)+t.alpha)})},Ue=e=>{const t=we(e);return t&&P(t)},He=(e,t)=>{const i=we(e);return i&&T(w([i,Re])(t))},We=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&Array.isArray(e.stops),Ge=(e,t)=>"number"==typeof e?(e=>Math.round(1e3*e)/1e3)(e*t):We(e)?Be(e,t):Array.isArray(e)?"interpolate"===e[0]||"step"===e[0]?Ve(e,t):(e=>JSON.stringify(e).includes('"zoom"'))(e)?void 0:["*",t,e]:void 0,Be=(e,t)=>{const i=[];for(const[r,s]of e.stops){const e=Ge(s,t);if(void 0===e)return;i.push([r,e])}return{...e,stops:i}},Ve=(e,t)=>{const i=[...e];for(let r="interpolate"===e[0]?4:2;r<i.length;r+=2){const e=Ge(i[r],t);if(void 0===e)return;i[r]=e}return i},ze=(e,t)=>{let i=!1;const r=e=>Array.isArray(e)?"-"===e[0]&&3===e.length&&Array.isArray(e[1])&&"zoom"===e[1][0]&&"number"==typeof e[2]?(i=!0,["-",["zoom"],e[2]+t]):e.map(r):e;return{filter:r(e),patched:i}},je={fill:["fill-color","fill-outline-color"],line:["line-color"],"fill-extrusion":["fill-extrusion-color"]},$e=e=>t=>({layers:[{...t,layerTypes:[e]}],properties:[...je[e]]}),Ye=$e("fill"),Ke=$e("line"),qe=$e("fill-extrusion"),Ze=(e,t)=>({metadataGroups:["road"],layerTypes:["line"],idIncludes:e,...t&&{idExcludes:t}}),Xe=Ze(["road line","road outline","under construction","link road"],["tarmac"]),Je=Ze(["motorway","primary road","major road"]),Qe=Ze(["secondary road","tertiary road","street","minor road","restricted","service road"],["outline"]),et=Ze(["secondary road outline","tertiary road outline","street outline","minor road outline","tarmac outline"]),tt=Ze(["railway","subway","track","path","aerialway"]),it={metadataGroups:["places_label","road_label","label","address_point_label","border_label"],layerTypes:["symbol"],idExcludes:["shield","exit","water","river"]},rt={land:{description:"Map background and other bare-land features, influences admin borders/labels. Also used to derive all map colours if undefined.",anchor:{layers:[{layerTypes:["background"]}],property:"background-color"},targets:[{layers:[{layerTypes:["background"]}],properties:["background-color"]},Ye({metadataGroups:["area"],idIncludes:["earth cover","landcover"]}),Ye({metadataGroups:["road_area"]}),Ye({metadataGroups:["transit_area"]}),Ke({metadataGroups:["transit_area"]})]},water:{description:"Waterbodies, waterways and other water features. Also influences glaciers, water labels and ferry lines.",anchor:{layers:[{metadataGroups:["water"],layerTypes:["fill"],idIncludes:["fill"]}],property:"fill-color"},targets:[Ye({metadataGroups:["water"]}),Ke({metadataGroups:["water"]}),{layers:[{metadataGroups:["label"],layerTypes:["symbol"],idIncludes:["water","river"]}],properties:["text-color","text-halo-color"]},Ke({metadataGroups:["road"],idIncludes:["ferry"]})]},vegetation:{description:"Forests and other land cover such as grass and shrubland. Also influences earth cover vegetation at smaller scales.",anchor:{layers:[{metadataGroups:["area"],layerTypes:["fill"],idIncludes:["landcover"]}],property:"fill-color"},targets:[Ye({metadataGroups:["area"],idIncludes:["landcover","earth cover"]})]},park:{description:"City parks and sport/recreation grounds. Also influences National Parks and other protected areas at smaller scales.",anchor:{layers:[{metadataGroups:["area"],layerTypes:["fill"],idIncludes:["protected"]}],property:"fill-color"},targets:[Ye({metadataGroups:["area"],idIncludes:["protected","outdoor","sport","landuse"]}),Ke({metadataGroups:["border"],idIncludes:["overlays"]})]},artificial:{description:"Built-up-areas and man-made features such as landuse grounds and buildings. Also influences railways.",anchor:{layers:[{metadataGroups:["area"],layerTypes:["fill"],idIncludes:["built-up"]}],property:"fill-color",lastStop:!0},targets:[...[Ye({metadataGroups:["area"],idIncludes:["built-up","landuse","parking"]}),Ye({metadataGroups:["building"]}),Ke({metadataGroups:["building"]}),qe({metadataGroups:["area_3d","building"]})].map(e=>({...e,recolorsTints:!0})),Ye({metadataGroups:["transit_area","road_area"]}),Ke({metadataGroups:["transit_area"]}),Ke(tt)]},roadMajor:{description:"Most important road classes, from motorways & trunks to primary roads. Also influences outline and tunnel colours.",anchor:{layers:[Ze(["motorway & trunk"],["outline"])],property:"line-color",roadClass:"major"},targets:[Ke(Je),{layers:[Xe],properties:["line-color"],roadClass:"major"}]},road:{description:"Less important road classes, from secondary/tertiary to streets and service roads. Also influences tunnel colours.",anchor:{layers:[Ze(["secondary road"],["outline"])],property:"line-color"},targets:[Ke(Qe),{layers:[Ze(["road line","under construction","link road"],["outline"])],properties:["line-color"],roadClass:"minor"}]},roadOutline:{description:"Road outlines for secondary/tertiary roads and minor classes. Also influences road labels and all other outline colours.",anchor:{layers:[Ze(["secondary road outline"])],property:"line-color"},targets:[Ke(et),{layers:[Ze(["road outline","link road outline"],["tarmac"])],properties:["line-color"],roadClass:"minor"}]},label:{description:"Labels for capitals and other populated places/admin areas. Also influences border styling and all other label colours.",anchor:{layers:[{metadataGroups:["places_label"],layerTypes:["symbol"],idIncludes:["capital"]}],property:"text-color"},targets:[{layers:[it],properties:["text-color"]},Ke({metadataGroups:["border"],idIncludes:["country","state","treaty","disputed"]})]},labelOutline:{description:"Outlines for populated places and admin area labels. Also influences border outlines and all other label halos.",anchor:{layers:[{metadataGroups:["places_label"],layerTypes:["symbol"],idIncludes:["capital"]}],property:"text-halo-color"},targets:[{layers:[it],properties:["text-halo-color"]},Ke({metadataGroups:["border"],idIncludes:["background"]})]}},st=Object.keys(rt),ot=e=>e in rt,at=st.filter(e=>"land"!==e),nt={monoLight:at,monoDark:at},lt=e=>"roadMajor"===e||"roadOutline"===e?["land","road"]:["land"],ct=e=>{const t=Ue(e);return void 0===t?void 0:ve(t)},ht=(e,t)=>({...e,l:Fe(t)}),ut=(e,t)=>De(ht(t,t.l*(1+e))),dt=(e,t)=>ut(-e,t),pt=(e,t)=>De({...t,s:Fe(t.s*(1-e))}),yt=(e,t)=>ht(t,t.l+e/100),ft=(e,t)=>yt(-e,t),mt=e=>e?1:-1,gt=(e,t,i)=>{const r=e.land??i,s=t.filter(t=>void 0===e[t]&&lt(t).some(t=>void 0!==e[t])),o=r&&s.length?((e,t)=>{const i=Me(e),r=ct(e);if(!i||void 0===r)return;const s=mt(r<=.95),o=mt(r>.3),a=yt(15*s,ut(Math.max(r/5,.1),i)),n=t&&Me(t)||a;return{water:xe(ft(10*mt(r>.01),dt(Math.max(r/20,.05),i))),vegetation:xe(dt(.05,ft(2,i))),park:xe(dt(.03,ft(1,i))),artificial:xe(ft(4*mt(r>.05),ut(Math.max(r/15,.02),i))),road:xe(a),roadMajor:xe(n),roadOutline:xe(ft(20*s,n)),label:xe(pt(.3,ft(60*o,ut(Math.max(r/5,.1),i)))),labelOutline:xe(yt(75*o,i))}})(r,e.road):void 0;return o?{...Object.fromEntries(s.map(e=>[e,o[e]])),...e}:e},_t=/* @__PURE__ */new Set(["motorway","trunk","primary"]),Lt=e=>(Array.isArray(e)?e:[e]).some(e=>"string"==typeof e&&_t.has(e.replace(/_link$/,"")))?"major":"minor",bt={roadClass:void 0,keyed:!1},St=(e,t,i=bt)=>{if((e=>{const t="string"==typeof e?we(e):void 0;return void 0!==t&&(t.alpha??1)>0})(e))return t(e,i);if(Array.isArray(e)){if("match"===e[0]){const s="match"===(r=e)[0]&&Array.isArray(r[1])&&"get"===r[1][0]&&("category"===r[1][1]||"road_category"===r[1][1]),o=[e[0],e[1]];for(let r=2;r<e.length-1;r+=2){const a=s?Lt(e[r]):i.roadClass;o.push(e[r],St(e[r+1],t,{roadClass:a,keyed:!0}))}const a=s?"minor":i.roadClass;return o.push(St(e.at(-1),t,{...i,roadClass:a})),o}return e.map(e=>St(e,t,i))}var r;return We(e)?{...e,stops:e.stops.map(([e,r])=>[e,St(r,t,i)])}:e},It=e=>{const t=[];return St(e,(e,i)=>(t.push({literal:e,...i}),e)),t},At=e=>{const t=ct(e);return void 0===t?void 0:Math.max(t,.33)},Et=(e,t,i)=>{const[r,s,o]=[e,t,i].map(Me);if(!r||!s||!o)return;const a=r.s<.08||s.s<.08;if(!a&&(({h:e},{h:t})=>void 0===e||void 0===t?0:Math.abs(R({h:e},{h:t})))(r,s)>40)return;const n=Pe(e,t),l=o.alpha??1;return n&&{...n,h:a?0:n.h,alpha:(s.alpha??1)*l-l}},vt=(e,t)=>{const i=[...t].reverse();return St(e,(e,{roadClass:t})=>{const r=i.filter(({owns:e})=>!e||e(t));for(const{anchorColor:i,newColor:o}of r){const t=Et(i,e,o);if(t)return ke(o,t)??e}const s=r.find(e=>e.recolorsTints);return s?((e,t,i)=>{const[r,s,o]=[e,t,i].map(Me),[a,n]=[e,i].map(At);if(!(r&&s&&o&&a&&n))return;const l=s.s*n/a,c=(s.alpha??1)*(o.alpha??1);return xe({h:s.h,s:l,l:o.l+s.l-r.l,alpha:c})})(s.anchorColor,e,s.newColor)??e:e})},Rt=["road_category","road_subcategory","relative_speed","left_hand_traffic","road_closure","absolute_speed","part_of_two_way_road","openlr","display_class"],Tt=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{roadCategory:t?.road_category,leftHandTraffic:Boolean(t?.left_hand_traffic),roadClosure:Boolean(t?.road_closure),relativeSpeed:t?.relative_speed,...t?.road_subcategory&&{roadSubcategory:t.road_subcategory},...t?.absolute_speed&&{absoluteSpeed:t.absolute_speed},...t?.part_of_two_way_road&&{partOfTwoWayRoad:Boolean(t.part_of_two_way_road)},...t?.openlr&&{openlr:t.openlr},...t?.display_class&&{displayClass:t.display_class}}}},Ct=["icon_category","left_hand_traffic","magnitude_of_delay","road_category","road_subcategory","id","description","delay","part_of_two_way_road","start_time","end_time","probability_of_occurrence","number_of_reports","last_report_time","average_speed_kmph","openlr","time_validity","display_class"],wt=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{id:t.id??m(),description:t?.description_0??"",category:L(t?.icon_category_0),magnitudeOfDelay:b[t?.magnitude_of_delay],roadCategory:t?.road_category,roadSubcategory:t?.road_subcategory,leftHandTraffic:Boolean(t?.left_hand_traffic),...t?.delay&&{delayInSeconds:t.delay},...t?.part_of_two_way_road&&{partOfTwoWayRoad:Boolean(t.part_of_two_way_road)},...t?.start_time&&{startTime:new Date(t.start_time)},...t?.end_time&&{endTime:new Date(t.end_time)},...t?.probability_of_occurrence&&{probabilityOfOccurrence:t.probability_of_occurrence},...t?.number_of_reports&&{numberOfReports:t.number_of_reports},...t?.last_report_time&&{lastReportTime:new Date(t.last_report_time)},...t?.average_speed_kmph&&{averageSpeedKmph:t.average_speed_kmph},...t?.openlr&&{openlr:t.openlr},...t?.time_validity&&{timeValidity:t.time_validity},...t?.display_class&&{displayClass:t.display_class},...t?.point_type&&{pointType:t.point_type}}}},Ot="pinCategories",Mt=e=>`${Ot}:${e}`,Nt=()=>"undefined"!=typeof document&&"undefined"!=typeof DOMParser&&"undefined"!=typeof btoa,xt=e=>{if(!Nt())return;const t=document.createElement("img");return t.src=`data:image/svg+xml;base64,${btoa((new XMLSerializer).serializeToString(e))}`,t},Dt=e=>(new DOMParser).parseFromString(e,"image/svg+xml").documentElement,Ft=e=>((e,t)=>(t?.fillColor&&e.querySelector("#background")?.setAttribute("fill",t.fillColor),t?.outlineColor&&e.querySelector("#outline")?.setAttribute("fill",t.outlineColor),void 0!==t?.outlineOpacity&&e.querySelector("#outline")?.setAttribute("fill-opacity",t.outlineOpacity.toString()),e))(Dt('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path id="background" d="M63.95 137.516c6.556-12.737 19.098-21.09 30.828-29.388C110.046 97.324 120 79.603 120 59.574 120 26.671 93.138 0 60 0S0 26.671 0 59.574c0 20.029 9.954 37.75 25.22 48.55 11.734 8.302 24.274 16.652 30.83 29.388 1.706 3.316 6.194 3.316 7.9 0z"\n fill="#1988cf"/>\n <path id="outline" d="M91.298 103.272C105.052 93.544 114 77.596 114 59.574c0-29.61-24.176-53.617-54-53.617S6 29.964 6 59.574c0 18.022 8.95 33.97 22.7 43.698l2.27 1.601c10.172 7.153 21.922 15.423 29.03 27.416 7.104-11.993 18.858-20.259 29.03-27.416l2.268-1.601zm1.468 6.274c-11.13 7.845-22.632 15.957-28.816 27.966-1.706 3.316-6.194 3.316-7.9 0-6.182-12.009-17.686-20.121-28.816-27.966l-2.016-1.422C9.954 97.324 0 79.603 0 59.574 0 26.671 26.862 0 60 0s60 26.671 60 59.574c0 20.029-9.954 37.75-25.222 48.55l-2.016 1.422z"\n fill-opacity=".3"/>\n</svg>\n'),e),Pt=async e=>{e.mapReady||(await e.mapLibreMap.once("styledata"),await Pt(e))},kt=e=>{const t=globalThis.__DEMOS_PROXY_ENSURE_SESSION__;return"function"!=typeof t?e:t().then(()=>e,()=>e)},Ut=e=>{const t=e.commonBaseURL??l,i=t!==l,r=S(e);return(s,o)=>{const a=((e,t,i,r)=>{if(!i)return e;try{const i=new URL(e);return"api.tomtom.com"===(s=i.hostname)||s.endsWith(".api.tomtom.com")?(r&&i.searchParams.delete("key"),t+i.pathname+i.search+i.hash):e}catch{return e}var s})(s,t,i,r),n=i&&a.startsWith(t),l=r&&n;let c=!1;try{const e=new URL(s).hostname;c="tomtom.com"===e||e.endsWith(".tomtom.com")}catch{c=!1}if(!c&&!n)return{url:a};if("Image"===o)return l?kt({url:a,credentials:"include"}):{url:a};const h=new URL(a);(e=>{e.pathname.includes("incidents")?e.searchParams.set("tags",Ct.join(",")):e.pathname.includes("flow")&&e.searchParams.set("tags",Rt.join(","))})(h);const u={url:h.toString(),headers:{...g(e)}};return l?(u.credentials="include",kt(u)):u}},Ht=(e,t,i)=>{const r=e.id;e.maxzoom===t.maxzoom&&e.minzoom===t.minzoom||i.setLayerZoomRange(r,e.minzoom??i.getMinZoom(),e.maxzoom??i.getMaxZoom()),i.setFilter(r,e.filter,{validate:!1});for(const s of Object.keys(t.layout??{}))e.layout?.[s]||i.setLayoutProperty(r,s,void 0,{validate:!1});for(const s of Object.keys(t.paint??{}))e.paint?.[s]||i.setPaintProperty(r,s,void 0,{validate:!1});for(const[s,o]of Object.entries(e.paint??{}))i.setPaintProperty(r,s,o,{validate:!1});for(const[s,o]of Object.entries(e.layout??{}))i.setLayoutProperty(r,s,o,{validate:!1})},Wt=(e,t,i,r)=>{const s=e.reduce((e,t)=>({...e,[t.id]:t}),{}),o=t.reduce((e,t)=>({...e,[t.id]:t}),{}),a=[],n=[],l=[],c=[];Object.keys(s).forEach(e=>{o[e]?(l.push(s[e]),c.push(o[e])):a.push(e)}),Object.keys(o).forEach(e=>{s[e]||n.push(e)});const h=i._layerSpecs;n.forEach(e=>{r.removeLayer(e);for(let t=0;t<h.length;t++)if(h[t].id===e){h.splice(t,1);break}});const u=a.map(e=>({...s[e],source:i.source.id}));u.length&&(h.push(...u),Vt(u,r)),i._updateSourceAndLayerIDs(),((e,t,i,r)=>{const s=/* @__PURE__ */new Set,o=e=>{if(!r.getLayer(e.id))return;Bt(r,e.id,e.beforeID),s.add(e.id);const t=i.find(t=>t.id===e.id);t&&(t.beforeID=e.beforeID)};e.forEach((e,i)=>{e.beforeID!==t[i].beforeID&&o(e)});const a=()=>e.filter(e=>!s.has(e.id)&&void 0!==e.beforeID&&s.has(e.beforeID));for(let n=a();n.length;n=a())n.forEach(o)})(l,c,h,r),((e,t,i)=>{e.forEach((e,r)=>Ht(e,t[r],i))})(l,c,r)},Gt=(e,t)=>t&&e.getLayer(t)?t:void 0,Bt=(e,t,i)=>{e.moveLayer(t,Gt(e,i))},Vt=(e,t)=>{const i=/* @__PURE__ */new Set,r=e=>{t.getLayer(e.id)||t.addLayer({...e,layout:{...e.layout,visibility:"none"}},e.beforeID),i.add(e.id)},s={};for(e.forEach(e=>{e.beforeID?i.has(e.beforeID)||t.getLayer(e.beforeID)?(i.add(e.beforeID),r(e)):s[e.beforeID]?s[e.beforeID].push(e):s[e.beforeID]=[e]:r(e)});Object.keys(s).length>0;){const e=Object.keys(s).filter(e=>i.has(e));if(!e.length)return void console.error(`Some layers cannot be added. Check for non-existing layers, or circular beforeID dependencies for the following: ${JSON.stringify(Object.keys(s))}`);e.forEach(e=>{s[e].forEach(e=>r(e)),delete s[e]})}},zt=(e,t)=>{switch(typeof e){case"undefined":return{type:"standard",include:[t]};case"string":return{type:"standard",id:e,include:[t]};default:if("standard"===e.type)return e.include?{...e,include:[...e.include,t]}:{...e,include:[t]};throw(e=>/* @__PURE__ */new Error(`The custom map style has no '${e}' part and the SDK cannot add one to it. Style-owned modules work on a custom style only when it already ships the matching source (e.g. built with that part enabled) — or switch to a standard style.`))(t)}},jt=async(e,t,i)=>{if(!e.mapLibreMap.getSource(t)){const r=e.mapLibreMap;r.isStyleLoaded()||await r.once("idle"),await e.setStyle(zt(e.getStyle(),i)),await(async(e,t)=>{e.mapLibreMap.getSource(t)&&e.mapLibreMap.isSourceLoaded(t)||await e.mapLibreMap.once("sourcedata")})(e,t)}},$t=async(e,t,i,r,s)=>{if(!i)return void console.warn(`addOrUpdateImage called with empty image for ID ${t}`);const o=i=>{const o=r.hasImage(t);o&&"add-or-update"==e?r.updateImage(t,i):o||r.addImage(t,i,s)},a=e=>{e.complete?e.naturalWidth>0?o(e):console.warn(`Failed to load image for ID ${t}`):(e.onload=()=>o(e),e.onerror=()=>console.warn(`Failed to load image for ID ${t}`))};if("string"==typeof i)if(i.includes("<svg"))a(xt(Dt(i)));else try{o((await r.loadImage(i)).data)}catch(n){console.warn(`Failed to load image for ID ${t}`,n)}else a(i)},Yt=e=>{const t=qt(e);if(t)return t;const i=Kt(e);return i?(e=>{switch(e){case"standardDark":case"drivingDark":case"monoDark":case"satellite":return"dark";default:return"light"}})(i):"light"},Kt=e=>"string"==typeof e?e:"standard"===e?.type?e.id??"standardLight":void 0,qt=e=>Zt(e)?e.lightDarkTheme:void 0,Zt=e=>"object"==typeof e&&"custom"===e?.type,Xt=class e{constructor(e){this.options=e,this.sources=e.sourcesWithLayers}where(t,i){return new e({...this.options,config:i??this.options.config,scope:X(this.options.scope,this.resolveScope(t))})}resolveScope(e){if("function"==typeof e){const t=e,i=this.options.mapping;return{featureMatches:i?e=>t(i(e)):e=>t(e)}}const t=this.options.scopeResolver;if(!t)throw new Error("This module supports only feature predicates in events.where().");return t(e)}on(e,t){const{eventProxy:i,config:r,owner:s,scope:o}=this.options,a=this.toRegisteredHandler(t),n=[];for(const l of this.sources)i.addEventHandler(l,a,e,{config:r,owner:s,scope:o}),n.push(l);return()=>{for(const t of n)i.removeHandler(t,e,a)}}toRegisteredHandler(e){const{mapping:t,scope:i}=this.options,r=i?.featureMatches;if(!t&&!r)return e;const s=e=>t?t(e):e;return r?(t,i,o,a)=>{const n=(o.length?o:[t]).filter(e=>r(e));if(!n.length)return;const l=n.map(s);e(l[0],i,l,a)}:(t,i,r,o)=>e(s(t),i,r.map(s),o)}off(e){for(const t of this.sources)this.options.eventProxy.remove(t,e,this.options.owner)}},Jt=class e{static{this.instanceCounters=/* @__PURE__ */new WeakMap}constructor(t,i){this._initializing=!0,this.configChangeHandlers=[],this.moduleReady=!1;const r=new.target,s=e.instanceCounters.get(r)??-1;this.instanceIndex=s+1,e.instanceCounters.set(r,this.instanceIndex),this.tomtomMap=t,this.eventsProxy=t._eventsProxy,this.mapLibreMap=t.mapLibreMap,this.filterComposer=de.for(t),this.initSourcesWithLayers(i),this.applyConfig(i),this.tomtomMap.addStyleChangeHandler({onStyleAboutToChange:()=>{this.moduleReady=!1},onStyleChanged:({resetState:e})=>e?this.resetOnNewStyle():this.restoreDataAndConfig(),priority:this.styleChangePriority()}),this._initializing=!1}styleChangePriority(){return 0}initSourcesWithLayers(e,t){this.moduleReady=!1,this.sourcesWithLayers=this._initSourcesWithLayers(e,t),this._sourceAndLayerIDs=Object.fromEntries(Object.entries(this.sourcesWithLayers).map(([e,t])=>[e,t.sourceAndLayerIDs])),t&&this.eventsProxy.updateIfRegistered(this.sourcesWithLayers,this),this.tomtomMap.mapReady&&(this.moduleReady=!0)}async waitUntilModuleReady(){await Pt(this.tomtomMap),this.moduleReady||await new Promise(e=>{const t=setInterval(()=>{this.tomtomMap.mapReady&&this.moduleReady&&(clearInterval(t),e())},200)})}applyConfig(e){this.config=this._applyConfig(e),this.emitConfigChange()}updateConfig(e){this.applyConfig({...this.config,...e})}emitConfigChange(){if(!this._initializing)for(const e of this.configChangeHandlers)e(this.config)}resetConfig(){this.applyConfig(void 0)}restoreDataAndConfig(){this.moduleReady=!1,this.restoreDataAndConfigImpl()}resetOnNewStyle(){this.moduleReady=!1,this.config=void 0,this.discardShownData(),this.initSourcesWithLayers(void 0,!0),this.config=this._applyConfig(void 0),this.emitConfigChange()}discardShownData(){}restoreDataAndConfigImpl(){this.initSourcesWithLayers(this.config,!0),this._applyConfig(this.config)}getConfig(){return this.config&&{...this.config}}get sourceAndLayerIDs(){return this._sourceAndLayerIDs}userEvents(e,t={}){return new Xt({eventProxy:this.eventsProxy,sourcesWithLayers:e.map(e=>this.sourcesWithLayers[e]).filter(e=>!!e),owner:this,config:this.config?.events,mapping:t.mapping,scopeResolver:t.scopeResolver})}lifecycleEvents(){return new pe(this.configChangeHandlers,[])}moduleEvents(e,t={}){return new q(this.userEvents(e,t),this.lifecycleEvents())}moduleEventsWithShown(e,t,i={}){return new q(this.userEvents(e,i),new pe(this.configChangeHandlers,t))}buildEvents(e,t){return ee(Object.keys(t),this.constructor.name),Object.assign(e,t)}},Qt=class extends Jt{},ei=class extends Jt{},ti=class{constructor(){this.interactiveLayerIDs=[],this.handlers={click:{},contextmenu:{},hover:{},"hover-move":{},"long-hover":{}},this.findHandlers=(e,t,i)=>t&&e.flatMap(e=>{const r=this.handlers[e][t]??[];return i?r.filter(e=>!e.scope?.featureMatches||e.scope.featureMatches(i)):r})||[]}ensureInteractiveLayerIDsAdded(e){for(const t of e)this.interactiveLayerIDs.includes(t)||this.interactiveLayerIDs.push(t)}releaseUnusedInteractiveLayerIDs(e){n(this.interactiveLayerIDs,t=>e.has(t)&&!this.hasHandlerForLayer(t))}indexHandler(e,t){const i=this.handlers[t];for(const r of e.layerIDs)i[r]??=[],i[r].push(e)}unindexHandlers(e,t){const i=this.handlers[t],r=/* @__PURE__ */new Set;for(const s of e)for(const t of s.layerIDs){r.add(t);const s=i[t];s&&(n(s,t=>e.has(t)),s.length||delete i[t])}return r}dropHandlers(e,t,i){const r=e.source.id,s=/* @__PURE__ */new Set;for(const o of Object.values(this.handlers[t]))for(const e of o)e.sourceWithLayers.source.id===r&&i(e)&&s.add(e);s.size&&this.releaseUnusedInteractiveLayerIDs(this.unindexHandlers(s,t))}addEventHandler(e,t,i,r){const s=new Set(J(e,r.scope).map(e=>e.id));this.ensureInteractiveLayerIDsAdded(s),this.indexHandler({...r,sourceWithLayers:e,layerIDs:s,fn:t},i)}removeHandler(e,t,i){this.dropHandlers(e,t,e=>e.fn===i)}remove(e,t,i){this.dropHandlers(e,t,e=>e.owner===i)}removeAll(){this.interactiveLayerIDs=[],this.handlers={click:{},contextmenu:{},hover:{},"hover-move":{},"long-hover":{}}}hasHandlerForLayer(e){return Object.values(this.handlers).some(t=>!!t[e]?.length)}sourceWithLayersFor(e){if(e)for(const t of Object.values(this.handlers)){const i=t[e];if(i?.length)return i[0].sourceWithLayers}}updateIfRegistered(e,t){const i=new Map(Object.values(e).map(e=>[e.source.id,e]));for(const r of Object.keys(this.handlers)){const e=/* @__PURE__ */new Set;for(const o of Object.values(this.handlers[r]))for(const r of o)r.owner===t&&i.has(r.sourceWithLayers.source.id)&&e.add(r);if(!e.size)continue;const s=this.unindexHandlers(e,r);for(const t of e){const e=i.get(t.sourceWithLayers.source.id);t.sourceWithLayers=e,t.layerIDs=new Set(J(e,t.scope).map(e=>e.id)),this.ensureInteractiveLayerIDsAdded(t.layerIDs),this.indexHandler(t,r)}this.releaseUnusedInteractiveLayerIDs(s)}}},ii=e=>{const t=e.properties?.id;return"string"==typeof t||"number"==typeof t?t:e.id},ri=(e,t)=>{if(null!=t)for(let i=0;i<e.length;i++)if(ii(e[i])===t)return{feature:e[i],index:i}};var si,oi,ai,ni=e=>(function(e){if(i(e))throw new Error(`${e} must not be null/undefined. Something went wrong with its initialization.`)}(e),e),li=class{constructor(e,t,i){this.id=e,this.spec=t,this.runtimeSource=i}ensureAddedToMap(e){this.runtimeSource||(!e.getSource(this.id)&&this.spec&&e.addSource(this.id,this.spec),this.runtimeSource=e.getSource(this.id))}},ci=class{constructor(e,t,i){this.map=e,this.source=t,this._layerSpecs=i,this._updateSourceAndLayerIDs()}get mapRemoved(){return!0===this.map._removed}isAnyLayerVisible(e){return this.getLayerSpecs(e).some(e=>this.isLayerVisible(e))}areAllLayersVisible(e){return this.getLayerSpecs(e).every(e=>this.isLayerVisible(e))}getLayerSpecs(e){return e?this._layerSpecs.filter(e):this._layerSpecs}_updateSourceAndLayerIDs(){this._sourceAndLayerIDs={sourceID:this.source.id,layerIDs:this._layerSpecs.map(e=>e.id)}}isLayerVisible(e){return!this.mapRemoved&&(!!this.map.getLayer(e.id)&&"none"!==this.map.getLayoutProperty(e.id,"visibility"))}setLayersVisible(e,t){if(!this.mapRemoved)for(const i of this.getLayerSpecs(t))this.map.getLayer(i.id)&&this.map.setLayoutProperty(i.id,"visibility",e?"visible":"none",{validate:!1})}get sourceAndLayerIDs(){return this._sourceAndLayerIDs}},hi=(e,t)=>e.getStyle().layers.filter(e=>t.includes(e?.source)),ui=class extends ci{constructor(e,t,i){let r=hi(e,[t.id]);i&&(r=r.filter(i)),super(e,new li(t.id,e.getStyle().sources[t.id],t),r)}},di=class extends ci{constructor(e,t,i,r){super(e,new li(t,i),r.map(e=>({...e,source:t})))}ensureLayersAddedToMap(){if(!this.mapRemoved)for(const e of this._layerSpecs)this.map.getLayer(e.id)||this.map.addLayer(e,e.beforeID)}ensureAddedToMapWithVisibility(e,t){this.mapRemoved||(this.source.ensureAddedToMap(this.map),t&&(this.ensureLayersAddedToMap(),this.setLayersVisible(e)))}},pi={type:"FeatureCollection",features:[]},yi=class extends di{constructor(e,t,i,r=!0,s){super(e,t,s?.cluster?{type:"geojson",data:pi,...s}:{type:"geojson",data:pi,promoteId:"id",...s??{}},i),this.shownFeatures=pi,this.showListeners=[],this.ensureAddedToMapWithVisibility(!1,r)}show(e,{automaticVisibility:t=!0}={}){if(this.shownFeatures=e,!this.mapRemoved){ni(this.source.runtimeSource).setData(e),t&&this.setLayersVisible(!!e.features.length);for(const e of this.showListeners)e()}}onShow(e){this.showListeners.push(e)}findById(e){return ri(this.shownFeatures.features,e)}clear(){this.show(pi)}findFeature(e){return"index"in e?this.shownFeatures.features[e.index]:"id"in e?this.findById(e.id)?.feature:void 0}putEventState(e){if("put"===(e.mode??"put"))for(const i of this.shownFeatures.features)i.properties?.eventState===e.state&&delete i.properties.eventState;const t=this.findFeature(e);t&&(t.properties={...t.properties,eventState:e.state}),!1!==e.show&&this.show(this.shownFeatures,{automaticVisibility:!1})}cleanEventState(e){const t=this.findFeature(e);t?.properties?.eventState&&(delete t?.properties?.eventState,!1!==e?.show&&this.show(this.shownFeatures,{automaticVisibility:!1}))}cleanEventStates(e){let t=!1;for(const i of this.shownFeatures.features)e?.states&&!e.states.includes(i.properties?.eventState)||(delete i.properties?.eventState,t=!0);!1!==e?.show&&t&&this.show(this.shownFeatures,{automaticVisibility:!1})}},fi=e=>"click"===e||"contextmenu"===e,mi=(e,t,i,r="updateInProps")=>{const{feature:s,index:a}=ri(i,t)||{};if(s&&((e,t)=>{return"recently-hovered"===t?"hover"===(i=e)||"long-hover"===i:!fi(e)||fi(t);var i})(s.properties?.eventState,e)){const t={...s,properties:"updateInProps"===r?{...s?.properties,eventState:e}:o(s?.properties,"eventState")};return i.splice(a,1,t),a}},gi=(e,t,i,r)=>r?mi("recently-hovered",t,i):mi(e,t,i,"removeFromProps"),_i=(e,t,r,s)=>{const o=[...r.shownFeatures.features],a=gi(e,ii(t),o,s);i(a)||r.show({...r.shownFeatures,features:o},{automaticVisibility:!1})},Li=(e,t,i,r,s,o=!1)=>{if(t&&r instanceof yi){const l=[...r.shownFeatures.features];return mi(e,ii(t),l),!i||(n=t,(a=i)&&n&&a.id===n.id)||(s===r?gi(e,ii(i),l,o):s instanceof yi&&_i(e,i,s,o)),void r.show({...r.shownFeatures,features:l},{automaticVisibility:!1})}var a,n;i&&s instanceof yi&&_i(e,i,s,o)},bi=[],Si=["hover","hover-move","long-hover","click","contextmenu"],Ii={precisionMode:"box",paddingBoxPx:5,cursorOnHover:"pointer",cursorOnMouseDown:"grabbing",cursorOnMap:"default",longHoverDelayAfterMapMoveMS:800,longHoverDelayOnStillMapMS:300,hoverGracePeriodMS:400},Ai=class extends ti{constructor(e,t={}){super(),this.enabled=!0,this.recentHoverTimeouts=new globalThis.Map,this.firstDelayedHoverSinceMapMove=!0,this.mouseMoveFrameRequested=!1,this.map=e,this.mapCanvas=e.getCanvas(),this.config={...Ii,...a(t,r)},this.mapCanvas.style.cursor=this.config.cursorOnMap,this.lastCursorStyle=this.config.cursorOnMap,this.listenToEvents()}updateConfig(e){this.config={...this.config,...a(e,r)},this.hoveringFeature||(this.mapCanvas.style.cursor=this.config.cursorOnMap)}listenToEvents(){this.map.on("mousemove",e=>this.onMouseMove(e)),this.map.on("movestart",()=>this.onMouseStart()),this.map.on("mouseout",()=>this.onMouseOut()),this.map.on("mouseover",e=>this.onMouseMove(e)),this.map.on("mousedown",()=>this.onMouseDown()),this.map.on("mouseup",()=>this.onMouseUp()),this.map.on("click",e=>this.onMapClick("click",e)),this.map.on("contextmenu",e=>this.onMapClick("contextmenu",e))}enable(e){this.enabled=e,e||(this.clearLongHoverTimeout(),this.pendingMouseMove=void 0)}toPaddedBounds(e){const t=this.config.paddingBoxPx;return[[e.x-t,e.y+t],[e.x+t,e.y-t]]}isEnabled(){return this.enabled&&!this.map.isMoving()}toCallerFeatures(e,t,i){const r=i?e.filter(e=>i.has(e.layer.id)):e,s=(e=>{const t=/* @__PURE__ */new Set,i=[];for(const r of e){const e=ii(r);if(void 0===e){i.push(r);continue}const s=`${r.source} ${e}`;t.has(s)||(t.add(s),i.push(r))}return i})((o=r,a=t?.source,a?o.filter(e=>e.source===a):o));var o,a;const n=this.sourceWithLayersFor(t?.layer.id);return n instanceof yi?s.map(e=>n.findById(ii(e))?.feature??e):s}callerFeaturesFor(e,t,i,r){return e.scope?.layerFilter?this.toCallerFeatures(t,i,e.layerIDs):r}getRenderedFeatures(e){if(!this.interactiveLayerIDs.length)return[];const t={layers:this.interactiveLayerIDs,validate:!1},i=this.config.precisionMode,r="point-then-box"===i||"point"===i?this.map.queryRenderedFeatures(e,t):[];return r.length||"point"===i?r:this.map.queryRenderedFeatures(this.toPaddedBounds(e),t)}clearLongHoverTimeout(){clearTimeout(this.longHoverTimeoutHandlerID)}restartLongHoverTimeout(){this.clearLongHoverTimeout(),this.longHoverTimeoutHandlerID=setTimeout(()=>this.handleLongHoverTimeout(),this.firstDelayedHoverSinceMapMove?this.config.longHoverDelayAfterMapMoveMS:this.config.longHoverDelayOnStillMapMS)}handleLongHoverTimeout(){if(this.firstDelayedHoverSinceMapMove=!1,this.hoveringSourceWithLayers){Li("long-hover",this.hoveringFeature,void 0,this.hoveringSourceWithLayers,void 0);const e=this.findHandlers(["long-hover"],this.hoveringFeature?.layer.id);if(e.length){const t=this.hoveringFeatures??bi,i=this.hoveringFeature,r=this.toCallerFeatures(t,i);for(const s of e){const e=this.callerFeaturesFor(s,t,i,r);s.fn(e[0],this.hoveringLngLat,e,s.sourceWithLayers)}}}}onMouseStart(){this.firstDelayedHoverSinceMapMove=!0,this.clearLongHoverTimeout()}onMouseOut(){this.clearLongHoverTimeout()}onMouseDown(){this.lastCursorStyle=this.mapCanvas.style.cursor,this.mapCanvas.style.cursor=this.config.cursorOnMouseDown}onMouseUp(){this.mapCanvas.style.cursor=this.lastCursorStyle}onMouseMove(e){this.pendingMouseMove=e,this.mouseMoveFrameRequested||(this.mouseMoveFrameRequested=!0,requestAnimationFrame(()=>{this.mouseMoveFrameRequested=!1;const e=this.pendingMouseMove;this.pendingMouseMove=void 0,e&&this.handleMouseMove(e)}))}handleMouseMove(e){if(!this.isEnabled())return;this.hoveringFeatures=this.getRenderedFeatures(e.point);const[t]=this.hoveringFeatures;if(t&&!this.hasHandlerForLayer(t.layer.id))return;const{hoverChanged:i,mouseInMotionOverHoveredFeature:r}=((e,t,i,r)=>{if(t){if(!r)return{hoverChanged:!0};if(t.id&&t.id!==r.id||t.properties.id&&t.properties.id!==r.properties.id||t.source!==r.source||t.layer.id!==r.layer.id)return{hoverChanged:!0};if(i&&(e.x-i.x!=0||e.y-i.y!=0))return{mouseInMotionOverHoveredFeature:!0}}else if(r)return{hoverChanged:!0};return{}})(e.point,t,this.hoveringPoint,this.hoveringFeature);if(!i&&!r)return;const s=this.hoveringFeature,o=this.hoveringSourceWithLayers;let a;this.hoveringLngLat=e.lngLat,this.hoveringPoint=e.point,this.hoveringFeature=t,this.hoveringSourceWithLayers=this.sourceWithLayersFor(t?.layer.id),i&&(a=this.dispatchHoverEnter(e,s,o)),r&&this.dispatchHoverMove(e,a),this.restartLongHoverTimeout()}dispatchHoverEnter(e,t,i){const r=this.hoveringFeature?.layer.id,s=this.findHandlers(Si,r,this.hoveringFeature)?.[0];this.updateHoverCursor(s?.config);const o=t?this.hoverGracePeriodFor(t):0;Li("hover",this.hoveringFeature,t,this.hoveringSourceWithLayers,i,o>0),t&&o>0&&this.clearRecentHoverLater(t,o);const a=this.findHandlers(["hover"],r);if(!a.length)return;const n=this.toCallerFeatures(this.hoveringFeatures??bi,this.hoveringFeature);return this.dispatchToHandlers(a,e,this.hoveringFeature,n),n}dispatchHoverMove(e,t){const i=this.findHandlers(["hover-move"],this.hoveringFeature?.layer.id);if(!i.length)return;const r=this.hoveringFeature,s=t??this.toCallerFeatures(this.hoveringFeatures??bi,r);this.dispatchToHandlers(i,e,r,s)}dispatchToHandlers(e,t,i,r){for(const s of e){const e=this.callerFeaturesFor(s,this.hoveringFeatures??bi,i,r);s.fn(e[0],t.lngLat,e,s.sourceWithLayers)}}hoverGracePeriodFor(e){return this.findHandlers(Si,e.layer.id,e)[0]?.config?.hoverGracePeriodMS??this.config.hoverGracePeriodMS}clearRecentHoverLater(e,t){const i=ii(e);if(void 0===i)return;const r=`${e.source} ${i}`,s=e.layer.id;clearTimeout(this.recentHoverTimeouts.get(r)),this.recentHoverTimeouts.set(r,setTimeout(()=>{this.recentHoverTimeouts.delete(r);const e=this.sourceWithLayersFor(s);e instanceof yi&&((e,t)=>{const i=e.findById(t);"recently-hovered"===i?.feature.properties?.eventState&&e.cleanEventState({index:i.index})})(e,i)},t))}updateHoverCursor(e){this.hoveringFeature?this.mapCanvas.style.cursor=e?.cursorOnHover??this.config.cursorOnHover:this.mapCanvas.style.cursor=this.config.cursorOnMap}onMapClick(e,t){if(!this.isEnabled())return;const i=this.getRenderedFeatures(t.point),r=this.lastClickedFeature;this.lastClickedFeature=i[0];const s=this.lastClickedSourceWithLayers,o=this.findHandlers([e],this.lastClickedFeature?.layer.id);if(this.lastClickedSourceWithLayers=o[0]?.sourceWithLayers,Li(e,this.lastClickedFeature,r,this.lastClickedSourceWithLayers,s),o.length){const e=this.lastClickedFeature,r=this.toCallerFeatures(i,e);for(const s of o){const o=this.callerFeaturesFor(s,i,e,r);s.fn(o[0],t.lngLat,o,s.sourceWithLayers)}}}},Ei="Noto-Bold",vi="Noto-Regular",Ri="Noto-Medium",Ti="NotoSans-MediumItalic",Ci=["interpolate",["linear"],["zoom"],10,14,18,16],wi=[vi,Ti,Ei,Ri],Oi=.8,Mi=["interpolate",["linear"],["zoom"],8,.6,22,Oi],Ni={country:"Places - Country name",lowestPlaceLabel:"Places - Village / Hamlet",poi:"POI",lowestLabel:"Borders - Treaty label",lowestRoadLine:"Tunnel - Railway outline",lowestBuilding:"Buildings - Underground"},xi="vectorTiles",Di="hillshade",Fi="hillshade-terrain",Pi="vectorTiles",ki="vectorTilesIncidents",Ui="vectorTilesFlow",Hi=/* @__PURE__ */new WeakMap,Wi=async(e,t,i,r)=>{let s=Hi.get(e);s||(s=/* @__PURE__ */new Map,Hi.set(e,s));const o=s.get(t);if(o){const e=await o;return r?.(e),e}const a=Promise.resolve().then(i);s.set(t,a);try{return await a}catch(n){throw s.delete(t),n}},Gi=["only","all-except"],Bi=["POI","POI - Micro"],Vi={ABORIGINAL_LAND:"aboriginal_land",AIRPORT:"airport",AMUSEMENT_PARK:"amusement_park",ATM:"atm",BANK:"bank",BAR:"bar",BEACH:"beach_resort",TRANSPORT_ACCESS:"border_control",BORDER_CONTROL:"border_control",BUS_STOP:"bus_station",CAFE:"cafe",CAFE_PUB:"cafe",CAMPING_GROUND:"camping_ground",CAR_RENTAL:"car_rental",CASINO_AND_GAMBLING:"casino_and_gambling",CEMETERY:"cemetery",CHARGING_LOCATION:"charging_location",CINEMA:"cinema",MOVIE_THEATER:"cinema",HEALTHCARE_SERVICE:"clinic",CLOTHING_SHOP:"clothing_shop",COFFEE_SHOP:"coffee_shop",COLLEGE_OR_UNIVERSITY:"college_or_university",AGRICULTURE:"commercial_area",BUSINESS_PARK:"commercial_area",COMMERCIAL_BUILDING:"commercial_area",COMPANY:"commercial_area",RESIDENTIAL_ACCOMMODATION:"commercial_area",RESIDENTIAL_ENTRANCE:"commercial_area",EXHIBITION_CONVENTION_CENTER:"conference_center",CLUB_AND_ASSOCIATION:"consumer_service",PUBLIC_AMENITY:"consumer_service",PEDESTRIAN_SUBWAY:"consumer_service",WELFARE_ORGANIZATION:"consumer_service",COURTHOUSE:"courthouse",COMMUNITY_CENTER:"cultural_center",CULTURAL_CENTER:"cultural_center",DENTIST:"dentist",DEPARTMENT_STORE:"department_store",DOCTOR:"doctor",EMERGENCY_MEDICAL_SERVICE:"emergency_ward_entrance",EMERGENCY_ROOM:"emergency_ward_entrance",FAST_FOOD:"fast_food",FERRY_TERMINAL:"ferry_terminal",FIRE_STATION:"fire_station",FITNESS_CLUB_AND_CENTER:"fitness_center",WINERY:"food_and_drinks_shop",FOREIGN_EXCHANGE:"foreign_exchange",EXCHANGE:"foreign_exchange",FUEL_STATION:"fuel_station",GOLD_EXCHANGE:"gold_exchange",GOLF_COURSE:"golf_course",EMBASSY:"government_office",GOVERNMENT_OFFICE:"government_office",HELIPORT_OR_HELIPAD:"heliport_or_helipad",HISTORIC_SITE:"historic_site",HOLIDAY_RENTAL:"holiday_home",GENERAL_HOSPITAL_AND_POLYCLINIC:"hospital",HOSPITAL:"hospital",HOTEL_OR_MOTEL:"hotel_or_motel",ICE_RINK:"ice_rink",INDUSTRIAL_BUILDING:"industrial_area",PORT_WAREHOUSE_FACILITY:"industrial_area",PRIMARY_RESOURCE_UTILITY:"industrial_area",NATURAL_FEATURE:"landmark",MALL:"mall",MANUFACTURING_FACILITY:"manufacturing_facility",MARINA:"marina",MARKETPLACE:"marketplace",MEDIA_FACILITY:"media_facility",MOUNTAIN_PASS:"mountain_pass",MUSEUM:"museum",NON_GOVERNMENTAL_ORGANIZATION:"ngo_office",CONCERT_HALL:"nightlife",ENTERTAINMENT:"nightlife",NIGHTLIFE:"nightlife",PARK_AND_RECREATION_AREA:"park_and_recreation_area",TRAIL_SYSTEM:"park_and_recreation_area",LEISURE_CENTER:"park_and_recreation_facility",FLYING_CLUB:"park_and_recreation_facility",WATER_SPORT:"park_and_recreation_facility",PARKING_GARAGE:"parking_facility",PHARMACY:"pharmacy",POLICE_STATION:"police_station",POST_OFFICE:"post_office",PRISON:"prison",PROTECTED_LAND:"protected_land",PUB:"pub",PUBLIC_LIBRARY:"public_library",PUBLIC_TRANSPORT_STOP:"public_transport_stop",RAILWAY_STATION:"railway_station",CHURCH:"religious_site",GURUDWARA:"religious_site",MOSQUE:"religious_site",PAGODA:"religious_site",RELIGIOUS_SITE:"religious_site",SYNAGOG:"religious_site",TEMPLE:"religious_site",RENTAL_CAR_PARKING:"rental_car_parking",RESEARCH_FACILITY:"research_facility",REST_AREA:"rest_and_service_area",RESTAURANT:"restaurant",RESTAURANT_AREA:"restaurant",SCHOOL:"school_or_kindergarten",SHOP_OR_STORE:"shop_or_store",ADVENTURE_SPORTS_FACILITY:"sport_facility",SPORTS_CENTER:"sport_facility",TENNIS_COURT:"sport_facility",STADIUM:"stadium",SUPERMARKET:"supermarket",SWIMMING_POOL:"swimming_pool",TAXI_STAND:"taxi_stand",OPERA_HOUSE:"theater",THEATER:"theater",TOLL_GATE:"toll_plaza",TOURIST_ATTRACTION:"tourist_attraction",TOURIST_INFORMATION:"tourist_information",TRUCK_STOP:"truck_stop",VEHICLE_DEALER:"vehicle_dealer",MOTORING_ORGANIZATION_OFFICE:"vehicle_inspection",TRAFFIC_CONTROL_DEPARTMENT:"vehicle_inspection",TRANSPORT_AUTHORITY_VEHICLE_REGISTRATION:"vehicle_inspection",VEHICLE_REPAIR:"vehicle_repair",CAR_WASH:"vehicle_wash",VETERINARY:"veterinary",HILL:"viewpoint",MOUNTAIN_PEAK:"viewpoint",VIEWPOINT:"viewpoint",WEIGH_STATION:"weighbridge",AQUATIC_ZOO:"zoo_or_aquarium",ARBORETA_AND_BOTANICAL_GARDENS:"zoo_or_aquarium",ZOOS_ARBORETA_BOTANICAL_GARDEN:"zoo_or_aquarium"},zi={...Vi,AIRFIELD:"airport",AIRLINE_ACCESS:"airport",PRIVATE_AIRPORT:"airport",PUBLIC_AIRPORT:"airport",ANIMAL_SHELTER:"animal_shelter",DIVERSIFIED_FINANCIALS:"bank",COCKTAIL_BAR:"bar",BEACH_CLUB:"beach_resort",SECURED_ENTRANCE:"border_control",INTERNET_CAFE:"cafe",CAFETERIA:"cafeteria",CARAVAN_SITE:"camping_ground",RECREATIONAL_CAMPING_GROUND:"camping_ground",REST_CAMP:"camping_ground",MAUSOLEUM_OR_GRAVE:"cemetery",CHILDCARE:"childcare",PRE_SCHOOL:"childcare",DRIVE_IN_MOVIES:"cinema",CHILDREN_S_CLOTHES:"clothing_shop",MEN_S_CLOTHING:"clothing_shop",SPECIALTY_CLOTHING_SHOP:"clothing_shop",WOMEN_S_CLOTHING:"clothing_shop",JUNIOR_COLLEGE_OR_COMMUNITY_COLLEGE:"college_or_university",COMEDY_CLUB:"comedy_club",ADVERTISING_COMPANY:"commercial_area",AGRICULTURAL_TECHNOLOGY:"commercial_area",AIRLINE_COMPANY:"commercial_area",APARTMENT_RENTAL:"commercial_area",AUTOMOBILE_COMPANY:"commercial_area",BUILDING:"commercial_area",BUSINESS_SERVICES:"commercial_area",BUS_CHARTER_COMPANY:"commercial_area",CABLE_AND_TELEPHONE_COMPANY:"commercial_area",CLEANING_SERVICES:"commercial_area",COMPUTER_AND_DATA_SERVICES:"commercial_area",CONSTRUCTION_COMPANY:"commercial_area",DELIVERY_SERVICE:"commercial_area",ELECTRONICS_COMPANY:"commercial_area",EQUIPMENT_RENTAL:"commercial_area",FARM:"commercial_area",FLATS_OR_APARTMENT_COMPLEX:"commercial_area",HORTICULTURE:"commercial_area",IMPORT_OR_EXPORT_AND_DISTRIBUTION:"commercial_area",INSURANCE_COMPANY:"commercial_area",INVESTMENT_ADVISOR:"commercial_area",LEGAL_SERVICES:"commercial_area",MINING_COMPANY:"commercial_area",MOVING_AND_STORAGE_COMPANY:"commercial_area",OIL_AND_NATURAL_GAS:"commercial_area",PHARMACEUTICAL_COMPANY:"commercial_area",PRIMARY_PRODUCER:"commercial_area",PUBLISHING_TECHNOLOGIES:"commercial_area",REAL_ESTATE_AGENT:"commercial_area",REAL_ESTATE_COMPANY:"commercial_area",RETIREMENT_COMMUNITY:"commercial_area",SCHOOL_BUS_COMPANY:"commercial_area",SERVICE_COMPANY:"commercial_area",SOFTWARE_COMPANY:"commercial_area",TAX_SERVICES:"commercial_area",TELECOMMUNICATIONS:"commercial_area",TRANSPORT_COMPANY:"commercial_area",TRAVEL_AGENT:"commercial_area",WEDDING_SERVICES:"commercial_area",PUBLIC_CALL_BOX:"consumer_service",PUBLIC_BATHROOM:"consumer_service",GENERAL_PRACTITIONER:"doctor",SPECIALIST:"doctor",AMBULANCE_UNIT:"emergency_ward_entrance",RESCUE_SERVICE:"emergency_ward_entrance",MICROBREWERY:"food_and_drinks_shop",BATTLEFIELD:"historic_site",MEMORIAL:"historic_site",BUNGALOW_RENTAL:"holiday_home",CHALET_RENTAL:"holiday_home",COTTAGE_RENTAL:"holiday_home",VILLA_RENTAL:"holiday_home",HORSE_RIDING:"horse_riding",BLOOD_BANK:"hospital",HOSPITAL_FOR_WOMEN_AND_CHILDREN:"hospital",HOSPITAL_OF_CHINESE_MEDICINE:"hospital",SPECIAL_HOSPITAL:"hospital",BANDB_OR_GUEST_HOUSE:"hotel_or_motel",CABINS_LODGES:"hotel_or_motel",HOSTEL:"hotel_or_motel",HOTEL:"hotel_or_motel",MOTEL:"hotel_or_motel",RESORT:"hotel_or_motel",ICE_CREAM_PARLOR:"ice_cream_shop",ICE_HOCKEY_ARENA:"ice_rink",CHEMICAL_COMPANY:"industrial_area",MECHANICAL_ENGINEERING:"industrial_area",QUARRY:"industrial_area",JUICE_BAR:"juice_bar",ARCH:"landmark",BAY:"landmark",BRIDGE:"landmark",CAPE:"landmark",COVE:"landmark",DAM:"landmark",DUNE:"landmark",ISLAND:"landmark",LOCALE:"landmark",MARSH:"landmark",MONUMENT:"landmark",OASIS:"landmark",OBSERVATORY:"landmark",PARKWAY:"landmark",PLAIN_OR_FLAT:"landmark",PLATEAU:"landmark",PAN:"landmark",RAPIDS:"landmark",REEF:"landmark",RESERVOIR:"landmark",RIVER_CROSSING:"landmark",ROCKS:"landmark",STATUE:"landmark",TOWER:"landmark",TUNNEL:"landmark",VALLEY:"landmark",WATER_HOLE:"landmark",WELL:"landmark",AUTOMOBILE_MANUFACTURING:"manufacturing_facility",MANUFACTURING_COMPANY:"manufacturing_facility",FARMERS_MARKET:"marketplace",FOOD_MARKET:"marketplace",INFORMAL_MARKET:"marketplace",PUBLIC_MARKET:"marketplace",MILITARY_AIRPORT:"military_airfield",FUNERAL_SERVICE_AND_MORTUARIES:"mourning_facility",AMUSEMENT_PLACE:"nightlife",BETTING_STATION:"nightlife",CABARET_THEATER:"nightlife",DISCO_CLUB:"nightlife",FAIRGROUND:"nightlife",JAZZ_CLUB:"nightlife",KARAOKE_CLUB:"nightlife",MUSIC_CENTER:"nightlife",ADVENTURE_VEHICLE_TRAIL:"park_and_recreation_area",FISHING_AND_HUNTING_AREA:"park_and_recreation_area",FOREST_AREA:"park_and_recreation_area",HIKING_TRAIL:"park_and_recreation_area",HISTORICAL_PARK:"park_and_recreation_area",HORSE_RIDING_TRAIL:"park_and_recreation_area",MOUNTAIN_BIKE_TRAIL:"park_and_recreation_area",PARK:"park_and_recreation_area",PICNIC_AREA:"park_and_recreation_area",RECREATION_AREA:"park_and_recreation_area",ROCK_CLIMBING_TRAIL:"park_and_recreation_area",WILDERNESS_AREA:"park_and_recreation_area",OPEN_CAR_PARKING_AREA:"parking_facility",BEAUTY_SALON:"personal_care_service",HAIRDRESSER:"personal_care_service",NAIL_SALON:"personal_care_service",PERSONAL_CARE_FACILITY:"personal_care_service",PERSONAL_SERVICE:"personal_care_service",SAUNA_SOLARIUM_MASSAGE:"personal_care_service",DRUG_STORE:"pharmacy",CANNABIS_SHOP:"pharmacy",MEDICINAL_AND_RECREATIONAL_DISPENSARY:"pharmacy",MEDICINAL_MARIJUANA_DISPENSARY:"pharmacy",RECREATIONAL_MARIJUANA_DISPENSARY:"pharmacy",PLANETARIUM:"planetarium",COURIER_DROP_BOX:"post_depot",BUS_LINES:"public_transport_stop",PASSENGER_TRANSPORT_TICKET_OFFICE:"public_transport_stop",STREETCAR_STOP:"public_transport_stop",SUBWAY_STATION:"public_transport_stop",SUBWAY_ENTRANCE:"public_transport_stop",INTERNATIONAL_RAILROAD_STATION:"railway_station",NATIONAL_RAILROAD_STATION:"railway_station",STATION_ACCESS:"railway_station",URBAN_STATION:"railway_station",AFGHAN_RESTAURANT:"restaurant",AFRICAN_RESTAURANT:"restaurant",AMERICAN_RESTAURANT:"restaurant",ARABIAN_RESTAURANT:"restaurant",ARMENIAN_RESTAURANT:"restaurant",ASIAN_RESTAURANT:"restaurant",AUSTRALIAN_RESTAURANT:"restaurant",AUSTRIAN_RESTAURANT:"restaurant",BANQUET_ROOMS:"restaurant",BARBECUE_RESTAURANT:"restaurant",BASQUE_RESTAURANT:"restaurant",BELGIAN_RESTAURANT:"restaurant",BISTRO:"restaurant",BOLIVIAN_RESTAURANT:"restaurant",BRAZILIAN_RESTAURANT:"restaurant",BRITISH_RESTAURANT:"restaurant",BUFFET_RESTAURANT:"restaurant",BULGARIAN_RESTAURANT:"restaurant",BURMESE_RESTAURANT:"restaurant",CALIFORNIAN_RESTAURANT:"restaurant",CAMBODIAN_RESTAURANT:"restaurant",CANADIAN_RESTAURANT:"restaurant",CARIBBEAN_RESTAURANT:"restaurant",CATERING_SERVICES:"restaurant",CHICKEN_RESTAURANT:"restaurant",CHILEAN_RESTAURANT:"restaurant",CHINESE_RESTAURANT:"restaurant",COLOMBIAN_RESTAURANT:"restaurant",CORSICAN_RESTAURANT:"restaurant",CREOLE_RESTAURANT:"restaurant",CREPERIE:"restaurant",CUBAN_RESTAURANT:"restaurant",CZECH_RESTAURANT:"restaurant",DANISH_RESTAURANT:"restaurant",DINNER_THEATER:"restaurant",DONGBEI_RESTAURANT:"restaurant",DOUGHNUT_RESTAURANT:"restaurant",DUTCH_RESTAURANT:"restaurant",EGYPTIAN_RESTAURANT:"restaurant",ENGLISH_RESTAURANT:"restaurant",ETHIOPIAN_RESTAURANT:"restaurant",FINNISH_RESTAURANT:"restaurant",FONDUE_RESTAURANT:"restaurant",FRENCH_RESTAURANT:"restaurant",FUSION_RESTAURANT:"restaurant",GERMAN_RESTAURANT:"restaurant",GREEK_RESTAURANT:"restaurant",GRILL_RESTAURANT:"restaurant",HAMBURGER_RESTAURANT:"restaurant",HAWAIIAN_RESTAURANT:"restaurant",HOT_POT_RESTAURANT:"restaurant",HUNAN_RESTAURANT:"restaurant",HUNGARIAN_RESTAURANT:"restaurant",INDIAN_RESTAURANT:"restaurant",INDONESIAN_RESTAURANT:"restaurant",INTERNATIONAL_RESTAURANT:"restaurant",IRANIAN_RESTAURANT:"restaurant",IRISH_RESTAURANT:"restaurant",ISRAELI_RESTAURANT:"restaurant",ITALIAN_RESTAURANT:"restaurant",JAMAICAN_RESTAURANT:"restaurant",JAPANESE_RESTAURANT:"restaurant",JEWISH_RESTAURANT:"restaurant",KOREAN_RESTAURANT:"restaurant",KOSHER_RESTAURANT:"restaurant",LATIN_AMERICAN_RESTAURANT:"restaurant",LEBANESE_RESTAURANT:"restaurant",MEDITERRANEAN_RESTAURANT:"restaurant",MEXICAN_RESTAURANT:"restaurant",MIDDLE_EASTERN_RESTAURANT:"restaurant",MONGOLIAN_RESTAURANT:"restaurant",MOROCCAN_RESTAURANT:"restaurant",NEPALESE_RESTAURANT:"restaurant",NORWEGIAN_RESTAURANT:"restaurant",ORGANIC_FOOD_RESTAURANT:"restaurant",ORIENTAL_RESTAURANT:"restaurant",PAKISTANI_RESTAURANT:"restaurant",PERUVIAN_RESTAURANT:"restaurant",PHILIPPINE_RESTAURANT:"restaurant",PIZZERIA:"restaurant",POLISH_RESTAURANT:"restaurant",PORTUGUESE_RESTAURANT:"restaurant",RUSSIAN_RESTAURANT:"restaurant",SALAD_BAR:"restaurant",SANDWICH_RESTAURANT:"restaurant",SCANDINAVIAN_RESTAURANT:"restaurant",SEAFOOD:"restaurant",SHANDONG_RESTAURANT:"restaurant",SICHUAN_RESTAURANT:"restaurant",SNACKS_RESTAURANT:"restaurant",SOUL_FOOD:"restaurant",SOUP_RESTAURANT:"restaurant",SPANISH_RESTAURANT:"restaurant",STEAK_HOUSE:"restaurant",SUSHI_RESTAURANT:"restaurant",SWEDISH_RESTAURANT:"restaurant",SWISS_RESTAURANT:"restaurant",SYRIAN_RESTAURANT:"restaurant",TAIWANESE_RESTAURANT:"restaurant",TAKEOUT_FOOD:"restaurant",TAPAS_RESTAURANT:"restaurant",TEPPANYAKI_RESTAURANT:"restaurant",THAI_RESTAURANT:"restaurant",TIBETAN_RESTAURANT:"restaurant",TUNISIAN_RESTAURANT:"restaurant",TURKISH_RESTAURANT:"restaurant",VEGETARIAN_RESTAURANT:"restaurant",VENEZUELAN_RESTAURANT:"restaurant",VIETNAMESE_RESTAURANT:"restaurant",WESTERN_RESTAURANT:"restaurant",ART_SCHOOL:"school_or_kindergarten",DANCE_STUDIO_AND_SCHOOL:"school_or_kindergarten",DRIVING_SCHOOL:"school_or_kindergarten",HIGH_SCHOOL:"school_or_kindergarten",LANGUAGE_SCHOOL:"school_or_kindergarten",MIDDLE_SCHOOL:"school_or_kindergarten",PRIMARY_SCHOOL:"school_or_kindergarten",SENIOR_HIGH_SCHOOL:"school_or_kindergarten",VOCATIONAL_SCHOOL:"school_or_kindergarten",AGRICULTURAL_SUPPLIES:"shop_or_store",ANTIQUE_ART_SHOP:"shop_or_store",BAGS_LEATHERWEAR:"shop_or_store",BAKERY:"shop_or_store",BEAUTY_SUPPLIES:"shop_or_store",BOATING_EQUIPMENT_AND_ACCESSORIES:"shop_or_store",BOOK_SHOP:"shop_or_store",BUTCHER:"shop_or_store",CAMERAS_AND_PHOTOGRAPHY:"shop_or_store",CARPET_FLOOR_COVERINGS:"shop_or_store",CHRISTMAS_OR_HOLIDAY_SHOP:"shop_or_store",COMPUTER_AND_COMPUTER_SUPPLIES:"shop_or_store",CONSTRUCTION_MATERIAL_AND_EQUIPMENT:"shop_or_store",CONSUMER_ELECTRONICS:"shop_or_store",CONVENIENCE_STORE:"shop_or_store",CURTAINS_TEXTILES:"shop_or_store",C_DS_DVD_VIDEOS:"shop_or_store",DELICATESSEN:"shop_or_store",DO_IT_YOURSELF_CENTERS:"shop_or_store",DRIVE_THROUGH_BOTTLE_SHOP:"shop_or_store",DRY_CLEANER:"shop_or_store",ELECTRICAL_APPLIANCES_SHOP:"shop_or_store",FACTORY_OUTLET:"shop_or_store",FISHMONGER:"shop_or_store",FLORISTS:"shop_or_store",FOOTWEAR_SHOE_REPAIRS:"shop_or_store",FURNITURE_HOME_FURNISHINGS:"shop_or_store",GARDEN_CENTERS_SERVICES:"shop_or_store",GIFTS_CARDS_NOVELTIES_SOUVENIRS:"shop_or_store",GLASSWARE_CERAMIC_SHOP:"shop_or_store",GLASS_WINDOWS_STORE:"shop_or_store",GREENGROCER:"shop_or_store",GROCERY_STORE:"shop_or_store",HARDWARE_STORE:"shop_or_store",HOBBY_SHOP:"shop_or_store",HOUSE_AND_GARDEN_FURNITURE_AND_FITTINGS:"shop_or_store",JEWELRY_CLOCKS_WATCHES:"shop_or_store",KITCHENS_BATHROOMS:"shop_or_store",LAUNDRY:"shop_or_store",LIGHTING_SHOPS:"shop_or_store",LOCAL_SPECIALITIES_SHOP:"shop_or_store",LOTTERY_SHOP:"shop_or_store",MEDICAL_SUPPLIES_EQUIPMENT:"shop_or_store",MOBILE_PHONE_SHOP:"shop_or_store",MUSIC_INSTRUMENTS_STORE:"shop_or_store",NEWSAGENTS_TOBACCONISTS:"shop_or_store",OFFICE_EQUIPMENT:"shop_or_store",OPTICIAN:"shop_or_store",FOOD_AND_DRINKS_SHOP:"shop_or_store",PAINTING_DECORATING:"shop_or_store",PAWN_SHOP:"shop_or_store",PET_SUPPLIES:"shop_or_store",PHOTOCOPY_SHOP:"shop_or_store",PHOTO_LAB_OR_DEVELOPMENT:"shop_or_store",RECYCLING_SHOP:"shop_or_store",RETAIL_OUTLET:"shop_or_store",SECURITY_PRODUCTS:"shop_or_store",SHOPPING_SERVICE:"shop_or_store",SPECIALTY_FOODS:"shop_or_store",SPORTS_EQUIPMENT_AND_CLOTHING:"shop_or_store",TAILOR_SHOP:"shop_or_store",TOYS_GAMES_SHOP:"shop_or_store",VARIETY_STORE:"shop_or_store",VIDEO_RENTAL_SHOP:"shop_or_store",WHOLESALE_CLUB:"shop_or_store",WINE_SPIRITS:"shop_or_store",ATHLETICS_TRACK:"sport_facility",BASEBALL_PARK:"sport_facility",BASKETBALL_ARENA:"sport_facility",BOWLING_CENTER:"sport_facility",CRICKET_GROUND:"sport_facility",HOCKEY_CLUB:"sport_facility",HORSE_RACING_TRACK:"sport_facility",RACE_TRACK:"sport_facility",RUGBY_GROUND:"sport_facility",SQUASH_COURT:"sport_facility",THEMATIC_SPORT_CENTER:"sport_facility",FOOTBALL_STADIUM:"stadium",MOTOR_RACING_STADIUM:"stadium",MULTI_PURPOSE_STADIUM:"stadium",NETBALL_STADIUM:"stadium",SOCCER_STADIUM:"stadium",STOCK_EXCHANGE:"stock_exchange",TAXI_LIMOUSINE_AND_SHUTTLE_SERVICE:"taxi_stand",TEA_HOUSE:"tea_house",AMPHITHEATER:"theater",CAVE:"tourist_attraction",MINERAL_OR_HOT_SPRINGS:"tourist_attraction",NATURAL_TOURIST_ATTRACTION:"tourist_attraction",BOAT_LAUNCHING_RAMP:"transport_access",HARBOR:"transport_access",YACHT_BASIN:"transport_access",ATV_DEALER:"vehicle_dealer",BOAT_DEALER:"vehicle_dealer",BUS_DEALER:"vehicle_dealer",CAR_DEALER:"vehicle_dealer",MOTORCYCLE_DEALER:"vehicle_dealer",RECREATIONAL_VEHICLE_DEALER:"vehicle_dealer",TRUCK_DEALER:"vehicle_dealer",VAN_DEALER:"vehicle_dealer",BODYSHOP:"vehicle_repair",CAR_GLASS_REPLACEMENT_SHOP:"vehicle_repair",CAR_REPAIR_AND_SERVICE:"vehicle_repair",HOME_APPLIANCE_REPAIR:"vehicle_repair",MOTORCYCLE_REPAIR:"vehicle_repair",TIRE_SERVICE:"vehicle_repair",TRUCK_REPAIR_AND_SERVICE:"vehicle_repair",ANIMAL_SERVICE:"veterinary",RIDGE:"viewpoint",SKI_RESORT:"winter_sports",WILDLIFE_PARK:"zoo_or_aquarium",ZOO:"zoo_or_aquarium"},ji=e=>zi[e],$i=Array.from(new Set(Object.values(zi))),Yi={bar:"eat_and_drink",cafe:"eat_and_drink",cafeteria:"eat_and_drink",coffee_shop:"eat_and_drink",fast_food:"eat_and_drink",ice_cream_shop:"eat_and_drink",juice_bar:"eat_and_drink",pub:"eat_and_drink",restaurant:"eat_and_drink",tea_house:"eat_and_drink",clothing_shop:"shopping",department_store:"shopping",food_and_drinks_shop:"shopping",mall:"shopping",marketplace:"shopping",shop_or_store:"shopping",supermarket:"shopping",atm:"finance",bank:"finance",foreign_exchange:"finance",gold_exchange:"finance",stock_exchange:"finance",camping_ground:"lodging",holiday_home:"lodging",hotel_or_motel:"lodging",airport:"transport",bus_station:"transport",ferry_terminal:"transport",heliport_or_helipad:"transport",marina:"transport",public_transport_stop:"transport",railway_station:"transport",taxi_stand:"transport",transport_access:"transport",border_control:"driving",car_rental:"driving",charging_location:"driving",fuel_station:"driving",rest_and_service_area:"driving",toll_plaza:"driving",truck_stop:"driving",vehicle_dealer:"driving",vehicle_inspection:"driving",vehicle_repair:"driving",vehicle_wash:"driving",weighbridge:"driving",parking_facility:"parking",rental_car_parking:"parking",clinic:"healthcare",dentist:"healthcare",doctor:"healthcare",emergency_ward_entrance:"healthcare",hospital:"healthcare",pharmacy:"healthcare",veterinary:"healthcare",childcare:"education",college_or_university:"education",research_facility:"education",school_or_kindergarten:"education",cultural_center:"cultural",historic_site:"cultural",museum:"cultural",planetarium:"cultural",theater:"cultural",amusement_park:"leisure",beach_resort:"leisure",casino_and_gambling:"leisure",cinema:"leisure",comedy_club:"leisure",nightlife:"leisure",park_and_recreation_facility:"leisure",tourist_attraction:"leisure",tourist_information:"leisure",zoo_or_aquarium:"leisure",fitness_center:"sport",golf_course:"sport",horse_riding:"sport",ice_rink:"sport",sport_facility:"sport",stadium:"sport",swimming_pool:"sport",winter_sports:"sport",aboriginal_land:"outdoor",landmark:"outdoor",mountain_pass:"outdoor",park_and_recreation_area:"outdoor",viewpoint:"outdoor",protected_land:"protected",cemetery:"public",courthouse:"public",fire_station:"public",government_office:"public",police_station:"public",post_depot:"public",post_office:"public",prison:"public",public_library:"public",military_airfield:"military",religious_site:"religion",animal_shelter:"business",commercial_area:"business",conference_center:"business",consumer_service:"business",industrial_area:"business",manufacturing_facility:"business",media_facility:"business",mourning_facility:"business",ngo_office:"business",personal_care_service:"business"},Ki=e=>{const t=ji(e);return t?Yi[t]:void 0},qi="title",Zi="iconID",Xi=.7,Ji="default_place",Qi="poi-parking-micro",er={"icon-image":["get",Zi],"icon-anchor":"bottom","icon-size":Mi,"icon-allow-overlap":!0,"icon-padding":0},tr={"icon-translate":[0,5],"icon-translate-anchor":"viewport"},ir={"text-optional":!0,"text-font":[Ei],"text-field":["get",qi],"text-justify":"auto","text-variable-anchor":["top","left","right"],"text-variable-anchor-offset":["top",[0,Xi],"left",[1.4,-1.4],"right",[-1.4,-1.4]],"text-size":Ci,"text-padding":5},rr={"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"},sr={type:"symbol",layout:{...er,...ir},paint:{...tr,...rr}},or=(e,t)=>`${e}-${t}`,ar=(e,t)=>t?`${t}-${e}`:e,nr=(e,t)=>t?{...e,...t,...t.paint&&{paint:{...e.paint,...t.paint}},...t.layout&&{layout:{...e.layout,...t.layout}}}:e,lr=["has","point_count"],cr=["!",lr],hr="clusterBaseMapIconIDs",ur=["all",lr,["==",["index-of",",",["get",hr]],-1]],dr=["all",lr,[">=",["index-of",",",["get",hr]],0]],pr=[12,-14],yr={[hr]:(si="baseMapIconID",oi=hr,[["case",["==",["get",oi],null],["accumulated"],["==",["accumulated"],null],["get",oi],[">=",["index-of",["concat",",",["get",oi],","],["concat",",",["accumulated"],","]],0],["accumulated"],["concat",["accumulated"],",",["get",oi]]],["get",si]])},fr=e=>{const t=["match",e];for(const i of $i){const e=`poi-${i}`;t.push(e,["image",e])}return t.push(["image",Qi]),t},mr=e=>({lineColor:"dark"===e?"#5AB6F0":"#3f9cd9",labelColor:"dark"===e?"#A9D6F5":"#1a5f8a",labelHaloColor:"dark"===e?"#1a1a1a":"#ffffff"}),gr=["in",["get","eventState"],["literal",["click","contextmenu"]]],_r=["all",["has","eventState"],["!=",["get","eventState"],"recently-hovered"]],Lr=["==",["get","type"],"main"],br=(e,t)=>({type:"line",minzoom:t,filter:["==",["geometry-type"],"LineString"],layout:{"line-cap":"round"},paint:{"line-color":e,"line-width":1.5,"line-dasharray":[1,2],"line-opacity":.8}}),Sr=(e,t,i)=>({type:"circle",minzoom:i,filter:["==",["geometry-type"],"Point"],paint:{"circle-color":e,"circle-radius":["+",["case",Lr,5,3.5],["case",_r,1.5,0]],"circle-stroke-width":1.5,"circle-stroke-color":t}}),Ir=(e,t="light",i=0)=>{const{color:r,strokeColor:s}=(e=>{const{lineColor:t,labelColor:i,labelHaloColor:r}=mr(e);return{color:"dark"===e?t:i,strokeColor:r}})(t),o=Math.max(e?.minZoom??15,i);return{line:nr(br(r,o),e?.layers?.line),point:nr(Sr(r,s,o),e?.layers?.point)}},Ar=(e,t)=>{if(!e)return;const i=(e=>{try{if("string"==typeof e){if(e.includes("<svg")){const t=Dt(e),i=t.getAttribute("viewBox");if(i){const e=i.split(/\s+/);if(4===e.length)return{width:Number.parseFloat(e[2]),height:Number.parseFloat(e[3])}}const r=t.getAttribute("width"),s=t.getAttribute("height");if(r&&s)return{width:Number.parseFloat(r),height:Number.parseFloat(s)}}return null}return e.complete&&e.naturalWidth>0?{width:e.naturalWidth,height:e.naturalHeight}:null}catch(t){return console.warn("Failed to extract image dimensions:",t),null}})(e);if(!i)return;const r="base-map"===t||"circle-icon"===t,s=r?54:140,o=r?54:120;return{heightScale:i.height/s,widthScale:i.width/o}},Er=e=>{const t=["case"];for(const[i,r]of e)0===r.x&&0===r.y||t.push(["==",["get",Zi],i],["literal",[r.x,r.y]]);if(1!==t.length)return t.push(["literal",[0,0]]),t},vr=e=>Boolean(e&&"availability"in e&&e.availability),Rr=e=>"CHARGING_LOCATION"===e.properties.poi?.categories?.[0]&&vr(e.properties.chargingPark),Tr=e=>{const t=e.properties.chargingPark;if(vr(t)){const e=t.availability.chargingPointAvailability,i=e.statusCounts.Available??0;return{availableCount:i,totalCount:e.count,ratio:i/e.count}}},Cr=(e,t)=>`${e}/${t}`,wr=e=>Tr(e)?.ratio??0,Or=e=>["case",[">=",["get","evAvailabilityRatio"],e?.threshold??0],"green","red"],Mr=e=>Math.round(1e4*e)/1e4,Nr=(e,t,i,r)=>{const s=void 0!==r;return{top:s?[0,r]:[0,Mr(e)],left:s?[r,Mr(i)]:[Mr(t),Mr(i)],right:s?[-r,Mr(i)]:[-Mr(t),Mr(i)]}},xr=(e,t,i,r)=>{const s=(e=>{if(!e)return Oi;if("number"==typeof e)return e;if(Array.isArray(e)){const t=e.at(-1);if("number"==typeof t)return t}if("object"==typeof e&&"stops"in e){const t=e.stops;if(Array.isArray(t)&&t.length>0){const e=t.at(-1);if(Array.isArray(e)&&"number"==typeof e[1])return e[1]}}return Oi})(e)/Oi,o="base-map"===i||"circle-icon"===i;if(o&&void 0!==r)return{"text-offset":[r,r]};const a=1.4*s,n=Nr(Xi*s,a,o?0:-a,r),l=["top",n.top,"left",n.left,"right",n.right];if(0===t.size)return{"text-variable-anchor-offset":l};const c=["case"];for(const[h,u]of t.entries()){const e=(o?1.4:Xi)*u.heightScale*s,t=1.4*u.widthScale*s,i=Nr(e,t,o?0:-t,r);c.push(["==",["get",Zi],h],["literal",["top",i.top,"left",i.left,"right",i.right]])}return c.push(["literal",l]),{"text-variable-anchor-offset":c}},Dr=(e,t,i,r,s)=>{const o=t?.text,a=t?.layers?.[i],n=s&&s.size>0,l={...e.layout},c=n||void 0!==o?.offset||"circle-icon"===t?.theme;c&&(delete l["text-offset"],delete l["text-variable-anchor-offset"],delete l["text-radial-offset"]);const h={...l,...a?.layout,...o?.size&&{"text-size":o.size},...o?.font&&{"text-font":o.font},...void 0!==r&&{"text-field":r}};if(c){const e={...h,...xr(h["icon-size"],s??/* @__PURE__ */new Map,t?.theme,o?.offset)},r="micro"!==i&&s&&Er([...s].map(([e,{offset:t}])=>[e,t]));return r?{...e,"icon-offset":r}:e}return h},Fr=(e,t,i,r)=>{const s=t?.text,o=t?.layers?.[i],{textColor:a,haloColor:n}=(e=>({textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}))(r),l=e.paint??{};return{...l,...void 0===l["text-color"]&&{"text-color":a},...void 0===l["text-halo-color"]&&{"text-halo-color":n},...s?.color&&{"text-color":s.color},...s?.haloColor&&{"text-halo-color":s.haloColor},...s?.haloWidth&&{"text-halo-width":s.haloWidth},...o?.paint}},Pr=e=>JSON.parse(JSON.stringify(e)?.replaceAll("name",qi)),kr=(e,t)=>e.getStyle().layers.find(e=>e.id===t)??{},Ur=e=>({filter:["!",gr],type:"symbol",paint:e.paint,layout:e.layout?o(e.layout,"visibility"):void 0}),Hr=e=>{const t=Ur(kr(e,"POI")),i=t.layout?.["text-size"];return{...t,layout:{...t.layout,"icon-image":["get",Zi],"text-field":["get",qi],...i&&{"text-size":Pr(i)}}}},Wr=e=>{const t=Ur(kr(e,"POI - Micro"));return{...t,minzoom:0,layout:{...t.layout,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{...t.paint,"icon-opacity":1}}},Gr=e=>{const t=kr(e,"POI").layout??{};return{...sr,layout:{...sr.layout,"icon-anchor":"center",...void 0!==t["icon-size"]&&{"icon-size":t["icon-size"]},...void 0!==t["icon-padding"]&&{"icon-padding":t["icon-padding"]}},paint:{...sr.paint,"icon-translate":[0,0]}}},Br={type:"symbol",layout:{visibility:"none"}},Vr={type:"circle",layout:{visibility:"none"}},zr="#3f9cd9",jr={...sr,filter:["!",_r]},$r={...sr,filter:_r,layout:{...sr.layout,"icon-size":["interpolate",["linear"],["zoom"],8,.8,22,1],"text-allow-overlap":!0},paint:{...sr.paint,"text-color":zr}},Yr=e=>({...e,filter:_r,layout:{...e.layout,"text-allow-overlap":!0},paint:{...e.paint,"text-color":zr}}),Kr=(e,t,i,r,s)=>{const o=t?.text,a=t?.layers?.[i],n=!0===t?.evAvailability?.enabled,l=o?.title&&"function"!=typeof o?.title?o.title:n?((e,t)=>t?["case",["has","evAvailabilityText"],["format",["get",qi],{},"\n",{},["get","evAvailabilityText"],{"font-scale":1.1,"text-color":Or(e?.evAvailability)}],["get",qi]]:["get",qi])(t,n):void 0;return{...e,...a,layout:Dr(e,t,i,l,s),paint:Fr(e,t,i,r)}},qr=(e,t,i,r)=>{const s=((e,t)=>{const i=/* @__PURE__ */new Map,r=e?.icon?.categoryIcons??[];for(const s of r)if(s.image){const r=Ar(s.image,e?.theme),o=void 0!==s.offsetX||void 0!==s.offsetY;if(void 0===r&&!o)continue;const a={heightScale:r?.heightScale??1,widthScale:r?.widthScale??1,offset:{x:s.offsetX??0,y:s.offsetY??0}},n=or(s.id,t);if(i.set(n,a),s.availabilityLevel){const e=or(`${s.id}-${s.availabilityLevel}`,t);i.set(e,a)}}return i})(e,r);let o,a,n=Br,l=Br,c=Vr,h=Br,u=Vr,d=Br;if("base-map"===e?.theme)o={...Hr(t),minzoom:10},n=Wr(t),a=(e=>Yr(Hr(e)))(t);else if("circle-icon"===e?.theme)o=(e=>({...Gr(e),filter:["!",_r]}))(t),a=(e=>Yr(Gr(e)))(t);else if("pin-clustered"===e?.theme){o={...jr,filter:["all",cr,["!",_r]]},a={...$r,filter:["all",cr,_r]};const e=Wr(t);n={...e,filter:e.filter?["all",cr,e.filter]:cr},l={type:"symbol",filter:ur,layout:{"icon-image":fr(["get",hr]),"icon-size":1,"icon-allow-overlap":!0,"icon-ignore-placement":!0}},c={type:"circle",filter:ur,paint:{"circle-radius":11,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5,"circle-translate":pr,"circle-translate-anchor":"viewport"}},h={type:"symbol",filter:ur,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[Ei],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF","text-translate":pr,"text-translate-anchor":"viewport"}},u={type:"circle",filter:dr,paint:{"circle-radius":15,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5}},d={type:"symbol",filter:dr,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[Ei],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF"}}}else o=jr,a=$r;return{micro:{...Kr(n,e,"micro",i,s),beforeID:Ni.lowestPlaceLabel},main:{...Kr(o,e,"main",i,s),beforeID:"selected"},selected:Kr(a,e,"selected",i,s),cluster:{...l,...e?.layers?.cluster,beforeID:"clusterBadge"},clusterBadge:{...c,...e?.layers?.clusterBadge,beforeID:"clusterCount"},clusterCount:{...h,...e?.layers?.clusterCount,beforeID:"clusterMixedBadge"},clusterMixedBadge:{...u,...e?.layers?.clusterMixedBadge,beforeID:"clusterMixedCount"},clusterMixedCount:{...d,...e?.layers?.clusterMixedCount},...e?.layers?.additional}},Zr=e=>{if(Nt())return xt(Ft(e))},Xr=(e,t)=>"string"!=typeof e?e:t.features.find(t=>t.id===e),Jr=(e,t)=>`${e}-entry-point-${t}`,Qr=(e,t)=>"all"===e||("selected"===e?void 0!==t:fi(t)),es=/* @__PURE__ */new Set([7339002,8099002,7369004,7321003,7376006,9362003,9362004,9160004,9376007,7315015,9376006,9376002,7315078,7315149,9376005,7372003,9352045,9352032,9361048,9902003,9378005,7383004,9910004,7320002,9362016,7320003,9362025,9942002,9942003,7380005,9663003,9361021,9379009,9379004,7315147,9376003,9160002,9160003,9352008,9361006,7389004,9910006]),ts=new Map([["ADVENTURE_SPORTS_FACILITY","SPORTS_CENTER"],["COMMUNITY_CENTER","CULTURAL_CENTER"],["EMBASSY","GOVERNMENT_OFFICE"],["EMERGENCY_MEDICAL_SERVICE","EMERGENCY_ROOM"],["ENTERTAINMENT","NIGHTLIFE"],["RESIDENTIAL_ENTRANCE","RESIDENTIAL_ACCOMMODATION"]].map(([e,t])=>[A[e],A[t]])),is=e=>e.properties.poi?.name??e.properties.address.freeformAddress,rs=(e,t,i)=>{if("pin"===t||"pin-clustered"===t)return(e=>{if(!e)return;const t=es.has(e)?e:Number(e.toString().substring(0,4));return Mt(String(ts.get(t)??t))})(A[e])??i;{const t=ji(e);return t?`poi-${t}`:i}},ss=(e,t,i={})=>{const r=i.theme??"pin",s=((e,t)=>e.icon?.default||"base-map"!==(e.theme??"pin")?or(Ji,t):Qi)(i,t),o=i.icon?.mapping;if(o)return"imageID"===o.to?o.fn(e):rs(o.fn(e),r,s);const a=e.properties.poi?.categories?.[0],n=((e,t,i,r,s)=>{if(!r.evAvailability?.enabled||!Rr(e))return;const o=wr(e)>=(r.evAvailability.threshold??.3)?"available":"occupied",a=r.icon?.categoryIcons&&r.icon.categoryIcons.length>0,n=r.icon?.categoryIcons?.find(e=>e.id===t&&e.availabilityLevel===o);return n?or(`${n.id}-${o}`,i):a||"pin"!==s?void 0:Mt(`7309-${o}`)})(e,a,t,i,r);if(n)return n;const l=i.icon?.categoryIcons?.find(e=>e.id===a);return l?or(l.id,t):rs(a,r,s)},os=(e,t)=>{const i=t?.icon?.mapping;return"poiCategory"===i?.to?i.fn(e):e.properties.poi?.categories?.[0]},as=(e,t)=>{const i=os(e,t);return i&&ji(i)},ns=(e,t)=>{const i=os(e,t);return i&&Ki(i)},ls=e=>Array.isArray(e)?{type:"FeatureCollection",features:e}:"Feature"===e.type?{type:"FeatureCollection",features:[e]}:e,cs=(e,t,i)=>{if(!0!==t?.enabled)return e;let r=!1,s=!1;for(const o of i.features)if("CHARGING_LOCATION"===o.properties.poi?.categories?.[0]&&(r=!0,Rr(o))){s=!0;break}return r&&!s&&console.warn("PlacesModule: evAvailability is enabled but no availability data found. Did you call getPlacesWithEVAvailability()?"),{...e,evAvailabilityText:e=>Rr(e)?((e,t)=>{const i=Tr(e);return i?(t?.formatText??Cr)(i.availableCount,i.totalCount):""})(e,t):"",evAvailabilityRatio:e=>Rr(e)?wr(e):0}},hs=(e,t)=>{const i=as(e,t);return i?`poi-${i}`:Qi},us=(e,t,i={})=>{const r=ls(e),s=!0===i.evAvailability?.enabled?cs(i.extraFeatureProps,i.evAvailability,r):i.extraFeatureProps;return{...r,features:r.features.map(e=>{const r="function"==typeof i?.text?.title?i?.text?.title(e):is(e),o=s?Object.fromEntries(Object.entries(s).map(([t,i])=>[t,"function"==typeof i?i(e):i])):{},a=e.id??m();return{...e,id:a,geometry:{...e.geometry,bbox:e.bbox},properties:{...e.properties,id:a,title:r,iconID:ss(e,t,i),...("base-map"===i?.theme||"pin-clustered"===i?.theme)&&{category:as(e,i),group:ns(e,i)},..."pin-clustered"===i?.theme&&{baseMapIconID:hs(e,i)},...o}}})}},ds=class e extends Qt{static async create(t,i){return await Pt(t),new e(t,i)}constructor(e,t){super(e,t),this.refreshingEntryPoints=!1,this.currentClusterMode=!1,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){t||(this.sourceID=`places-${this.instanceIndex}`,this.unclusteredSourceID=`places-${this.instanceIndex}-unclustered`,this.connectionSourceID=`places-connections-${this.instanceIndex}`,this.entryPointSourceID=`places-entry-points-${this.instanceIndex}`,this.layerIDPrefix=this.sourceID,this.defaultPlaceIconID=or(Ji,this.instanceIndex),this.shownConnections=[]),this.layerSpecs=this.buildLayerSpecs(e);const i=this.buildClusterOptions(e);this.currentClusterMode=!0===i?.cluster;const r=this.partitionSpecsForSources(this.layerSpecs),s=new yi(this.mapLibreMap,this.sourceID,r.clusteredSpecs,!1,i);let o;r.unclusteredSpecs.length>0&&(o=new yi(this.mapLibreMap,this.unclusteredSourceID,r.unclusteredSpecs,!1)),Vt([...s._layerSpecs,...o?._layerSpecs??[]],this.mapLibreMap),this.connectionLayerSpecs=this.buildConnectionLayerSpecs(e);const a=this.addOverlaySource(this.connectionSourceID,this.connectionLayerSpecs);this.entryPointLayerSpecs=this.buildEntryPointLayerSpecs(e);const n=this.addOverlaySource(this.entryPointSourceID,this.entryPointLayerSpecs),l=()=>{(this.config?.entryPoints||n.shownFeatures.features.length)&&this.updateEntryPointsData(this.config)};return s.onShow(l),n.onShow(l),o?{places:s,placesUnclustered:o,connections:a,entryPoints:n}:{places:s,connections:a,entryPoints:n}}addOverlaySource(e,t){const i=new yi(this.mapLibreMap,e,Object.values(t),!1);return Vt(i._layerSpecs,this.mapLibreMap),i}replaceLayerSpecs(e,t,i){return Wt(Object.values(e),Object.values(t),i,this.mapLibreMap),e}partitionSpecsForSources(e){if(!this.currentClusterMode)return{clusteredSpecs:Object.values(e),unclusteredSpecs:[]};const t=[],i=[];for(const[r,s]of Object.entries(e))"micro"===r?t.push(s):i.push(s);return{clusteredSpecs:i,unclusteredSpecs:t}}buildLayerSpecs(e){const t=qr(e,this.tomtomMap.mapLibreMap,this.tomtomMap.styleLightDarkTheme,this.instanceIndex),i=new Set(Object.keys(t));return Object.fromEntries(Object.entries(t).map(([e,t])=>{const r=t.beforeID;return[e,{...t,id:`${this.layerIDPrefix}-${e}`,...r&&i.has(r)?{beforeID:`${this.layerIDPrefix}-${r}`}:{}}]}))}buildClusterOptions(e){if("pin-clustered"===e?.theme)return{cluster:!0,clusterRadius:60,clusterMaxZoom:17,clusterProperties:yr}}buildConnectionLayerSpecs(e){const t=((e,t,i="light")=>{const r=mr(i);return{line:nr((a=t??r.lineColor,{type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":a,"line-width":1.5,"line-dasharray":[2,2],"line-opacity":.9}}),e?.layers?.line),label:nr((s=t??r.labelColor,o=r.labelHaloColor,{type:"symbol",layout:{"symbol-placement":"line-center","text-field":["get","label"],"text-size":12,"text-offset":[0,-1],"text-allow-overlap":!1,"text-ignore-placement":!1,"text-keep-upright":!0},paint:{"text-color":s,"text-halo-color":o,"text-halo-width":1.5}}),e?.layers?.label)};var s,o,a})(e?.connections,void 0,this.tomtomMap.styleLightDarkTheme),i=`${this.layerIDPrefix}-connection-line`,r=`${this.layerIDPrefix}-connection-label`,s=Ni.lowestLabel;return{line:{...t.line,id:i,beforeID:s},label:{...t.label,id:r,beforeID:s}}}buildEntryPointLayerSpecs(e){const t=this.buildClusterOptions(e)?18:0,i=Ir(e?.entryPoints,this.tomtomMap.styleLightDarkTheme,t);return{line:{...i.line,id:`${this.layerIDPrefix}-entry-point-line`,beforeID:this.layerSpecs.main.id},point:{...i.point,id:`${this.layerIDPrefix}-entry-point`,beforeID:this.layerSpecs.cluster.id}}}_applyConfig(e){return this.updateLayersAndData(e),e}discardShownData(){this.shownConnections=[]}restoreDataAndConfigImpl(){const e=this.sourcesWithLayers.places.shownFeatures,t=this.shownConnections;this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config),this.show(e),t.length&&this.showConnections(t)}applyTheme(e){this.applyConfigPart({theme:e})}applyIconConfig(e){this.applyConfigPart({icon:e})}applyTextConfig(e){this.applyConfigPart({text:e})}applyConfigPart(e){const t={...this.config,...e};this.updateLayersAndData(t),this.config=t,this.emitConfigChange()}applyExtraFeatureProps(e){const t={...this.config,extraFeatureProps:e};this.updateData(t),this.config=t,this.emitConfigChange()}updateLayersAndData(e){if(this.setupImages(e),!0===this.buildClusterOptions(e)?.cluster!==this.currentClusterMode)return void this.rebuildSourcesAndLayers(e);const t=this.buildLayerSpecs(e),i=this.currentClusterMode?this.partitionSpecsForSources(t):{clusteredSpecs:Object.values(t),unclusteredSpecs:[]},r=this.currentClusterMode?this.partitionSpecsForSources(this.layerSpecs):{clusteredSpecs:Object.values(this.layerSpecs),unclusteredSpecs:[]};Wt(i.clusteredSpecs,r.clusteredSpecs,this.sourcesWithLayers.places,this.mapLibreMap),this.sourcesWithLayers.placesUnclustered&&i.unclusteredSpecs.length>0&&Wt(i.unclusteredSpecs,r.unclusteredSpecs,this.sourcesWithLayers.placesUnclustered,this.mapLibreMap),this.layerSpecs=t,this.applyPlacesVisibility(),this.updateData(e),this.connectionLayerSpecs=this.replaceLayerSpecs(this.buildConnectionLayerSpecs(e),this.connectionLayerSpecs,this.sourcesWithLayers.connections),this.updateConnectionsData(e),this.entryPointLayerSpecs=this.replaceLayerSpecs(this.buildEntryPointLayerSpecs(e),this.entryPointLayerSpecs,this.sourcesWithLayers.entryPoints),this.updateEntryPointsData(e)}rebuildSourcesAndLayers(e){const t=this.sourcesWithLayers.places.shownFeatures,i=this.shownConnections,r=this.mapLibreMap;for(const o of[...Object.values(this.layerSpecs),...Object.values(this.connectionLayerSpecs),...Object.values(this.entryPointLayerSpecs)])r.getLayer(o.id)&&r.removeLayer(o.id);for(const o of[this.sourceID,this.unclusteredSourceID,this.connectionSourceID,this.entryPointSourceID])r.getSource(o)&&r.removeSource(o);this.initSourcesWithLayers(e,!0),this.setupImages(e);const s=us(t,this.instanceIndex,e);this.sourcesWithLayers.places.show(s,{automaticVisibility:!1}),this.sourcesWithLayers.placesUnclustered?.show(s,{automaticVisibility:!1}),this.applyPlacesVisibility(),i.length&&(this.shownConnections=[...i],this.updateConnectionsData(e)),this.updateEntryPointsData(e)}updateConnectionsData(e){const t=this.sourcesWithLayers.places.shownFeatures;this.sourcesWithLayers.connections.show(((e,t,i={})=>{const r=i.connections?.label,s=[];for(const o of e){const e=Xr(o.from,t),i=Xr(o.to,t);if(!e||!i)continue;const a=o.id??m(),n=r?r(o):"";s.push({type:"Feature",id:a,geometry:{type:"LineString",coordinates:[e.geometry.coordinates,i.geometry.coordinates]},properties:{id:a,fromId:"string"==typeof o.from?o.from:e.id,toId:"string"==typeof o.to?o.to:i.id,label:n}})}return{type:"FeatureCollection",features:s}})(this.shownConnections,t,e))}updateEntryPointsData(e){if(!this.refreshingEntryPoints){this.refreshingEntryPoints=!0;try{const t=this.sourcesWithLayers.entryPoints,i=((e,t,i)=>{const r=[];if(!i)return{type:"FeatureCollection",features:r};const s=i.showFor??"selected",o=/* @__PURE__ */new Map;for(const a of t.features)a.properties.eventState&&o.set(a.properties.id,a.properties.eventState);for(const a of e.features){const e=a.properties.id,t=a.properties.entryPoints??[],i=t.map((t,i)=>Jr(e,i));if(Qr(s,a.properties.eventState)||i.some(e=>Qr(s,o.get(e))))for(const[s,{position:n,...l}]of t.entries()){const t=i[s],c=o.get(t),h={...l,id:t,placeID:e,entryPointIndex:s};r.push({type:"Feature",id:t,geometry:{type:"Point",coordinates:n},properties:c?{...h,eventState:c}:h},{type:"Feature",id:t,geometry:{type:"LineString",coordinates:[a.geometry.coordinates,n]},properties:h})}}return{type:"FeatureCollection",features:r}})(this.sourcesWithLayers.places.shownFeatures,t.shownFeatures,e?.entryPoints);t.show(i,{automaticVisibility:!1}),this.applyLayersVisibility(Object.values(this.entryPointLayerSpecs),!!i.features.length)}finally{this.refreshingEntryPoints=!1}}}applyLayersVisibility(e,t){const i=t?"visible":"none";for(const r of e)"none"!==r.layout?.visibility&&this.mapLibreMap.setLayoutProperty(r.id,"visibility",i,{validate:!1})}applyPlacesVisibility(){this.applyLayersVisibility(Object.values(this.layerSpecs),!!this.sourcesWithLayers.places.shownFeatures.features.length)}setupImages(e){if(e?.icon){for(const t of e.icon.categoryIcons??[]){const e=t.availabilityLevel?`${t.id}-${t.availabilityLevel}`:t.id;$t("if-not-in-sprite",or(e,this.instanceIndex),t.image,this.mapLibreMap,{pixelRatio:t.pixelRatio??2})}e.icon.default&&(e.icon.default.image&&$t("if-not-in-sprite",this.defaultPlaceIconID,e.icon.default.image.image,this.mapLibreMap,{pixelRatio:e.icon.default.image.pixelRatio??2}),e.icon.default.style&&$t("if-not-in-sprite",this.defaultPlaceIconID,Zr(e.icon.default.style),this.mapLibreMap,{pixelRatio:2}))}else $t("if-not-in-sprite",this.defaultPlaceIconID,Zr(),this.mapLibreMap,{pixelRatio:2})}updateData(e){const t=us(this.sourcesWithLayers.places.shownFeatures,this.instanceIndex,e);this.sourcesWithLayers.places.source.runtimeSource?.setData(t),this.sourcesWithLayers.placesUnclustered?.source.runtimeSource?.setData(t)}async show(e){await this.waitUntilModuleReady(),this.clearConnectionsSync(),this.sourcesWithLayers.entryPoints.clear();const t=us(e,this.instanceIndex,this.config);this.sourcesWithLayers.places.show(t,{automaticVisibility:!1}),this.sourcesWithLayers.placesUnclustered?.show(t,{automaticVisibility:!1}),this.applyPlacesVisibility();for(const i of this.shownFeaturesHandlers)i({places:e})}async clear(){await this.waitUntilModuleReady(),this.clearConnectionsSync(),this.sourcesWithLayers.places.clear(),this.sourcesWithLayers.placesUnclustered?.clear()}async showConnections(e){await this.waitUntilModuleReady(),this.shownConnections=[...e],this.updateConnectionsData(this.config);for(const t of this.shownFeaturesHandlers)t({connections:e})}async clearConnections(){await this.waitUntilModuleReady(),this.clearConnectionsSync()}clearConnectionsSync(){this.shownConnections=[],this.sourcesWithLayers.connections?.clear()}getShown(){return{places:this.sourcesWithLayers.places.shownFeatures,connections:[...this.shownConnections]}}putEventState(e){this.sourcesWithLayers.places.putEventState(e)}cleanEventState(e){this.sourcesWithLayers.places.cleanEventState(e)}cleanEventStates(e){this.sourcesWithLayers.places.cleanEventStates(e)}get events(){const e=["places","placesUnclustered"];return this.buildEvents(this.moduleEventsWithShown([...e,"connections","entryPoints"],this.shownFeaturesHandlers),{places:this.userEvents(e),connections:this.userEvents(["connections"]),entryPoints:this.userEvents(["entryPoints"],{mapping:e=>((e,t)=>{const i=e.properties;return{type:"Feature",id:i.id,geometry:{type:"Point",coordinates:(r=e.geometry,"Point"===r.type?r.coordinates:r.coordinates[1])},properties:{...i,place:ri(t.features,i.placeID)?.feature}};var r})(e,this.sourcesWithLayers.places.shownFeatures)})})}},ps=["pin","circle-icon","base-map","pin-clustered"],ys={FOOD_DRINKS_GROUP:["RESTAURANT","FAST_FOOD","CAFE_PUB","PUB","WINERY","SOUL_FOOD","DELICATESSEN"],SHOPPING_GROUP:["SHOP_OR_STORE","MALL","CLOTHING_SHOP","MARKETPLACE","FOOD_MARKET","SUPERMARKET","DEPARTMENT_STORE","CONVENIENCE_STORE","GROCERY_STORE","HARDWARE_STORE","ELECTRICAL_APPLIANCES_SHOP"],TRANSPORTATION_GROUP:["AIRPORT","FERRY_TERMINAL","HELIPORT_OR_HELIPAD","PUBLIC_TRANSPORT_STOP","RAILWAY_STATION","BUS_STOP","TAXI_STAND"],HEALTH_GROUP:["DOCTOR","EMERGENCY_MEDICAL_SERVICE","EMERGENCY_ROOM","HEALTHCARE_SERVICE","HOSPITAL","PHARMACY","DENTIST","WELFARE_ORGANIZATION"],PARKING_GROUP:["PARKING_GARAGE","OPEN_CAR_PARKING_AREA"],HOLIDAY_TOURISM_GROUP:["AMUSEMENT_PARK","BEACH","HOLIDAY_RENTAL","NATURAL_FEATURE","TOURIST_ATTRACTION","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK","MUSEUM","VIEWPOINT","TOURIST_INFORMATION"],EV_CHARGING_STATIONS_GROUP:["CHARGING_LOCATION"],GAS_STATIONS_GROUP:["FUEL_STATION"],ACCOMMODATION_GROUP:["CAMPING_GROUND","HOTEL_OR_MOTEL","HOLIDAY_RENTAL"],ENTERTAINMENT_GROUP:["CINEMA","THEATER","MOVIE_THEATER","NIGHTLIFE","CONCERT_HALL","ENTERTAINMENT","CLUB_AND_ASSOCIATION","CASINO_AND_GAMBLING"],SPORTS_LEISURE_GROUP:["SPORTS_CENTER","WATER_SPORT","SWIMMING_POOL","GOLF_COURSE","STADIUM","BEACH","ICE_RINK","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK"],EDUCATION_GROUP:["SCHOOL","COLLEGE_OR_UNIVERSITY","PUBLIC_LIBRARY","CULTURAL_CENTER"],GOVERNMENT_GROUP:["GOVERNMENT_OFFICE","COURTHOUSE","EMBASSY","FIRE_STATION","POLICE_STATION"]},fs=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{id:String(t?.id),name:t?.name,category:t?.category,group:t?.group,priority:t?.priority}}},ms=e=>{const t=e.flatMap(e=>e in ys?ys[e].map(ji):[ji(e)]);return[...new Set(t.filter(e=>!i(e)))]},gs="pois.categories",_s=class e extends ei{static async get(t,i){return await Pt(t),Wi(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(xi);if(!t)throw ye(`init ${e.name} with source ID ${xi}`);return{poi:new ui(this.mapLibreMap,t,e=>Bi.includes(e.id))}}_applyConfig(e){return e&&!i(e.visible)?this._setVisible(e.visible,!1):this._initializing||this.isVisible()||this._setVisible(!0,!1),this._filterCategories(e?.filters?.categories,!1),e}isVisible(){return this.sourcesWithLayers.poi.isAnyLayerVisible()}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.poi.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}filterCategories(e){this._filterCategories(e)}_filterCategories(e,t=!0){if(e){if(this.tomtomMap.mapReady){const t=le("category",e.show,ms(e.values));this.filterComposer.setClause(Ni.poi,gs,t)}t&&(this.config={...this.config,filters:{categories:e}})}else this.categoriesFilter&&(t&&(this.config={...this.config,filters:{categories:{show:"all-except",values:[]}}}),this.tomtomMap.mapReady&&this.filterComposer.setClause(Ni.poi,gs,void 0));this.categoriesFilter=e,t&&this.emitConfigChange()}getShown(){return{poi:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.poi.sourceAndLayerIDs.layerIDs,validate:!1}).map(fs)}}get events(){return this.moduleEvents(["poi"],{mapping:fs})}},Ls=e=>"source"in e&&"string"==typeof e.source?e.source:void 0,bs=(e,t)=>!e||void 0!==t&&e.includes(t),Ss=(e,t,i)=>bs(e.metadataGroups,(e=>{const t=e.metadata;if(t&&"object"==typeof t&&"group"in t){const e=t.group;return"string"==typeof e?e:void 0}})(t))&&bs(e.layerTypes,t.type)&&bs(e.sources,Ls(t))&&bs(e.sourceTypes,((e,t)=>{const i=Ls(e);return void 0===i?void 0:t?.[i]?.type})(t,i))&&bs(e.sourceLayers,(e=>"source-layer"in e&&"string"==typeof e["source-layer"]?e["source-layer"]:void 0)(t))&&((e,t)=>{const i=t.id.toLowerCase(),r=e=>i.includes(e.toLowerCase());return!(e.idIncludes&&!e.idIncludes.some(r)||e.idExcludes?.some(r))})(e,t),Is=(e,t,i)=>e.some(e=>Ss(e,t,i)),As=["land","water","buildings2D","roads","railways","ferries","borders","buildings3D","natureLabels","roadLabels","roadShields","houseNumbers","smallerTownLabels","stateLabels","cityLabels","allPlaceLabels","capitalLabels","countryLabels"],Es={land:{metadataGroups:["area","background"]},water:{metadataGroups:["water"]},natureLabels:{metadataGroups:["label"]},roads:{metadataGroups:["road","road_area","transit_area"],idExcludes:["railway","subway","aerialway","ferry"]},railways:{metadataGroups:["road"],layerTypes:["line"],idIncludes:["railway","subway","aerialway"]},ferries:{metadataGroups:["road"],layerTypes:["line"],idIncludes:["ferry"]},buildings2D:{metadataGroups:["building"],layerTypes:["fill","line"]},buildings3D:{metadataGroups:["area_3d","building"],layerTypes:["fill-extrusion"]},borders:{metadataGroups:["border","border_label"]},roadLabels:{metadataGroups:["road_label"],idExcludes:["shield"]},roadShields:{metadataGroups:["road_label"],idIncludes:["shield"]},houseNumbers:{metadataGroups:["address_point_label"]},allPlaceLabels:{metadataGroups:["places_label"]},smallerTownLabels:{metadataGroups:["places_label"],idIncludes:["neighbourhood","village","hamlet","town"]},cityLabels:{metadataGroups:["places_label"],idIncludes:["city"]},capitalLabels:{metadataGroups:["places_label"],idIncludes:["capital"]},stateLabels:{metadataGroups:["places_label"],idIncludes:["state"]},countryLabels:{metadataGroups:["places_label"],idIncludes:["country"]}},vs=(e,t)=>Ss(Es[e],t),Rs=e=>Es[e],Ts=e=>{const t=e.mode,i=e.names;return"include"===t?e=>i.some(t=>vs(t,e)):"exclude"===t?e=>!i.some(t=>vs(t,e)):(console.error("Unrecognized layer group mode:",t),()=>!0)},Cs=e=>!Bi.includes(e.id),ws=class e extends ei{static async get(t,i){return await Pt(t),Wi(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Pi);if(!t)throw ye(`init ${e.name} with source ID ${Pi}`);const i=new ui(this.mapLibreMap,t,Cs);return this.layersByGroup=void 0,{vectorTiles:i}}_applyConfig(e){return e&&!i(e.visible)?this._setVisible(e.visible,void 0,!1):this._initializing||this.isVisible()||this._setVisible(!0,void 0,!1),e?.layerGroupsVisibility&&this._setVisible(e.layerGroupsVisibility.visible,{layerGroups:e.layerGroupsVisibility},!1),e?{...this.config,...e}:void 0}isVisible(e){return this.sourcesWithLayers.vectorTiles.isAnyLayerVisible(e?.layerGroups&&Ts(e.layerGroups))}setVisible(e,t){this._setVisible(e,t)}_setVisible(e,t,i=!0){i&&(t?.layerGroups?this.config={...this.config,layerGroupsVisibility:{...t.layerGroups,visible:e}}:(delete this.config?.layerGroupsVisibility,this.config={...this.config,visible:e})),this.tomtomMap.mapReady&&this.sourcesWithLayers.vectorTiles.setLayersVisible(e,t?.layerGroups&&Ts(t.layerGroups)),i&&this.emitConfigChange()}getLayers(){return s(this.groupedLayers(),e=>[...e])}getLayerIds(e){return[...this.groupedLayers()[e]]}groupedLayers(){return this.layersByGroup??=(e=>{const t=Object.fromEntries(As.map(e=>[e,[]]));for(const i of e)for(const e of As)vs(e,i)&&t[e].push(i.id);return t})(this.sourcesWithLayers.vectorTiles._layerSpecs),this.layersByGroup}get events(){return this.moduleEvents(["vectorTiles"],{scopeResolver:Os})}},Os=e=>({layerFilter:Ts(e.layerGroups),featureMatches:e.features}),Ms=class e extends Qt{static async create(t,i){return await Pt(t),Ns(i),new e(t,i)}constructor(e,t){super(e,t),this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=e??this.initialConfig;t||(this.lastShown={}),this.resolveIDs(i),this.registerImages(i);const r={};for(const s of Object.keys(i.sources)){const e=this.resolvedSourceIDs[s],t=this.resolvedLayerSpecs[s],o=i.sources[s].cluster;r[s]=new yi(this.mapLibreMap,e,t,!0,o)}return r}registerImages(e){if(e.images)for(const[t,i]of Object.entries(e.images))this.mapLibreMap.hasImage(t)||this.mapLibreMap.addImage(t,i.image,i.options)}resolveIDs(e){const t={},i={};for(const r of Object.keys(e.sources)){const s=e.sources[r],o=s.sourceID??`custom-geojson-${this.instanceIndex}-${String(r)}`;t[r]=o,i[r]=s.layers.map((e,t)=>({...e,id:e.id??`${o}-layer-${t}`}))}this.resolvedSourceIDs=t,this.resolvedLayerSpecs=i}_applyConfig(e){if(!e)return this._applyConfig(this.initialConfig);this.initialConfig??=e;const t=this.config,i=t?this.resolvedLayerSpecs:void 0;return this.resolveIDs(e),this.registerImages(e),t&&i&&this.updateLayersForExistingSources(i),void 0!==e.visible&&this.applyVisibility(e.visible),e}updateLayersForExistingSources(e){for(const t of Object.keys(this.resolvedLayerSpecs)){const i=e[t],r=this.resolvedLayerSpecs[t],s=this.sourcesWithLayers[t];if(!i||!s)continue;Wt(r,i,s,this.mapLibreMap);const o=[];for(const e of s._layerSpecs)this.mapLibreMap.getLayer(e.id)||o.push(e);o.length>0&&(Vt(o,this.mapLibreMap),s.shownFeatures.features.length>0&&s.setLayersVisible(!0))}}applyVisibility(e){for(const t of Object.keys(this.sourcesWithLayers))this.sourcesWithLayers[t].setLayersVisible(e)}discardShownData(){this.lastShown={}}restoreDataAndConfigImpl(){const e=Object.keys(this.lastShown);this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config);for(const t of e){const e=this.lastShown[t];e&&this.showOnSource(t,e)}}async show(e,t){if(await this.waitUntilModuleReady(),void 0!==t)this.showOnSource(t,e);else for(const i of Object.keys(this.sourcesWithLayers))this.showOnSource(i,e)}showOnSource(e,t){const i=xs(t);this.lastShown[e]=i,this.sourcesWithLayers[e].show(i);for(const r of this.shownFeaturesHandlers)r({sourceName:e,data:i})}async clear(e){if(await this.waitUntilModuleReady(),void 0!==e)return this.sourcesWithLayers[e].clear(),void delete this.lastShown[e];for(const t of Object.keys(this.sourcesWithLayers))this.sourcesWithLayers[t].clear(),delete this.lastShown[t]}getShown(){const e={};for(const t of Object.keys(this.sourcesWithLayers))e[t]=this.sourcesWithLayers[t].shownFeatures;return e}setVisible(e){this.config={...this.config,visible:e},this.applyVisibility(e),this.emitConfigChange()}get events(){const e=Object.keys(this.sourcesWithLayers),t={};for(const i of e)t[i]=this.userEvents([i]);return this.buildEvents(this.moduleEventsWithShown(e,this.shownFeaturesHandlers),t)}},Ns=e=>{if(!e.sources||0===Object.keys(e.sources).length)throw new Error("CustomGeoJSONModule requires at least one source in config.sources.");ee(Object.keys(e.sources),"CustomGeoJSONModule source");for(const[t,i]of Object.entries(e.sources))if(!i.layers||0===i.layers.length)throw new Error(`CustomGeoJSONModule source "${t}" requires at least one layer.`)},xs=e=>{let t=!1;for(const i of e.features)if(null==i.id||i.properties?.id!==i.id){t=!0;break}return t?{...e,features:e.features.map((e,t)=>{const i=e.id??e.properties?.id??t;return{...e,id:i,properties:{...e.properties,id:i}}})}:e},Ds="#0A3653",Fs="#555555",Ps=e=>({defaultColor:"dark"===e?"#5FA8D8":Ds,textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}),ks=(e,t,r,s=Ds)=>{const o=r?.fill,a=r?.line,n=((e=Ds)=>({type:"fill",paint:{"fill-color":["coalesce",["get","color"],e],"fill-opacity":["case",["==",["get","theme"],"outline"],0,.15],"fill-antialias":!1}}))(s),l=((e=Ds)=>({type:"line",paint:{"line-color":["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],Fs],["coalesce",["get","color"],e]],"line-opacity":["case",["==",["get","theme"],"outline"],.9,1],"line-width":["case",["==",["get","theme"],"outline"],5,2]}}))(s),c={...n,id:e,paint:{...n.paint,...!i(o?.opacity)&&{"fill-opacity":o?.opacity},...o?.color&&{"fill-color":["get","color"]}}},h=a?.layer;return[c,{...l,...h,id:t,...h?.layout&&{layout:{...l.layout,...h.layout}},paint:{...l.paint,...h?.paint,...!i(a?.color)&&{"line-color":a?.color},...!i(a?.width)&&{"line-width":a?.width},...!i(a?.opacity)&&{"line-opacity":a?.opacity}}}]},Us=(e,t,i="light")=>{const r=t?.textConfig,{textColor:s,haloColor:o}=Ps(i);return{type:"symbol",id:e,layout:{"text-field":["get","title"],...r?.textField&&{"text-field":r.textField},"text-padding":5,"text-size":15,"text-font":[Ei],"symbol-placement":"point"},paint:{"text-color":s,"text-halo-color":o,"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"}}},Hs=(e,t,r="light")=>{const s=t?.lineLabelConfig,o=s?.minZoom??3,{textColor:a,haloColor:n}=Ps(r);return{type:"symbol",id:e,minzoom:o,layout:{"text-field":["get","title"],"symbol-placement":"line","text-size":s?.textSize??15,"text-font":[Ei],"symbol-spacing":s?.symbolSpacing??200,"text-keep-upright":!0,"text-offset":s?.textOffset??[0,1]},paint:{"text-color":s?.textColor??a,"text-halo-color":s?.textHaloColor??n,"text-halo-width":s?.textHaloWidth??2,...!i(s?.textOpacity)&&{"text-opacity":s?.textOpacity}}}},Ws={warm:["#793F0D","#AC703D","#C38E63","#E49969","#E5AE86","#EEC5A9","#6E7649","#9D9754","#C7C397","#B4A851","#DFD27C","#E7E3B5","#846D74","#B7A6AD","#D3C9CE"],browns:["#edc4b3","#e6b8a2","#deab90","#d69f7e","#cd9777","#c38e70","#b07d62","#9d6b53","#8a5a44","#774936"],cold:["#344464","#548ca4","#549cac","#2c445c","#a4ccd4","#acbccc","#b4c4d4","#acd4cc","#5c8ca4"],fadedBlues:["#152033","#1d2d44","#2e455d","#3e5c76","#4c6884","#597491","#67809e","#6e86a5","#7b91ad","#879bb4"],blues:["#03045e","#023e8a","#0077b6","#0096c7","#00b4d8","#48cae4","#90e0ef","#ade8f4","#caf0f8"],greens:["#004b23","#006400","#007200","#008000","#38b000","#70e000","#9ef01a","#ccff33"],fadedGreenToBlue:["#d9ed92","#b5e48c","#99d98c","#76c893","#52b69a","#34a0a4","#168aad","#1a759f","#1e6091","#184e77"],blueToRed:["#033270","#1368aa","#4091c9","#9dcee2","#fedfd4","#f29479","#f26a4f","#ef3c2d","#cb1b16","#65010c"],greenToYellow:["#007f5f","#2b9348","#55a630","#80b918","#aacc00","#bfd200","#d4d700","#dddf00","#eeef20","#ffff3f"],pastel:["#fec5bb","#fcd5ce","#fae1dd","#f8edeb","#e8e8e4","#d8e2dc","#ece4db","#ffe5d9","#ffd7ba","#fec89a"],retro:["#f94144","#f3722c","#f8961e","#f9844a","#f9c74f","#90be6d","#43aa8b","#4d908e","#577590","#277da1"],contrastRetro:["#001219","#005f73","#0a9396","#94d2bd","#e9d8a6","#ee9b00","#ca6702","#bb3e03","#ae2012","#9b2226"],fadedRainbow:["#ffadad","#ffd6a5","#fdffb6","#caffbf","#9bf6ff","#a0c4ff","#bdb2ff","#ffc6ff","#fffffc"],pastelRainbow:["#54478c","#2c699a","#048ba8","#0db39e","#16db93","#83e377","#b9e769","#efea5a","#f1c453","#f29e4c"]},Gs=Object.keys(Ws),Bs=(e,t)=>"light"===t?e:e.map(e=>{const t=(e=>{const t=Oe(e);return t?.299*t[0]+.587*t[1]+.114*t[2]:.5})(e);return t>.6?He(e,.3)??e:t<.22?((e,t)=>{const i=we(e);return i&&T(w([i,Te])(t))})(e,.4)??e:e}),Vs=(e,t={},i="light")=>({...e,features:e.features.map((e,r)=>{const s=(e.properties??{}).theme??t.theme,o="inverted"===s?(e=>{const t=B(e);return{...e,geometry:t.geometry}})(e):e,a=o.properties??{},n=a.title??((e,t)=>t.textConfig?.textField?t.textConfig.textField:e.properties?.address?.freeformAddress)(o,t),l=a.color??((e,t,i)=>{const r=e?.fill?.color;if("string"==typeof r&&Ws[r]){const e=Bs(Ws[r],i);return e[t%e.length]}return r})(t,r,i);return{...o,properties:{...o.properties,...s&&{theme:s},...n&&{title:n},...l&&{color:l},id:a.id??m()}}})}),zs=e=>{const t=e.features.map(e=>{let t;if(e.properties?.placeCoordinates)t=e.properties?.placeCoordinates;else if("MultiPolygon"===e.geometry.type){const i=(e=>e.flat().reduce((e,t)=>t.length>e.length?t:e,[]))(e.geometry.coordinates),r=d(i);t=r&&u(r)||null}else t=e.geometry.coordinates.flat();const i=e.id??e.properties?.id??m();return{type:"Feature",id:i,geometry:{type:"Point",coordinates:t},properties:{...e.properties,id:i}}});return{type:"FeatureCollection",bbox:e.bbox,features:t}},js=class e extends Qt{static async create(t,i){return await Pt(t),new e(t,i)}constructor(e,t){super(e,t),this.lineLabelLayerSpecs=null,this.lastRawInput=null,this.shownFeaturesHandlers=[]}get lightDark(){return this.tomtomMap.styleLightDarkTheme}get defaultColor(){return Ps(this.lightDark).defaultColor}_initSourcesWithLayers(e,t){if(!t){this.sourceID=`geometry-${this.instanceIndex}`,this.titleSourceID=`geometryTitle-${this.instanceIndex}`;const e=`geometry-${this.instanceIndex}`;this.fillLayerID=`${e}_Fill`,this.outlineLayerID=`${e}_Outline`,this.lineLabelLayerID=`${e}_LineLabel`,this.titleLayerID=`${e}_Title`}const[i,r]=ks(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),s=Us(this.titleLayerID,e,this.lightDark);this.titleLayerSpecs=s,this.geometryFillLayerSpecs=i,this.geometryOutlineLayerSpecs=r;const o=void 0===e?.lineLabelConfig?null:Hs(this.lineLabelLayerID,e,this.lightDark);return this.lineLabelLayerSpecs=o,{geometry:new yi(this.mapLibreMap,this.sourceID,[{...i},{...r},...o?[o]:[]]),geometryLabel:new yi(this.mapLibreMap,this.titleSourceID,[s])}}_applyConfig(e){return(e?.textConfig||e?.fill||e?.line)&&this.updateLayerAndData(e),(e?.beforeLayerConfig||e?.fill?.beforeLayerConfig||e?.line?.beforeLayerConfig)&&this.applyBeforeLayerConfig(e),e}resolveBeforeID(e){return"top"===e?this.titleLayerID:Ni[e]}moveLayersBefore(e,t){for(const i of e)Bt(this.mapLibreMap,i,t)}get fillLayerIDs(){return[this.fillLayerID]}get lineLayerIDs(){return this.lineLabelLayerSpecs?[this.outlineLayerID,this.lineLabelLayerID]:[this.outlineLayerID]}moveBeforeLayer(e){this.config={...this.config,beforeLayerConfig:e},this.applyBeforeLayerConfig(this.config),this.emitConfigChange()}applyBeforeLayerConfig(e){const t=e?.beforeLayerConfig,i=e=>{if(void 0!==t)return"string"==typeof t?t:t[e]??t.all},r=e?.fill?.beforeLayerConfig??i("fill"),s=e?.line?.beforeLayerConfig??i("line");void 0!==r&&this.moveLayersBefore(this.fillLayerIDs,this.resolveBeforeID(r)),void 0!==s&&this.moveLayersBefore(this.lineLayerIDs,this.resolveBeforeID(s))}applyTextConfig(e){const t={...this.config,textConfig:e};this.updateLayerAndData(t),this.sourcesWithLayers.geometryLabel.show(zs(this.sourcesWithLayers.geometry.shownFeatures)),this.config=t,this.emitConfigChange()}updateLayerAndData(e){const[t,i]=ks(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),r=Us(this.titleLayerID,e,this.lightDark);if(Ht(t,this.geometryFillLayerSpecs,this.mapLibreMap),Ht(i,this.geometryOutlineLayerSpecs,this.mapLibreMap),Ht(r,this.titleLayerSpecs,this.mapLibreMap),this.geometryFillLayerSpecs=t,this.geometryOutlineLayerSpecs=i,this.titleLayerSpecs=r,this.lineLabelLayerSpecs){const t=Hs(this.lineLabelLayerID,e,this.lightDark);Ht(t,this.lineLabelLayerSpecs,this.mapLibreMap),this.lineLabelLayerSpecs=t}}discardShownData(){this.lastRawInput=null}restoreDataAndConfigImpl(){const e=this.lastRawInput;this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config),e&&this.show(e)}async show(e){await this.waitUntilModuleReady(),this.lastRawInput=e;const{transformFeaturesForDisplay:t}=this.config??{},i=t?t(e):e,r=this.sourcesWithLayers.geometry;r.show(Vs(i,this.config,this.lightDark)),this.sourcesWithLayers.geometryLabel.show(zs(r.shownFeatures));for(const s of this.shownFeaturesHandlers)s(e)}async clear(){await this.waitUntilModuleReady(),this.sourcesWithLayers.geometry.clear(),this.sourcesWithLayers.geometryLabel.clear()}getShown(){return{geometry:this.sourcesWithLayers.geometry.shownFeatures,geometryLabel:this.sourcesWithLayers.geometryLabel.shownFeatures}}get events(){return this.buildEvents(this.moduleEventsWithShown(["geometry","geometryLabel"],this.shownFeaturesHandlers),{geometry:this.userEvents(["geometry"]),geometryLabel:this.userEvents(["geometryLabel"])})}},$s={timeMinutes:"min",distanceKM:"km",remainingChargePCT:"% remaining",spentChargePCT:"% spent",spentFuelLiters:"L"},Ys=(e,t,i="filled")=>{const r=e.map((e,r)=>({...e,properties:{...e.properties,title:t[r],theme:i}}));return"inverted"===i?(e=>[...e.map((t,i)=>{const r=0===i?B(t):H(W([e[i-1],t])),{title:s,theme:o,...a}=t.properties??{};return{...t,geometry:r?.geometry??t.geometry,properties:a}}),...e.map(e=>({...e,id:void 0,properties:{...e.properties,theme:"filled"}}))])(r):r},Ks=(e,t="filled",i)=>{const r=e.features,s=r.map((e,t)=>{if(i)return i(e,t);const r=e.properties?.budget;return void 0!==r?.value&&r?.type?`${r.value} ${$s[r.type]??r.type}`:String(t+1)});return{type:"FeatureCollection",...e.bbox&&{bbox:e.bbox},features:Ys(r,s,t)}},qs=(e="fadedRainbow",t="lowestLabel")=>({beforeLayerConfig:t,line:{width:["case",["==",["get","theme"],"outline"],5,1],color:["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],Fs],"grey"],opacity:["case",["==",["get","theme"],"outline"],.9,1]},fill:{color:e,opacity:["case",["==",["get","theme"],"outline"],0,.6]},lineLabelConfig:{}}),Zs=(e="fadedRainbow",t,i,r)=>{const s=qs(e,i),o=e=>Ks(e,t,r);return"inverted"!==t?{...s,transformFeaturesForDisplay:o}:{...s,line:{...s.line,opacity:["case",["==",["get","theme"],"filled"],1,0]},fill:{...s.fill,opacity:["case",["==",["get","theme"],"filled"],0,.6]},lineLabelConfig:{textOpacity:["case",["==",["get","theme"],"filled"],1,0],textOffset:["case",["==",["get","theme"],"filled"],["literal",[0,-1]],["literal",[0,1]]]},transformFeaturesForDisplay:o}},Xs=["filled","outline","inverted"],Js="#1A2024",Qs="#F1F3F5",eo=(e,t)=>{const i=e?.color??("dark"===t?Qs:Js),r=Ue(i),s=void 0!==r&&r>.4?Js:Qs;return{plaque:i,text:e?.textColor??s}},to="stopDuration",io=[["coalesce",["get",to],""],{"text-color":"#727C85","text-font":["literal",[vi]]}],ro=["has",to],so="#36A8F0",oo="#105287",ao="#ABAFB3",no="#3C4956",lo="#727C85",co=["interpolate",["linear"],["zoom"],1,3,5,4,10,7,18,10],ho=["==",["get","routeState"],"selected"],uo=["==",["get","routeState"],"deselected"],po=["interpolate",["linear"],["zoom"],1,5,5,6,10,10,18,14],yo={s:["interpolate",["linear"],["zoom"],1,2,5,3,10,5,18,7],m:co,l:["interpolate",["linear"],["zoom"],1,5,5,6,10,11,18,15]},fo={s:["interpolate",["linear"],["zoom"],1,4,5,5,10,8,18,11],m:po,l:["interpolate",["linear"],["zoom"],1,7,5,9,10,14,18,19]},mo={s:["interpolate",["linear"],["zoom"],8,.45,22,.6],m:["interpolate",["linear"],["zoom"],8,.6,22,.8],l:["interpolate",["linear"],["zoom"],8,.75,22,1]},go=e=>yo[e??"m"],_o=e=>fo[e??"m"],Lo=e=>mo[e??"m"],bo={s:["interpolate",["linear"],["zoom"],1,8,5,9,10,12,18,15],m:["interpolate",["linear"],["zoom"],1,9,5,11,10,15,18,20],l:["interpolate",["linear"],["zoom"],1,12,5,14,10,19,18,24]},So=e=>bo[e??"m"],Io={s:["interpolate",["linear"],["zoom"],16,8,22,12],m:["interpolate",["linear"],["zoom"],16,12,22,17],l:["interpolate",["linear"],["zoom"],16,17,22,24]},Ao={s:["interpolate",["linear"],["zoom"],16,10,22,14],m:["interpolate",["linear"],["zoom"],16,14,22,20],l:["interpolate",["linear"],["zoom"],16,20,22,28]},Eo=e=>Io[e??"m"],vo=e=>Ao[e??"m"],Ro="#AD0000",To="#FB2D09",Co="#FFC105",wo="#f58240",Oo="#000000",Mo="#C7D2D8",No="rgba(190, 39, 27, 1)",xo="rgba(137, 150, 168, 1)",Do=e=>!1===e?.visible?"":e?.title??["format",["get","title"],{},"\n",{},["get","chargingPower"],{}," • ",{},...io],Fo=e=>{const t=Er(((e=[])=>{const t=/* @__PURE__ */new Map;for(const i of e){if(!i.image)continue;const e={x:i.offsetX??0,y:i.offsetY??0};0===e.x&&0===e.y||t.set(i.id,e)}return t})(e?.icon?.customIcons));return{...sr,filter:ho,minzoom:4,layout:{...sr.layout,"text-field":Do(e?.text),...t&&{"icon-offset":t}},paint:{...sr.paint}}},Po=eo(void 0,"light"),ko="route-country-crossing-plaque",Uo="routeCountryCrossing",Ho=["interpolate",["linear"],["zoom"],5,11,12,13],Wo=["case",[">",["get","bearing"],180],["-",["get","bearing"],270],["-",["get","bearing"],90]],Go=(e,t,i)=>{const r=void 0!==e?or(ko,e):ko,s="route"===t?.alignment;return{type:"symbol",filter:ho,minzoom:t?.minzoom??4,layout:{"symbol-placement":"point","icon-image":r,"icon-text-fit":"both","icon-text-fit-padding":[4,8,4,8],"icon-rotation-alignment":s?"map":"viewport","text-rotation-alignment":s?"map":"viewport",...s&&{"icon-rotate":Wo,"text-rotate":Wo},"text-field":["get","label"],"text-font":[Ei],"text-size":Ho,"text-allow-overlap":!0,"icon-allow-overlap":!0,...!1===t?.visible&&{visibility:"none"}},paint:{"text-color":i?.text??Po.text}}},Bo={filter:ho,minzoom:16},Vo={"line-cap":"round"},zo=e=>({...Bo,type:"line",layout:Vo,paint:{"line-width":vo(e),"line-color":"grey"}}),jo=e=>({...Bo,type:"line",layout:Vo,paint:{"line-width":Eo(e),"line-color":"white"}}),$o="instruction-arrow",Yo={...Bo,type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":$o,"icon-rotation-alignment":"map","icon-rotate":["get","lastPointBearingDegrees"],"icon-size":["interpolate",["linear"],["zoom"],16,1,22,2]}},Ko={filter:ho,type:"line",layout:{"line-join":"round"},paint:{"line-color":"#6dc4ed"}},qo={filter:ho,type:"symbol",minzoom:6,maxzoom:16.5,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-image":"poi-ferry_terminal","icon-size":["interpolate",["linear"],["zoom"],6,.8,16.5,1],"icon-ignore-placement":!0}},Zo={type:"line",layout:{"line-join":"round","line-cap":"round","line-sort-key":["get","index"]}},Xo=e=>({...Zo,filter:uo,paint:{"line-color":no,"line-width":_o(e)}}),Jo=e=>({...Zo,filter:uo,paint:{"line-color":ao,"line-width":go(e)}}),Qo=(e,t)=>({...Zo,filter:ho,paint:{"line-color":t??"#105287","line-width":_o(e)}}),ea=(e,t)=>({...Zo,filter:ho,paint:{"line-color":t??"#36A8F0","line-width":go(e)}}),ta={type:"symbol",layout:{"symbol-placement":"line","icon-image":"roads-arrow-white","icon-rotate":180}},ia="selected-route-summary-popup",ra="deselected-route-summary-popup",sa={filter:ho,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#BEBFFA"}},oa={filter:ho,type:"symbol",minzoom:4,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-image":"poi-toll_plaza","icon-size":["interpolate",["linear"],["zoom"],4,.8,16.5,1]}},aa=["match",["get","magnitudeOfDelay"],"minor",wo,"moderate",To,"major",Ro,"indefinite","#666666",Oo],na={type:"line",layout:{"line-cap":"round"},paint:{"line-color":["match",["get","magnitudeOfDelay"],"minor",Co,"moderate",To,"major",Ro,Mo]}},la={type:"line",filter:["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],layout:{"line-join":"round"},paint:{"line-color":["match",["get","magnitudeOfDelay"],"unknown",No,xo],"line-dasharray":[1.5,1]}},ca={filter:ho,type:"symbol",minzoom:6,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-ignore-placement":!0}},ha={...ca,filter:["all",["has","jamIconID"],ca.filter],layout:{...ca.layout,"icon-image":["get","jamIconID"],"icon-anchor":"bottom-left","text-anchor":"bottom-left","text-field":["get","title"],"text-font":[Ei],"text-offset":[3.9,-1.4],"text-size":13},paint:{...ca.paint,"text-color":aa,"text-halo-color":"#FFFFFF","text-halo-width":1}},ua={...ca,filter:["all",["has","causeIconID"],ca.filter],layout:{...ca.layout,"icon-image":["get","causeIconID"],"icon-anchor":"bottom-right"},paint:{...ca.paint}},da={filter:ho,type:"line",layout:{"line-join":"round"},paint:{"line-color":"#000000","line-opacity":.3}},pa={filter:ho,type:"line",layout:{"line-join":"round"},paint:{"line-color":oo}},ya={filter:ho,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":so}},fa=["carpool","carTrain","importantRoadStretch","lowEmissionZone","motorway","pedestrian","speedLimit","tollVignette","unpaved","urban"],ma=["ferry","tollRoad","traffic","tunnel","vehicleRestricted"],ga=[...fa,...ma],_a=["visible","color","opacity","width","style","pattern","icon"],La={carpool:{sourceKey:"carpoolSections",visible:!1,style:"halo",pattern:"solid",knobs:_a},carTrain:{sourceKey:"carTrainSections",visible:!0,style:"halo",pattern:"dashed",knobs:_a},importantRoadStretch:{sourceKey:"importantRoadStretchSections",visible:!1,style:"halo",pattern:"solid",knobs:_a},lowEmissionZone:{sourceKey:"lowEmissionZoneSections",visible:!0,style:"halo",pattern:"solid",knobs:_a},motorway:{sourceKey:"motorwaySections",visible:!1,style:"halo",pattern:"solid",knobs:_a},pedestrian:{sourceKey:"pedestrianSections",visible:!1,style:"halo",pattern:"dashed",knobs:_a},speedLimit:{sourceKey:"speedLimitSections",visible:!0,knobs:["visible","sign"]},tollVignette:{sourceKey:"tollVignetteSections",visible:!0,style:"halo",pattern:"dashed",knobs:_a},unpaved:{sourceKey:"unpavedSections",visible:!1,style:"halo",pattern:"dashed",knobs:_a},urban:{sourceKey:"urbanSections",visible:!1,style:"halo",pattern:"solid",knobs:_a},ferry:{sourceKey:"ferries",visible:!0,style:"inline",pattern:"solid",knobs:_a},tollRoad:{sourceKey:"tollRoads",visible:!0,style:"halo",pattern:"solid",knobs:_a},traffic:{sourceKey:"incidents",visible:!0,style:"inline",pattern:"solid",knobs:["visible","opacity","width","style"]},tunnel:{sourceKey:"tunnels",visible:!0,style:"inline",pattern:"solid",knobs:_a},vehicleRestricted:{sourceKey:"vehicleRestricted",visible:!0,style:"inline",pattern:"dotted",knobs:_a}},ba=(e,t)=>La[e].knobs.includes(t),Sa=e=>La[e],Ia=e=>La[e].visible,Aa=e=>ba(e,"sign"),Ea=(fa.filter(e=>!Aa(e)),e=>La[e].sourceKey),va={carpool:{color:"#6D4AC7",opacity:.55},carTrain:{color:"#8A5A2B",opacity:.6},importantRoadStretch:{color:"#C7761F",opacity:.6},lowEmissionZone:{color:"#2E8B57",opacity:.5},motorway:{color:"#1F6FB2",opacity:.4},pedestrian:{color:"#B23F86",opacity:.6},tollVignette:{color:"#8C6B1F",opacity:.55},unpaved:{color:"#7A6A54",opacity:.6},urban:{color:"#7E8C8E",opacity:.3}},Ra={solid:void 0,dashed:[2,1.5],dotted:[0,1.5]},Ta=(e,t)=>t?.visible??La[e].visible,Ca=(e,t)=>ba(e,"style")&&t?.style||Sa(e).style,wa={halo:"routeDeselectedOutline",inline:"routeLineArrows"},Oa=(e,t)=>{const i=Ca(e,t);return i&&wa[i]},Ma=(e,t,i,r,s="principal")=>{const o=i?.width??r,a={...t.paint,"line-width":"halo"===Ca(e,i)?So(o):go(o)};if(i?.color&&ba(e,"color")){const e="outline"===s?He(i.color,.4):i.color;e&&(a["line-color"]=e)}return void 0!==i?.opacity&&ba(e,"opacity")&&(a["line-opacity"]=i.opacity),"principal"===s&&ba(e,"pattern")&&((e,t,i)=>{const r=i?.pattern??Sa(e).pattern,s=r&&Ra[r];s?t["line-dasharray"]=s:delete t["line-dasharray"]})(e,a,i),{...t,layout:{...t.layout,...!Ta(e,i)&&{visibility:"none"}},paint:a}},Na=(e,t,i)=>{const r=ba(e,"icon")?i?.icon:void 0;return{...t,layout:{...t.layout,...r&&{"icon-image":r.image,...void 0!==r.size&&{"icon-size":r.size},...r.placement&&{"symbol-placement":"along"===r.placement?"line":"line-center"}},...!Ta(e,i)&&{visibility:"none"}}}},xa=(e,t,i)=>Ma(e,{filter:ho,type:"line",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":va[e].color,"line-opacity":va[e].opacity}},t,i),Da=["interpolate",["linear"],["zoom"],10,.5,16,.7],Fa=["interpolate",["linear"],["zoom"],10,9,16,13],Pa=["-",["get","startPointIndex"],["get","endPointIndex"]],ka=["case",["==",["get","signFace"],"plaque"],["literal",[0,.55]],["literal",[0,0]]],Ua=e=>e?.sign?.placement??"atChange",Ha=(e,t)=>{return{filter:ho,type:"symbol",minzoom:t?.sign?.minzoom??10,layout:{...(i=Ua(t),"atChange"===i?{"symbol-placement":"point"}:{"symbol-placement":"line","symbol-spacing":260}),"icon-image":["get","signImageID"],"icon-size":Da,"icon-rotation-alignment":"viewport","text-field":["get","signLabel"],"text-font":[Ei],"text-size":Fa,"text-offset":ka,"text-rotation-alignment":"viewport","symbol-sort-key":Pa,...!Ta(e,t)&&{visibility:"none"}},paint:{"text-color":["get","signNumeralsColor"]}};var i},Wa=(e,t)=>`routeSection${e.charAt(0).toUpperCase()+e.slice(1)}${t}`,Ga=e=>Wa(e,"Sign"),Ba="traffic-clear",Va="traffic-major",za="traffic-moderate",ja="traffic-minor",$a=["has","formattedTraffic"],Ya=e=>{const t=void 0!==e?or(ia,e):ia,i=void 0!==e?or(ra,e):ra,r=void 0!==e?or(Ba,e):Ba,s=void 0!==e?or(Va,e):Va,o=void 0!==e?or(za,e):za,a=void 0!==e?or(ja,e):ja;return{type:"symbol",layout:{"icon-image":["case",ho,t,i],"symbol-placement":"point","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport","symbol-sort-key":["case",ho,0,1],"icon-text-fit":"both","icon-text-fit-padding":[10,5,5,10],"text-font":[Ri],"text-size":13,"icon-padding":0,"text-justify":"left","text-line-height":1.5,"text-field":["format",["get","formattedDuration"],{"text-font":["literal",[Ei]],"text-color":["case",ho,"black",lo]},["concat","\t\t",["get","formattedDistance"]],{"text-color":lo},["case",$a,"\n",""],{},["image",["case",$a,["match",["get","magnitudeOfDelay"],"major",s,"moderate",o,"minor",a,r],""]],{},["case",$a,["concat"," ",["get","formattedTraffic"]],""],{"text-font":["literal",[Ei]],"text-color":aa}]},paint:{"icon-translate":[0,-35],"text-translate":[0,-35]}}},Ka=Ya(),qa="start",Za="middle",Xa="finish",Ja="stopDisplayIndex",Qa="waypointStart",en="waypointStop",tn="waypointFinish",rn=["format",["coalesce",["get",qi],""],{},["case",["all",["has",qi],ro],"\n",""],{},...io],sn={"text-field":["get",Ja],"text-font":[Ei],"text-size":["interpolate",["linear"],["zoom"],13,14,18,16],"text-offset":[0,-1.6],"icon-anchor":"bottom","text-allow-overlap":!0},on={type:"symbol",paint:{...tr,"text-color":"#ffffff"},layout:{...er,...sn,"symbol-sort-key":["abs",["-",["get","index"],1e3]]}},an={type:"symbol",paint:{...rr,"text-color":"black","text-halo-width":1.5,"text-halo-color":"#ffffff"},layout:{...ir,"text-field":rn,"text-anchor":"top","text-offset":[0,.4]}},nn=(e,t)=>e&&t&&(e.startsWith("route")||e.startsWith("waypoint"))?`${t}-${e}`:e,ln=(e,t)=>e&&t?Object.fromEntries(Object.entries(e).map(([e,i])=>[e,i?.beforeID?{...i,beforeID:nn(i.beforeID,t)}:i])):e,cn=(e,t)=>e&&void 0!==t?`${e}-${t}`:e,hn=(e={},t,i,r="light")=>{const s=e.layers,o=s?.sections,a=e.theme?.mainColor,n=a?He(a,.4):void 0,l=e.theme?.routeWidth,c=e.theme?.waypointSize,h=Lo(c),u=e.sections,d=(e,i,r)=>({...Ma(e,i,u?.[e],l,r?.role),beforeID:nn(r?.beforeID??Oa(e,u?.[e]),t)}),p=(e,i,r)=>({...Na(e,i,u?.[e]),beforeID:nn(r,t)}),y=Object.fromEntries(fa.map(e=>{const i=u?.[e],r=(e=>Wa(e,"Line"))(e),s=(e=>Wa(e,"Symbol"))(e),a=o?.[e];if(Aa(e)){const r=Ga(e);return[e,{[r]:nr(Ha(e,i),a?.[r]),...ln(a?.additional,t)}]}const n=i&&((e,t)=>{if(t.icon&&ba(e,"icon"))return Na(e,{filter:ho,type:"symbol",layout:{"symbol-placement":"line-center","icon-allow-overlap":!0,"icon-rotation-alignment":"viewport"}},t)})(e,i);return[e,{[r]:nr({...xa(e,i,l),beforeID:nn(Oa(e,i),t)},a?.[r]),...n&&{[s]:nr({...n,beforeID:Ni.lowestLabel},a?.[s])},...ln(a?.additional,t)}]}));return{mainLines:{routeLineArrows:nr({...ta,beforeID:Ni.lowestLabel},s?.mainLines?.routeLineArrows),routeLine:nr({...ea(l,a),beforeID:nn("routeIncidentBackgroundLine",t)},s?.mainLines?.routeLine),routeOutline:nr({...Qo(l,n),beforeID:nn("routeLine",t)},s?.mainLines?.routeOutline),routeDeselectedLine:nr({...Jo(l),beforeID:nn("routeOutline",t)},s?.mainLines?.routeDeselectedLine),routeDeselectedOutline:nr({...Xo(l),beforeID:nn("routeDeselectedLine",t)},s?.mainLines?.routeDeselectedOutline),...ln(s?.mainLines?.additional,t)},waypoints:{routeWaypointSymbol:nr({...on,layout:{...on.layout,"icon-size":h},beforeID:nn("routeSummaryBubbleSymbol",t)},s?.waypoints?.routeWaypointSymbol),routeWaypointLabel:nr({...an,beforeID:nn("routeWaypointSymbol",t)},s?.waypoints?.routeWaypointLabel),...ln(s?.waypoints?.additional,t)},chargingStops:{routeChargingStopSymbol:nr({...Fo(e.chargingStops),beforeID:nn("routeWaypointSymbol",t)},s?.chargingStops?.routeChargingStopSymbol),...ln(s?.chargingStops?.additional,t)},sections:{...y,traffic:{routeIncidentJamSymbol:nr(p("traffic",ha,"routeChargingStopSymbol"),o?.traffic?.routeIncidentJamSymbol),routeIncidentCauseSymbol:nr(p("traffic",ua,"routeChargingStopSymbol"),o?.traffic?.routeIncidentCauseSymbol),routeIncidentBackgroundLine:nr(d("traffic",na,{beforeID:"routeIncidentDashedLine"}),o?.traffic?.routeIncidentBackgroundLine),routeIncidentDashedLine:nr(d("traffic",la),o?.traffic?.routeIncidentDashedLine),...ln(o?.traffic?.additional,t)},ferry:{routeFerryLine:nr(d("ferry",Ko),o?.ferry?.routeFerryLine),routeFerrySymbol:nr(p("ferry",qo,"routeIncidentJamSymbol"),o?.ferry?.routeFerrySymbol),...ln(o?.ferry?.additional,t)},tollRoad:{routeTollRoadOutline:nr(d("tollRoad",sa),o?.tollRoad?.routeTollRoadOutline),routeTollRoadSymbol:nr(p("tollRoad",oa,"routeChargingStopSymbol"),o?.tollRoad?.routeTollRoadSymbol),...ln(o?.tollRoad?.additional,t)},tunnel:{routeTunnelLine:nr(d("tunnel",da),o?.tunnel?.routeTunnelLine),...ln(o?.tunnel?.additional,t)},vehicleRestricted:{routeVehicleRestrictedBackgroundLine:nr(d("vehicleRestricted",pa,{beforeID:"routeVehicleRestrictedForegroundLine",role:"outline"}),o?.vehicleRestricted?.routeVehicleRestrictedBackgroundLine),routeVehicleRestrictedForegroundLine:nr(d("vehicleRestricted",ya),o?.vehicleRestricted?.routeVehicleRestrictedForegroundLine),...ln(o?.vehicleRestricted?.additional,t)}},instructionLines:{routeInstructionLine:nr({...jo(l),beforeID:Ni.lowestLabel},s?.instructionLines?.routeInstructionLine),routeInstructionOutline:nr({...zo(l),beforeID:nn("routeInstructionLine",t)},s?.instructionLines?.routeInstructionOutline),...ln(s?.instructionLines?.additional,t)},instructionArrows:{routeInstructionArrowSymbol:nr({...Yo,beforeID:nn("routeInstructionLine",t),...void 0!==i&&{layout:{...Yo.layout,"icon-image":cn(Yo.layout?.["icon-image"],i)}}},s?.instructionArrows?.routeInstructionArrowSymbol),...ln(s?.instructionArrows?.additional,t)},summaryBubbles:{routeSummaryBubbleSymbol:nr(void 0===i?Ka:Ya(i),s?.summaryBubbles?.routeSummaryBubbleSymbol),...ln(s?.summaryBubbles?.additional,t)},countryCrossings:{[Uo]:nr({...Go(i,e.countryCrossings,eo(e.countryCrossings,r)),beforeID:nn("routeWaypointSymbol",t)},s?.countryCrossings?.[Uo]),...ln(s?.countryCrossings?.additional,t)}}},un=hn();Nt()&&(ai=xt(Dt('<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">\n <path d="M1.562 40.569L25 1.562l23.438 39.007L25 27.566 1.562 40.569z" fill="#fff"/>\n <path d="M25.369.107c.782.429.506.167.917.682l23.438 39.007c.79 1.316-.671 2.829-2.014 2.085L25 29.281l-22.71 12.6c-1.343.744-2.804-.769-2.014-2.085L23.714.789c.461-.694.9-.682 1.656-.682zM25 1.562L1.562 40.569 25 27.566l23.438 13.003L25 1.562z"\n fill="gray"/>\n</svg>\n')));var dn,pn=e=>{if(!Nt())return;const t=Dt('<svg xmlns="http://www.w3.org/2000/svg" width="160" height="65">\n <g filter="url(#A)">\n <rect id="pin" x="81.899" y="47" width="10" height="10" rx="2" transform="rotate(45 81.899 47)"/>\n <rect id="bubble" x="10" y="10" width="140" height="45" rx="12"/>\n </g>\n <defs>\n <filter id="A">\n <feDropShadow dx="0" dy="2" stdDeviation="4" flood-opacity=".3"/>\n </filter>\n </defs>\n</svg>\n');return t.querySelector("#bubble")?.setAttribute("fill",e),t.querySelector("#pin")?.setAttribute("fill",e),xt(t)},yn={pixelRatio:2,stretchX:[[20,45],[100,130]],stretchY:[[20,35]],content:[10,10,130,45]},fn={pixelRatio:2,stretchX:[[30,110]],stretchY:[[25,35]],content:[10,10,130,50]},mn=e=>{if(!Nt())return;const t=Dt('<svg xmlns="http://www.w3.org/2000/svg" width="140" height="60">\n <g filter="url(#shadow)">\n <rect id="plaque" x="10" y="10" width="120" height="40" rx="8"/>\n </g>\n <defs>\n <filter id="shadow">\n <feDropShadow dx="0" dy="2" stdDeviation="3" flood-opacity=".35"/>\n </filter>\n </defs>\n</svg>\n');return t.querySelector("#plaque")?.setAttribute("fill",e),xt(t)},gn={whiteDisc:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><circle cx="23" cy="23" r="19.5" fill="#fff" stroke="#D0021B" stroke-width="5"/></svg>\n',yellowDisc:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><circle cx="23" cy="23" r="19.5" fill="#FFCE00" stroke="#D0021B" stroke-width="5"/></svg>\n',plaque:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><rect x="7" y="3" width="32" height="40" rx="2" fill="#fff" stroke="#1A2024" stroke-width="2"/><text x="23" y="13" fill="#1A2024" font-family="sans-serif" font-size="7" font-weight="bold" text-anchor="middle">SPEED</text><text x="23" y="21" fill="#1A2024" font-family="sans-serif" font-size="7" font-weight="bold" text-anchor="middle">LIMIT</text></svg>\n'},_n=e=>{if(Nt())return xt(Dt(gn[e]))},Ln=e=>{if(!Nt())return;const t=Dt('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">\n <g id="main">\n <path fill-rule="evenodd"\n d="M11.389 4H9.025a.86.86 0 0 0-.517.173l-.001-.001a.5.5 0 0 1-.464.059l-.028-.011a.5.5 0 0 1-.129-.83A1.86 1.86 0 0 1 9.025 3h2.364a2 2 0 0 1 1.789 1.106l1.02 2.04c.471.176.802.63.802 1.156v.803c0 .543 0 .815-.071 1.038a1.5 1.5 0 0 1-.914.953c-.219.08-.491.092-1.034.114l-1.481.062v-.166-.803a2.23 2.23 0 0 0-1.055-1.897l-.74-1.479 2.326.033h.955l-.703-1.406A1 1 0 0 0 11.389 4zM12 8.4a1 1 0 1 1 2 0 .5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5z"/>\n <path d="M11.833 11.115c0-.109.089-.198.198-.198h1.979c.109 0 .198.089.198.198 0 .328-.266.594-.594.594h-1.187c-.328 0-.594-.266-.594-.594z"/>\n <path fill-rule="evenodd"\n d="M1.802 8.146C1.331 8.321 1 8.776 1 9.302v.803c0 .543 0 .815.071 1.038a1.5 1.5 0 0 0 .914.953c.219.08.491.092 1.034.114l2.731.114 2.731-.114c.543-.023.814-.034 1.034-.114a1.5 1.5 0 0 0 .914-.953c.071-.223.071-.494.071-1.038v-.803c0-.526-.331-.98-.802-1.156l-1.02-2.04A2 2 0 0 0 6.889 5H4.611a2 2 0 0 0-1.789 1.106l-1.02 2.04zM6.889 6H4.611a1 1 0 0 0-.894.553l-.703 1.406h.955 3.563.955l-.703-1.406A1 1 0 0 0 6.889 6zM2 10.4a1 1 0 1 1 2 0 .5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zm6.5-1a1 1 0 0 0-1 1 .5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5 1 1 0 0 0-1-1z"/>\n <path d="M1.792 13.115c0-.109.089-.198.198-.198h1.979c.109 0 .198.089.198.198 0 .328-.266.594-.594.594H2.385c-.328 0-.594-.266-.594-.594zm5.739-.198c-.109 0-.198.089-.198.198 0 .328.266.594.594.594h1.188c.328 0 .594-.266.594-.594 0-.109-.089-.198-.198-.198h-1.98z"/>\n </g>\n</svg>\n'),i=t.querySelector("#main");return i.setAttribute("transform","scale(2)"),i.setAttribute("fill",e),xt(t)},bn=(e,t)=>{if(!Nt())return;const i=Ft(t);return e&&i.appendChild(e),xt(i)},Sn=e=>{if(Nt())return bn(Dt('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path d="M63.734 86.383c-1.404.026-2.78-.393-3.93-1.197s-2.01-1.949-2.46-3.271l-3.15-9.339c-1.093-3.403-3.748-6.089-7.154-7.238L37.5 62.21c-2.742-.902-4.567-3.477-4.5-6.345-.058-2.874 1.761-5.457 4.5-6.388l36-11.886c2.461-.88 5.213-.27 7.062 1.567s2.466 4.571 1.578 7.015L70.17 81.918c-.938 2.719-3.54 4.526-6.436 4.469h0z"\n fill="#f4f5f6"/>\n</svg>\n'),e)},In=e=>{if(Nt())return bn(Dt('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path d="M33 83.404a2.99 2.99 0 0 1-3-2.978V44.681a2.99 2.99 0 1 1 6 0v35.745a2.99 2.99 0 0 1-3 2.978zm48-38.723H39v17.872h42V44.681zm3.878 37.851a3.02 3.02 0 0 0 4.244 0c.561-.559.878-1.317.878-2.106V44.681a2.99 2.99 0 1 0-6 0v35.745c0 .789.317 1.547.878 2.106z"\n fill="#f4f5f6"/>\n</svg>\n'),e)},An=(e={},t)=>Object.entries(e).map(([e,i])=>({...i,id:ar(e,t)})),En=(e={},t)=>({...Object.fromEntries(fa.map(i=>[Ea(i),An(e.sections?.[i],t)])),mainLines:An(e.mainLines,t),waypoints:An(e.waypoints,t),chargingStops:An(e?.chargingStops,t),ferries:An(e.sections?.ferry,t),incidents:An(e.sections?.traffic,t),tollRoads:An(e.sections?.tollRoad,t),tunnels:An(e.sections?.tunnel,t),vehicleRestricted:An(e.sections?.vehicleRestricted,t),instructionLines:An(e.instructionLines,t),instructionArrows:An(e.instructionArrows,t),summaryBubbles:An(e.summaryBubbles,t),countryCrossings:An(e.countryCrossings,t)}),vn=(e,t,i,r)=>{const s=h.instance.get().displayUnits,o=e?.displayUnits;return{...e,...o?{}:{displayUnits:s},layers:hn(e,t,i,r)}},Rn=(e,t)=>{const i=e[t-1]??e[t],r=e[t+1]??e[t];return i===r?0:(k(i,r)+360)%360},Tn=(e,t,i,r)=>{const s=m();return{type:"Feature",id:s,geometry:{type:"Point",coordinates:i[t.startPointIndex]},properties:{id:s,fromCountryCode:e.countryCodeISO2,toCountryCode:t.countryCodeISO2,label:`${e.countryCodeISO2} → ${t.countryCodeISO2}`,bearing:Rn(i,t.startPointIndex),fromSectionStartPointIndex:e.startPointIndex,toSectionStartPointIndex:t.startPointIndex,routeState:r.routeState,routeIndex:r.index}}},Cn=e=>{const t=e.properties.sections.country;if(!t?.length)return[];const i=[...t].sort((e,t)=>e.startPointIndex-t.startPointIndex),r=e.geometry.coordinates;return i.slice(1).flatMap((t,s)=>r[t.startPointIndex]?[Tn(i[s],t,r,e.properties)]:[])},wn=e=>({type:"FeatureCollection",features:e.features.flatMap(Cn)}),On=(e,t)=>{const i=t?.chargingStops?.icon;if(i?.mapping){const t=i.mapping;switch(t.basedOn){case"chargingSpeed":if(e.properties.chargingConnectionInfo?.chargingSpeed)return t.value[e.properties.chargingConnectionInfo?.chargingSpeed];break;case"custom":return t.fn(e)}}return Mt("7309")},Mn=e=>{const t=e.properties;return t.chargingParkName??t.chargingParkOperatorName},Nn=e=>e.categories.includes("jam"),xn=e=>{const t=(e=>{if(Nn(e))return f(e.delayInSeconds)})(e),i=((e,t)=>Nn(e)?`traffic-jam-${e.magnitudeOfDelay??"unknown"}-${(e=>e?.length?e.length<6?"small":e.length<8?"medium":"large":"collapsed")(t)}`:null)(e,t),r=(e=>{const t=e.categories.find(e=>"jam"!==e);return t?(e=>{switch(e){case"accident":return"traffic-incidents-accident";case"roadworks":return"traffic-incidents-roadworks";case"road-closed":return"traffic-incidents-road_closed";case"lane-closed":case"narrow-lanes":return"traffic-incidents-lane_closed";case"danger":case"animals-on-road":return"traffic-incidents-danger";case"broken-down-vehicle":return"traffic-incidents-broken_down_vehicle";case"wind":return"traffic-incidents-wind";case"fog":return"traffic-incidents-fog";case"rain":return"traffic-incidents-rain";case"frost":return"traffic-incidents-frost";case"flooding":return"traffic-incidents-flooding";default:return null}})(t):null})(e);return{...e,...i&&{jamIconID:i},...r&&{causeIconID:r},...t&&{title:t}}},Dn=(e,t,i)=>{let r;switch(t){case"start":r=Qa;break;case"finish":r=tn;break;default:r=en}return void 0!==i?or(r,i):r},Fn=(e,t,i,r)=>({type:"FeatureCollection",features:e.map((s,o)=>{if(!s)return null;const a=(e=>{return Array.isArray(e)?{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{}}:"Point"===e.type?{type:"Feature",geometry:t=e,properties:{},...t.bbox&&{bbox:t.bbox}}:e;var t})(s),n=((e,t)=>0===e?qa:e<t-1?Za:Xa)(o,e.length),l=(e=>{const t=e?.properties;return t?.poi?.name??t?.address?.freeformAddress??void 0})(a),c=a.id??m(),h=f(a.properties.pauseDurationSeconds,r);return{...a,..."main-when-available"===t?.entryPoints&&{geometry:{type:"Point",coordinates:_(a,{useEntryPoint:"main-when-available"})}},id:c,properties:{...a.properties,id:c,index:o,indexType:n,...l&&{title:l},...h&&{stopDuration:h},iconID:Dn(0,n,i),..."middle"===n&&{stopDisplayIndex:o}}}}).filter(e=>e)}),Pn=(e,t,i)=>({type:"FeatureCollection",features:e.features.flatMap(e=>((e,t,i)=>e.properties.sections[t]?.map(t=>{const r=t.id??m();return{type:"Feature",id:r,geometry:{type:"LineString",coordinates:e.geometry.coordinates.slice(t.startPointIndex,t.endPointIndex+1)},properties:{...i?i(t,e.properties):t,routeState:e.properties.routeState,routeIndex:e.properties.index,id:r}}})||[])(e,t,i))}),kn=(e,t)=>t.show(((e,t)=>({...t,features:t.features.map(t=>({...t,properties:{...t.properties,routeState:e.features[t.properties.routeIndex||0].properties.routeState}}))}))(e,t.shownFeatures)),Un=(e,t=0)=>{const i="features"in e?e:{type:"FeatureCollection",features:[e]};return{...i,features:i.features.map((e,i)=>{const r=e.id??m();return{...e,id:r,properties:{...e.properties,id:r,routeState:i===t?"selected":"deselected"}}})}},Hn=(e,t)=>e.some(e=>e.magnitudeOfDelay===t),Wn=(e,t)=>({type:"FeatureCollection",features:e.features.map(e=>{const i=e.properties.summary,r=e.geometry.coordinates,s=f(i.trafficDelayInSeconds,t?.time),o=(e=>{const t=e.properties.sections.traffic;if(t?.length)return Hn(t,"major")?"major":Hn(t,"moderate")?"moderate":Hn(t,"minor")?"minor":void 0})(e),a=e.id??m();return{type:"Feature",id:a,geometry:{type:"Point",coordinates:r[Math.round(r.length/2)]},properties:{id:a,routeIndex:e.properties.index,routeState:e.properties.routeState,formattedDistance:y(i.lengthInMeters,t?.distance),...o&&{magnitudeOfDelay:o},...s&&{formattedTraffic:s},formattedDuration:f(i.travelTimeInSeconds,t?.time)}}})}),Gn={GBR:{unit:"mph"},LBR:{unit:"mph"},MMR:{unit:"mph"},USA:{face:"plaque",unit:"mph"},SWE:{face:"yellowDisc"},FIN:{face:"yellowDisc"},ISL:{face:"yellowDisc"},JPN:{numerals:"#0B5FA5"}},Bn={metric:{},imperial_uk:{unit:"mph"},imperial_us:{face:"plaque",unit:"mph"}},Vn={whiteDisc:"routeSpeedLimitWhiteDisc",yellowDisc:"routeSpeedLimitYellowDisc",plaque:"routeSpeedLimitPlaque"},zn=(e,t)=>"mph"===t?5*Math.round(1e3*e/c/5):e,jn=class e extends Qt{static async create(t,i){return await Pt(t),new e(t,i)}constructor(e,t){super(e,t),this.shownFeaturesHandlers=[]}createSourcesWithLayers(e){const t=or("routes",this.instanceIndex);return{...Object.fromEntries(fa.map(i=>{const r=Ea(i);return[r,new yi(this.mapLibreMap,`${t}-${r}`,e[r],!1)]})),mainLines:new yi(this.mapLibreMap,`${t}-mainLines`,e.mainLines,!1),waypoints:new yi(this.mapLibreMap,`${t}-waypoints`,e.waypoints,!1),incidents:new yi(this.mapLibreMap,`${t}-incidents`,e.incidents,!1),ferries:new yi(this.mapLibreMap,`${t}-ferries`,e.ferries,!1),chargingStops:new yi(this.mapLibreMap,`${t}-chargingStops`,e.chargingStops,!1),tollRoads:new yi(this.mapLibreMap,`${t}-tollRoads`,e.tollRoads,!1),tunnels:new yi(this.mapLibreMap,`${t}-tunnels`,e.tunnels,!1),vehicleRestricted:new yi(this.mapLibreMap,`${t}-vehicleRestricted`,e.vehicleRestricted,!1),instructionLines:new yi(this.mapLibreMap,`${t}-instructionLines`,e.instructionLines,!1),instructionArrows:new yi(this.mapLibreMap,`${t}-instructionArrows`,e.instructionArrows,!1),summaryBubbles:new yi(this.mapLibreMap,`${t}-summaryBubbles`,e.summaryBubbles,!1),countryCrossings:new yi(this.mapLibreMap,`${t}-countryCrossings`,e.countryCrossings,!1)}}_initSourcesWithLayers(e,t){t||(this.layerIDPrefix=or("routes",this.instanceIndex)),this.layersSpecs=En(vn(e,this.layerIDPrefix,this.instanceIndex,this.tomtomMap.styleLightDarkTheme).layers,this.layerIDPrefix);const i=this.createSourcesWithLayers(this.layersSpecs);Vt(Object.values(i).flatMap(e=>e._layerSpecs),this.mapLibreMap);const r={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},s={pixelRatio:2},o=or(Qa,this.instanceIndex),a=or(en,this.instanceIndex),n=or(tn,this.instanceIndex),l=or($o,this.instanceIndex),c=or(ia,this.instanceIndex),h=or(ra,this.instanceIndex),u=or(Ba,this.instanceIndex),d=or(Va,this.instanceIndex),p=or(za,this.instanceIndex),y=or(ja,this.instanceIndex);this.addImageIfNotExisting(o,Sn(r),s),this.addImageIfNotExisting(a,bn(void 0,r),s),this.addImageIfNotExisting(n,In(r),s),this.addImageIfNotExisting(l,ai,s),this.addImageIfNotExisting(c,pn("white"),yn),this.addImageIfNotExisting(h,pn("#EEEEEE"),yn);for(const[f,m]of Object.entries(Vn))this.addImageIfNotExisting(or(m,this.instanceIndex),_n(f),s);this.appliedCrossingColors=void 0,this.addImageIfNotExisting(or(ko,this.instanceIndex),mn(this.crossingColors(this.config).plaque),{...s,...fn}),this.addImageIfNotExisting(u,Ln(Oo),s),this.addImageIfNotExisting(d,Ln(Ro),s),this.addImageIfNotExisting(p,Ln(To),s),this.addImageIfNotExisting(y,Ln(wo),s);for(const f of e?.chargingStops?.icon?.customIcons??[])this.addImageIfNotExisting(f.id,f.image,{pixelRatio:f.pixelRatio??2});return i}_applyConfig(e){const i=vn(e,this.layerIDPrefix,this.instanceIndex,this.tomtomMap.styleLightDarkTheme),r=!t(this.config?.displayUnits,i.displayUnits);if(this.config){const t=En(i.layers,this.layerIDPrefix);Object.keys(t).forEach(e=>{const i=e;Wt(t[i],this.layersSpecs[i],this.sourcesWithLayers[i],this.mapLibreMap)});const s=Object.values(this.sourcesWithLayers);Vt(s.flatMap(e=>e._layerSpecs),this.mapLibreMap),this.reshowSpeedLimitSigns(i,r),s.forEach(e=>e.setLayersVisible(!!e.shownFeatures.features.length)),this.applySectionVisibility(e),this.applySignPriority(e),this.layersSpecs=t}if(e?.theme?.mainColor!==this.config?.theme?.mainColor){const t={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},i={pixelRatio:2};$t("add-or-update",or(Qa,this.instanceIndex),Sn(t),this.mapLibreMap,i),$t("add-or-update",or(en,this.instanceIndex),bn(void 0,t),this.mapLibreMap,i),$t("add-or-update",or(tn,this.instanceIndex),In(t),this.mapLibreMap,i)}const s=!1!==i.summaryBubbles?.visible,o=!t(this.config?.summaryBubbles?.visible,i.summaryBubbles?.visible),a=this.sourcesWithLayers.summaryBubbles.shownFeatures.features.length>0,n=this.sourcesWithLayers.mainLines.shownFeatures.features.length>0;return!s&&o?this.sourcesWithLayers.summaryBubbles.clear():s&&(o&&n||r&&a)&&this.sourcesWithLayers.summaryBubbles.show(Wn(this.sourcesWithLayers.mainLines.shownFeatures,i.displayUnits)),this.applyCountryCrossingConfig(i),i}showSpeedLimitSections(e,t){var i,r;this.sourcesWithLayers.speedLimitSections.show(Pn(e,"speedLimit",(i=this.instanceIndex,r={unit:t?.sections?.speedLimit?.sign?.unit,displayUnits:t?.displayUnits},(e,t)=>{const s=(o=e.startPointIndex,a=t?.sections.country,a?.find(e=>o>=e.startPointIndex&&o<=e.endPointIndex)?.countryCodeISO3);var o,a;const n=s?Gn[s]??{}:Bn[r?.displayUnits?.distance?.type??"metric"],l=n.face??"whiteDisc",c=r?.unit??n.unit??"km/h";return{...e,signImageID:or(Vn[l],i),signLabel:String(zn(e.maxSpeedLimitInKmh,c)),signFace:l,signNumeralsColor:n.numerals??"#1A2024"}})))}crossingColors(e){return eo(e?.countryCrossings,this.tomtomMap.styleLightDarkTheme)}applyCountryCrossingConfig(e){const i=!1!==e.countryCrossings?.visible,r=!t(this.config?.countryCrossings?.visible,e.countryCrossings?.visible);!i&&r?this.sourcesWithLayers.countryCrossings.clear():i&&r&&this.sourcesWithLayers.countryCrossings.show(wn(this.sourcesWithLayers.mainLines.shownFeatures));const s=this.crossingColors(e);if(t(this.appliedCrossingColors,s))return;this.appliedCrossingColors=s,$t("add-or-update",or(ko,this.instanceIndex),mn(s.plaque),this.mapLibreMap,fn);const o=ar(Uo,this.layerIDPrefix);this.mapLibreMap.getLayer(o)&&this.mapLibreMap.setPaintProperty(o,"text-color",s.text,{validate:!1})}reshowSpeedLimitSigns(e,i){t(this.config?.sections?.speedLimit?.sign?.unit,e.sections?.speedLimit?.sign?.unit)&&!i||this.sourcesWithLayers.speedLimitSections.shownFeatures.features.length&&this.showSpeedLimitSections(this.sourcesWithLayers.mainLines.shownFeatures,e)}applySectionVisibility(e){for(const t of ga){const i=this.sourcesWithLayers[Ea(t)],r=!!i.shownFeatures.features.length;i.setLayersVisible(r&&Ta(t,e?.sections?.[t]))}}signLayerID(e){if(Aa(e))return ar(Ga(e),this.layerIDPrefix)}applySignPriority(e){for(const t of fa){const i=this.signLayerID(t);if(!i||!this.mapLibreMap.getLayer(i))continue;const r=e?.sections?.[t];this.mapLibreMap.moveLayer(i,this.signAnchorLayerID(i,r))}}signAnchorLayerID(e,t){const i=(e=>e?.sign?.priority??("atChange"===Ua(e)?"belowRouteIcons":"belowMapLabels"))(t);if("aboveRouteIcons"===i)return;const r=this.mapLibreMap.getStyle().layers;if("belowMapLabels"===i)return Ni.lowestLabel;const s=r.findIndex(e=>e.id===Ni.lowestLabel);return r.find((t,i)=>"symbol"===t.type&&t.id!==e&&i>s&&(!this.layerIDPrefix||t.id.startsWith(this.layerIDPrefix)))?.id}discardShownData(){}restoreDataAndConfigImpl(){const e=Object.fromEntries(Object.entries(this.sourcesWithLayers).map(([e,t])=>[e,t.shownFeatures]));this.initSourcesWithLayers(this.config,!0),this._applyConfig(this.config);for(const t of Object.keys(e))this.sourcesWithLayers[t].show(e[t]);this.applySectionVisibility(this.config)}addImageIfNotExisting(e,t,i){$t("if-not-in-sprite",e,t,this.mapLibreMap,i)}async showRoutes(e,t){const i=Un(e,t?.selectedIndex);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(i),this.sourcesWithLayers.vehicleRestricted.show(Pn(i,"vehicleRestricted")),this.sourcesWithLayers.incidents.show(Pn(i,"traffic",xn)),this.sourcesWithLayers.chargingStops.show(((e,t)=>{const i=[];if(!1!==t?.chargingStops?.visible)for(const r of e.features)for(const e of r.properties.sections.leg){const s=e.summary.chargingInformationAtEndOfLeg;if(s){const o=s.properties,a=f(e.summary.stopTimeInSeconds??o.chargingTimeInSeconds,t?.displayUnits?.time);i.push({...s,properties:{...s.properties,id:s.properties.chargingParkId??m(),iconID:On(s,t),title:Mn(s),chargingPower:`${o.chargingConnectionInfo?.chargingPowerInkW} kW`,chargingDuration:f(o.chargingTimeInSeconds,t?.displayUnits?.time),...a&&{stopDuration:a},routeState:r.properties.routeState,routeIndex:r.properties.index}})}}return{type:"FeatureCollection",features:i}})(i,this.config)),this.sourcesWithLayers.ferries.show(Pn(i,"ferry")),this.sourcesWithLayers.tunnels.show(Pn(i,"tunnel")),this.sourcesWithLayers.tollRoads.show(Pn(i,"tollRoad"));for(const r of fa)Aa(r)||this.sourcesWithLayers[Ea(r)].show(Pn(i,r));this.showSpeedLimitSections(i,this.config),this.applySectionVisibility(this.config),this.applySignPriority(this.config),this.sourcesWithLayers.instructionLines.show((e=>({type:"FeatureCollection",features:e.features.flatMap((e,t)=>e.properties.guidance?.instructions?.filter(e=>e.routePath?.length).map(i=>({type:"Feature",geometry:{type:"LineString",coordinates:i.routePath.map(e=>e.point)},properties:{...i,id:m(),routeIndex:t,routeState:e.properties.routeState}}))||[])}))(i)),this.sourcesWithLayers.instructionArrows.show((e=>({type:"FeatureCollection",features:e.features.flatMap((e,t)=>e.properties.guidance?.instructions?.filter(e=>e.routePath?.length&&e.routePath.length>1).map(i=>{const r=[i.routePath[i.routePath.length-2]?.point,i.routePath[i.routePath.length-1]?.point];return{type:"Feature",geometry:{type:"Point",coordinates:r[1]},properties:{...i,id:m(),routeIndex:t,routeState:e.properties.routeState,lastPointBearingDegrees:k(r[0],r[1])}}})||[])}))(i)),!1!==this.config?.countryCrossings?.visible?this.sourcesWithLayers.countryCrossings.show(wn(i)):this.sourcesWithLayers.countryCrossings.clear(),!1!==this.config?.summaryBubbles?.visible?this.sourcesWithLayers.summaryBubbles.show(Wn(i,this.config?.displayUnits)):this.sourcesWithLayers.summaryBubbles.clear();for(const r of this.shownFeaturesHandlers)r({routes:e})}async clearRoutes(){await this.waitUntilModuleReady();for(const e of Object.keys(this.sourcesWithLayers))"waypoints"!==e&&this.sourcesWithLayers[e].clear()}async selectRoute(e){const t=Un(this.sourcesWithLayers.mainLines.shownFeatures,e);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(t),kn(t,this.sourcesWithLayers.chargingStops),kn(t,this.sourcesWithLayers.vehicleRestricted),kn(t,this.sourcesWithLayers.incidents),kn(t,this.sourcesWithLayers.ferries),kn(t,this.sourcesWithLayers.tollRoads);for(const i of fa)kn(t,this.sourcesWithLayers[Ea(i)]);kn(t,this.sourcesWithLayers.tunnels),kn(t,this.sourcesWithLayers.instructionLines),kn(t,this.sourcesWithLayers.instructionArrows),kn(t,this.sourcesWithLayers.summaryBubbles),kn(t,this.sourcesWithLayers.countryCrossings),this.applySectionVisibility(this.config)}async showWaypoints(e){const t=Array.isArray(e)?Fn(e,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time):Fn(e.features,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time);await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.show(t),this.applySignPriority(this.config);for(const i of this.shownFeaturesHandlers)i({waypoints:e})}async clearWaypoints(){await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.clear()}getShown(){return{mainLines:this.sourcesWithLayers.mainLines.shownFeatures,waypoints:this.sourcesWithLayers.waypoints.shownFeatures,incidents:this.sourcesWithLayers.incidents.shownFeatures,ferries:this.sourcesWithLayers.ferries.shownFeatures,chargingStops:this.sourcesWithLayers.chargingStops.shownFeatures,tollRoads:this.sourcesWithLayers.tollRoads.shownFeatures,...Object.fromEntries(fa.map(e=>[Ea(e),this.sourcesWithLayers[Ea(e)].shownFeatures])),tunnels:this.sourcesWithLayers.tunnels.shownFeatures,vehicleRestricted:this.sourcesWithLayers.vehicleRestricted.shownFeatures,instructionLines:this.sourcesWithLayers.instructionLines.shownFeatures,instructionArrows:this.sourcesWithLayers.instructionArrows.shownFeatures,summaryBubbles:this.sourcesWithLayers.summaryBubbles.shownFeatures,countryCrossings:this.sourcesWithLayers.countryCrossings.shownFeatures}}get events(){const e=Object.fromEntries(fa.map(e=>[Ea(e),this.userEvents([Ea(e)])]));return this.buildEvents(this.moduleEventsWithShown(["mainLines","waypoints","chargingStops","summaryBubbles","countryCrossings","incidents","vehicleRestricted","ferries","tollRoads","tunnels","instructionLines",...fa.map(Ea)],this.shownFeaturesHandlers),{...e,mainLines:this.userEvents(["mainLines"]),waypoints:this.userEvents(["waypoints"]),chargingStops:this.userEvents(["chargingStops"]),summaryBubbles:this.userEvents(["summaryBubbles"]),countryCrossings:this.userEvents(["countryCrossings"],{mapping:e=>((e,t)=>{const i=e.properties,r=t.features[i.routeIndex]?.properties.sections.country??[],s=e=>r.find(t=>t.startPointIndex===e);return{type:"Feature",id:e.id,geometry:e.geometry,properties:{...i,fromSection:s(i.fromSectionStartPointIndex),toSection:s(i.toSectionStartPointIndex)}}})(e,this.sourcesWithLayers.mainLines.shownFeatures)}),incidents:this.userEvents(["incidents"]),vehicleRestricted:this.userEvents(["vehicleRestricted"]),ferries:this.userEvents(["ferries"]),tollRoads:this.userEvents(["tollRoads"]),tunnels:this.userEvents(["tunnels"]),instructionLines:this.userEvents(["instructionLines"])})}getLayerToRenderLinesUnder(){return Ni.lowestLabel}},$n={min:.5,max:1.5,step:.1},Yn={min:.5,max:2,step:.1},Kn={sourceTypes:["vector"],layerTypes:["symbol"]},qn={sources:["vectorTiles"],sourceLayers:["poi"],layerTypes:["symbol"]},Zn={...Rs("roads"),layerTypes:["line"]},Xn=e=>(t,i)=>({sources:[e],layerTypes:["line"],idIncludes:[i?`${t} outline`:t],...i?{}:{idExcludes:["outline"]}}),Jn=Xn(Ui),Qn=Xn(ki),el=(e,t,i=$n)=>({kind:"factor",description:e,range:i,appliesTo:"any-style",mechanisms:t}),tl=(e,t)=>({kind:"toggle",description:e,appliesTo:"tomtom-styles",mechanisms:[{type:"visibility",layers:t}]}),il=(e,t,i,r)=>({kind:"color",description:e,appliesTo:"tomtom-styles",mechanisms:[{type:"color",property:t,layers:i,shades:r}]}),rl={layerTypes:["hillshade"]},sl=/* @__PURE__ */new Set(["buildings2D","buildings3D"]),ol=Object.fromEntries(As.filter(e=>!(e=>sl.has(e))(e)).map(e=>[`basemap.${e}`,tl(`The base-map layer group '${e}' (the same as BaseMapModule's).`,[Rs(e)])])),al=e=>({kind:"color",description:rt[e].description,appliesTo:"tomtom-styles",mechanisms:[{type:"mapColor",color:e}]}),nl=e=>(t,i)=>il(t,"line-color",[e(i,!1)],[e(i,!0)]),ll=nl(Jn),cl=nl(Qn),hl={"labels.sizeFactor":el("Size of every base-map text label (places, roads, POIs, house numbers).",[{type:"scale",property:"text-size",layers:[Kn]}]),"symbols.sizeFactor":el("Size of every base-map icon (POI icons, route shields, road arrows).",[{type:"scale",property:"icon-size",layers:[Kn]}]),"roads.widthFactor":el("Width of all road lines, keeping the hierarchy motorway → path.",[{type:"scale",property:"line-width",layers:[Zn]}]),"pois.sizeFactor":el("Size of the base-map POI icons and their labels.",[{type:"scale",property:"icon-size",layers:[qn]},{type:"scale",property:"text-size",layers:[qn]}]),"pois.minZoom":{kind:"number",description:"Zoom level from which base-map POIs appear (the style default is 6).",range:{min:3,max:18,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"minZoom",layers:[{...qn,idExcludes:["micro"]}]}]},"pois.zoomShift":{kind:"number",description:"Shifts the zoom at which each POI appears: positive = later and sparser, negative = earlier and denser.",range:{min:-3,max:3,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"zoomOffset",layers:[qn]}]},"pois.labelColor":il("Text colour of base-map POI labels (replaces the per-category colours).","text-color",[qn]),"pois.labelOutlineColor":il("Halo colour of base-map POI labels.","text-halo-color",[qn]),"pois.microMarkers":tl("The small dot markers for low-priority POIs at high zoom.",[{...qn,idIncludes:["micro"]}]),"roads.exitNumbers":tl("Motorway exit number badges.",[{metadataGroups:["road_label"],layerTypes:["symbol"],idIncludes:["exit"]}]),"roads.shields":tl("Route shields along roads.",[{metadataGroups:["road_label"],layerTypes:["symbol"],idIncludes:["shield"]}]),"roads.arrows":tl("One-way arrows drawn on roads.",[{metadataGroups:["road"],layerTypes:["symbol"],idIncludes:["arrow"]}]),"roads.restricted":tl("Dashed marking of roads with restricted access.",[{metadataGroups:["road"],layerTypes:["line"],idIncludes:["restricted"]}]),"roads.underConstruction":tl("Roads under construction.",[{metadataGroups:["road"],layerTypes:["line"],idIncludes:["construction"]}]),"buildings.footprints":tl("2D building footprints, shadows and outlines.",[{metadataGroups:["building"],layerTypes:["fill","line"]}]),"buildings.3d":tl("Extruded 3D buildings (hidden by default in the standard styles).",[{metadataGroups:["area_3d","building"],layerTypes:["fill-extrusion"]}]),"traffic.flow.freeColor":ll("Traffic flow colour for free-flowing roads.","free flow"),"traffic.flow.slowColor":ll("Traffic flow colour for slow traffic.","slow flow"),"traffic.flow.queueingColor":ll("Traffic flow colour for queueing traffic.","queueing flow"),"traffic.flow.stationaryColor":ll("Traffic flow colour for stationary traffic.","stationary flow"),"traffic.flow.closedColor":il("Traffic flow colour for closed roads.","line-color",[Jn("closed road",!0)]),"traffic.flow.widthFactor":el("Width of the traffic flow tubes.",[{type:"scale",property:"line-width",layers:[{sources:[Ui],layerTypes:["line"]}]}],Yn),"traffic.incidents.minorColor":cl("Traffic incident tube colour for minor delays.","minor jam"),"traffic.incidents.moderateColor":cl("Traffic incident tube colour for moderate delays.","moderate jam"),"traffic.incidents.majorColor":cl("Traffic incident tube colour for major delays.","major jam"),"traffic.incidents.closedColor":il("Traffic incident tube colour for closed roads.","line-color",[Qn("closed road",!0)]),"traffic.incidents.widthFactor":el("Width of the traffic incident tubes.",[{type:"scale",property:"line-width",layers:[{sources:[ki],layerTypes:["line"]}]}],Yn),"colors.land":al("land"),"colors.water":al("water"),"colors.vegetation":al("vegetation"),"colors.park":al("park"),"colors.artificial":al("artificial"),"colors.roadMajor":al("roadMajor"),"colors.road":al("road"),"colors.roadOutline":al("roadOutline"),"colors.label":al("label"),"colors.labelOutline":al("labelOutline"),...ol,"hillshade.method":{kind:"enum",description:"How the relief is shaded: standard (one light), basic, igor (softer), combined, or multidirectional (four lights).",options:["standard","basic","igor","combined","multidirectional"],appliesTo:"tomtom-styles",mechanisms:[{type:"paintLiteral",property:"hillshade-method",layers:[rl]}]},"hillshade.lightDirection":{kind:"number",description:"Direction the light comes from, in degrees clockwise from north (335 is the cartographic default).",range:{min:0,max:359,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"paintLiteral",property:"hillshade-illumination-direction",layers:[rl]}]},"hillshade.exaggeration":{kind:"number",description:"Strength of the shading (0 = flat). The standard styles ramp it to zero by zoom 13; setting it replaces the ramp with a constant.",range:{min:0,max:1,step:.05},appliesTo:"tomtom-styles",mechanisms:[{type:"paintLiteral",property:"hillshade-exaggeration",layers:[rl]}]},"hillshade.maxZoom":{kind:"number",description:"Zoom level up to which the shading is drawn (the standard styles stop at 13; 22 keeps it at every zoom).",range:{min:10,max:22,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"maxZoom",layers:[rl]}]},"hillshade.shadowColor":il("Colour of the shaded slopes.","hillshade-shadow-color",[rl]),"hillshade.highlightColor":il("Colour of the lit slopes.","hillshade-highlight-color",[rl]),"hillshade.accentColor":il("Colour accentuating the steepest terrain.","hillshade-accent-color",[rl]),"view.projection":{kind:"enum",description:"How the map is drawn: flat Mercator or a globe. The globe flattens to Mercator between zoom 11 and 12 by design.",options:["mercator","globe"],appliesTo:"any-style",mechanisms:[{type:"projection"}]},"view.sky":{kind:"toggle",description:"A sky with atmosphere behind the globe and above a tilted flat map. Without it MapLibre draws a fully transparent sky, so a globe arrives with no atmosphere.",appliesTo:"any-style",mechanisms:[{type:"sky"}]},"view.skyColor":{kind:"color",description:"Colour of the sky (and of the atmosphere halo around the globe). Defaults to a daylit blue on a light style and a night blue on a dark one.",appliesTo:"any-style",mechanisms:[{type:"sky"}]},"view.horizonColor":{kind:"color",description:"Colour of the sky at the horizon. Defaults with the style theme, so a dark map gets a dim horizon rather than a white one.",appliesTo:"any-style",mechanisms:[{type:"sky"}]},"view.spaceColor":{kind:"color",description:"Colour behind the map, which a globe leaves visible around the planet. The map canvas is transparent, so without this the page background shows through. Defaults with the style theme: white on a light style, near-black on a dark one.",appliesTo:"any-style",mechanisms:[{type:"space"}]}},ul=Object.keys(hl),dl=ul.map(e=>{const{kind:t,description:i,range:r,options:s,appliesTo:o}=hl[e];return{id:e,kind:t,description:i,appliesTo:o,...r&&{range:r},...s&&{options:s}}}),pl=ul.filter(e=>"color"===hl[e].kind),yl="styling.layers",fl=class{constructor(e,t){this.registry=e,this.query=t}get layerIds(){return this.registry.resolve(this.query)}setPaint(e){for(const[t,i]of Object.entries(e))this.registry.override(this.query,{kind:"paint",property:t,value:i});return this}setLayout(e){for(const[t,i]of Object.entries(e))this.registry.override(this.query,{kind:"layout",property:t,value:i});return this}setFilter(e){return this.registry.overrideFilter(this.query,e),this}setVisible(e){return this.setLayout({visibility:e?"visible":"none"})}reset(){return this.registry.reset(this.query),this}},ml=class{constructor(e,t,i){this.mapLibreMap=e,this.filterComposer=t,this.warn=i,this.layers=[],this.sources={},this.properties=/* @__PURE__ */new Map,this.filters=/* @__PURE__ */new Map}index(e,t){this.layers=e,this.sources=t}clear(){this.properties.clear(),this.filters.clear()}resolve(e){const t=gl(e),i=this.layers.filter(e=>t.every(t=>Ss(t,e,this.sources))).map(e=>e.id);return 0===i.length&&this.warn(`query:${JSON.stringify(e)}`,`layers.query(${JSON.stringify(e)}) matches no layer in the loaded style; the edit will have no effect.`),i}override(e,t){const i=`${t.kind}:${t.property}`;for(const r of this.resolve(e)){const e=this.properties.get(r)??/* @__PURE__ */new Map,s=e.get(i);e.set(i,{override:t,before:s?s.before:this.read(r,t)}),this.properties.set(r,e),this.write(r,t)}}overrideFilter(e,t){for(const i of this.resolve(e))this.filters.set(i,t),this.filterComposer.setTransform(i,yl,()=>t)}reset(e){for(const t of this.resolve(e)){for(const{override:e,before:i}of this.properties.get(t)?.values()??[])this.write(t,{...e,value:i});this.properties.delete(t),this.filters.delete(t)&&this.filterComposer.setTransform(t,yl,void 0)}}reapply(){for(const[e,i]of this.properties)if(this.mapLibreMap.getLayer(e))for(const r of i.values()){const i=this.read(e,r.override);t(i,r.override.value)||(r.before=i),this.write(e,r.override)}for(const[e,t]of this.filters)this.filterComposer.setTransform(e,yl,()=>t)}read(e,{kind:t,property:i}){const r=this.mapLibreMap;return"paint"===t?r.getPaintProperty(e,i):r.getLayoutProperty(e,i)}write(e,{kind:t,property:i,value:r}){if(!this.mapLibreMap.getLayer(e))return;const s=this.mapLibreMap,o={validate:!1};"paint"===t?s.setPaintProperty(e,i,r,o):s.setLayoutProperty(e,i,r,o)}},gl=({group:e,...t})=>[t,...e?[Rs(e)]:[]],_l={"data-viz":{name:"Data visualisation",description:"A quiet base for your own data on top: fewer labels and markers, thinner roads, no badges competing with the overlay.",settings:{"labels.sizeFactor":.9,"symbols.sizeFactor":.9,"roads.widthFactor":.8,"roads.exitNumbers":!1,"roads.shields":!1,"roads.arrows":!1,"pois.microMarkers":!1,"pois.minZoom":14,"buildings.3d":!1}},"night-driving":{name:"Night driving",description:"Bigger labels and shields, wider roads and traffic tubes, POIs out of the way until close up.",settings:{"labels.sizeFactor":1.2,"symbols.sizeFactor":1.2,"roads.widthFactor":1.2,"roads.exitNumbers":!0,"roads.shields":!0,"roads.arrows":!0,"pois.minZoom":13,"pois.microMarkers":!1,"traffic.flow.widthFactor":1.3,"buildings.3d":!1}},minimal:{name:"Minimal",description:"The bare map: land, water, roads and the main place names. Everything decorative off.",settings:{"labels.sizeFactor":.9,"roads.exitNumbers":!1,"roads.shields":!1,"roads.arrows":!1,"roads.restricted":!1,"roads.underConstruction":!1,"buildings.footprints":!1,"buildings.3d":!1,"pois.microMarkers":!1,"pois.minZoom":16}},globe:{name:"Globe",description:"A globe with an atmosphere for the zoomed-out view; flattens to Mercator as you zoom in.",settings:{"view.projection":"globe","view.sky":!0}}},Ll=Object.keys(_l),bl=Ll.map(e=>({id:e,..._l[e],settings:{..._l[e].settings}})),Sl={minZoom:"minzoom",maxZoom:"maxzoom"},Il=/* @__PURE__ */new Set(["text-size","icon-size","visibility"]),Al=/* @__PURE__ */new Set(["line-width","fill-color","fill-outline-color","line-color","text-color","text-halo-color","fill-extrusion-color","background-color","hillshade-shadow-color","hillshade-highlight-color","hillshade-accent-color","hillshade-method","hillshade-illumination-direction","hillshade-exaggeration"]),El={"text-size":16,"icon-size":1,"line-width":1,visibility:"visible",minzoom:0,maxzoom:24,"hillshade-method":"standard","hillshade-illumination-direction":335,"hillshade-exaggeration":.5,"hillshade-shadow-color":"#000000","hillshade-highlight-color":"#FFFFFF","hillshade-accent-color":"#000000"},vl=(e,t)=>`${e}|${t}`,Rl={light:{"sky-color":"#88c6fc","horizon-color":"#ffffff","sky-horizon-blend":.8,"atmosphere-blend":.8,"fog-color":"#ffffff","fog-ground-blend":.5,"horizon-fog-blend":.8},dark:{"sky-color":"#0a1626","horizon-color":"#2b4a72","sky-horizon-blend":.8,"atmosphere-blend":.8,"fog-color":"#0a1626","fog-ground-blend":.5,"horizon-fog-blend":.8}},Tl={light:"#ffffff",dark:"#0a1626"},Cl=/* @__PURE__ */new Set(["","transparent","rgba(0, 0, 0, 0)"]),wl={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0},Ol=class e extends ei{static async get(t,i){return await Pt(t),Wi(t,e,()=>new e(t,i),i&&(e=>e.updateConfig(i)))}constructor(e,t){super(e,t)}styleChangePriority(){return 100}_initSourcesWithLayers(){return this.indexStyle(this.mapLibreMap.getStyle()),this.refreshSpace(this.config??{}),{}}_applyConfig(e){const t=Fl(e),i=/* @__PURE__ */new Set([...Dl(this.config),...Dl(t)]),r=this.reindexed?i:[...i].filter(e=>this.config?.[e]!==t[e]);this.reindexed=!1;for(const s of r)this.refreshKnob(s,t);return this.tomtomMap.mapReady&&this.layerOverrides.reapply(),Object.keys(t).length?t:void 0}discardShownData(){this.layerOverrides.clear()}get layers(){return{query:e=>new fl(this.layerOverrides,e)}}applyPreset(e,t={}){const i=_l[e];if(!i)throw new Error(`Unknown styling preset '${e}'. Known presets: ${Ll.join(", ")}.`);t.merge?this.updateConfig(i.settings):this.applyConfig({...i.settings})}get(e){return this.assertKnob(e),this.config?.[e]??this.derivedMapColorOf(e)??this.defaultOf(e)}set(e,t){this.assertKnob(e),this.validate(e,t),this.config={...this.config,[e]:t},this.refreshKnob(e,this.config),this.emitConfigChange()}reset(e){if(void 0===e)return void this.resetConfig();this.assertKnob(e);const{[e]:t,...i}=this.config??{};this.config=Object.keys(i).length?i:void 0,this.refreshKnob(e,this.config??{}),this.emitConfigChange()}setMapColors(e){const t={};for(const[i,r]of Object.entries(e)){if(!ot(i))throw new Error(`Unknown map colour '${i}'. Known colours: ${st.join(", ")}.`);if(void 0===r)continue;const e=Ml(i);this.validate(e,r),t[e]=r}this.updateConfig(t)}exportStyle(){return structuredClone(this.mapLibreMap.getStyle())}get events(){return this.moduleEvents([])}indexStyle(e){const t=e?.layers??[];this.originalValues=/* @__PURE__ */new Map,this.styleSources=e?.sources??{},this.resolved=/* @__PURE__ */new Map,this.scaleKnobsByTarget=/* @__PURE__ */new Map,this.mapColorTargetsByKey=/* @__PURE__ */new Map,this.mapColorTargetsByKnob=/* @__PURE__ */new Map,this.mapColorAnchors=/* @__PURE__ */new Map;const i=Kt(this.tomtomMap.getStyle());this.landDerivedColors=(i&&nt[i])??[],this.warned=/* @__PURE__ */new Set,this.reindexed=!0,this.layerOverrides??=new ml(this.mapLibreMap,this.filterComposer,(e,t)=>this.warnOnce(e,t)),this.layerOverrides.index(t,this.styleSources),this.mapLevelState={projection:e?.projection?.type??"mercator",sky:e?.sky};for(const r of ul){const e=hl[r],i=e.mechanisms.map(e=>this.resolveMechanism(r,e,t)),s=new Set(i.flatMap(e=>e.layerIds)).size;this.resolved.set(r,{definition:e,mechanisms:i,targets:s}),0===s&&this.warnOnce(r,`knob '${r}' matches no layer in the loaded style (curated for style version ${_e}); it will have no effect.`)}}resolveMechanism(e,t,i){if("mapColor"===t.type)return{mechanism:t,layerIds:this.resolveMapColor(t.color,i),shadeLayerIds:[]};if(!("layers"in t))return{mechanism:t,layerIds:["\0map"],shadeLayerIds:[]};const r=i.filter(e=>Is(t.layers,e,this.styleSources));let s,o=[];switch(t.type){case"scale":s=r.filter(e=>this.capture(e,t.property)).map(e=>e.id);for(const i of s){const r=vl(i,t.property);this.scaleKnobsByTarget.set(r,[...this.scaleKnobsByTarget.get(r)??[],e])}break;case"color":{s=r.filter(e=>this.capture(e,t.property)).map(e=>e.id);const e=t.shades??[];o=i.filter(t=>Is(e,t,this.styleSources)).filter(e=>this.capture(e,t.property)).map(e=>e.id);break}case"visibility":s=r.filter(e=>this.capture(e,"visibility")).map(e=>e.id);break;case"minZoom":case"maxZoom":s=r.map(e=>e.id);for(const e of r)this.capture(e,"minzoom"),this.capture(e,"maxzoom");break;case"paintLiteral":s=r.map(e=>e.id);for(const e of r)this.capture(e,t.property);break;case"zoomOffset":s=r.filter(e=>ze(kl(e),0).patched).map(e=>e.id)}return{mechanism:t,layerIds:s,shadeLayerIds:o}}capture(e,t){const i=Ul(e,t);return void 0!==i&&(this.originalValues.set(vl(e.id,t),i),!0)}originalValueOf(e,t){return this.originalValues.get(vl(e,t))}resolveMapColor(e,t){const i=Ml(e),r=rt[e],s=[];for(const l of r.targets)for(const i of t.filter(e=>Is(l.layers,e,this.styleSources)))for(const t of l.properties){if(!this.capture(i,t))continue;const r={color:e,layerId:i.id,property:t,owns:Nl(l),recolorsTints:l.recolorsTints};s.push(r);const o=vl(i.id,t);this.mapColorTargetsByKey.set(o,[...this.mapColorTargetsByKey.get(o)??[],r])}this.mapColorTargetsByKnob.set(i,s);const{anchor:o}=r,a=t.find(e=>Is(o.layers,e,this.styleSources)&&void 0!==Ul(e,o.property)),n=a&&((e,t=()=>!0,i=!1)=>{let r;for(const{literal:s,roadClass:o,keyed:a}of It(e)){if(!t(o))continue;const e=Math.round(100*(Me(s)?.s??0)),n=r?.saturation===e;r&&!(i?r.keyed||!a:e>r.saturation||n&&r.keyed&&!a)||(r={literal:s,saturation:e,keyed:a})}return r?.literal})(Ul(a,o.property),Nl({roadClass:o.roadClass}),o.lastStop);return n&&this.mapColorAnchors.set(i,n),n?[...new Set(s.map(e=>e.layerId))]:[]}refreshKnob(e,t){const i=this.resolved.get(e);if(i&&this.tomtomMap.mapReady)for(const r of i.mechanisms)this.refreshMechanism(e,r,t)}refreshMechanism(e,{mechanism:t,layerIds:i,shadeLayerIds:r},s){switch(t.type){case"color":this.refreshColor(t.property,i,r,s[e]);break;case"projection":this.refreshProjection(s);break;case"sky":this.refreshSky(s);break;case"space":this.refreshSpace(s);break;case"mapColor":this.refreshMapColor(t.color,s);break;default:for(const r of i)this.refreshLayer(t,r,s[e],s)}}refreshLayer(e,t,i,r){switch(e.type){case"scale":this.refreshScaledProperty(t,e.property,r);break;case"visibility":this.refreshVisibility(t,i);break;case"minZoom":case"maxZoom":this.refreshZoomBound(t,Sl[e.type],i);break;case"paintLiteral":this.setProperty(t,e.property,i??this.originalValueOf(t,e.property));break;case"zoomOffset":this.refreshZoomOffset(t,i)}}refreshSpace(e){const t=this.mapLibreMap.getContainer();this.originalSpaceColor??=Pl(t),t.style.backgroundColor=e["view.spaceColor"]??this.defaultSpaceColor()}defaultSpaceColor(){return this.originalSpaceColor||Tl[this.tomtomMap.styleLightDarkTheme]}refreshMapColor(e,t){const i=this.mapColorsOf(t),r=[e,...this.landDerivedColors.filter(t=>lt(t).includes(e))],s=new Map(r.flatMap(e=>this.mapColorTargetsByKnob.get(Ml(e))??[]).map(e=>[vl(e.layerId,e.property),e]));for(const{layerId:o,property:a}of s.values())this.refreshMapColorProperty(o,a,i)}derivedMapColorOf(e){const[t]=this.resolved.get(e)?.mechanisms??[];if("mapColor"===t?.mechanism.type&&this.mapColorAnchors.has(e))return this.mapColorsOf(this.config??{})[t.mechanism.color]}mapColorsOf(e){const t={};for(const i of st){const r=e[Ml(i)];"string"==typeof r&&(t[i]=r)}return gt(t,this.landDerivedColors,this.mapColorAnchors.get(Ml("land")))}refreshMapColorProperty(e,t,i){const r=this.originalValueOf(e,t),s=[],o=this.mapColorTargetsByKey.get(vl(e,t))??[];for(const{color:a,owns:n,recolorsTints:l}of o){const e=i[a],t=this.mapColorAnchors.get(Ml(a));e&&t&&s.push({anchorColor:t,newColor:e,owns:n,recolorsTints:l})}this.setProperty(e,t,s.length?vt(r,s):r)}refreshProjection(e){const t=e["view.projection"];this.mapLibreMap.setProjection({type:t??this.mapLevelState.projection})}refreshSky(e){const t=this.mapLevelState.sky,i=e["view.sky"]??this.defaultOf("view.sky"),r=Rl[this.tomtomMap.styleLightDarkTheme],s=i?{...r,...t,"sky-color":e["view.skyColor"]??t?.["sky-color"]??r["sky-color"],"horizon-color":e["view.horizonColor"]??t?.["horizon-color"]??r["horizon-color"]}:wl;this.mapLibreMap.setSky(s,{validate:!1})}refreshVisibility(e,t){void 0!==t?this.setProperty(e,"visibility",t?"visible":"none"):this.setProperty(e,"visibility",this.originalValueOf(e,"visibility"))}refreshZoomBound(e,t,i){if(!this.mapLibreMap.getLayer(e))return;const r={minzoom:this.styleZoomBound(e,"minzoom"),maxzoom:this.styleZoomBound(e,"maxzoom")};r[t]=i??r[t],this.mapLibreMap.setLayerZoomRange(e,r.minzoom,r.maxzoom)}styleZoomBound(e,t){return this.originalValueOf(e,t)??El[t]}refreshZoomOffset(e,t){this.filterComposer.setTransform(e,"styling.zoomShift",void 0===t?void 0:e=>ze(e,t).filter)}refreshScaledProperty(e,t,i){const r=this.originalValueOf(e,t),s=(this.scaleKnobsByTarget.get(vl(e,t))??[]).reduce((e,t)=>e*(i[t]??1),1);if(1===s)return void this.setProperty(e,t,r);const o=Ge(r,s);void 0!==o?this.setProperty(e,t,o):this.warnOnce(`scale:${e}:${t}`,`cannot scale '${t}' of layer '${e}': the style gives it a value this knob cannot scale (a non-numeric value, or an expression holding a nested zoom term); leaving it as the style defines it.`)}refreshColor(e,t,i,r){for(const o of t)this.setProperty(o,e,r??this.originalValueOf(o,e));const s=t.map(t=>this.originalValueOf(t,e)).find(Ne);for(const o of i){const t=this.originalValueOf(o,e);let i=t;if(void 0!==r){const e=Ne(t)&&s&&Pe(s,t);i=(e&&ke(r,e))??r}this.setProperty(o,e,i)}}setProperty(e,t,i){if(!this.mapLibreMap.getLayer(e))return;const r=this.mapLibreMap;Il.has(t)?r.setLayoutProperty(e,t,i,{validate:!1}):Al.has(t)&&r.setPaintProperty(e,t,i,{validate:!1})}defaultOf(e){const t=this.resolved.get(e);if(!t)return;const{definition:i,mechanisms:r}=t;if("factor"===i.kind)return 1;const[s]=r,[o]=s?.layerIds??[];if(void 0!==o){if("mapColor"===s.mechanism.type){const t=this.mapColorAnchors.get(e);return t&&(e=>{const t=Me(e);return t&&(t.alpha??1)<1?xe({...t,alpha:void 0}):e})(t)}if(!("layers"in s.mechanism))return this.mapLevelDefaultOf(e);switch(s.mechanism.type){case"visibility":return"none"!==this.originalValueOf(o,"visibility");case"color":{const e=this.originalValueOf(o,s.mechanism.property);return Ne(e)?e:void 0}case"minZoom":case"maxZoom":return this.styleZoomBound(o,Sl[s.mechanism.type]);case"paintLiteral":{const e=this.originalValueOf(o,s.mechanism.property);return"string"==typeof e||"number"==typeof e?e:void 0}case"zoomOffset":return 0;default:return}}}mapLevelDefaultOf(e){const{projection:t,sky:i}=this.mapLevelState;switch(e){case"view.projection":return"string"==typeof t?t:void 0;case"view.sky":return void 0!==i&&0!==i["atmosphere-blend"]&&"transparent"!==i["sky-color"];case"view.skyColor":return Ne(i?.["sky-color"])?i["sky-color"]:Rl[this.tomtomMap.styleLightDarkTheme]["sky-color"];case"view.horizonColor":return Ne(i?.["horizon-color"])?i["horizon-color"]:Rl[this.tomtomMap.styleLightDarkTheme]["horizon-color"];case"view.spaceColor":return this.defaultSpaceColor();default:return}}assertKnob(e){if(!(e in hl))throw new Error(`Unknown styling knob '${e}'. stylingKnobIds lists every knob id.`)}validate(e,t){const{kind:i,range:r,options:s}=hl[e];switch(i){case"toggle":if("boolean"!=typeof t)throw new RangeError(`Knob '${e}' expects true or false; got ${xl(t)}.`);break;case"enum":if("string"!=typeof t||!s?.includes(t))throw new RangeError(`Knob '${e}' expects one of ${s?.join(", ")}; got ${xl(t)}.`);break;case"color":if(!Ne(t))throw new RangeError(`Knob '${e}' expects a CSS colour (#rrggbb, hsl(), rgb() or a named colour); got ${xl(t)}.`);break;default:if("number"!=typeof t||!Number.isFinite(t))throw new RangeError(`Knob '${e}' expects a number; got ${xl(t)}.`);if(r&&(t<r.min||t>r.max))throw new RangeError(`Knob '${e}' expects a number between ${r.min} and ${r.max}; got ${t}.`)}}warnOnce(e,t){this.warned.has(e)||(this.warned.add(e),console.warn(`[StylingModule] ${t}`))}},Ml=e=>`colors.${e}`,Nl=e=>"major"===e.roadClass?e=>"major"===e:"minor"===e.roadClass?e=>"major"!==e:()=>!0,xl=e=>"string"==typeof e?`'${e}'`:String(e),Dl=e=>Object.keys(e??{}).filter(e=>e in hl),Fl=e=>Object.fromEntries(Object.entries(e??{}).filter(([,e])=>void 0!==e)),Pl=e=>{const t=getComputedStyle(e).backgroundColor;return Cl.has(t)?"":t},kl=e=>"filter"in e?e.filter:void 0,Ul=(e,t)=>{const i="layout"in e?e.layout:void 0,r="paint"in e?e.paint:void 0;switch(t){case"text-size":return"symbol"===e.type&&void 0!==i?.["text-field"]?i["text-size"]??El["text-size"]:void 0;case"icon-size":return"symbol"===e.type&&void 0!==i?.["icon-image"]?i["icon-size"]??El["icon-size"]:void 0;case"line-width":return"line"===e.type?r?.["line-width"]??El["line-width"]:void 0;case"visibility":return i?.visibility??El.visibility;case"minzoom":return e.minzoom;case"maxzoom":return e.maxzoom;default:return Hl(e,t,r)}},Hl=(e,t,i)=>i?.[t]??("hillshade"===e.type&&(e=>e in El)(t)?El[t]:void 0),Wl=["factor","number","toggle","color","enum"],Gl=["any-style","tomtom-styles"],Bl=class{get styleLightDarkTheme(){return this._styleLightDarkTheme}constructor(e){var t;this.mapReady=!1,this.styleChangeHandlers=[],this.styleRequestSequence=0,this.setStyle=(e,t={})=>{const i={resetState:t.resetState??!1};this.mapReady=!1;const r=++this.styleRequestSequence,s=i.resetState?e:((e,t)=>t&&"object"==typeof t&&"standard"===t.type&&t.include&&("string"==typeof e||"standard"===e.type&&!e.include)?{type:"standard",id:"string"==typeof e?e:e.id,include:t.include}:e)(e,this._params.style);return this._params={...this._params,style:s},this._styleLightDarkTheme=Yt(s),this.applyStyle(i,r)},this.getStyle=()=>this._params.style,this._params=I(e),void 0===this._params.style&&(this._params={...this._params,style:ge}),this._styleLightDarkTheme=Yt(this._params.style),this.ensureMapLibreCSSLoaded(),K(4),this.styleGivenToMapLibre=Ie(this._params),this.mapLibreMap=new z({validateStyle:!1,maxTileCacheZoomLevels:22,cancelPendingTileRequestsWhileZooming:!1,...(t=this._params).mapLibre,style:Ie(t),attributionControl:{compact:!1},transformRequest:Ut(t)}),this.mapLibreMap.once("style.load",()=>{this.handleStyleData()}),this._eventsProxy=new Ai(this.mapLibreMap,this._params?.events),this.loadRTLTextPlugin()}loadRTLTextPlugin(){setTimeout(()=>{["deferred","loaded"].includes(j())||Y("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js",!0).catch(e=>console.error("Something went wrong when setting RTL plugin",e))})}ensureMapLibreCSSLoaded(){if("undefined"==typeof document)return;if(Array.from(document.querySelectorAll('link[rel="stylesheet"], style')).some(e=>e.textContent?.includes(".maplibregl-map")))return;const e=document.createElement("link");e.rel="stylesheet",e.href=`https://unpkg.com/maplibre-gl@${$()}/dist/maplibre-gl.css`,document.head.appendChild(e)}async applyStyle(e,t){if(await this.notifyHandlers("onStyleAboutToChange",e),this.isSuperseded(t))return;if(await(this.styleLoadInFlight?.catch(()=>{})),this.isSuperseded(t))return;const i=this.loadIntoMapLibre();this.styleLoadInFlight=i;try{await i}finally{this.styleLoadInFlight===i&&(this.styleLoadInFlight=void 0)}if(!this.isSuperseded(t))try{await this.handleStyleData(e)}catch(r){console.error(r)}}async loadIntoMapLibre(){const e=Ie(this._params);if(t(e,this.styleGivenToMapLibre))return;const i=this.styleGivenToMapLibre;this.styleGivenToMapLibre=e,await new Promise((t,r)=>{const s=()=>{this.mapLibreMap.off("error",o),t()},o=e=>{"sourceId"in e||(this.mapLibreMap.off("style.load",s),this.mapLibreMap.off("error",o),this.styleGivenToMapLibre=i,r(e.error instanceof Error?e.error:new Error(e.error.message)))};this.mapLibreMap.once("style.load",s),this.mapLibreMap.on("error",o),this.mapLibreMap.setStyle(e,{validate:!1})})}isSuperseded(e){return e!==this.styleRequestSequence}async notifyHandlers(e,t){const i=[...this.styleChangeHandlers].sort((e,t)=>(e.priority??0)-(t.priority??0));for(const s of i)try{await(s[e]?.(t))}catch(r){console.error(r)}}_setTomTomUserAgent(e){this._params={...this._params,"tomtom-user-agent":e},this.mapLibreMap.setTransformRequest(Ut(this._params))}_setLanguage(e){this._params={...this._params,language:e};const t=e?.includes("-")?e.split("-")[0]:e;this.mapLibreMap.getStyle().layers.forEach(e=>{if("symbol"===e.type&&(e=>{const t=e.layout?.["text-field"]??"";return!!t&&("{name}"===t||2===t.length&&"name"===t[1]||3===t.length&&Array.isArray(t[1])&&"string"==typeof t[1][1]&&t[1][1].includes("name_")&&Array.isArray(t[2])&&t[2].includes("name"))})(e)){const i=t?["coalesce",["get",`name_${t}`],["get","name"]]:["get","name"];this.mapLibreMap.setLayoutProperty(e.id,"text-field",i,{validate:!1})}})}setLanguage(e){this.mapReady?this._setLanguage(e):this.mapLibreMap.once("styledata",()=>this.setLanguage(e))}updateEventsConfig(e){this._eventsProxy.updateConfig(e)}getBBox(){return this.mapLibreMap.getBounds().toArray().flat()}async handleStyleData(e){for(const t of hi(this.mapLibreMap,[ki,Ui,Di]))this.mapLibreMap.setLayoutProperty(t.id,"visibility","none",{validate:!1});Zt(this._params.style)&&!qt(this._params.style)&&(this._styleLightDarkTheme=(e=>{const t=e?.layers?.find(e=>"background"===e?.type);if(!t)return;const[i]=It(t.paint?.["background-color"]),r=i&&Ue(i.literal);return void 0!==r?r<.35?"dark":"light":void 0})(this.mapLibreMap.getStyle())??this._styleLightDarkTheme),(async(e,t,i)=>{if(i.getSprite().some(e=>"pinCategories"===e.id))return;const r=new URLSearchParams;e.apiKey&&r.set("key",e.apiKey),r.set("poi",`poi_${t}`),r.set("apiVersion","1"),r.set("apiChannel","preview"),i.addSprite(Ot,`${e.commonBaseURL}/maps/orbis/assets/sprites/2.*/sprite?${r}`,{validate:!1})})(this._params,this._styleLightDarkTheme,this.mapLibreMap),this._params.language&&this._setLanguage(this._params.language),this.mapReady=!0,e&&await this.notifyHandlers("onStyleChanged",e)}addStyleChangeHandler(e){this.styleChangeHandlers.push(e);let t=!1;return()=>{if(t)return;t=!0;const i=this.styleChangeHandlers.indexOf(e);-1!==i&&this.styleChangeHandlers.splice(i,1)}}},Vl=class e extends ei{static async get(t,i){return await Pt(t),await jt(t,Di,"hillshade"),Wi(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Di);if(!t)throw ye(`init ${e.name} with source ID ${Di}`);const i=this.mapLibreMap.getTerrain();return"hillshade-terrain"!==i?.source&&(this.mapTerrain=i),{hillshade:new ui(this.mapLibreMap,t)}}_applyConfig(e){return this.showHillshade(e?.hillshade??!1),this.showElevation(e?.elevation,e?.elevationExaggeration??1),e}setHillshadeVisible(e){this.showHillshade(e),this.storeConfig({hillshade:e})}isHillshadeVisible(){return this.sourcesWithLayers.hillshade.isAnyLayerVisible()}setElevationEnabled(e){this.showElevation(e,this.config?.elevationExaggeration??1),this.storeConfig({elevation:e})}isElevationEnabled(){return null!==this.mapLibreMap.getTerrain()}setElevationExaggeration(e){this.showElevation(this.config?.elevation,e),this.storeConfig({elevationExaggeration:e})}get events(){return this.lifecycleEvents()}showHillshade(e){this.tomtomMap.mapReady&&this.sourcesWithLayers.hillshade.setLayersVisible(e)}showElevation(e,t){this.tomtomMap.mapReady&&(void 0===e?this.overridesMapTerrain&&this.mapLibreMap.setTerrain(this.mapTerrain):e?(new li(Fi,this.sourcesWithLayers.hillshade.source.spec).ensureAddedToMap(this.mapLibreMap),this.mapLibreMap.setTerrain({source:Fi,exaggeration:t})):this.mapLibreMap.setTerrain(null),this.overridesMapTerrain=void 0!==e)}storeConfig(e){this.config={...this.config,...e},this.emitConfigChange()}},zl="#2dc653",jl="#f5a623",$l="#e03030",Yl=()=>[{value:0,color:zl},{value:50,color:jl},{value:100,color:$l}],Kl=()=>[{value:0,color:$l},{value:50,color:jl},{value:100,color:zl}],ql={visible:!0,displayMode:"hexgrid-3d",activeMetric:"congestionLevel",metricConfig:{congestionLevel:{color:{valueType:"raw",stops:Yl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},speed:{color:{valueType:"relativeToPredefinedRangePCT",stops:Kl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},travelTime:{color:{valueType:"relativeToPredefinedRangePCT",stops:Yl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},freeFlowSpeed:{color:{valueType:"relativeToPredefinedRangePCT",stops:Kl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},networkLength:{color:{valueType:"relativeToActualRangePCT",stops:Yl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"currentRange"}}},regionPolygon:{fillOpacity:0,outlineOpacity:.5,outlineWidth:2,inverted:!1}},Zl="#ffffff",Xl=e=>"dark"===e?"#FFFFFF":"#000000",Jl={trafficLight:[zl,jl,$l],heat:["#2196F3","#FF9800","#F44336"],monochrome:["#e0e0e0","#888888","#1a1a1a"],viridis:["#fde725","#35b779","#31688e","#440154"],plasma:["#f0f921","#ed7953","#9c179e","#0d0887"]},Ql={congestionLevel:{min:0,max:100},speed:{min:0,max:120},travelTime:{min:0,max:20},freeFlowSpeed:{min:0,max:120},networkLength:{min:0,max:5e3}},ec=e=>"speed"===e||"freeFlowSpeed"===e,tc=e=>e?.activeMetric??ql.activeMetric,ic=e=>{return"string"==typeof e?(t=Jl[e]).map((e,i)=>({value:1===t.length?0:i/(t.length-1),color:e})):e.stops;var t},rc=e=>{if("top"!==e)return e?Ni[e]:Ni.lowestLabel},sc=e=>{if("top"!==e)return e?Ni[e]:Ni.lowestPlaceLabel},oc=(e,t,i)=>{const r=t??ql.metricConfig[e].color??"trafficLight",s=ic(r);let o;if("string"==typeof r){const{min:t,max:i}=Ql[e],r=ec(e)?[...s].reverse().map(e=>e.color):s.map(e=>e.color);o=s.map(({value:e},s)=>[t+e*(i-t),r[s]])}else if("relativeToPredefinedRangePCT"===r.valueType){const{min:t,max:i}=Ql[e];o=s.map(({value:e,color:r})=>[t+e/100*(i-t),r])}else if("relativeToActualRangePCT"===r.valueType){const{min:t,max:r}=i??Ql[e];o=s.map(({value:e,color:i})=>[t+e/100*(r-t),i])}else o=s.map(({value:e,color:t})=>[e,t]);return["interpolate",["linear"],["get",e],...o.flatMap(([e,t])=>[e,t])]},ac=(e,t)=>{const i=t??ql.metricConfig[e].color??"trafficLight",r=ic(i);let s;if("string"==typeof i){const t=ec(e)?[...r].reverse().map(e=>e.color):r.map(e=>e.color);s=r.flatMap(({value:e},i)=>[.3+.7*e,t[i]])}else if("relativeToPredefinedRangePCT"===i.valueType||"relativeToActualRangePCT"===i.valueType)s=r.flatMap(({value:e,color:t})=>[.3+e/100*.7,t]);else{const e=Math.min(...r.map(e=>e.value)),t=Math.max(...r.map(e=>e.value))-e||1;s=r.flatMap(({value:i,color:r})=>[.3+(i-e)/t*.7,r])}return["interpolate",["linear"],["heatmap-density"],0,"rgba(0,0,0,0)",...s]},nc=(e,t,i)=>{const r=ql.metricConfig[e].height,s=t?.minHeightMeters??r.minHeightMeters??0;if("raw"===t?.scaleMode){const i=t.scaleFactor??1;if("speed"===e){const{max:t}=Ql[e];return["max",s,["*",["-",t,["coalesce",["get","speed"],0]],i]]}return["max",s,["*",["coalesce",["get",e],0],i]]}const o=t?.maxHeightMeters??r.maxHeightMeters??1e3,{min:a,max:n}="currentRange"===(t?.scaleMode??r.scaleMode)?i??Ql[e]:Ql[e],l=n-a||1;return"speed"===e?["max",s,["*",["/",["-",n,["coalesce",["get","speed"],0]],l],o]]:["max",s,["*",["/",["-",["coalesce",["get",e],0],a],l],o]]},lc=(e,t,i)=>{const r=tc(t),s=t?.metricConfig?.[r],{min:o,max:a}=i??Ql[r];return{id:e,type:"heatmap",beforeID:rc(t?.beforeLayerConfig?.heatmap),paint:{"heatmap-weight":["interpolate",["linear"],["get",r],o,0,a,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],10,.5,14,2,16,4],"heatmap-color":ac(r,s?.color),"heatmap-radius":["interpolate",["linear"],["zoom"],4,1,8,3,12,35,14,80,16,100],"heatmap-opacity":["interpolate",["linear"],["zoom"],4,.8,13,.8,17,0]}}},cc=(e,t,i)=>{const r=tc(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:rc(t?.beforeLayerConfig?.hexgrid?.flat2D),paint:{"fill-color":oc(r,s?.color,i),"fill-opacity":.6}}},hc=(e,t,i)=>{const r=tc(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:sc(t?.beforeLayerConfig?.hexgrid?.extrusion3D),paint:{"fill-extrusion-color":oc(r,s?.color,i),"fill-extrusion-height":nc(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},uc=(e,t,i)=>{const r=tc(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:rc(t?.beforeLayerConfig?.square?.flat2D),paint:{"fill-color":oc(r,s?.color,i),"fill-opacity":.6}}},dc=(e,t,i)=>{const r=tc(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:sc(t?.beforeLayerConfig?.square?.extrusion3D),paint:{"fill-extrusion-color":oc(r,s?.color,i),"fill-extrusion-height":nc(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},pc=e=>({...ql.regionPolygon,...e}),yc=(e,t,i)=>{const{color:r,fillOpacity:s}=pc(t?.regionPolygon);return{id:e,type:"fill",beforeID:rc(),paint:{"fill-color":r??Xl(i),"fill-opacity":s}}},fc=(e,t,i)=>{const{color:r,outlineOpacity:s,outlineWidth:o}=pc(t?.regionPolygon);return{id:e,type:"line",beforeID:rc(),paint:{"line-color":r??Xl(i),"line-opacity":s,"line-width":o}}},mc=(e,t)=>({id:e,type:"line",beforeID:t,filter:_r,paint:{"line-color":Zl,"line-width":["case",gr,3,2],"line-opacity":["case",gr,1,.8]}}),gc=e=>({...e,filter:_r,paint:{...e.paint,"fill-extrusion-color":["case",gr,Zl,Zl],"fill-extrusion-height":["+",e.paint?.["fill-extrusion-height"],.5],"fill-extrusion-opacity":.6}}),_c=(e,t,i)=>gc(hc(e,t,i)),Lc=(e,t,i)=>gc(dc(e,t,i)),bc=(e,t,i)=>((e,t,i)=>{const r=[];for(let s=0;s<e.length;s++){const o=e[s];if(!o)continue;const{congestionSum:a,speedSum:n,freeFlowSum:l,travelTimeSum:c,networkLengthSum:h,count:u}=o,d=`${i}-${s}`;r.push({type:"Feature",id:d,geometry:t.features[s].geometry,properties:{id:d,congestionLevel:Math.round(a/u),speed:Math.round(n/u),freeFlowSpeed:Math.round(l/u),travelTime:Math.round(c/u*10)/10,networkLength:Math.round(h/u)}})}return r})(((e,t)=>{const i=[];for(const r of e)for(let e=0;e<t.features.length;e++)if(U(r.tileCentre,t.features[e])){let t=i[e];void 0===t&&(t={congestionSum:0,speedSum:0,freeFlowSum:0,travelTimeSum:0,networkLengthSum:0,count:0},i[e]=t),t.congestionSum+=r.congestionLevel??0,t.speedSum+=r.speed??0,t.freeFlowSum+=r.freeFlowSpeed??0,t.travelTimeSum+=r.travelTime??0,t.networkLengthSum+=r.networkLength??0,t.count++;break}return i})(e,t),t,i),Sc=.005,Ic=(e,t,i,r)=>{const s=[];for(let o=0;o<e.features.length;o++){const a=e.features[o],n=a.properties?.tiledData?.tiles??[];if(0===n.length)continue;const l=p(a);if(!l)continue;const c=i([l[0]-Sc,l[1]-Sc,l[2]+Sc,l[3]+Sc],t);s.push(...bc(n,c,`${r}-${o}`))}return{type:"FeatureCollection",features:s}},Ac=class e extends Qt{static async create(t,i){return await Pt(t),new e(t,i??{})}constructor(e,t){super(e,t),this.lastAnalytics=null,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=this.instanceIndex,r=`area-analytics-heatmap-${i}`,s=`area-analytics-hexgrid-${i}`,o=`area-analytics-square-${i}`,a=`area-analytics-region-${i}`,n=`${r}-layer`,l=`${s}-fill`,c=`${s}-extrusion`,h=`${s}-outline`,u=`${s}-extrusion-highlight`,d=`${o}-fill`,p=`${o}-extrusion`,y=`${o}-outline`,f=`${o}-extrusion-highlight`,m=`${a}-fill`,g=`${a}-line`,_=this.lightDark;this.heatmapLayerSpec=lc(n,e),this.hexFillLayerSpec=cc(l,e),this.hexExtrusionLayerSpec=hc(c,e),this.squareFillLayerSpec=uc(d,e),this.squareExtrusionLayerSpec=dc(p,e),this.regionFillLayerSpec=yc(m,e,_),this.regionLineLayerSpec=fc(g,e,_),this.hexOutlineLayerSpec=((e,t)=>mc(e,rc(t?.beforeLayerConfig?.hexgrid?.flat2D)))(h,e),this.hexExtrusionHighlightLayerSpec=_c(u,e),this.squareOutlineLayerSpec=((e,t)=>mc(e,rc(t?.beforeLayerConfig?.square?.flat2D)))(y,e),this.squareExtrusionHighlightLayerSpec=Lc(f,e);const L={heatmap:new yi(this.mapLibreMap,r,[this.heatmapLayerSpec]),hexgrid:new yi(this.mapLibreMap,s,[this.hexFillLayerSpec,this.hexExtrusionLayerSpec]),square:new yi(this.mapLibreMap,o,[this.squareFillLayerSpec,this.squareExtrusionLayerSpec]),region:new yi(this.mapLibreMap,a,[this.regionFillLayerSpec,this.regionLineLayerSpec])};return this.addHighlightLayersToMap(s,o),L}_applyConfig(e){const t=this.config,i=void 0===e?void 0:t,r=e??{},s=r.metricConfig&&i?.metricConfig?{...i.metricConfig,...r.metricConfig}:r.metricConfig??i?.metricConfig,o=Object.keys(ql.metricConfig),a=Object.fromEntries(o.map(e=>[e,s?.[e]??ql.metricConfig[e]])),n={activeMetric:ql.activeMetric,displayMode:ql.displayMode,...i,...r,metricConfig:a};return this.config=n,this.applyLayerConfig(n),(n.regionPolygon||t?.regionPolygon)&&this.applyRegionConfig(n),n.beforeLayerConfig?this._moveBeforeLayer(n.beforeLayerConfig,!1):t?.beforeLayerConfig&&this.moveLayersToSpecPositions(),this.applyModeVisibility(),n}moveLayersToSpecPositions(){for(const e of[this.heatmapLayerSpec,this.hexFillLayerSpec,this.hexExtrusionLayerSpec,this.squareFillLayerSpec,this.squareExtrusionLayerSpec])Bt(this.mapLibreMap,e.id,e.beforeID)}discardShownData(){this.lastAnalytics=null}restoreDataAndConfigImpl(){const e=this.lastAnalytics;this.initSourcesWithLayers(this.config,!0),e?(!1===this.config?.visible&&this.setVisible(!1),this.show(e)):this.config&&this._applyConfig(this.config)}async show(e){await this.waitUntilModuleReady(),this.lastAnalytics=e,this.sourcesWithLayers.heatmap.show((e=>({type:"FeatureCollection",features:e.features.flatMap(e=>e.properties?.tiledData?.tiles??[]).map((e,t)=>{const[i,r]=e.tileCentre,s=`tile-${t}-${i}-${r}`;return{type:"Feature",id:s,geometry:{type:"Point",coordinates:[i,r]},properties:{id:s,speed:e.speed??0,freeFlowSpeed:e.freeFlowSpeed??0,congestionLevel:e.congestionLevel??0,travelTime:e.travelTime??0,networkLength:e.networkLength??0}}})}))(e),{automaticVisibility:!1}),this.sourcesWithLayers.hexgrid.show(((e,t=.25)=>Ic(e,t,(e,t)=>G(e,t,{units:"kilometers"}),"hex"))(e),{automaticVisibility:!1}),this.sourcesWithLayers.square.show(((e,t=.5)=>Ic(e,t,(e,t)=>V(e,t,{units:"kilometers"}),"square"))(e),{automaticVisibility:!1});const t=this.config?.regionPolygon?.inverted??ql.regionPolygon.inverted;this.sourcesWithLayers.region.show(this.buildRegionFC(e.features,t)),this.applyLayerConfig(this.config),this.applyModeVisibility();for(const i of this.shownFeaturesHandlers)i(e)}async clear(){await this.waitUntilModuleReady(),this.lastAnalytics=null,this.sourcesWithLayers.heatmap.clear(),this.sourcesWithLayers.hexgrid.clear(),this.sourcesWithLayers.square.clear(),this.sourcesWithLayers.region.clear()}setMode(e){e!==this.mode&&(this.config={...this.config,displayMode:e},this.applyModeVisibility(),this.emitConfigChange())}setMetric(e){e!==this.activeMetric&&(this.config={...this.config,activeMetric:e},this.applyLayerConfig(this.config),this.emitConfigChange())}setColor(e,t){const i=Object.keys(ql.metricConfig),r=t??i,s={...this.config?.metricConfig};if(void 0===e)for(const o of r){const{color:e,...t}=s[o]??{};s[o]=t}else if("string"==typeof e){const t=(e=>{const t=ic(e),i=e=>{const{min:i,max:r}=Ql[e],s=ec(e)?[...t].reverse().map(e=>e.color):t.map(e=>e.color);return{valueType:"raw",stops:t.map(({value:e},t)=>({value:i+e*(r-i),color:s[t]}))}};return{congestionLevel:{color:i("congestionLevel")},speed:{color:i("speed")},travelTime:{color:i("travelTime")},freeFlowSpeed:{color:i("freeFlowSpeed")},networkLength:{color:i("networkLength")}}})(e);for(const e of r)s[e]={...s[e],...t[e]}}else for(const o of r)s[o]={...s[o],color:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}setHeight(e,t){const i=Object.keys(ql.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const o of r)s[o]={...s[o],height:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}filter(e,t){const i=Object.keys(ql.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const o of r)s[o]={...s[o],filters:e};this.config={...this.config,metricConfig:s},this.applyFiltersToLayers(),this.emitConfigChange()}clearFilter(e){this.filter(void 0,e)}setVisible(e){this.config={...this.config,visible:e},this.applyModeVisibility(),this.emitConfigChange()}isVisible(){return this.sourcesWithLayers.heatmap.isAnyLayerVisible()||this.sourcesWithLayers.hexgrid.isAnyLayerVisible()||this.sourcesWithLayers.square.isAnyLayerVisible()}getShown(){return{heatmap:this.sourcesWithLayers.heatmap.shownFeatures,hexgrid:this.sourcesWithLayers.hexgrid.shownFeatures,square:this.sourcesWithLayers.square.shownFeatures}}moveBeforeLayer(e){this._moveBeforeLayer(e)}_moveBeforeLayer(e,t=!0){const i=e=>"top"===e?void 0:Ni[e];void 0!==e.heatmap&&Bt(this.mapLibreMap,this.heatmapLayerSpec.id,i(e.heatmap)),void 0!==e.hexgrid?.flat2D&&Bt(this.mapLibreMap,this.hexFillLayerSpec.id,i(e.hexgrid.flat2D)),void 0!==e.hexgrid?.extrusion3D&&Bt(this.mapLibreMap,this.hexExtrusionLayerSpec.id,i(e.hexgrid.extrusion3D)),void 0!==e.square?.flat2D&&Bt(this.mapLibreMap,this.squareFillLayerSpec.id,i(e.square.flat2D)),void 0!==e.square?.extrusion3D&&Bt(this.mapLibreMap,this.squareExtrusionLayerSpec.id,i(e.square.extrusion3D)),t&&(this.config={...this.config,beforeLayerConfig:e})}get events(){return this.moduleEventsWithShown(["hexgrid","square","heatmap"],this.shownFeaturesHandlers)}get mode(){return this.config?.displayMode??ql.displayMode}get activeMetric(){return tc(this.config)}get lightDark(){return this.tomtomMap.styleLightDarkTheme}applyModeVisibility(){if(!1===this.config?.visible)return void this.hideAllDataLayers();const e=this.mode,t=this.sourcesWithLayers.heatmap.shownFeatures.features.length>0,i=this.sourcesWithLayers.hexgrid.shownFeatures.features.length>0,r=this.sourcesWithLayers.square.shownFeatures.features.length>0,s=this.sourcesWithLayers.region.shownFeatures.features.length>0;this.sourcesWithLayers.heatmap.setLayersVisible("heatmap"===e&&t),this.sourcesWithLayers.hexgrid.setLayersVisible("hexgrid-3d"===e&&i,e=>e.id===this.hexExtrusionLayerSpec.id),this.sourcesWithLayers.hexgrid.setLayersVisible("hexgrid-2d"===e&&i,e=>e.id===this.hexFillLayerSpec.id),this.sourcesWithLayers.square.setLayersVisible("square-3d"===e&&r,e=>e.id===this.squareExtrusionLayerSpec.id),this.sourcesWithLayers.square.setLayersVisible("square-2d"===e&&r,e=>e.id===this.squareFillLayerSpec.id),this.sourcesWithLayers.region.setLayersVisible(s),this.setHighlightLayerVisible(this.hexOutlineLayerSpec.id,"hexgrid-2d"===e&&i),this.setHighlightLayerVisible(this.hexExtrusionHighlightLayerSpec.id,"hexgrid-3d"===e&&i),this.setHighlightLayerVisible(this.squareOutlineLayerSpec.id,"square-2d"===e&&r),this.setHighlightLayerVisible(this.squareExtrusionHighlightLayerSpec.id,"square-3d"===e&&r)}hideAllDataLayers(){this.sourcesWithLayers.heatmap.setLayersVisible(!1),this.sourcesWithLayers.hexgrid.setLayersVisible(!1),this.sourcesWithLayers.square.setLayersVisible(!1),this.sourcesWithLayers.region.setLayersVisible(!1),this.setHighlightLayerVisible(this.hexOutlineLayerSpec.id,!1),this.setHighlightLayerVisible(this.hexExtrusionHighlightLayerSpec.id,!1),this.setHighlightLayerVisible(this.squareOutlineLayerSpec.id,!1),this.setHighlightLayerVisible(this.squareExtrusionHighlightLayerSpec.id,!1)}addHighlightLayersToMap(e,t){const i=(e,t)=>{this.mapLibreMap.getLayer(e.id)||this.mapLibreMap.addLayer({...e,source:t},Gt(this.mapLibreMap,e.beforeID)),this.mapLibreMap.setLayoutProperty(e.id,"visibility","none")};i(this.hexOutlineLayerSpec,e),i(this.hexExtrusionHighlightLayerSpec,e),i(this.squareOutlineLayerSpec,t),i(this.squareExtrusionHighlightLayerSpec,t)}setHighlightLayerVisible(e,t){this.mapLibreMap.getLayer(e)&&this.mapLibreMap.setLayoutProperty(e,"visibility",t?"visible":"none")}applyLayerConfig(e){const t=this.lastAnalytics?.properties.ranges?.[this.activeMetric],i=lc(this.heatmapLayerSpec.id,e,t),r=cc(this.hexFillLayerSpec.id,e,t),s=hc(this.hexExtrusionLayerSpec.id,e,t),o=_c(this.hexExtrusionHighlightLayerSpec.id,e,t),a=uc(this.squareFillLayerSpec.id,e,t),n=dc(this.squareExtrusionLayerSpec.id,e,t),l=Lc(this.squareExtrusionHighlightLayerSpec.id,e,t);Ht(i,this.heatmapLayerSpec,this.mapLibreMap),Ht(r,this.hexFillLayerSpec,this.mapLibreMap),Ht(s,this.hexExtrusionLayerSpec,this.mapLibreMap),Ht(o,this.hexExtrusionHighlightLayerSpec,this.mapLibreMap),Ht(a,this.squareFillLayerSpec,this.mapLibreMap),Ht(n,this.squareExtrusionLayerSpec,this.mapLibreMap),Ht(l,this.squareExtrusionHighlightLayerSpec,this.mapLibreMap),this.heatmapLayerSpec=i,this.hexFillLayerSpec=r,this.hexExtrusionLayerSpec=s,this.hexExtrusionHighlightLayerSpec=o,this.squareFillLayerSpec=a,this.squareExtrusionLayerSpec=n,this.squareExtrusionHighlightLayerSpec=l,this.applyFiltersToLayers()}applyRegionConfig(e){const t=this.lightDark,i=yc(this.regionFillLayerSpec.id,e,t),r=fc(this.regionLineLayerSpec.id,e,t);if(Ht(i,this.regionFillLayerSpec,this.mapLibreMap),Ht(r,this.regionLineLayerSpec,this.mapLibreMap),this.regionFillLayerSpec=i,this.regionLineLayerSpec=r,this.lastAnalytics){const t=e?.regionPolygon?.inverted??ql.regionPolygon.inverted;this.sourcesWithLayers.region.show(this.buildRegionFC(this.lastAnalytics.features,t))}}applyFiltersToLayers(){const e=this.activeMetric,t=this.config?.metricConfig?.[e]?.filters,i=[this.hexFillLayerSpec.id,this.hexExtrusionLayerSpec.id,this.squareFillLayerSpec.id,this.squareExtrusionLayerSpec.id];if(!t||void 0===t.min&&void 0===t.max){for(const e of i)this.mapLibreMap.setFilter(e,null);return}const r=[];void 0!==t.min&&r.push([">=",["get",e],t.min]),void 0!==t.max&&r.push(["<=",["get",e],t.max]);const s=1===r.length?r[0]:["any",...r];for(const o of i)this.mapLibreMap.setFilter(o,s)}buildRegionFC(e,t){return{type:"FeatureCollection",features:e.map((e,i)=>{const r=`traffic-area-analytics-region-${i}`,s=t?B(e).geometry:e.geometry;return{...e,id:r,geometry:s,properties:{id:r}}})}}},Ec=e=>e.length?1===e.length?e[0]:["all",...e]:null,vc=(e,t)=>{e&&t.push(e)},Rc=(e,t,i)=>{e&&vc(ce(t,e),i)},Tc=(e,t)=>{Rc(e.roadCategories,"road_category",t),Rc(e.roadSubCategories,"road_subcategory",t)},Cc=e=>{const t=[];if(Tc(e,t),e.incidentCategories){const i=ce("icon_category_0",e.incidentCategories,E);vc(i,t)}if(e.magnitudes){const i=ce("magnitude_of_delay",e.magnitudes,e=>b.indexOf(e));vc(i,t)}return e.delays&&vc((e=>{const t=[];if(e.mustHaveDelay&&e.minDelayMinutes){const i=60*e.minDelayMinutes;t.push([">=",["get","delay"],i])}else if(e.mustHaveDelay)t.push([">",["get","delay"],0]);else if(e.minDelayMinutes){const i=60*e.minDelayMinutes;t.push(["any",["!",["has","delay"]],["==",["get","delay"],0],[">=",["get","delay"],i]])}return Ec(t)})(e.delays),t),Ec(t)},wc=e=>{if(!e?.any?.length)return null;const t=e.any.map(Cc).filter(e=>!i(e));return ne(t)},Oc=e=>{const t=[];if(Tc(e,t),e.showRoadClosures){const i="only"===e.showRoadClosures?"==":"!=";t.push([i,["get","road_closure"],!0])}return Ec(t)},Mc=(e,t,i,r)=>{for(const s of t)i.setClause(s.id,r,e)},Nc="traffic.flow",xc=class e extends ei{static async get(t,i){return await Pt(t),await jt(t,Ui,"trafficFlow"),Wi(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Ui);if(!t)throw ye(`init ${e.name} with source ID ${Ui}`);return{trafficFlow:new ui(this.mapLibreMap,t)}}_applyConfig(e){return this._setVisible(e?.visible??!1,!1),this._filter(e?.filters,!1),e}getLayers(){return hi(this.tomtomMap.mapLibreMap,[Ui])}filter(e){this._filter(e)}_filter(e,t=!0){if(this.tomtomMap.mapReady)if(e?.any?.length){const t=(e=>{if(!e?.any?.length)return null;const t=e.any.map(Oc).filter(e=>!i(e));return ne(t)})(e);t&&Mc(t,this.getLayers(),this.filterComposer,Nc)}else this.config?.filters?.any?.length&&Mc(void 0,this.getLayers(),this.filterComposer,Nc);t&&(this.config=a({...this.config,filters:e},i),this.emitConfigChange())}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficFlow.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}isVisible(){return this.sourcesWithLayers.trafficFlow.isAnyLayerVisible()}getShown(){return{trafficFlow:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.trafficFlow.sourceAndLayerIDs.layerIDs,validate:!1}).map(Tt)}}get events(){return this.moduleEvents(["trafficFlow"],{mapping:Tt})}},Dc="tt-traffic-incident-direction-chevron",Fc='<svg xmlns="http://www.w3.org/2000/svg" width="48" height="18" viewBox="0 0 48 18">\n<path d="M 18 4 L 30 9 L 18 14" fill="none" stroke="rgba(20, 30, 50, 0.5)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>\n<path d="M 18 4 L 30 9 L 18 14" fill="none" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>',Pc=["interpolate",["exponential",1.5],["zoom"],5,0,9,.96,13,2.1,19,10.8],kc=["interpolate",["exponential",1.5],["zoom"],5,.75,9,1.96,13,3.6,19,13.8],Uc=e=>["match",["get","magnitudeOfDelay"],"unknown",e.unknown,"minor",e.minor,"moderate",e.moderate,"major",e.major,"indefinite",e.indefinite,e.major],Hc=["match",["get","magnitudeOfDelay"],"unknown","traffic-incidents-no_delay-pattern","indefinite","traffic-incidents-road_closed-pattern",""],Wc=e=>"dark"===e?"#FFF":"#000",Gc=["interpolate",["exponential",1.5],["zoom"],5,2.2,9,4.6,13,8.3,19,26],Bc=["case",["==",["feature-state","focused"],!0],1,0],Vc=(e,t)=>{if(null===t)return e;const[i,r,s,...o]=e;return[i,r,s,...o.map((e,i)=>i%2==1?["case",["==",["feature-state","focused"],!0],e*t,e]:e)]},zc=["in",["get","magnitudeOfDelay"],["literal",["minor","moderate","major"]]],jc=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],$c=(e,t,i,r)=>{const s=r?.widthScale??null,o=[];return null!==r&&o.push({id:`${e}-focus-halo`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":r.outlineColor,"line-width":Gc,"line-blur":0,"line-opacity":Bc},beforeID:t}),o.push({id:`${e}-outline`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Uc(i.outline),"line-width":Vc(kc,s)},beforeID:t},{id:`${e}-inner-solid`,type:"line",minzoom:6,filter:zc,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Uc(i.inner),"line-width":Vc(Pc,s)},beforeID:t},{id:`${e}-inner-chevron`,type:"line",minzoom:12,filter:zc,layout:{"line-cap":"butt","line-join":"round"},paint:{"line-pattern":Dc,"line-width":Vc(Pc,s)},beforeID:t},{id:`${e}-inner-pattern`,type:"line",minzoom:6,filter:jc,layout:{"line-cap":"round","line-join":"round"},paint:{"line-pattern":Hc,"line-width":Vc(Pc,s)},beforeID:t}),o},Yc=["step",["zoom"],.7,14,.8,16,.9,18,1],Kc=["step",["zoom"],12.6,14,14.4,16,16.2,18,18],qc=["match",["get","category"],"other","traffic-incidents-info","accident","traffic-incidents-accident","fog","traffic-incidents-fog","danger","traffic-incidents-roadworks","rain","traffic-incidents-rain","frost","traffic-incidents-frost","lane-closed","traffic-incidents-lane_closed","roadworks","traffic-incidents-roadworks","wind","traffic-incidents-wind","flooding","traffic-incidents-flooding","broken-down-vehicle","traffic-incidents-broken_down_vehicle",""],Zc=["all",["!=",["get","magnitudeOfDelay"],"indefinite"],["any",["!",["has","delayInSeconds"]],["step",["zoom"],[">",["get","delayInSeconds"],900],14,[">",["get","delayInSeconds"],600],15,[">",["get","delayInSeconds"],300],16,!0]]],Xc=["all",["==",["get","category"],"jam"],["!=",["get","magnitudeOfDelay"],"unknown"],["!=",["get","magnitudeOfDelay"],"indefinite"],["step",["zoom"],[">",["get","delayInSeconds"],900],13,[">",["get","delayInSeconds"],600],14,[">",["get","delayInSeconds"],300],15,!0]],Jc=["==",["get","magnitudeOfDelay"],"indefinite"],Qc=["concat","traffic-jam-",["get","magnitudeOfDelay"],["case",["<",["get","delayInSeconds"],600],"-small",["<",["get","delayInSeconds"],3600],"-medium","-large"]],eh=["case",["<=",["get","delayInSeconds"],60],"1 min",[">=",["get","delayInSeconds"],3600],["concat",["to-string",["floor",["/",["to-number",["get","delayInSeconds"]],3600]]]," hr ",["case",["==",["%",["round",["/",["to-number",["get","delayInSeconds"]],60]],60],0],"",["concat",["to-string",["round",["%",["/",["to-number",["get","delayInSeconds"]],60],60]]]," min"]]],["concat",["round",["/",["get","delayInSeconds"],60]]," min"]],th=["case",["has","delayInSeconds"],["*",-1,["get","delayInSeconds"]],0],ih=(e,t)=>[{id:`${e}-incident-marker`,type:"symbol",minzoom:13,filter:Zc,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":qc,"icon-size":Yc,"symbol-sort-key":th},beforeID:t},{id:`${e}-jam-marker`,type:"symbol",minzoom:12,filter:Xc,layout:{"symbol-placement":"point","icon-anchor":"bottom-left","icon-offset":[2,3],"icon-image":Qc,"icon-size":Yc,"icon-padding":0,"text-anchor":"bottom-left","text-field":eh,"text-font":["NotoSans-CondensedBold"],"text-offset":[2.7,-.75],"text-size":Kc,"symbol-sort-key":th},paint:{"text-color":"hsl(210, 30%, 14%)"},beforeID:t},{id:`${e}-closed-road-marker`,type:"symbol",minzoom:12,filter:Jc,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":"traffic-incidents-road_closed","icon-size":Yc},beforeID:t}],rh=["unknown","minor","moderate","major","indefinite"],sh={unknown:{outline:"TrafficIncidents - No delay outline",inner:"TrafficIncidents - No delay pattern"},minor:{outline:"TrafficIncidents - Minor jam outline",inner:"TrafficIncidents - Minor jam"},moderate:{outline:"TrafficIncidents - Moderate jam outline",inner:"TrafficIncidents - Moderate jam"},major:{outline:"TrafficIncidents - Major jam outline",inner:"TrafficIncidents - Major jam"},indefinite:{outline:"TrafficIncidents - Closed road outline",inner:"TrafficIncidents - Closed road pattern"}},oh={unknown:"hsl(198, 20%, 54%)",minor:"hsl(45, 85%, 36%)",moderate:"hsl(9, 87%, 31%)",major:"hsl(0, 100%, 17%)",indefinite:"hsl(0, 100%, 34%)"},ah={unknown:"hsl(198, 20%, 90%)",minor:"hsl(45, 100%, 51%)",moderate:"hsl(9, 97%, 51%)",major:"hsl(0, 100%, 34%)",indefinite:"hsl(197, 28%, 95%)"},nh=(e,t,i)=>{if(!e||"object"!=typeof e)return;const r=e.paint;if(!r||"object"!=typeof r)return;const s=r["line-color"];if("string"==typeof s)return s;void 0!==s&&i.push(t)},lh=e=>{if("top"!==e)return e?Ni[e]:Ni.lowestLabel},ch=class e extends Qt{static async create(t,i){return await Pt(t),new e(t,i??{})}constructor(e,t){super(e,t),this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=`traffic-incident-overlay-${this.instanceIndex}`,r=this.tomtomMap.styleLightDarkTheme,s=(()=>{if(Nt())return dn||(dn=xt(Dt(Fc))),dn})();s&&$t("if-not-in-sprite",Dc,s,this.mapLibreMap);const o=lh(e?.beforeLayerConfig),a=(e=>{const t=e.getStyle()?.layers??[],i=/* @__PURE__ */new Map;for(const o of t)i.set(o.id,o);const r={outline:{...oh},inner:{...ah}},s=[];for(const o of rh){const e=sh[o],t=nh(i.get(e.outline),e.outline,s),a=nh(i.get(e.inner),e.inner,s);t&&(r.outline[o]=t),a&&(r.inner[o]=a)}return s.length>0&&console.warn("[TrafficIncidentOverlayModule] style layers have non-literal `line-color` (match/case/etc.); falling back to default colour for: "+s.join(", ")),r})(this.mapLibreMap),n=((e,t)=>!1===e?null:{outlineColor:e?.outlineColor??Wc(t),widthScale:e?.widthScale??1.6})(e?.focus,r),l=[...$c(i,o,a,n),...ih(i,o)];return{incidents:new yi(this.mapLibreMap,i,l)}}_applyConfig(e){return!1===e?.visible?this.sourcesWithLayers.incidents.setLayersVisible(!1):this.sourcesWithLayers.incidents.setLayersVisible(!0),this.applyBeforeLayer(e?.beforeLayerConfig),e}applyBeforeLayer(e){const t=lh(e);for(const i of this.sourcesWithLayers.incidents.sourceAndLayerIDs.layerIDs)Bt(this.mapLibreMap,i,t)}discardShownData(){this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null}restoreDataAndConfigImpl(){this.initSourcesWithLayers(this.config,!0),this.lastResult&&this.sourcesWithLayers.incidents.show(this.lastResult),this._applyConfig(this.config),null!==this.lastFocusIds&&this.lastFocusIds.length>0&&this.setFocus(this.lastFocusIds)}async show(e){await this.waitUntilModuleReady(),this.clearFeatureState(),this.lastFocusIds=null,this.lastResult=e,this.lastFeatureIds=e.features.map(e=>e.properties.id).filter(e=>"string"==typeof e),this.sourcesWithLayers.incidents.show(e);for(const t of this.shownFeaturesHandlers)t(e)}async clear(){await this.waitUntilModuleReady(),this.clearFeatureState(),this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null,this.sourcesWithLayers.incidents.clear()}setVisible(e){this.config={...this.config,visible:e},this.sourcesWithLayers.incidents.setLayersVisible(e),this.emitConfigChange()}isVisible(){return this.sourcesWithLayers.incidents.isAnyLayerVisible()}moveBeforeLayer(e){this.config={...this.config,beforeLayerConfig:e},this.applyBeforeLayer(e),this.emitConfigChange()}getShown(){return{incidents:this.sourcesWithLayers.incidents.shownFeatures}}get events(){return this.moduleEventsWithShown(["incidents"],this.shownFeaturesHandlers)}setFocus(e){if(null===e||0===e.length)return this.lastFocusIds=null,void this.clearFeatureState();if(0===this.lastFeatureIds.length)return;this.lastFocusIds=e;const t=new Set(e),i=this.sourcesWithLayers.incidents.sourceAndLayerIDs.sourceID;for(const r of this.lastFeatureIds)this.mapLibreMap.setFeatureState({source:i,id:r},{focused:t.has(r)})}clearFeatureState(){if(0===this.lastFeatureIds.length)return;const e=this.sourcesWithLayers.incidents.sourceAndLayerIDs.sourceID;for(const t of this.lastFeatureIds)this.mapLibreMap.removeFeatureState({source:e,id:t})}},hh="traffic.incidents",uh=class t extends ei{static async get(e,i){return await Pt(e),await jt(e,ki,"trafficIncidents"),Wi(e,t,()=>new t(e,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const e=this.mapLibreMap.getSource(ki);if(!e)throw ye(`init ${t.name} with source ID ${ki}`);return{trafficIncidents:new ui(this.mapLibreMap,e)}}_applyConfig(e){return this._setVisible(e?.visible??!1,{updateConfig:!1}),i(e?.icons?.visible)||this._setIconsVisible(e.icons.visible,!1),this._filter(e?.filters,e?.icons?.filters,!1),e}filter(e,t){this._filter(e,t)}_filter(e,t,r=!0){if(this.tomtomMap.mapReady){if(e?.any?.length){const i=wc(e);if(i){const e=t?this.getNonSymbolLayers():this.getLayers();Mc(i,e,this.filterComposer,hh)}}else this.config?.filters?.any?.length&&Mc(void 0,this.getLayers(),this.filterComposer,hh);if(t?.any?.length){const e=wc(t);e&&Mc(e,this.getSymbolLayers(),this.filterComposer,hh)}}r&&(this.config=a({...this.config,filters:e,icons:{...this.config?.icons,filters:t}},i),this.emitConfigChange())}getLayers(){return hi(this.tomtomMap.mapLibreMap,[ki])}getSymbolLayers(){return this.getLayers().filter(e=>"symbol"===e.type)}getNonSymbolLayers(){return this.getLayers().filter(e=>"symbol"!=e.type)}setIconsVisible(e){this._setIconsVisible(e)}_setIconsVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficIncidents.setLayersVisible(e,e=>"symbol"===e.type),t&&(this.config={...this.config,icons:{...this.config?.icons,visible:e}},this.emitConfigChange())}setVisible(e){this._setVisible(e)}_setVisible(t,i){(i?.updateConfig??1)&&(delete this.config?.icons?.visible,this.config={...a({...this.config},e),visible:t},this.emitConfigChange()),this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficIncidents.setLayersVisible(t)}isVisible(){return this.sourcesWithLayers.trafficIncidents.isAnyLayerVisible()}anyIconLayersVisible(){return this.sourcesWithLayers.trafficIncidents?.isAnyLayerVisible(e=>"symbol"===e.type)}getShown(){return{trafficIncidents:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.trafficIncidents.sourceAndLayerIDs.layerIDs,validate:!1}).map(wt)}}get events(){return this.moduleEvents(["trafficIncidents"],{mapping:wt})}},dh=["motorway","motorway_link","trunk","trunk_link","primary","primary_link","secondary","secondary_link","tertiary","tertiary_link","street","service","track"],ph=["unclassified","residential","living_street"],yh=["parking","driveway","alley"],fh=(e,t)=>({left:e.left-t.left,top:e.top-t.top,right:e.right-t.left,bottom:e.bottom-t.top}),mh=(e,t,i)=>e.right<=0||e.left>=t||e.bottom<=0||e.top>=i,gh=(e,t,i,r)=>{e.top<=i-e.bottom?t.top=Math.max(t.top,e.bottom+r):t.bottom=Math.min(t.bottom,e.top-r)},_h=(e,t,i,r)=>{e.left<=i-e.right?t.left=Math.max(t.left,e.right+r):t.right=Math.min(t.right,e.left-r)},Lh=(e,t,i,r,s)=>{const o=((e,t,i)=>({left:Math.max(0,e.left),top:Math.max(0,e.top),right:Math.min(t,e.right),bottom:Math.min(i,e.bottom)}))(e,i,r),a=e.left<=0&&e.right>=i,n=e.top<=0&&e.bottom>=r;if(a&&!n)return void gh(o,t,r,s);if(n&&!a)return void _h(o,t,i,s);const l=e.left<=0,c=e.right>=i,h=e.top<=0,u=e.bottom>=r;!l&&!c||h||u?!h&&!u||l||c?((e,t,i,r,s)=>{const o=e.left,a=i-e.right,n=e.top,l=r-e.bottom,c=Math.min(o,a,n,l);c===o?t.left=Math.max(t.left,e.right+s):c===a?t.right=Math.min(t.right,e.left-s):c===n?t.top=Math.max(t.top,e.bottom+s):t.bottom=Math.min(t.bottom,e.top-s)})(o,t,i,r,s):_h(o,t,i,s):gh(o,t,r,s)},bh=e=>"string"==typeof e?document.querySelector(e):e,Sh=e=>"mapLibreMap"in e?e.mapLibreMap:e,Ih=(e,t,i)=>{const r=Sh(e).getContainer().getBoundingClientRect(),{width:s,height:o}=r,a={left:i,top:i,right:s-i,bottom:o-i};for(const n of t){const e=bh(n);if(!e)continue;const t=e.getBoundingClientRect(),l=fh(t,r);mh(l,s,o)||Lh(l,a,s,o,i)}return a.left>=a.right||a.top>=a.bottom?null:{visibleAreaBounds:a,mapWidthPX:s,mapHeightPX:o}},Ah=e=>{const{map:t,surroundingElements:i,paddingPX:r=0}=e,s=Ih(t,i,r);if(!s)return null;const{visibleAreaBounds:o}=s,a=Sh(t),n=a.unproject([o.left,o.bottom]),l=a.unproject([o.right,o.top]);return[n.lng,n.lat,l.lng,l.lat]},Eh=e=>{const{map:t,surroundingElements:i}=e,r=Ah({map:t,surroundingElements:i});if(!r)return null;const[s,o,a,n]=r;return[(s+a)/2,(o+n)/2]},vh=e=>{const{map:t,toBeContainedBBox:i,surroundingElements:r,paddingPX:s=0}=e,o=Ih(t,r,s);if(!o)return null;const{visibleAreaBounds:a,mapWidthPX:n,mapHeightPX:l}=o,c=a.left/n,h=a.right/n,u=a.top/l,d=h-c,p=a.bottom/l-u,[y,f,m,g]=i,_=(m-y)/d,L=(g-f)/p,b=y-c*_,S=g+u*L;return[b,S-L,b+_,S]};export{Qt as AbstractDataOwnedMapModule,Jt as AbstractMapModule,ci as AbstractSourceWithLayers,ei as AbstractStyleOwnedMapModule,di as AddedSourceWithLayers,Pi as BASE_MAP_SOURCE_ID,ws as BaseMapModule,q as CombinedEvents,Ms as CustomGeoJSONModule,_e as DEFAULT_STYLE_VERSION,Ci as DEFAULT_TEXT_SIZE,ao as DESELECTED_FOREGROUND_COLOR,no as DESELECTED_OUTLINE_COLOR,uo as DESELECTED_ROUTE_FILTER,lo as DESELECTED_SECONDARY_COLOR,Ai as EventsProxy,Xa as FINISH_INDEX,yi as GeoJSONSourceWithLayers,js as GeometriesModule,Di as HILLSHADE_SOURCE_ID,xo as INDEFINITE_DELAY_DASH_COLOR,de as LayerFilterComposer,fl as LayerSelection,Ro as MAJOR_DELAY_COLOR,Ei as MAP_BOLD_FONT,Ti as MAP_ITALIC_FONT,Ri as MAP_MEDIUM_FONT,vi as MAP_REGULAR_FONT,Za as MIDDLE_INDEX,Co as MINOR_DELAY_COLOR,wo as MINOR_DELAY_LABEL_COLOR,To as MODERATE_DELAY_COLOR,pe as ModuleEvents,xi as POI_SOURCE_ID,_s as POIsModule,ds as PlacesModule,so as ROUTE_LINE_FOREGROUND_COLOR,co as ROUTE_LINE_FOREGROUND_WIDTH,oo as ROUTE_LINE_OUTLINE_COLOR,po as ROUTE_LINE_OUTLINE_WIDTH,jn as RoutingModule,ho as SELECTED_ROUTE_FILTER,qa as START_INDEX,Ja as STOP_DISPLAY_INDEX,ui as StyleSourceWithLayers,Ol as StylingModule,Fi as TERRAIN_SOURCE_ID,Ui as TRAFFIC_FLOW_SOURCE_ID,ki as TRAFFIC_INCIDENTS_SOURCE_ID,Vl as TerrainModule,Bl as TomTomMap,li as TomTomMapSource,Ac as TrafficAreaAnalyticsModule,xc as TrafficFlowModule,ch as TrafficIncidentOverlayModule,uh as TrafficIncidentsModule,Mo as UNKNOWN_DELAY_BG_COLOR,Oo as UNKNOWN_DELAY_COLOR,No as UNKNOWN_DELAY_DASH_COLOR,Xt as UserEvents,Bs as adaptPaletteForTheme,ee as assertNoReservedScopeNames,As as baseMapLayerGroupNames,$i as baseMapPOICategoryValues,ma as bespokeSectionTypes,is as buildPlaceTitle,Ys as buildReachableRangeFeatures,hn as buildRoutingLayers,vh as calculateFittingBBox,Ah as calculatePaddedBBox,Eh as calculatePaddedCenter,Gs as colorPaletteIDs,Ws as colorPalettes,X as combineEventScopes,un as defaultRoutingLayers,ga as drawnSectionTypes,hi as filterLayersBySources,Gi as filterShowModes,ri as findFeatureByRefId,xe as formatStyleHsl,fa as generatedSectionTypes,Xs as geometryThemes,ss as getIconIDForPlace,Eo as getInstructionLineWidth,vo as getInstructionOutlineWidth,go as getLineForegroundWidth,_o as getLineOutlineWidth,ns as getPOIGroupForPlace,as as getPOILayerCategoryForPlace,So as getSectionHaloWidth,ms as getStyleCategories,Lo as getWaypointIconSize,st as mapColorNames,Vi as mapDisplayPoiCategoryMappings,wi as mapFonts,Ni as mapStyleLayerIDs,Oe as parseCssColor,ps as placesThemes,ys as poiCategoryGroups,Bi as poiLayerIDs,us as preparePlacesForDisplay,Ks as prepareReachableRangesForDisplay,Zs as reachableRangeGeometryConfig,ii as renderedRefId,Q as reservedScopeNames,ic as resolveColorStops,dh as roadCategories,J as scopedLayerSpecs,Ia as sectionDrawsByDefault,Ea as sectionSourceKey,ba as sectionSupportsKnob,yh as serviceRoadSubCategories,Wi as sharedInstance,fe as standardStyleIDs,ph as streetRoadSubCategories,me as styleModules,pl as stylingColorKnobIds,Gl as stylingKnobAppliesTo,dl as stylingKnobCatalogue,ul as stylingKnobIds,Wl as stylingKnobKinds,bl as stylingPresetCatalogue,Ll as stylingPresetIds,qs as themedGeometryConfig,ji as toBaseMapPOICategory,Ki as toBaseMapPOIGroup,Me as toHsl,ls as toPlaces};
2
2
  //# sourceMappingURL=map.es.js.map