@maptiler/client 2.6.0 → 2.7.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 +1 @@
1
- import De from"quick-lru";function we(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class q{constructor(){this._apiKey="",this._fetch=we(),this.tileCacheSize=200}set apiKey(a){this._apiKey=a}get apiKey(){return this._apiKey}set fetch(a){this._fetch=a}get fetch(){return this._fetch}}const m=new q,Y={AUTO:{code:null,flag:"auto",name:"Auto",latin:!1,isMode:!0,geocoding:!0},LATIN:{code:"latin",flag:"name:latin",name:"Latin",latin:!0,isMode:!1,geocoding:!1},NON_LATIN:{code:"nonlatin",flag:"name:nonlatin",name:"Non Latin",latin:!1,isMode:!1,geocoding:!1},LOCAL:{code:null,flag:"name",name:"Local",latin:!0,isMode:!1,geocoding:!1}},Z={ALBANIAN:{code:"sq",flag:"name:sq",name:"Albanian",latin:!0,isMode:!1,geocoding:!0},AMHARIC:{code:"am",flag:"name:am",name:"Amharic",latin:!1,isMode:!1,geocoding:!0},ARABIC:{code:"ar",flag:"name:ar",name:"Arabic",latin:!1,isMode:!1,geocoding:!0},ARMENIAN:{code:"hy",flag:"name:hy",name:"Armenian",latin:!1,isMode:!1,geocoding:!0},AZERBAIJANI:{code:"az",flag:"name:az",name:"Azerbaijani",latin:!0,isMode:!1,geocoding:!0},BASQUE:{code:"eu",flag:"name:eu",name:"Basque",latin:!0,isMode:!1,geocoding:!0},BELARUSIAN:{code:"be",flag:"name:be",name:"Belarusian",latin:!1,isMode:!1,geocoding:!0},BENGALI:{code:"bn",flag:"name:bn",name:"Bengali",latin:!0,isMode:!1,geocoding:!0},BOSNIAN:{code:"bs",flag:"name:bs",name:"Bosnian",latin:!0,isMode:!1,geocoding:!0},BRETON:{code:"br",flag:"name:br",name:"Breton",latin:!0,isMode:!1,geocoding:!0},BULGARIAN:{code:"bg",flag:"bg",name:"Bulgarian",latin:!1,isMode:!1,geocoding:!0},CATALAN:{code:"ca",flag:"name:ca",name:"Catalan",latin:!0,isMode:!1,geocoding:!0},CHINESE:{code:"zh",flag:"name:zh",name:"Chinese",latin:!1,isMode:!1,geocoding:!0},TRADITIONAL_CHINESE:{code:"zh-Hant",flag:"name:zh-Hant",name:"Chinese (traditional)",latin:!1,isMode:!1,geocoding:!1},SIMPLIFIED_CHINESE:{code:"zh-Hans",flag:"name:zh-Hans",name:"Chinese (simplified)",latin:!1,isMode:!1,geocoding:!1},CORSICAN:{code:"co",flag:"name:co",name:"Corsican",latin:!0,isMode:!1,geocoding:!0},CROATIAN:{code:"hr",flag:"name:hr",name:"Croatian",latin:!0,isMode:!1,geocoding:!0},CZECH:{code:"cs",flag:"name:cs",name:"Czech",latin:!0,isMode:!1,geocoding:!0},DANISH:{code:"da",flag:"name:da",name:"Danish",latin:!0,isMode:!1,geocoding:!0},DUTCH:{code:"nl",flag:"name:nl",name:"Dutch",latin:!0,isMode:!1,geocoding:!0},GERMAN:{code:"de",flag:"name:de",name:"German",latin:!0,isMode:!1,geocoding:!0},GREEK:{code:"el",flag:"name:el",name:"Greek",latin:!1,isMode:!1,geocoding:!0},ENGLISH:{code:"en",flag:"name:en",name:"English",latin:!0,isMode:!1,geocoding:!0},ESPERANTO:{code:"eo",flag:"name:eo",name:"Esperanto",latin:!0,isMode:!1,geocoding:!0},ESTONIAN:{code:"et",flag:"name:et",name:"Estonian",latin:!0,isMode:!1,geocoding:!0},FINNISH:{code:"fi",flag:"name:fi",name:"Finnish",latin:!0,isMode:!1,geocoding:!0},FRENCH:{code:"fr",flag:"name:fr",name:"French",latin:!0,isMode:!1,geocoding:!0},FRISIAN:{code:"fy",flag:"name:fy",name:"Frisian (West)",latin:!0,isMode:!1,geocoding:!0},GEORGIAN:{code:"ka",flag:"name:ka",name:"Georgian",latin:!1,isMode:!1,geocoding:!0},HEBREW:{code:"he",flag:"name:he",name:"Hebrew",latin:!1,isMode:!1,geocoding:!0},HINDI:{code:"hi",flag:"name:hi",name:"Hindi",latin:!1,isMode:!1,geocoding:!0},HUNGARIAN:{code:"hu",flag:"name:hu",name:"Hungarian",latin:!0,isMode:!1,geocoding:!0},ICELANDIC:{code:"is",flag:"name:is",name:"Icelandic",latin:!0,isMode:!1,geocoding:!0},INDONESIAN:{code:"id",flag:"name:id",name:"Indonesian",latin:!0,isMode:!1,geocoding:!0},IRISH:{code:"ga",flag:"name:ga",name:"Irish",latin:!0,isMode:!1,geocoding:!0},ITALIAN:{code:"it",flag:"name:it",name:"Italian",latin:!0,isMode:!1,geocoding:!0},JAPANESE:{code:"ja",flag:"name:ja",name:"Japanese",latin:!1,isMode:!1,geocoding:!0},JAPANESE_HIRAGANA:{code:"ja-Hira",flag:"name:ja-Hira",name:"Japanese Hiragana form",latin:!1,isMode:!1,geocoding:!1},JAPANESE_2018:{code:"ja-Latn",flag:"name:ja-Latn",name:"Japanese (Latin 2018)",latin:!0,isMode:!1,geocoding:!1},JAPANESE_KANA:{code:"ja_kana",flag:"name:ja_kana",name:"Japanese (Kana)",latin:!1,isMode:!1,geocoding:!1},JAPANESE_LATIN:{code:"ja_rm",flag:"name:ja_rm",name:"Japanese (Latin script)",latin:!0,isMode:!1,geocoding:!1},KANNADA:{code:"kn",flag:"name:kn",name:"Kannada",latin:!0,isMode:!1,geocoding:!0},KAZAKH:{code:"kk",flag:"name:kk",name:"Kazakh",latin:!1,isMode:!1,geocoding:!0},KOREAN:{code:"ko",flag:"name:ko",name:"Korean",latin:!1,isMode:!1,geocoding:!0},KOREAN_LATIN:{code:"ko-Latn",flag:"name:ko-Latn",name:"Korean (Latin script)",latin:!0,isMode:!1,geocoding:!1},KURDISH:{code:"ku",flag:"name:ku",name:"Kurdish",latin:!0,isMode:!1,geocoding:!0},CLASSICAL_LATIN:{code:"la",flag:"name:la",name:"Latin",latin:!0,isMode:!1,geocoding:!0},LATVIAN:{code:"lv",flag:"name:lv",name:"Latvian",latin:!0,isMode:!1,geocoding:!0},LITHUANIAN:{code:"lt",flag:"name:lt",name:"Lithuanian",latin:!0,isMode:!1,geocoding:!0},LUXEMBOURGISH:{code:"lb",flag:"name:lb",name:"Luxembourgish",latin:!0,isMode:!1,geocoding:!0},MACEDONIAN:{code:"mk",flag:"name:mk",name:"Macedonian",latin:!1,isMode:!1,geocoding:!0},MALAYALAM:{code:"ml",flag:"name:ml",name:"Malayalam",latin:!1,isMode:!1,geocoding:!0},MALTESE:{code:"mt",flag:"name:mt",name:"Maltese",latin:!0,isMode:!1,geocoding:!0},NORWEGIAN:{code:"no",flag:"name:no",name:"Norwegian",latin:!0,isMode:!1,geocoding:!0},OCCITAN:{code:"oc",flag:"name:oc",name:"Occitan",latin:!0,isMode:!1,geocoding:!0},PERSIAN:{code:"fa",flag:"name:fa",name:"Persian",latin:!1,isMode:!1,geocoding:!0},POLISH:{code:"pl",flag:"name:pl",name:"Polish",latin:!0,isMode:!1,geocoding:!0},PORTUGUESE:{code:"pt",flag:"name:pt",name:"Portuguese",latin:!0,isMode:!1,geocoding:!0},PUNJABI:{code:"pa",flag:"name:pa",name:"Punjabi",latin:!1,isMode:!1,geocoding:!0},WESTERN_PUNJABI:{code:"pnb",flag:"name:pnb",name:"Western Punjabi",latin:!1,isMode:!1,geocoding:!1},ROMANIAN:{code:"ro",flag:"name:ro",name:"Romanian",latin:!0,isMode:!1,geocoding:!0},ROMANSH:{code:"rm",flag:"name:rm",name:"Romansh",latin:!0,isMode:!1,geocoding:!0},RUSSIAN:{code:"ru",flag:"name:ru",name:"Russian",latin:!1,isMode:!1,geocoding:!0},SERBIAN_CYRILLIC:{code:"sr",flag:"name:sr",name:"Serbian (Cyrillic script)",latin:!1,isMode:!1,geocoding:!0},SERBIAN_LATIN:{code:"sr-Latn",flag:"name:sr-Latn",name:"Serbian (Latin script)",latin:!0,isMode:!1,geocoding:!1},SCOTTISH_GAELIC:{code:"gd",flag:"name:gd",name:"Scottish Gaelic",latin:!0,isMode:!1,geocoding:!0},SLOVAK:{code:"sk",flag:"name:sk",name:"Slovak",latin:!0,isMode:!1,geocoding:!0},SLOVENE:{code:"sl",flag:"name:sl",name:"Slovene",latin:!0,isMode:!1,geocoding:!0},SPANISH:{code:"es",flag:"name:es",name:"Spanish",latin:!0,isMode:!1,geocoding:!0},SWEDISH:{code:"sv",flag:"name:sv",name:"Swedish",latin:!0,isMode:!1,geocoding:!0},TAMIL:{code:"ta",flag:"name:ta",name:"Tamil",latin:!1,isMode:!1,geocoding:!0},TELUGU:{code:"te",flag:"name:te",name:"Telugu",latin:!1,isMode:!1,geocoding:!0},THAI:{code:"th",flag:"name:th",name:"Thai",latin:!1,isMode:!1,geocoding:!0},TURKISH:{code:"tr",flag:"name:tr",name:"Turkish",latin:!0,isMode:!1,geocoding:!0},UKRAINIAN:{code:"uk",flag:"name:uk",name:"Ukrainian",latin:!1,isMode:!1,geocoding:!0},VIETNAMESE:{code:"vi",flag:"name:vi",name:"Vietnamese (Latin script)",latin:!0,isMode:!1,geocoding:!0},WELSH:{code:"cy",flag:"name:cy",name:"Welsh",latin:!0,isMode:!1,geocoding:!0}},v={...Y,...Z};function Q(e,a=v){return e in a?e[e]:null}function M(e,a=v){for(const t of Object.values(a))if(t.code===e)return t;return null}function E(e,a=v){for(const t of Object.values(a))if(t.flag===e)return t;return null}function K(){if(typeof navigator>"u"){const e=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];return M(e)??v.ENGLISH}return Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>M(e)).filter(e=>e)[0]??v.ENGLISH}function j(e){return e!==null&&typeof e=="object"&&"code"in e&&"flag"in e&&"name"in e&&"latin"in e&&"isMode"in e&&"geocoding"in e&&(typeof e.code=="string"||e.code===null)&&typeof e.flag=="string"&&typeof e.name=="string"&&typeof e.latin=="boolean"&&typeof e.isMode=="boolean"&&typeof e.geocoding=="boolean"}function O(e,a=v){return j(e)?E(e.flag,a):typeof e!="string"?null:Q(e,a)||M(e,a)||E(e,a)||null}function Ee(e,a,t=v){const n=O(e,t),i=O(a,t);return n&&i&&n.flag===i.flag}async function u(e,a={}){if(m.fetch===null)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(new URL(e).searchParams.get("key").trim()==="")throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return m.fetch(e,a)}const f={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(f);class p extends Error{constructor(a,t=""){super(`Call to enpoint ${a.url} failed with the status code ${a.status}. ${t}`),this.res=a}}const U={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function X(e,a){const{language:t}=a;if(t===void 0)return;const n=(Array.isArray(t)?t:[t]).map(r=>Ue(r)).filter(r=>r),i=Array.from(new Set(n)).join(",");e.set("language",i)}function Ue(e){const a=e===v.AUTO.flag?K():typeof e=="string"?M(e):j(e)?e.flag===v.AUTO.flag?K():E(e.flag):null;return a?.geocoding?a.code:null}function ee(e,a){const{apiKey:t,limit:n,types:i,excludeTypes:r}=a;e.set("key",t??m.apiKey),n!==void 0&&e.set("limit",String(n)),i!==void 0&&e.set("types",i.join(",")),r!==void 0&&e.set("excludeTypes",String(r)),X(e,a)}function ae(e,a){ee(e,a);const{bbox:t,proximity:n,country:i,fuzzyMatch:r,autocomplete:o}=a;t!==void 0&&e.set("bbox",t.join(",")),n!==void 0&&e.set("proximity",n==="ip"?n:n.join(",")),i!==void 0&&e.set("country",i.join(",")),r!==void 0&&e.set("fuzzyMatch",r?"true":"false"),o!==void 0&&e.set("autocomplete",o?"true":"false")}async function ke(e,a={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const t=new URL(`geocoding/${encodeURIComponent(e)}.json`,f.maptilerApiURL);ae(t.searchParams,a);const n=await u(t.toString());if(!n.ok)throw new p(n,U[n.status]??"");return await n.json()}async function Pe(e,a={}){if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const t=new URL(`geocoding/${e[0]},${e[1]}.json`,f.maptilerApiURL);ee(t.searchParams,a);const n=await u(t.toString());if(!n.ok)throw new p(n,U[n.status]??"");return await n.json()}async function Ne(e,a={}){const t=new URL(`geocoding/${e}.json`,f.maptilerApiURL);t.searchParams.set("key",a.apiKey??m.apiKey),X(t.searchParams,a);const n=await u(t.toString());if(!n.ok)throw new p(n,U[n.status]??"");return await n.json()}async function $e(e,a={}){if(!e.length)return[];const t=e.map(o=>encodeURIComponent(o)).join(";"),n=new URL(`geocoding/${t}.json`,f.maptilerApiURL);ae(n.searchParams,a);const i=await u(n.toString());if(!i.ok)throw new p(i,U[i.status]??"");const r=await i.json();return e.length===1?[r]:r}const be={forward:ke,reverse:Pe,byId:Ne,batch:$e},te={403:"Key is missing, invalid or restricted"};async function Ce(e={}){const a=new URL("geolocation/ip.json",f.maptilerApiURL);a.searchParams.set("key",e.apiKey??m.apiKey),"elevation"in e&&a.searchParams.set("elevation",e.elevation?"true":"false");const t=a.toString(),n=await u(t);if(!n.ok)throw new p(n,n.status in te?te[n.status]:"");return await n.json()}const Ke={info:Ce},k={403:"Key is missing, invalid or restricted"};async function je(e,a={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const t=new URL(`coordinates/search/${e}.json`,f.maptilerApiURL);t.searchParams.set("key",a.apiKey??m.apiKey),"limit"in a&&t.searchParams.set("limit",a.limit.toString()),"transformations"in a&&t.searchParams.set("transformations",a.transformations.toString()),"exports"in a&&t.searchParams.set("exports",a.exports.toString());const n=t.toString(),i=await u(n);if(!i.ok)throw new p(i,i.status in k?k[i.status]:"");return await i.json()}async function Oe(e,a={}){const t=(Array.isArray(e[0])?e:[e]).map(o=>`${o[0]},${o[1]}`).join(";"),n=new URL(`coordinates/transform/${t}.json`,f.maptilerApiURL);n.searchParams.set("key",a.apiKey??m.apiKey),"sourceCrs"in a&&n.searchParams.set("s_srs",a.sourceCrs.toString()),"targetCrs"in a&&n.searchParams.set("t_srs",a.targetCrs.toString()),"operations"in a&&n.searchParams.set("ops",(Array.isArray(a.operations)?a.operations:[a.operations]).join("|"));const i=n.toString(),r=await u(i);if(!r.ok)throw new p(r,r.status in k?k[r.status]:"");return await r.json()}const He={search:je,transform:Oe},ne={403:"Key is missing, invalid or restricted"};async function Ve(e,a={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The data ID must be a non-empty string");const t=new URL(`data/${encodeURIComponent(e)}/features.json`,f.maptilerApiURL);t.searchParams.set("key",a.apiKey??m.apiKey);const n=t.toString(),i=await u(n);if(!i.ok)throw new p(i,i.status in ne?ne[i.status]:"");return await i.json()}const xe={get:Ve};function ie(e){const a=/^maptiler:\/\/(.*)/;let t;const n=e.trim();let i;return n.startsWith("http://")||n.startsWith("https://")?i=n:(t=a.exec(n))!==null?i=`https://api.maptiler.com/maps/${t[1]}/style.json`:i=`https://api.maptiler.com/maps/${n}/style.json`,i}class H{constructor(a,t,n,i,r,o,s=!1,c){this.name=a,this.variantType=t,this.id=n,this.referenceStyle=i,this.description=r,this.imageURL=o,this.deprecated=s,this.deprecationMessage=c}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(a){return this.referenceStyle.hasVariant(a)}getVariant(a){const t=this.referenceStyle.getVariant(a);return this.warnIfDeprecated(t),t}getVariants(){return this.referenceStyle.getVariants().filter(a=>a!==this).map(a=>(this.warnIfDeprecated(a),a))}getImageURL(){return this.imageURL}getExpandedStyleURL(){return ie(this.getId())}warnIfDeprecated(a=this){if(!a.deprecated)return a;if(a.deprecationMessage)console.warn(a.deprecationMessage);else{const t=a.getFullName();console.warn(`Style "${t}" is deprecated and will be removed in a future version.`)}return a}}class V{constructor(a,t){this.name=a,this.id=t,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(a){this.variants[a.getType()]=a,this.orderedVariants.push(a)}hasVariant(a){return a in this.variants}getVariant(a){return a in this.variants?this.variants[a]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0].warnIfDeprecated()}}const S=[{referenceStyleID:"STREETS_V2",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default v2",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2" is deprecated, use "streets-v4" instead'},{id:"streets-v2-dark",name:"Dark v2",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-dark" is deprecated, use "streets-v4-dark" instead'},{id:"streets-v2-light",name:"Light v2",variantType:"LIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-light" is deprecated, use "streets-v4-light" instead'},{id:"streets-v2-night",name:"Night v2",variantType:"NIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-night" is deprecated, use "streets-v4-night" instead'},{id:"streets-v2-pastel",name:"Pastel v2",variantType:"PASTEL",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-pastel" is deprecated, use "streets-v4-pastel" instead'}]},{referenceStyleID:"STREETS_V4",name:"Streets",description:"",variants:[{id:"streets-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v4-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"BASE_V4",name:"Base",description:"",variants:[{id:"base-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"base-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"base-v4-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"base-v4-ai",name:"Base AI",variantType:"NIGHT",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"outdoor-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"BASIC_V2",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"basic-v2" is deprecated, use "basic-v4" instead'},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"TOPO",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"topo-v2-shiny",name:"Shiny",deprecated:!0,variantType:"SHINY",description:"",imageURL:""},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]},{referenceStyleID:"VOYAGER",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",deprecated:!0,variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",deprecated:!0,variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",deprecated:!0,variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",deprecated:!0,variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER",name:"Toner",description:"",variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",deprecated:!0,description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",deprecated:!0,description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BACKDROP",name:"Backdrop",description:"",variants:[{id:"backdrop",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"backdrop-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"backdrop-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"AQUARELLE",name:"Aquarelle",description:"Watercolor map for creative use",variants:[{id:"aquarelle",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"aquarelle-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"aquarelle-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]},{referenceStyleID:"LANDSCAPE_V2",name:"Landscape",description:"Terrain map for data overlays and visualisations",variants:[{id:"landscape",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape" is deprecated, use "landscape-v4" instead'},{id:"landscape-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape-dark" is deprecated, use "landscape-v4-dark" instead'},{id:"landscape-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape-vivid" is deprecated, use "landscape-v4-vivid" instead'}]},{referenceStyleID:"LANDSCAPE_V4",name:"Landscape",description:"Terrain map for data overlays and visualisations",variants:[{id:"landscape-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"landscape-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"landscape-v4-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]}],Fe={STREETS:"STREETS_V2",BASIC:"BASIC_V2",LANDSCAPE:"LANDSCAPE_V2"};function _e(e,a){S.find(i=>i.referenceStyleID===e)&&console.warn(`Default reference style ${e} already exists, it will be overwritten...`);const t=S.find(i=>i.referenceStyleID===a);if(!t)throw new Error(`Versioned map style not found for reference style: ${a}`);const n={...t,referenceStyleID:e};S.push(n)}Object.entries(Fe).forEach(([e,a])=>{_e(e,a)});function Be(e){return new Proxy(e,{get(a,t,n){return a.hasVariant(t)?a.getVariant(t):t.toString().toUpperCase()===t?e.getDefaultVariant():Reflect.get(a,t,n)}})}function Ge(){const e={};for(let a=0;a<S.length;a+=1){const t=S[a],n=Be(new V(t.name,t.referenceStyleID));for(let i=0;i<t.variants.length;i+=1){const r=t.variants[i],o=new H(r.name,r.variantType,r.id,n,r.description,r.imageURL,r.deprecated);n.addVariant(o)}e[t.referenceStyleID]=n}return e}function P(e){if(!e)return re[S[0].referenceStyleID].getDefaultVariant().getId();if(typeof e=="string"||e instanceof String)return e.trim().toLowerCase();if(e instanceof H)return e.getId();if(e instanceof V)return e.getDefaultVariant().getId()}const re=Ge();function ze(e){const a=[];function t(r){(r.type==="LineString"||r.type==="MultiLineString")&&a.push(r)}function n(r){r.geometry&&t(r.geometry)}function i(r){for(const o of r.features)o.type==="Feature"?n(o):o.type==="FeatureCollection"&&i(o)}return e.type==="Feature"?n(e):e.type==="FeatureCollection"?i(e):t(e),a}function We(e,a,t){let n=a[0],i=a[1],r=t[0]-n,o=t[1]-i;if(r!==0||o!==0){const s=((e[0]-n)*r+(e[1]-i)*o)/(r*r+o*o);s>1?(n=t[0],i=t[1]):s>0&&(n+=r*s,i+=o*s)}return r=e[0]-n,o=e[1]-i,r*r+o*o}function x(e,a,t,n,i){let r=n,o;for(let s=a+1;s<t;s++){const c=We(e[s],e[a],e[t]);c>r&&(o=s,r=c)}r>n&&(o-a>1&&x(e,a,o,n,i),i.push(e[o]),t-o>1&&x(e,o,t,n,i))}function Je(e,a){const t=e.length-1,n=[e[0]];return x(e,0,t,a,n),n.push(e[t]),n}function qe(e,a){if(e.length<=2)return e;const t=a!==void 0?a*a:1;return Je(e,t)}const oe={extractLineStrings:ze,simplify:qe};function F(e,a=!0){let t=`${e[0]},${e[1]}`;return e.length===3&&a&&(t+=`,${e[2]}`),t}function _(e,a=3e3){let t=e.map(r=>r.join(",")).join("|"),n=5e-6;const i=1e-5;for(;t.length>a;)t=oe.simplify(e,n).map(r=>`${r[0]},${r[1]}`).join("|"),n+=i;return t}function Ye(e,a,t={}){const n=P(t.style),i=t.hiDPI?"@2x":"",r=t.format??"png";let o=~~(t.width??1024),s=~~(t.height??1024);t.hiDPI&&(o=~~(o/2),s=~~(s/2));const c=new URL(`maps/${encodeURIComponent(n)}/static/${e[0]},${e[1]},${a}/${o}x${s}${i}.${r}`,f.maptilerApiURL);if("attribution"in t&&c.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let d="";const g="markerIcon"in t;g&&(d+=`icon:${t.markerIcon}|`),g&&"markerAnchor"in t&&(d+=`anchor:${t.markerAnchor}|`),g&&t.hiDPI&&(d+="scale:2|");const h=Array.isArray(t.markers[0])?t.markers:[t.markers];d+=h.map(A=>F(A,!g)).join("|"),c.searchParams.set("markers",d)}if("path"in t){let d="";if(d+=`fill:${t.pathFillColor??"none"}|`,"pathStrokeColor"in t&&(d+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const g=t.pathWidth/(t.hiDPI?2:1);d+=`width:${g.toString()}|`}d+=_(t.path),c.searchParams.set("path",d)}return c.searchParams.set("key",t.apiKey??m.apiKey),c.toString()}function Ze(e,a={}){const t=P(a.style),n=a.hiDPI?"@2x":"",i=a.format??"png";let r=~~(a.width??1024),o=~~(a.height??1024);a.hiDPI&&(r=~~(r/2),o=~~(o/2));const s=new URL(`maps/${encodeURIComponent(t)}/static/${e[0]},${e[1]},${e[2]},${e[3]}/${r}x${o}${n}.${i}`,f.maptilerApiURL);if("attribution"in a&&s.searchParams.set("attribution",a.attribution.toString()),"padding"in a&&s.searchParams.set("padding",a.padding.toString()),"markers"in a){let c="";const d="markerIcon"in a;d&&(c+=`icon:${a.markerIcon}|`),d&&"markerAnchor"in a&&(c+=`anchor:${a.markerAnchor}|`),d&&a.hiDPI&&(c+="scale:2|");const g=Array.isArray(a.markers[0])?a.markers:[a.markers];c+=g.map(h=>F(h,!d)).join("|"),s.searchParams.set("markers",c)}if("path"in a){let c="";if(c+=`fill:${a.pathFillColor??"none"}|`,"pathStrokeColor"in a&&(c+=`stroke:${a.pathStrokeColor}|`),"pathWidth"in a){const d=a.pathWidth/(a.hiDPI?2:1);c+=`width:${d.toString()}|`}c+=_(a.path),s.searchParams.set("path",c)}return s.searchParams.set("key",a.apiKey??m.apiKey),s.toString()}function Qe(e={}){if(!("markers"in e)&&!("path"in e))throw new Error("Automatic static maps require markers and/or path to be created.");const a=P(e.style),t=e.hiDPI?"@2x":"",n=e.format??"png";let i=~~(e.width??1024),r=~~(e.height??1024);e.hiDPI&&(i=~~(i/2),r=~~(r/2));const o=new URL(`maps/${encodeURIComponent(a)}/static/auto/${i}x${r}${t}.${n}`,f.maptilerApiURL);if("attribution"in e&&o.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&o.searchParams.set("padding",e.padding.toString()),"markers"in e){let s="";const c="markerIcon"in e;c&&(s+=`icon:${e.markerIcon}|`),c&&"markerAnchor"in e&&(s+=`anchor:${e.markerAnchor}|`),c&&e.hiDPI&&(s+="scale:2|");const d=Array.isArray(e.markers[0])?e.markers:[e.markers];s+=d.map(g=>F(g,!c)).join("|"),o.searchParams.set("markers",s)}if("path"in e){let s="";if(s+=`fill:${e.pathFillColor??"none"}|`,"pathStrokeColor"in e&&(s+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const c=e.pathWidth/(e.hiDPI?2:1);s+=`width:${c.toString()}|`}s+=_(e.path),o.searchParams.set("path",s)}return o.searchParams.set("key",e.apiKey??m.apiKey),o.toString()}const Xe={centered:Ye,bounded:Ze,automatic:Qe},N=63710088e-1,se=2*Math.PI*N;function ce(e){return(180+e)/360}function le(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function de(e){const a=fe(e);return[ce(a[0]),le(a[1])]}function ge(e){return e*360-180}function me(e){const a=180-e*360;return 360/Math.PI*Math.atan(Math.exp(a*Math.PI/180))-90}function ea(e){return[ge(e[0]),me(e[1])]}function B(e,a){const t=Math.PI/180,n=e[1]*t,i=a[1]*t,r=Math.sin(n)*Math.sin(i)+Math.cos(n)*Math.cos(i)*Math.cos((a[0]-e[0])*t);return N*Math.acos(Math.min(r,1))}function aa(e){const a=Array(e.length);a[0]=0;const t=a.length;for(let n=1;n<t;n++)a[n]=B(e[n-1],e[n])+a[n-1];return a}function fe(e){const a=e[0],t=e[1],n=360,i=((a+180)%n+n)%n-180;return[i===-180?180:i,t]}function ue(e){return se*Math.cos(e*Math.PI/180)}function pe(e,a,t=!0){const n=2**a,i=[e[0]*n,e[1]*n];return t?[~~i[0],~~i[1]]:i}function ta(e,a,t=!0){const n=de(e);return pe(n,a,t)}function R(e){return e*Math.PI/180}function G(e){return e*180/Math.PI}function na(e,a,t){const n=B(e,a),i=R(e[0]),r=R(e[1]),o=R(a[0]),s=R(a[1]),c=n/N,d=Math.sin((1-t)*c)/Math.sin(c),g=Math.sin(t*c)/Math.sin(c),h=d*Math.cos(r)*Math.cos(i)+g*Math.cos(s)*Math.cos(o),A=d*Math.cos(r)*Math.sin(i)+g*Math.cos(s)*Math.sin(o),T=d*Math.sin(r)+g*Math.sin(s),D=Math.atan2(T,Math.sqrt(h*h+A*A)),l=Math.atan2(A,h);return[G(l),G(D)]}const he={EARTH_RADIUS:N,EARTH_CIRCUMFERENCE:se,longitudeToMercatorX:ce,latitudeToMercatorY:le,wgs84ToMercator:de,mercatorXToLongitude:ge,mercatorYToLatitude:me,mercatorToWgs84:ea,haversineDistanceWgs84:B,wrapWgs84:fe,circumferenceAtLatitude:ue,mercatorToTileIndex:pe,wgs84ToTileIndex:ta,toRadians:R,toDegrees:G,haversineIntermediateWgs84:na,haversineCumulatedDistanceWgs84:aa};let z=null;function ye(){return z||(z=new De({maxSize:m.tileCacheSize})),z}async function ve(e){const a=new Blob([e]),t=await createImageBitmap(a),n=document.createElement("canvas"),i=n.getContext("2d");n.width=t.width,n.height=t.height,i.drawImage(t,0,0);const r=i.getImageData(0,0,n.width,n.height);return{pixels:r.data,width:n.width,height:n.height,components:r.data.length/(n.width*n.height)}}function Ae(){if(m.bufferToPixelData)return m.bufferToPixelData;if(typeof window<"u")return ve;throw new Error("An image file buffer to pixel data parser is necessary. Specify it in `config.bufferToPixelData`")}function W(){return!!m.bufferToPixelData||typeof window<"u"}const ia="terrain-rgb-v2",J=50,ra=1e3;let $=null;const Le={403:"Key is missing, invalid or restricted"};async function oa(e,a){e.length>ra&&console.warn("Computing elevation for complex geometries is discouraged - simplify the geometry before proceeding");const t=Math.ceil(e.length/J),n=Array.from({length:t},()=>null).map((r,o)=>{const s=o*J,c=e.slice(s,s+J).map(g=>g.join(",")).join(";"),d=new URL(`elevation/${c}.json`,f.maptilerApiURL);return d.searchParams.set("key",a),u(d.toString())}),i=await Promise.allSettled(n);return(await Promise.all(i.map(async r=>{if(r.status==="rejected")throw new Error(`Some segments could not be fetched, error: ${r.reason}`);if(!r.value.ok)throw new Error(`Some segments could not be fetched, response: ${r.value.status} ${await r.value.text()}, url: ${r.value.url}`);return r.value.json()}))).flat()}async function sa(e,a,t){if(!$){const l=new URL(`tiles/${ia}/tiles.json`,f.maptilerApiURL);l.searchParams.set("key",a);const I=l.toString(),y=await u(I);if(y.ok)$=await y.json();else throw new p(y,Le[y.status]??"")}const n=Ae(),i=$.tiles[0],r=ye(),o=$.maxzoom;let s=~~(t??o);(s>o||s<0)&&(s=o);const c=e.map(l=>he.wgs84ToTileIndex(l,s,!1)),d=c.map(l=>[~~l[0],~~l[1]]).map(l=>`terrain_${s.toString()}_${l[0].toString()}_${l[1].toString()}`),g=Array.from(new Set(d.filter(l=>!r.has(l)))).map(l=>l.split("_").slice(1)),h=g.map(l=>i.replace("{x}",l[1].toString()).replace("{y}",l[2].toString()).replace("{z}",l[0].toString())).map(l=>u(l)),A=(await Promise.allSettled(h)).map(l=>l.status==="fulfilled"?l.value:null).filter(l=>l),T=A.filter(l=>!l.ok);if(A.length!==h.length)throw new Error("Some tiles could not be fetched.");if(T.length)throw new p(T[0],Le[T[0].status]??"");const D=await Promise.all(A.map(l=>l.arrayBuffer()));if(!D.every(l=>l.byteLength>0))throw new Error("Some tiles are not available.");return(await Promise.all(D.map(l=>n(l)))).forEach((l,I)=>{const y=g[I],w=`terrain_${y[0].toString()}_${y[1].toString()}_${y[2].toString()}`;r.set(w,l)}),e.map((l,I)=>{const y=d[I],w=c[I],L=r.get(y),Se=Math.min(Math.round(L.width*(w[0]%1)),L.width-1),C=(Math.min(Math.round(L.height*(w[1]%1)),L.height-1)*L.width+Se)*L.components,Ie=L.pixels[C],Te=L.pixels[C+1],Me=L.pixels[C+2],Re=-1e4+(Ie*256*256+Te*256+Me)*.1;return[l[0],l[1],~~(Re*1e3)/1e3]})}async function ca(e,a={}){return(await b([e],a))[0]}async function b(e,a={}){if(e.length===0)return[];const t=a.apiKey??m.apiKey,n=a.computeOn==="client"?await sa(e,t,a.zoom):await oa(e,t);if(a.smoothingKernelSize){const i=~~(a.smoothingKernelSize/2)*2+1,r=n.map(s=>s[2]),o=~~(i/2);for(let s=o;s<r.length-o-1;s+=1){let c=0;for(let d=0;d<i;d+=1){const g=r[s-o+d];c+=g}c/=i,n[s][2]=c}}return n}async function la(e,a={}){if(e.type!=="LineString")throw new Error("The provided object is not a GeoJSON LineString");a.computeOn??(a.computeOn=W()?"client":"server");const t=structuredClone(e),n=await b(t.coordinates,a);return t.coordinates=n,t}async function da(e,a={}){if(e.type!=="MultiLineString")throw new Error("The provided object is not a GeoJSON MultiLineString");a.computeOn??(a.computeOn=W()?"client":"server");const t=structuredClone(e),n=t.coordinates.map(c=>c.length),i=t.coordinates.flat(),r=await b(i,a),o=[];let s=0;for(const c of n)o.push(r.slice(s,s+c)),s+=c;return t.coordinates=o,t}const ga={at:ca,batch:b,fromLineString:la,fromMultiLineString:da};export{q as ClientConfig,Z as ISOLanguage,v as Language,re as MapStyle,H as MapStyleVariant,Y as NonISOLanguage,V as ReferenceMapStyle,p as ServiceError,Ee as areSameLanguages,ve as bufferToPixelDataBrowser,W as canParsePixelData,ue as circumferenceAtLatitude,m as config,He as coordinates,xe as data,ga as elevation,ie as expandMapStyle,be as geocoding,Ke as geolocation,K as getAutoLanguage,Ae as getBufferToPixelDataParser,M as getLanguageInfoFromCode,E as getLanguageInfoFromFlag,Q as getLanguageInfoFromKey,ye as getTileCache,j as isLanguageInfo,S as mapStylePresetList,he as math,oe as misc,Xe as staticMaps,P as styleToStyle,O as toLanguageInfo};
1
+ import Ee from"quick-lru";function Ue(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class J{constructor(){this._apiKey="",this._fetch=Ue(),this.tileCacheSize=200}set apiKey(a){this._apiKey=a}get apiKey(){return this._apiKey}set fetch(a){this._fetch=a}get fetch(){return this._fetch}}const p=new J,Y={AUTO:{code:null,flag:"auto",name:"Auto",latin:!1,isMode:!0,geocoding:!0},LATIN:{code:"latin",flag:"name:latin",name:"Latin",latin:!0,isMode:!1,geocoding:!1},NON_LATIN:{code:"nonlatin",flag:"name:nonlatin",name:"Non Latin",latin:!1,isMode:!1,geocoding:!1},LOCAL:{code:null,flag:"name",name:"Local",latin:!0,isMode:!1,geocoding:!1}},Q={ALBANIAN:{code:"sq",flag:"name:sq",name:"Albanian",latin:!0,isMode:!1,geocoding:!0},AMHARIC:{code:"am",flag:"name:am",name:"Amharic",latin:!1,isMode:!1,geocoding:!0},ARABIC:{code:"ar",flag:"name:ar",name:"Arabic",latin:!1,isMode:!1,geocoding:!0},ARMENIAN:{code:"hy",flag:"name:hy",name:"Armenian",latin:!1,isMode:!1,geocoding:!0},AZERBAIJANI:{code:"az",flag:"name:az",name:"Azerbaijani",latin:!0,isMode:!1,geocoding:!0},BASQUE:{code:"eu",flag:"name:eu",name:"Basque",latin:!0,isMode:!1,geocoding:!0},BELARUSIAN:{code:"be",flag:"name:be",name:"Belarusian",latin:!1,isMode:!1,geocoding:!0},BENGALI:{code:"bn",flag:"name:bn",name:"Bengali",latin:!0,isMode:!1,geocoding:!0},BOSNIAN:{code:"bs",flag:"name:bs",name:"Bosnian",latin:!0,isMode:!1,geocoding:!0},BRETON:{code:"br",flag:"name:br",name:"Breton",latin:!0,isMode:!1,geocoding:!0},BULGARIAN:{code:"bg",flag:"bg",name:"Bulgarian",latin:!1,isMode:!1,geocoding:!0},CATALAN:{code:"ca",flag:"name:ca",name:"Catalan",latin:!0,isMode:!1,geocoding:!0},CHINESE:{code:"zh",flag:"name:zh",name:"Chinese",latin:!1,isMode:!1,geocoding:!0},TRADITIONAL_CHINESE:{code:"zh-Hant",flag:"name:zh-Hant",name:"Chinese (traditional)",latin:!1,isMode:!1,geocoding:!1},SIMPLIFIED_CHINESE:{code:"zh-Hans",flag:"name:zh-Hans",name:"Chinese (simplified)",latin:!1,isMode:!1,geocoding:!1},CORSICAN:{code:"co",flag:"name:co",name:"Corsican",latin:!0,isMode:!1,geocoding:!0},CROATIAN:{code:"hr",flag:"name:hr",name:"Croatian",latin:!0,isMode:!1,geocoding:!0},CZECH:{code:"cs",flag:"name:cs",name:"Czech",latin:!0,isMode:!1,geocoding:!0},DANISH:{code:"da",flag:"name:da",name:"Danish",latin:!0,isMode:!1,geocoding:!0},DUTCH:{code:"nl",flag:"name:nl",name:"Dutch",latin:!0,isMode:!1,geocoding:!0},GERMAN:{code:"de",flag:"name:de",name:"German",latin:!0,isMode:!1,geocoding:!0},GREEK:{code:"el",flag:"name:el",name:"Greek",latin:!1,isMode:!1,geocoding:!0},ENGLISH:{code:"en",flag:"name:en",name:"English",latin:!0,isMode:!1,geocoding:!0},ESPERANTO:{code:"eo",flag:"name:eo",name:"Esperanto",latin:!0,isMode:!1,geocoding:!0},ESTONIAN:{code:"et",flag:"name:et",name:"Estonian",latin:!0,isMode:!1,geocoding:!0},FINNISH:{code:"fi",flag:"name:fi",name:"Finnish",latin:!0,isMode:!1,geocoding:!0},FRENCH:{code:"fr",flag:"name:fr",name:"French",latin:!0,isMode:!1,geocoding:!0},FRISIAN:{code:"fy",flag:"name:fy",name:"Frisian (West)",latin:!0,isMode:!1,geocoding:!0},GEORGIAN:{code:"ka",flag:"name:ka",name:"Georgian",latin:!1,isMode:!1,geocoding:!0},HEBREW:{code:"he",flag:"name:he",name:"Hebrew",latin:!1,isMode:!1,geocoding:!0},HINDI:{code:"hi",flag:"name:hi",name:"Hindi",latin:!1,isMode:!1,geocoding:!0},HUNGARIAN:{code:"hu",flag:"name:hu",name:"Hungarian",latin:!0,isMode:!1,geocoding:!0},ICELANDIC:{code:"is",flag:"name:is",name:"Icelandic",latin:!0,isMode:!1,geocoding:!0},INDONESIAN:{code:"id",flag:"name:id",name:"Indonesian",latin:!0,isMode:!1,geocoding:!0},IRISH:{code:"ga",flag:"name:ga",name:"Irish",latin:!0,isMode:!1,geocoding:!0},ITALIAN:{code:"it",flag:"name:it",name:"Italian",latin:!0,isMode:!1,geocoding:!0},JAPANESE:{code:"ja",flag:"name:ja",name:"Japanese",latin:!1,isMode:!1,geocoding:!0},JAPANESE_HIRAGANA:{code:"ja-Hira",flag:"name:ja-Hira",name:"Japanese Hiragana form",latin:!1,isMode:!1,geocoding:!1},JAPANESE_2018:{code:"ja-Latn",flag:"name:ja-Latn",name:"Japanese (Latin 2018)",latin:!0,isMode:!1,geocoding:!1},JAPANESE_KANA:{code:"ja_kana",flag:"name:ja_kana",name:"Japanese (Kana)",latin:!1,isMode:!1,geocoding:!1},JAPANESE_LATIN:{code:"ja_rm",flag:"name:ja_rm",name:"Japanese (Latin script)",latin:!0,isMode:!1,geocoding:!1},KANNADA:{code:"kn",flag:"name:kn",name:"Kannada",latin:!0,isMode:!1,geocoding:!0},KAZAKH:{code:"kk",flag:"name:kk",name:"Kazakh",latin:!1,isMode:!1,geocoding:!0},KOREAN:{code:"ko",flag:"name:ko",name:"Korean",latin:!1,isMode:!1,geocoding:!0},KOREAN_LATIN:{code:"ko-Latn",flag:"name:ko-Latn",name:"Korean (Latin script)",latin:!0,isMode:!1,geocoding:!1},KURDISH:{code:"ku",flag:"name:ku",name:"Kurdish",latin:!0,isMode:!1,geocoding:!0},CLASSICAL_LATIN:{code:"la",flag:"name:la",name:"Latin",latin:!0,isMode:!1,geocoding:!0},LATVIAN:{code:"lv",flag:"name:lv",name:"Latvian",latin:!0,isMode:!1,geocoding:!0},LITHUANIAN:{code:"lt",flag:"name:lt",name:"Lithuanian",latin:!0,isMode:!1,geocoding:!0},LUXEMBOURGISH:{code:"lb",flag:"name:lb",name:"Luxembourgish",latin:!0,isMode:!1,geocoding:!0},MACEDONIAN:{code:"mk",flag:"name:mk",name:"Macedonian",latin:!1,isMode:!1,geocoding:!0},MALAYALAM:{code:"ml",flag:"name:ml",name:"Malayalam",latin:!1,isMode:!1,geocoding:!0},MALTESE:{code:"mt",flag:"name:mt",name:"Maltese",latin:!0,isMode:!1,geocoding:!0},NORWEGIAN:{code:"no",flag:"name:no",name:"Norwegian",latin:!0,isMode:!1,geocoding:!0},OCCITAN:{code:"oc",flag:"name:oc",name:"Occitan",latin:!0,isMode:!1,geocoding:!0},PERSIAN:{code:"fa",flag:"name:fa",name:"Persian",latin:!1,isMode:!1,geocoding:!0},POLISH:{code:"pl",flag:"name:pl",name:"Polish",latin:!0,isMode:!1,geocoding:!0},PORTUGUESE:{code:"pt",flag:"name:pt",name:"Portuguese",latin:!0,isMode:!1,geocoding:!0},PUNJABI:{code:"pa",flag:"name:pa",name:"Punjabi",latin:!1,isMode:!1,geocoding:!0},WESTERN_PUNJABI:{code:"pnb",flag:"name:pnb",name:"Western Punjabi",latin:!1,isMode:!1,geocoding:!1},ROMANIAN:{code:"ro",flag:"name:ro",name:"Romanian",latin:!0,isMode:!1,geocoding:!0},ROMANSH:{code:"rm",flag:"name:rm",name:"Romansh",latin:!0,isMode:!1,geocoding:!0},RUSSIAN:{code:"ru",flag:"name:ru",name:"Russian",latin:!1,isMode:!1,geocoding:!0},SERBIAN_CYRILLIC:{code:"sr",flag:"name:sr",name:"Serbian (Cyrillic script)",latin:!1,isMode:!1,geocoding:!0},SERBIAN_LATIN:{code:"sr-Latn",flag:"name:sr-Latn",name:"Serbian (Latin script)",latin:!0,isMode:!1,geocoding:!1},SCOTTISH_GAELIC:{code:"gd",flag:"name:gd",name:"Scottish Gaelic",latin:!0,isMode:!1,geocoding:!0},SLOVAK:{code:"sk",flag:"name:sk",name:"Slovak",latin:!0,isMode:!1,geocoding:!0},SLOVENE:{code:"sl",flag:"name:sl",name:"Slovene",latin:!0,isMode:!1,geocoding:!0},SPANISH:{code:"es",flag:"name:es",name:"Spanish",latin:!0,isMode:!1,geocoding:!0},SWEDISH:{code:"sv",flag:"name:sv",name:"Swedish",latin:!0,isMode:!1,geocoding:!0},TAMIL:{code:"ta",flag:"name:ta",name:"Tamil",latin:!1,isMode:!1,geocoding:!0},TELUGU:{code:"te",flag:"name:te",name:"Telugu",latin:!1,isMode:!1,geocoding:!0},THAI:{code:"th",flag:"name:th",name:"Thai",latin:!1,isMode:!1,geocoding:!0},TURKISH:{code:"tr",flag:"name:tr",name:"Turkish",latin:!0,isMode:!1,geocoding:!0},UKRAINIAN:{code:"uk",flag:"name:uk",name:"Ukrainian",latin:!1,isMode:!1,geocoding:!0},VIETNAMESE:{code:"vi",flag:"name:vi",name:"Vietnamese (Latin script)",latin:!0,isMode:!1,geocoding:!0},WELSH:{code:"cy",flag:"name:cy",name:"Welsh",latin:!0,isMode:!1,geocoding:!0}},y={...Y,...Q};function Z(e,a=y){return e in a?e[e]:null}function S(e,a=y){for(const t of Object.values(a))if(t.code===e)return t;return null}function U(e,a=y){for(const t of Object.values(a))if(t.flag===e)return t;return null}function V(){if(typeof navigator>"u"){const e=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];return S(e)??y.ENGLISH}return Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>S(e)).filter(e=>e)[0]??y.ENGLISH}function O(e){return e!==null&&typeof e=="object"&&"code"in e&&"flag"in e&&"name"in e&&"latin"in e&&"isMode"in e&&"geocoding"in e&&(typeof e.code=="string"||e.code===null)&&typeof e.flag=="string"&&typeof e.name=="string"&&typeof e.latin=="boolean"&&typeof e.isMode=="boolean"&&typeof e.geocoding=="boolean"}function K(e,a=y){return O(e)?U(e.flag,a):typeof e!="string"?null:Z(e,a)||S(e,a)||U(e,a)||null}function ke(e,a,t=y){const n=K(e,t),i=K(a,t);return n&&i&&n.flag===i.flag}async function u(e,a={}){if(p.fetch===null)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(new URL(e).searchParams.get("key").trim()==="")throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return p.fetch(e,a)}const m={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(m);class f extends Error{constructor(a,t=""){super(`Call to enpoint ${a.url} failed with the status code ${a.status}. ${t}`),this.res=a}}const k={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function X(e,a){const{language:t}=a;if(t===void 0)return;const n=(Array.isArray(t)?t:[t]).map(r=>we(r)).filter(r=>r),i=Array.from(new Set(n)).join(",");e.set("language",i)}function we(e){const a=e===y.AUTO.flag?V():typeof e=="string"?S(e):O(e)?e.flag===y.AUTO.flag?V():U(e.flag):null;return a?.geocoding?a.code:null}function ee(e,a){const{apiKey:t,limit:n,types:i,excludeTypes:r}=a;e.set("key",t??p.apiKey),n!==void 0&&e.set("limit",String(n)),i!==void 0&&e.set("types",i.join(",")),r!==void 0&&e.set("excludeTypes",String(r)),X(e,a)}function ae(e,a){ee(e,a);const{bbox:t,proximity:n,country:i,fuzzyMatch:r,autocomplete:o}=a;t!==void 0&&e.set("bbox",t.join(",")),n!==void 0&&e.set("proximity",n==="ip"?n:n.join(",")),i!==void 0&&e.set("country",i.join(",")),r!==void 0&&e.set("fuzzyMatch",r?"true":"false"),o!==void 0&&e.set("autocomplete",o?"true":"false")}async function Pe(e,a={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const t=new URL(`geocoding/${encodeURIComponent(e)}.json`,m.maptilerApiURL);ae(t.searchParams,a);const n=await u(t.toString());if(!n.ok)throw new f(n,k[n.status]??"");return await n.json()}async function be(e,a={}){if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const t=new URL(`geocoding/${e[0]},${e[1]}.json`,m.maptilerApiURL);ee(t.searchParams,a);const n=await u(t.toString());if(!n.ok)throw new f(n,k[n.status]??"");return await n.json()}async function Ne(e,a={}){const t=new URL(`geocoding/${e}.json`,m.maptilerApiURL);t.searchParams.set("key",a.apiKey??p.apiKey),X(t.searchParams,a);const n=await u(t.toString());if(!n.ok)throw new f(n,k[n.status]??"");return await n.json()}async function $e(e,a={}){if(!e.length)return[];const t=e.map(o=>encodeURIComponent(o)).join(";"),n=new URL(`geocoding/${t}.json`,m.maptilerApiURL);ae(n.searchParams,a);const i=await u(n.toString());if(!i.ok)throw new f(i,k[i.status]??"");const r=await i.json();return e.length===1?[r]:r}const Ce={forward:Pe,reverse:be,byId:Ne,batch:$e},te={403:"Key is missing, invalid or restricted"};async function Ve(e={}){const a=new URL("geolocation/ip.json",m.maptilerApiURL);a.searchParams.set("key",e.apiKey??p.apiKey),"elevation"in e&&a.searchParams.set("elevation",e.elevation?"true":"false");const t=a.toString(),n=await u(t);if(!n.ok)throw new f(n,n.status in te?te[n.status]:"");return await n.json()}const Oe={info:Ve},w={403:"Key is missing, invalid or restricted"};async function Ke(e,a={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const t=new URL(`coordinates/search/${e}.json`,m.maptilerApiURL);t.searchParams.set("key",a.apiKey??p.apiKey),"limit"in a&&t.searchParams.set("limit",a.limit.toString()),"transformations"in a&&t.searchParams.set("transformations",a.transformations.toString()),"exports"in a&&t.searchParams.set("exports",a.exports.toString());const n=t.toString(),i=await u(n);if(!i.ok)throw new f(i,i.status in w?w[i.status]:"");return await i.json()}async function _e(e,a={}){const t=(Array.isArray(e[0])?e:[e]).map(o=>`${o[0]},${o[1]}`).join(";"),n=new URL(`coordinates/transform/${t}.json`,m.maptilerApiURL);n.searchParams.set("key",a.apiKey??p.apiKey),"sourceCrs"in a&&n.searchParams.set("s_srs",a.sourceCrs.toString()),"targetCrs"in a&&n.searchParams.set("t_srs",a.targetCrs.toString()),"operations"in a&&n.searchParams.set("ops",(Array.isArray(a.operations)?a.operations:[a.operations]).join("|"));const i=n.toString(),r=await u(i);if(!r.ok)throw new f(r,r.status in w?w[r.status]:"");return await r.json()}const je={search:Ke,transform:_e},ne={403:"Key is missing, invalid or restricted"};async function He(e,a={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The data ID must be a non-empty string");const t=new URL(`data/${encodeURIComponent(e)}/features.json`,m.maptilerApiURL);t.searchParams.set("key",a.apiKey??p.apiKey);const n=t.toString(),i=await u(n);if(!i.ok)throw new f(i,i.status in ne?ne[i.status]:"");return await i.json()}const Fe={get:He};function ie(e){const a=/^maptiler:\/\/(.*)/;let t;const n=e.trim();let i;return n.startsWith("http://")||n.startsWith("https://")?i=n:(t=a.exec(n))!==null?i=`https://api.maptiler.com/maps/${t[1]}/style.json`:i=`https://api.maptiler.com/maps/${n}/style.json`,i}class _{constructor(a,t,n,i,r,o,s=!1,d){this.name=a,this.variantType=t,this.id=n,this.referenceStyle=i,this.description=r,this.imageURL=o,this.deprecated=s,this.deprecationMessage=d}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(a){return this.referenceStyle.hasVariant(a)}getVariant(a){const t=this.referenceStyle.getVariant(a);return this.warnIfDeprecated(t),t}getVariants(){return this.referenceStyle.getVariants().filter(a=>a!==this).map(a=>(this.warnIfDeprecated(a),a))}getImageURL(){return this.imageURL}getExpandedStyleURL(){return ie(this.getId())}warnIfDeprecated(a=this){if(!a.deprecated)return a;if(a.deprecationMessage)console.warn(a.deprecationMessage);else{const t=a.getFullName();console.warn(`Style "${t}" is deprecated and will be removed in a future version.`)}return a}}class j{constructor(a,t){this.name=a,this.id=t,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(a){this.variants[a.getType()]=a,this.orderedVariants.push(a)}hasVariant(a){return a in this.variants}getVariant(a){return a in this.variants?this.variants[a]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0].warnIfDeprecated()}}const xe=[{referenceStyleID:"STREETS_V2",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default v2",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2" is deprecated, use "streets-v4" instead'},{id:"streets-v2-dark",name:"Dark v2",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-dark" is deprecated, use "streets-v4-dark" instead'},{id:"streets-v2-light",name:"Light v2",variantType:"LIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-light" is deprecated, use "streets-v4-light" instead'},{id:"streets-v2-night",name:"Night v2",variantType:"NIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-night" is deprecated, use "streets-v4-night" instead'},{id:"streets-v2-pastel",name:"Pastel v2",variantType:"PASTEL",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-pastel" is deprecated, use "streets-v4-pastel" instead'}]},{referenceStyleID:"STREETS_V4",name:"Streets",description:"",variants:[{id:"streets-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v4-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"BASE_V4",name:"Base",description:"",variants:[{id:"base-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"base-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"base-v4-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"base-v4-ai",name:"Base AI",variantType:"AI",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"outdoor-v2" is deprecated, use "outdoor-v4" instead'},{id:"outdoor-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"outdoor-v2-dark" is deprecated, use "outdoor-v4-dark" instead'}]},{referenceStyleID:"WINTER_V2",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"WINTER_V4",name:"Winter",description:"",variants:[{id:"winter-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE_V2",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"satellite" is deprecated, use "satellite-v4" instead'}]},{referenceStyleID:"HYBRID_V2",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID_V4",name:"Hybrid",description:"",variants:[{id:"hybrid-v4",name:"Default",variantType:"DEFAULT",imageURL:""},{id:"hybrid-v4-dark",name:"Dark",variantType:"DARK",imageURL:""}]},{referenceStyleID:"BASIC_V2",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"basic-v2" is deprecated, use "base-v4" instead'},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecationMessage:'"basic-v2" is deprecated, use "base-v4" instead'},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"basic-v2" is deprecated, use "base-v4" instead'}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP_V2",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"openstreetmap-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"TOPO_V2",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"topo-v2" is deprecated, use "topo-v4" instead'},{id:"topo-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"topo-v2-dark" is deprecated, use "topo-v4-dark" instead'},{id:"topo-v2-shiny",name:"Shiny",variantType:"SHINY",description:"",imageURL:"",deprecated:!0},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"topo-v2-pastel" is deprecated, use "topo-v4-pastel" instead'},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"topo-v2-topographique" is deprecated, use "topo-v4-topographique" instead'}]},{referenceStyleID:"VOYAGER_V2",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",deprecated:!0,variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",deprecated:!0,variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",deprecated:!0,variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",deprecated:!0,variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER_V2",name:"Toner",description:"",deprecated:!0,deprecationMessage:'"toner-v2" is deprecated, and will be no longer be a default style in the future',variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"toner-v2" is deprecated, and may be removed in future versions.'},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",deprecated:!0,description:"",imageURL:"",deprecationMessage:'"toner-v2-background" is deprecated, and may be removed in future versions.'},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"toner-v2-lite" is deprecated, and may be removed in future versions.'},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"toner-v2-lines" is deprecated, and may be removed in future versions.'}]},{referenceStyleID:"DATAVIZ_V2",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"dataviz" is deprecated, use "dataviz-v4" instead'},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"dataviz-dark" is deprecated, use "dataviz-v4-dark" instead'},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"dataviz-light" is deprecated, use "dataviz-v4-light" instead'}]},{referenceStyleID:"BACKDROP_V2",name:"Backdrop",description:"",variants:[{id:"backdrop",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"backdrop" is deprecated, use "backdrop-v4" instead'},{id:"backdrop-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"backdrop-dark" is deprecated, use "backdrop-v4-dark" instead'},{id:"backdrop-light",name:"Light",variantType:"LIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"backdrop-light" is deprecated, use "backdrop-v4-light" instead'}]},{referenceStyleID:"OCEAN_V2",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"ocean" is deprecated, use "ocean-v4" instead'}]},{referenceStyleID:"AQUARELLE_V2",name:"Aquarelle",description:"Watercolor map for creative use",variants:[{id:"aquarelle",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"aquarelle" is deprecated, use "aquarelle-v4" instead'},{id:"aquarelle-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"aquarelle-dark" is deprecated, use "aquarelle-v4-dark" instead'},{id:"aquarelle-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"aquarelle-vivid" is deprecated, use "aquarelle-v4-vivid" instead'}]},{referenceStyleID:"LANDSCAPE_V2",name:"Landscape",description:"Terrain map for data overlays and visualisations",variants:[{id:"landscape",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape" is deprecated, use "landscape-v4" instead'},{id:"landscape-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape-dark" is deprecated, use "landscape-v4-dark" instead'},{id:"landscape-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape-vivid" is deprecated, use "landscape-v4-vivid" instead'}]},{referenceStyleID:"LANDSCAPE_V4",name:"Landscape",description:"Terrain map for data overlays and visualisations",variants:[{id:"landscape-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"landscape-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"landscape-v4-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE_V4",name:"Satellite v4",description:"",variants:[{id:"satellite-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"satellite-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ_V4",name:"Dataviz",description:"",variants:[{id:"dataviz-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-v4-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR_V4",name:"Outdoor",description:"",variants:[{id:"outdoor-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"outdoor-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"BACKDROP_V4",name:"Backdrop",description:"",variants:[{id:"backdrop-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"backdrop-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"backdrop-v4-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"AQUARELLE_V4",name:"Aquarelle",description:"Watercolor map for creative use",variants:[{id:"aquarelle-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"aquarelle-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"aquarelle-v4-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]},{referenceStyleID:"OCEAN_V4",name:"Ocean",description:"",variants:[{id:"ocean-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"ocean-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"TOPO_V4",name:"Topo",description:"",variants:[{id:"topo-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"topo-v4-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v4-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]}],Be={STREETS:"STREETS_V2",BASIC:"BASIC_V2",LANDSCAPE:"LANDSCAPE_V2",AQUARELLE:"AQUARELLE_V2",SATELLITE:"SATELLITE_V2",WINTER:"WINTER_V2",HYBRID:"HYBRID_V2",OCEAN:"OCEAN_V2",TONER:"TONER_V2",TOPO:"TOPO_V2",OPENSTREETMAP:"OPENSTREETMAP_V2",DATAVIZ:"DATAVIZ_V2",BACKDROP:"BACKDROP_V2",VOYAGER:"VOYAGER_V2"},T=[...xe];function Ge(e,a){T.find(i=>i.referenceStyleID===e)&&console.warn(`Default reference style ${e} already exists, it will be overwritten...`);const t=T.find(i=>i.referenceStyleID===a);if(!t)throw new Error(`Versioned map style not found for reference style: ${a}`);const n={...t,referenceStyleID:e};T.push(n)}Object.entries(Be).forEach(([e,a])=>{Ge(e,a)});function ze(e){return new Proxy(e,{get(a,t,n){return a.hasVariant(t)?a.getVariant(t):t.toString().toUpperCase()===t?e.getDefaultVariant():Reflect.get(a,t,n)}})}function We(){const e={};for(let a=0;a<T.length;a+=1){const t=T[a],n=ze(new j(t.name,t.referenceStyleID));for(let i=0;i<t.variants.length;i+=1){const r=t.variants[i],o=new _(r.name,r.variantType,r.id,n,r.description,r.imageURL,r.deprecated);n.addVariant(o)}e[t.referenceStyleID]=n}return e}function P(e){if(!e)return re[T[0].referenceStyleID].getDefaultVariant().getId();if(typeof e=="string"||e instanceof String)return e.trim().toLowerCase();if(e instanceof _)return e.getId();if(e instanceof j)return e.getDefaultVariant().getId()}const re=We();function qe(e){const a=[];function t(r){(r.type==="LineString"||r.type==="MultiLineString")&&a.push(r)}function n(r){r.geometry&&t(r.geometry)}function i(r){for(const o of r.features)o.type==="Feature"?n(o):o.type==="FeatureCollection"&&i(o)}return e.type==="Feature"?n(e):e.type==="FeatureCollection"?i(e):t(e),a}function Je(e,a,t){let n=a[0],i=a[1],r=t[0]-n,o=t[1]-i;if(r!==0||o!==0){const s=((e[0]-n)*r+(e[1]-i)*o)/(r*r+o*o);s>1?(n=t[0],i=t[1]):s>0&&(n+=r*s,i+=o*s)}return r=e[0]-n,o=e[1]-i,r*r+o*o}function H(e,a,t,n,i){let r=n,o;for(let s=a+1;s<t;s++){const d=Je(e[s],e[a],e[t]);d>r&&(o=s,r=d)}r>n&&(o-a>1&&H(e,a,o,n,i),i.push(e[o]),t-o>1&&H(e,o,t,n,i))}function Ye(e,a){const t=e.length-1,n=[e[0]];return H(e,0,t,a,n),n.push(e[t]),n}function Qe(e,a){if(e.length<=2)return e;const t=a!==void 0?a*a:1;return Ye(e,t)}const oe={extractLineStrings:qe,simplify:Qe};function F(e,a=!0){let t=`${e[0]},${e[1]}`;return e.length===3&&a&&(t+=`,${e[2]}`),t}function x(e,a=3e3){let t=e.map(r=>r.join(",")).join("|"),n=5e-6;const i=1e-5;for(;t.length>a;)t=oe.simplify(e,n).map(r=>`${r[0]},${r[1]}`).join("|"),n+=i;return t}function Ze(e,a,t={}){const n=P(t.style),i=t.hiDPI?"@2x":"",r=t.format??"png";let o=~~(t.width??1024),s=~~(t.height??1024);t.hiDPI&&(o=~~(o/2),s=~~(s/2));const d=new URL(`maps/${encodeURIComponent(n)}/static/${e[0]},${e[1]},${a}/${o}x${s}${i}.${r}`,m.maptilerApiURL);if("attribution"in t&&d.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let l="";const g="markerIcon"in t;g&&(l+=`icon:${t.markerIcon}|`),g&&"markerAnchor"in t&&(l+=`anchor:${t.markerAnchor}|`),g&&t.hiDPI&&(l+="scale:2|");const h=Array.isArray(t.markers[0])?t.markers:[t.markers];l+=h.map(A=>F(A,!g)).join("|"),d.searchParams.set("markers",l)}if("path"in t){let l="";if(l+=`fill:${t.pathFillColor??"none"}|`,"pathStrokeColor"in t&&(l+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const g=t.pathWidth/(t.hiDPI?2:1);l+=`width:${g.toString()}|`}l+=x(t.path),d.searchParams.set("path",l)}return d.searchParams.set("key",t.apiKey??p.apiKey),d.toString()}function Xe(e,a={}){const t=P(a.style),n=a.hiDPI?"@2x":"",i=a.format??"png";let r=~~(a.width??1024),o=~~(a.height??1024);a.hiDPI&&(r=~~(r/2),o=~~(o/2));const s=new URL(`maps/${encodeURIComponent(t)}/static/${e[0]},${e[1]},${e[2]},${e[3]}/${r}x${o}${n}.${i}`,m.maptilerApiURL);if("attribution"in a&&s.searchParams.set("attribution",a.attribution.toString()),"padding"in a&&s.searchParams.set("padding",a.padding.toString()),"markers"in a){let d="";const l="markerIcon"in a;l&&(d+=`icon:${a.markerIcon}|`),l&&"markerAnchor"in a&&(d+=`anchor:${a.markerAnchor}|`),l&&a.hiDPI&&(d+="scale:2|");const g=Array.isArray(a.markers[0])?a.markers:[a.markers];d+=g.map(h=>F(h,!l)).join("|"),s.searchParams.set("markers",d)}if("path"in a){let d="";if(d+=`fill:${a.pathFillColor??"none"}|`,"pathStrokeColor"in a&&(d+=`stroke:${a.pathStrokeColor}|`),"pathWidth"in a){const l=a.pathWidth/(a.hiDPI?2:1);d+=`width:${l.toString()}|`}d+=x(a.path),s.searchParams.set("path",d)}return s.searchParams.set("key",a.apiKey??p.apiKey),s.toString()}function ea(e={}){if(!("markers"in e)&&!("path"in e))throw new Error("Automatic static maps require markers and/or path to be created.");const a=P(e.style),t=e.hiDPI?"@2x":"",n=e.format??"png";let i=~~(e.width??1024),r=~~(e.height??1024);e.hiDPI&&(i=~~(i/2),r=~~(r/2));const o=new URL(`maps/${encodeURIComponent(a)}/static/auto/${i}x${r}${t}.${n}`,m.maptilerApiURL);if("attribution"in e&&o.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&o.searchParams.set("padding",e.padding.toString()),"markers"in e){let s="";const d="markerIcon"in e;d&&(s+=`icon:${e.markerIcon}|`),d&&"markerAnchor"in e&&(s+=`anchor:${e.markerAnchor}|`),d&&e.hiDPI&&(s+="scale:2|");const l=Array.isArray(e.markers[0])?e.markers:[e.markers];s+=l.map(g=>F(g,!d)).join("|"),o.searchParams.set("markers",s)}if("path"in e){let s="";if(s+=`fill:${e.pathFillColor??"none"}|`,"pathStrokeColor"in e&&(s+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const d=e.pathWidth/(e.hiDPI?2:1);s+=`width:${d.toString()}|`}s+=x(e.path),o.searchParams.set("path",s)}return o.searchParams.set("key",e.apiKey??p.apiKey),o.toString()}const aa={centered:Ze,bounded:Xe,automatic:ea},b=63710088e-1,se=2*Math.PI*b,de=85.0511287;function ce(e){return(180+e)/360}function le(e){return e=Math.max(Math.min(e,de),-de),(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function ge(e){const a=ue(e);return[ce(a[0]),le(a[1])]}function pe(e){return e*360-180}function me(e){const a=180-e*360;return 360/Math.PI*Math.atan(Math.exp(a*Math.PI/180))-90}function ta(e){return[pe(e[0]),me(e[1])]}function B(e,a){const t=Math.PI/180,n=e[1]*t,i=a[1]*t,r=Math.sin(n)*Math.sin(i)+Math.cos(n)*Math.cos(i)*Math.cos((a[0]-e[0])*t);return b*Math.acos(Math.min(r,1))}function na(e){const a=Array(e.length);a[0]=0;const t=a.length;for(let n=1;n<t;n++)a[n]=B(e[n-1],e[n])+a[n-1];return a}function ue(e){const a=e[0],t=e[1],n=360,i=((a+180)%n+n)%n-180;return[i===-180?180:i,t]}function fe(e){return se*Math.cos(e*Math.PI/180)}function he(e,a,t=!0){const n=2**a,i=[e[0]*n,e[1]*n];return t?[~~i[0],~~i[1]]:i}function ia(e,a,t=!0){const n=ge(e);return he(n,a,t)}function D(e){return e*Math.PI/180}function G(e){return e*180/Math.PI}function ra(e,a,t){const n=B(e,a),i=D(e[0]),r=D(e[1]),o=D(a[0]),s=D(a[1]),d=n/b,l=Math.sin((1-t)*d)/Math.sin(d),g=Math.sin(t*d)/Math.sin(d),h=l*Math.cos(r)*Math.cos(i)+g*Math.cos(s)*Math.cos(o),A=l*Math.cos(r)*Math.sin(i)+g*Math.cos(s)*Math.sin(o),R=l*Math.sin(r)+g*Math.sin(s),M=Math.atan2(R,Math.sqrt(h*h+A*A)),c=Math.atan2(A,h);return[G(c),G(M)]}const ve={EARTH_RADIUS:b,EARTH_CIRCUMFERENCE:se,longitudeToMercatorX:ce,latitudeToMercatorY:le,wgs84ToMercator:ge,mercatorXToLongitude:pe,mercatorYToLatitude:me,mercatorToWgs84:ta,haversineDistanceWgs84:B,wrapWgs84:ue,circumferenceAtLatitude:fe,mercatorToTileIndex:he,wgs84ToTileIndex:ia,toRadians:D,toDegrees:G,haversineIntermediateWgs84:ra,haversineCumulatedDistanceWgs84:na};let z=null;function ye(){return z||(z=new Ee({maxSize:p.tileCacheSize})),z}async function Ae(e){const a=new Blob([e]),t=await createImageBitmap(a),n=document.createElement("canvas"),i=n.getContext("2d");n.width=t.width,n.height=t.height,i.drawImage(t,0,0);const r=i.getImageData(0,0,n.width,n.height);return{pixels:r.data,width:n.width,height:n.height,components:r.data.length/(n.width*n.height)}}function Le(){if(p.bufferToPixelData)return p.bufferToPixelData;if(typeof window<"u")return Ae;throw new Error("An image file buffer to pixel data parser is necessary. Specify it in `config.bufferToPixelData`")}function W(){return!!p.bufferToPixelData||typeof window<"u"}const oa="terrain-rgb-v2",q=50,sa=1e3;let N=null;const Te={403:"Key is missing, invalid or restricted"};async function da(e,a){e.length>sa&&console.warn("Computing elevation for complex geometries is discouraged - simplify the geometry before proceeding");const t=Math.ceil(e.length/q),n=Array.from({length:t},()=>null).map((r,o)=>{const s=o*q,d=e.slice(s,s+q).map(g=>g.join(",")).join(";"),l=new URL(`elevation/${d}.json`,m.maptilerApiURL);return l.searchParams.set("key",a),u(l.toString())}),i=await Promise.allSettled(n);return(await Promise.all(i.map(async r=>{if(r.status==="rejected")throw new Error(`Some segments could not be fetched, error: ${r.reason}`);if(!r.value.ok)throw new Error(`Some segments could not be fetched, response: ${r.value.status} ${await r.value.text()}, url: ${r.value.url}`);return r.value.json()}))).flat()}async function ca(e,a,t){if(!N){const c=new URL(`tiles/${oa}/tiles.json`,m.maptilerApiURL);c.searchParams.set("key",a);const I=c.toString(),v=await u(I);if(v.ok)N=await v.json();else throw new f(v,Te[v.status]??"")}const n=Le(),i=N.tiles[0],r=ye(),o=N.maxzoom;let s=~~(t??o);(s>o||s<0)&&(s=o);const d=e.map(c=>ve.wgs84ToTileIndex(c,s,!1)),l=d.map(c=>[~~c[0],~~c[1]]).map(c=>`terrain_${s.toString()}_${c[0].toString()}_${c[1].toString()}`),g=Array.from(new Set(l.filter(c=>!r.has(c)))).map(c=>c.split("_").slice(1)),h=g.map(c=>i.replace("{x}",c[1].toString()).replace("{y}",c[2].toString()).replace("{z}",c[0].toString())).map(c=>u(c)),A=(await Promise.allSettled(h)).map(c=>c.status==="fulfilled"?c.value:null).filter(c=>c),R=A.filter(c=>!c.ok);if(A.length!==h.length)throw new Error("Some tiles could not be fetched.");if(R.length)throw new f(R[0],Te[R[0].status]??"");const M=await Promise.all(A.map(c=>c.arrayBuffer()));if(!M.every(c=>c.byteLength>0))throw new Error("Some tiles are not available.");return(await Promise.all(M.map(c=>n(c)))).forEach((c,I)=>{const v=g[I],E=`terrain_${v[0].toString()}_${v[1].toString()}_${v[2].toString()}`;r.set(E,c)}),e.map((c,I)=>{const v=l[I],E=d[I],L=r.get(v),Ie=Math.min(Math.round(L.width*(E[0]%1)),L.width-1),C=(Math.min(Math.round(L.height*(E[1]%1)),L.height-1)*L.width+Ie)*L.components,Re=L.pixels[C],Se=L.pixels[C+1],De=L.pixels[C+2],Me=-1e4+(Re*256*256+Se*256+De)*.1;return[c[0],c[1],~~(Me*1e3)/1e3]})}async function la(e,a={}){return(await $([e],a))[0]}async function $(e,a={}){if(e.length===0)return[];const t=a.apiKey??p.apiKey,n=a.computeOn==="client"?await ca(e,t,a.zoom):await da(e,t);if(a.smoothingKernelSize){const i=~~(a.smoothingKernelSize/2)*2+1,r=n.map(s=>s[2]),o=~~(i/2);for(let s=o;s<r.length-o-1;s+=1){let d=0;for(let l=0;l<i;l+=1){const g=r[s-o+l];d+=g}d/=i,n[s][2]=d}}return n}async function ga(e,a={}){if(e.type!=="LineString")throw new Error("The provided object is not a GeoJSON LineString");a.computeOn??(a.computeOn=W()?"client":"server");const t=structuredClone(e),n=await $(t.coordinates,a);return t.coordinates=n,t}async function pa(e,a={}){if(e.type!=="MultiLineString")throw new Error("The provided object is not a GeoJSON MultiLineString");a.computeOn??(a.computeOn=W()?"client":"server");const t=structuredClone(e),n=t.coordinates.map(d=>d.length),i=t.coordinates.flat(),r=await $(i,a),o=[];let s=0;for(const d of n)o.push(r.slice(s,s+d)),s+=d;return t.coordinates=o,t}const ma={at:la,batch:$,fromLineString:ga,fromMultiLineString:pa};export{J as ClientConfig,Q as ISOLanguage,y as Language,re as MapStyle,_ as MapStyleVariant,Y as NonISOLanguage,j as ReferenceMapStyle,f as ServiceError,ke as areSameLanguages,Ae as bufferToPixelDataBrowser,W as canParsePixelData,fe as circumferenceAtLatitude,p as config,je as coordinates,Fe as data,ma as elevation,ie as expandMapStyle,Ce as geocoding,Oe as geolocation,V as getAutoLanguage,Le as getBufferToPixelDataParser,S as getLanguageInfoFromCode,U as getLanguageInfoFromFlag,Z as getLanguageInfoFromKey,ye as getTileCache,O as isLanguageInfo,T as mapStylePresetList,ve as math,oe as misc,aa as staticMaps,P as styleToStyle,K as toLanguageInfo};