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.9 to 1.0.0-beta.10

1

dist/index-development.js

@@ -122,2 +122,3 @@ var __create = Object.create;

SessionToken: () => SessionToken,
debounce: () => debounce,
featureToSuggestion: () => featureToSuggestion,

@@ -124,0 +125,0 @@ polyfillFetch: () => polyfillFetch

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

SessionToken,
debounce,
featureToSuggestion,

@@ -813,0 +814,0 @@ polyfillFetch

3

dist/index.d.ts

@@ -13,2 +13,3 @@ import { Options, MapboxSearch, SuggestionResponse, RetrieveResponse } from './search/MapboxSearch';

import { Evented } from './utils/Evented';
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 };
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 };

@@ -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,W=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var te=(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={}))W.call(e,t)&&te(n,t,e[t]);if(j)for(var t of j(e))ne.call(e,t)&&te(n,t,e[t]);return n},b=(n,e)=>xe(n,Oe(e)),se=n=>P(n,"__esModule",{value:!0});var q=(n,e)=>{var t={};for(var s in n)W.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&&ne.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})},re=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ae(e))!W.call(n,r)&&(t||r!=="default")&&P(n,r,{get:()=>e[r],enumerable:!(s=_e(e,r))||s.enumerable});return n},Fe=(n,e)=>re(se(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=re(se({}),e,1),n&&n.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var M=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var l=(n,e,t)=>(M(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)=>(M(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t),oe=(n,e,t,s)=>({set _(r){p(n,e,r,t)},get _(){return l(n,e,s)}}),T=(n,e,t)=>(M(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:()=>ee,SessionToken:()=>f,featureToSuggestion:()=>ve,polyfillFetch:()=>Q});var E="https://api.mapbox.com/search/v1",J="suggest",H="retrieve",ie="forward",ae="reverse",ge=`${E}/${J}`,ue=`${E}/${H}`,ce=`${E}/${ie}`,le=`${E}/permanent/${ie}`,fe=`${E}/${ae}`,me=`${E}/permanent/${ae}`;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 he=Fe(require("polyfill-crypto.getrandomvalues"));function Ie(n){return typeof globalThis.crypto=="undefined"||typeof globalThis.crypto.getRandomValues!="function"?(0,he.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 pe(){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:pe(),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,Se=globalThis.AbortController;function Q({fetch:n,AbortController:e},t=!1){if(!n)throw new Error("Fetch implementation must include implementations of `fetch`.");U&&!t||(U=n,Se=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:Se}}function de(n,e){return n(e)}if(!U&&!0&&process.versions.node){let{default:n}=de(require,"node-fetch"),e=de(require,"abort-controller");Q({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,be,V,Ce,X=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({},X.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(`${ge}/${encodeURIComponent(e)}`);g.search=T(this,F,be).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(ue);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===H:!1}canSuggest(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===J:!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?le:ce,g=new URL(`${o}/${encodeURIComponent(e)}`);g.search=T(this,F,be).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?me:fe,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=X;F=new WeakSet,be=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 Re="https://api.mapbox.com/autofill/v1",De="suggest",Ve="retrieve",Le=`${Re}/${De}`,Te=`${Re}/${Ve}`;var N,ke,Y=class{constructor(e={}){m(this,N);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}),g=new URL(`${Le}/${encodeURIComponent(e)}`);g.search=T(this,N,ke).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(`${Te}/${encodeURIComponent(c)}`);i.search=T(this,N,ke).call(this,o);let{fetch:h}=R(),A=yield h(i.toString(),{signal:r});yield y(A);let K=yield A.json();return g?b(a({},K),{features:K.features.filter(we=>we.properties.full_address===e.full_address)}):K})}},G=Y;N=new WeakSet,ke=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 ye(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 Z(){let{AbortController:n}=R();return new n}var O,L,v,B,Be,w,k,$,ee=class extends I{constructor(e,t=0){super();m(this,B);m(this,O,!1);m(this,L,new f);m(this,v,0);m(this,w,void 0);m(this,k,Z());m(this,$,void 0);p(this,$,ye((o,...g)=>d(this,[o,...g],function*(s,r={}){if(l(this,k).abort(),p(this,k,Z()),!s){p(this,w,null),this.fire("suggest",l(this,w));return}let c=T(this,B,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,Z())}};O=new WeakMap,L=new WeakMap,v=new WeakMap,B=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)),oe(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 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);
//# 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,B=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var se=(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={}))B.call(e,t)&&se(n,t,e[t]);if(M)for(var t of M(e))re.call(e,t)&&se(n,t,e[t]);return n},R=(n,e)=>Fe(n,$e(e)),ie=n=>N(n,"__esModule",{value:!0});var X=(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)B.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&&re.call(n,s)&&(t[s]=n[s]);return t};var oe=(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})},ae=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of je(e))!B.call(n,r)&&(t||r!=="default")&&N(n,r,{get:()=>e[r],enumerable:!(s=Ie(e,r))||s.enumerable});return n},Ce=(n,e)=>ae(ie(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=ae(ie({}),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)),f=(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),ge=(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 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 Re=oe((gt,Se)=>{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)};Se.exports=y});var Le=oe((ut,be)=>{var Ke=Re(),Ve=new Ke(Math.random()*Number.MAX_SAFE_INTEGER);be.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:()=>ee,Evented:()=>$,LngLat:()=>u,LngLatBounds:()=>S,MapboxAutofill:()=>V,MapboxError:()=>C,MapboxSearch:()=>D,SearchSession:()=>ne,SessionToken:()=>h,featureToSuggestion:()=>Pe,polyfillFetch:()=>Y});var k="https://api.mapbox.com/search/v1",H="suggest",Q="retrieve",ue="forward",ce="reverse",le=`${k}/${H}`,he=`${k}/${Q}`,fe=`${k}/${ue}`,me=`${k}/permanent/${ue}`,pe=`${k}/${ce}`,de=`${k}/permanent/${ce}`;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 Te=Ce(Le());function Be(n){return typeof globalThis.crypto=="undefined"||typeof globalThis.crypto.getRandomValues!="function"?(0,Te.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 ye(){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,h=class{constructor(e,t=Date.now()){this.id=e!=null?e:ye(),this.ts=t}toString(){return this.id}static convert(e){return new h(e instanceof h?e.id:e.toString(),e instanceof h?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,we=globalThis.AbortController;function Y({fetch:n,AbortController:e},t=!1){if(!n)throw new Error("Fetch implementation must include implementations of `fetch`.");U&&!t||(U=n,we=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:we}}function ve(n,e){return n(e)}if(!U&&!0&&process.versions.node){let{default:n}=ve(X,"node-fetch"),e=ve(X,"abort-controller");Y({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,Ee,K,Qe,z=class{constructor(e={}){f(this,F);f(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(`${le}/${encodeURIComponent(e)}`);g.search=T(this,F,Ee).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=h.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===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),i=r.permanent?me:fe,g=new URL(`${i}/${encodeURIComponent(e)}`);g.search=T(this,F,Ee).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?de:pe,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,Ee=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:h.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 xe="https://api.mapbox.com/autofill/v1",Ye="suggest",ze="retrieve",ke=`${xe}/${Ye}`,_e=`${xe}/${ze}`;var I,Ae,Z=class{constructor(e={}){f(this,I);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}),g=new URL(`${ke}/${encodeURIComponent(e)}`);g.search=T(this,I,Ae).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(`${_e}/${encodeURIComponent(c)}`);o.search=T(this,I,Ae).call(this,i);let{fetch:m}=b(),P=yield m(o.toString(),{signal:r});yield w(P);let W=yield P.json();return g?R(a({},W),{features:W.features.filter(Ne=>Ne.properties.full_address===e.full_address)}):W})}},V=Z;I=new WeakSet,Ae=function(e){return _({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:h.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 ee=(r=>(r.exact="exact",r.high="high",r.medium="medium",r.low="low",r))(ee||{});var A,$=class{constructor(){f(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 Oe(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 te(){let{AbortController:n}=b();return new n}var O,L,E,G,et,x,v,j,ne=class extends ${constructor(e,t=0){super();f(this,G);f(this,O,!1);f(this,L,new h);f(this,E,0);f(this,x,void 0);f(this,v,te());f(this,j,void 0);p(this,j,Oe((i,...g)=>d(this,[i,...g],function*(s,r={}){if(l(this,v).abort(),p(this,v,te()),!s){p(this,x,null),this.fire("suggest",l(this,x));return}let c=T(this,G,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 h),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,te())}};O=new WeakMap,L=new WeakMap,E=new WeakMap,G=new WeakSet,et=function(){return l(this,O)||(l(this,L).isExpired()||l(this,E)>=Ze)&&(p(this,L,new h),p(this,E,0)),ge(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 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);})();
//# sourceMappingURL=mapboxsearchcore.js.map
{
"name": "@mapbox/search-js-core",
"version": "1.0.0-beta.9",
"version": "1.0.0-beta.10",
"description": "Platform agnostic wrappers for the Search API and Geocoding API.",

@@ -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

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