Socket
Socket
Sign inDemoInstall

@mapbox/search-js-core

Package Overview
Dependencies
Maintainers
14
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.10 to 1.0.0-beta.11

.turbo/turbo-size-limit.log

10

dist/autofill/MapboxAutofill.d.ts

@@ -155,5 +155,2 @@ import { AutofillSuggestion, AutofillFeatureSuggestion } from './types';

*
* Multiple feature suggestions may be returned from a single address,
* for example an address with multiple buildings.
*
* **Legal terms:**

@@ -177,4 +174,9 @@ *

*/
retrieve(suggestion: string | AutofillSuggestion, optionsArg: SessionTokenOptions & Partial<FetchOptions & AutofillOptions>): Promise<AutofillRetrieveResponse>;
retrieve(suggestion: AutofillSuggestion, optionsArg: SessionTokenOptions & Partial<FetchOptions>): Promise<AutofillRetrieveResponse>;
/**
* Returns true if {@link MapboxAutofill#retrieve} can be called on this suggestion,
* false otherwise.
*/
canRetrieve(suggestion: AutofillSuggestion): boolean;
}
export {};

73

dist/autofill/types.d.ts
import { LngLatBoundsLike } from '../LngLatBounds';
import { MatchCode } from '../types';
/**
* @typedef AutofillMatchCodeConfidence
*/
export declare enum AutofillMatchCodeConfidence {
/**
* An exact match.
*/
exact = "exact",
/**
* High confidence of a match.
*/
high = "high",
/**
* Medium confidence of a match.
*/
medium = "medium",
/**
* Low confidence of a match.
*/
low = "low"
}
/**
* 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.
*
* @typedef AutofillMatchCode
*/
export interface AutofillMatchCode {
/**
* A measure of confidence that the returned feature suggestion matches the intended address, based on the search text provided.
*/
confidence: AutofillMatchCodeConfidence;
/**
* True if the confidence value is "exact".
*/
exact_match: boolean;
/**
* True if the house number component was matched.
*/
house_number: boolean;
/**
* True if the street component was matched.
*/
street: boolean;
/**
* True if the postcode was matched.
*/
postcode: boolean;
/**
* True if the place component was matched.
*/
place: boolean;
/**
* True if the region component was matched.
*/
region?: boolean;
/**
* True if the locality component was matched.
*/
locality?: boolean;
}
/**
* An `AutofillSuggestion` object represents a suggestion

@@ -171,3 +111,10 @@ * result from the Mapbox Autofill API.

*/
match_code: AutofillMatchCode;
match_code: MatchCode;
/**
* Action block of the suggestion result.
* contains id to execute retrieve
*/
action: {
id: string;
};
}

@@ -195,3 +142,3 @@ /**

*/
export declare type AutofillFeatureSuggestion = GeoJSON.Feature<GeoJSON.Point, AutofillSuggestion> & {
export declare type AutofillFeatureSuggestion = GeoJSON.Feature<GeoJSON.Point, Omit<AutofillSuggestion, 'original_search_text' | 'action'>> & {
/**

@@ -198,0 +145,0 @@ * A bounding box for the feature. This may be significantly

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

var __create = Object.create;
var __defProp = Object.defineProperty;

@@ -8,3 +7,2 @@ var __defProps = Object.defineProperties;

var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -50,5 +48,2 @@ var __propIsEnum = Object.prototype.propertyIsEnumerable;

};
var __toESM = (module2, isNodeMode) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {

@@ -77,12 +72,2 @@ return (module2, temp) => {

};
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) => {

@@ -116,3 +101,2 @@ __accessCheck(obj, member, "access private method");

__export(src_exports, {
AutofillMatchCodeConfidence: () => AutofillMatchCodeConfidence,
Evented: () => Evented,

@@ -124,2 +108,4 @@ LngLat: () => LngLat,

MapboxSearch: () => MapboxSearch,
MapboxValidate: () => MapboxValidate,
MatchCodeConfidence: () => MatchCodeConfidence,
SearchSession: () => SearchSession,

@@ -237,39 +223,18 @@ SessionToken: () => SessionToken,

// src/utils/uuid.ts
var import_polyfill_crypto = __toESM(require("polyfill-crypto.getrandomvalues"));
function getRandomValues(arr) {
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.getRandomValues !== "function") {
return (0, import_polyfill_crypto.default)(arr);
}
return globalThis.crypto.getRandomValues(arr);
}
function bytesToUuid(bytes) {
const bits = [...bytes].map((bit) => {
const s = bit.toString(16);
return bit < 16 ? "0" + s : s;
});
return [
...bits.slice(0, 4),
"-",
...bits.slice(4, 6),
"-",
...bits.slice(6, 8),
"-",
...bits.slice(8, 10),
"-",
...bits.slice(10, 16)
].join("");
}
function generateUUID() {
const rnds = getRandomValues(new Uint8Array(16));
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
return bytesToUuid(rnds);
const randomString = Date.now().toString(16) + Math.random().toString(16) + Math.random().toString(16);
const uuidString = randomString.replace(/\./g, "");
const uuid = [
uuidString.slice(0, 8),
uuidString.slice(8, 12),
"4" + uuidString.slice(12, 15) + "-8" + uuidString.slice(15, 18),
uuidString.slice(18, 30)
].join("-");
return uuid;
}
// src/SessionToken.ts
var SESSION_TOKEN_EXPIRY = 60 * 60 * 1e3;
var SessionToken = class {
constructor(id, ts = Date.now()) {
constructor(id) {
this.id = id != null ? id : generateUUID();
this.ts = ts;
}

@@ -280,7 +245,4 @@ toString() {

static convert(token) {
return new SessionToken(token instanceof SessionToken ? token.id : token.toString(), token instanceof SessionToken ? token.ts : Date.now());
return new SessionToken(token instanceof SessionToken ? token.id : token.toString());
}
isExpired() {
return Date.now() - this.ts > SESSION_TOKEN_EXPIRY;
}
};

@@ -374,8 +336,2 @@

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
if (!optionsArg || !optionsArg.sessionToken) {
throw new Error("sessionToken is required");
}
const { sessionToken, signal } = optionsArg;

@@ -407,11 +363,5 @@ const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
if (!this.canRetrieve(suggestion)) {
throw new Error("suggestion cannot be retrieved");
}
if (!optionsArg || !optionsArg.sessionToken) {
throw new Error("sessionToken is required");
}
const { sessionToken: sessionTokenLike, signal } = optionsArg;

@@ -452,5 +402,2 @@ const sessionToken = SessionToken.convert(sessionTokenLike);

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);

@@ -474,5 +421,2 @@ const baseUrl = options.permanent ? PERMANENT_FORWARD_URL : FORWARD_URL;

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);

@@ -562,8 +506,2 @@ const searchText = typeof lngLat === "string" ? lngLat : LngLat.convert(lngLat).toArray().join(",");

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
if (!optionsArg || !optionsArg.sessionToken) {
throw new Error("sessionToken is required");
}
const { sessionToken, signal } = optionsArg;

@@ -595,32 +533,23 @@ const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {

}
if (!this.accessToken) {
throw new Error("accessToken is required");
if (!this.canRetrieve(suggestion)) {
throw new Error("suggestion cannot be retrieved");
}
if (!optionsArg || !optionsArg.sessionToken) {
throw new Error("sessionToken is required");
}
const { sessionToken, signal } = optionsArg;
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
sessionToken
const { sessionToken: sessionTokenLike, signal } = optionsArg;
const sessionToken = SessionToken.convert(sessionTokenLike);
const url = new URL(`${RETRIEVE_URL2}/${suggestion.action.id}`);
url.search = queryParams({
access_token: this.accessToken,
session_token: sessionToken.id
});
const isRichSuggestion = typeof suggestion !== "string";
const searchText = isRichSuggestion ? suggestion.original_search_text : suggestion;
const url = new URL(`${RETRIEVE_URL2}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams2, getQueryParams_fn2).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal
});
const res = yield fetch(url.toString(), { signal });
yield handleNonOkRes(res);
const json = yield res.json();
if (!isRichSuggestion) {
return json;
}
return __spreadProps(__spreadValues({}, json), {
features: json.features.filter((feature) => {
return feature.properties.full_address === suggestion.full_address;
})
});
return json;
});
}
canRetrieve(suggestion) {
const action = suggestion.action;
return typeof (action == null ? void 0 : action.id) === "string";
}
};

@@ -648,10 +577,10 @@ var MapboxAutofill = _MapboxAutofill;

// src/autofill/types.ts
var AutofillMatchCodeConfidence = /* @__PURE__ */ ((AutofillMatchCodeConfidence2) => {
AutofillMatchCodeConfidence2["exact"] = "exact";
AutofillMatchCodeConfidence2["high"] = "high";
AutofillMatchCodeConfidence2["medium"] = "medium";
AutofillMatchCodeConfidence2["low"] = "low";
return AutofillMatchCodeConfidence2;
})(AutofillMatchCodeConfidence || {});
// src/types.ts
var MatchCodeConfidence = /* @__PURE__ */ ((MatchCodeConfidence2) => {
MatchCodeConfidence2["exact"] = "exact";
MatchCodeConfidence2["high"] = "high";
MatchCodeConfidence2["medium"] = "medium";
MatchCodeConfidence2["low"] = "low";
return MatchCodeConfidence2;
})(MatchCodeConfidence || {});

@@ -714,3 +643,2 @@ // src/utils/Evented.ts

// src/SearchSession.ts
var SESSION_TOKEN_NUM = 50;
function createAbortController() {

@@ -720,10 +648,7 @@ const { AbortController } = getFetch();

}
var _persistSessionToken, _sessionToken, _sessionTokenRef, _getSessionTokenForSuggest, getSessionTokenForSuggest_fn, _suggestions, _abort, _suggestDebounce;
var _suggestions, _abort, _suggestDebounce;
var SearchSession = class extends Evented {
constructor(search, wait = 0) {
super();
__privateAdd(this, _getSessionTokenForSuggest);
__privateAdd(this, _persistSessionToken, false);
__privateAdd(this, _sessionToken, new SessionToken());
__privateAdd(this, _sessionTokenRef, 0);
this.sessionToken = new SessionToken();
__privateAdd(this, _suggestions, void 0);

@@ -740,6 +665,5 @@ __privateAdd(this, _abort, createAbortController());

}
const sessionToken = __privateMethod(this, _getSessionTokenForSuggest, getSessionTokenForSuggest_fn).call(this);
try {
const res = yield this.search.suggest(searchText, __spreadProps(__spreadValues({
sessionToken
sessionToken: this.sessionToken
}, options), {

@@ -768,9 +692,2 @@ signal: __privateGet(this, _abort).signal

}
get sessionToken() {
return __privateGet(this, _sessionToken);
}
set sessionToken(token) {
__privateSet(this, _sessionToken, token);
__privateSet(this, _persistSessionToken, true);
}
get suggestions() {

@@ -804,8 +721,4 @@ return __privateGet(this, _suggestions);

const res = yield this.search.retrieve(suggestion, __spreadValues({
sessionToken: __privateGet(this, _sessionToken)
sessionToken: this.sessionToken
}, options));
if (!__privateGet(this, _persistSessionToken)) {
__privateSet(this, _sessionToken, new SessionToken());
__privateSet(this, _sessionTokenRef, 0);
}
this.fire("retrieve", res);

@@ -832,16 +745,2 @@ return res;

};
_persistSessionToken = new WeakMap();
_sessionToken = new WeakMap();
_sessionTokenRef = new WeakMap();
_getSessionTokenForSuggest = new WeakSet();
getSessionTokenForSuggest_fn = function() {
if (!__privateGet(this, _persistSessionToken)) {
if (__privateGet(this, _sessionToken).isExpired() || __privateGet(this, _sessionTokenRef) >= SESSION_TOKEN_NUM) {
__privateSet(this, _sessionToken, new SessionToken());
__privateSet(this, _sessionTokenRef, 0);
}
}
__privateWrapper(this, _sessionTokenRef)._++;
return __privateGet(this, _sessionToken);
};
_suggestions = new WeakMap();

@@ -856,3 +755,61 @@ _abort = new WeakMap();

}
// src/validate/constants.ts
var SEARCH_URL3 = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_VALIDATE = "retrieve";
var VALIDATE_URL = `${SEARCH_URL3}/${ENDPOINT_VALIDATE}`;
// src/validate/MapboxValidate.ts
var _getQueryParams3, getQueryParams_fn3;
var _MapboxValidate = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams3);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);
this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxValidate.defaults), defaults);
}
validate(searchText, optionsArg) {
return __async(this, null, function* () {
if (!searchText) {
throw new Error("searchText is required");
}
const { sessionToken, signal } = optionsArg;
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
sessionToken
});
const url = new URL(`${VALIDATE_URL}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams3, getQueryParams_fn3).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal
});
yield handleNonOkRes(res);
const json = yield res.json();
if (json.features.length > 0) {
json.features = [json.features[0]];
}
return json;
});
}
};
var MapboxValidate = _MapboxValidate;
_getQueryParams3 = new WeakSet();
getQueryParams_fn3 = function(options) {
return queryParams({
access_token: this.accessToken,
language: options.language,
country: options.country
}, options.sessionToken && {
session_token: SessionToken.convert(options.sessionToken).id
}, options.proximity && {
proximity: typeof options.proximity === "string" ? options.proximity : LngLat.convert(options.proximity).toArray().join(",")
}, options.bbox && {
bbox: typeof options.bbox === "string" ? options.bbox : LngLatBounds.convert(options.bbox).toFlatArray().join(",")
});
};
MapboxValidate.defaults = {
language: "en",
proximity: "ip"
};
module.exports = __toCommonJS(src_exports);
//# sourceMappingURL=index-development.js.map

@@ -57,12 +57,2 @@ 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) => {

@@ -198,39 +188,18 @@ __accessCheck(obj, member, "access private method");

// src/utils/uuid.ts
import getRandomValuesPolyfill from "polyfill-crypto.getrandomvalues";
function getRandomValues(arr) {
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.getRandomValues !== "function") {
return getRandomValuesPolyfill(arr);
}
return globalThis.crypto.getRandomValues(arr);
}
function bytesToUuid(bytes) {
const bits = [...bytes].map((bit) => {
const s = bit.toString(16);
return bit < 16 ? "0" + s : s;
});
return [
...bits.slice(0, 4),
"-",
...bits.slice(4, 6),
"-",
...bits.slice(6, 8),
"-",
...bits.slice(8, 10),
"-",
...bits.slice(10, 16)
].join("");
}
function generateUUID() {
const rnds = getRandomValues(new Uint8Array(16));
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
return bytesToUuid(rnds);
const randomString = Date.now().toString(16) + Math.random().toString(16) + Math.random().toString(16);
const uuidString = randomString.replace(/\./g, "");
const uuid = [
uuidString.slice(0, 8),
uuidString.slice(8, 12),
"4" + uuidString.slice(12, 15) + "-8" + uuidString.slice(15, 18),
uuidString.slice(18, 30)
].join("-");
return uuid;
}
// src/SessionToken.ts
var SESSION_TOKEN_EXPIRY = 60 * 60 * 1e3;
var SessionToken = class {
constructor(id, ts = Date.now()) {
constructor(id) {
this.id = id != null ? id : generateUUID();
this.ts = ts;
}

@@ -241,7 +210,4 @@ toString() {

static convert(token) {
return new SessionToken(token instanceof SessionToken ? token.id : token.toString(), token instanceof SessionToken ? token.ts : Date.now());
return new SessionToken(token instanceof SessionToken ? token.id : token.toString());
}
isExpired() {
return Date.now() - this.ts > SESSION_TOKEN_EXPIRY;
}
};

@@ -335,8 +301,2 @@

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
if (!optionsArg || !optionsArg.sessionToken) {
throw new Error("sessionToken is required");
}
const { sessionToken, signal } = optionsArg;

@@ -368,11 +328,5 @@ const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
if (!this.canRetrieve(suggestion)) {
throw new Error("suggestion cannot be retrieved");
}
if (!optionsArg || !optionsArg.sessionToken) {
throw new Error("sessionToken is required");
}
const { sessionToken: sessionTokenLike, signal } = optionsArg;

@@ -413,5 +367,2 @@ const sessionToken = SessionToken.convert(sessionTokenLike);

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);

@@ -435,5 +386,2 @@ const baseUrl = options.permanent ? PERMANENT_FORWARD_URL : FORWARD_URL;

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);

@@ -523,8 +471,2 @@ const searchText = typeof lngLat === "string" ? lngLat : LngLat.convert(lngLat).toArray().join(",");

}
if (!this.accessToken) {
throw new Error("accessToken is required");
}
if (!optionsArg || !optionsArg.sessionToken) {
throw new Error("sessionToken is required");
}
const { sessionToken, signal } = optionsArg;

@@ -556,32 +498,23 @@ const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {

}
if (!this.accessToken) {
throw new Error("accessToken is required");
if (!this.canRetrieve(suggestion)) {
throw new Error("suggestion cannot be retrieved");
}
if (!optionsArg || !optionsArg.sessionToken) {
throw new Error("sessionToken is required");
}
const { sessionToken, signal } = optionsArg;
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
sessionToken
const { sessionToken: sessionTokenLike, signal } = optionsArg;
const sessionToken = SessionToken.convert(sessionTokenLike);
const url = new URL(`${RETRIEVE_URL2}/${suggestion.action.id}`);
url.search = queryParams({
access_token: this.accessToken,
session_token: sessionToken.id
});
const isRichSuggestion = typeof suggestion !== "string";
const searchText = isRichSuggestion ? suggestion.original_search_text : suggestion;
const url = new URL(`${RETRIEVE_URL2}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams2, getQueryParams_fn2).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal
});
const res = yield fetch(url.toString(), { signal });
yield handleNonOkRes(res);
const json = yield res.json();
if (!isRichSuggestion) {
return json;
}
return __spreadProps(__spreadValues({}, json), {
features: json.features.filter((feature) => {
return feature.properties.full_address === suggestion.full_address;
})
});
return json;
});
}
canRetrieve(suggestion) {
const action = suggestion.action;
return typeof (action == null ? void 0 : action.id) === "string";
}
};

@@ -609,10 +542,10 @@ var MapboxAutofill = _MapboxAutofill;

// src/autofill/types.ts
var AutofillMatchCodeConfidence = /* @__PURE__ */ ((AutofillMatchCodeConfidence2) => {
AutofillMatchCodeConfidence2["exact"] = "exact";
AutofillMatchCodeConfidence2["high"] = "high";
AutofillMatchCodeConfidence2["medium"] = "medium";
AutofillMatchCodeConfidence2["low"] = "low";
return AutofillMatchCodeConfidence2;
})(AutofillMatchCodeConfidence || {});
// src/types.ts
var MatchCodeConfidence = /* @__PURE__ */ ((MatchCodeConfidence2) => {
MatchCodeConfidence2["exact"] = "exact";
MatchCodeConfidence2["high"] = "high";
MatchCodeConfidence2["medium"] = "medium";
MatchCodeConfidence2["low"] = "low";
return MatchCodeConfidence2;
})(MatchCodeConfidence || {});

@@ -675,3 +608,2 @@ // src/utils/Evented.ts

// src/SearchSession.ts
var SESSION_TOKEN_NUM = 50;
function createAbortController() {

@@ -681,10 +613,7 @@ const { AbortController } = getFetch();

}
var _persistSessionToken, _sessionToken, _sessionTokenRef, _getSessionTokenForSuggest, getSessionTokenForSuggest_fn, _suggestions, _abort, _suggestDebounce;
var _suggestions, _abort, _suggestDebounce;
var SearchSession = class extends Evented {
constructor(search, wait = 0) {
super();
__privateAdd(this, _getSessionTokenForSuggest);
__privateAdd(this, _persistSessionToken, false);
__privateAdd(this, _sessionToken, new SessionToken());
__privateAdd(this, _sessionTokenRef, 0);
this.sessionToken = new SessionToken();
__privateAdd(this, _suggestions, void 0);

@@ -701,6 +630,5 @@ __privateAdd(this, _abort, createAbortController());

}
const sessionToken = __privateMethod(this, _getSessionTokenForSuggest, getSessionTokenForSuggest_fn).call(this);
try {
const res = yield this.search.suggest(searchText, __spreadProps(__spreadValues({
sessionToken
sessionToken: this.sessionToken
}, options), {

@@ -729,9 +657,2 @@ signal: __privateGet(this, _abort).signal

}
get sessionToken() {
return __privateGet(this, _sessionToken);
}
set sessionToken(token) {
__privateSet(this, _sessionToken, token);
__privateSet(this, _persistSessionToken, true);
}
get suggestions() {

@@ -765,8 +686,4 @@ return __privateGet(this, _suggestions);

const res = yield this.search.retrieve(suggestion, __spreadValues({
sessionToken: __privateGet(this, _sessionToken)
sessionToken: this.sessionToken
}, options));
if (!__privateGet(this, _persistSessionToken)) {
__privateSet(this, _sessionToken, new SessionToken());
__privateSet(this, _sessionTokenRef, 0);
}
this.fire("retrieve", res);

@@ -793,16 +710,2 @@ return res;

};
_persistSessionToken = new WeakMap();
_sessionToken = new WeakMap();
_sessionTokenRef = new WeakMap();
_getSessionTokenForSuggest = new WeakSet();
getSessionTokenForSuggest_fn = function() {
if (!__privateGet(this, _persistSessionToken)) {
if (__privateGet(this, _sessionToken).isExpired() || __privateGet(this, _sessionTokenRef) >= SESSION_TOKEN_NUM) {
__privateSet(this, _sessionToken, new SessionToken());
__privateSet(this, _sessionTokenRef, 0);
}
}
__privateWrapper(this, _sessionTokenRef)._++;
return __privateGet(this, _sessionToken);
};
_suggestions = new WeakMap();

@@ -817,4 +720,61 @@ _abort = new WeakMap();

}
// src/validate/constants.ts
var SEARCH_URL3 = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_VALIDATE = "retrieve";
var VALIDATE_URL = `${SEARCH_URL3}/${ENDPOINT_VALIDATE}`;
// src/validate/MapboxValidate.ts
var _getQueryParams3, getQueryParams_fn3;
var _MapboxValidate = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams3);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);
this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxValidate.defaults), defaults);
}
validate(searchText, optionsArg) {
return __async(this, null, function* () {
if (!searchText) {
throw new Error("searchText is required");
}
const { sessionToken, signal } = optionsArg;
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
sessionToken
});
const url = new URL(`${VALIDATE_URL}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams3, getQueryParams_fn3).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal
});
yield handleNonOkRes(res);
const json = yield res.json();
if (json.features.length > 0) {
json.features = [json.features[0]];
}
return json;
});
}
};
var MapboxValidate = _MapboxValidate;
_getQueryParams3 = new WeakSet();
getQueryParams_fn3 = function(options) {
return queryParams({
access_token: this.accessToken,
language: options.language,
country: options.country
}, options.sessionToken && {
session_token: SessionToken.convert(options.sessionToken).id
}, options.proximity && {
proximity: typeof options.proximity === "string" ? options.proximity : LngLat.convert(options.proximity).toArray().join(",")
}, options.bbox && {
bbox: typeof options.bbox === "string" ? options.bbox : LngLatBounds.convert(options.bbox).toFlatArray().join(",")
});
};
MapboxValidate.defaults = {
language: "en",
proximity: "ip"
};
export {
AutofillMatchCodeConfidence,
Evented,

@@ -826,2 +786,4 @@ LngLat,

MapboxSearch,
MapboxValidate,
MatchCodeConfidence,
SearchSession,

@@ -828,0 +790,0 @@ SessionToken,

import { Options, MapboxSearch, SuggestionResponse, RetrieveResponse } from './search/MapboxSearch';
import { AdministrativeUnitTypes, Suggestion, FeatureSuggestion } from './search/types';
import { AutofillOptions, MapboxAutofill, AutofillSuggestionResponse, AutofillRetrieveResponse } from './autofill/MapboxAutofill';
import { AutofillSuggestion, AutofillFeatureSuggestion, AutofillMatchCode, AutofillMatchCodeConfidence } from './autofill/types';
import { AutofillSuggestion, AutofillFeatureSuggestion } from './autofill/types';
import { MatchCodeConfidence, MatchCode } from './types';
import { ValidateFeature } from './validate/types';
import { SearchSession } from './SearchSession';

@@ -14,2 +16,3 @@ import { SessionToken, SessionTokenLike } from './SessionToken';

import { debounce } from './utils/debounce';
export { Options, MapboxSearch, SuggestionResponse, RetrieveResponse, Suggestion, FeatureSuggestion, AutofillOptions, MapboxAutofill, AutofillSuggestionResponse, AutofillRetrieveResponse, AutofillSuggestion, AutofillFeatureSuggestion, AutofillMatchCode, AutofillMatchCodeConfidence, AdministrativeUnitTypes, SearchSession, SessionToken, SessionTokenLike, MapboxError, LngLat, LngLatLike, LngLatBounds, LngLatBoundsLike, polyfillFetch, featureToSuggestion, Evented, debounce };
import { ValidateOptions, MapboxValidate, ValidateResponse } from './validate/MapboxValidate';
export { Options, MapboxSearch, SuggestionResponse, RetrieveResponse, Suggestion, FeatureSuggestion, AutofillOptions, MapboxAutofill, AutofillSuggestionResponse, AutofillRetrieveResponse, AutofillSuggestion, AutofillFeatureSuggestion, MatchCode, MatchCodeConfidence, AdministrativeUnitTypes, SearchSession, SessionToken, SessionTokenLike, MapboxError, LngLat, LngLatLike, LngLatBounds, LngLatBoundsLike, polyfillFetch, featureToSuggestion, Evented, debounce, ValidateOptions, MapboxValidate, ValidateResponse, ValidateFeature };

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

var Ee=Object.create;var P=Object.defineProperty,xe=Object.defineProperties,_e=Object.getOwnPropertyDescriptor,Oe=Object.getOwnPropertyDescriptors,Ae=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols,Pe=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var ne=(n,e,t)=>e in n?P(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,a=(n,e)=>{for(var t in e||(e={}))M.call(e,t)&&ne(n,t,e[t]);if(j)for(var t of j(e))se.call(e,t)&&ne(n,t,e[t]);return n},b=(n,e)=>xe(n,Oe(e)),re=n=>P(n,"__esModule",{value:!0});var q=(n,e)=>{var t={};for(var s in n)M.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&j)for(var s of j(n))e.indexOf(s)<0&&se.call(n,s)&&(t[s]=n[s]);return t};var Ue=(n,e)=>{for(var t in e)P(n,t,{get:e[t],enumerable:!0})},oe=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ae(e))!M.call(n,r)&&(t||r!=="default")&&P(n,r,{get:()=>e[r],enumerable:!(s=_e(e,r))||s.enumerable});return n},Fe=(n,e)=>oe(re(P(n!=null?Ee(Pe(n)):{},"default",!e&&n&&n.__esModule?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n),Ne=(n=>(e,t)=>n&&n.get(e)||(t=oe(re({}),e,1),n&&n.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var J=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var l=(n,e,t)=>(J(n,e,"read from private field"),t?t.call(n):e.get(n)),m=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},p=(n,e,t,s)=>(J(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t),ie=(n,e,t,s)=>({set _(r){p(n,e,r,t)},get _(){return l(n,e,s)}}),T=(n,e,t)=>(J(n,e,"access private method"),t);var d=(n,e,t)=>new Promise((s,r)=>{var o=i=>{try{c(t.next(i))}catch(h){r(h)}},g=i=>{try{c(t.throw(i))}catch(h){r(h)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(o,g);c((t=t.apply(n,e)).next())});var Ke={};Ue(Ke,{AutofillMatchCodeConfidence:()=>Z,Evented:()=>I,LngLat:()=>u,LngLatBounds:()=>S,MapboxAutofill:()=>G,MapboxError:()=>C,MapboxSearch:()=>D,SearchSession:()=>te,SessionToken:()=>f,debounce:()=>B,featureToSuggestion:()=>ve,polyfillFetch:()=>X});var E="https://api.mapbox.com/search/v1",H="suggest",Q="retrieve",ae="forward",ge="reverse",ue=`${E}/${H}`,ce=`${E}/${Q}`,le=`${E}/${ae}`,fe=`${E}/permanent/${ae}`,me=`${E}/${ge}`,he=`${E}/permanent/${ge}`;var u=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 u)return new u(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new u(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 u(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 S=class{constructor(e,t){this._sw=u.convert(e),this._ne=u.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new u(this.getWest(),this.getNorth())}getSouthEast(){return new u(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 S)return new S(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new S(u.convert(e[0]),u.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new S(u.convert([e[0],e[1]]),u.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>]")}};var pe=Fe(require("polyfill-crypto.getrandomvalues"));function Ie(n){return typeof globalThis.crypto=="undefined"||typeof globalThis.crypto.getRandomValues!="function"?(0,pe.default)(n):globalThis.crypto.getRandomValues(n)}function $e(n){let e=[...n].map(t=>{let s=t.toString(16);return t<16?"0"+s:s});return[...e.slice(0,4),"-",...e.slice(4,6),"-",...e.slice(6,8),"-",...e.slice(8,10),"-",...e.slice(10,16)].join("")}function de(){let n=Ie(new Uint8Array(16));return n[6]=n[6]&15|64,n[8]=n[8]&63|128,$e(n)}var je=60*60*1e3,f=class{constructor(e,t=Date.now()){this.id=e!=null?e:de(),this.ts=t}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString(),e instanceof f?e.ts:Date.now())}isExpired(){return Date.now()-this.ts>je}};var qe="Unknown error",C=class extends Error{constructor(e,t){super(String(e.message||e.error||qe));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function y(n){return d(this,null,function*(){if(!n.ok){let e=yield n.json();throw new C(e,n.status)}})}var U=globalThis.fetch,be=globalThis.AbortController;function X({fetch:n,AbortController:e},t=!1){if(!n)throw new Error("Fetch implementation must include implementations of `fetch`.");U&&!t||(U=n,be=e)}function R(){if(!U)throw new Error("Fetch implementation not found. Please use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:U,AbortController:be}}function Se(n,e){return n(e)}if(!U&&!0&&process.versions.node){let{default:n}=Se(require,"node-fetch"),e=Se(require,"abort-controller");X({fetch:n,AbortController:e})}function x(...n){let e=[];for(let t of n){if(!t)continue;let s=Object.entries(t);for(let[r,o]of s)o!=null&&e.push(`${r}=${encodeURIComponent(String(o))}`)}return e.join("&")}var F,Re,V,Ce,Y=class{constructor(e={}){m(this,F);m(this,V);let r=e,{accessToken:t}=r,s=q(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},Y.defaults),s)}suggest(e,t){return d(this,null,function*(){if(!e)throw new Error("searchText is required");if(!this.accessToken)throw new Error("accessToken is required");if(!t||!t.sessionToken)throw new Error("sessionToken is required");let{sessionToken:s,signal:r}=t,o=b(a(a({},this.defaults),t),{sessionToken:s});if(o.eta_type&&(!o.origin||!o.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(o.origin&&!o.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let g=new URL(`${ue}/${encodeURIComponent(e)}`);g.search=T(this,F,Re).call(this,o);let{fetch:c}=R(),i=yield c(g.toString(),{signal:r});return yield y(i),yield i.json()})}retrieve(e,t){return d(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.accessToken)throw new Error("accessToken is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");if(!t||!t.sessionToken)throw new Error("sessionToken is required");let{sessionToken:s,signal:r}=t,o=f.convert(s),g=new URL(ce);g.search=x({access_token:this.accessToken,session_token:o.id});let{fetch:c}=R(),i=yield c(g.toString(),b(a({},T(this,V,Ce).call(this,e)),{signal:r}));return yield y(i),yield i.json()})}canRetrieve(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===Q:!1}canSuggest(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===H:!1}forward(s){return d(this,arguments,function*(e,t={}){if(!e)throw new Error("searchText is required");if(!this.accessToken)throw new Error("accessToken is required");let r=a(a({},this.defaults),t),o=r.permanent?fe:le,g=new URL(`${o}/${encodeURIComponent(e)}`);g.search=T(this,F,Re).call(this,r);let{fetch:c}=R(),i=yield c(g.toString(),{signal:r.signal});return yield y(i),yield i.json()})}reverse(s){return d(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");if(!this.accessToken)throw new Error("accessToken is required");let r=a(a({},this.defaults),t),o=typeof e=="string"?e:u.convert(e).toArray().join(","),g=r.permanent?he:me,c=new URL(`${g}/${encodeURIComponent(o)}`);c.search=x({access_token:this.accessToken,language:r.language,limit:r.limit},r.types&&{types:typeof r.types=="string"?r.types:[...r.types].join(",")});let{fetch:i}=R(),h=yield i(c.toString(),{signal:r.signal});return yield y(h),yield h.json()})}},D=Y;F=new WeakSet,Re=function(e){return x({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,navigation_profile:e.navigation_profile,eta_type:e.eta_type},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.origin&&{origin:typeof e.origin=="string"?e.origin:u.convert(e.origin).toArray().join(",")},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:S.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},V=new WeakSet,Ce=function(e){if(!this.canRetrieve(e)&&!this.canSuggest(e))throw new Error("Suggestion cannot be retrieved or suggested");let t=e.action,s=JSON.stringify(t.body);return{method:t.method,body:s,headers:{"Content-Type":"application/json","Content-Length":s.length.toString()}}},D.defaults={language:"en"};var Le="https://api.mapbox.com/autofill/v1",De="suggest",Ve="retrieve",Te=`${Le}/${De}`,ke=`${Le}/${Ve}`;var N,ye,z=class{constructor(e={}){m(this,N);let r=e,{accessToken:t}=r,s=q(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},z.defaults),s)}suggest(e,t){return d(this,null,function*(){if(!e)throw new Error("searchText is required");if(!this.accessToken)throw new Error("accessToken is required");if(!t||!t.sessionToken)throw new Error("sessionToken is required");let{sessionToken:s,signal:r}=t,o=b(a(a({},this.defaults),t),{sessionToken:s}),g=new URL(`${Te}/${encodeURIComponent(e)}`);g.search=T(this,N,ye).call(this,o);let{fetch:c}=R(),i=yield c(g.toString(),{signal:r});yield y(i);let h=yield i.json();return b(a({},h),{suggestions:h.suggestions.map(A=>b(a({},A),{original_search_text:e}))})})}retrieve(e,t){return d(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.accessToken)throw new Error("accessToken is required");if(!t||!t.sessionToken)throw new Error("sessionToken is required");let{sessionToken:s,signal:r}=t,o=b(a(a({},this.defaults),t),{sessionToken:s}),g=typeof e!="string",c=g?e.original_search_text:e,i=new URL(`${ke}/${encodeURIComponent(c)}`);i.search=T(this,N,ye).call(this,o);let{fetch:h}=R(),A=yield h(i.toString(),{signal:r});yield y(A);let W=yield A.json();return g?b(a({},W),{features:W.features.filter(we=>we.properties.full_address===e.full_address)}):W})}},G=z;N=new WeakSet,ye=function(e){return x({access_token:this.accessToken,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:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:S.convert(e.bbox).toFlatArray().join(",")})},G.defaults={language:"en",proximity:"ip"};var Z=(r=>(r.exact="exact",r.high="high",r.medium="medium",r.low="low",r))(Z||{});var _,I=class{constructor(){m(this,_,{})}addEventListener(e,t){let s=l(this,_);s[e]||(s[e]=[]),s[e].push(t)}removeEventListener(e,t){let s=l(this,_);if(!s[e])return;let r=s[e],o=r.indexOf(t);o!==-1&&r.splice(o,1)}fire(e,t){let s=l(this,_);if(!s[e])return;let r=s[e];for(let o of r)o(t)}};_=new WeakMap;function B(n,e,t){let s=null;return(...r)=>{s!==null&&clearTimeout(s);let o=t&&t();s=setTimeout(()=>{s=null,!(o==null?void 0:o.aborted)&&n(...r)},e)}}var Ge=50;function ee(){let{AbortController:n}=R();return new n}var O,L,v,K,Be,w,k,$,te=class extends I{constructor(e,t=0){super();m(this,K);m(this,O,!1);m(this,L,new f);m(this,v,0);m(this,w,void 0);m(this,k,ee());m(this,$,void 0);p(this,$,B((o,...g)=>d(this,[o,...g],function*(s,r={}){if(l(this,k).abort(),p(this,k,ee()),!s){p(this,w,null),this.fire("suggest",l(this,w));return}let c=T(this,K,Be).call(this);try{let i=yield this.search.suggest(s,b(a({sessionToken:c},r),{signal:l(this,k).signal}));p(this,w,i),this.fire("suggest",i)}catch(i){if(i.name==="AbortError")return;this.fire("suggesterror",i)}}),t,()=>l(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get sessionToken(){return l(this,L)}set sessionToken(e){p(this,L,e),p(this,O,!0)}get suggestions(){return l(this,w)}suggest(e,t){return l(this,$).call(this,e,t),new Promise((s,r)=>{let o,g;o=c=>{this.removeEventListener("suggest",o),this.removeEventListener("suggesterror",g),s(c)},g=c=>{this.removeEventListener("suggest",o),this.removeEventListener("suggesterror",g),r(c)},this.addEventListener("suggest",o),this.addEventListener("suggesterror",g)})}clear(){this.suggest("")}retrieve(e,t){return d(this,null,function*(){let s=yield this.search.retrieve(e,a({sessionToken:l(this,L)},t));return l(this,O)||(p(this,L,new f),p(this,v,0)),this.fire("retrieve",s),s})}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(),p(this,k,ee())}};O=new WeakMap,L=new WeakMap,v=new WeakMap,K=new WeakSet,Be=function(){return l(this,O)||(l(this,L).isExpired()||l(this,v)>=Ge)&&(p(this,L,new f),p(this,v,0)),ie(this,v)._++,l(this,L)},w=new WeakMap,k=new WeakMap,$=new WeakMap;function ve(n){let{properties:e}=n;return a({},e)}module.exports=Ne(Ke);
var U=Object.defineProperty,Se=Object.defineProperties,Re=Object.getOwnPropertyDescriptor,ke=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertyNames,F=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var ee=(n,e,t)=>e in n?U(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e)=>{for(var t in e||(e={}))B.call(e,t)&&ee(n,t,e[t]);if(F)for(var t of F(e))te.call(e,t)&&ee(n,t,e[t]);return n},b=(n,e)=>Se(n,ke(e)),ve=n=>U(n,"__esModule",{value:!0});var T=(n,e)=>{var t={};for(var o in n)B.call(n,o)&&e.indexOf(o)<0&&(t[o]=n[o]);if(n!=null&&F)for(var o of F(n))e.indexOf(o)<0&&te.call(n,o)&&(t[o]=n[o]);return t};var Te=(n,e)=>{for(var t in e)U(n,t,{get:e[t],enumerable:!0})},Ee=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ye(e))!B.call(n,s)&&(t||s!=="default")&&U(n,s,{get:()=>e[s],enumerable:!(o=Re(e,s))||o.enumerable});return n};var xe=(n=>(e,t)=>n&&n.get(e)||(t=Ee(ve({}),e,1),n&&n.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var G=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var L=(n,e,t)=>(G(n,e,"read from private field"),t?t.call(n):e.get(n)),h=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},E=(n,e,t,o)=>(G(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);var y=(n,e,t)=>(G(n,e,"access private method"),t);var f=(n,e,t)=>new Promise((o,s)=>{var r=a=>{try{i(t.next(a))}catch(l){s(l)}},u=a=>{try{i(t.throw(a))}catch(l){s(l)}},i=a=>a.done?o(a.value):Promise.resolve(a.value).then(r,u);i((t=t.apply(n,e)).next())});var $e={};Te($e,{Evented:()=>P,LngLat:()=>c,LngLatBounds:()=>p,MapboxAutofill:()=>I,MapboxError:()=>N,MapboxSearch:()=>$,MapboxValidate:()=>D,MatchCodeConfidence:()=>J,SearchSession:()=>X,SessionToken:()=>m,debounce:()=>C,featureToSuggestion:()=>de,polyfillFetch:()=>M});var x="https://api.mapbox.com/search/v1",W="suggest",K="retrieve",ne="forward",oe="reverse",se=`${x}/${W}`,re=`${x}/${K}`,ie=`${x}/${ne}`,ae=`${x}/permanent/${ne}`,ge=`${x}/${oe}`,ue=`${x}/permanent/${oe}`;var c=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 c)return new c(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new c(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 c(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 p=class{constructor(e,t){this._sw=c.convert(e),this._ne=c.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new c(this.getWest(),this.getNorth())}getSouthEast(){return new c(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 p)return new p(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new p(c.convert(e[0]),c.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new p(c.convert([e[0],e[1]]),c.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 ce(){let e=(Date.now().toString(16)+Math.random().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 m=class{constructor(e){this.id=e!=null?e:ce()}toString(){return this.id}static convert(e){return new m(e instanceof m?e.id:e.toString())}};var we="Unknown error",N=class extends Error{constructor(e,t){super(String(e.message||e.error||we));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function S(n){return f(this,null,function*(){if(!n.ok){let e=yield n.json();throw new N(e,n.status)}})}var A=globalThis.fetch,me=globalThis.AbortController;function M({fetch:n,AbortController:e},t=!1){if(!n)throw new Error("Fetch implementation must include implementations of `fetch`.");A&&!t||(A=n,me=e)}function d(){if(!A)throw new Error("Fetch implementation not found. Please use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:A,AbortController:me}}function le(n,e){return n(e)}if(!A&&!0&&process.versions.node){let{default:n}=le(require,"node-fetch"),e=le(require,"abort-controller");M({fetch:n,AbortController:e})}function R(...n){let e=[];for(let t of n){if(!t)continue;let o=Object.entries(t);for(let[s,r]of o)r!=null&&e.push(`${s}=${encodeURIComponent(String(r))}`)}return e.join("&")}var O,fe,j,Ae,H=class{constructor(e={}){h(this,O);h(this,j);let s=e,{accessToken:t}=s,o=T(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},H.defaults),o)}suggest(e,t){return f(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:o,signal:s}=t,r=b(g(g({},this.defaults),t),{sessionToken:o});if(r.eta_type&&(!r.origin||!r.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(r.origin&&!r.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let u=new URL(`${se}/${encodeURIComponent(e)}`);u.search=y(this,O,fe).call(this,r);let{fetch:i}=d(),a=yield i(u.toString(),{signal:s});return yield S(a),yield a.json()})}retrieve(e,t){return f(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:o,signal:s}=t,r=m.convert(o),u=new URL(re);u.search=R({access_token:this.accessToken,session_token:r.id});let{fetch:i}=d(),a=yield i(u.toString(),b(g({},y(this,j,Ae).call(this,e)),{signal:s}));return yield S(a),yield a.json()})}canRetrieve(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===K:!1}canSuggest(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===W:!1}forward(o){return f(this,arguments,function*(e,t={}){if(!e)throw new Error("searchText is required");let s=g(g({},this.defaults),t),r=s.permanent?ae:ie,u=new URL(`${r}/${encodeURIComponent(e)}`);u.search=y(this,O,fe).call(this,s);let{fetch:i}=d(),a=yield i(u.toString(),{signal:s.signal});return yield S(a),yield a.json()})}reverse(o){return f(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let s=g(g({},this.defaults),t),r=typeof e=="string"?e:c.convert(e).toArray().join(","),u=s.permanent?ue:ge,i=new URL(`${u}/${encodeURIComponent(r)}`);i.search=R({access_token:this.accessToken,language:s.language,limit:s.limit},s.types&&{types:typeof s.types=="string"?s.types:[...s.types].join(",")});let{fetch:a}=d(),l=yield a(i.toString(),{signal:s.signal});return yield S(l),yield l.json()})}},$=H;O=new WeakSet,fe=function(e){return R({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,navigation_profile:e.navigation_profile,eta_type:e.eta_type},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.origin&&{origin:typeof e.origin=="string"?e.origin:c.convert(e.origin).toArray().join(",")},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:c.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},j=new WeakSet,Ae=function(e){if(!this.canRetrieve(e)&&!this.canSuggest(e))throw new Error("Suggestion cannot be retrieved or suggested");let t=e.action,o=JSON.stringify(t.body);return{method:t.method,body:o,headers:{"Content-Type":"application/json","Content-Length":o.length.toString()}}},$.defaults={language:"en"};var pe="https://api.mapbox.com/autofill/v1",Oe="suggest",Pe="retrieve",he=`${pe}/${Oe}`,Le=`${pe}/${Pe}`;var V,_e,Q=class{constructor(e={}){h(this,V);let s=e,{accessToken:t}=s,o=T(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Q.defaults),o)}suggest(e,t){return f(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:o,signal:s}=t,r=b(g(g({},this.defaults),t),{sessionToken:o}),u=new URL(`${he}/${encodeURIComponent(e)}`);u.search=y(this,V,_e).call(this,r);let{fetch:i}=d(),a=yield i(u.toString(),{signal:s});yield S(a);let l=yield a.json();return b(g({},l),{suggestions:l.suggestions.map(Z=>b(g({},Z),{original_search_text:e}))})})}retrieve(e,t){return f(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:o,signal:s}=t,r=m.convert(o),u=new URL(`${Le}/${e.action.id}`);u.search=R({access_token:this.accessToken,session_token:r.id});let{fetch:i}=d(),a=yield i(u.toString(),{signal:s});return yield S(a),yield a.json()})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},I=Q;V=new WeakSet,_e=function(e){return R({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:c.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")})},I.defaults={language:"en",proximity:"ip"};var J=(s=>(s.exact="exact",s.high="high",s.medium="medium",s.low="low",s))(J||{});var w,P=class{constructor(){h(this,w,{})}addEventListener(e,t){let o=L(this,w);o[e]||(o[e]=[]),o[e].push(t)}removeEventListener(e,t){let o=L(this,w);if(!o[e])return;let s=o[e],r=s.indexOf(t);r!==-1&&s.splice(r,1)}fire(e,t){let o=L(this,w);if(!o[e])return;let s=o[e];for(let r of s)r(t)}};w=new WeakMap;function C(n,e,t){let o=null;return(...s)=>{o!==null&&clearTimeout(o);let r=t&&t();o=setTimeout(()=>{o=null,!(r==null?void 0:r.aborted)&&n(...s)},e)}}function z(){let{AbortController:n}=d();return new n}var v,k,_,X=class extends P{constructor(e,t=0){super();this.sessionToken=new m;h(this,v,void 0);h(this,k,z());h(this,_,void 0);E(this,_,C((r,...u)=>f(this,[r,...u],function*(o,s={}){if(L(this,k).abort(),E(this,k,z()),!o){E(this,v,null),this.fire("suggest",L(this,v));return}try{let i=yield this.search.suggest(o,b(g({sessionToken:this.sessionToken},s),{signal:L(this,k).signal}));E(this,v,i),this.fire("suggest",i)}catch(i){if(i.name==="AbortError")return;this.fire("suggesterror",i)}}),t,()=>L(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return L(this,v)}suggest(e,t){return L(this,_).call(this,e,t),new Promise((o,s)=>{let r,u;r=i=>{this.removeEventListener("suggest",r),this.removeEventListener("suggesterror",u),o(i)},u=i=>{this.removeEventListener("suggest",r),this.removeEventListener("suggesterror",u),s(i)},this.addEventListener("suggest",r),this.addEventListener("suggesterror",u)})}clear(){this.suggest("")}retrieve(e,t){return f(this,null,function*(){let o=yield this.search.retrieve(e,g({sessionToken:this.sessionToken},t));return this.fire("retrieve",o),o})}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(),E(this,k,z())}};v=new WeakMap,k=new WeakMap,_=new WeakMap;function de(n){let{properties:e}=n;return g({},e)}var Fe="https://api.mapbox.com/autofill/v1",Ue="retrieve",be=`${Fe}/${Ue}`;var q,Ne,Y=class{constructor(e={}){h(this,q);let s=e,{accessToken:t}=s,o=T(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Y.defaults),o)}validate(e,t){return f(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:o,signal:s}=t,r=b(g(g({},this.defaults),t),{sessionToken:o}),u=new URL(`${be}/${encodeURIComponent(e)}`);u.search=y(this,q,Ne).call(this,r);let{fetch:i}=d(),a=yield i(u.toString(),{signal:s});yield S(a);let l=yield a.json();return l.features.length>0&&(l.features=[l.features[0]]),l})}},D=Y;q=new WeakSet,Ne=function(e){return R({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:c.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")})},D.defaults={language:"en",proximity:"ip"};module.exports=xe($e);
//# sourceMappingURL=index.js.map

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

var mapboxsearchcore=(()=>{var Ue=Object.create;var N=Object.defineProperty,Fe=Object.defineProperties,Ie=Object.getOwnPropertyDescriptor,$e=Object.getOwnPropertyDescriptors,je=Object.getOwnPropertyNames,M=Object.getOwnPropertySymbols,Me=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var re=(n,e,t)=>e in n?N(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,a=(n,e)=>{for(var t in e||(e={}))X.call(e,t)&&re(n,t,e[t]);if(M)for(var t of M(e))ie.call(e,t)&&re(n,t,e[t]);return n},R=(n,e)=>Fe(n,$e(e)),oe=n=>N(n,"__esModule",{value:!0});var J=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+n+'" is not supported')});var q=(n,e)=>{var t={};for(var s in n)X.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&M)for(var s of M(n))e.indexOf(s)<0&&ie.call(n,s)&&(t[s]=n[s]);return t};var ae=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),qe=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})},ge=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of je(e))!X.call(n,r)&&(t||r!=="default")&&N(n,r,{get:()=>e[r],enumerable:!(s=Ie(e,r))||s.enumerable});return n},Ce=(n,e)=>ge(oe(N(n!=null?Ue(Me(n)):{},"default",!e&&n&&n.__esModule?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n),De=(n=>(e,t)=>n&&n.get(e)||(t=ge(oe({}),e,1),n&&n.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var H=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var l=(n,e,t)=>(H(n,e,"read from private field"),t?t.call(n):e.get(n)),h=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},p=(n,e,t,s)=>(H(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t),ue=(n,e,t,s)=>({set _(r){p(n,e,r,t)},get _(){return l(n,e,s)}}),T=(n,e,t)=>(H(n,e,"access private method"),t);var d=(n,e,t)=>new Promise((s,r)=>{var i=o=>{try{c(t.next(o))}catch(m){r(m)}},g=o=>{try{c(t.throw(o))}catch(m){r(m)}},c=o=>o.done?s(o.value):Promise.resolve(o.value).then(i,g);c((t=t.apply(n,e)).next())});var be=ae((gt,Re)=>{var y=function(n){n==null&&(n=new Date().getTime()),this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,n.constructor==Array?this.init_by_array(n,n.length):this.init_seed(n)};y.prototype.init_seed=function(n){for(this.mt[0]=n>>>0,this.mti=1;this.mti<this.N;this.mti++){var n=this.mt[this.mti-1]^this.mt[this.mti-1]>>>30;this.mt[this.mti]=(((n&4294901760)>>>16)*1812433253<<16)+(n&65535)*1812433253+this.mti,this.mt[this.mti]>>>=0}};y.prototype.init_by_array=function(n,e){var t,s,r;for(this.init_seed(19650218),t=1,s=0,r=this.N>e?this.N:e;r;r--){var i=this.mt[t-1]^this.mt[t-1]>>>30;this.mt[t]=(this.mt[t]^(((i&4294901760)>>>16)*1664525<<16)+(i&65535)*1664525)+n[s]+s,this.mt[t]>>>=0,t++,s++,t>=this.N&&(this.mt[0]=this.mt[this.N-1],t=1),s>=e&&(s=0)}for(r=this.N-1;r;r--){var i=this.mt[t-1]^this.mt[t-1]>>>30;this.mt[t]=(this.mt[t]^(((i&4294901760)>>>16)*1566083941<<16)+(i&65535)*1566083941)-t,this.mt[t]>>>=0,t++,t>=this.N&&(this.mt[0]=this.mt[this.N-1],t=1)}this.mt[0]=2147483648};y.prototype.random_int=function(){var n,e=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var t;for(this.mti==this.N+1&&this.init_seed(5489),t=0;t<this.N-this.M;t++)n=this.mt[t]&this.UPPER_MASK|this.mt[t+1]&this.LOWER_MASK,this.mt[t]=this.mt[t+this.M]^n>>>1^e[n&1];for(;t<this.N-1;t++)n=this.mt[t]&this.UPPER_MASK|this.mt[t+1]&this.LOWER_MASK,this.mt[t]=this.mt[t+(this.M-this.N)]^n>>>1^e[n&1];n=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^n>>>1^e[n&1],this.mti=0}return n=this.mt[this.mti++],n^=n>>>11,n^=n<<7&2636928640,n^=n<<15&4022730752,n^=n>>>18,n>>>0};y.prototype.random_int31=function(){return this.random_int()>>>1};y.prototype.random_incl=function(){return this.random_int()*(1/4294967295)};y.prototype.random=function(){return this.random_int()*(1/4294967296)};y.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)};y.prototype.random_long=function(){var n=this.random_int()>>>5,e=this.random_int()>>>6;return(n*67108864+e)*(1/9007199254740992)};Re.exports=y});var Te=ae((ut,Le)=>{var Ke=be(),Ve=new Ke(Math.random()*Number.MAX_SAFE_INTEGER);Le.exports=Ge;function Ge(n){for(var e=n.length;e--;)n[e]=Math.floor(We()*256);return n}function We(){return Ve.random()}});var tt={};qe(tt,{AutofillMatchCodeConfidence:()=>te,Evented:()=>$,LngLat:()=>u,LngLatBounds:()=>S,MapboxAutofill:()=>V,MapboxError:()=>C,MapboxSearch:()=>D,SearchSession:()=>se,SessionToken:()=>f,debounce:()=>G,featureToSuggestion:()=>Pe,polyfillFetch:()=>z});var k="https://api.mapbox.com/search/v1",Q="suggest",Y="retrieve",ce="forward",le="reverse",fe=`${k}/${Q}`,he=`${k}/${Y}`,me=`${k}/${ce}`,pe=`${k}/permanent/${ce}`,de=`${k}/${le}`,Se=`${k}/permanent/${le}`;var u=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 u)return new u(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new u(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 u(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 S=class{constructor(e,t){this._sw=u.convert(e),this._ne=u.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new u(this.getWest(),this.getNorth())}getSouthEast(){return new u(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 S)return new S(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new S(u.convert(e[0]),u.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new S(u.convert([e[0],e[1]]),u.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>]")}};var ye=Ce(Te());function Be(n){return typeof globalThis.crypto=="undefined"||typeof globalThis.crypto.getRandomValues!="function"?(0,ye.default)(n):globalThis.crypto.getRandomValues(n)}function Xe(n){let e=[...n].map(t=>{let s=t.toString(16);return t<16?"0"+s:s});return[...e.slice(0,4),"-",...e.slice(4,6),"-",...e.slice(6,8),"-",...e.slice(8,10),"-",...e.slice(10,16)].join("")}function ve(){let n=Be(new Uint8Array(16));return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Xe(n)}var Je=60*60*1e3,f=class{constructor(e,t=Date.now()){this.id=e!=null?e:ve(),this.ts=t}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString(),e instanceof f?e.ts:Date.now())}isExpired(){return Date.now()-this.ts>Je}};var He="Unknown error",C=class extends Error{constructor(e,t){super(String(e.message||e.error||He));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function w(n){return d(this,null,function*(){if(!n.ok){let e=yield n.json();throw new C(e,n.status)}})}var U=globalThis.fetch,Ee=globalThis.AbortController;function z({fetch:n,AbortController:e},t=!1){if(!n)throw new Error("Fetch implementation must include implementations of `fetch`.");U&&!t||(U=n,Ee=e)}function b(){if(!U)throw new Error("Fetch implementation not found. Please use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:U,AbortController:Ee}}function we(n,e){return n(e)}if(!U&&!0&&process.versions.node){let{default:n}=we(J,"node-fetch"),e=we(J,"abort-controller");z({fetch:n,AbortController:e})}function _(...n){let e=[];for(let t of n){if(!t)continue;let s=Object.entries(t);for(let[r,i]of s)i!=null&&e.push(`${r}=${encodeURIComponent(String(i))}`)}return e.join("&")}var F,xe,K,Qe,Z=class{constructor(e={}){h(this,F);h(this,K);let r=e,{accessToken:t}=r,s=q(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},Z.defaults),s)}suggest(e,t){return d(this,null,function*(){if(!e)throw new Error("searchText is required");if(!this.accessToken)throw new Error("accessToken is required");if(!t||!t.sessionToken)throw new Error("sessionToken is required");let{sessionToken:s,signal:r}=t,i=R(a(a({},this.defaults),t),{sessionToken:s});if(i.eta_type&&(!i.origin||!i.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(i.origin&&!i.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let g=new URL(`${fe}/${encodeURIComponent(e)}`);g.search=T(this,F,xe).call(this,i);let{fetch:c}=b(),o=yield c(g.toString(),{signal:r});return yield w(o),yield o.json()})}retrieve(e,t){return d(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.accessToken)throw new Error("accessToken is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");if(!t||!t.sessionToken)throw new Error("sessionToken is required");let{sessionToken:s,signal:r}=t,i=f.convert(s),g=new URL(he);g.search=_({access_token:this.accessToken,session_token:i.id});let{fetch:c}=b(),o=yield c(g.toString(),R(a({},T(this,K,Qe).call(this,e)),{signal:r}));return yield w(o),yield o.json()})}canRetrieve(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===Y:!1}canSuggest(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===Q:!1}forward(s){return d(this,arguments,function*(e,t={}){if(!e)throw new Error("searchText is required");if(!this.accessToken)throw new Error("accessToken is required");let r=a(a({},this.defaults),t),i=r.permanent?pe:me,g=new URL(`${i}/${encodeURIComponent(e)}`);g.search=T(this,F,xe).call(this,r);let{fetch:c}=b(),o=yield c(g.toString(),{signal:r.signal});return yield w(o),yield o.json()})}reverse(s){return d(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");if(!this.accessToken)throw new Error("accessToken is required");let r=a(a({},this.defaults),t),i=typeof e=="string"?e:u.convert(e).toArray().join(","),g=r.permanent?Se:de,c=new URL(`${g}/${encodeURIComponent(i)}`);c.search=_({access_token:this.accessToken,language:r.language,limit:r.limit},r.types&&{types:typeof r.types=="string"?r.types:[...r.types].join(",")});let{fetch:o}=b(),m=yield o(c.toString(),{signal:r.signal});return yield w(m),yield m.json()})}},D=Z;F=new WeakSet,xe=function(e){return _({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,navigation_profile:e.navigation_profile,eta_type:e.eta_type},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.origin&&{origin:typeof e.origin=="string"?e.origin:u.convert(e.origin).toArray().join(",")},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:S.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},K=new WeakSet,Qe=function(e){if(!this.canRetrieve(e)&&!this.canSuggest(e))throw new Error("Suggestion cannot be retrieved or suggested");let t=e.action,s=JSON.stringify(t.body);return{method:t.method,body:s,headers:{"Content-Type":"application/json","Content-Length":s.length.toString()}}},D.defaults={language:"en"};var ke="https://api.mapbox.com/autofill/v1",Ye="suggest",ze="retrieve",_e=`${ke}/${Ye}`,Ae=`${ke}/${ze}`;var I,Oe,ee=class{constructor(e={}){h(this,I);let r=e,{accessToken:t}=r,s=q(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},ee.defaults),s)}suggest(e,t){return d(this,null,function*(){if(!e)throw new Error("searchText is required");if(!this.accessToken)throw new Error("accessToken is required");if(!t||!t.sessionToken)throw new Error("sessionToken is required");let{sessionToken:s,signal:r}=t,i=R(a(a({},this.defaults),t),{sessionToken:s}),g=new URL(`${_e}/${encodeURIComponent(e)}`);g.search=T(this,I,Oe).call(this,i);let{fetch:c}=b(),o=yield c(g.toString(),{signal:r});yield w(o);let m=yield o.json();return R(a({},m),{suggestions:m.suggestions.map(P=>R(a({},P),{original_search_text:e}))})})}retrieve(e,t){return d(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.accessToken)throw new Error("accessToken is required");if(!t||!t.sessionToken)throw new Error("sessionToken is required");let{sessionToken:s,signal:r}=t,i=R(a(a({},this.defaults),t),{sessionToken:s}),g=typeof e!="string",c=g?e.original_search_text:e,o=new URL(`${Ae}/${encodeURIComponent(c)}`);o.search=T(this,I,Oe).call(this,i);let{fetch:m}=b(),P=yield m(o.toString(),{signal:r});yield w(P);let B=yield P.json();return g?R(a({},B),{features:B.features.filter(Ne=>Ne.properties.full_address===e.full_address)}):B})}},V=ee;I=new WeakSet,Oe=function(e){return _({access_token:this.accessToken,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:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:S.convert(e.bbox).toFlatArray().join(",")})},V.defaults={language:"en",proximity:"ip"};var te=(r=>(r.exact="exact",r.high="high",r.medium="medium",r.low="low",r))(te||{});var A,$=class{constructor(){h(this,A,{})}addEventListener(e,t){let s=l(this,A);s[e]||(s[e]=[]),s[e].push(t)}removeEventListener(e,t){let s=l(this,A);if(!s[e])return;let r=s[e],i=r.indexOf(t);i!==-1&&r.splice(i,1)}fire(e,t){let s=l(this,A);if(!s[e])return;let r=s[e];for(let i of r)i(t)}};A=new WeakMap;function G(n,e,t){let s=null;return(...r)=>{s!==null&&clearTimeout(s);let i=t&&t();s=setTimeout(()=>{s=null,!(i==null?void 0:i.aborted)&&n(...r)},e)}}var Ze=50;function ne(){let{AbortController:n}=b();return new n}var O,L,E,W,et,x,v,j,se=class extends ${constructor(e,t=0){super();h(this,W);h(this,O,!1);h(this,L,new f);h(this,E,0);h(this,x,void 0);h(this,v,ne());h(this,j,void 0);p(this,j,G((i,...g)=>d(this,[i,...g],function*(s,r={}){if(l(this,v).abort(),p(this,v,ne()),!s){p(this,x,null),this.fire("suggest",l(this,x));return}let c=T(this,W,et).call(this);try{let o=yield this.search.suggest(s,R(a({sessionToken:c},r),{signal:l(this,v).signal}));p(this,x,o),this.fire("suggest",o)}catch(o){if(o.name==="AbortError")return;this.fire("suggesterror",o)}}),t,()=>l(this,v).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get sessionToken(){return l(this,L)}set sessionToken(e){p(this,L,e),p(this,O,!0)}get suggestions(){return l(this,x)}suggest(e,t){return l(this,j).call(this,e,t),new Promise((s,r)=>{let i,g;i=c=>{this.removeEventListener("suggest",i),this.removeEventListener("suggesterror",g),s(c)},g=c=>{this.removeEventListener("suggest",i),this.removeEventListener("suggesterror",g),r(c)},this.addEventListener("suggest",i),this.addEventListener("suggesterror",g)})}clear(){this.suggest("")}retrieve(e,t){return d(this,null,function*(){let s=yield this.search.retrieve(e,a({sessionToken:l(this,L)},t));return l(this,O)||(p(this,L,new f),p(this,E,0)),this.fire("retrieve",s),s})}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,v).abort(),p(this,v,ne())}};O=new WeakMap,L=new WeakMap,E=new WeakMap,W=new WeakSet,et=function(){return l(this,O)||(l(this,L).isExpired()||l(this,E)>=Ze)&&(p(this,L,new f),p(this,E,0)),ue(this,E)._++,l(this,L)},x=new WeakMap,v=new WeakMap,j=new WeakMap;function Pe(n){let{properties:e}=n;return a({},e)}return De(tt);})();
var mapboxsearchcore=(()=>{var U=Object.defineProperty,Re=Object.defineProperties,ke=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertyNames,F=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var te=(n,e,t)=>e in n?U(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e)=>{for(var t in e||(e={}))B.call(e,t)&&te(n,t,e[t]);if(F)for(var t of F(e))ne.call(e,t)&&te(n,t,e[t]);return n},b=(n,e)=>Re(n,ye(e)),Te=n=>U(n,"__esModule",{value:!0});var G=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+n+'" is not supported')});var T=(n,e)=>{var t={};for(var o in n)B.call(n,o)&&e.indexOf(o)<0&&(t[o]=n[o]);if(n!=null&&F)for(var o of F(n))e.indexOf(o)<0&&ne.call(n,o)&&(t[o]=n[o]);return t};var Ee=(n,e)=>{for(var t in e)U(n,t,{get:e[t],enumerable:!0})},xe=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ve(e))!B.call(n,s)&&(t||s!=="default")&&U(n,s,{get:()=>e[s],enumerable:!(o=ke(e,s))||o.enumerable});return n};var we=(n=>(e,t)=>n&&n.get(e)||(t=xe(Te({}),e,1),n&&n.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var W=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var L=(n,e,t)=>(W(n,e,"read from private field"),t?t.call(n):e.get(n)),h=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},E=(n,e,t,o)=>(W(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);var y=(n,e,t)=>(W(n,e,"access private method"),t);var f=(n,e,t)=>new Promise((o,s)=>{var r=a=>{try{i(t.next(a))}catch(l){s(l)}},u=a=>{try{i(t.throw(a))}catch(l){s(l)}},i=a=>a.done?o(a.value):Promise.resolve(a.value).then(r,u);i((t=t.apply(n,e)).next())});var je={};Ee(je,{Evented:()=>P,LngLat:()=>c,LngLatBounds:()=>p,MapboxAutofill:()=>I,MapboxError:()=>N,MapboxSearch:()=>$,MapboxValidate:()=>D,MatchCodeConfidence:()=>z,SearchSession:()=>Y,SessionToken:()=>m,debounce:()=>C,featureToSuggestion:()=>be,polyfillFetch:()=>H});var x="https://api.mapbox.com/search/v1",K="suggest",M="retrieve",oe="forward",se="reverse",re=`${x}/${K}`,ie=`${x}/${M}`,ae=`${x}/${oe}`,ge=`${x}/permanent/${oe}`,ue=`${x}/${se}`,ce=`${x}/permanent/${se}`;var c=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 c)return new c(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new c(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 c(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 p=class{constructor(e,t){this._sw=c.convert(e),this._ne=c.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new c(this.getWest(),this.getNorth())}getSouthEast(){return new c(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 p)return new p(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new p(c.convert(e[0]),c.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new p(c.convert([e[0],e[1]]),c.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 le(){let e=(Date.now().toString(16)+Math.random().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 m=class{constructor(e){this.id=e!=null?e:le()}toString(){return this.id}static convert(e){return new m(e instanceof m?e.id:e.toString())}};var Ae="Unknown error",N=class extends Error{constructor(e,t){super(String(e.message||e.error||Ae));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function S(n){return f(this,null,function*(){if(!n.ok){let e=yield n.json();throw new N(e,n.status)}})}var A=globalThis.fetch,fe=globalThis.AbortController;function H({fetch:n,AbortController:e},t=!1){if(!n)throw new Error("Fetch implementation must include implementations of `fetch`.");A&&!t||(A=n,fe=e)}function d(){if(!A)throw new Error("Fetch implementation not found. Please use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:A,AbortController:fe}}function me(n,e){return n(e)}if(!A&&!0&&process.versions.node){let{default:n}=me(G,"node-fetch"),e=me(G,"abort-controller");H({fetch:n,AbortController:e})}function R(...n){let e=[];for(let t of n){if(!t)continue;let o=Object.entries(t);for(let[s,r]of o)r!=null&&e.push(`${s}=${encodeURIComponent(String(r))}`)}return e.join("&")}var O,pe,j,Oe,Q=class{constructor(e={}){h(this,O);h(this,j);let s=e,{accessToken:t}=s,o=T(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Q.defaults),o)}suggest(e,t){return f(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:o,signal:s}=t,r=b(g(g({},this.defaults),t),{sessionToken:o});if(r.eta_type&&(!r.origin||!r.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(r.origin&&!r.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let u=new URL(`${re}/${encodeURIComponent(e)}`);u.search=y(this,O,pe).call(this,r);let{fetch:i}=d(),a=yield i(u.toString(),{signal:s});return yield S(a),yield a.json()})}retrieve(e,t){return f(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:o,signal:s}=t,r=m.convert(o),u=new URL(ie);u.search=R({access_token:this.accessToken,session_token:r.id});let{fetch:i}=d(),a=yield i(u.toString(),b(g({},y(this,j,Oe).call(this,e)),{signal:s}));return yield S(a),yield a.json()})}canRetrieve(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===M:!1}canSuggest(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===K:!1}forward(o){return f(this,arguments,function*(e,t={}){if(!e)throw new Error("searchText is required");let s=g(g({},this.defaults),t),r=s.permanent?ge:ae,u=new URL(`${r}/${encodeURIComponent(e)}`);u.search=y(this,O,pe).call(this,s);let{fetch:i}=d(),a=yield i(u.toString(),{signal:s.signal});return yield S(a),yield a.json()})}reverse(o){return f(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let s=g(g({},this.defaults),t),r=typeof e=="string"?e:c.convert(e).toArray().join(","),u=s.permanent?ce:ue,i=new URL(`${u}/${encodeURIComponent(r)}`);i.search=R({access_token:this.accessToken,language:s.language,limit:s.limit},s.types&&{types:typeof s.types=="string"?s.types:[...s.types].join(",")});let{fetch:a}=d(),l=yield a(i.toString(),{signal:s.signal});return yield S(l),yield l.json()})}},$=Q;O=new WeakSet,pe=function(e){return R({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,navigation_profile:e.navigation_profile,eta_type:e.eta_type},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.origin&&{origin:typeof e.origin=="string"?e.origin:c.convert(e.origin).toArray().join(",")},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:c.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},j=new WeakSet,Oe=function(e){if(!this.canRetrieve(e)&&!this.canSuggest(e))throw new Error("Suggestion cannot be retrieved or suggested");let t=e.action,o=JSON.stringify(t.body);return{method:t.method,body:o,headers:{"Content-Type":"application/json","Content-Length":o.length.toString()}}},$.defaults={language:"en"};var he="https://api.mapbox.com/autofill/v1",Pe="suggest",_e="retrieve",Le=`${he}/${Pe}`,de=`${he}/${_e}`;var V,Fe,J=class{constructor(e={}){h(this,V);let s=e,{accessToken:t}=s,o=T(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},J.defaults),o)}suggest(e,t){return f(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:o,signal:s}=t,r=b(g(g({},this.defaults),t),{sessionToken:o}),u=new URL(`${Le}/${encodeURIComponent(e)}`);u.search=y(this,V,Fe).call(this,r);let{fetch:i}=d(),a=yield i(u.toString(),{signal:s});yield S(a);let l=yield a.json();return b(g({},l),{suggestions:l.suggestions.map(ee=>b(g({},ee),{original_search_text:e}))})})}retrieve(e,t){return f(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:o,signal:s}=t,r=m.convert(o),u=new URL(`${de}/${e.action.id}`);u.search=R({access_token:this.accessToken,session_token:r.id});let{fetch:i}=d(),a=yield i(u.toString(),{signal:s});return yield S(a),yield a.json()})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},I=J;V=new WeakSet,Fe=function(e){return R({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:c.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")})},I.defaults={language:"en",proximity:"ip"};var z=(s=>(s.exact="exact",s.high="high",s.medium="medium",s.low="low",s))(z||{});var w,P=class{constructor(){h(this,w,{})}addEventListener(e,t){let o=L(this,w);o[e]||(o[e]=[]),o[e].push(t)}removeEventListener(e,t){let o=L(this,w);if(!o[e])return;let s=o[e],r=s.indexOf(t);r!==-1&&s.splice(r,1)}fire(e,t){let o=L(this,w);if(!o[e])return;let s=o[e];for(let r of s)r(t)}};w=new WeakMap;function C(n,e,t){let o=null;return(...s)=>{o!==null&&clearTimeout(o);let r=t&&t();o=setTimeout(()=>{o=null,!(r==null?void 0:r.aborted)&&n(...s)},e)}}function X(){let{AbortController:n}=d();return new n}var v,k,_,Y=class extends P{constructor(e,t=0){super();this.sessionToken=new m;h(this,v,void 0);h(this,k,X());h(this,_,void 0);E(this,_,C((r,...u)=>f(this,[r,...u],function*(o,s={}){if(L(this,k).abort(),E(this,k,X()),!o){E(this,v,null),this.fire("suggest",L(this,v));return}try{let i=yield this.search.suggest(o,b(g({sessionToken:this.sessionToken},s),{signal:L(this,k).signal}));E(this,v,i),this.fire("suggest",i)}catch(i){if(i.name==="AbortError")return;this.fire("suggesterror",i)}}),t,()=>L(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return L(this,v)}suggest(e,t){return L(this,_).call(this,e,t),new Promise((o,s)=>{let r,u;r=i=>{this.removeEventListener("suggest",r),this.removeEventListener("suggesterror",u),o(i)},u=i=>{this.removeEventListener("suggest",r),this.removeEventListener("suggesterror",u),s(i)},this.addEventListener("suggest",r),this.addEventListener("suggesterror",u)})}clear(){this.suggest("")}retrieve(e,t){return f(this,null,function*(){let o=yield this.search.retrieve(e,g({sessionToken:this.sessionToken},t));return this.fire("retrieve",o),o})}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(),E(this,k,X())}};v=new WeakMap,k=new WeakMap,_=new WeakMap;function be(n){let{properties:e}=n;return g({},e)}var Ue="https://api.mapbox.com/autofill/v1",Ne="retrieve",Se=`${Ue}/${Ne}`;var q,$e,Z=class{constructor(e={}){h(this,q);let s=e,{accessToken:t}=s,o=T(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Z.defaults),o)}validate(e,t){return f(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:o,signal:s}=t,r=b(g(g({},this.defaults),t),{sessionToken:o}),u=new URL(`${Se}/${encodeURIComponent(e)}`);u.search=y(this,q,$e).call(this,r);let{fetch:i}=d(),a=yield i(u.toString(),{signal:s});yield S(a);let l=yield a.json();return l.features.length>0&&(l.features=[l.features[0]]),l})}},D=Z;q=new WeakSet,$e=function(e){return R({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:c.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")})},D.defaults={language:"en",proximity:"ip"};return we(je);})();
//# sourceMappingURL=mapboxsearchcore.js.map

@@ -103,14 +103,9 @@ import { SessionToken, SessionTokenLike } from './SessionToken';

/**
* The {@link SessionToken} used within the current session.
* The session token is an SKU (billing token) used to identify the current
* search session and provide analytics to the customer.
*
* By default, this value is managed internally and automatically regenerated
* according to its lifecycle criteria, i.e. time, number of calls to suggest,
* and a call to retrieve.
* As per {@link SessionToken}, this is a UUIDv4 value.
*
* This value should not be explicitly set except within the Autofill web
* component library, as doing so will persist the token for the duration
* of those component lifecycles.
*/
get sessionToken(): SessionToken;
set sessionToken(token: SessionToken);
sessionToken: SessionToken;
/**

@@ -117,0 +112,0 @@ * The suggestions from the last successful suggest call, if any.

@@ -27,8 +27,4 @@ /**

readonly id: string;
constructor(id?: string);
/**
* Returns the timestamp of when the session token was initialized.
*/
readonly ts: number;
constructor(id?: string, ts?: number);
/**
* Returns the session token in string format.

@@ -45,6 +41,2 @@ *

static convert(token: SessionToken | string): SessionToken;
/**
* Returns `true` if the session token has expired (expired after 60 minutes).
*/
isExpired(): boolean;
}

@@ -51,0 +43,0 @@ /**

/**
* Converts the byte array to a UUID string
* @param bytes - Used to convert Byte to Hex
*/
export declare function bytesToUuid(bytes: number[] | Uint8Array): string;
/**
* Validates the UUID v4.

@@ -11,3 +6,10 @@ * @param id - UUID value.

export declare function validateUUID(id: string): boolean;
/** Generates a RFC4122 v4 UUID (pseudo-randomly-based) */
/**
* Generates a RFC4122 v4 UUID (pseudo-randomly-based)
*
* IMPORTANT: THIS IS NOT CRYPTO-GRAPHICALLY SECURE!
*
* Since we're using this to generate a random UUID, essentially as an SKU,
* we don't need to worry about the randomness of the values as much.
*/
export declare function generateUUID(): string;
{
"name": "@mapbox/search-js-core",
"version": "1.0.0-beta.10",
"version": "1.0.0-beta.11",
"description": "Platform agnostic wrappers for the Search API and Geocoding API.",

@@ -39,4 +39,3 @@ "main": "dist/index.js",

"@types/geojson": "^7946.0.8",
"node-fetch": "2",
"polyfill-crypto.getrandomvalues": "^1.0.0"
"node-fetch": "2"
},

@@ -43,0 +42,0 @@ "size-limit": [

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