Socket
Socket
Sign inDemoInstall

@mapbox/search-js-core

Package Overview
Dependencies
Maintainers
28
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/search-js-core - npm Package Compare versions

Comparing version 1.0.0-beta.19 to 1.0.0-beta.20

dist/geocode-v6/constants.d.ts

2

dist/autofill/types.d.ts

@@ -32,3 +32,3 @@ import { LngLatBoundsLike } from '../LngLatBounds';

* A point accuracy metric for the returned address feature. Can be one of `rooftop`, `parcel`, `point`, `interpolated`, `intersection`, `street`.
* @see [Point accuracy for address features](https://docs.mapbox.com/api/search/geocoding/#point-accuracy-for-address-features)
* @see [Point accuracy for address features](https://docs.mapbox.com/api/search/geocoding-v6/#point-accuracy-for-address-features)
*/

@@ -35,0 +35,0 @@ accuracy?: string;

@@ -1,3 +0,3 @@

export declare const SEARCH_URL = "https://api.mapbox.com/geocoding/v5";
export declare const TEMP_URL: string;
export declare const PERMANENT_URL: string;
export declare const FORWARD_URL: string;
export declare const REVERSE_URL: string;
export declare const BATCH_URL: string;
import { LngLatLike } from '../LngLat';
import { LngLatBoundsLike } from '../LngLatBounds';
import { DataTypes, GeocodingFeature } from './types';
import { FeatureTypes, GeocodingFeature } from './types';
interface AccessTokenOptions {

@@ -42,8 +42,2 @@ /**

/**
* Specify whether the Geocoding API should attempt approximate, as well as exact, matching when performing searches.
*
* Defaults to true.
*/
fuzzyMatch: boolean;
/**
* An [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) that controls the language of the text supplied in responses, and also affects result scoring.

@@ -65,9 +59,5 @@ */

/**
* Specify whether to request additional metadata about the recommended navigation destination corresponding to the feature (`true`) or not (`false`, default). Only applicable for address features.
*/
routing: boolean;
/**
* Filter results to include only a subset (one or more) of the available feature types. Multiple options can be comma-separated.
*/
types: string | Set<DataTypes>;
types: string | Set<FeatureTypes>;
/**

@@ -77,15 +67,12 @@ * Available worldviews are: `cn`, `in`, `jp`, `us`. If a worldview is not set, `us` worldview boundaries will be returned.

worldview: string;
}
interface PermanentOptions {
/**
* Permanent geocodes are used for use cases that require storing
* position data. If 'true', the permanent endpoints will be used, which are
* billed separately.
* data indefinitely. If 'true', requests will be made with permanent enabled.
* Separate billing for permanent geocoding will apply.
*
* If you're interested in using {@link PermanentOptions#permanent}, contact
* If undefined or 'false', the geocoder will default to use temporary geocoding.
* Temporary geocoding results are not allowed to be cached.
*
* For questions related to permanent resource usage and billing, contact
* [Mapbox sales](https://www.mapbox.com/contact/sales/).
*
* It's important to speak with an Account Manager on the Sales team prior to making requests
* with {@link PermanentOptions#permanent} set to `true`, as unsuccessful requests
* made by an account that does not have access to the endpoint may be billable.
*/

@@ -95,3 +82,3 @@ permanent: boolean;

/**
* A `GeocodingResponse` object represents a returned data object from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding/#geocoding-response-object).
* A `GeocodingResponse` object represents a returned data object from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding-v6/#geocoding-response-object).
*

@@ -106,8 +93,2 @@ * @typedef GeocodingResponse

/**
* Forward geocodes: An array of space and punctuation-separated strings from the original query.
*
* Reverse geocodes: An array containing the coordinates being queried.
*/
query: string[];
/**
* The returned feature objects.

@@ -125,3 +106,3 @@ *

/**
* A `GeocodingCore` object is an application's main entrypoint to the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding/).
* A `GeocodingCore` object is an application's main entrypoint to the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding-v6/).
* The Geocoding API allows forward (location to coordinates) and reverse (coordinates to location) queries, enabled by corresponding

@@ -134,2 +115,4 @@ * methods from the `GeocodingCore` object.

* @class GeocodingCore
* @param {GeocodingOptions} [options]
* @param {string} [options.accessToken]
*

@@ -160,5 +143,5 @@ * @example

constructor(options?: Partial<AccessTokenOptions & GeocodingOptions>);
/** @section {Methods} */
/** @section {Programmatic search} */
/**
* {@link GeocodingCore#forward} allows you to look up a single location by name
* {@link GeocodingCore#forward} allows you to look up a feature by name
* and returns the feature(s) and corresponding geographic coordinates in [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) format.

@@ -195,3 +178,4 @@ *

*/
forward(searchText: string, optionsArg?: Partial<FetchOptions & GeocodingOptions & PermanentOptions>): Promise<GeocodingResponse>;
forward(searchText: string, // TODO: enable structured input alternative arguments (e.g. `searchText: string | StructuredInput`)
optionsArg?: Partial<FetchOptions & GeocodingOptions>): Promise<GeocodingResponse>;
/**

@@ -230,4 +214,33 @@ * {@link GeocodingCore#reverse} allows you to look up a single pair of coordinates and returns the

*/
reverse(lngLat: string | LngLatLike, optionsArg?: Partial<FetchOptions & GeocodingOptions & PermanentOptions>): Promise<GeocodingResponse>;
reverse(lngLat: string | LngLatLike, optionsArg?: Partial<FetchOptions & GeocodingOptions>): Promise<GeocodingResponse>;
/** @section {Interactive search} */
/**
* {@link GeocodingCore#suggest} is a managed endpoint for an interactive {@link SearchSession}, such as one operated
* through a web or React component. It accepts a search text string for either a {@link GeocodingCore#forward} or
* {@link GeocodingCore#reverse} geocoding query and returns a {@link GeocodingResponse} object.
*
* @param {String} searchText
* @param {GeocodingOptions} [optionsArg]
* @param {AbortSignal} [optionsArg.signal]
*
* @example
* ```typescript
* const result = await geocode.suggest('123 Main St');
* if (results.features.length === 0) return;
*
* const feature = results.features[0];
* doSomethingWithCoordinates(feature);
* ```
*/
suggest(searchText: string, optionsArg?: Partial<FetchOptions & GeocodingOptions>): Promise<GeocodingResponse>;
/**
* {@link GeocodingCore#retrieve} is a managed endpoint for an interactive {@link SearchSession}, such as one operated
* through a web or React component. It accepts a {@link GeocodingFeature} object and returns the same object. It is used
* in a SearchSession to respond to a user's selection of a feature suggestion. Unlike the Search Box API, the Geocoding API
* returns all feature data in the initial response, so this method does not perform any further data retrieval.
*
* @param {GeocodingFeature} suggestion
*/
retrieve(suggestion: GeocodingFeature): Promise<GeocodingFeature>;
}
export {};

@@ -1,16 +0,59 @@

import { LngLatLike } from '../LngLat';
import { LngLatBoundsLike } from '../LngLatBounds';
import { MatchCode } from '../types';
/**
* Geographic feature data types for the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding/).
* Geographic feature data types for the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding-v6/).
*
* @typedef DataTypes
* @see https://docs.mapbox.com/api/search/geocoding/#data-types
* @typedef FeatureTypes
* @see https://docs.mapbox.com/api/search/geocoding-v6/#geographic-feature-types
*/
export declare type DataTypes = 'country' | 'region' | 'postcode' | 'district' | 'place' | 'locality' | 'neighborhood' | 'address' | 'poi';
export declare type FeatureTypes = 'country' | 'region' | 'postcode' | 'district' | 'place' | 'locality' | 'neighborhood' | 'street' | 'block' | 'address' | 'secondary_address';
/**
* Routable point data for an address feature.
*
* @typedef RoutablePoint
*/
export interface RoutablePoint {
/**
* The name of the routable point.
*/
name: string;
/**
* The longitude of the routable point.
*/
longitude: number;
/**
* The latitude of the routable point.
*/
latitude: number;
}
/**
* Coordinate and accuracy data for a geographic feature.
*
* @typedef Coordinates
*/
export interface Coordinates {
/**
* The longitude of the feature.
*/
longitude: number;
/**
* The latitude of the feature.
*/
latitude: number;
/**
* A coordinate accuracy indicator for address features. Can be one of `rooftop`, `parcel`, `point`, `interpolated`, `approximate`.
* @see [Point accuracy for address features](https://docs.mapbox.com/api/search/geocoding-v6/#point-accuracy-for-address-features)
*/
accuracy?: string;
/**
* Routable point data for an address feature.
*/
routable_points?: RoutablePoint[];
}
/**
* Raw [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) feature properties
* from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding/).
* from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding-v6/).
*
* Reference:
* https://docs.mapbox.com/api/search/geocoding/#geocoding-response-object
* https://docs.mapbox.com/api/search/geocoding-v6/#geocoding-response-object
*

@@ -21,49 +64,115 @@ * @typedef GeocodingFeatureProperties

/**
* A point accuracy metric for the returned address feature. Can be one of `rooftop`, `parcel`, `point`, `interpolated`, `intersection`, `street`.
* @see [Point accuracy for address features](https://docs.mapbox.com/api/search/geocoding/#point-accuracy-for-address-features)
* Feature id. The `mapbox_id` uniquely identifies a feature in the Mapbox search database. Mapbox ID’s are accepted in requests to the Geocoding API as a forward search, and will return the feature corresponding to that id.
*/
accuracy?: string;
mapbox_id: string;
/**
* The full street address for the returned `poi` feature.
* A string describing the geographic type of the feature. See {@link FeatureTypes} for supported options.
*/
address?: string;
feature_type: string;
/**
* Comma-separated categories for the returned `poi` feature.
* Formatted string of the most granular geographical component of the feature. For example, for an address this will be the address number and street.
* For features known by multiple aliases, this field will represent the alias, if one is available, matching the queried text.
*/
category?: string;
name: string;
/**
* The name of a suggested [Maki](https://www.mapbox.com/maki-icons/) icon to visualize a `poi` feature based on its `category`.
* Similar to `name`, except this will always be the canonical or otherwise more common alias for the feature name. For example, searching for "America" will return "America" as the `name`, and "United States" as name_preferred.
*/
maki?: string;
name_preferred: string;
/**
* The [Wikidata](https://wikidata.org/) identifier for the returned feature.
* Formatted string of the feature context (e.g. `place` + `region` + `country` + `postcode` + `counry`). The part of the full feature name which comes after `name`.
*/
wikidata?: string;
place_formatted: string;
/**
* The [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country and [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) region code for the returned feature.
* The full feature text string, combining `name_preferred` and `place_formatted`.
*/
short_code?: string;
full_address: string;
/**
* Coordinate and accuracy data for a geographic feature.
*/
coordinates: Coordinates;
/**
* Object representing the hierarchy of encompassing parent features.
*/
context: Partial<GeocodingFeatureContext>;
/**
* A bounding box for the feature. This may be significantly
* larger than the geometry.
* This property is only provided with features of type `country`, `region`, `postcode`, `district`, `place`, `locality`, or `neighborhood`.
*/
bbox?: LngLatBoundsLike;
/**
* Match codes for each context component of an address, plus an overall match confidence. Provides an indication of how well each part of the address matched the query.
*/
match_code?: MatchCode;
}
/**
* Object representing one level of hierarcy among encompassing parent features for a given {@link GeocodingFeature}.
* Object representing the hierarchy of encompassing parent features for a given {@link GeocodingFeature}.
*
* @typedef GeocodingFeatureContext
*/
export declare type GeocodingFeatureContext = Partial<GeocodingFeatureProperties> & {
export declare type GeocodingFeatureContext = {
/**
* A feature ID in the format `{type}.{id}`.
* Address context component. Includes separate `address_number` and `street_name` properties.
*/
id: string;
address: GeocodingFeatureContextComponent;
/**
* A string representing the feature in the requested language, if specified.
* Street context component.
*/
text: string;
street: GeocodingFeatureContextComponent;
/**
* Neighborhood context component.
*/
neighborhood: GeocodingFeatureContextComponent;
/**
* Postcode context component.
*/
postcode: GeocodingFeatureContextComponent;
/**
* Locality context component.
*/
locality: GeocodingFeatureContextComponent;
/**
* Place context component.
*/
place: GeocodingFeatureContextComponent;
/**
* District context component.
*/
district: GeocodingFeatureContextComponent;
/**
* Region context component. If available, may include additional `region_code` and `region_code_full` properties.
*/
region: GeocodingFeatureContextComponent;
/**
* Country context component. Includes additional `country_code` and `country_code_alpha_3` properties.
* @see https://en.wikipedia.org/wiki/ISO_3166-1
*/
country: GeocodingFeatureContextComponent;
};
/**
* A `GeocodingFeature` object represents a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) feature result from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding/).
* Object representing one level of hierarcy among encompassing parent features for a given {@link GeocodingFeature}.
*
* @typedef GeocodingFeatureContextComponent
*/
export interface GeocodingFeatureContextComponent {
/**
* The unique Mapbox ID of the context feature.
*/
mapbox_id: string;
/**
* A string representing the feature in the requested language, if specified.
*/
name: string;
/**
* The [Wikidata](https://wikidata.org/) identifier for the returned feature.
*/
wikidata_id?: string;
}
/**
* A `GeocodingFeature` object represents a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) feature result from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding-v6/).
*
* **Legal terms:**
*
* Due to legal terms from our data sources, results from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding/) should come from the `permanentForward` & `permanentReverse`
* methods if the results are to be cached/stored in a customer database. Otherwise, results should be used ephemerally and not persisted.
* Due to legal terms from our data sources, results from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding-v6/) should use the `permanent=true` flag
* if the results are to be cached/stored in a customer database. Otherwise, results should be used ephemerally and not persisted.
*

@@ -81,54 +190,9 @@ * This permanent policy is consistent with the [Mapbox Terms of Service](https://www.mapbox.com/tos/) and failure to comply

* @typedef GeocodingFeature
* @see [Geocoding response object](https://docs.mapbox.com/api/search/geocoding/#geocoding-response-object)
* @see [Geocoding response object](https://docs.mapbox.com/api/search/geocoding-v6/#geocoding-response-object)
*/
export declare type GeocodingFeature = GeoJSON.Feature<GeoJSON.Point, GeocodingFeatureProperties> & {
/**
* A feature ID in the format `{type}.{id}` where `{type}` is the lowest hierarchy feature in the `place_type` field.
* Feature id. This property is named "id" to conform to the GeoJSON specification, but is the same id referred to as mapbox_id within the properties object.
*/
id: string;
/**
* An array of {@link DataTypes} describing the feature.
*/
place_type: string[];
/**
* Indicates how well the returned feature matches the user's query on a scale from `0` to `1`, with `1` meaning the result fully matches the query text.
*/
relevance: number;
/**
* The house number for the returned `address` feature.
*/
address?: string;
/**
* A string representing the feature in the requested language, if specified.
*/
text: string;
/**
* A string representing the feature in the requested language, if specified, and its full result hierarchy.
*/
place_name: string;
/**
* A string analogous to the text field that more closely matches the query than results in the specified language.
*/
matching_text?: string;
/**
* A string analogous to the `place_name` field that more closely matches the query than results in the specified language.
*/
matching_place_name?: string;
/**
* A string of the [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) of the query’s primary language.
*/
language?: string;
/**
* A bounding box for the feature. This may be significantly
* larger than the geometry.
*/
bbox?: LngLatBoundsLike;
/**
* The coordinates of the feature’s center in the form `[longitude,latitude]`.
*/
center: LngLatLike;
/**
* An array representing the hierarchy of encompassing parent features. Each parent feature may include any of the above properties.
*/
context: GeocodingFeatureContext[];
};

@@ -108,2 +108,3 @@ var __defProp = Object.defineProperty;

MatchCodeConfidence: () => MatchCodeConfidence,
MatchCodeType: () => MatchCodeType,
SearchBoxCore: () => SearchBoxCore,

@@ -605,7 +606,10 @@ SearchSession: () => SearchSession,

// src/geocode/constants.ts
var SEARCH_URL4 = `https://api.mapbox.com/geocoding/v5`;
var TEMP_URL = `${SEARCH_URL4}/mapbox.places`;
var PERMANENT_URL = `${SEARCH_URL4}/mapbox.places-permanent`;
var BASE_URL = `https://api.mapbox.com/search/geocode/v6`;
var FORWARD_URL = `${BASE_URL}/forward`;
var REVERSE_URL2 = `${BASE_URL}/reverse`;
var BATCH_URL = `${BASE_URL}/batch`;
// src/geocode/GeocodingCore.ts
var REVERSE_GEOCODE_COORD_REGEX = /^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)[ ]*$/;
var SPACES_OR_COMMA_REGEX = /[\s,]+/;
var _getQueryParams4, getQueryParams_fn4;

@@ -628,5 +632,6 @@ var GeocodingCore = class {

}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const baseUrl = options.permanent ? PERMANENT_URL : TEMP_URL;
const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}.json`);
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
q: searchText
});
const url = new URL(`${FORWARD_URL}`);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options);

@@ -651,6 +656,14 @@ const { fetch } = getFetch();

}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const searchText = typeof lngLat === "string" ? lngLat : LngLat.convert(lngLat).toArray().join(",");
const baseUrl = options.permanent ? PERMANENT_URL : TEMP_URL;
const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}.json`);
let lngLatObj;
if (typeof lngLat === "string") {
const [lng, lat] = lngLat.split(",");
lngLatObj = new LngLat(Number(lng), Number(lat));
} else {
lngLatObj = LngLat.convert(lngLat);
}
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
longitude: lngLatObj.lng,
latitude: lngLatObj.lat
});
const url = new URL(`${REVERSE_URL2}`);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options, true);

@@ -666,2 +679,18 @@ const { fetch } = getFetch();

}
suggest(searchText, optionsArg) {
return __async(this, null, function* () {
const isReverseQuery = REVERSE_GEOCODE_COORD_REGEX.test(searchText);
if (isReverseQuery) {
const coordinates = searchText.trim().split(SPACES_OR_COMMA_REGEX).map((part) => part.trim()).join(",");
return this.reverse(coordinates, optionsArg);
} else {
return this.forward(searchText, optionsArg);
}
});
}
retrieve(suggestion) {
return __async(this, null, function* () {
return suggestion;
});
}
};

@@ -671,3 +700,3 @@ _getQueryParams4 = new WeakSet();

if (isReverse) {
["proximity", "autocomplete", "fuzzyMatch", "bbox"].forEach((key) => {
["proximity", "autocomplete", "bbox"].forEach((key) => {
if (key in options) {

@@ -679,3 +708,7 @@ delete options[key];

return queryParams({
q: options.q,
longitude: options.longitude,
latitude: options.latitude,
access_token: this.accessToken,
permanent: options.permanent,
language: options.language,

@@ -685,4 +718,2 @@ country: options.country,

autocomplete: options.autocomplete,
fuzzyMatch: options.fuzzyMatch,
routing: options.routing,
worldview: options.worldview

@@ -699,2 +730,10 @@ }, options.proximity && {

// src/types.ts
var MatchCodeType = /* @__PURE__ */ ((MatchCodeType2) => {
MatchCodeType2["matched"] = "matched";
MatchCodeType2["unmatched"] = "unmatched";
MatchCodeType2["plausible"] = "plausible";
MatchCodeType2["not_applicable"] = "not_applicable";
MatchCodeType2["inferred"] = "inferred";
return MatchCodeType2;
})(MatchCodeType || {});
var MatchCodeConfidence = /* @__PURE__ */ ((MatchCodeConfidence2) => {

@@ -701,0 +740,0 @@ MatchCodeConfidence2["exact"] = "exact";

@@ -562,7 +562,10 @@ var __defProp = Object.defineProperty;

// src/geocode/constants.ts
var SEARCH_URL4 = `https://api.mapbox.com/geocoding/v5`;
var TEMP_URL = `${SEARCH_URL4}/mapbox.places`;
var PERMANENT_URL = `${SEARCH_URL4}/mapbox.places-permanent`;
var BASE_URL = `https://api.mapbox.com/search/geocode/v6`;
var FORWARD_URL = `${BASE_URL}/forward`;
var REVERSE_URL2 = `${BASE_URL}/reverse`;
var BATCH_URL = `${BASE_URL}/batch`;
// src/geocode/GeocodingCore.ts
var REVERSE_GEOCODE_COORD_REGEX = /^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)[ ]*$/;
var SPACES_OR_COMMA_REGEX = /[\s,]+/;
var _getQueryParams4, getQueryParams_fn4;

@@ -585,5 +588,6 @@ var GeocodingCore = class {

}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const baseUrl = options.permanent ? PERMANENT_URL : TEMP_URL;
const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}.json`);
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
q: searchText
});
const url = new URL(`${FORWARD_URL}`);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options);

@@ -608,6 +612,14 @@ const { fetch } = getFetch();

}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const searchText = typeof lngLat === "string" ? lngLat : LngLat.convert(lngLat).toArray().join(",");
const baseUrl = options.permanent ? PERMANENT_URL : TEMP_URL;
const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}.json`);
let lngLatObj;
if (typeof lngLat === "string") {
const [lng, lat] = lngLat.split(",");
lngLatObj = new LngLat(Number(lng), Number(lat));
} else {
lngLatObj = LngLat.convert(lngLat);
}
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
longitude: lngLatObj.lng,
latitude: lngLatObj.lat
});
const url = new URL(`${REVERSE_URL2}`);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options, true);

@@ -623,2 +635,18 @@ const { fetch } = getFetch();

}
suggest(searchText, optionsArg) {
return __async(this, null, function* () {
const isReverseQuery = REVERSE_GEOCODE_COORD_REGEX.test(searchText);
if (isReverseQuery) {
const coordinates = searchText.trim().split(SPACES_OR_COMMA_REGEX).map((part) => part.trim()).join(",");
return this.reverse(coordinates, optionsArg);
} else {
return this.forward(searchText, optionsArg);
}
});
}
retrieve(suggestion) {
return __async(this, null, function* () {
return suggestion;
});
}
};

@@ -628,3 +656,3 @@ _getQueryParams4 = new WeakSet();

if (isReverse) {
["proximity", "autocomplete", "fuzzyMatch", "bbox"].forEach((key) => {
["proximity", "autocomplete", "bbox"].forEach((key) => {
if (key in options) {

@@ -636,3 +664,7 @@ delete options[key];

return queryParams({
q: options.q,
longitude: options.longitude,
latitude: options.latitude,
access_token: this.accessToken,
permanent: options.permanent,
language: options.language,

@@ -642,4 +674,2 @@ country: options.country,

autocomplete: options.autocomplete,
fuzzyMatch: options.fuzzyMatch,
routing: options.routing,
worldview: options.worldview

@@ -656,2 +686,10 @@ }, options.proximity && {

// src/types.ts
var MatchCodeType = /* @__PURE__ */ ((MatchCodeType2) => {
MatchCodeType2["matched"] = "matched";
MatchCodeType2["unmatched"] = "unmatched";
MatchCodeType2["plausible"] = "plausible";
MatchCodeType2["not_applicable"] = "not_applicable";
MatchCodeType2["inferred"] = "inferred";
return MatchCodeType2;
})(MatchCodeType || {});
var MatchCodeConfidence = /* @__PURE__ */ ((MatchCodeConfidence2) => {

@@ -838,2 +876,3 @@ MatchCodeConfidence2["exact"] = "exact";

MatchCodeConfidence,
MatchCodeType,
SearchBoxCore,

@@ -840,0 +879,0 @@ SearchSession,

@@ -8,4 +8,4 @@ import { AddressAutofillOptions, AddressAutofillCore, AddressAutofillSuggestionResponse, AddressAutofillRetrieveResponse } from './autofill/AddressAutofillCore';

import { GeocodingOptions, GeocodingCore, GeocodingResponse } from './geocode/GeocodingCore';
import { GeocodingFeatureProperties, GeocodingFeatureContext, GeocodingFeature, DataTypes } from './geocode/types';
import { MatchCodeConfidence, MatchCode } from './types';
import { GeocodingFeatureProperties, GeocodingFeatureContext, GeocodingFeatureContextComponent, GeocodingFeature, FeatureTypes, Coordinates, RoutablePoint } from './geocode/types';
import { MatchCode, MatchCodeType, MatchCodeConfidence } from './types';
import { SearchSession } from './SearchSession';

@@ -20,2 +20,2 @@ import { SessionToken, SessionTokenLike } from './SessionToken';

import { debounce } from './utils/debounce';
export { SearchBoxOptions, SearchBoxCore, SearchBoxSuggestionResponse, SearchBoxRetrieveResponse, SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion, SearchBoxCategoryResponse, SearchBoxReverseResponse, SearchBoxCategorySuggestion, AddressAutofillOptions, AddressAutofillCore, AddressAutofillSuggestionResponse, AddressAutofillRetrieveResponse, AddressAutofillSuggestion, AddressAutofillFeatureSuggestion, MatchCode, MatchCodeConfidence, SearchSession, SessionToken, SessionTokenLike, MapboxError, LngLat, LngLatLike, LngLatBounds, LngLatBoundsLike, polyfillFetch, featureToSuggestion, Evented, debounce, ValidationOptions, ValidationCore, ValidationResponse, ValidationFeature, GeocodingOptions, GeocodingCore, GeocodingResponse, GeocodingFeatureProperties, GeocodingFeatureContext, GeocodingFeature, DataTypes, AddressAutofillOptions as AutofillOptions, AddressAutofillCore as MapboxAutofill, AddressAutofillSuggestionResponse as AutofillSuggestionResponse, AddressAutofillRetrieveResponse as AutofillRetrieveResponse, AddressAutofillSuggestion as AutofillSuggestion, AddressAutofillFeatureSuggestion as AutofillFeatureSuggestion, ValidationOptions as ValidateOptions, ValidationCore as MapboxValidate, ValidationResponse as ValidateResponse, ValidationFeature as ValidateFeature, GeocodingOptions as GeocodeOptions, GeocodingCore as MapboxGeocode, GeocodingResponse as GeocodeResponse, GeocodingFeatureProperties as GeocodeFeatureProperties, GeocodingFeatureContext as GeocodeFeatureContext, GeocodingFeature as GeocodeFeature };
export { SearchBoxOptions, SearchBoxCore, SearchBoxSuggestionResponse, SearchBoxRetrieveResponse, SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion, SearchBoxCategoryResponse, SearchBoxReverseResponse, SearchBoxCategorySuggestion, AddressAutofillOptions, AddressAutofillCore, AddressAutofillSuggestionResponse, AddressAutofillRetrieveResponse, AddressAutofillSuggestion, AddressAutofillFeatureSuggestion, MatchCode, MatchCodeType, MatchCodeConfidence, SearchSession, SessionToken, SessionTokenLike, MapboxError, LngLat, LngLatLike, LngLatBounds, LngLatBoundsLike, polyfillFetch, featureToSuggestion, Evented, debounce, ValidationOptions, ValidationCore, ValidationResponse, ValidationFeature, GeocodingOptions, GeocodingCore, GeocodingResponse, GeocodingFeatureProperties, GeocodingFeatureContext, GeocodingFeature, GeocodingFeatureContextComponent, FeatureTypes, Coordinates, RoutablePoint, AddressAutofillOptions as AutofillOptions, AddressAutofillCore as MapboxAutofill, AddressAutofillSuggestionResponse as AutofillSuggestionResponse, AddressAutofillRetrieveResponse as AutofillRetrieveResponse, AddressAutofillSuggestion as AutofillSuggestion, AddressAutofillFeatureSuggestion as AutofillFeatureSuggestion, ValidationOptions as ValidateOptions, ValidationCore as MapboxValidate, ValidationResponse as ValidateResponse, ValidationFeature as ValidateFeature, GeocodingOptions as GeocodeOptions, GeocodingCore as MapboxGeocode, GeocodingResponse as GeocodeResponse, GeocodingFeatureProperties as GeocodeFeatureProperties, GeocodingFeatureContext as GeocodeFeatureContext, GeocodingFeature as GeocodeFeature };

@@ -1,2 +0,2 @@

var U=Object.defineProperty,Le=Object.defineProperties,be=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var te=(o,e,t)=>e in o?U(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e)=>{for(var t in e||(e={}))M.call(e,t)&&te(o,t,e[t]);if(B)for(var t of B(e))re.call(e,t)&&te(o,t,e[t]);return o},x=(o,e)=>Le(o,ye(e)),Re=o=>U(o,"__esModule",{value:!0});var v=(o,e)=>{var t={};for(var r in o)M.call(o,r)&&e.indexOf(r)<0&&(t[r]=o[r]);if(o!=null&&B)for(var r of B(o))e.indexOf(r)<0&&re.call(o,r)&&(t[r]=o[r]);return t};var ke=(o,e)=>{for(var t in e)U(o,t,{get:e[t],enumerable:!0})},ve=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xe(e))!M.call(o,s)&&(t||s!=="default")&&U(o,s,{get:()=>e[s],enumerable:!(r=be(e,s))||r.enumerable});return o};var Te=(o=>(e,t)=>o&&o.get(e)||(t=ve(Re({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var K=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var L=(o,e,t)=>(K(o,e,"read from private field"),t?t.call(o):e.get(o)),d=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},A=(o,e,t,r)=>(K(o,e,"write to private field"),r?r.call(o,t):e.set(o,t),t);var R=(o,e,t)=>(K(o,e,"access private method"),t);var p=(o,e,t)=>new Promise((r,s)=>{var n=c=>{try{a(t.next(c))}catch(u){s(u)}},i=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,i);a((t=t.apply(o,e)).next())});var $e={};ke($e,{AddressAutofillCore:()=>$,Evented:()=>_,GeocodingCore:()=>J,LngLat:()=>l,LngLatBounds:()=>m,MapboxAutofill:()=>$,MapboxError:()=>j,MapboxGeocode:()=>J,MapboxValidate:()=>V,MatchCodeConfidence:()=>X,SearchBoxCore:()=>I,SearchSession:()=>ee,SessionToken:()=>f,ValidationCore:()=>V,debounce:()=>D,featureToSuggestion:()=>Se,polyfillFetch:()=>ge});var oe="https://api.mapbox.com/autofill/v1",Ae="suggest",we="retrieve",se=`${oe}/${Ae}`,ne=`${oe}/${we}`;var l=class{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90");if(this.lng>180||this.lng<-180)throw new Error("Invalid LngLat longitude value: must be between -180 and 180")}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}static convert(e){if(e instanceof l)return new l(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new l(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null&&("lng"in e||"lon"in e)&&"lat"in e)return new l(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};var m=class{constructor(e,t){this._sw=l.convert(e),this._ne=l.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new l(this.getWest(),this.getNorth())}getSouthEast(){return new l(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toFlatArray(){return[this._sw.lng,this._sw.lat,this._ne.lng,this._ne.lat]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}static convert(e){if(!e)throw new Error("Invalid LngLatBounds convert value: falsy");if(e instanceof m)return new m(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new m(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new m(l.convert([e[0],e[1]]),l.convert([e[2],e[3]]));throw new Error("`LngLatBoundsLike` argument must be specified as an array [<LngLatLike>, <LngLatLike>] or an array [<west>, <south>, <east>, <north>]")}};function ie(){let e=(Math.random().toString(16)+Date.now().toString(16)+Math.random().toString(16)).replace(/\./g,"");return[e.slice(0,8),e.slice(8,12),"4"+e.slice(12,15)+"-8"+e.slice(15,18),e.slice(18,30)].join("-")}var f=class{constructor(e){this.id=e!=null?e:ie()}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString())}};var Ee="Unknown error",j=class extends Error{constructor(e,t){super(String(e.message||e.error||Ee));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function S(o){return p(this,null,function*(){if(!o.ok){let e=yield o.json();throw new j(e,o.status)}})}var N=globalThis.fetch,ae=globalThis.AbortController;function ge({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");N&&!t||(N=o,ae=e)}function h(){if(!N)throw new Error("Fetch implementation not found. Please include a fetch polyfill in your application or use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:N,AbortController:ae}}function b(...o){let e=[];for(let t of o){if(!t)continue;let r=Object.entries(t);for(let[s,n]of r)n!=null&&e.push(`${s}=${encodeURIComponent(String(n))}`)}return e.join("&")}var C,Oe,z=class{constructor(e={}){d(this,C);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},z.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{sessionToken:r}),i=new URL(`${se}/${encodeURIComponent(e)}`);i.search=R(this,C,Oe).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return x(g({},u),{suggestions:u.suggestions.map(y=>x(g({},y),{original_search_text:e})),url:i.toString()})})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:r,signal:s}=t,n=f.convert(r),i=new URL(`${ne}/${e.action.id}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},$=z;C=new WeakSet,Oe=function(e){return b({types:"address",access_token:this.accessToken,streets:e.streets,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},$.defaults={language:"en",proximity:"ip",streets:!0};var G="https://api.mapbox.com/search/searchbox/v1",_e="suggest",Pe="retrieve",Fe="category",Be="reverse",ce=`${G}/${_e}`,ue=`${G}/${Pe}`,le=`${G}/${Fe}`,pe=`${G}/${Be}`;var E,me,Q=class{constructor(e={}){d(this,E);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Q.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{q:e,sessionToken:r});if(n.eta_type&&(!n.origin||!n.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(n.origin&&!n.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(ce);i.search=R(this,E,me).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");let{sessionToken:r,signal:s}=t,n=f.convert(r),i=new URL(`${ue}/${encodeURIComponent(e.mapbox_id)}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}category(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("category is required");let s=g(g({},this.defaults),t),n=new URL(`${le}/${encodeURIComponent(e)}`);n.search=R(this,E,me).call(this,s);let{fetch:i}=h(),a=yield i(n.toString(),{signal:s.signal});yield S(a);let c=yield a.json();return c.url=n.toString(),c})}reverse(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let[s,n]=typeof e=="string"?e.split(",").map(F=>parseFloat(F)):l.convert(e).toArray();if(isNaN(s)||isNaN(n))throw new Error("lngLat is required");let i=g(g({},this.defaults),t),a=new URL(pe);a.search=b({access_token:this.accessToken,language:i.language,limit:i.limit,longitude:s,latitude:n},i.types&&{types:typeof i.types=="string"?i.types:[...i.types].join(",")});let{fetch:c}=h(),u=yield c(a.toString(),{signal:i.signal});yield S(u);let y=yield u.json();return y.url=a.toString(),y})}},I=Q;E=new WeakSet,me=function(e){return b({q:e.q,access_token:this.accessToken,language:e.language,limit:e.limit,navigation_profile:e.navigation_profile,route:e.route,route_geometry:e.route_geometry,sar_type:e.sar_type,time_deviation:e.time_deviation,eta_type:e.eta_type,country:e.country,poi_category:e.poi_category,radius:e.radius,user_id:e.user_id,rich_metadata_provider:e.rich_metadata_provider,poi_category_exclusions:e.poi_category_exclusions},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.origin&&{origin:typeof e.origin=="string"?e.origin:l.convert(e.origin).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},I.defaults={language:"en"};var Ue="https://api.mapbox.com/autofill/v1",je="retrieve",fe=`${Ue}/${je}`;var q,Ne,W=class{constructor(e={}){d(this,q);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},W.defaults),r)}validate(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{sessionToken:r}),i=new URL(`${fe}/${encodeURIComponent(e)}`);i.search=R(this,q,Ne).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},V=W;q=new WeakSet,Ne=function(e){return b({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},V.defaults={language:"en",proximity:"ip"};var he="https://api.mapbox.com/geocoding/v5",H=`${he}/mapbox.places`,Y=`${he}/mapbox.places-permanent`;var O,de,J=class{constructor(e={}){d(this,O);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g({},r)}forward(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let r;t&&({signal:r}=t);let s=g(g({},this.defaults),t),n=s.permanent?Y:H,i=new URL(`${n}/${encodeURIComponent(e)}.json`);i.search=R(this,O,de).call(this,s);let{fetch:a}=h(),c=r?{signal:r}:{},u=yield a(i.toString(),c);yield S(u);let y=yield u.json();return y.url=i.toString(),y})}reverse(e,t){return p(this,null,function*(){if(!e)throw new Error("lngLat is required");let r;t&&({signal:r}=t);let s=g(g({},this.defaults),t),n=typeof e=="string"?e:l.convert(e).toArray().join(","),i=s.permanent?Y:H,a=new URL(`${i}/${encodeURIComponent(n)}.json`);a.search=R(this,O,de).call(this,s,!0);let{fetch:c}=h(),u=r?{signal:r}:{},y=yield c(a.toString(),u);yield S(y);let F=yield y.json();return F.url=a.toString(),F})}};O=new WeakSet,de=function(e,t=!1){return t&&["proximity","autocomplete","fuzzyMatch","bbox"].forEach(r=>{r in e&&delete e[r]}),b({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,autocomplete:e.autocomplete,fuzzyMatch:e.fuzzyMatch,routing:e.routing,worldview:e.worldview},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var X=(s=>(s.exact="exact",s.high="high",s.medium="medium",s.low="low",s))(X||{});var w,_=class{constructor(){d(this,w,{})}addEventListener(e,t){let r=L(this,w);r[e]||(r[e]=[]),r[e].push(t)}removeEventListener(e,t){let r=L(this,w);if(!r[e])return;let s=r[e],n=s.indexOf(t);n!==-1&&s.splice(n,1)}fire(e,t){let r=L(this,w);if(!r[e])return;let s=r[e];for(let n of s)n(t)}};w=new WeakMap;function D(o,e,t){let r=null;return(...s)=>{r!==null&&clearTimeout(r);let n=t&&t();r=setTimeout(()=>{r=null,!(n==null?void 0:n.aborted)&&o(...s)},e)}}function Z(){let{AbortController:o}=h();return new o}var T,k,P,ee=class extends _{constructor(e,t=0){super();this.sessionToken=new f;d(this,T,void 0);d(this,k,Z());d(this,P,void 0);A(this,P,D((n,...i)=>p(this,[n,...i],function*(r,s={}){if(L(this,k).abort(),A(this,k,Z()),!r){A(this,T,null),this.fire("suggest",L(this,T));return}try{let a=yield this.search.suggest(r,x(g({sessionToken:this.sessionToken},s),{signal:L(this,k).signal}));A(this,T,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>L(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return L(this,T)}suggest(e,t){return L(this,P).call(this,e,t),new Promise((r,s)=>{let n,i;n=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),r(a)},i=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),s(a)},this.addEventListener("suggest",n),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return p(this,null,function*(){let r=yield this.search.retrieve(e,g({sessionToken:this.sessionToken},t));return this.fire("retrieve",r),r})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){L(this,k).abort(),A(this,k,Z())}};T=new WeakMap,k=new WeakMap,P=new WeakMap;function Se(o){let{properties:e}=o;return g({},e)}module.exports=Te($e);
var B=Object.defineProperty,be=Object.defineProperties,xe=Object.getOwnPropertyDescriptor,Re=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var te=(o,e,t)=>e in o?B(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,c=(o,e)=>{for(var t in e||(e={}))M.call(e,t)&&te(o,t,e[t]);if(P)for(var t of P(e))re.call(e,t)&&te(o,t,e[t]);return o},S=(o,e)=>be(o,Re(e)),ve=o=>B(o,"__esModule",{value:!0});var k=(o,e)=>{var t={};for(var r in o)M.call(o,r)&&e.indexOf(r)<0&&(t[r]=o[r]);if(o!=null&&P)for(var r of P(o))e.indexOf(r)<0&&re.call(o,r)&&(t[r]=o[r]);return t};var Te=(o,e)=>{for(var t in e)B(o,t,{get:e[t],enumerable:!0})},Ae=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ke(e))!M.call(o,s)&&(t||s!=="default")&&B(o,s,{get:()=>e[s],enumerable:!(r=xe(e,s))||r.enumerable});return o};var we=(o=>(e,t)=>o&&o.get(e)||(t=Ae(ve({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var K=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var y=(o,e,t)=>(K(o,e,"read from private field"),t?t.call(o):e.get(o)),h=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},A=(o,e,t,r)=>(K(o,e,"write to private field"),r?r.call(o,t):e.set(o,t),t);var x=(o,e,t)=>(K(o,e,"access private method"),t);var p=(o,e,t)=>new Promise((r,s)=>{var n=g=>{try{a(t.next(g))}catch(u){s(u)}},i=g=>{try{a(t.throw(g))}catch(u){s(u)}},a=g=>g.done?r(g.value):Promise.resolve(g.value).then(n,i);a((t=t.apply(o,e)).next())});var Ve={};Te(Ve,{AddressAutofillCore:()=>G,Evented:()=>_,GeocodingCore:()=>X,LngLat:()=>l,LngLatBounds:()=>m,MapboxAutofill:()=>G,MapboxError:()=>U,MapboxGeocode:()=>X,MapboxValidate:()=>I,MatchCodeConfidence:()=>J,MatchCodeType:()=>z,SearchBoxCore:()=>N,SearchSession:()=>ee,SessionToken:()=>d,ValidationCore:()=>I,debounce:()=>q,featureToSuggestion:()=>Le,polyfillFetch:()=>ge});var oe="https://api.mapbox.com/autofill/v1",Ee="suggest",Oe="retrieve",se=`${oe}/${Ee}`,ne=`${oe}/${Oe}`;var l=class{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90");if(this.lng>180||this.lng<-180)throw new Error("Invalid LngLat longitude value: must be between -180 and 180")}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}static convert(e){if(e instanceof l)return new l(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new l(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null&&("lng"in e||"lon"in e)&&"lat"in e)return new l(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};var m=class{constructor(e,t){this._sw=l.convert(e),this._ne=l.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new l(this.getWest(),this.getNorth())}getSouthEast(){return new l(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toFlatArray(){return[this._sw.lng,this._sw.lat,this._ne.lng,this._ne.lat]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}static convert(e){if(!e)throw new Error("Invalid LngLatBounds convert value: falsy");if(e instanceof m)return new m(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new m(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new m(l.convert([e[0],e[1]]),l.convert([e[2],e[3]]));throw new Error("`LngLatBoundsLike` argument must be specified as an array [<LngLatLike>, <LngLatLike>] or an array [<west>, <south>, <east>, <north>]")}};function ie(){let e=(Math.random().toString(16)+Date.now().toString(16)+Math.random().toString(16)).replace(/\./g,"");return[e.slice(0,8),e.slice(8,12),"4"+e.slice(12,15)+"-8"+e.slice(15,18),e.slice(18,30)].join("-")}var d=class{constructor(e){this.id=e!=null?e:ie()}toString(){return this.id}static convert(e){return new d(e instanceof d?e.id:e.toString())}};var _e="Unknown error",U=class extends Error{constructor(e,t){super(String(e.message||e.error||_e));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function L(o){return p(this,null,function*(){if(!o.ok){let e=yield o.json();throw new U(e,o.status)}})}var C=globalThis.fetch,ae=globalThis.AbortController;function ge({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");C&&!t||(C=o,ae=e)}function f(){if(!C)throw new Error("Fetch implementation not found. Please include a fetch polyfill in your application or use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:C,AbortController:ae}}function b(...o){let e=[];for(let t of o){if(!t)continue;let r=Object.entries(t);for(let[s,n]of r)n!=null&&e.push(`${s}=${encodeURIComponent(String(n))}`)}return e.join("&")}var j,Fe,Q=class{constructor(e={}){h(this,j);let s=e,{accessToken:t}=s,r=k(s,["accessToken"]);this.accessToken=t,this.defaults=c(c({},Q.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=S(c(c({},this.defaults),t),{sessionToken:r}),i=new URL(`${se}/${encodeURIComponent(e)}`);i.search=x(this,j,Fe).call(this,n);let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return S(c({},u),{suggestions:u.suggestions.map(v=>S(c({},v),{original_search_text:e})),url:i.toString()})})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:r,signal:s}=t,n=d.convert(r),i=new URL(`${ne}/${e.action.id}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return u.url=i.toString(),u})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},G=Q;j=new WeakSet,Fe=function(e){return b({types:"address",access_token:this.accessToken,streets:e.streets,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:d.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},G.defaults={language:"en",proximity:"ip",streets:!0};var $="https://api.mapbox.com/search/searchbox/v1",Pe="suggest",Be="retrieve",Ue="category",Ce="reverse",ce=`${$}/${Pe}`,ue=`${$}/${Be}`,le=`${$}/${Ue}`,pe=`${$}/${Ce}`;var E,me,W=class{constructor(e={}){h(this,E);let s=e,{accessToken:t}=s,r=k(s,["accessToken"]);this.accessToken=t,this.defaults=c(c({},W.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=S(c(c({},this.defaults),t),{q:e,sessionToken:r});if(n.eta_type&&(!n.origin||!n.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(n.origin&&!n.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(ce);i.search=x(this,E,me).call(this,n);let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return u.url=i.toString(),u})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");let{sessionToken:r,signal:s}=t,n=d.convert(r),i=new URL(`${ue}/${encodeURIComponent(e.mapbox_id)}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return u.url=i.toString(),u})}category(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("category is required");let s=c(c({},this.defaults),t),n=new URL(`${le}/${encodeURIComponent(e)}`);n.search=x(this,E,me).call(this,s);let{fetch:i}=f(),a=yield i(n.toString(),{signal:s.signal});yield L(a);let g=yield a.json();return g.url=n.toString(),g})}reverse(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let[s,n]=typeof e=="string"?e.split(",").map(D=>parseFloat(D)):l.convert(e).toArray();if(isNaN(s)||isNaN(n))throw new Error("lngLat is required");let i=c(c({},this.defaults),t),a=new URL(pe);a.search=b({access_token:this.accessToken,language:i.language,limit:i.limit,longitude:s,latitude:n},i.types&&{types:typeof i.types=="string"?i.types:[...i.types].join(",")});let{fetch:g}=f(),u=yield g(a.toString(),{signal:i.signal});yield L(u);let v=yield u.json();return v.url=a.toString(),v})}},N=W;E=new WeakSet,me=function(e){return b({q:e.q,access_token:this.accessToken,language:e.language,limit:e.limit,navigation_profile:e.navigation_profile,route:e.route,route_geometry:e.route_geometry,sar_type:e.sar_type,time_deviation:e.time_deviation,eta_type:e.eta_type,country:e.country,poi_category:e.poi_category,radius:e.radius,user_id:e.user_id,rich_metadata_provider:e.rich_metadata_provider,poi_category_exclusions:e.poi_category_exclusions},e.sessionToken&&{session_token:d.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.origin&&{origin:typeof e.origin=="string"?e.origin:l.convert(e.origin).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},N.defaults={language:"en"};var Ge="https://api.mapbox.com/autofill/v1",je="retrieve",de=`${Ge}/${je}`;var V,$e,H=class{constructor(e={}){h(this,V);let s=e,{accessToken:t}=s,r=k(s,["accessToken"]);this.accessToken=t,this.defaults=c(c({},H.defaults),r)}validate(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=S(c(c({},this.defaults),t),{sessionToken:r}),i=new URL(`${de}/${encodeURIComponent(e)}`);i.search=x(this,V,$e).call(this,n);let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},I=H;V=new WeakSet,$e=function(e){return b({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:d.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},I.defaults={language:"en",proximity:"ip"};var Y="https://api.mapbox.com/search/geocode/v6",fe=`${Y}/forward`,he=`${Y}/reverse`,Ct=`${Y}/batch`;var Ne=/^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)[ ]*$/,Ie=/[\s,]+/,O,Se,X=class{constructor(e={}){h(this,O);let s=e,{accessToken:t}=s,r=k(s,["accessToken"]);this.accessToken=t,this.defaults=c({},r)}forward(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let r;t&&({signal:r}=t);let s=S(c(c({},this.defaults),t),{q:e}),n=new URL(`${fe}`);n.search=x(this,O,Se).call(this,s);let{fetch:i}=f(),a=r?{signal:r}:{},g=yield i(n.toString(),a);yield L(g);let u=yield g.json();return u.url=n.toString(),u})}reverse(e,t){return p(this,null,function*(){if(!e)throw new Error("lngLat is required");let r;t&&({signal:r}=t);let s;if(typeof e=="string"){let[D,ye]=e.split(",");s=new l(Number(D),Number(ye))}else s=l.convert(e);let n=S(c(c({},this.defaults),t),{longitude:s.lng,latitude:s.lat}),i=new URL(`${he}`);i.search=x(this,O,Se).call(this,n,!0);let{fetch:a}=f(),g=r?{signal:r}:{},u=yield a(i.toString(),g);yield L(u);let v=yield u.json();return v.url=i.toString(),v})}suggest(e,t){return p(this,null,function*(){if(Ne.test(e)){let s=e.trim().split(Ie).map(n=>n.trim()).join(",");return this.reverse(s,t)}else return this.forward(e,t)})}retrieve(e){return p(this,null,function*(){return e})}};O=new WeakSet,Se=function(e,t=!1){return t&&["proximity","autocomplete","bbox"].forEach(r=>{r in e&&delete e[r]}),b({q:e.q,longitude:e.longitude,latitude:e.latitude,access_token:this.accessToken,permanent:e.permanent,language:e.language,country:e.country,limit:e.limit,autocomplete:e.autocomplete,worldview:e.worldview},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var z=(n=>(n.matched="matched",n.unmatched="unmatched",n.plausible="plausible",n.not_applicable="not_applicable",n.inferred="inferred",n))(z||{}),J=(s=>(s.exact="exact",s.high="high",s.medium="medium",s.low="low",s))(J||{});var w,_=class{constructor(){h(this,w,{})}addEventListener(e,t){let r=y(this,w);r[e]||(r[e]=[]),r[e].push(t)}removeEventListener(e,t){let r=y(this,w);if(!r[e])return;let s=r[e],n=s.indexOf(t);n!==-1&&s.splice(n,1)}fire(e,t){let r=y(this,w);if(!r[e])return;let s=r[e];for(let n of s)n(t)}};w=new WeakMap;function q(o,e,t){let r=null;return(...s)=>{r!==null&&clearTimeout(r);let n=t&&t();r=setTimeout(()=>{r=null,!(n==null?void 0:n.aborted)&&o(...s)},e)}}function Z(){let{AbortController:o}=f();return new o}var T,R,F,ee=class extends _{constructor(e,t=0){super();this.sessionToken=new d;h(this,T,void 0);h(this,R,Z());h(this,F,void 0);A(this,F,q((n,...i)=>p(this,[n,...i],function*(r,s={}){if(y(this,R).abort(),A(this,R,Z()),!r){A(this,T,null),this.fire("suggest",y(this,T));return}try{let a=yield this.search.suggest(r,S(c({sessionToken:this.sessionToken},s),{signal:y(this,R).signal}));A(this,T,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>y(this,R).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return y(this,T)}suggest(e,t){return y(this,F).call(this,e,t),new Promise((r,s)=>{let n,i;n=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),r(a)},i=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),s(a)},this.addEventListener("suggest",n),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return p(this,null,function*(){let r=yield this.search.retrieve(e,c({sessionToken:this.sessionToken},t));return this.fire("retrieve",r),r})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){y(this,R).abort(),A(this,R,Z())}};T=new WeakMap,R=new WeakMap,F=new WeakMap;function Le(o){let{properties:e}=o;return c({},e)}module.exports=we(Ve);
//# sourceMappingURL=index.js.map

@@ -7,3 +7,3 @@ export declare const UNKNOWN_ERROR = "Unknown error";

* - [SearchBoxCore](https://docs.mapbox.com/api/search/search-box/#search-box-api-errors)
* - [AddressAutofillCore](https://docs.mapbox.com/api/search/geocoding/#geocoding-api-errors)
* - [AddressAutofillCore](https://docs.mapbox.com/api/search/geocoding-v6/#geocoding-api-errors)
*/

@@ -10,0 +10,0 @@ export declare class MapboxError extends Error {

@@ -1,2 +0,2 @@

var mapboxsearchcore=(()=>{var U=Object.defineProperty,Le=Object.defineProperties,be=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var te=(o,e,t)=>e in o?U(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e)=>{for(var t in e||(e={}))M.call(e,t)&&te(o,t,e[t]);if(B)for(var t of B(e))re.call(e,t)&&te(o,t,e[t]);return o},x=(o,e)=>Le(o,ye(e)),Re=o=>U(o,"__esModule",{value:!0});var v=(o,e)=>{var t={};for(var r in o)M.call(o,r)&&e.indexOf(r)<0&&(t[r]=o[r]);if(o!=null&&B)for(var r of B(o))e.indexOf(r)<0&&re.call(o,r)&&(t[r]=o[r]);return t};var ke=(o,e)=>{for(var t in e)U(o,t,{get:e[t],enumerable:!0})},ve=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xe(e))!M.call(o,s)&&(t||s!=="default")&&U(o,s,{get:()=>e[s],enumerable:!(r=be(e,s))||r.enumerable});return o};var Te=(o=>(e,t)=>o&&o.get(e)||(t=ve(Re({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var K=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var L=(o,e,t)=>(K(o,e,"read from private field"),t?t.call(o):e.get(o)),d=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},A=(o,e,t,r)=>(K(o,e,"write to private field"),r?r.call(o,t):e.set(o,t),t);var R=(o,e,t)=>(K(o,e,"access private method"),t);var p=(o,e,t)=>new Promise((r,s)=>{var n=c=>{try{a(t.next(c))}catch(u){s(u)}},i=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,i);a((t=t.apply(o,e)).next())});var $e={};ke($e,{AddressAutofillCore:()=>$,Evented:()=>_,GeocodingCore:()=>J,LngLat:()=>l,LngLatBounds:()=>m,MapboxAutofill:()=>$,MapboxError:()=>j,MapboxGeocode:()=>J,MapboxValidate:()=>V,MatchCodeConfidence:()=>X,SearchBoxCore:()=>I,SearchSession:()=>ee,SessionToken:()=>f,ValidationCore:()=>V,debounce:()=>D,featureToSuggestion:()=>Se,polyfillFetch:()=>ge});var oe="https://api.mapbox.com/autofill/v1",Ae="suggest",we="retrieve",se=`${oe}/${Ae}`,ne=`${oe}/${we}`;var l=class{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90");if(this.lng>180||this.lng<-180)throw new Error("Invalid LngLat longitude value: must be between -180 and 180")}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}static convert(e){if(e instanceof l)return new l(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new l(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null&&("lng"in e||"lon"in e)&&"lat"in e)return new l(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};var m=class{constructor(e,t){this._sw=l.convert(e),this._ne=l.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new l(this.getWest(),this.getNorth())}getSouthEast(){return new l(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toFlatArray(){return[this._sw.lng,this._sw.lat,this._ne.lng,this._ne.lat]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}static convert(e){if(!e)throw new Error("Invalid LngLatBounds convert value: falsy");if(e instanceof m)return new m(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new m(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new m(l.convert([e[0],e[1]]),l.convert([e[2],e[3]]));throw new Error("`LngLatBoundsLike` argument must be specified as an array [<LngLatLike>, <LngLatLike>] or an array [<west>, <south>, <east>, <north>]")}};function ie(){let e=(Math.random().toString(16)+Date.now().toString(16)+Math.random().toString(16)).replace(/\./g,"");return[e.slice(0,8),e.slice(8,12),"4"+e.slice(12,15)+"-8"+e.slice(15,18),e.slice(18,30)].join("-")}var f=class{constructor(e){this.id=e!=null?e:ie()}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString())}};var Ee="Unknown error",j=class extends Error{constructor(e,t){super(String(e.message||e.error||Ee));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function S(o){return p(this,null,function*(){if(!o.ok){let e=yield o.json();throw new j(e,o.status)}})}var N=globalThis.fetch,ae=globalThis.AbortController;function ge({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");N&&!t||(N=o,ae=e)}function h(){if(!N)throw new Error("Fetch implementation not found. Please include a fetch polyfill in your application or use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:N,AbortController:ae}}function b(...o){let e=[];for(let t of o){if(!t)continue;let r=Object.entries(t);for(let[s,n]of r)n!=null&&e.push(`${s}=${encodeURIComponent(String(n))}`)}return e.join("&")}var C,Oe,z=class{constructor(e={}){d(this,C);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},z.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{sessionToken:r}),i=new URL(`${se}/${encodeURIComponent(e)}`);i.search=R(this,C,Oe).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return x(g({},u),{suggestions:u.suggestions.map(y=>x(g({},y),{original_search_text:e})),url:i.toString()})})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:r,signal:s}=t,n=f.convert(r),i=new URL(`${ne}/${e.action.id}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},$=z;C=new WeakSet,Oe=function(e){return b({types:"address",access_token:this.accessToken,streets:e.streets,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},$.defaults={language:"en",proximity:"ip",streets:!0};var G="https://api.mapbox.com/search/searchbox/v1",_e="suggest",Pe="retrieve",Fe="category",Be="reverse",ce=`${G}/${_e}`,ue=`${G}/${Pe}`,le=`${G}/${Fe}`,pe=`${G}/${Be}`;var E,me,Q=class{constructor(e={}){d(this,E);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Q.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{q:e,sessionToken:r});if(n.eta_type&&(!n.origin||!n.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(n.origin&&!n.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(ce);i.search=R(this,E,me).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");let{sessionToken:r,signal:s}=t,n=f.convert(r),i=new URL(`${ue}/${encodeURIComponent(e.mapbox_id)}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}category(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("category is required");let s=g(g({},this.defaults),t),n=new URL(`${le}/${encodeURIComponent(e)}`);n.search=R(this,E,me).call(this,s);let{fetch:i}=h(),a=yield i(n.toString(),{signal:s.signal});yield S(a);let c=yield a.json();return c.url=n.toString(),c})}reverse(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let[s,n]=typeof e=="string"?e.split(",").map(F=>parseFloat(F)):l.convert(e).toArray();if(isNaN(s)||isNaN(n))throw new Error("lngLat is required");let i=g(g({},this.defaults),t),a=new URL(pe);a.search=b({access_token:this.accessToken,language:i.language,limit:i.limit,longitude:s,latitude:n},i.types&&{types:typeof i.types=="string"?i.types:[...i.types].join(",")});let{fetch:c}=h(),u=yield c(a.toString(),{signal:i.signal});yield S(u);let y=yield u.json();return y.url=a.toString(),y})}},I=Q;E=new WeakSet,me=function(e){return b({q:e.q,access_token:this.accessToken,language:e.language,limit:e.limit,navigation_profile:e.navigation_profile,route:e.route,route_geometry:e.route_geometry,sar_type:e.sar_type,time_deviation:e.time_deviation,eta_type:e.eta_type,country:e.country,poi_category:e.poi_category,radius:e.radius,user_id:e.user_id,rich_metadata_provider:e.rich_metadata_provider,poi_category_exclusions:e.poi_category_exclusions},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.origin&&{origin:typeof e.origin=="string"?e.origin:l.convert(e.origin).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},I.defaults={language:"en"};var Ue="https://api.mapbox.com/autofill/v1",je="retrieve",fe=`${Ue}/${je}`;var q,Ne,W=class{constructor(e={}){d(this,q);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},W.defaults),r)}validate(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{sessionToken:r}),i=new URL(`${fe}/${encodeURIComponent(e)}`);i.search=R(this,q,Ne).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},V=W;q=new WeakSet,Ne=function(e){return b({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},V.defaults={language:"en",proximity:"ip"};var he="https://api.mapbox.com/geocoding/v5",H=`${he}/mapbox.places`,Y=`${he}/mapbox.places-permanent`;var O,de,J=class{constructor(e={}){d(this,O);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g({},r)}forward(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let r;t&&({signal:r}=t);let s=g(g({},this.defaults),t),n=s.permanent?Y:H,i=new URL(`${n}/${encodeURIComponent(e)}.json`);i.search=R(this,O,de).call(this,s);let{fetch:a}=h(),c=r?{signal:r}:{},u=yield a(i.toString(),c);yield S(u);let y=yield u.json();return y.url=i.toString(),y})}reverse(e,t){return p(this,null,function*(){if(!e)throw new Error("lngLat is required");let r;t&&({signal:r}=t);let s=g(g({},this.defaults),t),n=typeof e=="string"?e:l.convert(e).toArray().join(","),i=s.permanent?Y:H,a=new URL(`${i}/${encodeURIComponent(n)}.json`);a.search=R(this,O,de).call(this,s,!0);let{fetch:c}=h(),u=r?{signal:r}:{},y=yield c(a.toString(),u);yield S(y);let F=yield y.json();return F.url=a.toString(),F})}};O=new WeakSet,de=function(e,t=!1){return t&&["proximity","autocomplete","fuzzyMatch","bbox"].forEach(r=>{r in e&&delete e[r]}),b({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,autocomplete:e.autocomplete,fuzzyMatch:e.fuzzyMatch,routing:e.routing,worldview:e.worldview},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var X=(s=>(s.exact="exact",s.high="high",s.medium="medium",s.low="low",s))(X||{});var w,_=class{constructor(){d(this,w,{})}addEventListener(e,t){let r=L(this,w);r[e]||(r[e]=[]),r[e].push(t)}removeEventListener(e,t){let r=L(this,w);if(!r[e])return;let s=r[e],n=s.indexOf(t);n!==-1&&s.splice(n,1)}fire(e,t){let r=L(this,w);if(!r[e])return;let s=r[e];for(let n of s)n(t)}};w=new WeakMap;function D(o,e,t){let r=null;return(...s)=>{r!==null&&clearTimeout(r);let n=t&&t();r=setTimeout(()=>{r=null,!(n==null?void 0:n.aborted)&&o(...s)},e)}}function Z(){let{AbortController:o}=h();return new o}var T,k,P,ee=class extends _{constructor(e,t=0){super();this.sessionToken=new f;d(this,T,void 0);d(this,k,Z());d(this,P,void 0);A(this,P,D((n,...i)=>p(this,[n,...i],function*(r,s={}){if(L(this,k).abort(),A(this,k,Z()),!r){A(this,T,null),this.fire("suggest",L(this,T));return}try{let a=yield this.search.suggest(r,x(g({sessionToken:this.sessionToken},s),{signal:L(this,k).signal}));A(this,T,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>L(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return L(this,T)}suggest(e,t){return L(this,P).call(this,e,t),new Promise((r,s)=>{let n,i;n=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),r(a)},i=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),s(a)},this.addEventListener("suggest",n),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return p(this,null,function*(){let r=yield this.search.retrieve(e,g({sessionToken:this.sessionToken},t));return this.fire("retrieve",r),r})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){L(this,k).abort(),A(this,k,Z())}};T=new WeakMap,k=new WeakMap,P=new WeakMap;function Se(o){let{properties:e}=o;return g({},e)}return Te($e);})();
var mapboxsearchcore=(()=>{var B=Object.defineProperty,be=Object.defineProperties,xe=Object.getOwnPropertyDescriptor,Re=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var te=(o,e,t)=>e in o?B(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,c=(o,e)=>{for(var t in e||(e={}))M.call(e,t)&&te(o,t,e[t]);if(P)for(var t of P(e))re.call(e,t)&&te(o,t,e[t]);return o},S=(o,e)=>be(o,Re(e)),ve=o=>B(o,"__esModule",{value:!0});var k=(o,e)=>{var t={};for(var r in o)M.call(o,r)&&e.indexOf(r)<0&&(t[r]=o[r]);if(o!=null&&P)for(var r of P(o))e.indexOf(r)<0&&re.call(o,r)&&(t[r]=o[r]);return t};var Te=(o,e)=>{for(var t in e)B(o,t,{get:e[t],enumerable:!0})},Ae=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ke(e))!M.call(o,s)&&(t||s!=="default")&&B(o,s,{get:()=>e[s],enumerable:!(r=xe(e,s))||r.enumerable});return o};var we=(o=>(e,t)=>o&&o.get(e)||(t=Ae(ve({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var K=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var y=(o,e,t)=>(K(o,e,"read from private field"),t?t.call(o):e.get(o)),h=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},A=(o,e,t,r)=>(K(o,e,"write to private field"),r?r.call(o,t):e.set(o,t),t);var x=(o,e,t)=>(K(o,e,"access private method"),t);var p=(o,e,t)=>new Promise((r,s)=>{var n=g=>{try{a(t.next(g))}catch(u){s(u)}},i=g=>{try{a(t.throw(g))}catch(u){s(u)}},a=g=>g.done?r(g.value):Promise.resolve(g.value).then(n,i);a((t=t.apply(o,e)).next())});var Ve={};Te(Ve,{AddressAutofillCore:()=>G,Evented:()=>_,GeocodingCore:()=>X,LngLat:()=>l,LngLatBounds:()=>m,MapboxAutofill:()=>G,MapboxError:()=>U,MapboxGeocode:()=>X,MapboxValidate:()=>I,MatchCodeConfidence:()=>J,MatchCodeType:()=>z,SearchBoxCore:()=>N,SearchSession:()=>ee,SessionToken:()=>d,ValidationCore:()=>I,debounce:()=>q,featureToSuggestion:()=>Le,polyfillFetch:()=>ge});var oe="https://api.mapbox.com/autofill/v1",Ee="suggest",Oe="retrieve",se=`${oe}/${Ee}`,ne=`${oe}/${Oe}`;var l=class{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90");if(this.lng>180||this.lng<-180)throw new Error("Invalid LngLat longitude value: must be between -180 and 180")}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}static convert(e){if(e instanceof l)return new l(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new l(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null&&("lng"in e||"lon"in e)&&"lat"in e)return new l(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};var m=class{constructor(e,t){this._sw=l.convert(e),this._ne=l.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new l(this.getWest(),this.getNorth())}getSouthEast(){return new l(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toFlatArray(){return[this._sw.lng,this._sw.lat,this._ne.lng,this._ne.lat]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}static convert(e){if(!e)throw new Error("Invalid LngLatBounds convert value: falsy");if(e instanceof m)return new m(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new m(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new m(l.convert([e[0],e[1]]),l.convert([e[2],e[3]]));throw new Error("`LngLatBoundsLike` argument must be specified as an array [<LngLatLike>, <LngLatLike>] or an array [<west>, <south>, <east>, <north>]")}};function ie(){let e=(Math.random().toString(16)+Date.now().toString(16)+Math.random().toString(16)).replace(/\./g,"");return[e.slice(0,8),e.slice(8,12),"4"+e.slice(12,15)+"-8"+e.slice(15,18),e.slice(18,30)].join("-")}var d=class{constructor(e){this.id=e!=null?e:ie()}toString(){return this.id}static convert(e){return new d(e instanceof d?e.id:e.toString())}};var _e="Unknown error",U=class extends Error{constructor(e,t){super(String(e.message||e.error||_e));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function L(o){return p(this,null,function*(){if(!o.ok){let e=yield o.json();throw new U(e,o.status)}})}var C=globalThis.fetch,ae=globalThis.AbortController;function ge({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");C&&!t||(C=o,ae=e)}function f(){if(!C)throw new Error("Fetch implementation not found. Please include a fetch polyfill in your application or use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:C,AbortController:ae}}function b(...o){let e=[];for(let t of o){if(!t)continue;let r=Object.entries(t);for(let[s,n]of r)n!=null&&e.push(`${s}=${encodeURIComponent(String(n))}`)}return e.join("&")}var j,Fe,Q=class{constructor(e={}){h(this,j);let s=e,{accessToken:t}=s,r=k(s,["accessToken"]);this.accessToken=t,this.defaults=c(c({},Q.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=S(c(c({},this.defaults),t),{sessionToken:r}),i=new URL(`${se}/${encodeURIComponent(e)}`);i.search=x(this,j,Fe).call(this,n);let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return S(c({},u),{suggestions:u.suggestions.map(v=>S(c({},v),{original_search_text:e})),url:i.toString()})})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:r,signal:s}=t,n=d.convert(r),i=new URL(`${ne}/${e.action.id}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return u.url=i.toString(),u})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},G=Q;j=new WeakSet,Fe=function(e){return b({types:"address",access_token:this.accessToken,streets:e.streets,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:d.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},G.defaults={language:"en",proximity:"ip",streets:!0};var $="https://api.mapbox.com/search/searchbox/v1",Pe="suggest",Be="retrieve",Ue="category",Ce="reverse",ce=`${$}/${Pe}`,ue=`${$}/${Be}`,le=`${$}/${Ue}`,pe=`${$}/${Ce}`;var E,me,W=class{constructor(e={}){h(this,E);let s=e,{accessToken:t}=s,r=k(s,["accessToken"]);this.accessToken=t,this.defaults=c(c({},W.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=S(c(c({},this.defaults),t),{q:e,sessionToken:r});if(n.eta_type&&(!n.origin||!n.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(n.origin&&!n.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(ce);i.search=x(this,E,me).call(this,n);let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return u.url=i.toString(),u})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");let{sessionToken:r,signal:s}=t,n=d.convert(r),i=new URL(`${ue}/${encodeURIComponent(e.mapbox_id)}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return u.url=i.toString(),u})}category(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("category is required");let s=c(c({},this.defaults),t),n=new URL(`${le}/${encodeURIComponent(e)}`);n.search=x(this,E,me).call(this,s);let{fetch:i}=f(),a=yield i(n.toString(),{signal:s.signal});yield L(a);let g=yield a.json();return g.url=n.toString(),g})}reverse(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let[s,n]=typeof e=="string"?e.split(",").map(D=>parseFloat(D)):l.convert(e).toArray();if(isNaN(s)||isNaN(n))throw new Error("lngLat is required");let i=c(c({},this.defaults),t),a=new URL(pe);a.search=b({access_token:this.accessToken,language:i.language,limit:i.limit,longitude:s,latitude:n},i.types&&{types:typeof i.types=="string"?i.types:[...i.types].join(",")});let{fetch:g}=f(),u=yield g(a.toString(),{signal:i.signal});yield L(u);let v=yield u.json();return v.url=a.toString(),v})}},N=W;E=new WeakSet,me=function(e){return b({q:e.q,access_token:this.accessToken,language:e.language,limit:e.limit,navigation_profile:e.navigation_profile,route:e.route,route_geometry:e.route_geometry,sar_type:e.sar_type,time_deviation:e.time_deviation,eta_type:e.eta_type,country:e.country,poi_category:e.poi_category,radius:e.radius,user_id:e.user_id,rich_metadata_provider:e.rich_metadata_provider,poi_category_exclusions:e.poi_category_exclusions},e.sessionToken&&{session_token:d.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.origin&&{origin:typeof e.origin=="string"?e.origin:l.convert(e.origin).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},N.defaults={language:"en"};var Ge="https://api.mapbox.com/autofill/v1",je="retrieve",de=`${Ge}/${je}`;var V,$e,H=class{constructor(e={}){h(this,V);let s=e,{accessToken:t}=s,r=k(s,["accessToken"]);this.accessToken=t,this.defaults=c(c({},H.defaults),r)}validate(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=S(c(c({},this.defaults),t),{sessionToken:r}),i=new URL(`${de}/${encodeURIComponent(e)}`);i.search=x(this,V,$e).call(this,n);let{fetch:a}=f(),g=yield a(i.toString(),{signal:s});yield L(g);let u=yield g.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},I=H;V=new WeakSet,$e=function(e){return b({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:d.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},I.defaults={language:"en",proximity:"ip"};var Y="https://api.mapbox.com/search/geocode/v6",fe=`${Y}/forward`,he=`${Y}/reverse`,Ct=`${Y}/batch`;var Ne=/^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)[ ]*$/,Ie=/[\s,]+/,O,Se,X=class{constructor(e={}){h(this,O);let s=e,{accessToken:t}=s,r=k(s,["accessToken"]);this.accessToken=t,this.defaults=c({},r)}forward(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let r;t&&({signal:r}=t);let s=S(c(c({},this.defaults),t),{q:e}),n=new URL(`${fe}`);n.search=x(this,O,Se).call(this,s);let{fetch:i}=f(),a=r?{signal:r}:{},g=yield i(n.toString(),a);yield L(g);let u=yield g.json();return u.url=n.toString(),u})}reverse(e,t){return p(this,null,function*(){if(!e)throw new Error("lngLat is required");let r;t&&({signal:r}=t);let s;if(typeof e=="string"){let[D,ye]=e.split(",");s=new l(Number(D),Number(ye))}else s=l.convert(e);let n=S(c(c({},this.defaults),t),{longitude:s.lng,latitude:s.lat}),i=new URL(`${he}`);i.search=x(this,O,Se).call(this,n,!0);let{fetch:a}=f(),g=r?{signal:r}:{},u=yield a(i.toString(),g);yield L(u);let v=yield u.json();return v.url=i.toString(),v})}suggest(e,t){return p(this,null,function*(){if(Ne.test(e)){let s=e.trim().split(Ie).map(n=>n.trim()).join(",");return this.reverse(s,t)}else return this.forward(e,t)})}retrieve(e){return p(this,null,function*(){return e})}};O=new WeakSet,Se=function(e,t=!1){return t&&["proximity","autocomplete","bbox"].forEach(r=>{r in e&&delete e[r]}),b({q:e.q,longitude:e.longitude,latitude:e.latitude,access_token:this.accessToken,permanent:e.permanent,language:e.language,country:e.country,limit:e.limit,autocomplete:e.autocomplete,worldview:e.worldview},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var z=(n=>(n.matched="matched",n.unmatched="unmatched",n.plausible="plausible",n.not_applicable="not_applicable",n.inferred="inferred",n))(z||{}),J=(s=>(s.exact="exact",s.high="high",s.medium="medium",s.low="low",s))(J||{});var w,_=class{constructor(){h(this,w,{})}addEventListener(e,t){let r=y(this,w);r[e]||(r[e]=[]),r[e].push(t)}removeEventListener(e,t){let r=y(this,w);if(!r[e])return;let s=r[e],n=s.indexOf(t);n!==-1&&s.splice(n,1)}fire(e,t){let r=y(this,w);if(!r[e])return;let s=r[e];for(let n of s)n(t)}};w=new WeakMap;function q(o,e,t){let r=null;return(...s)=>{r!==null&&clearTimeout(r);let n=t&&t();r=setTimeout(()=>{r=null,!(n==null?void 0:n.aborted)&&o(...s)},e)}}function Z(){let{AbortController:o}=f();return new o}var T,R,F,ee=class extends _{constructor(e,t=0){super();this.sessionToken=new d;h(this,T,void 0);h(this,R,Z());h(this,F,void 0);A(this,F,q((n,...i)=>p(this,[n,...i],function*(r,s={}){if(y(this,R).abort(),A(this,R,Z()),!r){A(this,T,null),this.fire("suggest",y(this,T));return}try{let a=yield this.search.suggest(r,S(c({sessionToken:this.sessionToken},s),{signal:y(this,R).signal}));A(this,T,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>y(this,R).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return y(this,T)}suggest(e,t){return y(this,F).call(this,e,t),new Promise((r,s)=>{let n,i;n=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),r(a)},i=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),s(a)},this.addEventListener("suggest",n),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return p(this,null,function*(){let r=yield this.search.retrieve(e,c({sessionToken:this.sessionToken},t));return this.fire("retrieve",r),r})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){y(this,R).abort(),A(this,R,Z())}};T=new WeakMap,R=new WeakMap,F=new WeakMap;function Le(o){let{properties:e}=o;return c({},e)}return we(Ve);})();
//# sourceMappingURL=mapboxsearchcore.js.map
/**
* An indication of how well a context component of the feature matches the query.
*
* @typedef MatchCodeType
*/
export declare const enum MatchCodeType {
/**
* The component value matches the user's input.
*/
matched = "matched",
/**
* The component value doesn't match the user's input, or the user didn't submit this component type as part of the query.
*/
unmatched = "unmatched",
/**
* Only relevant for the `address_number` and `secondary_address` components.
* In the case of `address_number`, this means the address accuracy is interpolated.
* In the case of `secondary_address`, this means the secondary address was extrapolated, i.e. the primary address is known to have secondary addresses, but the geocoder did not find a specific matching secondary address in our data.
*/
plausible = "plausible",
/**
* The component is not used in the postal address string representation of the feature.
*/
not_applicable = "not_applicable",
/**
* The component type wasn't submitted as part of the query, but we were able to confidently fill in the value. Only returned for the `country` component.
*/
inferred = "inferred"
}
/**
* An overall confidence level for how well the feature matches the query.
*
* @typedef MatchCodeConfidence

@@ -24,3 +55,2 @@ */

* An object describing the level of confidence that the given response feature matches the address intended by the request query.
* Includes boolean flags denoting matches for each address sub-component.
*

@@ -31,33 +61,37 @@ * @typedef MatchCode

/**
* A measure of confidence that the returned feature suggestion matches the intended address, based on the search text provided.
* An indication of how well the `secondary_address` component of the feature matches the query.
*/
confidence: MatchCodeConfidence;
secondary_address?: MatchCodeType;
/**
* True if the confidence value is "exact".
* An indication of how well the `address_number` component of the feature matches the query.
*/
exact_match: boolean;
address_number: MatchCodeType;
/**
* True if the house number component was matched.
* An indication of how well the `street` component of the feature matches the query.
*/
house_number: boolean;
street: MatchCodeType;
/**
* True if the street component was matched.
* An indication of how well the `postcode` component of the feature matches the query.
*/
street: boolean;
postcode: MatchCodeType;
/**
* True if the postcode was matched.
* An indication of how well the `place` component of the feature matches the query.
*/
postcode: boolean;
place: MatchCodeType;
/**
* True if the place component was matched.
* An indication of how well the `region` component of the feature matches the query.
*/
place: boolean;
region: MatchCodeType;
/**
* True if the region component was matched.
* An indication of how well the `locality` component of the feature matches the query.
*/
region?: boolean;
locality: MatchCodeType;
/**
* True if the locality component was matched.
* An indication of how well the `country` component of the feature matches the query.
*/
locality?: boolean;
country: MatchCodeType;
/**
* An overall confidence level for how well the feature matches the query.
*/
confidence: MatchCodeConfidence;
}
{
"name": "@mapbox/search-js-core",
"version": "1.0.0-beta.19",
"version": "1.0.0-beta.20",
"description": "Platform agnostic wrappers for the Search Box, Address Autofill, and Geocoding APIs.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc