@maptiler/client 3.1.0 → 3.2.0-rc.1
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,4 +1,4 @@
|
|
|
1
|
-
import { BBox, Position, Feature, Geometry, FeatureCollection, LineString, MultiLineString, GeoJsonObject } from 'geojson';
|
|
1
|
+
import { BBox, Position, Feature, Geometry, MultiPoint, MultiPolygon, FeatureCollection, LineString, MultiLineString, GeoJsonObject } from 'geojson';
|
|
2
2
|
export { BBox, LineString, MultiLineString, Position } from 'geojson';
|
|
3
3
|
import QuickLRU from 'quick-lru';
|
|
4
4
|
|
|
@@ -1212,6 +1212,316 @@ declare const geolocation: {
|
|
|
1212
1212
|
info: typeof info;
|
|
1213
1213
|
};
|
|
1214
1214
|
|
|
1215
|
+
/** Routing profile — determines the costing model. */
|
|
1216
|
+
type RoutingProfile = "car" | "truck" | "bicycle" | "pedestrian";
|
|
1217
|
+
/** Unit of length to use */
|
|
1218
|
+
type RoutingDistanceUnit = "km" | "mi";
|
|
1219
|
+
/** Language of navigation instructions */
|
|
1220
|
+
type RoutingInstructionsLanguage = "bg" | "ca" | "cs" | "da" | "de" | "el" | "en" | "es" | "et" | "fi" | "fr" | "hi" | "hu" | "it" | "ja" | "nb" | "nl" | "pl" | "pt" | "ro" | "ru" | "sk" | "sl" | "sv" | "tr" | "uk";
|
|
1221
|
+
/**
|
|
1222
|
+
* A single routing location as accepted by the GET endpoint, which encodes
|
|
1223
|
+
* each location as a `lon,lat` pair and therefore supports no extra fields.
|
|
1224
|
+
*/
|
|
1225
|
+
interface RoutingGetLocation {
|
|
1226
|
+
/** Longitude of the point */
|
|
1227
|
+
lon: number;
|
|
1228
|
+
/** Latitude of the point */
|
|
1229
|
+
lat: number;
|
|
1230
|
+
}
|
|
1231
|
+
/** A single routing location */
|
|
1232
|
+
interface RoutingLocation extends RoutingGetLocation {
|
|
1233
|
+
/** Preferred direction of travel starting from this location. */
|
|
1234
|
+
heading?: number;
|
|
1235
|
+
/**
|
|
1236
|
+
* Whether this location is a waypoint (default: true).
|
|
1237
|
+
* If false, the router may pass through without splitting legs.
|
|
1238
|
+
*/
|
|
1239
|
+
waypoint?: boolean;
|
|
1240
|
+
}
|
|
1241
|
+
/** Avoidance flags. Available for the car and truck profiles only. */
|
|
1242
|
+
interface RoutingAvoidances {
|
|
1243
|
+
/** Avoid toll roads */
|
|
1244
|
+
tolls?: boolean;
|
|
1245
|
+
/** Avoid ferries */
|
|
1246
|
+
ferry?: boolean;
|
|
1247
|
+
/** Avoid highways */
|
|
1248
|
+
highway?: boolean;
|
|
1249
|
+
}
|
|
1250
|
+
/** Car-specific routing options. */
|
|
1251
|
+
interface RoutingCarOptions {
|
|
1252
|
+
/** Car routing mode: fastest, shortest or balanced */
|
|
1253
|
+
mode?: "fastest" | "shortest" | "balanced";
|
|
1254
|
+
/**
|
|
1255
|
+
* Maximal speed of the car, in km/h. Whole numbers only.
|
|
1256
|
+
* Default: 140. Maximum: 252.
|
|
1257
|
+
*/
|
|
1258
|
+
topSpeed?: number;
|
|
1259
|
+
/** Avoidance flags */
|
|
1260
|
+
avoidances?: RoutingAvoidances;
|
|
1261
|
+
}
|
|
1262
|
+
/** Truck-specific routing options supported by the GET endpoint. */
|
|
1263
|
+
interface RoutingGetTruckOptions {
|
|
1264
|
+
/**
|
|
1265
|
+
* Weight of the truck, in metric tonnes. Used for restrictions.
|
|
1266
|
+
* Default: 21.77.
|
|
1267
|
+
*/
|
|
1268
|
+
weight?: number;
|
|
1269
|
+
/**
|
|
1270
|
+
* Height of the truck, in meters.
|
|
1271
|
+
* Default: 4.11.
|
|
1272
|
+
*/
|
|
1273
|
+
height?: number;
|
|
1274
|
+
/**
|
|
1275
|
+
* Axle load of the truck, in metric tonnes.
|
|
1276
|
+
* Default: 9.07. Maximum: 40.
|
|
1277
|
+
*/
|
|
1278
|
+
axleLoad?: number;
|
|
1279
|
+
/** Whether the truck carries hazardous materials */
|
|
1280
|
+
hazmat?: boolean;
|
|
1281
|
+
/**
|
|
1282
|
+
* Maximal speed of the truck, in km/h. Whole numbers only.
|
|
1283
|
+
* Default: 120. Maximum: 252.
|
|
1284
|
+
*/
|
|
1285
|
+
topSpeed?: number;
|
|
1286
|
+
/** Avoidance flags */
|
|
1287
|
+
avoidances?: RoutingAvoidances;
|
|
1288
|
+
}
|
|
1289
|
+
/** Truck-specific routing options. */
|
|
1290
|
+
interface RoutingTruckOptions extends RoutingGetTruckOptions {
|
|
1291
|
+
/**
|
|
1292
|
+
* Length of the truck, in meters.
|
|
1293
|
+
* Default: 21.64.
|
|
1294
|
+
*/
|
|
1295
|
+
length?: number;
|
|
1296
|
+
}
|
|
1297
|
+
/** Bicycle-specific routing options. */
|
|
1298
|
+
interface RoutingBicycleOptions {
|
|
1299
|
+
/** Bicycle type: road, gravel, mountain, city */
|
|
1300
|
+
type?: "road" | "gravel" | "mountain" | "city";
|
|
1301
|
+
/**
|
|
1302
|
+
* Average speed along flat, smooth road, in km/h. Used to calculate ETA.
|
|
1303
|
+
* The default depends on the bicycle type.
|
|
1304
|
+
*/
|
|
1305
|
+
cyclingSpeed?: number;
|
|
1306
|
+
}
|
|
1307
|
+
/** Pedestrian-specific routing options. */
|
|
1308
|
+
interface RoutingPedestrianOptions {
|
|
1309
|
+
/**
|
|
1310
|
+
* Average walking speed along flat, smooth road, in km/h.
|
|
1311
|
+
* Used to calculate ETA. Default: 5.1.
|
|
1312
|
+
*/
|
|
1313
|
+
walkingSpeed?: number;
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* The `profile` and the matching `profileOptions`. Pairing a profile with
|
|
1317
|
+
* options belonging to another profile is a type error, because the API
|
|
1318
|
+
* accepts only the options defined for the selected profile.
|
|
1319
|
+
*/
|
|
1320
|
+
type RoutingProfileSelection<CarOptions, TruckOptions, BicycleOptions, PedestrianOptions> = {
|
|
1321
|
+
profile: "car";
|
|
1322
|
+
profileOptions?: CarOptions;
|
|
1323
|
+
} | {
|
|
1324
|
+
profile: "truck";
|
|
1325
|
+
profileOptions?: TruckOptions;
|
|
1326
|
+
} | {
|
|
1327
|
+
profile: "bicycle";
|
|
1328
|
+
profileOptions?: BicycleOptions;
|
|
1329
|
+
} | {
|
|
1330
|
+
profile: "pedestrian";
|
|
1331
|
+
profileOptions?: PedestrianOptions;
|
|
1332
|
+
};
|
|
1333
|
+
/** How much routing detail should be returned. */
|
|
1334
|
+
type RoutingDetailLevel = "legs" | "steps" | "instructions";
|
|
1335
|
+
/** Response formatting options supported by both endpoints. */
|
|
1336
|
+
interface RoutingResponseOptions {
|
|
1337
|
+
/** Units for distance */
|
|
1338
|
+
units?: RoutingDistanceUnit;
|
|
1339
|
+
/** Language of navigation instructions */
|
|
1340
|
+
language?: RoutingInstructionsLanguage;
|
|
1341
|
+
/**
|
|
1342
|
+
* Number of alternate routes to generate. Whole numbers only. Maximum: 3.
|
|
1343
|
+
* Note that alternates are not generated when the request contains more
|
|
1344
|
+
* than two locations.
|
|
1345
|
+
*/
|
|
1346
|
+
alternates?: number;
|
|
1347
|
+
/** Additional data returned with the route */
|
|
1348
|
+
additionalData?: {
|
|
1349
|
+
/** Level of detail: legs, steps or instructions */
|
|
1350
|
+
detailLevel?: RoutingDetailLevel;
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
/** Request fields shared by both endpoints. */
|
|
1354
|
+
interface RoutingRequestBase {
|
|
1355
|
+
/** Pass-through identifier returned in response */
|
|
1356
|
+
id?: string;
|
|
1357
|
+
/**
|
|
1358
|
+
* Time of departure.
|
|
1359
|
+
* Format: YYYY-MM-DDTHH:MM
|
|
1360
|
+
*/
|
|
1361
|
+
departureTime?: string;
|
|
1362
|
+
/**
|
|
1363
|
+
* Desired arrival time.
|
|
1364
|
+
* Format: YYYY-MM-DDTHH:MM
|
|
1365
|
+
*/
|
|
1366
|
+
arrivalTime?: string;
|
|
1367
|
+
/** Response formatting options */
|
|
1368
|
+
response?: RoutingResponseOptions;
|
|
1369
|
+
}
|
|
1370
|
+
/** Full routing request body for POST /routing/v1/directions. */
|
|
1371
|
+
type RoutingRequest = RoutingRequestBase & {
|
|
1372
|
+
/** List of route locations (at least 2) */
|
|
1373
|
+
locations: RoutingLocation[];
|
|
1374
|
+
/** Locations or polygons to avoid. */
|
|
1375
|
+
avoidLocations?: MultiPoint | MultiPolygon;
|
|
1376
|
+
} & RoutingProfileSelection<RoutingCarOptions, RoutingTruckOptions, RoutingBicycleOptions, RoutingPedestrianOptions>;
|
|
1377
|
+
/**
|
|
1378
|
+
* Routing request for GET /routing/v1/directions.
|
|
1379
|
+
*
|
|
1380
|
+
* The GET endpoint takes a strict subset of what the POST body accepts, so
|
|
1381
|
+
* this type deliberately omits the fields that cannot be expressed as query
|
|
1382
|
+
* parameters: {@link RoutingLocation.heading}, {@link RoutingLocation.waypoint},
|
|
1383
|
+
* `avoidLocations` and the truck `length`.
|
|
1384
|
+
* Use {@link routing.directionsPost} if you need any of them.
|
|
1385
|
+
*/
|
|
1386
|
+
type RoutingGetRequest = RoutingRequestBase & {
|
|
1387
|
+
/** List of route locations (at least 2) */
|
|
1388
|
+
locations: RoutingGetLocation[];
|
|
1389
|
+
} & RoutingProfileSelection<RoutingCarOptions, RoutingGetTruckOptions, RoutingBicycleOptions, RoutingPedestrianOptions>;
|
|
1390
|
+
/** Options applying to the routing request itself, rather than to the route. */
|
|
1391
|
+
interface RoutingOptions {
|
|
1392
|
+
/**
|
|
1393
|
+
* Custom MapTiler Cloud API key to use instead of the one in global `config`.
|
|
1394
|
+
*/
|
|
1395
|
+
apiKey?: string;
|
|
1396
|
+
/**
|
|
1397
|
+
* Callback function to adjust the target URL search params before fetching.
|
|
1398
|
+
* @param searchParams [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) object that can be modified in place.
|
|
1399
|
+
*/
|
|
1400
|
+
adjustSearchParams?: (searchParams: URLSearchParams) => void;
|
|
1401
|
+
/** Extra options to pass to the underlying [fetch](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit) call. */
|
|
1402
|
+
fetchExtras?: RequestInit;
|
|
1403
|
+
}
|
|
1404
|
+
/** Routing response */
|
|
1405
|
+
interface RoutingResponse {
|
|
1406
|
+
/** Pass-through identifier */
|
|
1407
|
+
id?: string;
|
|
1408
|
+
/** Main route */
|
|
1409
|
+
route: RoutingRoute;
|
|
1410
|
+
/** Alternate routes */
|
|
1411
|
+
alternates?: RoutingRoute[];
|
|
1412
|
+
/** Attribution text */
|
|
1413
|
+
attribution?: string;
|
|
1414
|
+
/** Units used in response */
|
|
1415
|
+
units?: RoutingDistanceUnit;
|
|
1416
|
+
/** Language used in response */
|
|
1417
|
+
language?: RoutingInstructionsLanguage;
|
|
1418
|
+
}
|
|
1419
|
+
interface RoutingRoute {
|
|
1420
|
+
/** Summary of this route */
|
|
1421
|
+
summary: RoutingSummary;
|
|
1422
|
+
/** Route legs between waypoints */
|
|
1423
|
+
legs: RoutingRouteLeg[];
|
|
1424
|
+
}
|
|
1425
|
+
/** Bounding box of a route or a leg: `[minLon, minLat, maxLon, maxLat]`. */
|
|
1426
|
+
type RoutingBBox = [number, number, number, number];
|
|
1427
|
+
/** Summary of a route or a leg */
|
|
1428
|
+
interface RoutingSummary {
|
|
1429
|
+
/** Cost calculated by the costing model */
|
|
1430
|
+
cost: number;
|
|
1431
|
+
/** Total travel time in seconds */
|
|
1432
|
+
totalTime: number;
|
|
1433
|
+
/** Total travel distance in chosen units */
|
|
1434
|
+
totalLength: number;
|
|
1435
|
+
/** Bounding box of the route */
|
|
1436
|
+
bbox: RoutingBBox;
|
|
1437
|
+
/** Whether route contains tolls */
|
|
1438
|
+
toll?: boolean;
|
|
1439
|
+
/** Whether route contains highways */
|
|
1440
|
+
highway?: boolean;
|
|
1441
|
+
/** Whether route contains ferries */
|
|
1442
|
+
ferry?: boolean;
|
|
1443
|
+
}
|
|
1444
|
+
/** Single leg of a route */
|
|
1445
|
+
interface RoutingRouteLeg {
|
|
1446
|
+
/** Summary of the leg */
|
|
1447
|
+
summary: RoutingSummary;
|
|
1448
|
+
/**
|
|
1449
|
+
* Geometry of the leg as a list of coordinates.
|
|
1450
|
+
* Encoded Polyline geometry is decoded by the client before being returned.
|
|
1451
|
+
*/
|
|
1452
|
+
geometry: Position[];
|
|
1453
|
+
/** Turn-by-turn steps */
|
|
1454
|
+
steps?: RoutingRouteStep[];
|
|
1455
|
+
}
|
|
1456
|
+
/** Details of a single turn-by-turn step */
|
|
1457
|
+
interface RoutingRouteStep {
|
|
1458
|
+
/** Time in seconds */
|
|
1459
|
+
time: number;
|
|
1460
|
+
/** Distance in chosen units */
|
|
1461
|
+
length: number;
|
|
1462
|
+
/** Street name */
|
|
1463
|
+
streetName?: string;
|
|
1464
|
+
/** Maneuver details */
|
|
1465
|
+
maneuver?: RoutingRouteManeuver;
|
|
1466
|
+
/** Index of step start in geometry array */
|
|
1467
|
+
beginIndex?: number;
|
|
1468
|
+
/** Index of step end in geometry array */
|
|
1469
|
+
endIndex?: number;
|
|
1470
|
+
/** Step-level flags */
|
|
1471
|
+
details?: {
|
|
1472
|
+
toll?: boolean;
|
|
1473
|
+
highway?: boolean;
|
|
1474
|
+
rough?: boolean;
|
|
1475
|
+
ferry?: boolean;
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Type of maneuver.
|
|
1480
|
+
*
|
|
1481
|
+
* The API may add new maneuver types without a breaking change, so this type
|
|
1482
|
+
* also accepts arbitrary strings. Always handle the unknown case.
|
|
1483
|
+
*/
|
|
1484
|
+
type RoutingManeuverType = "none" | "continue" | "slightLeftTurn" | "slightRightTurn" | "leftTurn" | "rightTurn" | "leftSharpTurn" | "rightSharpTurn" | "leftUTurn" | "rightUTurn" | "roundaboutEnter" | "roundaboutExit" | "start" | "destination" | (string & NonNullable<unknown>);
|
|
1485
|
+
/** Details of a single turn-by-turn step maneuver */
|
|
1486
|
+
interface RoutingRouteManeuver {
|
|
1487
|
+
/** Human-readable instruction */
|
|
1488
|
+
instruction?: string;
|
|
1489
|
+
/** Roundabout exit number */
|
|
1490
|
+
exitNumber?: number;
|
|
1491
|
+
/** Turn sharpness */
|
|
1492
|
+
turnAngle?: number;
|
|
1493
|
+
/** Maneuver type */
|
|
1494
|
+
type?: RoutingManeuverType;
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Get directions using POST request.
|
|
1498
|
+
*
|
|
1499
|
+
* Accepts the full request body. Use this over {@link directionsGet} when the
|
|
1500
|
+
* route needs `avoidLocations`, per-location `heading` or `waypoint`, or the
|
|
1501
|
+
* truck `length`.
|
|
1502
|
+
*/
|
|
1503
|
+
declare function directionsPost(body: RoutingRequest, options?: RoutingOptions): Promise<RoutingResponse>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Get directions using GET request.
|
|
1506
|
+
*
|
|
1507
|
+
* The GET endpoint supports fewer parameters than the POST one - see
|
|
1508
|
+
* {@link RoutingGetRequest} for what it leaves out.
|
|
1509
|
+
*/
|
|
1510
|
+
declare function directionsGet(req: RoutingGetRequest, options?: RoutingOptions): Promise<RoutingResponse>;
|
|
1511
|
+
/**
|
|
1512
|
+
* API client module for MapTiler Routing API
|
|
1513
|
+
*/
|
|
1514
|
+
declare const routing: {
|
|
1515
|
+
/**
|
|
1516
|
+
* Get directions using POST request
|
|
1517
|
+
*/
|
|
1518
|
+
directionsPost: typeof directionsPost;
|
|
1519
|
+
/**
|
|
1520
|
+
* Get directions using GET request
|
|
1521
|
+
*/
|
|
1522
|
+
directionsGet: typeof directionsGet;
|
|
1523
|
+
};
|
|
1524
|
+
|
|
1215
1525
|
type CoordinatesSearchOptions = {
|
|
1216
1526
|
/**
|
|
1217
1527
|
* Custom MapTiler Cloud API key to use instead of the one in global `config`
|
|
@@ -2697,4 +3007,4 @@ declare const misc: {
|
|
|
2697
3007
|
simplify: typeof simplify;
|
|
2698
3008
|
};
|
|
2699
3009
|
|
|
2700
|
-
export { type AutomaticStaticMapOptions, type BaseGeocodingOptions, type BoundedStaticMapOptions, type BufferToPixelDataFunction, type ByIdGeocodingOptions, type CenteredStaticMapOptions, ClientConfig, type CommonForwardAndReverseGeocodingOptions, type CoordinateExport, type CoordinateGrid, type CoordinateId, type CoordinateSearch, type CoordinateSearchResult, type CoordinateTransformResult, type CoordinateTransformation, type Coordinates, type CoordinatesSearchOptions, type CoordinatesTransformOptions, type DefaultTransformation, type ElevationAtOptions, type ElevationBatchOptions, type FeatureHierarchy, type FetchFunction, type GeocodingFeature, type GeocodingOptions, type GeocodingPlaceType, type GeocodingSearchResult, type GeolocationInfoOptions, type GeolocationResult, type GetDataOptions, ISOLanguage, Language, type LanguageGeocodingOptions, type LanguageInfo, MapStyle, type MapStylePreset, type MapStyleType, MapStyleVariant, NonISOLanguage, type PixelData, ReferenceMapStyle, type ReverseGeocodingOptions, ServiceError, type StaticMapBaseOptions, type StaticMapMarker, type TileJSON, type XYZ, areSameLanguages, bufferToPixelDataBrowser, canParsePixelData, circumferenceAtLatitude, config, coordinates, data, defaultReferenceStyleMap, elevation, expandMapStyle, geocoding, geolocation, getAutoLanguage, getBufferToPixelDataParser, getLanguageInfoFromCode, getLanguageInfoFromFlag, getLanguageInfoFromKey, getTileCache, isLanguageInfo, mapStylePresetList, math, misc, staticMaps, styleToStyle, toLanguageInfo };
|
|
3010
|
+
export { type AutomaticStaticMapOptions, type BaseGeocodingOptions, type BoundedStaticMapOptions, type BufferToPixelDataFunction, type ByIdGeocodingOptions, type CenteredStaticMapOptions, ClientConfig, type CommonForwardAndReverseGeocodingOptions, type CoordinateExport, type CoordinateGrid, type CoordinateId, type CoordinateSearch, type CoordinateSearchResult, type CoordinateTransformResult, type CoordinateTransformation, type Coordinates, type CoordinatesSearchOptions, type CoordinatesTransformOptions, type DefaultTransformation, type ElevationAtOptions, type ElevationBatchOptions, type FeatureHierarchy, type FetchFunction, type GeocodingFeature, type GeocodingOptions, type GeocodingPlaceType, type GeocodingSearchResult, type GeolocationInfoOptions, type GeolocationResult, type GetDataOptions, ISOLanguage, Language, type LanguageGeocodingOptions, type LanguageInfo, MapStyle, type MapStylePreset, type MapStyleType, MapStyleVariant, NonISOLanguage, type PixelData, ReferenceMapStyle, type ReverseGeocodingOptions, type RoutingAvoidances, type RoutingBBox, type RoutingBicycleOptions, type RoutingCarOptions, type RoutingDetailLevel, type RoutingDistanceUnit, type RoutingGetLocation, type RoutingGetRequest, type RoutingGetTruckOptions, type RoutingInstructionsLanguage, type RoutingLocation, type RoutingManeuverType, type RoutingOptions, type RoutingPedestrianOptions, type RoutingProfile, type RoutingProfileSelection, type RoutingRequest, type RoutingRequestBase, type RoutingResponse, type RoutingResponseOptions, type RoutingRoute, type RoutingRouteLeg, type RoutingRouteManeuver, type RoutingRouteStep, type RoutingSummary, type RoutingTruckOptions, ServiceError, type StaticMapBaseOptions, type StaticMapMarker, type TileJSON, type XYZ, areSameLanguages, bufferToPixelDataBrowser, canParsePixelData, circumferenceAtLatitude, config, coordinates, data, defaultReferenceStyleMap, elevation, expandMapStyle, geocoding, geolocation, getAutoLanguage, getBufferToPixelDataParser, getLanguageInfoFromCode, getLanguageInfoFromFlag, getLanguageInfoFromKey, getTileCache, isLanguageInfo, mapStylePresetList, math, misc, routing, staticMaps, styleToStyle, toLanguageInfo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import ke from"quick-lru";const we="api.maptiler.com",Pe="api.maptiler.eu";function be(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class Q{constructor(){this._apiKey="",this._fetch=be(),this._useEuEndpoints=!1,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}set useEuEndpoints(a){this._useEuEndpoints=a}get useEuEndpoints(){return this._useEuEndpoints}get apiHost(){return this._useEuEndpoints?Pe:we}get apiURL(){return`https://${this.apiHost}/`}}const g=new Q,Z={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}},X={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={...Z,...X};function ee(e,a=v){return e in a?a[e]:null}function I(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 C(){if(typeof navigator>"u"){const e=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];return I(e)??v.ENGLISH}return Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>I(e)).filter(e=>e)[0]??v.ENGLISH}function _(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=v){return _(e)?E(e.flag,a):typeof e!="string"?null:ee(e,a)||I(e,a)||E(e,a)||null}function Ne(e,a,t=v){const n=K(e,t),i=K(a,t);return n!==null&&i!==null&&n.flag===i.flag}async function u(e,a={}){if(g.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 g.fetch(e,a)}class m 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 k(e,a){const{adjustSearchParams:t,apiKey:n}=a;typeof t=="function"&&t(e),e.set("key",n??g.apiKey)}function w(e,a){const{language:t}=a;if(t===void 0)return;const n=(Array.isArray(t)?t:[t]).map(r=>$e(r)).filter(r=>r),i=Array.from(new Set(n)).join(",");e.set("language",i)}function $e(e){const a=e===v.AUTO.flag?C():typeof e=="string"?I(e):_(e)?e.flag===v.AUTO.flag?C():E(e.flag):null;return a?.geocoding?a.code:null}function H(e,a){const{limit:t,types:n,excludeTypes:i}=a;t!==void 0&&e.set("limit",String(t)),n!==void 0&&e.set("types",n.join(",")),i!==void 0&&e.set("excludeTypes",String(i))}function ae(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 Ve(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`,g.apiURL);k(t.searchParams,a),w(t.searchParams,a),H(t.searchParams,a),ae(t.searchParams,a);const n=await u(t.toString());if(!n.ok)throw new m(n,U[n.status]??"");return await n.json()}async function Oe(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`,g.apiURL);k(t.searchParams,a),w(t.searchParams,a),H(t.searchParams,a);const n=await u(t.toString());if(!n.ok)throw new m(n,U[n.status]??"");return await n.json()}async function Ce(e,a={}){const t=new URL(`geocoding/${e}.json`,g.apiURL);k(t.searchParams,a),w(t.searchParams,a);const n=await u(t.toString());if(!n.ok)throw new m(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`,g.apiURL);k(n.searchParams,a),w(n.searchParams,a),H(n.searchParams,a),ae(n.searchParams,a);const i=await u(n.toString());if(!i.ok)throw new m(i,U[i.status]??"");const r=await i.json();return e.length===1?[r]:r}const Ke={forward:Ve,reverse:Oe,byId:Ce,batch:_e},te={403:"Key is missing, invalid or restricted"};async function He(e={}){const a=new URL("geolocation/ip.json",g.apiURL);a.searchParams.set("key",e.apiKey??g.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 m(n,n.status in te?te[n.status]:"");return await n.json()}const je={info:He},P={403:"Key is missing, invalid or restricted"};async function Fe(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`,g.apiURL);t.searchParams.set("key",a.apiKey??g.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 m(i,i.status in P?P[i.status]:"");return await i.json()}async function xe(e,a={}){const t=(Array.isArray(e[0])?e:[e]).map(o=>`${o[0]},${o[1]}`).join(";"),n=new URL(`coordinates/transform/${t}.json`,g.apiURL);n.searchParams.set("key",a.apiKey??g.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 m(r,r.status in P?P[r.status]:"");return await r.json()}const Be={search:Fe,transform:xe},ne={403:"Key is missing, invalid or restricted"};async function Ge(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`,g.apiURL);t.searchParams.set("key",a.apiKey??g.apiKey);const n=t.toString(),i=await u(n);if(!i.ok)throw new m(i,i.status in ne?ne[i.status]:"");return await i.json()}const ze={get:Ge};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=`${g.apiURL}maps/${t[1]}/style.json`:i=`${g.apiURL}maps/${n}/style.json`,i}class j{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 F{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 We=[{referenceStyleID:"STREETS_V2",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2" is deprecated, use "streets-v4" instead'},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-dark" is deprecated, use "streets-v4-dark" instead'},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-light" is deprecated, use "streets-v4-light" instead'},{id:"streets-v2-night",name:"Night",variantType:"NIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-night" is deprecated, use "streets-v4-night" instead'},{id:"streets-v2-pastel",name:"Pastel",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:"AI",variantType:"AI",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR_V2",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",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:""}]}],re={STREETS:"STREETS_V4",BASIC:"BASIC_V2",BASE:"BASE_V4",LANDSCAPE:"LANDSCAPE_V4",AQUARELLE:"AQUARELLE_V4",SATELLITE:"SATELLITE_V4",WINTER:"WINTER_V4",HYBRID:"HYBRID_V4",OCEAN:"OCEAN_V4",OUTDOOR:"OUTDOOR_V4",TONER:"TONER_V2",TOPO:"TOPO_V4",OPENSTREETMAP:"OPENSTREETMAP_V2",DATAVIZ:"DATAVIZ_V4",BACKDROP:"BACKDROP_V4",VOYAGER:"VOYAGER_V2"},A=[...We];function qe(e,a){A.find(i=>i.referenceStyleID===e)&&console.warn(`Default reference style ${e} already exists, it will be overwritten...`);const t=A.find(i=>i.referenceStyleID===a);if(!t)throw new Error(`Versioned map style not found for reference style: ${a}`);const n={...t,referenceStyleID:e};A.push(n)}Object.entries(re).forEach(([e,a])=>{qe(e,a)});function Je(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 Ye(){const e={};for(let a=0;a<A.length;a+=1){const t=A[a],n=Je(new F(t.name,t.referenceStyleID));for(let i=0;i<t.variants.length;i+=1){const r=t.variants[i],o=new j(r.name,r.variantType,r.id,n,r.description,r.imageURL,r.deprecated);n.addVariant(o)}e[t.referenceStyleID]=n}return e}function b(e){if(!e)return oe[A[0].referenceStyleID].getDefaultVariant().getId();if(typeof e=="string"||e instanceof String)return e.trim().toLowerCase();if(e instanceof j)return e.getId();if(e instanceof F)return e.getDefaultVariant().getId()}const oe=Ye();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 Ze(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 d=Ze(e[s],e[a],e[t]);d>r&&(o=s,r=d)}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 Xe(e,a){const t=e.length-1,n=[e[0]];return x(e,0,t,a,n),n.push(e[t]),n}function ea(e,a){if(e.length<=2)return e;const t=a!==void 0?a*a:1;return Xe(e,t)}const se={extractLineStrings:Qe,simplify:ea};function B(e,a=!0){let t=`${e[0]},${e[1]}`;return e.length===3&&a&&(t+=`,${e[2]}`),t}function G(e,a=3e3){let t=e.map(r=>r.join(",")).join("|"),n=5e-6;const i=1e-5;for(;t.length>a;)t=se.simplify(e,n).map(r=>`${r[0]},${r[1]}`).join("|"),n+=i;return t}function aa(e,a,t={}){const n=b(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}`,g.apiURL);if("attribution"in t&&d.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let l="";const p="markerIcon"in t;p&&(l+=`icon:${t.markerIcon}|`),p&&"markerAnchor"in t&&(l+=`anchor:${t.markerAnchor}|`),p&&t.hiDPI&&(l+="scale:2|");const f=Array.isArray(t.markers[0])?t.markers:[t.markers];l+=f.map(y=>B(y,!p)).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 p=t.pathWidth/(t.hiDPI?2:1);l+=`width:${p.toString()}|`}l+=G(t.path),d.searchParams.set("path",l)}return d.searchParams.set("key",t.apiKey??g.apiKey),d.toString()}function ta(e,a={}){const t=b(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}`,g.apiURL);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 p=Array.isArray(a.markers[0])?a.markers:[a.markers];d+=p.map(f=>B(f,!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+=G(a.path),s.searchParams.set("path",d)}return s.searchParams.set("key",a.apiKey??g.apiKey),s.toString()}function na(e={}){if(!("markers"in e)&&!("path"in e))throw new Error("Automatic static maps require markers and/or path to be created.");const a=b(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}`,g.apiURL);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(p=>B(p,!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+=G(e.path),o.searchParams.set("path",s)}return o.searchParams.set("key",e.apiKey??g.apiKey),o.toString()}const ia={centered:aa,bounded:ta,automatic:na},N=63710088e-1,de=2*Math.PI*N,ce=85.0511287;function le(e){return(180+e)/360}function ge(e){return e=Math.max(Math.min(e,ce),-ce),(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function pe(e){const a=fe(e);return[le(a[0]),ge(a[1])]}function ue(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 ra(e){return[ue(e[0]),me(e[1])]}function z(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 oa(e){const a=Array(e.length);a[0]=0;const t=a.length;for(let n=1;n<t;n++)a[n]=z(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 he(e){return de*Math.cos(e*Math.PI/180)}function ve(e,a,t=!0){const n=2**a,i=[e[0]*n,e[1]*n];return t?[~~i[0],~~i[1]]:i}function sa(e,a,t=!0){const n=pe(e);return ve(n,a,t)}function S(e){return e*Math.PI/180}function W(e){return e*180/Math.PI}function da(e,a,t){const n=z(e,a),i=S(e[0]),r=S(e[1]),o=S(a[0]),s=S(a[1]),d=n/N,l=Math.sin((1-t)*d)/Math.sin(d),p=Math.sin(t*d)/Math.sin(d),f=l*Math.cos(r)*Math.cos(i)+p*Math.cos(s)*Math.cos(o),y=l*Math.cos(r)*Math.sin(i)+p*Math.cos(s)*Math.sin(o),R=l*Math.sin(r)+p*Math.sin(s),D=Math.atan2(R,Math.sqrt(f*f+y*y)),c=Math.atan2(y,f);return[W(c),W(D)]}const ye={EARTH_RADIUS:N,EARTH_CIRCUMFERENCE:de,longitudeToMercatorX:le,latitudeToMercatorY:ge,wgs84ToMercator:pe,mercatorXToLongitude:ue,mercatorYToLatitude:me,mercatorToWgs84:ra,haversineDistanceWgs84:z,wrapWgs84:fe,circumferenceAtLatitude:he,mercatorToTileIndex:ve,wgs84ToTileIndex:sa,toRadians:S,toDegrees:W,haversineIntermediateWgs84:da,haversineCumulatedDistanceWgs84:oa};let q=null;function Le(){return q||(q=new ke({maxSize:g.tileCacheSize})),q}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 Te(){if(g.bufferToPixelData)return g.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 J(){return!!g.bufferToPixelData||typeof window<"u"}const ca="terrain-rgb-v2",Y=50,la=1e3;let $=null,Re=null;const Ie={403:"Key is missing, invalid or restricted"};async function ga(e,a){e.length>la&&console.warn("Computing elevation for complex geometries is discouraged - simplify the geometry before proceeding");const t=Math.ceil(e.length/Y),n=Array.from({length:t},()=>null).map((r,o)=>{const s=o*Y,d=e.slice(s,s+Y).map(p=>p.join(",")).join(";"),l=new URL(`elevation/${d}.json`,g.apiURL);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 pa(e,a,t){if(!$||Re!==g.apiHost){const c=new URL(`tiles/${ca}/tiles.json`,g.apiURL);c.searchParams.set("key",a);const T=c.toString(),h=await u(T);if(h.ok)$=await h.json(),Re=g.apiHost;else throw new m(h,Ie[h.status]??"")}const n=Te(),i=$.tiles[0],r=Le(),o=$.maxzoom;let s=~~(t??o);(s>o||s<0)&&(s=o);const d=e.map(c=>ye.wgs84ToTileIndex(c,s,!1)),l=d.map(c=>[~~c[0],~~c[1]]).map(c=>`terrain_${s.toString()}_${c[0].toString()}_${c[1].toString()}`),p=Array.from(new Set(l.filter(c=>!r.has(c)))).map(c=>c.split("_").slice(1)),f=p.map(c=>i.replace("{x}",c[1].toString()).replace("{y}",c[2].toString()).replace("{z}",c[0].toString())).map(c=>u(c)),y=(await Promise.allSettled(f)).map(c=>c.status==="fulfilled"?c.value:null).filter(c=>c),R=y.filter(c=>!c.ok);if(y.length!==f.length)throw new Error("Some tiles could not be fetched.");if(R.length)throw new m(R[0],Ie[R[0].status]??"");const D=await Promise.all(y.map(c=>c.arrayBuffer()));if(!D.every(c=>c.byteLength>0))throw new Error("Some tiles are not available.");return(await Promise.all(D.map(c=>n(c)))).forEach((c,T)=>{const h=p[T],M=`terrain_${h[0].toString()}_${h[1].toString()}_${h[2].toString()}`;r.set(M,c)}),e.map((c,T)=>{const h=l[T],M=d[T],L=r.get(h),Se=Math.min(Math.round(L.width*(M[0]%1)),L.width-1),O=(Math.min(Math.round(L.height*(M[1]%1)),L.height-1)*L.width+Se)*L.components,De=L.pixels[O],Me=L.pixels[O+1],Ee=L.pixels[O+2],Ue=-1e4+(De*256*256+Me*256+Ee)*.1;return[c[0],c[1],~~(Ue*1e3)/1e3]})}async function ua(e,a={}){return(await V([e],a))[0]}async function V(e,a={}){if(e.length===0)return[];const t=a.apiKey??g.apiKey,n=a.computeOn==="client"?await pa(e,t,a.zoom):await ga(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;s+=1){let d=0;for(let l=0;l<i;l+=1){const p=r[s-o+l];d+=p}d/=i,n[s][2]=d}}return n}async function ma(e,a={}){if(e.type!=="LineString")throw new Error("The provided object is not a GeoJSON LineString");a.computeOn??(a.computeOn=J()?"client":"server");const t=structuredClone(e),n=await V(t.coordinates,a);return t.coordinates=n,t}async function fa(e,a={}){if(e.type!=="MultiLineString")throw new Error("The provided object is not a GeoJSON MultiLineString");a.computeOn??(a.computeOn=J()?"client":"server");const t=structuredClone(e),n=t.coordinates.map(d=>d.length),i=t.coordinates.flat(),r=await V(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 ha={at:ua,batch:V,fromLineString:ma,fromMultiLineString:fa};export{Q as ClientConfig,X as ISOLanguage,v as Language,oe as MapStyle,j as MapStyleVariant,Z as NonISOLanguage,F as ReferenceMapStyle,m as ServiceError,Ne as areSameLanguages,Ae as bufferToPixelDataBrowser,J as canParsePixelData,he as circumferenceAtLatitude,g as config,Be as coordinates,ze as data,re as defaultReferenceStyleMap,ha as elevation,ie as expandMapStyle,Ke as geocoding,je as geolocation,C as getAutoLanguage,Te as getBufferToPixelDataParser,I as getLanguageInfoFromCode,E as getLanguageInfoFromFlag,ee as getLanguageInfoFromKey,Le as getTileCache,_ as isLanguageInfo,A as mapStylePresetList,ye as math,se as misc,ia as staticMaps,b as styleToStyle,K as toLanguageInfo};
|
|
1
|
+
import be from"quick-lru";const Ne="api.maptiler.com",Oe="api.maptiler.eu";function Ve(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class Q{constructor(){this._apiKey="",this._fetch=Ve(),this._useEuEndpoints=!1,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}set useEuEndpoints(a){this._useEuEndpoints=a}get useEuEndpoints(){return this._useEuEndpoints}get apiHost(){return this._useEuEndpoints?Oe:Ne}get apiURL(){return`https://${this.apiHost}/`}}const g=new Q,Z={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}},X={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={...Z,...X};function ee(e,a=v){return e in a?a[e]:null}function R(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 C(){if(typeof navigator>"u"){const e=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];return R(e)??v.ENGLISH}return Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>R(e)).filter(e=>e)[0]??v.ENGLISH}function _(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=v){return _(e)?E(e.flag,a):typeof e!="string"?null:ee(e,a)||R(e,a)||E(e,a)||null}function Ce(e,a,t=v){const n=K(e,t),i=K(a,t);return n!==null&&i!==null&&n.flag===i.flag}async function m(e,a={}){if(g.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 g.fetch(e,a)}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 U={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function w(e,a){const{adjustSearchParams:t,apiKey:n}=a;typeof t=="function"&&t(e),e.set("key",n??g.apiKey)}function k(e,a){const{language:t}=a;if(t===void 0)return;const n=(Array.isArray(t)?t:[t]).map(r=>_e(r)).filter(r=>r),i=Array.from(new Set(n)).join(",");e.set("language",i)}function _e(e){const a=e===v.AUTO.flag?C():typeof e=="string"?R(e):_(e)?e.flag===v.AUTO.flag?C():E(e.flag):null;return a?.geocoding?a.code:null}function H(e,a){const{limit:t,types:n,excludeTypes:i}=a;t!==void 0&&e.set("limit",String(t)),n!==void 0&&e.set("types",n.join(",")),i!==void 0&&e.set("excludeTypes",String(i))}function ae(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`,g.apiURL);w(t.searchParams,a),k(t.searchParams,a),H(t.searchParams,a),ae(t.searchParams,a);const n=await m(t.toString());if(!n.ok)throw new f(n,U[n.status]??"");return await n.json()}async function He(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`,g.apiURL);w(t.searchParams,a),k(t.searchParams,a),H(t.searchParams,a);const n=await m(t.toString());if(!n.ok)throw new f(n,U[n.status]??"");return await n.json()}async function je(e,a={}){const t=new URL(`geocoding/${e}.json`,g.apiURL);w(t.searchParams,a),k(t.searchParams,a);const n=await m(t.toString());if(!n.ok)throw new f(n,U[n.status]??"");return await n.json()}async function xe(e,a={}){if(!e.length)return[];const t=e.map(o=>encodeURIComponent(o)).join(";"),n=new URL(`geocoding/${t}.json`,g.apiURL);w(n.searchParams,a),k(n.searchParams,a),H(n.searchParams,a),ae(n.searchParams,a);const i=await m(n.toString());if(!i.ok)throw new f(i,U[i.status]??"");const r=await i.json();return e.length===1?[r]:r}const Fe={forward:Ke,reverse:He,byId:je,batch:xe},te={403:"Key is missing, invalid or restricted"};async function Be(e={}){const a=new URL("geolocation/ip.json",g.apiURL);a.searchParams.set("key",e.apiKey??g.apiKey),"elevation"in e&&a.searchParams.set("elevation",e.elevation?"true":"false");const t=a.toString(),n=await m(t);if(!n.ok)throw new f(n,n.status in te?te[n.status]:"");return await n.json()}const Ge={info:Be};var ze=function(e,a){for(var t=Math.pow(10,a),n=e.length,i=new Array(Math.floor(e.length/2)),r=0,o=0,s=0,d=0;r<n;++d){var c=1,p=0,u=void 0;do u=e.charCodeAt(r++)-63-1,c+=u<<p,p+=5;while(u>=31);o+=c&1?~(c>>1):c>>1,c=1,p=0;do u=e.charCodeAt(r++)-63-1,c+=u<<p,p+=5;while(u>=31);s+=c&1?~(c>>1):c>>1,i[d]=[o/t,s/t]}return i.length=d,i};const We=6;function qe(e,a){for(const t of a)e.append("location",`${t.lon},${t.lat}`)}function Je(e,a){a&&(a.units!==void 0&&e.set("response.units",a.units),a.language!==void 0&&e.set("response.language",a.language),a.alternates!==void 0&&e.set("alternates",String(a.alternates)),a.additionalData?.detailLevel!==void 0&&e.set("response.additionalData.detailLevel",a.additionalData.detailLevel))}function ne(e,a){a.topSpeed!==void 0&&e.set("topSpeed",String(a.topSpeed));const{avoidances:t}=a;t&&(t.tolls!==void 0&&e.set("avoidances.tolls",String(t.tolls)),t.ferry!==void 0&&e.set("avoidances.ferry",String(t.ferry)),t.highway!==void 0&&e.set("avoidances.highway",String(t.highway)))}function Ye(e,a){switch(a.profile){case"car":{const t=a.profileOptions;if(!t)return;t.mode!==void 0&&e.set("car.mode",t.mode),ne(e,t);return}case"truck":{const t=a.profileOptions;if(!t)return;t.height!==void 0&&e.set("truck.height",String(t.height)),t.weight!==void 0&&e.set("truck.weight",String(t.weight)),t.axleLoad!==void 0&&e.set("truck.axleLoad",String(t.axleLoad)),t.hazmat!==void 0&&e.set("truck.hazmat",String(t.hazmat)),ne(e,t);return}case"bicycle":{const t=a.profileOptions;if(!t)return;t.type!==void 0&&e.set("bicycle.type",t.type),t.cyclingSpeed!==void 0&&e.set("bicycle.cyclingSpeed",String(t.cyclingSpeed));return}case"pedestrian":{const t=a.profileOptions;if(!t)return;t.walkingSpeed!==void 0&&e.set("pedestrian.walkingSpeed",String(t.walkingSpeed));return}}}function ie(e,a){const{adjustSearchParams:t,apiKey:n}=a;typeof t=="function"&&t(e),e.set("key",n??g.apiKey)}function Qe(e){return typeof e=="string"?ze(e,We).map(([a,t])=>[t,a]):e}function re(e){return{...e,legs:e.legs.map(a=>({...a,geometry:Qe(a.geometry)}))}}async function Ze(e){let a=null;try{a=await e.json()}catch{return""}return typeof a?.message=="string"?a.message:""}async function oe(e){if(!e.ok)throw new f(e,await Ze(e));const{route:a,alternates:t,...n}=await e.json(),i={...n,route:re(a)};return t&&(i.alternates=t.map(re)),i}async function Xe(e,a={}){const{fetchExtras:t}=a,n=new URL("routing/v1/directions",g.apiURL);ie(n.searchParams,a);const i=new Headers(t?.headers);i.set("content-type","application/json");const r=await m(n.toString(),{...t,method:"POST",headers:i,body:JSON.stringify(e)});return await oe(r)}async function ea(e,a={}){const{fetchExtras:t}=a,n=new URL("routing/v1/directions",g.apiURL),i=n.searchParams;i.set("profile",e.profile),e.id!==void 0&&i.set("id",e.id),e.departureTime!==void 0&&i.set("departureTime",e.departureTime),e.arrivalTime!==void 0&&i.set("arrivalTime",e.arrivalTime),qe(i,e.locations),Je(i,e.response),Ye(i,e),ie(i,a);const r=await m(n.toString(),{...t,method:"GET",body:null});return await oe(r)}const aa={directionsPost:Xe,directionsGet:ea},P={403:"Key is missing, invalid or restricted"};async function ta(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`,g.apiURL);t.searchParams.set("key",a.apiKey??g.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 m(n);if(!i.ok)throw new f(i,i.status in P?P[i.status]:"");return await i.json()}async function na(e,a={}){const t=(Array.isArray(e[0])?e:[e]).map(o=>`${o[0]},${o[1]}`).join(";"),n=new URL(`coordinates/transform/${t}.json`,g.apiURL);n.searchParams.set("key",a.apiKey??g.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 m(i);if(!r.ok)throw new f(r,r.status in P?P[r.status]:"");return await r.json()}const ia={search:ta,transform:na},se={403:"Key is missing, invalid or restricted"};async function ra(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`,g.apiURL);t.searchParams.set("key",a.apiKey??g.apiKey);const n=t.toString(),i=await m(n);if(!i.ok)throw new f(i,i.status in se?se[i.status]:"");return await i.json()}const oa={get:ra};function de(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=`${g.apiURL}maps/${t[1]}/style.json`:i=`${g.apiURL}maps/${n}/style.json`,i}class j{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 de(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 x{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 sa=[{referenceStyleID:"STREETS_V2",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2" is deprecated, use "streets-v4" instead'},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-dark" is deprecated, use "streets-v4-dark" instead'},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-light" is deprecated, use "streets-v4-light" instead'},{id:"streets-v2-night",name:"Night",variantType:"NIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-night" is deprecated, use "streets-v4-night" instead'},{id:"streets-v2-pastel",name:"Pastel",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:"AI",variantType:"AI",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR_V2",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",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:""}]}],ce={STREETS:"STREETS_V4",BASIC:"BASIC_V2",BASE:"BASE_V4",LANDSCAPE:"LANDSCAPE_V4",AQUARELLE:"AQUARELLE_V4",SATELLITE:"SATELLITE_V4",WINTER:"WINTER_V4",HYBRID:"HYBRID_V4",OCEAN:"OCEAN_V4",OUTDOOR:"OUTDOOR_V4",TONER:"TONER_V2",TOPO:"TOPO_V4",OPENSTREETMAP:"OPENSTREETMAP_V2",DATAVIZ:"DATAVIZ_V4",BACKDROP:"BACKDROP_V4",VOYAGER:"VOYAGER_V2"},A=[...sa];function da(e,a){A.find(i=>i.referenceStyleID===e)&&console.warn(`Default reference style ${e} already exists, it will be overwritten...`);const t=A.find(i=>i.referenceStyleID===a);if(!t)throw new Error(`Versioned map style not found for reference style: ${a}`);const n={...t,referenceStyleID:e};A.push(n)}Object.entries(ce).forEach(([e,a])=>{da(e,a)});function ca(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 la(){const e={};for(let a=0;a<A.length;a+=1){const t=A[a],n=ca(new x(t.name,t.referenceStyleID));for(let i=0;i<t.variants.length;i+=1){const r=t.variants[i],o=new j(r.name,r.variantType,r.id,n,r.description,r.imageURL,r.deprecated);n.addVariant(o)}e[t.referenceStyleID]=n}return e}function $(e){if(!e)return le[A[0].referenceStyleID].getDefaultVariant().getId();if(typeof e=="string"||e instanceof String)return e.trim().toLowerCase();if(e instanceof j)return e.getId();if(e instanceof x)return e.getDefaultVariant().getId()}const le=la();function ga(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 pa(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 F(e,a,t,n,i){let r=n,o;for(let s=a+1;s<t;s++){const d=pa(e[s],e[a],e[t]);d>r&&(o=s,r=d)}r>n&&(o-a>1&&F(e,a,o,n,i),i.push(e[o]),t-o>1&&F(e,o,t,n,i))}function ua(e,a){const t=e.length-1,n=[e[0]];return F(e,0,t,a,n),n.push(e[t]),n}function ma(e,a){if(e.length<=2)return e;const t=a!==void 0?a*a:1;return ua(e,t)}const ge={extractLineStrings:ga,simplify:ma};function B(e,a=!0){let t=`${e[0]},${e[1]}`;return e.length===3&&a&&(t+=`,${e[2]}`),t}function G(e,a=3e3){let t=e.map(r=>r.join(",")).join("|"),n=5e-6;const i=1e-5;for(;t.length>a;)t=ge.simplify(e,n).map(r=>`${r[0]},${r[1]}`).join("|"),n+=i;return t}function fa(e,a,t={}){const n=$(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}`,g.apiURL);if("attribution"in t&&d.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let c="";const p="markerIcon"in t;p&&(c+=`icon:${t.markerIcon}|`),p&&"markerAnchor"in t&&(c+=`anchor:${t.markerAnchor}|`),p&&t.hiDPI&&(c+="scale:2|");const u=Array.isArray(t.markers[0])?t.markers:[t.markers];c+=u.map(y=>B(y,!p)).join("|"),d.searchParams.set("markers",c)}if("path"in t){let c="";if(c+=`fill:${t.pathFillColor??"none"}|`,"pathStrokeColor"in t&&(c+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const p=t.pathWidth/(t.hiDPI?2:1);c+=`width:${p.toString()}|`}c+=G(t.path),d.searchParams.set("path",c)}return d.searchParams.set("key",t.apiKey??g.apiKey),d.toString()}function ha(e,a={}){const t=$(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}`,g.apiURL);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 c="markerIcon"in a;c&&(d+=`icon:${a.markerIcon}|`),c&&"markerAnchor"in a&&(d+=`anchor:${a.markerAnchor}|`),c&&a.hiDPI&&(d+="scale:2|");const p=Array.isArray(a.markers[0])?a.markers:[a.markers];d+=p.map(u=>B(u,!c)).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 c=a.pathWidth/(a.hiDPI?2:1);d+=`width:${c.toString()}|`}d+=G(a.path),s.searchParams.set("path",d)}return s.searchParams.set("key",a.apiKey??g.apiKey),s.toString()}function va(e={}){if(!("markers"in e)&&!("path"in e))throw new Error("Automatic static maps require markers and/or path to be created.");const a=$(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}`,g.apiURL);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 c=Array.isArray(e.markers[0])?e.markers:[e.markers];s+=c.map(p=>B(p,!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+=G(e.path),o.searchParams.set("path",s)}return o.searchParams.set("key",e.apiKey??g.apiKey),o.toString()}const ya={centered:fa,bounded:ha,automatic:va},b=63710088e-1,pe=2*Math.PI*b,ue=85.0511287;function me(e){return(180+e)/360}function fe(e){return e=Math.max(Math.min(e,ue),-ue),(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function he(e){const a=Le(e);return[me(a[0]),fe(a[1])]}function ve(e){return e*360-180}function ye(e){const a=180-e*360;return 360/Math.PI*Math.atan(Math.exp(a*Math.PI/180))-90}function La(e){return[ve(e[0]),ye(e[1])]}function z(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 Aa(e){const a=Array(e.length);a[0]=0;const t=a.length;for(let n=1;n<t;n++)a[n]=z(e[n-1],e[n])+a[n-1];return a}function Le(e){const a=e[0],t=e[1],n=360,i=((a+180)%n+n)%n-180;return[i===-180?180:i,t]}function Ae(e){return pe*Math.cos(e*Math.PI/180)}function Te(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=he(e);return Te(n,a,t)}function I(e){return e*Math.PI/180}function W(e){return e*180/Math.PI}function Sa(e,a,t){const n=z(e,a),i=I(e[0]),r=I(e[1]),o=I(a[0]),s=I(a[1]),d=n/b,c=Math.sin((1-t)*d)/Math.sin(d),p=Math.sin(t*d)/Math.sin(d),u=c*Math.cos(r)*Math.cos(i)+p*Math.cos(s)*Math.cos(o),y=c*Math.cos(r)*Math.sin(i)+p*Math.cos(s)*Math.sin(o),S=c*Math.sin(r)+p*Math.sin(s),D=Math.atan2(S,Math.sqrt(u*u+y*y)),l=Math.atan2(y,u);return[W(l),W(D)]}const Se={EARTH_RADIUS:b,EARTH_CIRCUMFERENCE:pe,longitudeToMercatorX:me,latitudeToMercatorY:fe,wgs84ToMercator:he,mercatorXToLongitude:ve,mercatorYToLatitude:ye,mercatorToWgs84:La,haversineDistanceWgs84:z,wrapWgs84:Le,circumferenceAtLatitude:Ae,mercatorToTileIndex:Te,wgs84ToTileIndex:Ta,toRadians:I,toDegrees:W,haversineIntermediateWgs84:Sa,haversineCumulatedDistanceWgs84:Aa};let q=null;function Re(){return q||(q=new be({maxSize:g.tileCacheSize})),q}async function Ie(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 De(){if(g.bufferToPixelData)return g.bufferToPixelData;if(typeof window<"u")return Ie;throw new Error("An image file buffer to pixel data parser is necessary. Specify it in `config.bufferToPixelData`")}function J(){return!!g.bufferToPixelData||typeof window<"u"}const Ra="terrain-rgb-v2",Y=50,Ia=1e3;let N=null,Me=null;const Ee={403:"Key is missing, invalid or restricted"};async function Da(e,a){e.length>Ia&&console.warn("Computing elevation for complex geometries is discouraged - simplify the geometry before proceeding");const t=Math.ceil(e.length/Y),n=Array.from({length:t},()=>null).map((r,o)=>{const s=o*Y,d=e.slice(s,s+Y).map(p=>p.join(",")).join(";"),c=new URL(`elevation/${d}.json`,g.apiURL);return c.searchParams.set("key",a),m(c.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 Ma(e,a,t){if(!N||Me!==g.apiHost){const l=new URL(`tiles/${Ra}/tiles.json`,g.apiURL);l.searchParams.set("key",a);const T=l.toString(),h=await m(T);if(h.ok)N=await h.json(),Me=g.apiHost;else throw new f(h,Ee[h.status]??"")}const n=De(),i=N.tiles[0],r=Re(),o=N.maxzoom;let s=~~(t??o);(s>o||s<0)&&(s=o);const d=e.map(l=>Se.wgs84ToTileIndex(l,s,!1)),c=d.map(l=>[~~l[0],~~l[1]]).map(l=>`terrain_${s.toString()}_${l[0].toString()}_${l[1].toString()}`),p=Array.from(new Set(c.filter(l=>!r.has(l)))).map(l=>l.split("_").slice(1)),u=p.map(l=>i.replace("{x}",l[1].toString()).replace("{y}",l[2].toString()).replace("{z}",l[0].toString())).map(l=>m(l)),y=(await Promise.allSettled(u)).map(l=>l.status==="fulfilled"?l.value:null).filter(l=>l),S=y.filter(l=>!l.ok);if(y.length!==u.length)throw new Error("Some tiles could not be fetched.");if(S.length)throw new f(S[0],Ee[S[0].status]??"");const D=await Promise.all(y.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,T)=>{const h=p[T],M=`terrain_${h[0].toString()}_${h[1].toString()}_${h[2].toString()}`;r.set(M,l)}),e.map((l,T)=>{const h=c[T],M=d[T],L=r.get(h),Ue=Math.min(Math.round(L.width*(M[0]%1)),L.width-1),V=(Math.min(Math.round(L.height*(M[1]%1)),L.height-1)*L.width+Ue)*L.components,we=L.pixels[V],ke=L.pixels[V+1],Pe=L.pixels[V+2],$e=-1e4+(we*256*256+ke*256+Pe)*.1;return[l[0],l[1],~~($e*1e3)/1e3]})}async function Ea(e,a={}){return(await O([e],a))[0]}async function O(e,a={}){if(e.length===0)return[];const t=a.apiKey??g.apiKey,n=a.computeOn==="client"?await Ma(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;s+=1){let d=0;for(let c=0;c<i;c+=1){const p=r[s-o+c];d+=p}d/=i,n[s][2]=d}}return n}async function Ua(e,a={}){if(e.type!=="LineString")throw new Error("The provided object is not a GeoJSON LineString");a.computeOn??(a.computeOn=J()?"client":"server");const t=structuredClone(e),n=await O(t.coordinates,a);return t.coordinates=n,t}async function wa(e,a={}){if(e.type!=="MultiLineString")throw new Error("The provided object is not a GeoJSON MultiLineString");a.computeOn??(a.computeOn=J()?"client":"server");const t=structuredClone(e),n=t.coordinates.map(d=>d.length),i=t.coordinates.flat(),r=await O(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 ka={at:Ea,batch:O,fromLineString:Ua,fromMultiLineString:wa};export{Q as ClientConfig,X as ISOLanguage,v as Language,le as MapStyle,j as MapStyleVariant,Z as NonISOLanguage,x as ReferenceMapStyle,f as ServiceError,Ce as areSameLanguages,Ie as bufferToPixelDataBrowser,J as canParsePixelData,Ae as circumferenceAtLatitude,g as config,ia as coordinates,oa as data,ce as defaultReferenceStyleMap,ka as elevation,de as expandMapStyle,Fe as geocoding,Ge as geolocation,C as getAutoLanguage,De as getBufferToPixelDataParser,R as getLanguageInfoFromCode,E as getLanguageInfoFromFlag,ee as getLanguageInfoFromKey,Re as getTileCache,_ as isLanguageInfo,A as mapStylePresetList,Se as math,ge as misc,aa as routing,ya as staticMaps,$ as styleToStyle,K as toLanguageInfo};
|