@mapbox/search-js-core
Advanced tools
Comparing version 1.0.0-beta.22 to 1.0.0-beta.23
@@ -26,6 +26,6 @@ import { AddressAutofillSuggestion, AddressAutofillFeatureSuggestion } from './types'; | ||
/** | ||
* A customer-provided session token value, which groups a series of requests together for [billing purposes](https://docs.mapbox.com/api/search/search-box/#search-box-api-pricing). | ||
* A customer-provided session token value, which groups a series of requests together for [billing purposes](https://www.mapbox.com/pricing#autofill-session). | ||
* | ||
* Reference: | ||
* https://docs.mapbox.com/api/search/search-box/#session-billing | ||
* https://www.mapbox.com/pricing#autofill-session | ||
*/ | ||
@@ -120,2 +120,3 @@ sessionToken: SessionTokenLike; | ||
defaults: Partial<AddressAutofillOptions>; | ||
get responseHeaders(): Headers; | ||
constructor(options?: Partial<AccessTokenOptions & AddressAutofillOptions>); | ||
@@ -122,0 +123,0 @@ /** @section {Methods} */ |
import { LngLatBoundsLike } from '../LngLatBounds'; | ||
import { MatchCode } from '../types'; | ||
/** | ||
* Object representing one level of hierarcy among encompassing parent features for a given {@link AddressAutofillSuggestion}. | ||
* | ||
* @typedef AddressAutofillFeatureContextComponent | ||
*/ | ||
export interface AddressAutofillFeatureContextComponent { | ||
/** | ||
* An identifier prefixed with the component type, for example `country.123`. | ||
*/ | ||
id: string; | ||
/** | ||
* The unique Mapbox ID of the context feature. | ||
*/ | ||
mapbox_id: string; | ||
/** | ||
* A string representing the feature in the requested language, if specified. | ||
*/ | ||
text: string; | ||
/** | ||
* The [Wikidata](https://wikidata.org/) identifier for the returned feature. | ||
*/ | ||
wikidata_id?: string; | ||
} | ||
/** | ||
* An `AddressAutofillSuggestion` object represents a suggestion | ||
@@ -55,2 +78,6 @@ * result from the Mapbox Address Autofill API. | ||
/** | ||
* Feature id. The `mapbox_id` uniquely identifies a feature in the Mapbox search database. | ||
*/ | ||
mapbox_id: string; | ||
/** | ||
* The name of the [Maki](https://labs.mapbox.com/maki-icons/) icon associated with the feature. | ||
@@ -129,2 +156,6 @@ */ | ||
/** | ||
* An array of context objects representing the hierarchy of encompassing parent features for a given feature. | ||
*/ | ||
context: AddressAutofillFeatureContextComponent[]; | ||
/** | ||
* Action block of the suggestion result. | ||
@@ -131,0 +162,0 @@ * contains id to execute retrieve |
import { LngLatLike } from '../LngLat'; | ||
import { LngLatBoundsLike } from '../LngLatBounds'; | ||
import { SessionTokenLike } from '../SessionToken'; | ||
import { FeatureTypes, GeocodingFeature } from './types'; | ||
@@ -23,2 +24,11 @@ interface AccessTokenOptions { | ||
} | ||
interface SessionTokenOptions { | ||
/** | ||
* A customer-provided session token value, which groups a series of requests together for [billing purposes](https://www.mapbox.com/pricing#autofill-session). | ||
* | ||
* Reference: | ||
* https://www.mapbox.com/pricing#autofill-session | ||
*/ | ||
sessionToken: SessionTokenLike; | ||
} | ||
/** | ||
@@ -33,15 +43,15 @@ * @typedef GeocodingOptions | ||
*/ | ||
autocomplete: boolean; | ||
autocomplete?: boolean; | ||
/** | ||
* Limit results to only those contained within the supplied bounding box. | ||
*/ | ||
bbox: string | LngLatBoundsLike; | ||
bbox?: string | LngLatBoundsLike; | ||
/** | ||
* Limit results to one or more countries. Permitted values are [ISO 3166 alpha 2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country codes separated by commas. | ||
*/ | ||
country: string; | ||
country?: string; | ||
/** | ||
* 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. | ||
*/ | ||
language: string; | ||
language?: string; | ||
/** | ||
@@ -52,3 +62,3 @@ * The number of results to return, up to `10`. | ||
*/ | ||
limit: number; | ||
limit?: number; | ||
/** | ||
@@ -59,11 +69,11 @@ * Bias the response to favor results that are closer to this location. | ||
*/ | ||
proximity: string | LngLatLike; | ||
proximity?: string | LngLatLike; | ||
/** | ||
* Filter results to include only a subset (one or more) of the available feature types. Multiple options can be comma-separated. | ||
*/ | ||
types: string | Set<FeatureTypes>; | ||
types?: string | Set<FeatureTypes>; | ||
/** | ||
* Available worldviews are: `cn`, `in`, `jp`, `us`. If a worldview is not set, `us` worldview boundaries will be returned. | ||
*/ | ||
worldview: string; | ||
worldview?: string; | ||
/** | ||
@@ -80,3 +90,3 @@ * Permanent geocodes are used for use cases that require storing | ||
*/ | ||
permanent: boolean; | ||
permanent?: boolean; | ||
} | ||
@@ -140,2 +150,3 @@ /** | ||
defaults: Partial<GeocodingOptions>; | ||
get responseHeaders(): Headers; | ||
constructor(options?: Partial<AccessTokenOptions & GeocodingOptions>); | ||
@@ -177,3 +188,3 @@ /** @section {Programmatic search} */ | ||
forward(searchText: string, // TODO: enable structured input alternative arguments (e.g. `searchText: string | StructuredInput`) | ||
optionsArg?: Partial<FetchOptions & GeocodingOptions>): Promise<GeocodingResponse>; | ||
optionsArg?: Partial<FetchOptions & GeocodingOptions & SessionTokenOptions>): Promise<GeocodingResponse>; | ||
/** | ||
@@ -199,3 +210,3 @@ * {@link GeocodingCore#reverse} allows you to look up a single pair of coordinates and returns the | ||
* | ||
* @param {String} searchText | ||
* @param {String | LngLatLike} lngLat | ||
* @param {GeocodingOptions} [optionsArg] | ||
@@ -213,3 +224,3 @@ * @param {AbortSignal} [optionsArg.signal] | ||
*/ | ||
reverse(lngLat: string | LngLatLike, optionsArg?: Partial<FetchOptions & GeocodingOptions>): Promise<GeocodingResponse>; | ||
reverse(lngLat: string | LngLatLike, optionsArg?: Partial<FetchOptions & GeocodingOptions & SessionTokenOptions>): Promise<GeocodingResponse>; | ||
/** @section {Interactive search} */ | ||
@@ -234,3 +245,3 @@ /** | ||
*/ | ||
suggest(searchText: string, optionsArg?: Partial<FetchOptions & GeocodingOptions>): Promise<GeocodingResponse>; | ||
suggest(searchText: string, optionsArg?: Partial<FetchOptions & GeocodingOptions & SessionTokenOptions>): Promise<GeocodingResponse>; | ||
/** | ||
@@ -237,0 +248,0 @@ * {@link GeocodingCore#retrieve} is a managed endpoint for an interactive {@link SearchSession}, such as one operated |
@@ -70,2 +70,12 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var __privateWrapper = (obj, member, setter, getter) => { | ||
return { | ||
set _(value) { | ||
__privateSet(obj, member, value, setter); | ||
}, | ||
get _() { | ||
return __privateGet(obj, member, getter); | ||
} | ||
}; | ||
}; | ||
var __privateMethod = (obj, member, method) => { | ||
@@ -304,6 +314,7 @@ __accessCheck(obj, member, "access private method"); | ||
// src/autofill/AddressAutofillCore.ts | ||
var _getQueryParams, getQueryParams_fn; | ||
var _responseHeaders, _getQueryParams, getQueryParams_fn; | ||
var _AddressAutofillCore = class { | ||
constructor(options = {}) { | ||
__privateAdd(this, _getQueryParams); | ||
__privateAdd(this, _responseHeaders, void 0); | ||
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]); | ||
@@ -313,2 +324,5 @@ this.accessToken = accessToken; | ||
} | ||
get responseHeaders() { | ||
return __privateGet(this, _responseHeaders); | ||
} | ||
suggest(searchText, optionsArg) { | ||
@@ -329,2 +343,3 @@ return __async(this, null, function* () { | ||
}); | ||
__privateSet(this, _responseHeaders, res.headers); | ||
yield handleNonOkRes(res); | ||
@@ -371,2 +386,3 @@ const json = yield res.json(); | ||
var AddressAutofillCore = _AddressAutofillCore; | ||
_responseHeaders = new WeakMap(); | ||
_getQueryParams = new WeakSet(); | ||
@@ -531,3 +547,2 @@ getQueryParams_fn = function(options) { | ||
radius: options.radius, | ||
user_id: options.user_id, | ||
rich_metadata_provider: options.rich_metadata_provider, | ||
@@ -619,6 +634,7 @@ poi_category_exclusions: options.poi_category_exclusions | ||
var SPACES_OR_COMMA_REGEX = /[\s,]+/; | ||
var _getQueryParams4, getQueryParams_fn4; | ||
var _responseHeaders2, _getQueryParams4, getQueryParams_fn4; | ||
var GeocodingCore = class { | ||
constructor(options = {}) { | ||
__privateAdd(this, _getQueryParams4); | ||
__privateAdd(this, _responseHeaders2, void 0); | ||
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]); | ||
@@ -628,2 +644,5 @@ this.accessToken = accessToken; | ||
} | ||
get responseHeaders() { | ||
return __privateGet(this, _responseHeaders2); | ||
} | ||
forward(searchText, optionsArg) { | ||
@@ -646,2 +665,3 @@ return __async(this, null, function* () { | ||
const res = yield fetch(url.toString(), fetchInit); | ||
__privateSet(this, _responseHeaders2, res.headers); | ||
yield handleNonOkRes(res); | ||
@@ -678,2 +698,3 @@ const json = yield res.json(); | ||
const res = yield fetch(url.toString(), fetchInit); | ||
__privateSet(this, _responseHeaders2, res.headers); | ||
yield handleNonOkRes(res); | ||
@@ -702,2 +723,3 @@ const json = yield res.json(); | ||
}; | ||
_responseHeaders2 = new WeakMap(); | ||
_getQueryParams4 = new WeakSet(); | ||
@@ -723,2 +745,4 @@ getQueryParams_fn4 = function(options, isReverse = false) { | ||
worldview: options.worldview | ||
}, options.sessionToken && { | ||
session_token: SessionToken.convert(options.sessionToken).id | ||
}, options.proximity && { | ||
@@ -810,7 +834,9 @@ proximity: typeof options.proximity === "string" ? options.proximity : LngLat.convert(options.proximity).toArray().join(",") | ||
} | ||
var _suggestions, _abort, _suggestDebounce; | ||
var _sessionTokenBase, _sessionIncrementer, _sessionTokenCustom, _suggestions, _abort, _suggestDebounce; | ||
var SearchSession = class extends Evented { | ||
constructor(search, wait = 0) { | ||
super(); | ||
this.sessionToken = new SessionToken(); | ||
__privateAdd(this, _sessionTokenBase, new SessionToken()); | ||
__privateAdd(this, _sessionIncrementer, 0); | ||
__privateAdd(this, _sessionTokenCustom, false); | ||
__privateAdd(this, _suggestions, void 0); | ||
@@ -853,2 +879,12 @@ __privateAdd(this, _abort, createAbortController()); | ||
} | ||
get sessionToken() { | ||
if (__privateGet(this, _sessionTokenCustom)) { | ||
return __privateGet(this, _sessionTokenBase).id; | ||
} | ||
return `${__privateGet(this, _sessionTokenBase).id}.${__privateGet(this, _sessionIncrementer)}`; | ||
} | ||
set sessionToken(token) { | ||
__privateSet(this, _sessionTokenCustom, true); | ||
__privateSet(this, _sessionTokenBase, new SessionToken(token)); | ||
} | ||
get suggestions() { | ||
@@ -904,3 +940,9 @@ return __privateGet(this, _suggestions); | ||
} | ||
incrementSession() { | ||
__privateWrapper(this, _sessionIncrementer)._++; | ||
} | ||
}; | ||
_sessionTokenBase = new WeakMap(); | ||
_sessionIncrementer = new WeakMap(); | ||
_sessionTokenCustom = new WeakMap(); | ||
_suggestions = new WeakMap(); | ||
@@ -907,0 +949,0 @@ _abort = new WeakMap(); |
@@ -50,2 +50,12 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var __privateWrapper = (obj, member, setter, getter) => { | ||
return { | ||
set _(value) { | ||
__privateSet(obj, member, value, setter); | ||
}, | ||
get _() { | ||
return __privateGet(obj, member, getter); | ||
} | ||
}; | ||
}; | ||
var __privateMethod = (obj, member, method) => { | ||
@@ -261,6 +271,7 @@ __accessCheck(obj, member, "access private method"); | ||
// src/autofill/AddressAutofillCore.ts | ||
var _getQueryParams, getQueryParams_fn; | ||
var _responseHeaders, _getQueryParams, getQueryParams_fn; | ||
var _AddressAutofillCore = class { | ||
constructor(options = {}) { | ||
__privateAdd(this, _getQueryParams); | ||
__privateAdd(this, _responseHeaders, void 0); | ||
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]); | ||
@@ -270,2 +281,5 @@ this.accessToken = accessToken; | ||
} | ||
get responseHeaders() { | ||
return __privateGet(this, _responseHeaders); | ||
} | ||
suggest(searchText, optionsArg) { | ||
@@ -286,2 +300,3 @@ return __async(this, null, function* () { | ||
}); | ||
__privateSet(this, _responseHeaders, res.headers); | ||
yield handleNonOkRes(res); | ||
@@ -328,2 +343,3 @@ const json = yield res.json(); | ||
var AddressAutofillCore = _AddressAutofillCore; | ||
_responseHeaders = new WeakMap(); | ||
_getQueryParams = new WeakSet(); | ||
@@ -488,3 +504,2 @@ getQueryParams_fn = function(options) { | ||
radius: options.radius, | ||
user_id: options.user_id, | ||
rich_metadata_provider: options.rich_metadata_provider, | ||
@@ -576,6 +591,7 @@ poi_category_exclusions: options.poi_category_exclusions | ||
var SPACES_OR_COMMA_REGEX = /[\s,]+/; | ||
var _getQueryParams4, getQueryParams_fn4; | ||
var _responseHeaders2, _getQueryParams4, getQueryParams_fn4; | ||
var GeocodingCore = class { | ||
constructor(options = {}) { | ||
__privateAdd(this, _getQueryParams4); | ||
__privateAdd(this, _responseHeaders2, void 0); | ||
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]); | ||
@@ -585,2 +601,5 @@ this.accessToken = accessToken; | ||
} | ||
get responseHeaders() { | ||
return __privateGet(this, _responseHeaders2); | ||
} | ||
forward(searchText, optionsArg) { | ||
@@ -603,2 +622,3 @@ return __async(this, null, function* () { | ||
const res = yield fetch(url.toString(), fetchInit); | ||
__privateSet(this, _responseHeaders2, res.headers); | ||
yield handleNonOkRes(res); | ||
@@ -635,2 +655,3 @@ const json = yield res.json(); | ||
const res = yield fetch(url.toString(), fetchInit); | ||
__privateSet(this, _responseHeaders2, res.headers); | ||
yield handleNonOkRes(res); | ||
@@ -659,2 +680,3 @@ const json = yield res.json(); | ||
}; | ||
_responseHeaders2 = new WeakMap(); | ||
_getQueryParams4 = new WeakSet(); | ||
@@ -680,2 +702,4 @@ getQueryParams_fn4 = function(options, isReverse = false) { | ||
worldview: options.worldview | ||
}, options.sessionToken && { | ||
session_token: SessionToken.convert(options.sessionToken).id | ||
}, options.proximity && { | ||
@@ -767,7 +791,9 @@ proximity: typeof options.proximity === "string" ? options.proximity : LngLat.convert(options.proximity).toArray().join(",") | ||
} | ||
var _suggestions, _abort, _suggestDebounce; | ||
var _sessionTokenBase, _sessionIncrementer, _sessionTokenCustom, _suggestions, _abort, _suggestDebounce; | ||
var SearchSession = class extends Evented { | ||
constructor(search, wait = 0) { | ||
super(); | ||
this.sessionToken = new SessionToken(); | ||
__privateAdd(this, _sessionTokenBase, new SessionToken()); | ||
__privateAdd(this, _sessionIncrementer, 0); | ||
__privateAdd(this, _sessionTokenCustom, false); | ||
__privateAdd(this, _suggestions, void 0); | ||
@@ -810,2 +836,12 @@ __privateAdd(this, _abort, createAbortController()); | ||
} | ||
get sessionToken() { | ||
if (__privateGet(this, _sessionTokenCustom)) { | ||
return __privateGet(this, _sessionTokenBase).id; | ||
} | ||
return `${__privateGet(this, _sessionTokenBase).id}.${__privateGet(this, _sessionIncrementer)}`; | ||
} | ||
set sessionToken(token) { | ||
__privateSet(this, _sessionTokenCustom, true); | ||
__privateSet(this, _sessionTokenBase, new SessionToken(token)); | ||
} | ||
get suggestions() { | ||
@@ -861,3 +897,9 @@ return __privateGet(this, _suggestions); | ||
} | ||
incrementSession() { | ||
__privateWrapper(this, _sessionIncrementer)._++; | ||
} | ||
}; | ||
_sessionTokenBase = new WeakMap(); | ||
_sessionIncrementer = new WeakMap(); | ||
_sessionTokenCustom = new WeakMap(); | ||
_suggestions = new WeakMap(); | ||
@@ -864,0 +906,0 @@ _abort = new WeakMap(); |
import { AddressAutofillOptions, AddressAutofillCore, AddressAutofillSuggestionResponse, AddressAutofillRetrieveResponse } from './autofill/AddressAutofillCore'; | ||
import { AddressAutofillSuggestion, AddressAutofillFeatureSuggestion } from './autofill/types'; | ||
import { AddressAutofillSuggestion, AddressAutofillFeatureSuggestion, AddressAutofillFeatureContextComponent } from './autofill/types'; | ||
import { SearchBoxOptions, SearchBoxCore, SearchBoxSuggestionResponse, SearchBoxRetrieveResponse, SearchBoxCategoryResponse, SearchBoxReverseResponse } from './searchbox/SearchBoxCore'; | ||
@@ -19,2 +19,2 @@ import { SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion, SearchBoxCategorySuggestion } from './searchbox/types'; | ||
import { debounce } from './utils/debounce'; | ||
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 }; | ||
export { SearchBoxOptions, SearchBoxCore, SearchBoxSuggestionResponse, SearchBoxRetrieveResponse, SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion, SearchBoxCategoryResponse, SearchBoxReverseResponse, SearchBoxCategorySuggestion, AddressAutofillOptions, AddressAutofillCore, AddressAutofillSuggestionResponse, AddressAutofillRetrieveResponse, AddressAutofillSuggestion, AddressAutofillFeatureSuggestion, AddressAutofillFeatureContextComponent, 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 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); | ||
var j=Object.defineProperty,Ae=Object.defineProperties,we=Object.getOwnPropertyDescriptor,Oe=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertyNames,$=Object.getOwnPropertySymbols;var Y=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var ie=(s,e,t)=>e in s?j(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,c=(s,e)=>{for(var t in e||(e={}))Y.call(e,t)&&ie(s,t,e[t]);if($)for(var t of $(e))ae.call(e,t)&&ie(s,t,e[t]);return s},y=(s,e)=>Ae(s,Oe(e)),_e=s=>j(s,"__esModule",{value:!0});var T=(s,e)=>{var t={};for(var r in s)Y.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&$)for(var r of $(s))e.indexOf(r)<0&&ae.call(s,r)&&(t[r]=s[r]);return t};var Fe=(s,e)=>{for(var t in e)j(s,t,{get:e[t],enumerable:!0})},Pe=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ee(e))!Y.call(s,o)&&(t||o!=="default")&&j(s,o,{get:()=>e[o],enumerable:!(r=we(e,o))||r.enumerable});return s};var Be=(s=>(e,t)=>s&&s.get(e)||(t=Pe(_e({}),e,1),s&&s.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var X=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var p=(s,e,t)=>(X(s,e,"read from private field"),t?t.call(s):e.get(s)),d=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},L=(s,e,t,r)=>(X(s,e,"write to private field"),r?r.call(s,t):e.set(s,t),t),ge=(s,e,t,r)=>({set _(o){L(s,e,o,t)},get _(){return p(s,e,r)}}),R=(s,e,t)=>(X(s,e,"access private method"),t);var m=(s,e,t)=>new Promise((r,o)=>{var n=g=>{try{a(t.next(g))}catch(u){o(u)}},i=g=>{try{a(t.throw(g))}catch(u){o(u)}},a=g=>g.done?r(g.value):Promise.resolve(g.value).then(n,i);a((t=t.apply(s,e)).next())});var Qe={};Fe(Qe,{AddressAutofillCore:()=>V,Evented:()=>B,GeocodingCore:()=>te,LngLat:()=>l,LngLatBounds:()=>h,MapboxAutofill:()=>V,MapboxError:()=>N,MapboxGeocode:()=>te,MapboxValidate:()=>H,MatchCodeConfidence:()=>se,MatchCodeType:()=>re,SearchBoxCore:()=>M,SearchSession:()=>ne,SessionToken:()=>f,ValidationCore:()=>H,debounce:()=>Q,featureToSuggestion:()=>Te,polyfillFetch:()=>de});var ce="https://api.mapbox.com/autofill/v1",Ue="suggest",Ce="retrieve",ue=`${ce}/${Ue}`,le=`${ce}/${Ce}`;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 h=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 h)return new h(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new h(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new h(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 pe(){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:pe()}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString())}};var Ge="Unknown error",N=class extends Error{constructor(e,t){super(String(e.message||e.error||Ge));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function b(s){return m(this,null,function*(){if(!s.ok){let e=yield s.json();throw new N(e,s.status)}})}var I=globalThis.fetch,me=globalThis.AbortController;function de({fetch:s,AbortController:e},t=!1){if(!s)throw new Error("Fetch implementation must include implementations of `fetch`.");I&&!t||(I=s,me=e)}function S(){if(!I)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:I,AbortController:me}}function x(...s){let e=[];for(let t of s){if(!t)continue;let r=Object.entries(t);for(let[o,n]of r)n!=null&&e.push(`${o}=${encodeURIComponent(String(n))}`)}return e.join("&")}var _,q,$e,z=class{constructor(e={}){d(this,q);d(this,_,void 0);let o=e,{accessToken:t}=o,r=T(o,["accessToken"]);this.accessToken=t,this.defaults=c(c({},z.defaults),r)}get responseHeaders(){return p(this,_)}suggest(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:o}=t,n=y(c(c({},this.defaults),t),{sessionToken:r}),i=new URL(`${ue}/${encodeURIComponent(e)}`);i.search=R(this,q,$e).call(this,n);let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});L(this,_,g.headers),yield b(g);let u=yield g.json();return y(c({},u),{suggestions:u.suggestions.map(v=>y(c({},v),{original_search_text:e})),url:i.toString()})})}retrieve(e,t){return m(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:o}=t,n=f.convert(r),i=new URL(`${le}/${e.action.id}`);i.search=x({access_token:this.accessToken,session_token:n.id});let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});yield b(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"}},V=z;_=new WeakMap,q=new WeakSet,$e=function(e){return x({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:h.convert(e.bbox).toFlatArray().join(",")})},V.defaults={language:"en",proximity:"ip",streets:!0};var D="https://api.mapbox.com/search/searchbox/v1",je="suggest",Ne="retrieve",Ie="category",Ve="reverse",fe=`${D}/${je}`,he=`${D}/${Ne}`,Se=`${D}/${Ie}`,Le=`${D}/${Ve}`;var F,ye,J=class{constructor(e={}){d(this,F);let o=e,{accessToken:t}=o,r=T(o,["accessToken"]);this.accessToken=t,this.defaults=c(c({},J.defaults),r)}suggest(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:o}=t,n=y(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(fe);i.search=R(this,F,ye).call(this,n);let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});yield b(g);let u=yield g.json();return u.url=i.toString(),u})}retrieve(e,t){return m(this,null,function*(){if(!e)throw new Error("suggestion is required");let{sessionToken:r,signal:o}=t,n=f.convert(r),i=new URL(`${he}/${encodeURIComponent(e.mapbox_id)}`);i.search=x({access_token:this.accessToken,session_token:n.id});let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});yield b(g);let u=yield g.json();return u.url=i.toString(),u})}category(r){return m(this,arguments,function*(e,t={}){if(!e)throw new Error("category is required");let o=c(c({},this.defaults),t),n=new URL(`${Se}/${encodeURIComponent(e)}`);n.search=R(this,F,ye).call(this,o);let{fetch:i}=S(),a=yield i(n.toString(),{signal:o.signal});yield b(a);let g=yield a.json();return g.url=n.toString(),g})}reverse(r){return m(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let[o,n]=typeof e=="string"?e.split(",").map(W=>parseFloat(W)):l.convert(e).toArray();if(isNaN(o)||isNaN(n))throw new Error("lngLat is required");let i=c(c({},this.defaults),t),a=new URL(Le);a.search=x({access_token:this.accessToken,language:i.language,limit:i.limit,longitude:o,latitude:n},i.types&&{types:typeof i.types=="string"?i.types:[...i.types].join(",")});let{fetch:g}=S(),u=yield g(a.toString(),{signal:i.signal});yield b(u);let v=yield u.json();return v.url=a.toString(),v})}},M=J;F=new WeakSet,ye=function(e){return x({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,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:h.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},M.defaults={language:"en"};var qe="https://api.mapbox.com/autofill/v1",De="retrieve",be=`${qe}/${De}`;var K,Me,Z=class{constructor(e={}){d(this,K);let o=e,{accessToken:t}=o,r=T(o,["accessToken"]);this.accessToken=t,this.defaults=c(c({},Z.defaults),r)}validate(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:o}=t,n=y(c(c({},this.defaults),t),{sessionToken:r}),i=new URL(`${be}/${encodeURIComponent(e)}`);i.search=R(this,K,Me).call(this,n);let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});yield b(g);let u=yield g.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},H=Z;K=new WeakSet,Me=function(e){return x({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:h.convert(e.bbox).toFlatArray().join(",")})},H.defaults={language:"en",proximity:"ip"};var ee="https://api.mapbox.com/search/geocode/v6",xe=`${ee}/forward`,Re=`${ee}/reverse`,Vt=`${ee}/batch`;var He=/^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)[ ]*$/,Ke=/[\s,]+/,w,P,ke,te=class{constructor(e={}){d(this,P);d(this,w,void 0);let o=e,{accessToken:t}=o,r=T(o,["accessToken"]);this.accessToken=t,this.defaults=c({},r)}get responseHeaders(){return p(this,w)}forward(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let r;t&&({signal:r}=t);let o=y(c(c({},this.defaults),t),{q:e}),n=new URL(`${xe}`);n.search=R(this,P,ke).call(this,o);let{fetch:i}=S(),a=r?{signal:r}:{},g=yield i(n.toString(),a);L(this,w,g.headers),yield b(g);let u=yield g.json();return u.url=n.toString(),u})}reverse(e,t){return m(this,null,function*(){if(!e)throw new Error("lngLat is required");let r;t&&({signal:r}=t);let o;if(typeof e=="string"){let[W,ve]=e.split(",");o=new l(Number(W),Number(ve))}else o=l.convert(e);let n=y(c(c({},this.defaults),t),{longitude:o.lng,latitude:o.lat}),i=new URL(`${Re}`);i.search=R(this,P,ke).call(this,n,!0);let{fetch:a}=S(),g=r?{signal:r}:{},u=yield a(i.toString(),g);L(this,w,u.headers),yield b(u);let v=yield u.json();return v.url=i.toString(),v})}suggest(e,t){return m(this,null,function*(){if(He.test(e)){let o=e.trim().split(Ke).map(n=>n.trim()).join(",");return this.reverse(o,t)}else return this.forward(e,t)})}retrieve(e){return m(this,null,function*(){return e})}};w=new WeakMap,P=new WeakSet,ke=function(e,t=!1){return t&&["proximity","autocomplete","bbox"].forEach(r=>{r in e&&delete e[r]}),x({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.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:h.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var re=(n=>(n.matched="matched",n.unmatched="unmatched",n.plausible="plausible",n.not_applicable="not_applicable",n.inferred="inferred",n))(re||{}),se=(o=>(o.exact="exact",o.high="high",o.medium="medium",o.low="low",o))(se||{});var O,B=class{constructor(){d(this,O,{})}addEventListener(e,t){let r=p(this,O);r[e]||(r[e]=[]),r[e].push(t)}removeEventListener(e,t){let r=p(this,O);if(!r[e])return;let o=r[e],n=o.indexOf(t);n!==-1&&o.splice(n,1)}fire(e,t){let r=p(this,O);if(!r[e])return;let o=r[e];for(let n of o)n(t)}};O=new WeakMap;function Q(s,e,t){let r=null;return(...o)=>{r!==null&&clearTimeout(r);let n=t&&t();r=setTimeout(()=>{r=null,!(n==null?void 0:n.aborted)&&s(...o)},e)}}function oe(){let{AbortController:s}=S();return new s}var E,U,C,A,k,G,ne=class extends B{constructor(e,t=0){super();d(this,E,new f);d(this,U,0);d(this,C,!1);d(this,A,void 0);d(this,k,oe());d(this,G,void 0);L(this,G,Q((n,...i)=>m(this,[n,...i],function*(r,o={}){if(p(this,k).abort(),L(this,k,oe()),!r){L(this,A,null),this.fire("suggest",p(this,A));return}try{let a=yield this.search.suggest(r,y(c({sessionToken:this.sessionToken},o),{signal:p(this,k).signal}));L(this,A,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>p(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get sessionToken(){return p(this,C)?p(this,E).id:`${p(this,E).id}.${p(this,U)}`}set sessionToken(e){L(this,C,!0),L(this,E,new f(e))}get suggestions(){return p(this,A)}suggest(e,t){return p(this,G).call(this,e,t),new Promise((r,o)=>{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),o(a)},this.addEventListener("suggest",n),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return m(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(){p(this,k).abort(),L(this,k,oe())}incrementSession(){ge(this,U)._++}};E=new WeakMap,U=new WeakMap,C=new WeakMap,A=new WeakMap,k=new WeakMap,G=new WeakMap;function Te(s){let{properties:e}=s;return c({},e)}module.exports=Be(Qe); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
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);})(); | ||
var mapboxsearchcore=(()=>{var j=Object.defineProperty,Ae=Object.defineProperties,we=Object.getOwnPropertyDescriptor,Oe=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertyNames,$=Object.getOwnPropertySymbols;var Y=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var ie=(s,e,t)=>e in s?j(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,c=(s,e)=>{for(var t in e||(e={}))Y.call(e,t)&&ie(s,t,e[t]);if($)for(var t of $(e))ae.call(e,t)&&ie(s,t,e[t]);return s},y=(s,e)=>Ae(s,Oe(e)),_e=s=>j(s,"__esModule",{value:!0});var T=(s,e)=>{var t={};for(var r in s)Y.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&$)for(var r of $(s))e.indexOf(r)<0&&ae.call(s,r)&&(t[r]=s[r]);return t};var Fe=(s,e)=>{for(var t in e)j(s,t,{get:e[t],enumerable:!0})},Pe=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ee(e))!Y.call(s,o)&&(t||o!=="default")&&j(s,o,{get:()=>e[o],enumerable:!(r=we(e,o))||r.enumerable});return s};var Be=(s=>(e,t)=>s&&s.get(e)||(t=Pe(_e({}),e,1),s&&s.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var X=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var p=(s,e,t)=>(X(s,e,"read from private field"),t?t.call(s):e.get(s)),d=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},L=(s,e,t,r)=>(X(s,e,"write to private field"),r?r.call(s,t):e.set(s,t),t),ge=(s,e,t,r)=>({set _(o){L(s,e,o,t)},get _(){return p(s,e,r)}}),R=(s,e,t)=>(X(s,e,"access private method"),t);var m=(s,e,t)=>new Promise((r,o)=>{var n=g=>{try{a(t.next(g))}catch(u){o(u)}},i=g=>{try{a(t.throw(g))}catch(u){o(u)}},a=g=>g.done?r(g.value):Promise.resolve(g.value).then(n,i);a((t=t.apply(s,e)).next())});var Qe={};Fe(Qe,{AddressAutofillCore:()=>V,Evented:()=>B,GeocodingCore:()=>te,LngLat:()=>l,LngLatBounds:()=>h,MapboxAutofill:()=>V,MapboxError:()=>N,MapboxGeocode:()=>te,MapboxValidate:()=>H,MatchCodeConfidence:()=>se,MatchCodeType:()=>re,SearchBoxCore:()=>M,SearchSession:()=>ne,SessionToken:()=>f,ValidationCore:()=>H,debounce:()=>Q,featureToSuggestion:()=>Te,polyfillFetch:()=>de});var ce="https://api.mapbox.com/autofill/v1",Ue="suggest",Ce="retrieve",ue=`${ce}/${Ue}`,le=`${ce}/${Ce}`;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 h=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 h)return new h(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new h(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new h(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 pe(){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:pe()}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString())}};var Ge="Unknown error",N=class extends Error{constructor(e,t){super(String(e.message||e.error||Ge));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function b(s){return m(this,null,function*(){if(!s.ok){let e=yield s.json();throw new N(e,s.status)}})}var I=globalThis.fetch,me=globalThis.AbortController;function de({fetch:s,AbortController:e},t=!1){if(!s)throw new Error("Fetch implementation must include implementations of `fetch`.");I&&!t||(I=s,me=e)}function S(){if(!I)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:I,AbortController:me}}function x(...s){let e=[];for(let t of s){if(!t)continue;let r=Object.entries(t);for(let[o,n]of r)n!=null&&e.push(`${o}=${encodeURIComponent(String(n))}`)}return e.join("&")}var _,q,$e,z=class{constructor(e={}){d(this,q);d(this,_,void 0);let o=e,{accessToken:t}=o,r=T(o,["accessToken"]);this.accessToken=t,this.defaults=c(c({},z.defaults),r)}get responseHeaders(){return p(this,_)}suggest(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:o}=t,n=y(c(c({},this.defaults),t),{sessionToken:r}),i=new URL(`${ue}/${encodeURIComponent(e)}`);i.search=R(this,q,$e).call(this,n);let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});L(this,_,g.headers),yield b(g);let u=yield g.json();return y(c({},u),{suggestions:u.suggestions.map(v=>y(c({},v),{original_search_text:e})),url:i.toString()})})}retrieve(e,t){return m(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:o}=t,n=f.convert(r),i=new URL(`${le}/${e.action.id}`);i.search=x({access_token:this.accessToken,session_token:n.id});let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});yield b(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"}},V=z;_=new WeakMap,q=new WeakSet,$e=function(e){return x({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:h.convert(e.bbox).toFlatArray().join(",")})},V.defaults={language:"en",proximity:"ip",streets:!0};var D="https://api.mapbox.com/search/searchbox/v1",je="suggest",Ne="retrieve",Ie="category",Ve="reverse",fe=`${D}/${je}`,he=`${D}/${Ne}`,Se=`${D}/${Ie}`,Le=`${D}/${Ve}`;var F,ye,J=class{constructor(e={}){d(this,F);let o=e,{accessToken:t}=o,r=T(o,["accessToken"]);this.accessToken=t,this.defaults=c(c({},J.defaults),r)}suggest(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:o}=t,n=y(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(fe);i.search=R(this,F,ye).call(this,n);let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});yield b(g);let u=yield g.json();return u.url=i.toString(),u})}retrieve(e,t){return m(this,null,function*(){if(!e)throw new Error("suggestion is required");let{sessionToken:r,signal:o}=t,n=f.convert(r),i=new URL(`${he}/${encodeURIComponent(e.mapbox_id)}`);i.search=x({access_token:this.accessToken,session_token:n.id});let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});yield b(g);let u=yield g.json();return u.url=i.toString(),u})}category(r){return m(this,arguments,function*(e,t={}){if(!e)throw new Error("category is required");let o=c(c({},this.defaults),t),n=new URL(`${Se}/${encodeURIComponent(e)}`);n.search=R(this,F,ye).call(this,o);let{fetch:i}=S(),a=yield i(n.toString(),{signal:o.signal});yield b(a);let g=yield a.json();return g.url=n.toString(),g})}reverse(r){return m(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let[o,n]=typeof e=="string"?e.split(",").map(W=>parseFloat(W)):l.convert(e).toArray();if(isNaN(o)||isNaN(n))throw new Error("lngLat is required");let i=c(c({},this.defaults),t),a=new URL(Le);a.search=x({access_token:this.accessToken,language:i.language,limit:i.limit,longitude:o,latitude:n},i.types&&{types:typeof i.types=="string"?i.types:[...i.types].join(",")});let{fetch:g}=S(),u=yield g(a.toString(),{signal:i.signal});yield b(u);let v=yield u.json();return v.url=a.toString(),v})}},M=J;F=new WeakSet,ye=function(e){return x({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,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:h.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},M.defaults={language:"en"};var qe="https://api.mapbox.com/autofill/v1",De="retrieve",be=`${qe}/${De}`;var K,Me,Z=class{constructor(e={}){d(this,K);let o=e,{accessToken:t}=o,r=T(o,["accessToken"]);this.accessToken=t,this.defaults=c(c({},Z.defaults),r)}validate(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:o}=t,n=y(c(c({},this.defaults),t),{sessionToken:r}),i=new URL(`${be}/${encodeURIComponent(e)}`);i.search=R(this,K,Me).call(this,n);let{fetch:a}=S(),g=yield a(i.toString(),{signal:o});yield b(g);let u=yield g.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},H=Z;K=new WeakSet,Me=function(e){return x({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:h.convert(e.bbox).toFlatArray().join(",")})},H.defaults={language:"en",proximity:"ip"};var ee="https://api.mapbox.com/search/geocode/v6",xe=`${ee}/forward`,Re=`${ee}/reverse`,Vt=`${ee}/batch`;var He=/^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)[ ]*$/,Ke=/[\s,]+/,w,P,ke,te=class{constructor(e={}){d(this,P);d(this,w,void 0);let o=e,{accessToken:t}=o,r=T(o,["accessToken"]);this.accessToken=t,this.defaults=c({},r)}get responseHeaders(){return p(this,w)}forward(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let r;t&&({signal:r}=t);let o=y(c(c({},this.defaults),t),{q:e}),n=new URL(`${xe}`);n.search=R(this,P,ke).call(this,o);let{fetch:i}=S(),a=r?{signal:r}:{},g=yield i(n.toString(),a);L(this,w,g.headers),yield b(g);let u=yield g.json();return u.url=n.toString(),u})}reverse(e,t){return m(this,null,function*(){if(!e)throw new Error("lngLat is required");let r;t&&({signal:r}=t);let o;if(typeof e=="string"){let[W,ve]=e.split(",");o=new l(Number(W),Number(ve))}else o=l.convert(e);let n=y(c(c({},this.defaults),t),{longitude:o.lng,latitude:o.lat}),i=new URL(`${Re}`);i.search=R(this,P,ke).call(this,n,!0);let{fetch:a}=S(),g=r?{signal:r}:{},u=yield a(i.toString(),g);L(this,w,u.headers),yield b(u);let v=yield u.json();return v.url=i.toString(),v})}suggest(e,t){return m(this,null,function*(){if(He.test(e)){let o=e.trim().split(Ke).map(n=>n.trim()).join(",");return this.reverse(o,t)}else return this.forward(e,t)})}retrieve(e){return m(this,null,function*(){return e})}};w=new WeakMap,P=new WeakSet,ke=function(e,t=!1){return t&&["proximity","autocomplete","bbox"].forEach(r=>{r in e&&delete e[r]}),x({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.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:h.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var re=(n=>(n.matched="matched",n.unmatched="unmatched",n.plausible="plausible",n.not_applicable="not_applicable",n.inferred="inferred",n))(re||{}),se=(o=>(o.exact="exact",o.high="high",o.medium="medium",o.low="low",o))(se||{});var O,B=class{constructor(){d(this,O,{})}addEventListener(e,t){let r=p(this,O);r[e]||(r[e]=[]),r[e].push(t)}removeEventListener(e,t){let r=p(this,O);if(!r[e])return;let o=r[e],n=o.indexOf(t);n!==-1&&o.splice(n,1)}fire(e,t){let r=p(this,O);if(!r[e])return;let o=r[e];for(let n of o)n(t)}};O=new WeakMap;function Q(s,e,t){let r=null;return(...o)=>{r!==null&&clearTimeout(r);let n=t&&t();r=setTimeout(()=>{r=null,!(n==null?void 0:n.aborted)&&s(...o)},e)}}function oe(){let{AbortController:s}=S();return new s}var E,U,C,A,k,G,ne=class extends B{constructor(e,t=0){super();d(this,E,new f);d(this,U,0);d(this,C,!1);d(this,A,void 0);d(this,k,oe());d(this,G,void 0);L(this,G,Q((n,...i)=>m(this,[n,...i],function*(r,o={}){if(p(this,k).abort(),L(this,k,oe()),!r){L(this,A,null),this.fire("suggest",p(this,A));return}try{let a=yield this.search.suggest(r,y(c({sessionToken:this.sessionToken},o),{signal:p(this,k).signal}));L(this,A,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>p(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get sessionToken(){return p(this,C)?p(this,E).id:`${p(this,E).id}.${p(this,U)}`}set sessionToken(e){L(this,C,!0),L(this,E,new f(e))}get suggestions(){return p(this,A)}suggest(e,t){return p(this,G).call(this,e,t),new Promise((r,o)=>{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),o(a)},this.addEventListener("suggest",n),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return m(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(){p(this,k).abort(),L(this,k,oe())}incrementSession(){ge(this,U)._++}};E=new WeakMap,U=new WeakMap,C=new WeakMap,A=new WeakMap,k=new WeakMap,G=new WeakMap;function Te(s){let{properties:e}=s;return c({},e)}return Be(Qe);})(); | ||
//# sourceMappingURL=mapboxsearchcore.js.map |
@@ -42,7 +42,7 @@ import { SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion, SearchBoxCategorySuggestion } from './types'; | ||
*/ | ||
language: string; | ||
language?: string; | ||
/** | ||
* The number of results to return, up to `10`. | ||
*/ | ||
limit: string | number; | ||
limit?: string | number; | ||
/** | ||
@@ -54,3 +54,3 @@ * Bias the response to favor results that are closer to this location. | ||
*/ | ||
proximity: string | LngLatLike; | ||
proximity?: string | LngLatLike; | ||
/** | ||
@@ -68,7 +68,7 @@ * The location from which to calculate distance. **This parameter may incur additional latency.** | ||
*/ | ||
origin: string | LngLatLike; | ||
origin?: string | LngLatLike; | ||
/** | ||
* Limit results to only those contained within the supplied bounding box. | ||
*/ | ||
bbox: string | LngLatBoundsLike; | ||
bbox?: string | LngLatBoundsLike; | ||
/** | ||
@@ -119,3 +119,3 @@ * The navigation routing profile to use for distance/eta calculations. | ||
*/ | ||
country: string; | ||
country?: string; | ||
/** | ||
@@ -137,6 +137,2 @@ * Limit results to one or more types of features. If no types are specified, all possible types may be returned. | ||
/** | ||
* A customer provided user id. | ||
*/ | ||
user_id?: string; | ||
/** | ||
* A comma-separated list of rich metadata providers to include in a suggestion result. | ||
@@ -143,0 +139,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
import { SessionToken, SessionTokenLike } from './SessionToken'; | ||
import { SessionTokenLike } from './SessionToken'; | ||
import { Evented } from './utils/Evented'; | ||
@@ -109,3 +109,4 @@ interface EventTypes<SuggestionResponse, RetrieveResponse> { | ||
*/ | ||
sessionToken: SessionToken; | ||
get sessionToken(): string; | ||
set sessionToken(token: string); | ||
/** | ||
@@ -194,3 +195,7 @@ * The suggestions from the last successful suggest call, if any. | ||
abort(): void; | ||
/** | ||
* Increments the session counter. | ||
*/ | ||
incrementSession(): void; | ||
} | ||
export {}; |
import { LngLatBoundsLike } from '../LngLatBounds'; | ||
import { MatchCode } from '../types'; | ||
/** | ||
* Object representing one level of hierarcy among encompassing parent features for a given {@link ValidationFeature}. | ||
* | ||
* @typedef ValidationFeatureContextComponent | ||
*/ | ||
export interface ValidationFeatureContextComponent { | ||
/** | ||
* An identifier prefixed with the component type, for example `country.123`. | ||
*/ | ||
id: string; | ||
/** | ||
* The unique Mapbox ID of the context feature. | ||
*/ | ||
mapbox_id: string; | ||
/** | ||
* A string representing the feature in the requested language, if specified. | ||
*/ | ||
text: string; | ||
/** | ||
* The [Wikidata](https://wikidata.org/) identifier for the returned feature. | ||
*/ | ||
wikidata_id?: string; | ||
} | ||
/** | ||
* Validation feature properties from the Mapbox Validation API. | ||
@@ -34,2 +57,6 @@ * | ||
/** | ||
* Feature id. The `mapbox_id` uniquely identifies a feature in the Mapbox search database. | ||
*/ | ||
mapbox_id: string; | ||
/** | ||
* The name of the [Maki](https://labs.mapbox.com/maki-icons/) icon associated with the feature. | ||
@@ -102,2 +129,6 @@ */ | ||
match_code: MatchCode; | ||
/** | ||
* An array of context objects representing the hierarchy of encompassing parent features for a given feature. | ||
*/ | ||
context: ValidationFeatureContextComponent[]; | ||
} | ||
@@ -104,0 +135,0 @@ /** |
/* eslint @typescript-eslint/no-var-requires: "off" */ | ||
require('cross-fetch/polyfill'); | ||
// Test SearchBoxCore in Node environment | ||
const { SearchBoxCore, SessionToken } = require('../dist'); | ||
const search = new SearchBoxCore({ | ||
accessToken: process.env.MAPBOX_ACCESS_TOKEN | ||
}); | ||
const sessionToken = new SessionToken(); | ||
search | ||
.suggest('740 15th St NW', { sessionToken }) | ||
.then((res) => | ||
console.log( | ||
res.suggestions[0].name + ', ' + res.suggestions[0].place_formatted | ||
) | ||
(async () => { | ||
let search; | ||
let sessionToken; | ||
let res; | ||
const { | ||
SearchBoxCore, | ||
GeocodingCore, | ||
AddressAutofillCore, | ||
SessionToken | ||
} = require('../dist'); | ||
// Test SearchBoxCore in Node environment | ||
search = new SearchBoxCore({ | ||
accessToken: process.env.MAPBOX_ACCESS_TOKEN | ||
}); | ||
sessionToken = new SessionToken(); | ||
res = await search.suggest('740 15th St NW', { sessionToken }); | ||
console.log( | ||
'SearchBoxCore: ', | ||
res.suggestions[0].name + ', ' + res.suggestions[0].place_formatted | ||
); | ||
// Test GeocodingCore in Node environment | ||
search = new GeocodingCore({ | ||
accessToken: process.env.MAPBOX_ACCESS_TOKEN | ||
}); | ||
sessionToken = new SessionToken(); | ||
res = await search.suggest('740 15th St NW', { | ||
sessionToken, | ||
proximity: 'ip' | ||
}); | ||
console.log('GeocodingCore: ', res.features[0].properties.full_address); | ||
// Test AddressAutofillCore in Node environment | ||
search = new AddressAutofillCore({ | ||
accessToken: process.env.MAPBOX_ACCESS_TOKEN | ||
}); | ||
sessionToken = new SessionToken(); | ||
res = await search.suggest('740 15th St NW', { | ||
sessionToken, | ||
proximity: 'ip' | ||
}); | ||
console.log('AddressAutofillCore: ', res.suggestions[0].full_address); | ||
})(); |
{ | ||
"name": "@mapbox/search-js-core", | ||
"version": "1.0.0-beta.22", | ||
"version": "1.0.0-beta.23", | ||
"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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
1621894
55
5432
1
4