@maptiler/client 1.4.0 → 1.6.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.
Files changed (71) hide show
  1. package/dist/maptiler-client.cjs +28 -0
  2. package/dist/maptiler-client.cjs.map +1 -1
  3. package/dist/maptiler-client.d.ts +81 -9
  4. package/dist/maptiler-client.min.mjs +1 -1
  5. package/dist/maptiler-client.mjs +28 -0
  6. package/dist/maptiler-client.mjs.map +1 -1
  7. package/dist/maptiler-client.umd.js +28 -0
  8. package/dist/maptiler-client.umd.js.map +1 -1
  9. package/dist/maptiler-client.umd.min.js +1 -1
  10. package/docs/assets/search.js +1 -1
  11. package/docs/classes/config.ClientConfig.html +9 -9
  12. package/docs/classes/services_ServiceError.ServiceError.html +7 -7
  13. package/docs/functions/language.getAutoLanguageGeocoding.html +5 -5
  14. package/docs/functions/services_simplify.default.html +5 -5
  15. package/docs/index.html +16 -10
  16. package/docs/modules/config.html +5 -5
  17. package/docs/modules/language.html +5 -5
  18. package/docs/modules/services_ServiceError.html +5 -5
  19. package/docs/modules/services_coordinates.html +5 -5
  20. package/docs/modules/services_data.html +5 -5
  21. package/docs/modules/services_geocoding.html +5 -5
  22. package/docs/modules/services_geolocation.html +5 -5
  23. package/docs/modules/services_simplify.html +5 -5
  24. package/docs/modules/services_staticMaps.html +5 -5
  25. package/docs/modules.html +4 -4
  26. package/docs/types/config.FetchFunction.html +5 -5
  27. package/docs/types/language.LanguageGeocodingString.html +5 -5
  28. package/docs/types/services_coordinates.CoordinateExport.html +5 -5
  29. package/docs/types/services_coordinates.CoordinateGrid.html +5 -5
  30. package/docs/types/services_coordinates.CoordinateId.html +5 -5
  31. package/docs/types/services_coordinates.CoordinateSearch.html +5 -5
  32. package/docs/types/services_coordinates.CoordinateSearchResult.html +5 -5
  33. package/docs/types/services_coordinates.CoordinateTransformResult.html +5 -5
  34. package/docs/types/services_coordinates.CoordinateTransformation.html +5 -5
  35. package/docs/types/services_coordinates.CoordinatesSearchOptions.html +5 -5
  36. package/docs/types/services_coordinates.CoordinatesTransformOptions.html +5 -5
  37. package/docs/types/services_coordinates.XYZ.html +5 -5
  38. package/docs/types/services_data.GetDataOptions.html +5 -5
  39. package/docs/types/services_geocoding.ByIdGeocodingOptions.html +5 -5
  40. package/docs/types/services_geocoding.CommonForwardAndReverseGeocodingOptions.html +6 -6
  41. package/docs/types/services_geocoding.Coordinates.html +5 -5
  42. package/docs/types/services_geocoding.FeatureHierarchy.html +6 -17
  43. package/docs/types/services_geocoding.GeocodingFeature.html +6 -6
  44. package/docs/types/services_geocoding.GeocodingOptions.html +5 -5
  45. package/docs/types/services_geocoding.GeocodingSearchResult.html +5 -5
  46. package/docs/types/services_geocoding.LanguageGeocodingOptions.html +5 -5
  47. package/docs/types/services_geocoding.ReverseGeocodingOptions.html +5 -5
  48. package/docs/types/services_geolocation.GeolocationInfoOptions.html +5 -5
  49. package/docs/types/services_geolocation.GeolocationResult.html +5 -5
  50. package/docs/types/services_staticMaps.AutomaticStaticMapOptions.html +5 -5
  51. package/docs/types/services_staticMaps.BoundedStaticMapOptions.html +5 -5
  52. package/docs/types/services_staticMaps.CenteredStaticMapOptions.html +5 -5
  53. package/docs/types/services_staticMaps.StaticMapBaseOptions.html +5 -5
  54. package/docs/types/services_staticMaps.StaticMapMarker.html +5 -5
  55. package/docs/variables/config.config.html +5 -5
  56. package/docs/variables/language.LanguageGeocoding.html +5 -5
  57. package/docs/variables/services_coordinates.coordinates.html +5 -5
  58. package/docs/variables/services_data.data.html +5 -5
  59. package/docs/variables/services_geocoding.geocoding.html +5 -5
  60. package/docs/variables/services_geolocation.geolocation.html +5 -5
  61. package/docs/variables/services_staticMaps.staticMaps.html +5 -5
  62. package/docsmd/README.md +46 -52
  63. package/docsmd/classes/ClientConfig.md +5 -5
  64. package/docsmd/classes/MapStyleVariant.md +13 -13
  65. package/docsmd/classes/ReferenceMapStyle.md +9 -9
  66. package/docsmd/classes/ServiceError.md +3 -3
  67. package/examples/test-node.js +9 -9
  68. package/package.json +1 -1
  69. package/readme.md +8 -4
  70. package/src/mapstyle.ts +49 -0
  71. package/src/services/geocoding.ts +96 -18
@@ -1,4 +1,4 @@
1
- import { BBox, Position, Feature, FeatureCollection } from 'geojson';
1
+ import { BBox, Position, Feature, Geometry, FeatureCollection } from 'geojson';
2
2
  export { BBox, Position } from 'geojson';
3
3
 
4
4
  type FetchFunction = (url: string, options: object) => Promise<any>;
@@ -121,7 +121,7 @@ type CommonForwardAndReverseGeocodingOptions = LanguageGeocodingOptions & {
121
121
  /**
122
122
  * Filter of feature types to return. If not specified, all available feature types are returned.
123
123
  */
124
- types?: ("country" | "region" | "subregion" | "county" | "joint_municipality" | "joint_submunicipality" | "municipality" | "municipal_district" | "locality" | "neighbourhood" | "place" | "postal_code" | "address")[];
124
+ types?: ("country" | "region" | "subregion" | "county" | "joint_municipality" | "joint_submunicipality" | "municipality" | "municipal_district" | "locality" | "neighbourhood" | "place" | "postal_code" | "address" | "poi")[];
125
125
  };
126
126
  type GeocodingOptions = CommonForwardAndReverseGeocodingOptions & {
127
127
  /**
@@ -149,7 +149,33 @@ type GeocodingOptions = CommonForwardAndReverseGeocodingOptions & {
149
149
  type ReverseGeocodingOptions = CommonForwardAndReverseGeocodingOptions;
150
150
  type ByIdGeocodingOptions = LanguageGeocodingOptions;
151
151
  type Coordinates = Position;
152
- type FeatureHierarchy = {
152
+ type FeatureProperties = {
153
+ /**
154
+ * External reference of the feature used for debugging purposes
155
+ */
156
+ ref: string;
157
+ /**
158
+ * ISO 3166-1 alpha-2 country code of the feature
159
+ */
160
+ country_code: string;
161
+ /**
162
+ * (experimental) Kind of the feature
163
+ */
164
+ kind?: "road" | "road_relation" | "admin_area" | "place" | "street" | "virtual_street";
165
+ /**
166
+ * (experimental) Value of place=* tag from OpenStreetMap feature if kind=place
167
+ */
168
+ "osm:place_type"?: string;
169
+ /**
170
+ * (experimental) Feature tags from OpenStreetMap. Only available for `poi` type.
171
+ */
172
+ "osm:tags"?: Record<string, string>;
173
+ /**
174
+ * Array of POI categories. Only available for `poi` type.
175
+ */
176
+ categories?: string[];
177
+ };
178
+ type FeatureBase = {
153
179
  /**
154
180
  * Unique feature ID
155
181
  */
@@ -158,8 +184,23 @@ type FeatureHierarchy = {
158
184
  * Localized feature name
159
185
  */
160
186
  text: string;
187
+ /**
188
+ * Query's primary ISO 639-1 language code
189
+ */
190
+ language?: string;
191
+ /**
192
+ * A string analogous to the `text` field that matches the query in the requested language.
193
+ * This field is only returned when multiple languages are requested using the `language` parameter, and will be present for each requested language.
194
+ */
195
+ [text: `text_${string}`]: string;
196
+ /**
197
+ * A ISO 639-1 query's fallback language code.
198
+ * This field is only returned when multiple languages are requested using the `language` parameter, and will be present for each requested language.
199
+ */
200
+ [language: `language_${string}`]: string;
161
201
  };
162
- type GeocodingFeature = Feature & {
202
+ type FeatureHierarchy = FeatureProperties & FeatureBase;
203
+ type GeocodingFeature = Feature<Geometry, FeatureProperties> & FeatureBase & {
163
204
  /**
164
205
  * Bounding box of the original feature as [w, s, e, n] array
165
206
  */
@@ -173,9 +214,19 @@ type GeocodingFeature = Feature & {
173
214
  */
174
215
  place_name: string;
175
216
  /**
176
- * Localized feature name
217
+ * A string analogous to the `place_name` field that matches the query in the requested language.
218
+ * This field is only returned when multiple languages are requested using the `language` parameter, and will be present for each requested language.
177
219
  */
178
- text: string;
220
+ [key: `place_name_${string}`]: string;
221
+ /**
222
+ * An array of feature types describing the feature.
223
+ * Currently each feature has only single type but this may change in the future.
224
+ */
225
+ place_type: string[];
226
+ /**
227
+ * Localized type of the place name, matches `place_type` property
228
+ */
229
+ place_type_name: string[];
179
230
  /**
180
231
  * Feature hierarchy
181
232
  */
@@ -184,6 +235,12 @@ type GeocodingFeature = Feature & {
184
235
  * Address number, if applicable
185
236
  */
186
237
  address?: string;
238
+ /**
239
+ * Indicates how well the returned feature matches the user's query on a scale from 0 to 1.
240
+ * 0 means the result does not match the query text at all, while 1 means the result fully matches the query text.
241
+ * You can use the relevance property to remove results that don't fully match the query.
242
+ */
243
+ relevance: number;
187
244
  };
188
245
  type GeocodingSearchResult = {
189
246
  type: "FeatureCollection";
@@ -288,9 +345,7 @@ declare const geocoding: {
288
345
  LUXEMBOURGISH: string;
289
346
  MACEDONIAN: string;
290
347
  MALTESE: string;
291
- NORWEGIAN: string; /**
292
- * Maximum number of results to show. Must be between 1 and 10. Default is 5 for forward and 1 for reverse geocoding.
293
- */
348
+ NORWEGIAN: string;
294
349
  POLISH: string;
295
350
  PORTUGUESE: string;
296
351
  ROMANIAN: string;
@@ -966,6 +1021,23 @@ type MapStyleType = {
966
1021
  */
967
1022
  DEFAULT: MapStyleVariant;
968
1023
  };
1024
+ /**
1025
+ * Neutral greyscale style with hillshading suitable for colorful terrain-aware visualization
1026
+ */
1027
+ BACKDROP: ReferenceMapStyle & {
1028
+ /**
1029
+ * Neutral greyscale style with hillshading suitable for colorful terrain-aware visualization
1030
+ */
1031
+ DEFAULT: MapStyleVariant;
1032
+ /**
1033
+ * Dark greyscale style with hillshading suitable for colorful terrain-aware visualization
1034
+ */
1035
+ DARK: MapStyleVariant;
1036
+ /**
1037
+ * Light greyscale style with hillshading suitable for colorful terrain-aware visualization
1038
+ */
1039
+ LIGHT: MapStyleVariant;
1040
+ };
969
1041
  };
970
1042
  declare const mapStylePresetList: Array<MapStylePreset>;
971
1043
  /**
@@ -1 +1 @@
1
- function F(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class N{constructor(){this._apiKey="",this._fetch=F()}set apiKey(e){this._apiKey=e}get apiKey(){return this._apiKey}set fetch(e){this._fetch=e}get fetch(){return this._fetch}}const y=new N,L={AUTO:"auto",ALBANIAN:"sq",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HUNGARIAN:"hu",ICELANDIC:"is",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALTESE:"mt",NORWEGIAN:"no",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},M=new Set(Object.values(L));function B(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const n=Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).filter(e=>M.has(e));return n.length?n[0]:L.ENGLISH}var W=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});function A(n){return W(this,arguments,function*(e,t={}){if(y.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 y.fetch(e,t)})}const d={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(d);class v extends Error{constructor(e,t=""){super(`Call to enpoint ${e.url} failed with the status code ${e.status}. ${t}`),this.res=e}}var R=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const I={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function b(n,e){if(e.language==null)return;const t=Array.from(new Set((Array.isArray(e.language)?e.language:[e.language]).map(r=>r===L.AUTO?B():r))).join(",");n.set("language",t)}function C(n,e){var t;n.set("key",(t=e.apiKey)!=null?t:y.apiKey),e.limit!=null&&n.set("limit",String(e.limit)),e.types!=null&&n.set("types",e.types.join(",")),b(n,e)}function K(n,e){C(n,e),e.bbox!=null&&n.set("bbox",e.bbox.join(",")),e.proximity!=null&&n.set("proximity",e.proximity.join(",")),e.country!=null&&n.set("country",e.country.join(",")),e.fuzzyMatch!=null&&n.set("fuzzyMatch",e.fuzzyMatch?"true":"false"),e.autocomplete!=null&&n.set("autocomplete",e.autocomplete?"true":"false")}function z(n){return R(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const i=new URL(`geocoding/${encodeURIComponent(e)}.json`,d.maptilerApiURL),{searchParams:s}=i;K(s,t);const a=i.toString(),c=yield A(a);if(!c.ok)throw new v(c,(r=I[c.status])!=null?r:"");return yield c.json()})}function _(n){return R(this,arguments,function*(e,t={}){var r;if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const i=new URL(`geocoding/${e[0]},${e[1]}.json`,d.maptilerApiURL);C(i.searchParams,t);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,(r=I[a.status])!=null?r:"");return yield a.json()})}function q(n){return R(this,arguments,function*(e,t={}){var r;const i=new URL(`geocoding/${e}.json`,d.maptilerApiURL);b(i.searchParams,t);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,(r=I[a.status])!=null?r:"");return yield a.json()})}function Y(n){return R(this,arguments,function*(e,t={}){var r;if(!e.length)return[];const i=e.map(g=>encodeURIComponent(g)).join(";"),s=new URL(`geocoding/${i}.json`,d.maptilerApiURL),{searchParams:a}=s;K(a,t);const c=s.toString(),o=yield A(c);if(!o.ok)throw new v(o,(r=I[o.status])!=null?r:"");const l=yield o.json();return e.length===1?[l]:l})}const Z={forward:z,reverse:_,byId:q,batch:Y,language:L};var J=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const O={403:"Key is missing, invalid or restricted"};function Q(){return J(this,arguments,function*(n={}){var e;const t=new URL("geolocation/ip.json",d.maptilerApiURL);t.searchParams.set("key",(e=n.apiKey)!=null?e:y.apiKey);const r=t.toString(),i=yield A(r);if(!i.ok)throw new v(i,i.status in O?O[i.status]:"");return yield i.json()})}const X={info:Q};var j=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const S={403:"Key is missing, invalid or restricted"};function ee(n){return j(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const i=new URL(`coordinates/search/${e}.json`,d.maptilerApiURL);i.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey),"limit"in t&&i.searchParams.set("limit",t.limit.toString()),"transformations"in t&&i.searchParams.set("transformations",t.transformations.toString()),"exports"in t&&i.searchParams.set("exports",t.exports.toString());const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,a.status in S?S[a.status]:"");return yield a.json()})}function te(n){return j(this,arguments,function*(e,t={}){var r;const i=(Array.isArray(e[0])?e:[e]).map(o=>`${o[0]},${o[1]}`).join(";"),s=new URL(`coordinates/transform/${i}.json`,d.maptilerApiURL);s.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey),"sourceCrs"in t&&s.searchParams.set("s_srs",t.sourceCrs.toString()),"targetCrs"in t&&s.searchParams.set("t_srs",t.targetCrs.toString()),"operations"in t&&s.searchParams.set("ops",(Array.isArray(t.operations)?t.operations:[t.operations]).join("|"));const a=s.toString(),c=yield A(a);if(!c.ok)throw new v(c,c.status in S?S[c.status]:"");return yield c.json()})}const ne={search:ee,transform:te};var re=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const H={403:"Key is missing, invalid or restricted"};function ie(n){return re(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The data ID must be a non-empty string");const i=new URL(`data/${encodeURIComponent(e)}/features.json`,d.maptilerApiURL);i.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,a.status in H?H[a.status]:"");return yield a.json()})}const ae={get:ie};function x(n){const e=/^maptiler:\/\/(.*)/;let t;const r=n.trim();let i;return r.startsWith("http://")||r.startsWith("https://")?i=r:(t=e.exec(r))!==null?i=`https://api.maptiler.com/maps/${t[1]}/style.json`:i=`https://api.maptiler.com/maps/${r}/style.json`,i}class D{constructor(e,t,r,i,s,a){this.name=e,this.variantType=t,this.id=r,this.referenceStyle=i,this.description=s,this.imageURL=a}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(e){return this.referenceStyle.hasVariant(e)}getVariant(e){return this.referenceStyle.getVariant(e)}getVariants(){return this.referenceStyle.getVariants().filter(e=>e!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return x(this.getId())}}class k{constructor(e,t){this.name=e,this.id=t,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(e){this.variants[e.getType()]=e,this.orderedVariants.push(e)}hasVariant(e){return e in this.variants}getVariant(e){return e in this.variants?this.variants[e]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const T=[{referenceStyleID:"STREETS",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"streets-v2-night",name:"Night",variantType:"NIGHT",description:"",imageURL:""},{id:"streets-v2-pastel",name:"Pastel",variantType:"PASTEL",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",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{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",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",variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",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",description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",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:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]}];function se(n){return new Proxy(n,{get(e,t,r){return e.hasVariant(t)?e.getVariant(t):t.toString().toUpperCase()===t?n.getDefaultVariant():Reflect.get(e,t,r)}})}function oe(){const n={};for(let e=0;e<T.length;e+=1){const t=T[e],r=se(new k(t.name,t.referenceStyleID));for(let i=0;i<t.variants.length;i+=1){const s=t.variants[i],a=new D(s.name,s.variantType,s.id,r,s.description,s.imageURL);r.addVariant(a)}n[t.referenceStyleID]=r}return n}function $(n){if(!n)return V[T[0].referenceStyleID].getDefaultVariant().getId();if(typeof n=="string"||n instanceof String)return n.trim().toLowerCase();if(n instanceof D)return n.getId();if(n instanceof k)return n.getDefaultVariant().getId()}const V=oe();function ce(n,e,t){let r=e[0],i=e[1],s=t[0]-r,a=t[1]-i;if(s!==0||a!==0){const c=((n[0]-r)*s+(n[1]-i)*a)/(s*s+a*a);c>1?(r=t[0],i=t[1]):c>0&&(r+=s*c,i+=a*c)}return s=n[0]-r,a=n[1]-i,s*s+a*a}function E(n,e,t,r,i){let s=r,a;for(let c=e+1;c<t;c++){const o=ce(n[c],n[e],n[t]);o>s&&(a=c,s=o)}s>r&&(a-e>1&&E(n,e,a,r,i),i.push(n[a]),t-a>1&&E(n,a,t,r,i))}function le(n,e){const t=n.length-1,r=[n[0]];return E(n,0,t,e,r),r.push(n[t]),r}function pe(n,e){if(n.length<=2)return n;const t=e!==void 0?e*e:1;return le(n,t)}function w(n,e=!0){let t=`${n[0]},${n[1]}`;return n.length===3&&e&&(t+=`,${n[2]}`),t}function P(n,e=3e3){let t=n.map(s=>s.join(",")).join("|"),r=5e-6;const i=1e-5;for(;t.length>e;)t=pe(n,r).map(s=>`${s[0]},${s[1]}`).join("|"),r+=i;return t}function me(n,e,t={}){var r,i,s,a,c;const o=$(t.style),l=t.hiDPI?"@2x":"",g=(r=t.format)!=null?r:"png";let u=~~((i=t.width)!=null?i:1024),m=~~((s=t.height)!=null?s:1024);t.hiDPI&&(u=~~(u/2),m=~~(m/2));const p=new URL(`maps/${encodeURIComponent(o)}/static/${n[0]},${n[1]},${e}/${u}x${m}${l}.${g}`,d.maptilerApiURL);if("attribution"in t&&p.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let h="";const f="markerIcon"in t;f&&(h+=`icon:${t.markerIcon}|`),f&&"markerAnchor"in t&&(h+=`anchor:${t.markerAnchor}|`),f&&t.hiDPI&&(h+="scale:2|");const U=Array.isArray(t.markers[0])?t.markers:[t.markers];h+=U.map(G=>w(G,!f)).join("|"),p.searchParams.set("markers",h)}if("path"in t){let h="";if(h+=`fill:${(a=t.pathFillColor)!=null?a:"none"}|`,"pathStrokeColor"in t&&(h+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const f=t.pathWidth/(t.hiDPI?2:1);h+=`width:${f.toString()}|`}h+=P(t.path),p.searchParams.set("path",h)}return p.searchParams.set("key",(c=t.apiKey)!=null?c:y.apiKey),p.toString()}function he(n,e={}){var t,r,i,s,a;const c=$(e.style),o=e.hiDPI?"@2x":"",l=(t=e.format)!=null?t:"png";let g=~~((r=e.width)!=null?r:1024),u=~~((i=e.height)!=null?i:1024);e.hiDPI&&(g=~~(g/2),u=~~(u/2));const m=new URL(`maps/${encodeURIComponent(c)}/static/${n[0]},${n[1]},${n[2]},${n[3]}/${g}x${u}${o}.${l}`,d.maptilerApiURL);if("attribution"in e&&m.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&m.searchParams.set("padding",e.padding.toString()),"markers"in e){let p="";const h="markerIcon"in e;h&&(p+=`icon:${e.markerIcon}|`),h&&"markerAnchor"in e&&(p+=`anchor:${e.markerAnchor}|`),h&&e.hiDPI&&(p+="scale:2|");const f=Array.isArray(e.markers[0])?e.markers:[e.markers];p+=f.map(U=>w(U,!h)).join("|"),m.searchParams.set("markers",p)}if("path"in e){let p="";if(p+=`fill:${(s=e.pathFillColor)!=null?s:"none"}|`,"pathStrokeColor"in e&&(p+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const h=e.pathWidth/(e.hiDPI?2:1);p+=`width:${h.toString()}|`}p+=P(e.path),m.searchParams.set("path",p)}return m.searchParams.set("key",(a=e.apiKey)!=null?a:y.apiKey),m.toString()}function ue(n={}){var e,t,r,i,s;if(!("markers"in n)&&!("path"in n))throw new Error("Automatic static maps require markers and/or path to be created.");const a=$(n.style),c=n.hiDPI?"@2x":"",o=(e=n.format)!=null?e:"png";let l=~~((t=n.width)!=null?t:1024),g=~~((r=n.height)!=null?r:1024);n.hiDPI&&(l=~~(l/2),g=~~(g/2));const u=new URL(`maps/${encodeURIComponent(a)}/static/auto/${l}x${g}${c}.${o}`,d.maptilerApiURL);if("attribution"in n&&u.searchParams.set("attribution",n.attribution.toString()),"padding"in n&&u.searchParams.set("padding",n.padding.toString()),"markers"in n){let m="";const p="markerIcon"in n;p&&(m+=`icon:${n.markerIcon}|`),p&&"markerAnchor"in n&&(m+=`anchor:${n.markerAnchor}|`),p&&n.hiDPI&&(m+="scale:2|");const h=Array.isArray(n.markers[0])?n.markers:[n.markers];m+=h.map(f=>w(f,!p)).join("|"),u.searchParams.set("markers",m)}if("path"in n){let m="";if(m+=`fill:${(i=n.pathFillColor)!=null?i:"none"}|`,"pathStrokeColor"in n&&(m+=`stroke:${n.pathStrokeColor}|`),"pathWidth"in n){const p=n.pathWidth/(n.hiDPI?2:1);m+=`width:${p.toString()}|`}m+=P(n.path),u.searchParams.set("path",m)}return u.searchParams.set("key",(s=n.apiKey)!=null?s:y.apiKey),u.toString()}const de={centered:me,bounded:he,automatic:ue};export{N as ClientConfig,L as LanguageGeocoding,V as MapStyle,D as MapStyleVariant,k as ReferenceMapStyle,v as ServiceError,y as config,ne as coordinates,ae as data,x as expandMapStyle,Z as geocoding,X as geolocation,T as mapStylePresetList,de as staticMaps};
1
+ function F(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class N{constructor(){this._apiKey="",this._fetch=F()}set apiKey(e){this._apiKey=e}get apiKey(){return this._apiKey}set fetch(e){this._fetch=e}get fetch(){return this._fetch}}const y=new N,L={AUTO:"auto",ALBANIAN:"sq",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HUNGARIAN:"hu",ICELANDIC:"is",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALTESE:"mt",NORWEGIAN:"no",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},B=new Set(Object.values(L));function M(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const n=Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).filter(e=>B.has(e));return n.length?n[0]:L.ENGLISH}var W=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});function A(n){return W(this,arguments,function*(e,t={}){if(y.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 y.fetch(e,t)})}const d={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(d);class v extends Error{constructor(e,t=""){super(`Call to enpoint ${e.url} failed with the status code ${e.status}. ${t}`),this.res=e}}var R=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const I={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function b(n,e){if(e.language==null)return;const t=Array.from(new Set((Array.isArray(e.language)?e.language:[e.language]).map(r=>r===L.AUTO?M():r))).join(",");n.set("language",t)}function C(n,e){var t;n.set("key",(t=e.apiKey)!=null?t:y.apiKey),e.limit!=null&&n.set("limit",String(e.limit)),e.types!=null&&n.set("types",e.types.join(",")),b(n,e)}function K(n,e){C(n,e),e.bbox!=null&&n.set("bbox",e.bbox.join(",")),e.proximity!=null&&n.set("proximity",e.proximity.join(",")),e.country!=null&&n.set("country",e.country.join(",")),e.fuzzyMatch!=null&&n.set("fuzzyMatch",e.fuzzyMatch?"true":"false"),e.autocomplete!=null&&n.set("autocomplete",e.autocomplete?"true":"false")}function z(n){return R(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const i=new URL(`geocoding/${encodeURIComponent(e)}.json`,d.maptilerApiURL),{searchParams:s}=i;K(s,t);const a=i.toString(),c=yield A(a);if(!c.ok)throw new v(c,(r=I[c.status])!=null?r:"");return yield c.json()})}function _(n){return R(this,arguments,function*(e,t={}){var r;if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const i=new URL(`geocoding/${e[0]},${e[1]}.json`,d.maptilerApiURL);C(i.searchParams,t);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,(r=I[a.status])!=null?r:"");return yield a.json()})}function q(n){return R(this,arguments,function*(e,t={}){var r;const i=new URL(`geocoding/${e}.json`,d.maptilerApiURL);b(i.searchParams,t);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,(r=I[a.status])!=null?r:"");return yield a.json()})}function Y(n){return R(this,arguments,function*(e,t={}){var r;if(!e.length)return[];const i=e.map(g=>encodeURIComponent(g)).join(";"),s=new URL(`geocoding/${i}.json`,d.maptilerApiURL),{searchParams:a}=s;K(a,t);const c=s.toString(),o=yield A(c);if(!o.ok)throw new v(o,(r=I[o.status])!=null?r:"");const l=yield o.json();return e.length===1?[l]:l})}const Z={forward:z,reverse:_,byId:q,batch:Y,language:L};var J=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const O={403:"Key is missing, invalid or restricted"};function Q(){return J(this,arguments,function*(n={}){var e;const t=new URL("geolocation/ip.json",d.maptilerApiURL);t.searchParams.set("key",(e=n.apiKey)!=null?e:y.apiKey);const r=t.toString(),i=yield A(r);if(!i.ok)throw new v(i,i.status in O?O[i.status]:"");return yield i.json()})}const X={info:Q};var j=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const S={403:"Key is missing, invalid or restricted"};function ee(n){return j(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const i=new URL(`coordinates/search/${e}.json`,d.maptilerApiURL);i.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey),"limit"in t&&i.searchParams.set("limit",t.limit.toString()),"transformations"in t&&i.searchParams.set("transformations",t.transformations.toString()),"exports"in t&&i.searchParams.set("exports",t.exports.toString());const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,a.status in S?S[a.status]:"");return yield a.json()})}function te(n){return j(this,arguments,function*(e,t={}){var r;const i=(Array.isArray(e[0])?e:[e]).map(o=>`${o[0]},${o[1]}`).join(";"),s=new URL(`coordinates/transform/${i}.json`,d.maptilerApiURL);s.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey),"sourceCrs"in t&&s.searchParams.set("s_srs",t.sourceCrs.toString()),"targetCrs"in t&&s.searchParams.set("t_srs",t.targetCrs.toString()),"operations"in t&&s.searchParams.set("ops",(Array.isArray(t.operations)?t.operations:[t.operations]).join("|"));const a=s.toString(),c=yield A(a);if(!c.ok)throw new v(c,c.status in S?S[c.status]:"");return yield c.json()})}const ne={search:ee,transform:te};var re=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const H={403:"Key is missing, invalid or restricted"};function ie(n){return re(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The data ID must be a non-empty string");const i=new URL(`data/${encodeURIComponent(e)}/features.json`,d.maptilerApiURL);i.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,a.status in H?H[a.status]:"");return yield a.json()})}const ae={get:ie};function x(n){const e=/^maptiler:\/\/(.*)/;let t;const r=n.trim();let i;return r.startsWith("http://")||r.startsWith("https://")?i=r:(t=e.exec(r))!==null?i=`https://api.maptiler.com/maps/${t[1]}/style.json`:i=`https://api.maptiler.com/maps/${r}/style.json`,i}class D{constructor(e,t,r,i,s,a){this.name=e,this.variantType=t,this.id=r,this.referenceStyle=i,this.description=s,this.imageURL=a}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(e){return this.referenceStyle.hasVariant(e)}getVariant(e){return this.referenceStyle.getVariant(e)}getVariants(){return this.referenceStyle.getVariants().filter(e=>e!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return x(this.getId())}}class k{constructor(e,t){this.name=e,this.id=t,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(e){this.variants[e.getType()]=e,this.orderedVariants.push(e)}hasVariant(e){return e in this.variants}getVariant(e){return e in this.variants?this.variants[e]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const T=[{referenceStyleID:"STREETS",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"streets-v2-night",name:"Night",variantType:"NIGHT",description:"",imageURL:""},{id:"streets-v2-pastel",name:"Pastel",variantType:"PASTEL",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",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{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",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",variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",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",description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",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:""}]}];function se(n){return new Proxy(n,{get(e,t,r){return e.hasVariant(t)?e.getVariant(t):t.toString().toUpperCase()===t?n.getDefaultVariant():Reflect.get(e,t,r)}})}function oe(){const n={};for(let e=0;e<T.length;e+=1){const t=T[e],r=se(new k(t.name,t.referenceStyleID));for(let i=0;i<t.variants.length;i+=1){const s=t.variants[i],a=new D(s.name,s.variantType,s.id,r,s.description,s.imageURL);r.addVariant(a)}n[t.referenceStyleID]=r}return n}function $(n){if(!n)return V[T[0].referenceStyleID].getDefaultVariant().getId();if(typeof n=="string"||n instanceof String)return n.trim().toLowerCase();if(n instanceof D)return n.getId();if(n instanceof k)return n.getDefaultVariant().getId()}const V=oe();function ce(n,e,t){let r=e[0],i=e[1],s=t[0]-r,a=t[1]-i;if(s!==0||a!==0){const c=((n[0]-r)*s+(n[1]-i)*a)/(s*s+a*a);c>1?(r=t[0],i=t[1]):c>0&&(r+=s*c,i+=a*c)}return s=n[0]-r,a=n[1]-i,s*s+a*a}function E(n,e,t,r,i){let s=r,a;for(let c=e+1;c<t;c++){const o=ce(n[c],n[e],n[t]);o>s&&(a=c,s=o)}s>r&&(a-e>1&&E(n,e,a,r,i),i.push(n[a]),t-a>1&&E(n,a,t,r,i))}function le(n,e){const t=n.length-1,r=[n[0]];return E(n,0,t,e,r),r.push(n[t]),r}function pe(n,e){if(n.length<=2)return n;const t=e!==void 0?e*e:1;return le(n,t)}function w(n,e=!0){let t=`${n[0]},${n[1]}`;return n.length===3&&e&&(t+=`,${n[2]}`),t}function P(n,e=3e3){let t=n.map(s=>s.join(",")).join("|"),r=5e-6;const i=1e-5;for(;t.length>e;)t=pe(n,r).map(s=>`${s[0]},${s[1]}`).join("|"),r+=i;return t}function me(n,e,t={}){var r,i,s,a,c;const o=$(t.style),l=t.hiDPI?"@2x":"",g=(r=t.format)!=null?r:"png";let u=~~((i=t.width)!=null?i:1024),m=~~((s=t.height)!=null?s:1024);t.hiDPI&&(u=~~(u/2),m=~~(m/2));const p=new URL(`maps/${encodeURIComponent(o)}/static/${n[0]},${n[1]},${e}/${u}x${m}${l}.${g}`,d.maptilerApiURL);if("attribution"in t&&p.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let h="";const f="markerIcon"in t;f&&(h+=`icon:${t.markerIcon}|`),f&&"markerAnchor"in t&&(h+=`anchor:${t.markerAnchor}|`),f&&t.hiDPI&&(h+="scale:2|");const U=Array.isArray(t.markers[0])?t.markers:[t.markers];h+=U.map(G=>w(G,!f)).join("|"),p.searchParams.set("markers",h)}if("path"in t){let h="";if(h+=`fill:${(a=t.pathFillColor)!=null?a:"none"}|`,"pathStrokeColor"in t&&(h+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const f=t.pathWidth/(t.hiDPI?2:1);h+=`width:${f.toString()}|`}h+=P(t.path),p.searchParams.set("path",h)}return p.searchParams.set("key",(c=t.apiKey)!=null?c:y.apiKey),p.toString()}function he(n,e={}){var t,r,i,s,a;const c=$(e.style),o=e.hiDPI?"@2x":"",l=(t=e.format)!=null?t:"png";let g=~~((r=e.width)!=null?r:1024),u=~~((i=e.height)!=null?i:1024);e.hiDPI&&(g=~~(g/2),u=~~(u/2));const m=new URL(`maps/${encodeURIComponent(c)}/static/${n[0]},${n[1]},${n[2]},${n[3]}/${g}x${u}${o}.${l}`,d.maptilerApiURL);if("attribution"in e&&m.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&m.searchParams.set("padding",e.padding.toString()),"markers"in e){let p="";const h="markerIcon"in e;h&&(p+=`icon:${e.markerIcon}|`),h&&"markerAnchor"in e&&(p+=`anchor:${e.markerAnchor}|`),h&&e.hiDPI&&(p+="scale:2|");const f=Array.isArray(e.markers[0])?e.markers:[e.markers];p+=f.map(U=>w(U,!h)).join("|"),m.searchParams.set("markers",p)}if("path"in e){let p="";if(p+=`fill:${(s=e.pathFillColor)!=null?s:"none"}|`,"pathStrokeColor"in e&&(p+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const h=e.pathWidth/(e.hiDPI?2:1);p+=`width:${h.toString()}|`}p+=P(e.path),m.searchParams.set("path",p)}return m.searchParams.set("key",(a=e.apiKey)!=null?a:y.apiKey),m.toString()}function ue(n={}){var e,t,r,i,s;if(!("markers"in n)&&!("path"in n))throw new Error("Automatic static maps require markers and/or path to be created.");const a=$(n.style),c=n.hiDPI?"@2x":"",o=(e=n.format)!=null?e:"png";let l=~~((t=n.width)!=null?t:1024),g=~~((r=n.height)!=null?r:1024);n.hiDPI&&(l=~~(l/2),g=~~(g/2));const u=new URL(`maps/${encodeURIComponent(a)}/static/auto/${l}x${g}${c}.${o}`,d.maptilerApiURL);if("attribution"in n&&u.searchParams.set("attribution",n.attribution.toString()),"padding"in n&&u.searchParams.set("padding",n.padding.toString()),"markers"in n){let m="";const p="markerIcon"in n;p&&(m+=`icon:${n.markerIcon}|`),p&&"markerAnchor"in n&&(m+=`anchor:${n.markerAnchor}|`),p&&n.hiDPI&&(m+="scale:2|");const h=Array.isArray(n.markers[0])?n.markers:[n.markers];m+=h.map(f=>w(f,!p)).join("|"),u.searchParams.set("markers",m)}if("path"in n){let m="";if(m+=`fill:${(i=n.pathFillColor)!=null?i:"none"}|`,"pathStrokeColor"in n&&(m+=`stroke:${n.pathStrokeColor}|`),"pathWidth"in n){const p=n.pathWidth/(n.hiDPI?2:1);m+=`width:${p.toString()}|`}m+=P(n.path),u.searchParams.set("path",m)}return u.searchParams.set("key",(s=n.apiKey)!=null?s:y.apiKey),u.toString()}const de={centered:me,bounded:he,automatic:ue};export{N as ClientConfig,L as LanguageGeocoding,V as MapStyle,D as MapStyleVariant,k as ReferenceMapStyle,v as ServiceError,y as config,ne as coordinates,ae as data,x as expandMapStyle,Z as geocoding,X as geolocation,T as mapStylePresetList,de as staticMaps};
@@ -1003,6 +1003,34 @@ const mapStylePresetList = [
1003
1003
  }
1004
1004
  ]
1005
1005
  },
1006
+ {
1007
+ referenceStyleID: "BACKDROP",
1008
+ name: "Backdrop",
1009
+ description: "",
1010
+ variants: [
1011
+ {
1012
+ id: "backdrop",
1013
+ name: "Default",
1014
+ variantType: "DEFAULT",
1015
+ description: "",
1016
+ imageURL: ""
1017
+ },
1018
+ {
1019
+ id: "backdrop-dark",
1020
+ name: "Dark",
1021
+ variantType: "DARK",
1022
+ description: "",
1023
+ imageURL: ""
1024
+ },
1025
+ {
1026
+ id: "backdrop-light",
1027
+ name: "Light",
1028
+ variantType: "LIGHT",
1029
+ description: "",
1030
+ imageURL: ""
1031
+ }
1032
+ ]
1033
+ },
1006
1034
  {
1007
1035
  referenceStyleID: "OCEAN",
1008
1036
  name: "Ocean",