places-autocomplete-js 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -91,6 +91,7 @@ var e = {
|
|
|
91
91
|
sublocality_level_5: "Neighborhood",
|
|
92
92
|
default: "Default"
|
|
93
93
|
}, t = {
|
|
94
|
+
Distance: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-route-icon lucide-route\"><circle cx=\"6\" cy=\"19\" r=\"3\"/><path d=\"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15\"/><circle cx=\"18\" cy=\"5\" r=\"3\"/></svg>",
|
|
94
95
|
Automotive: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2\"/><circle cx=\"7\" cy=\"17\" r=\"2\"/><path d=\"M9 17h6\"/><circle cx=\"17\" cy=\"17\" r=\"2\"/></svg>",
|
|
95
96
|
Transport: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z\"/></svg>",
|
|
96
97
|
"Food and Drink": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2\"/><path d=\"M7 2v20\"/><path d=\"M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7\"/></svg>",
|
|
@@ -246,8 +247,7 @@ var e = {
|
|
|
246
247
|
};
|
|
247
248
|
}
|
|
248
249
|
_formatDistance(e, t) {
|
|
249
|
-
if (!this.#i.distance) return null;
|
|
250
|
-
if (typeof e != "number") return "Origin required for distance";
|
|
250
|
+
if (!this.#i.distance || typeof e != "number") return null;
|
|
251
251
|
let n, r;
|
|
252
252
|
return t === "km" ? (n = (e / 1e3).toFixed(2), r = "km") : (n = (e / 1609.34).toFixed(2), r = "miles"), n = n.replace(/\.00$/, ""), `${n} ${r}`;
|
|
253
253
|
}
|
|
@@ -368,9 +368,11 @@ var e = {
|
|
|
368
368
|
let n = this._createDivElement(this.#i.classes.li_div_two_p_place_type_item), i = this._createPElement(this.#i.classes.li_div_two_p_place_type_icon), o = this._createPElement(this.#i.classes.li_div_two_p_place_type_label), s = r.placePrediction.types.find((t) => typeof t == "string" && t in e);
|
|
369
369
|
o.textContent = s ? e[s] : "Default", i.innerHTML = t[o.textContent] || t.Default, n.appendChild(i), n.appendChild(o), a.appendChild(n);
|
|
370
370
|
}
|
|
371
|
-
if (this.#i.distance
|
|
372
|
-
let e = this._createDivElement(this.#i.classes.li_div_two_p_place_type_item),
|
|
373
|
-
|
|
371
|
+
if (this.#i.distance) {
|
|
372
|
+
let e = this._createDivElement(this.#i.classes.li_div_two_p_place_type_item), n = this._createPElement(this.#i.classes.li_div_two_p_place_type_icon);
|
|
373
|
+
n.innerHTML = t.Distance;
|
|
374
|
+
let r = this._createPElement(this.#i.classes.li_div_two_p);
|
|
375
|
+
r.textContent = i ?? "-", e.appendChild(n), e.appendChild(r), a.appendChild(e);
|
|
374
376
|
}
|
|
375
377
|
a.hasChildNodes() && n.appendChild(a);
|
|
376
378
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"places-autocomplete.js","names":["#containerId","#pacEl","#googleMapsApiKey","#googleMapsApiVersion","#options","#defaultOptions","#defaultClasses","#onDataCallback","#onErrorCallback","#request","#defaultRequestParams","#debouncedMakeAcRequest","#inputElement","#cache","#ul","#ariaStatus","#fetchFields","#defaultFetchFields","#container","#kbdEscape","#kbdUp","#kbdDown","#allSuggestions","#currentSuggestion"],"sources":["../constants.js","../PlacesAutocomplete.js"],"sourcesContent":["export const ITINERARY_CATEGORIES = {\n // --- TRANSPORT & AUTO ---\n car_rental: \"Automotive\",\n car_dealer: \"Automotive\",\n gas_station: \"Automotive\",\n electric_vehicle_charging_station: \"Automotive\",\n parking: \"Automotive\",\n airport: \"Airport\",\n bus_station: \"Transport\",\n train_station: \"Train Station\",\n subway_station: \"Subway Station\",\n taxi_stand: \"Transport\",\n ferry_terminal: \"Transport\",\n\n // --- DINING & NIGHTLIFE ---\n restaurant: \"Food and Drink\",\n cafe: \"Food and Drink\",\n coffee_shop: \"Food and Drink\",\n bar: \"Food and Drink\",\n pub: \"Food and Drink\",\n night_club: \"Food and Drink\",\n bakery: \"Food and Drink\",\n fast_food_restaurant: \"Food and Drink\",\n ice_cream_shop: \"Food and Drink\",\n pizza_restaurant: \"Food and Drink\",\n steak_house: \"Food and Drink\",\n sushi_restaurant: \"Food and Drink\",\n\n // --- LODGING ---\n hotel: \"Lodging\",\n hostel: \"Lodging\",\n motel: \"Lodging\",\n resort_hotel: \"Lodging\",\n bed_and_breakfast: \"Lodging\",\n campground: \"Lodging\",\n rv_park: \"Lodging\",\n lodging: \"Lodging\",\n cottage: \"Lodging\",\n inn: \"Lodging\",\n guest_house: \"Lodging\",\n\n // --- SIGHTSEEING & CULTURE ---\n tourist_attraction: \"Sightseeing\",\n museum: \"Sightseeing\",\n art_gallery: \"Sightseeing\",\n cultural_landmark: \"Sightseeing\",\n historical_landmark: \"Sightseeing\",\n monument: \"Sightseeing\",\n performing_arts_theater: \"Sightseeing\",\n aquarium: \"Sightseeing\",\n zoo: \"Sightseeing\",\n visitor_center: \"Sightseeing\",\n town_square: \"Sightseeing\",\n landmark: \"Sightseeing\",\n place_of_worship: \"Sightseeing\",\n\n // --- RECREATION & PARKS ---\n park: \"Recreation\",\n national_park: \"Recreation\",\n state_park: \"Recreation\",\n beach: \"Recreation\",\n hiking_area: \"Recreation\",\n amusement_park: \"Recreation\",\n water_park: \"Recreation\",\n botanical_garden: \"Recreation\",\n golf_course: \"Recreation\",\n gym: \"Recreation\",\n natural_feature: \"Recreation\",\n\n // --- SHOPPING ---\n shopping_mall: \"Shopping\",\n supermarket: \"Shopping\",\n grocery_store: \"Shopping\",\n clothing_store: \"Shopping\",\n electronics_store: \"Shopping\",\n souvenir_shop: \"Shopping\",\n gift_shop: \"Shopping\",\n duty_free_store: \"Shopping\",\n\n // --- ESSENTIAL SERVICES ---\n hospital: \"Health\",\n pharmacy: \"Health\",\n atm: \"Finance\",\n bank: \"Finance\",\n post_office: \"Services\",\n police: \"Services\",\n\n // --- GEOGRAPHICAL ---\n neighborhood: \"Geographical\",\n sublocality: \"Geographical\",\n\n // --- NAVIGATION ---\n route: \"Navigation\",\n street_address: \"Navigation\",\n intersection: \"Navigation\",\n\n // -- CITY --\n locality: \"City\",\n administrative_area_level_4: \"City\",\n country: \"Country\",\n administrative_area_level_1: \"City\",\n administrative_area_level_2: \"City\",\n administrative_area_level_3: \"City\",\n administrative_area_level_5: \"City\",\n sublocality_level_1: \"Neighborhood\",\n sublocality_level_2: \"Neighborhood\",\n sublocality_level_3: \"Neighborhood\",\n sublocality_level_4: \"Neighborhood\",\n sublocality_level_5: \"Neighborhood\",\n\n // --- DEFAULT ---\n default: \"Default\",\n};\n\nexport const ITINERARY_SVG_ICONS = {\n Automotive: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2\"/><circle cx=\"7\" cy=\"17\" r=\"2\"/><path d=\"M9 17h6\"/><circle cx=\"17\" cy=\"17\" r=\"2\"/></svg>`,\n\n Transport: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z\"/></svg>`,\n\n \"Food and Drink\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2\"/><path d=\"M7 2v20\"/><path d=\"M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7\"/></svg>`,\n\n Lodging: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2 4v16\"/><path d=\"M2 8h18a2 2 0 0 1 2 2v10\"/><path d=\"M2 17h20\"/><path d=\"M6 8v9\"/></svg>`,\n\n Sightseeing: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-binoculars-icon lucide-binoculars\"><path d=\"M10 10h4\"/><path d=\"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3\"/><path d=\"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z\"/><path d=\"M 22 16 L 2 16\"/><path d=\"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z\"/><path d=\"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3\"/></svg>`,\n\n Recreation: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-kayak-icon lucide-kayak\"><path d=\"M18 17a1 1 0 0 0-1 1v1a2 2 0 1 0 2-2z\"/><path d=\"M20.97 3.61a.45.45 0 0 0-.58-.58C10.2 6.6 6.6 10.2 3.03 20.39a.45.45 0 0 0 .58.58C13.8 17.4 17.4 13.8 20.97 3.61\"/><path d=\"m6.707 6.707 10.586 10.586\"/><path d=\"M7 5a2 2 0 1 0-2 2h1a1 1 0 0 0 1-1z\"/></svg>`,\n\n Shopping: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z\"/><path d=\"M3 6h18\"/><path d=\"M16 10a4 4 0 0 1-8 0\"/></svg>`,\n\n Health: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 7v4\"/><path d=\"M14 21v-3a2 2 0 0 0-4 0v3\"/><path d=\"M14 9h-4\"/><path d=\"M18 11h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2\"/><path d=\"M18 21V5a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16\"/></svg>`,\n\n Finance: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect width=\"20\" height=\"14\" x=\"2\" y=\"5\" rx=\"2\"/><line x1=\"2\" y1=\"10\" x2=\"22\" y2=\"10\"/></svg>`,\n\n Geographical: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"m20 20-6-10.6c-.4-.7-1.5-.7-1.9 0L6 20\"/><path d=\"M7 16h10\"/><path d=\"M12 4a8 8 0 0 1 8 8v2a2 2 0 0 1-2 2h-1\"/><path d=\"M7 16H6a2 2 0 0 1-2-2v-2a8 8 0 0 1 8-8\"/></svg>`,\n\n Navigation: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-navigation-icon lucide-navigation\"><polygon points=\"3 11 22 2 13 21 11 13 3 11\"/></svg>`,\n\n City: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-building2-icon lucide-building-2\"><path d=\"M10 12h4\"/><path d=\"M10 8h4\"/><path d=\"M14 21v-3a2 2 0 0 0-4 0v3\"/><path d=\"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2\"/><path d=\"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16\"/></svg>`,\n\n District: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-land-plot-icon lucide-land-plot\"><path d=\"m12 8 6-3-6-3v10\"/><path d=\"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12\"/><path d=\"m6.49 12.85 11.02 6.3\"/><path d=\"M17.51 12.85 6.5 19.15\"/></svg>`,\n\n Airport: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-plane-icon lucide-plane\"><path d=\"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z\"/></svg>`,\n\n \"Subway Station\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-subway-icon lucide-subway\"><path d=\"M12 22a10 10 0 0 0 10-10V8l-5-5H7L2 8v4a10 10 0 0 0 10 10Z\"/><path d=\"M12 22V8\"/><path d=\"M7 13h10\"/><path d=\"M7 17h10\"/></svg>`,\n\n \"Train Station\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-train-icon lucide-train\"><path d=\"M2 10h20\"/><path d=\"M2 10a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5Z\"/><circle cx=\"7\" cy=\"15\" r=\"2\"/><circle cx=\"17\" cy=\"15\" r=\"2\"/></svg>`,\n\n Default: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z\"/><circle cx=\"12\" cy=\"10\" r=\"3\"/></svg>`,\n};\n","import \"./places-autocomplete.css\";\nimport { ITINERARY_CATEGORIES, ITINERARY_SVG_ICONS } from \"./constants.js\";\n\n/**\n * A flexible and customisable Places Autocomplete widget powered by the Google Maps Places API.\n *\n * Features:\n * - Dynamic Google Maps API loading\n * - Debounced input for optimized API requests\n * - Keyboard navigation (Arrow keys, Enter, Escape)\n * - Session token management for cost-effective API usage\n * - Customizable styling and behavior\n *\n * @author Alexander Pechkarev <alexpechkarev@gmail.com>\n * @license MIT\n */\nexport class PlacesAutocomplete {\n // --- Private Properties (using # or _ prefix by convention) ---\n #containerId; // Container ID where the autocomplete widget will be rendered.\n #pacEl;\n #googleMapsApiKey;\n #googleMapsApiVersion;\n #options;\n #request;\n #inputElement;\n #container;\n #ul;\n #ariaStatus; // For screen reader announcements\n #cache = new Map(); // Simple cache for suggestions\n #kbdEscape;\n #kbdUp;\n #kbdDown;\n #allSuggestions = [];\n #currentSuggestion = -1;\n #onDataCallback; // For user-provided data callback\n #onErrorCallback; // For user-provided error callback\n #debouncedMakeAcRequest; // Declare without initializing here\n #defaultOptions = {\n // Default options for the autocomplete widget.\n autofocus: false, // Automatically focus the input on load.\n autocomplete: \"off\", // HTML autocomplete attribute for the input.\n placeholder: \"Start typing your address ...\", // Placeholder text for the input.\n distance: false, // Show distance in suggestions (requires origin in request).\n distance_units: \"km\", // Units for distance ('km' or 'miles').\n label: \"\", // Optional label text above the input.\n debounce: 100, // Debounce delay (ms) for API requests.\n clear_input: false, // Clear input .\n debug: false, // Enable debug mode (not implemented in this version).\n response_type: \"json\", // Return format: 'json' for JSON object, 'place' for Google Maps Place instance.\n show_place_type: false, // Display place type icons (mutually exclusive with distance).\n };\n #defaultClasses = {\n // CSS classes for various parts of the widget.\n section: \"pac-section\", // Outer section container.\n container: \"pac-container\", // Main container div.\n icon_container: \"pac-icon-container\", // Container for the search icon.\n icon: '<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"pac-w-5 pac-h-5\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\" /><path d=\"m21 21-4.3-4.3\" /></svg>', // SVG for the search icon.\n input: \"pac-input\", // Input field.\n kbd_container: \"pac-kbd-container\", // Container for keyboard hints.\n kbd_escape: \"pac-kbd-escape\", // Escape key hint.\n kbd_up: \"pac-kbd-up\", // Up arrow key hint.\n kbd_down: \"pac-kbd-down\", // Down arrow key hint.\n kbd_active: \"pac-kbd-active\", // Class for active keyboard hint.\n ul: \"pac-ul\", // Suggestions list (ul).\n li: \"pac-li\", // Suggestion item (li).\n li_current: \"pac-li-current\", // Class for the currently selected suggestion item.\n li_button: \"pac-li-button\", // Link element within a suggestion item.\n li_button_current: \"pac-li-button-current\", // Class for the link in the currently selected suggestion item.\n li_div_container: \"pac-li-div-container\", // Container div within the suggestion link.\n li_div_p_container: \"pac-li-div-p-container\",\n li_div_one: \"pac-li-div-one\", // First inner div (for place name).\n li_div_one_p: \"pac-li-div-one-p\", // Paragraph for the place name.\n map_icon_svg: \"pac-map-icon-svg\",\n map_pin_icon:\n '<path d=\"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\"/><circle cx=\"12\" cy=\"10\" r=\"3\"/>',\n li_div_one_p_secondaryText: \"pac-li-div-one-p-secondaryText\",\n li_div_two: \"pac-li-div-two\", // Second inner div (for distance).\n li_div_two_p: \"pac-li-div-two-p\", // Paragraph for the distance.\n li_div_two_p_place_type: \"pac-li-div-two-p-place_type\", // Container for place type display.\n li_div_two_p_place_type_item: \"pac-li-div-two-p-place_type-item\", // Wrapper for individual options within the place type container.\n li_div_two_p_place_type_icon: \"pac-li-div-two-p-place_type-icon\", // The place type icon element.\n li_div_two_p_place_type_label: \"pac-li-div-two-p-place_type-label\", // The place type label text.\n highlight: \"pac-highlight\", // Class for highlighting matched text in suggestions.\n };\n #defaultRequestParams = {\n // Default parameters for the autocomplete request.\n input: \"\", // Initial input value (empty).\n includedRegionCodes: [\"GB\"], // Default region codes to include in suggestions.\n language: \"en-gb\",\n // region: \"GB\",\n };\n #fetchFields = [\"formattedAddress\", \"addressComponents\"];\n #defaultFetchFields = [\"formattedAddress\", \"addressComponents\"]; // Fields to fetch for the selected place (can be extended).\n\n /**\n * Class constructor for PacAutocomplete.\n * Initializes the autocomplete widget with the provided configuration.\n * @param {Object} config - Configuration object for the autocomplete widget.\n * @param {string} config.containerId - ID of the container element for the widget.\n * @param {string} config.googleMapsApiKey - Google Maps API key.\n * @param {string} [config.googleMapsApiVersion] - Version of the Google Maps API to use (default: \"weekly\").\n * @param {Object} [config.options] - Additional options for the widget (e.g., classes, callbacks).\n * @param {Object} [config.requestParams] - Parameters for the autocomplete request (e.g., input, region).\n * @param {*} config\n */\n constructor(config) {\n if (!config || !config.containerId || !config.googleMapsApiKey) {\n throw new Error(\n \"PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).\",\n );\n }\n\n this.#containerId = config.containerId; // Store the configuration object\n this.#pacEl = document.getElementById(config.containerId);\n if (!this.#pacEl) {\n throw new Error(\n `PacAutocomplete: Container element with ID \"${config.containerId}\" not found.`,\n );\n }\n\n this.#googleMapsApiKey = config.googleMapsApiKey;\n this.#googleMapsApiVersion = config.googleMapsApiVersion || \"weekly\";\n\n // Merge user options with defaults\n this.#options = {\n ...this.#defaultOptions, // Default options\n ...config.options, // User-defined options override defaults\n };\n // Ensure classes are deeply merged if user provides partial classes\n if (config.options && config.options.classes) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...config.options.classes,\n };\n } else {\n this.#options.classes = this.#defaultClasses; // Use default classes if none provided\n }\n\n if (this.#options.debug) {\n console.log(\"___debug constructor options:\");\n console.log(this.#options);\n }\n\n if (config.fetchFields && Array.isArray(config.fetchFields)) {\n this._setFetchFields(config.fetchFields); // Set fetch fields from user config\n }\n\n // Set default response and error callbacks if not provided\n this.#onDataCallback =\n config.onResponse ||\n ((place) => {\n console.info(\"---------Default onResponse not provided---------\");\n console.info(\"Selected Place:\", JSON.stringify(place, null, 2));\n });\n this.#onErrorCallback =\n config.onError ||\n ((error) => {\n console.error(\"---------Default onError not provided---------\");\n console.error(\"PAC Error:\", error);\n });\n\n if (config.requestParams && Object.keys(config.requestParams).length > 0) {\n this.#request = {\n ...this.#defaultRequestParams,\n ...config.requestParams,\n };\n } else {\n this.#request = { ...this.#defaultRequestParams }; // Use defaults if no requestParams provided\n }\n\n if (this.#options.debug) {\n console.log(\"___debug constructor requestParams:\", this.#request);\n }\n\n this._initialiseDebouncedRequest(); // Initialize the debounced request function\n\n this._init(); // Underscore prefix for internal initialization method\n }\n\n // --- Private Initialization Method ---\n async _init() {\n try {\n // check if google maps api is already loaded\n if (typeof google === \"undefined\" || !google.maps) {\n // Load the Google Maps API dynamically\n await this._loadGoogleMapsApi({\n key: this.#googleMapsApiKey,\n v: this.#googleMapsApiVersion,\n });\n }\n this._createPACStructure();\n await this._initializeAutocomplete();\n } catch (error) {\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Initializes the debounced request function for fetching autocomplete suggestions.\n * This function is called on initialization and when options are updated.\n *\n * @private\n */\n _initialiseDebouncedRequest() {\n this.#debouncedMakeAcRequest = this._debounce(async () => {\n const query = this.#inputElement?.value;\n if (!query) {\n this._reset();\n if (this.#inputElement)\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n return;\n }\n\n // Check cache\n if (this.#cache.has(query)) {\n await this._renderSuggestions(this.#cache.get(query));\n return;\n }\n\n this.#request.input = query;\n\n try {\n const { suggestions } =\n // eslint-disable-next-line no-undef\n await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(\n this.#request,\n );\n\n // Cache and display suggestions\n if (suggestions && suggestions.length > 0) {\n this.#cache.set(query, suggestions);\n await this._renderSuggestions(suggestions);\n } else {\n // No suggestions found\n this._reset(); // Clear any old suggestions\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this._announceStatus(\"No suggestions found.\");\n }\n } catch (error) {\n this.#onErrorCallback(error);\n this._reset();\n }\n }, this.#options.debounce); // Default debounce to 100ms if not set\n }\n\n /**\n * Renders the suggestions list.\n * @private\n */\n async _renderSuggestions(suggestions) {\n const suggestionElements = await Promise.all(\n this._createSuggestionElements(suggestions),\n );\n this.#ul.replaceChildren(...suggestionElements);\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n this._announceStatus(`${suggestions.length} suggestions found.`);\n }\n\n /**\n * Announces a message to screen readers using aria-live.\n * @private\n */\n _announceStatus(message) {\n if (this.#ariaStatus) {\n this.#ariaStatus.textContent = message;\n }\n }\n\n /**\n * Sets the fields to fetch for the selected place.\n * @param {Array<string>} fields - The fields to fetch.\n */\n _setFetchFields(fields) {\n if (Array.isArray(fields) && fields.length > 0) {\n this.#fetchFields = [\n ...new Set([...this.#defaultFetchFields, ...fields]),\n ].filter((e) => e); // Ensure unique and non-empty fields\n }\n }\n\n /**\n * Creates a debounced version of a function.\n *\n * @private\n * @param {Function} func - The function to debounce\n * @param {number} wait - Delay in milliseconds\n * @returns {Function} Debounced function\n */\n _debounce(func, wait) {\n let timeout = null;\n return function executedFunction(...args) {\n const later = () => {\n timeout = null;\n func(...args); // Call original function\n };\n if (timeout !== null) {\n clearTimeout(timeout); // Clear the previous timeout\n }\n timeout = setTimeout(later, wait ?? 100); // Set the new timeout\n };\n }\n /**\n * Formats a distance value from meters to the specified unit.\n *\n * @private\n * @param {number|null|undefined} distance - Distance in meters\n * @param {('km'|'miles')} units - Target unit for conversion\n * @returns {string|null} Formatted distance string or null if invalid\n */\n _formatDistance(distance, units) {\n if (!this.#options.distance) {\n return null;\n }\n if (typeof distance !== \"number\") {\n return \"Origin required for distance\"; // Return informative message if distance requested but missing\n }\n let value;\n let unitLabel;\n if (units === \"km\") {\n value = (distance / 1000).toFixed(2);\n unitLabel = \"km\";\n } else {\n // Default to miles if not 'km'\n value = (distance / 1609.34).toFixed(2);\n unitLabel = \"miles\";\n }\n // Avoid showing \".00\"\n value = value.replace(/\\.00$/, \"\");\n return `${value} ${unitLabel}`;\n }\n\n /**\n * Dynamically loads the Google Maps JavaScript API using the importLibrary method.\n * This is the standard approach recommended by Google.\n * @see https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n * @param {object} g - Configuration object for the API loader (key, v, libraries, etc.).\n */\n async _loadGoogleMapsApi(g) {\n var h, // Promise tracking API load\n a, // Script element\n k, // Loop variable for config keys\n p = \"The Google Maps JavaScript API\", // Error message prefix\n c = \"google\", // Global namespace\n l = \"importLibrary\", // Loader function name\n q = \"__ib__\", // Internal callback name\n m = document, // Document reference\n b = window; // Window reference\n b = b[c] || (b[c] = {}); // Ensure google namespace exists\n var d = b.maps || (b.maps = {}), // Ensure google.maps namespace exists\n r = new Set(), // Set to track requested libraries\n e = new URLSearchParams(), // URL parameters for the API script\n u = () =>\n // Function to initiate API loading (if not already started)\n h ||\n // eslint-disable-next-line no-async-promise-executor\n (h = new Promise(async (f, n) => {\n // Create script element (done async to potentially wait for nonce)\n // await (a = m.createElement('script')); // Original Google code had await here, might not be needed\n a = m.createElement(\"script\"); // Create script tag\n e.set(\"libraries\", [...r].join(\",\")); // Add accumulated libraries\n // Add other parameters from the config object 'g'\n for (k in g)\n e.set(\n k.replace(/[A-Z]/g, (t) => \"_\" + t[0].toLowerCase()), // Convert camelCase to snake_case\n g[k],\n );\n e.set(\"callback\", c + \".maps.\" + q); // Set the internal callback function name\n a.src = `https://maps.${c}apis.com/maps/api/js?` + e; // Construct the API URL\n d[q] = f; // Assign the promise resolver to the callback name on google.maps\n // Error handling for script loading failure\n a.onerror = () =>\n (h = n(\n new Error(\n `${p} could not load. Check your API key and network connection.`,\n ),\n )); // Use onerror for load failures\n // Nonce for Content Security Policy\n a.nonce = m.querySelector(\"script[nonce]\")?.nonce || \"\";\n m.head.append(a); // Append the script to the document head\n }));\n // Define or reuse the importLibrary function on google.maps\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n d[l]\n ? console.warn(p + \" only loads once. Ignoring:\", g) // Warn if called again\n : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n))); // The actual importLibrary implementation\n }\n\n // --- UI Creation ---\n _createPACStructure() {\n const section = document.createElement(\"section\");\n section.className = this.#options.classes.section;\n\n // Main container\n this.#container = document.createElement(\"div\");\n this.#container.className = this.#options.classes.container;\n this.#container.setAttribute(\"id\", this.#containerId + \"-div\");\n section.appendChild(this.#container);\n\n // Live region for a11y status updates\n this.#ariaStatus = document.createElement(\"div\");\n this.#ariaStatus.setAttribute(\"aria-live\", \"polite\");\n this.#ariaStatus.setAttribute(\"role\", \"status\");\n this.#ariaStatus.className = \"pac-sr-only\"; // Screen reader only\n this.#container.appendChild(this.#ariaStatus);\n\n // Icon\n const iconContainer = document.createElement(\"div\");\n iconContainer.className = this.#options.classes.icon_container;\n this.#container.appendChild(iconContainer);\n const icon = document.createElement(\"div\");\n icon.innerHTML = this.#options.classes.icon;\n iconContainer.appendChild(icon.firstElementChild); // Append the actual SVG element\n\n // Input field\n this.#inputElement = document.createElement(\"input\");\n this.#inputElement.id = this.#containerId + \"-input\"; // Assign ID for label association\n this.#inputElement.type = \"text\";\n this.#inputElement.name = \"search\"; // Consider making name configurable\n this.#inputElement.placeholder = this.#options.placeholder;\n this.#inputElement.autocomplete = this.#options.autocomplete;\n this.#inputElement.className = this.#options.classes.input;\n this.#inputElement.setAttribute(\"role\", \"combobox\");\n this.#inputElement.setAttribute(\"aria-autocomplete\", \"list\");\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\"); // Will be updated dynamically\n this.#inputElement.setAttribute(\"aria-controls\", \"pacSuggestions\"); // Links to the suggestions list\n this.#inputElement.setAttribute(\"aria-activedescendant\", \"\"); // Will be updated dynamically\n\n if (this.#options.autofocus) {\n this.#inputElement.autofocus = true;\n }\n if (this.#options.label) {\n const label = document.createElement(\"label\");\n label.htmlFor = this.#inputElement.id; // Correctly link label to input by ID\n label.textContent = this.#options.label;\n // Add label classes if needed from opts.classes\n section.prepend(label); // Append label before input or adjust structure\n }\n this.#container.appendChild(this.#inputElement);\n\n // Keyboard hints container\n const kbdContainer = document.createElement(\"div\");\n kbdContainer.className = this.#options.classes.kbd_container;\n this.#kbdEscape = document.createElement(\"kbd\");\n this.#kbdEscape.className = this.#options.classes.kbd_escape;\n this.#kbdEscape.textContent = \"Esc\";\n kbdContainer.appendChild(this.#kbdEscape);\n this.#kbdUp = document.createElement(\"kbd\");\n this.#kbdUp.className = this.#options.classes.kbd_up;\n this.#kbdUp.innerHTML = \"↑\"; // Up arrow HTML entity\n kbdContainer.appendChild(this.#kbdUp);\n this.#kbdDown = document.createElement(\"kbd\");\n this.#kbdDown.className = this.#options.classes.kbd_down;\n this.#kbdDown.innerHTML = \"↓\"; // Down arrow HTML entity\n kbdContainer.appendChild(this.#kbdDown);\n this.#container.appendChild(kbdContainer);\n\n // Suggestions list (initially hidden)\n this.#ul = document.createElement(\"ul\");\n this.#ul.id = \"pacSuggestions\"; // Must match aria-controls\n this.#ul.className = this.#options.classes.ul;\n this.#ul.style.display = \"none\";\n this.#ul.setAttribute(\"role\", \"listbox\");\n this.#ul.setAttribute(\"aria-labelledby\", this.#inputElement.id); // Link listbox to input for accessibility\n this.#container.appendChild(this.#ul);\n\n // Event Delegation for suggestion selection\n this.#ul.addEventListener(\"click\", (e) => {\n const li = e.target.closest(\"li\");\n if (li && this.#ul.contains(li)) {\n const index = Array.from(this.#ul.children).indexOf(li);\n if (index !== -1 && this.#allSuggestions[index]) {\n this._onPlaceSelected(this.#allSuggestions[index].place);\n }\n }\n });\n\n this.#pacEl.appendChild(section);\n section.addEventListener(\"keydown\", this._onKeyDown.bind(this)); // Bind 'this'\n }\n\n /**\n * Attaches event listeners to the input element for handling user input.\n * This includes debounced input handling, focus/blur events, and keyboard navigation.\n */\n _attachedEventListeners() {\n this.#inputElement.addEventListener(\"input\", this.#debouncedMakeAcRequest);\n // Add focus/blur listeners if needed to manage suggestion visibility\n this.#inputElement.addEventListener(\"blur\", () => {\n // Delay hiding suggestions to allow click events on them\n setTimeout(() => {\n if (this.#ul && !this.#ul.contains(document.activeElement)) {\n // Check if focus moved outside suggestions\n this.#ul.style.display = \"none\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, 200); // Adjust delay as needed\n });\n this.#inputElement.addEventListener(\"focus\", () => {\n // Potentially show suggestions again if input has value\n if (this.#inputElement.value && this.#allSuggestions.length > 0) {\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n }\n });\n }\n\n _detachEventListeners() {\n // Remove event listeners, remove elements from DOM\n if (this.#inputElement) {\n this.#inputElement.removeEventListener(\n \"input\",\n this.#debouncedMakeAcRequest,\n );\n // remove other listeners\n }\n if (this.#pacEl && this.#container) {\n this.#pacEl.removeChild(this.#container.parentElement); // remove the whole section\n }\n }\n\n /**\n * Initializes the core autocomplete functionality after the API is loaded.\n * Imports necessary libraries and sets up the input event listener.\n */\n async _initializeAutocomplete() {\n try {\n // Ensure the 'places' library is available via the dynamic loader\n // eslint-disable-next-line no-undef\n await google.maps.importLibrary(\"places\");\n // console.log('Places library imported successfully.'); // For debugging\n\n // Initial token generation\n this._refreshToken();\n\n // Attach the debounced request function to the input element's 'input' event\n if (this.#inputElement) {\n this._attachedEventListeners();\n } else {\n this.#onErrorCallback(\n new Error(\"Input element not found during initialization.\"),\n );\n }\n } catch (error) {\n console.error(\"Error initializing Google Places Autocomplete:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(\n new Error(\"Google Maps Places library not available.\"),\n );\n }\n }\n\n /**\n * Resets the autocomplete input field, clears suggestions, and optionally refreshes the session token.\n * @param {boolean} [refresh=false] - Whether to refresh the Google Places session token.\n */\n _reset(refresh = false, placeData = null) {\n this.#currentSuggestion = -1;\n\n /**\n * If the input element exists and clear_input is false, set its value to the formatted address\n * from placeData. Otherwise, clear the input value.\n * This allows the user to keep the input value if they selected a place,\n * but still allows clearing it if clear_input is true or placeData is not provided.\n * @type {HTMLInputElement}\n * @property {string} value - The value of the input element.\n * @property {boolean} clear_input - Whether to clear the input value after selection.\n * @property {Object} placeData - The data of the selected place, containing formattedAddress.\n */\n if (\n this.#inputElement &&\n this.#options.clear_input == false &&\n placeData &&\n placeData.formattedAddress\n ) {\n this.#inputElement.value = placeData.formattedAddress; // Set input value to formatted address\n } else if (this.#inputElement) {\n this.#inputElement.value = \"\";\n }\n\n if (this.#inputElement) {\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this.#inputElement.setAttribute(\"aria-activedescendant\", \"\"); // Clear aria-activedescendant\n this.#inputElement.blur();\n }\n\n this.#allSuggestions = [];\n this.#currentSuggestion = -1;\n if (this.#ul) {\n this.#ul.innerHTML = \"\"; // Clear existing suggestions\n this.#ul.style.display = \"none\";\n }\n if (refresh) {\n this._refreshToken();\n }\n }\n /**\n * Removes the 'current' highlighting classes from all suggestion list items (li) and their links (a).\n */\n _resetLiClasses() {\n if (!this.#ul) return;\n Array.from(this.#ul.children).forEach((li) => {\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => li.classList.remove(cl));\n const link = li.querySelector(\"button\");\n if (link) {\n this.#options.classes.li_button_current\n .split(\" \")\n .forEach((cl) => link.classList.remove(cl));\n }\n });\n }\n\n /**\n * Handles keyboard events (ArrowDown, ArrowUp, Enter, Escape) for navigating\n * and selecting suggestions or closing the list.\n * @param {KeyboardEvent} e - The keyboard event object.\n */\n _onKeyDown(e) {\n this._resetLiClasses(); // Reset classes on any key press within the suggestions\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.remove(cl)),\n 300,\n );\n\n this._reset(true); // Reset search input and results, refresh token\n }\n\n if (\n !this.#allSuggestions.length ||\n !this.#ul ||\n this.#ul.style.display === \"none\"\n )\n return;\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.min(\n this.#currentSuggestion + 1,\n this.#allSuggestions.length - 1,\n );\n this._highlightSuggestion();\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.max(this.#currentSuggestion - 1, 0); // Stay at 0 if already there\n this._highlightSuggestion();\n } else if (e.key === \"Home\") {\n e.preventDefault();\n this.#currentSuggestion = 0;\n this._highlightSuggestion();\n } else if (e.key === \"End\") {\n e.preventDefault();\n this.#currentSuggestion = this.#allSuggestions.length - 1;\n this._highlightSuggestion();\n } else if (e.key === \"Enter\") {\n e.preventDefault(); // Prevent form submission if applicable\n if (\n this.#currentSuggestion >= 0 &&\n this.#currentSuggestion < this.#allSuggestions.length\n ) {\n this._onPlaceSelected(\n this.#allSuggestions[this.#currentSuggestion].place,\n );\n // Reset is handled within onPlaceSelected via reset(true)\n }\n }\n }\n\n /**\n * Highlights the current suggestion in the UI.\n * @private\n */\n _highlightSuggestion() {\n if (this.#currentSuggestion < 0) return;\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentButton = currentLi.querySelector(\"button\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentButton) {\n this.#options.classes.li_button_current\n .split(\" \")\n .forEach((cl) => currentButton.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n this.#inputElement.setAttribute(\"aria-activedescendant\", currentLi.id); // Update aria-activedescendant\n\n // Visual feedback for key press\n const kbd =\n this.#currentSuggestion === 0\n ? this.#kbdUp\n : this.#kbdDown;\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => kbd?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => kbd?.classList.remove(cl)),\n 300,\n );\n }\n }\n\n // Helper function to find a specific address component\n _getAddressComponent(response, type) {\n return (\n response.addressComponents?.find((c) => c.types.includes(type))\n ?.longText || \"\"\n );\n }\n\n /**\n * Creates a button element for a suggestion item.\n * @returns {HTMLButtonElement} The created button element.\n */\n _createButtonElement(index) {\n const button = document.createElement(\"button\");\n button.tabIndex = index + 1;\n button.className = this.#options.classes.li_button; // block w-full flex justify-between\n return button;\n }\n\n /**\n * Creates a div container for suggestion item.\n * @returns {HTMLDivElement} The created div container element.\n */\n _createDivElement(className) {\n // create div elements pac-li-div-container\n const divContainer = document.createElement(\"div\");\n if (className) {\n divContainer.className = className;\n }\n return divContainer;\n }\n\n /**\n * Creates an SVG element representing a map pin icon.\n * @returns {SVGSVGElement} The created SVG element.\n */\n _createMapPinIconElement() {\n const svgIcon = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"svg\",\n );\n svgIcon.setAttribute(\"xmlns\", \"http://www.w3.org/2000/svg\");\n svgIcon.setAttribute(\"width\", \"24\");\n svgIcon.setAttribute(\"height\", \"24\");\n svgIcon.setAttribute(\"viewBox\", \"0 0 24 24\");\n svgIcon.setAttribute(\"fill\", \"none\");\n svgIcon.setAttribute(\"stroke\", \"currentColor\");\n svgIcon.setAttribute(\"stroke-width\", \"2\");\n svgIcon.setAttribute(\"stroke-linecap\", \"round\");\n svgIcon.setAttribute(\"stroke-linejoin\", \"round\");\n svgIcon.setAttribute(\"class\", this.#options.classes.map_icon_svg);\n // insert map pin icon path\n svgIcon.innerHTML = this.#options.classes.map_pin_icon;\n return svgIcon;\n }\n\n /**\n * Creates a paragraph (P) element with an optional class name.\n * @param {string} className\n * @returns {HTMLParagraphElement}\n */\n _createPElement(className) {\n const p = document.createElement(\"p\");\n if (className) {\n p.className = className;\n }\n return p;\n }\n /**\n * Creates an array of list item (LI) elements for the suggestions dropdown.\n * Each LI contains a link (A) with the place prediction details and distance.\n * Handles highlighting the matched parts of the suggestion text.\n * @param {Array<google.maps.places.AutocompleteSuggestion>} suggestions - Array of suggestion objects from the API.\n * @returns {Array<HTMLLIElement>} An array of LI elements to be added to the suggestions UL.\n */\n _createSuggestionElements(suggestions) {\n this.#allSuggestions = []; // Reset before populating\n // Map suggestions to LI elements\n return suggestions.map(async (suggestion, index) => {\n // Fetch place details for each suggestion\n let place = suggestion.placePrediction.toPlace();\n\n const li = document.createElement(\"li\");\n li.id = `option-${index + 1}`;\n li.className = this.#options.classes.li;\n li.setAttribute(\"role\", \"option\");\n\n // create button element\n const button = this._createButtonElement(index);\n\n // create div elements pac-li-div-container\n const divContainer = this._createDivElement(\n this.#options.classes.li_div_container,\n );\n\n // create li div one element - place name\n const liDivOne = this._createDivElement(this.#options.classes.li_div_one);\n const liDivTwo = this._createDivElement(this.#options.classes.li_div_two);\n // create map pin icon element\n const mapPinIcon = this._createMapPinIconElement();\n // append map pin icon to liDivOne\n liDivOne.appendChild(mapPinIcon);\n\n // create div p container\n const divPContainer = this._createDivElement(\n this.#options.classes.li_div_p_container,\n );\n // append div p container to liDivOne\n liDivOne.appendChild(divPContainer);\n\n // create p element - place name\n const pOne = this._createPElement(this.#options.classes.li_div_one_p);\n // create p element - secondary text\n const pTwo = this._createPElement(\n this.#options.classes.li_div_one_p_secondaryText,\n );\n // create p element - distance\n // Try to get distanceMeters from placePrediction or directly from suggestion\n const distanceMeters =\n suggestion.placePrediction?.distanceMeters ?? suggestion.distanceMeters;\n const distanceValue = this._formatDistance(\n distanceMeters,\n this.#options.distance_units ?? \"km\",\n );\n\n // append p element to div p container\n divPContainer.appendChild(pOne);\n divPContainer.appendChild(pTwo);\n\n // Add place type display and/or distance if enabled\n this._renderSuggestionMeta(liDivTwo, suggestion, distanceValue);\n\n // append liDivOne to divContainer\n divContainer.appendChild(liDivOne);\n divContainer.appendChild(liDivTwo);\n // append divContainer to button\n button.appendChild(divContainer);\n // append button to li\n li.appendChild(button);\n\n this._renderHighlightText(pOne, suggestion.placePrediction.mainText);\n\n // set secondary text if available\n const secondaryText =\n suggestion.placePrediction?.secondaryText?.text ?? \"\";\n\n if (secondaryText) {\n pTwo.textContent = secondaryText;\n }\n\n this.#allSuggestions.push({\n id: index + 1,\n place: place,\n mainText: suggestion.placePrediction.mainText.text,\n secondaryText: secondaryText,\n description: suggestion.placePrediction.toString(),\n });\n\n return li;\n });\n }\n\n /**\n * Renders meta information (place type, distance) for a suggestion.\n * @private\n */\n _renderSuggestionMeta(container, suggestion, distanceValue) {\n if (this.#options.show_place_type || this.#options.distance) {\n const metaContainer = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type,\n );\n\n // Place Type display\n if (\n this.#options.show_place_type &&\n Array.isArray(suggestion.placePrediction?.types) &&\n suggestion.placePrediction.types.length > 0\n ) {\n const placeTypeWrapper = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type_item,\n );\n\n const placeTypeIcon = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_icon,\n );\n\n const placeTypeLabel = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_label,\n );\n\n // Look through the array until we find a type we actually recognize\n const matchedType = suggestion.placePrediction.types.find(\n (type) => typeof type === \"string\" && type in ITINERARY_CATEGORIES,\n );\n\n placeTypeLabel.textContent = matchedType\n ? ITINERARY_CATEGORIES[matchedType]\n : \"Default\";\n\n placeTypeIcon.innerHTML =\n ITINERARY_SVG_ICONS[placeTypeLabel.textContent] ||\n ITINERARY_SVG_ICONS[\"Default\"];\n\n placeTypeWrapper.appendChild(placeTypeIcon);\n placeTypeWrapper.appendChild(placeTypeLabel);\n metaContainer.appendChild(placeTypeWrapper);\n }\n\n // Distance display\n if (this.#options.distance && distanceValue !== null) {\n const distanceWrapper = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type_item,\n );\n const pThree = this._createPElement(this.#options.classes.li_div_two_p);\n pThree.textContent = distanceValue;\n distanceWrapper.appendChild(pThree);\n metaContainer.appendChild(distanceWrapper);\n }\n\n if (metaContainer.hasChildNodes()) {\n container.appendChild(metaContainer);\n }\n }\n }\n\n /**\n * Renders highlighted text for a suggestion.\n * @private\n */\n _renderHighlightText(element, predictionText) {\n const originalText = predictionText.text;\n const matches = predictionText.matches;\n let lastIndex = 0;\n\n matches.sort((a, b) => a.startOffset - b.startOffset);\n\n const outerSpan = document.createElement(\"span\");\n const innerSpan = document.createElement(\"span\");\n innerSpan.classList = this.#options.classes.highlight ?? \"font-bold\";\n\n for (const match of matches) {\n outerSpan.textContent += originalText.substring(\n lastIndex,\n match.startOffset,\n );\n if (match.startOffset > 0) {\n const prevChar = originalText.charAt(match.startOffset - 1);\n if (prevChar === \" \") {\n innerSpan.textContent += \" \";\n }\n }\n innerSpan.textContent += originalText.substring(\n match.startOffset,\n match.endOffset,\n );\n lastIndex = match.endOffset;\n }\n\n outerSpan.appendChild(innerSpan);\n outerSpan.appendChild(\n document.createTextNode(originalText.substring(lastIndex)),\n );\n element.appendChild(outerSpan);\n }\n\n /**\n * Handles the selection of a place. Fetches required fields\n * (displayName, formattedAddress, addressComponents) and calls the\n * user-defined `onPacData` callback.\n * @param {google.maps.places.Place} place - The selected Place object.\n */\n async _onPlaceSelected(place) {\n let data = null;\n try {\n // Fetch necessary details for the selected place\n await place.fetchFields({\n fields: this.#fetchFields, //[\"displayName\", \"formattedAddress\", \"addressComponents\"], // Add more fields as needed\n });\n // Call the user-provided callback with the place data\n // Handle response_type option\n if (this.#options.response_type === \"place\") {\n data = place; // Return the Place instance\n this.#onDataCallback(place);\n } else {\n // eslint-disable-next-line no-undef\n data = place.toJSON(); // Convert to plain JSON object (default)\n this.#onDataCallback(data);\n }\n } catch (error) {\n console.error(\"Error fetching place details:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n } finally {\n // Reset the input and suggestions regardless of success/error\n this._reset(true, data); // Refresh token after selection\n }\n }\n\n /**\n * Creates a new Google Places Autocomplete Session Token.\n * This should be called before starting a new series of autocomplete requests.\n */\n _refreshToken() {\n try {\n // eslint-disable-next-line no-undef\n this.#request.sessionToken =\n new google.maps.places.AutocompleteSessionToken();\n } catch (error) {\n console.error(\"Error creating session token:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to be fetched for the selected place.\n * This allows you to specify which details you want to retrieve\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @param {Array<string>} fields - Array of field names to fetch.\n */\n setFetchFields(fields) {\n this._setFetchFields(fields);\n }\n /**\n * Gets the current fields that will be fetched for the selected place.\n * This is useful for understanding what details will be available\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @returns {Array<string>} The current fetch fields.\n */\n getFetchFields() {\n return this.#fetchFields;\n }\n\n /**\n * Sets the request parameters for the Places Autocomplete instance.\n * This method allows you to update the request parameters dynamically,\n * such as the input value, region codes, language, etc.\n * It merges the provided parameters with the default request parameters,\n * allowing you to override specific values while keeping the defaults intact.\n * This is useful for updating the search criteria without needing to recreate the instance.\n * @param {*} params\n */\n setRequestParams(params) {\n if (\n typeof params === \"object\" &&\n !Array.isArray(params) &&\n params !== null\n ) {\n // if params.input is provided, set it to the input element\n if (params.input && typeof params.input === \"string\") {\n this.#inputElement.value = params.input; // Set input value if provided\n }\n // Merge provided params with default request parameters\n // This allows overriding specific request parameters while keeping defaults\n this.#request = {\n ...this.#defaultRequestParams,\n ...params,\n };\n }\n }\n\n /**\n * Returns the current request parameters used by the Places Autocomplete instance.\n * This includes the input value, included region codes, language, and other settings.\n * It is useful for debugging or when you need to know the current search criteria.\n * @returns {Object} The current request parameters.\n */\n getRequestParams() {\n return this.#request;\n }\n\n /**\n * Sets the options for the Places Autocomplete instance.\n * This method allows you to change the appearance and behavior of the autocomplete widget,\n * such as classes, placeholder text, debounce time, etc.\n * It merges the provided options with the default options, allowing you to override specific values\n * while keeping the defaults intact.\n * This is useful for updating the widget's configuration without needing to recreate the instance.\n * @param {*} options\n */\n setOptions(options) {\n if (\n typeof options === \"object\" &&\n !Array.isArray(options) &&\n options !== null\n ) {\n this._detachEventListeners(); // Detach event listeners\n\n // // Ensure classes are deeply merged if user provides partial classes\n const tmpClasses = options.classes || {};\n delete options.classes; // Remove classes from options to avoid overwriting\n\n // Merge provided options with default options\n // This allows overriding specific options while keeping defaults\n this.#options = {\n ...this.#defaultOptions,\n ...options,\n };\n\n // Merge classes with defaults\n // This allows overriding specific classes while keeping defaults\n if (\n tmpClasses &&\n typeof tmpClasses === \"object\" &&\n Object.keys(tmpClasses).length > 0\n ) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...tmpClasses,\n };\n } else {\n this.#options.classes = { ...this.#defaultClasses }; // Use defaults if no classes provided\n }\n\n this._initialiseDebouncedRequest(); // Reinitialize the debounced request function\n this._createPACStructure(); // Recreate the structure with new options\n // Reattach the input event listener to the input element\n // This is necessary to ensure the new input element is ready for events\n if (this.#inputElement) {\n this._attachedEventListeners();\n } // Reinitialize the autocomplete functionality\n }\n }\n\n /**\n * Gets the current options used by the Places Autocomplete instance.\n * @returns {Object} The current options.\n */\n getOptions() {\n /**\n * Returns the current options used by the Places Autocomplete instance.\n * This includes classes, placeholder text, debounce time, and other settings.\n * It is useful for debugging or when you need to know the current configuration of the widget.\n * @returns {Object} The current options.\n */\n return this.#options;\n }\n\n /**\n * Sets the input value by reverse geocoding coordinates.\n * Performs reverse geocoding to convert lat/lng to a place, then triggers onResponse.\n * Requires the Geocoding API to be enabled in your Google Cloud Console project.\n * @param {number} latitude - Latitude coordinate\n * @param {number} longitude - Longitude coordinate\n * @returns {Promise<void>}\n */\n async setInputValue(latitude, longitude) {\n try {\n // Import the geocoding library\n const { Geocoder } = await google.maps.importLibrary(\"geocoding\");\n const geocoder = new Geocoder();\n\n // Perform reverse geocoding\n const response = await geocoder.geocode({\n location: { lat: latitude, lng: longitude },\n });\n\n if (response.results && response.results.length > 0) {\n const placeId = response.results[0].place_id;\n const place = new google.maps.places.Place({ id: placeId });\n\n // Fetch the configured fields\n await place.fetchFields({ fields: this.#fetchFields });\n\n // Update input field if clear_input is false\n if (!this.#options.clear_input && place.formattedAddress) {\n this.#inputElement.value = place.formattedAddress;\n }\n\n // Trigger the callback with appropriate response type\n if (this.#options.response_type === \"place\") {\n this.#onDataCallback(place);\n } else {\n this.#onDataCallback(place.toJSON());\n }\n } else {\n throw new Error(\"No results found for the provided coordinates\");\n }\n } catch (error) {\n console.error(\"Error in setInputValue:\", error);\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Clears the autocomplete input field and suggestions list.\n * This method resets the state of the autocomplete widget,\n * allowing the user to start a new search without any previous input or suggestions.\n * It also refreshes the Google Places session token to ensure a new session.\n * @returns {void}\n */\n clear() {\n this.#cache.clear();\n this._reset(true);\n }\n\n /**\n * Sets focus on the autocomplete input field.\n * This method allows programmatic control of the input focus,\n * useful for improving user experience and accessibility.\n * @returns {void}\n */\n focus() {\n if (this.#inputElement) {\n this.#inputElement.focus();\n }\n }\n\n /**\n * Destroys the PacAutocomplete instance.\n * Removes event listeners, clears the DOM, and nullifies properties.\n * This method should be called when the autocomplete widget is no longer needed.\n * It ensures that all resources are cleaned up to prevent memory leaks.\n * @returns {void}\n */\n destroy() {\n // Remove event listeners, remove elements from DOM\n this._detachEventListeners(); // Detach event listeners\n // Nullify properties\n this.#containerId = null;\n this.#pacEl = null;\n this.#googleMapsApiKey = null;\n this.#googleMapsApiVersion = null;\n this.#options = null;\n this.#request = null;\n this.#inputElement = null;\n this.#container = null;\n this.#ul = null;\n this.#ariaStatus = null;\n this.#cache = null;\n this.#kbdEscape = null;\n this.#kbdUp = null;\n this.#kbdDown = null;\n this.#allSuggestions = null;\n this.#currentSuggestion = -1;\n this.#onDataCallback = null;\n this.#onErrorCallback = null;\n this.#debouncedMakeAcRequest = null;\n }\n}\n"],"mappings":";AAAA,IAAa,IAAuB;CAElC,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,mCAAmC;CACnC,SAAS;CACT,SAAS;CACT,aAAa;CACb,eAAe;CACf,gBAAgB;CAChB,YAAY;CACZ,gBAAgB;CAGhB,YAAY;CACZ,MAAM;CACN,aAAa;CACb,KAAK;CACL,KAAK;CACL,YAAY;CACZ,QAAQ;CACR,sBAAsB;CACtB,gBAAgB;CAChB,kBAAkB;CAClB,aAAa;CACb,kBAAkB;CAGlB,OAAO;CACP,QAAQ;CACR,OAAO;CACP,cAAc;CACd,mBAAmB;CACnB,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS;CACT,KAAK;CACL,aAAa;CAGb,oBAAoB;CACpB,QAAQ;CACR,aAAa;CACb,mBAAmB;CACnB,qBAAqB;CACrB,UAAU;CACV,yBAAyB;CACzB,UAAU;CACV,KAAK;CACL,gBAAgB;CAChB,aAAa;CACb,UAAU;CACV,kBAAkB;CAGlB,MAAM;CACN,eAAe;CACf,YAAY;CACZ,OAAO;CACP,aAAa;CACb,gBAAgB;CAChB,YAAY;CACZ,kBAAkB;CAClB,aAAa;CACb,KAAK;CACL,iBAAiB;CAGjB,eAAe;CACf,aAAa;CACb,eAAe;CACf,gBAAgB;CAChB,mBAAmB;CACnB,eAAe;CACf,WAAW;CACX,iBAAiB;CAGjB,UAAU;CACV,UAAU;CACV,KAAK;CACL,MAAM;CACN,aAAa;CACb,QAAQ;CAGR,cAAc;CACd,aAAa;CAGb,OAAO;CACP,gBAAgB;CAChB,cAAc;CAGd,UAAU;CACV,6BAA6B;CAC7B,SAAS;CACT,6BAA6B;CAC7B,6BAA6B;CAC7B,6BAA6B;CAC7B,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MACvB,MAAA,IAAwB,MACxB,MAAA,IAA+B"}
|
|
1
|
+
{"version":3,"file":"places-autocomplete.js","names":["#containerId","#pacEl","#googleMapsApiKey","#googleMapsApiVersion","#options","#defaultOptions","#defaultClasses","#onDataCallback","#onErrorCallback","#request","#defaultRequestParams","#debouncedMakeAcRequest","#inputElement","#cache","#ul","#ariaStatus","#fetchFields","#defaultFetchFields","#container","#kbdEscape","#kbdUp","#kbdDown","#allSuggestions","#currentSuggestion"],"sources":["../constants.js","../PlacesAutocomplete.js"],"sourcesContent":["export const ITINERARY_CATEGORIES = {\n // --- TRANSPORT & AUTO ---\n car_rental: \"Automotive\",\n car_dealer: \"Automotive\",\n gas_station: \"Automotive\",\n electric_vehicle_charging_station: \"Automotive\",\n parking: \"Automotive\",\n airport: \"Airport\",\n bus_station: \"Transport\",\n train_station: \"Train Station\",\n subway_station: \"Subway Station\",\n taxi_stand: \"Transport\",\n ferry_terminal: \"Transport\",\n\n // --- DINING & NIGHTLIFE ---\n restaurant: \"Food and Drink\",\n cafe: \"Food and Drink\",\n coffee_shop: \"Food and Drink\",\n bar: \"Food and Drink\",\n pub: \"Food and Drink\",\n night_club: \"Food and Drink\",\n bakery: \"Food and Drink\",\n fast_food_restaurant: \"Food and Drink\",\n ice_cream_shop: \"Food and Drink\",\n pizza_restaurant: \"Food and Drink\",\n steak_house: \"Food and Drink\",\n sushi_restaurant: \"Food and Drink\",\n\n // --- LODGING ---\n hotel: \"Lodging\",\n hostel: \"Lodging\",\n motel: \"Lodging\",\n resort_hotel: \"Lodging\",\n bed_and_breakfast: \"Lodging\",\n campground: \"Lodging\",\n rv_park: \"Lodging\",\n lodging: \"Lodging\",\n cottage: \"Lodging\",\n inn: \"Lodging\",\n guest_house: \"Lodging\",\n\n // --- SIGHTSEEING & CULTURE ---\n tourist_attraction: \"Sightseeing\",\n museum: \"Sightseeing\",\n art_gallery: \"Sightseeing\",\n cultural_landmark: \"Sightseeing\",\n historical_landmark: \"Sightseeing\",\n monument: \"Sightseeing\",\n performing_arts_theater: \"Sightseeing\",\n aquarium: \"Sightseeing\",\n zoo: \"Sightseeing\",\n visitor_center: \"Sightseeing\",\n town_square: \"Sightseeing\",\n landmark: \"Sightseeing\",\n place_of_worship: \"Sightseeing\",\n\n // --- RECREATION & PARKS ---\n park: \"Recreation\",\n national_park: \"Recreation\",\n state_park: \"Recreation\",\n beach: \"Recreation\",\n hiking_area: \"Recreation\",\n amusement_park: \"Recreation\",\n water_park: \"Recreation\",\n botanical_garden: \"Recreation\",\n golf_course: \"Recreation\",\n gym: \"Recreation\",\n natural_feature: \"Recreation\",\n\n // --- SHOPPING ---\n shopping_mall: \"Shopping\",\n supermarket: \"Shopping\",\n grocery_store: \"Shopping\",\n clothing_store: \"Shopping\",\n electronics_store: \"Shopping\",\n souvenir_shop: \"Shopping\",\n gift_shop: \"Shopping\",\n duty_free_store: \"Shopping\",\n\n // --- ESSENTIAL SERVICES ---\n hospital: \"Health\",\n pharmacy: \"Health\",\n atm: \"Finance\",\n bank: \"Finance\",\n post_office: \"Services\",\n police: \"Services\",\n\n // --- GEOGRAPHICAL ---\n neighborhood: \"Geographical\",\n sublocality: \"Geographical\",\n\n // --- NAVIGATION ---\n route: \"Navigation\",\n street_address: \"Navigation\",\n intersection: \"Navigation\",\n\n // -- CITY --\n locality: \"City\",\n administrative_area_level_4: \"City\",\n country: \"Country\",\n administrative_area_level_1: \"City\",\n administrative_area_level_2: \"City\",\n administrative_area_level_3: \"City\",\n administrative_area_level_5: \"City\",\n sublocality_level_1: \"Neighborhood\",\n sublocality_level_2: \"Neighborhood\",\n sublocality_level_3: \"Neighborhood\",\n sublocality_level_4: \"Neighborhood\",\n sublocality_level_5: \"Neighborhood\",\n\n // --- DEFAULT ---\n default: \"Default\",\n};\n\nexport const ITINERARY_SVG_ICONS = {\n Distance:\n '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-route-icon lucide-route\"><circle cx=\"6\" cy=\"19\" r=\"3\"/><path d=\"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15\"/><circle cx=\"18\" cy=\"5\" r=\"3\"/></svg>',\n\n Automotive: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2\"/><circle cx=\"7\" cy=\"17\" r=\"2\"/><path d=\"M9 17h6\"/><circle cx=\"17\" cy=\"17\" r=\"2\"/></svg>`,\n\n Transport: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z\"/></svg>`,\n\n \"Food and Drink\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2\"/><path d=\"M7 2v20\"/><path d=\"M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7\"/></svg>`,\n\n Lodging: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2 4v16\"/><path d=\"M2 8h18a2 2 0 0 1 2 2v10\"/><path d=\"M2 17h20\"/><path d=\"M6 8v9\"/></svg>`,\n\n Sightseeing: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-binoculars-icon lucide-binoculars\"><path d=\"M10 10h4\"/><path d=\"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3\"/><path d=\"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z\"/><path d=\"M 22 16 L 2 16\"/><path d=\"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z\"/><path d=\"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3\"/></svg>`,\n\n Recreation: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-kayak-icon lucide-kayak\"><path d=\"M18 17a1 1 0 0 0-1 1v1a2 2 0 1 0 2-2z\"/><path d=\"M20.97 3.61a.45.45 0 0 0-.58-.58C10.2 6.6 6.6 10.2 3.03 20.39a.45.45 0 0 0 .58.58C13.8 17.4 17.4 13.8 20.97 3.61\"/><path d=\"m6.707 6.707 10.586 10.586\"/><path d=\"M7 5a2 2 0 1 0-2 2h1a1 1 0 0 0 1-1z\"/></svg>`,\n\n Shopping: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z\"/><path d=\"M3 6h18\"/><path d=\"M16 10a4 4 0 0 1-8 0\"/></svg>`,\n\n Health: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 7v4\"/><path d=\"M14 21v-3a2 2 0 0 0-4 0v3\"/><path d=\"M14 9h-4\"/><path d=\"M18 11h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2\"/><path d=\"M18 21V5a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16\"/></svg>`,\n\n Finance: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect width=\"20\" height=\"14\" x=\"2\" y=\"5\" rx=\"2\"/><line x1=\"2\" y1=\"10\" x2=\"22\" y2=\"10\"/></svg>`,\n\n Geographical: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"m20 20-6-10.6c-.4-.7-1.5-.7-1.9 0L6 20\"/><path d=\"M7 16h10\"/><path d=\"M12 4a8 8 0 0 1 8 8v2a2 2 0 0 1-2 2h-1\"/><path d=\"M7 16H6a2 2 0 0 1-2-2v-2a8 8 0 0 1 8-8\"/></svg>`,\n\n Navigation: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-navigation-icon lucide-navigation\"><polygon points=\"3 11 22 2 13 21 11 13 3 11\"/></svg>`,\n\n City: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-building2-icon lucide-building-2\"><path d=\"M10 12h4\"/><path d=\"M10 8h4\"/><path d=\"M14 21v-3a2 2 0 0 0-4 0v3\"/><path d=\"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2\"/><path d=\"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16\"/></svg>`,\n\n District: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-land-plot-icon lucide-land-plot\"><path d=\"m12 8 6-3-6-3v10\"/><path d=\"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12\"/><path d=\"m6.49 12.85 11.02 6.3\"/><path d=\"M17.51 12.85 6.5 19.15\"/></svg>`,\n\n Airport: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-plane-icon lucide-plane\"><path d=\"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z\"/></svg>`,\n\n \"Subway Station\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-subway-icon lucide-subway\"><path d=\"M12 22a10 10 0 0 0 10-10V8l-5-5H7L2 8v4a10 10 0 0 0 10 10Z\"/><path d=\"M12 22V8\"/><path d=\"M7 13h10\"/><path d=\"M7 17h10\"/></svg>`,\n\n \"Train Station\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-train-icon lucide-train\"><path d=\"M2 10h20\"/><path d=\"M2 10a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5Z\"/><circle cx=\"7\" cy=\"15\" r=\"2\"/><circle cx=\"17\" cy=\"15\" r=\"2\"/></svg>`,\n\n Default: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z\"/><circle cx=\"12\" cy=\"10\" r=\"3\"/></svg>`,\n};\n","import \"./places-autocomplete.css\";\nimport { ITINERARY_CATEGORIES, ITINERARY_SVG_ICONS } from \"./constants.js\";\n\n/**\n * A flexible and customisable Places Autocomplete widget powered by the Google Maps Places API.\n *\n * Features:\n * - Dynamic Google Maps API loading\n * - Debounced input for optimized API requests\n * - Keyboard navigation (Arrow keys, Enter, Escape)\n * - Session token management for cost-effective API usage\n * - Customizable styling and behavior\n *\n * @author Alexander Pechkarev <alexpechkarev@gmail.com>\n * @license MIT\n */\nexport class PlacesAutocomplete {\n // --- Private Properties (using # or _ prefix by convention) ---\n #containerId; // Container ID where the autocomplete widget will be rendered.\n #pacEl;\n #googleMapsApiKey;\n #googleMapsApiVersion;\n #options;\n #request;\n #inputElement;\n #container;\n #ul;\n #ariaStatus; // For screen reader announcements\n #cache = new Map(); // Simple cache for suggestions\n #kbdEscape;\n #kbdUp;\n #kbdDown;\n #allSuggestions = [];\n #currentSuggestion = -1;\n #onDataCallback; // For user-provided data callback\n #onErrorCallback; // For user-provided error callback\n #debouncedMakeAcRequest; // Declare without initializing here\n #defaultOptions = {\n // Default options for the autocomplete widget.\n autofocus: false, // Automatically focus the input on load.\n autocomplete: \"off\", // HTML autocomplete attribute for the input.\n placeholder: \"Start typing your address ...\", // Placeholder text for the input.\n distance: false, // Show distance in suggestions (requires origin in request).\n distance_units: \"km\", // Units for distance ('km' or 'miles').\n label: \"\", // Optional label text above the input.\n debounce: 100, // Debounce delay (ms) for API requests.\n clear_input: false, // Clear input .\n debug: false, // Enable debug mode (not implemented in this version).\n response_type: \"json\", // Return format: 'json' for JSON object, 'place' for Google Maps Place instance.\n show_place_type: false, // Display place type icons (mutually exclusive with distance).\n };\n #defaultClasses = {\n // CSS classes for various parts of the widget.\n section: \"pac-section\", // Outer section container.\n container: \"pac-container\", // Main container div.\n icon_container: \"pac-icon-container\", // Container for the search icon.\n icon: '<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"pac-w-5 pac-h-5\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\" /><path d=\"m21 21-4.3-4.3\" /></svg>', // SVG for the search icon.\n input: \"pac-input\", // Input field.\n kbd_container: \"pac-kbd-container\", // Container for keyboard hints.\n kbd_escape: \"pac-kbd-escape\", // Escape key hint.\n kbd_up: \"pac-kbd-up\", // Up arrow key hint.\n kbd_down: \"pac-kbd-down\", // Down arrow key hint.\n kbd_active: \"pac-kbd-active\", // Class for active keyboard hint.\n ul: \"pac-ul\", // Suggestions list (ul).\n li: \"pac-li\", // Suggestion item (li).\n li_current: \"pac-li-current\", // Class for the currently selected suggestion item.\n li_button: \"pac-li-button\", // Link element within a suggestion item.\n li_button_current: \"pac-li-button-current\", // Class for the link in the currently selected suggestion item.\n li_div_container: \"pac-li-div-container\", // Container div within the suggestion link.\n li_div_p_container: \"pac-li-div-p-container\",\n li_div_one: \"pac-li-div-one\", // First inner div (for place name).\n li_div_one_p: \"pac-li-div-one-p\", // Paragraph for the place name.\n map_icon_svg: \"pac-map-icon-svg\",\n map_pin_icon:\n '<path d=\"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\"/><circle cx=\"12\" cy=\"10\" r=\"3\"/>',\n li_div_one_p_secondaryText: \"pac-li-div-one-p-secondaryText\",\n li_div_two: \"pac-li-div-two\", // Second inner div (for distance).\n li_div_two_p: \"pac-li-div-two-p\", // Paragraph for the distance.\n li_div_two_p_place_type: \"pac-li-div-two-p-place_type\", // Container for place type display.\n li_div_two_p_place_type_item: \"pac-li-div-two-p-place_type-item\", // Wrapper for individual options within the place type container.\n li_div_two_p_place_type_icon: \"pac-li-div-two-p-place_type-icon\", // The place type icon element.\n li_div_two_p_place_type_label: \"pac-li-div-two-p-place_type-label\", // The place type label text.\n highlight: \"pac-highlight\", // Class for highlighting matched text in suggestions.\n };\n #defaultRequestParams = {\n // Default parameters for the autocomplete request.\n input: \"\", // Initial input value (empty).\n includedRegionCodes: [\"GB\"], // Default region codes to include in suggestions.\n language: \"en-gb\",\n // region: \"GB\",\n };\n #fetchFields = [\"formattedAddress\", \"addressComponents\"];\n #defaultFetchFields = [\"formattedAddress\", \"addressComponents\"]; // Fields to fetch for the selected place (can be extended).\n\n /**\n * Class constructor for PacAutocomplete.\n * Initializes the autocomplete widget with the provided configuration.\n * @param {Object} config - Configuration object for the autocomplete widget.\n * @param {string} config.containerId - ID of the container element for the widget.\n * @param {string} config.googleMapsApiKey - Google Maps API key.\n * @param {string} [config.googleMapsApiVersion] - Version of the Google Maps API to use (default: \"weekly\").\n * @param {Object} [config.options] - Additional options for the widget (e.g., classes, callbacks).\n * @param {Object} [config.requestParams] - Parameters for the autocomplete request (e.g., input, region).\n * @param {*} config\n */\n constructor(config) {\n if (!config || !config.containerId || !config.googleMapsApiKey) {\n throw new Error(\n \"PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).\",\n );\n }\n\n this.#containerId = config.containerId; // Store the configuration object\n this.#pacEl = document.getElementById(config.containerId);\n if (!this.#pacEl) {\n throw new Error(\n `PacAutocomplete: Container element with ID \"${config.containerId}\" not found.`,\n );\n }\n\n this.#googleMapsApiKey = config.googleMapsApiKey;\n this.#googleMapsApiVersion = config.googleMapsApiVersion || \"weekly\";\n\n // Merge user options with defaults\n this.#options = {\n ...this.#defaultOptions, // Default options\n ...config.options, // User-defined options override defaults\n };\n // Ensure classes are deeply merged if user provides partial classes\n if (config.options && config.options.classes) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...config.options.classes,\n };\n } else {\n this.#options.classes = this.#defaultClasses; // Use default classes if none provided\n }\n\n if (this.#options.debug) {\n console.log(\"___debug constructor options:\");\n console.log(this.#options);\n }\n\n if (config.fetchFields && Array.isArray(config.fetchFields)) {\n this._setFetchFields(config.fetchFields); // Set fetch fields from user config\n }\n\n // Set default response and error callbacks if not provided\n this.#onDataCallback =\n config.onResponse ||\n ((place) => {\n console.info(\"---------Default onResponse not provided---------\");\n console.info(\"Selected Place:\", JSON.stringify(place, null, 2));\n });\n this.#onErrorCallback =\n config.onError ||\n ((error) => {\n console.error(\"---------Default onError not provided---------\");\n console.error(\"PAC Error:\", error);\n });\n\n if (config.requestParams && Object.keys(config.requestParams).length > 0) {\n this.#request = {\n ...this.#defaultRequestParams,\n ...config.requestParams,\n };\n } else {\n this.#request = { ...this.#defaultRequestParams }; // Use defaults if no requestParams provided\n }\n\n if (this.#options.debug) {\n console.log(\"___debug constructor requestParams:\", this.#request);\n }\n\n this._initialiseDebouncedRequest(); // Initialize the debounced request function\n\n this._init(); // Underscore prefix for internal initialization method\n }\n\n // --- Private Initialization Method ---\n async _init() {\n try {\n // check if google maps api is already loaded\n if (typeof google === \"undefined\" || !google.maps) {\n // Load the Google Maps API dynamically\n await this._loadGoogleMapsApi({\n key: this.#googleMapsApiKey,\n v: this.#googleMapsApiVersion,\n });\n }\n this._createPACStructure();\n await this._initializeAutocomplete();\n } catch (error) {\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Initializes the debounced request function for fetching autocomplete suggestions.\n * This function is called on initialization and when options are updated.\n *\n * @private\n */\n _initialiseDebouncedRequest() {\n this.#debouncedMakeAcRequest = this._debounce(async () => {\n const query = this.#inputElement?.value;\n if (!query) {\n this._reset();\n if (this.#inputElement)\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n return;\n }\n\n // Check cache\n if (this.#cache.has(query)) {\n await this._renderSuggestions(this.#cache.get(query));\n return;\n }\n\n this.#request.input = query;\n\n try {\n const { suggestions } =\n // eslint-disable-next-line no-undef\n await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(\n this.#request,\n );\n\n // Cache and display suggestions\n if (suggestions && suggestions.length > 0) {\n this.#cache.set(query, suggestions);\n await this._renderSuggestions(suggestions);\n } else {\n // No suggestions found\n this._reset(); // Clear any old suggestions\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this._announceStatus(\"No suggestions found.\");\n }\n } catch (error) {\n this.#onErrorCallback(error);\n this._reset();\n }\n }, this.#options.debounce); // Default debounce to 100ms if not set\n }\n\n /**\n * Renders the suggestions list.\n * @private\n */\n async _renderSuggestions(suggestions) {\n const suggestionElements = await Promise.all(\n this._createSuggestionElements(suggestions),\n );\n this.#ul.replaceChildren(...suggestionElements);\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n this._announceStatus(`${suggestions.length} suggestions found.`);\n }\n\n /**\n * Announces a message to screen readers using aria-live.\n * @private\n */\n _announceStatus(message) {\n if (this.#ariaStatus) {\n this.#ariaStatus.textContent = message;\n }\n }\n\n /**\n * Sets the fields to fetch for the selected place.\n * @param {Array<string>} fields - The fields to fetch.\n */\n _setFetchFields(fields) {\n if (Array.isArray(fields) && fields.length > 0) {\n this.#fetchFields = [\n ...new Set([...this.#defaultFetchFields, ...fields]),\n ].filter((e) => e); // Ensure unique and non-empty fields\n }\n }\n\n /**\n * Creates a debounced version of a function.\n *\n * @private\n * @param {Function} func - The function to debounce\n * @param {number} wait - Delay in milliseconds\n * @returns {Function} Debounced function\n */\n _debounce(func, wait) {\n let timeout = null;\n return function executedFunction(...args) {\n const later = () => {\n timeout = null;\n func(...args); // Call original function\n };\n if (timeout !== null) {\n clearTimeout(timeout); // Clear the previous timeout\n }\n timeout = setTimeout(later, wait ?? 100); // Set the new timeout\n };\n }\n /**\n * Formats a distance value from meters to the specified unit.\n *\n * @private\n * @param {number|null|undefined} distance - Distance in meters\n * @param {('km'|'miles')} units - Target unit for conversion\n * @returns {string|null} Formatted distance string or null if invalid\n */\n _formatDistance(distance, units) {\n if (!this.#options.distance) {\n return null;\n }\n if (typeof distance !== \"number\") {\n return null;\n }\n let value;\n let unitLabel;\n if (units === \"km\") {\n value = (distance / 1000).toFixed(2);\n unitLabel = \"km\";\n } else {\n // Default to miles if not 'km'\n value = (distance / 1609.34).toFixed(2);\n unitLabel = \"miles\";\n }\n // Avoid showing \".00\"\n value = value.replace(/\\.00$/, \"\");\n return `${value} ${unitLabel}`;\n }\n\n /**\n * Dynamically loads the Google Maps JavaScript API using the importLibrary method.\n * This is the standard approach recommended by Google.\n * @see https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n * @param {object} g - Configuration object for the API loader (key, v, libraries, etc.).\n */\n async _loadGoogleMapsApi(g) {\n var h, // Promise tracking API load\n a, // Script element\n k, // Loop variable for config keys\n p = \"The Google Maps JavaScript API\", // Error message prefix\n c = \"google\", // Global namespace\n l = \"importLibrary\", // Loader function name\n q = \"__ib__\", // Internal callback name\n m = document, // Document reference\n b = window; // Window reference\n b = b[c] || (b[c] = {}); // Ensure google namespace exists\n var d = b.maps || (b.maps = {}), // Ensure google.maps namespace exists\n r = new Set(), // Set to track requested libraries\n e = new URLSearchParams(), // URL parameters for the API script\n u = () =>\n // Function to initiate API loading (if not already started)\n h ||\n // eslint-disable-next-line no-async-promise-executor\n (h = new Promise(async (f, n) => {\n // Create script element (done async to potentially wait for nonce)\n // await (a = m.createElement('script')); // Original Google code had await here, might not be needed\n a = m.createElement(\"script\"); // Create script tag\n e.set(\"libraries\", [...r].join(\",\")); // Add accumulated libraries\n // Add other parameters from the config object 'g'\n for (k in g)\n e.set(\n k.replace(/[A-Z]/g, (t) => \"_\" + t[0].toLowerCase()), // Convert camelCase to snake_case\n g[k],\n );\n e.set(\"callback\", c + \".maps.\" + q); // Set the internal callback function name\n a.src = `https://maps.${c}apis.com/maps/api/js?` + e; // Construct the API URL\n d[q] = f; // Assign the promise resolver to the callback name on google.maps\n // Error handling for script loading failure\n a.onerror = () =>\n (h = n(\n new Error(\n `${p} could not load. Check your API key and network connection.`,\n ),\n )); // Use onerror for load failures\n // Nonce for Content Security Policy\n a.nonce = m.querySelector(\"script[nonce]\")?.nonce || \"\";\n m.head.append(a); // Append the script to the document head\n }));\n // Define or reuse the importLibrary function on google.maps\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n d[l]\n ? console.warn(p + \" only loads once. Ignoring:\", g) // Warn if called again\n : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n))); // The actual importLibrary implementation\n }\n\n // --- UI Creation ---\n _createPACStructure() {\n const section = document.createElement(\"section\");\n section.className = this.#options.classes.section;\n\n // Main container\n this.#container = document.createElement(\"div\");\n this.#container.className = this.#options.classes.container;\n this.#container.setAttribute(\"id\", this.#containerId + \"-div\");\n section.appendChild(this.#container);\n\n // Live region for a11y status updates\n this.#ariaStatus = document.createElement(\"div\");\n this.#ariaStatus.setAttribute(\"aria-live\", \"polite\");\n this.#ariaStatus.setAttribute(\"role\", \"status\");\n this.#ariaStatus.className = \"pac-sr-only\"; // Screen reader only\n this.#container.appendChild(this.#ariaStatus);\n\n // Icon\n const iconContainer = document.createElement(\"div\");\n iconContainer.className = this.#options.classes.icon_container;\n this.#container.appendChild(iconContainer);\n const icon = document.createElement(\"div\");\n icon.innerHTML = this.#options.classes.icon;\n iconContainer.appendChild(icon.firstElementChild); // Append the actual SVG element\n\n // Input field\n this.#inputElement = document.createElement(\"input\");\n this.#inputElement.id = this.#containerId + \"-input\"; // Assign ID for label association\n this.#inputElement.type = \"text\";\n this.#inputElement.name = \"search\"; // Consider making name configurable\n this.#inputElement.placeholder = this.#options.placeholder;\n this.#inputElement.autocomplete = this.#options.autocomplete;\n this.#inputElement.className = this.#options.classes.input;\n this.#inputElement.setAttribute(\"role\", \"combobox\");\n this.#inputElement.setAttribute(\"aria-autocomplete\", \"list\");\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\"); // Will be updated dynamically\n this.#inputElement.setAttribute(\"aria-controls\", \"pacSuggestions\"); // Links to the suggestions list\n this.#inputElement.setAttribute(\"aria-activedescendant\", \"\"); // Will be updated dynamically\n\n if (this.#options.autofocus) {\n this.#inputElement.autofocus = true;\n }\n if (this.#options.label) {\n const label = document.createElement(\"label\");\n label.htmlFor = this.#inputElement.id; // Correctly link label to input by ID\n label.textContent = this.#options.label;\n // Add label classes if needed from opts.classes\n section.prepend(label); // Append label before input or adjust structure\n }\n this.#container.appendChild(this.#inputElement);\n\n // Keyboard hints container\n const kbdContainer = document.createElement(\"div\");\n kbdContainer.className = this.#options.classes.kbd_container;\n this.#kbdEscape = document.createElement(\"kbd\");\n this.#kbdEscape.className = this.#options.classes.kbd_escape;\n this.#kbdEscape.textContent = \"Esc\";\n kbdContainer.appendChild(this.#kbdEscape);\n this.#kbdUp = document.createElement(\"kbd\");\n this.#kbdUp.className = this.#options.classes.kbd_up;\n this.#kbdUp.innerHTML = \"↑\"; // Up arrow HTML entity\n kbdContainer.appendChild(this.#kbdUp);\n this.#kbdDown = document.createElement(\"kbd\");\n this.#kbdDown.className = this.#options.classes.kbd_down;\n this.#kbdDown.innerHTML = \"↓\"; // Down arrow HTML entity\n kbdContainer.appendChild(this.#kbdDown);\n this.#container.appendChild(kbdContainer);\n\n // Suggestions list (initially hidden)\n this.#ul = document.createElement(\"ul\");\n this.#ul.id = \"pacSuggestions\"; // Must match aria-controls\n this.#ul.className = this.#options.classes.ul;\n this.#ul.style.display = \"none\";\n this.#ul.setAttribute(\"role\", \"listbox\");\n this.#ul.setAttribute(\"aria-labelledby\", this.#inputElement.id); // Link listbox to input for accessibility\n this.#container.appendChild(this.#ul);\n\n // Event Delegation for suggestion selection\n this.#ul.addEventListener(\"click\", (e) => {\n const li = e.target.closest(\"li\");\n if (li && this.#ul.contains(li)) {\n const index = Array.from(this.#ul.children).indexOf(li);\n if (index !== -1 && this.#allSuggestions[index]) {\n this._onPlaceSelected(this.#allSuggestions[index].place);\n }\n }\n });\n\n this.#pacEl.appendChild(section);\n section.addEventListener(\"keydown\", this._onKeyDown.bind(this)); // Bind 'this'\n }\n\n /**\n * Attaches event listeners to the input element for handling user input.\n * This includes debounced input handling, focus/blur events, and keyboard navigation.\n */\n _attachedEventListeners() {\n this.#inputElement.addEventListener(\"input\", this.#debouncedMakeAcRequest);\n // Add focus/blur listeners if needed to manage suggestion visibility\n this.#inputElement.addEventListener(\"blur\", () => {\n // Delay hiding suggestions to allow click events on them\n setTimeout(() => {\n if (this.#ul && !this.#ul.contains(document.activeElement)) {\n // Check if focus moved outside suggestions\n this.#ul.style.display = \"none\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, 200); // Adjust delay as needed\n });\n this.#inputElement.addEventListener(\"focus\", () => {\n // Potentially show suggestions again if input has value\n if (this.#inputElement.value && this.#allSuggestions.length > 0) {\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n }\n });\n }\n\n _detachEventListeners() {\n // Remove event listeners, remove elements from DOM\n if (this.#inputElement) {\n this.#inputElement.removeEventListener(\n \"input\",\n this.#debouncedMakeAcRequest,\n );\n // remove other listeners\n }\n if (this.#pacEl && this.#container) {\n this.#pacEl.removeChild(this.#container.parentElement); // remove the whole section\n }\n }\n\n /**\n * Initializes the core autocomplete functionality after the API is loaded.\n * Imports necessary libraries and sets up the input event listener.\n */\n async _initializeAutocomplete() {\n try {\n // Ensure the 'places' library is available via the dynamic loader\n // eslint-disable-next-line no-undef\n await google.maps.importLibrary(\"places\");\n // console.log('Places library imported successfully.'); // For debugging\n\n // Initial token generation\n this._refreshToken();\n\n // Attach the debounced request function to the input element's 'input' event\n if (this.#inputElement) {\n this._attachedEventListeners();\n } else {\n this.#onErrorCallback(\n new Error(\"Input element not found during initialization.\"),\n );\n }\n } catch (error) {\n console.error(\"Error initializing Google Places Autocomplete:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(\n new Error(\"Google Maps Places library not available.\"),\n );\n }\n }\n\n /**\n * Resets the autocomplete input field, clears suggestions, and optionally refreshes the session token.\n * @param {boolean} [refresh=false] - Whether to refresh the Google Places session token.\n */\n _reset(refresh = false, placeData = null) {\n this.#currentSuggestion = -1;\n\n /**\n * If the input element exists and clear_input is false, set its value to the formatted address\n * from placeData. Otherwise, clear the input value.\n * This allows the user to keep the input value if they selected a place,\n * but still allows clearing it if clear_input is true or placeData is not provided.\n * @type {HTMLInputElement}\n * @property {string} value - The value of the input element.\n * @property {boolean} clear_input - Whether to clear the input value after selection.\n * @property {Object} placeData - The data of the selected place, containing formattedAddress.\n */\n if (\n this.#inputElement &&\n this.#options.clear_input == false &&\n placeData &&\n placeData.formattedAddress\n ) {\n this.#inputElement.value = placeData.formattedAddress; // Set input value to formatted address\n } else if (this.#inputElement) {\n this.#inputElement.value = \"\";\n }\n\n if (this.#inputElement) {\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this.#inputElement.setAttribute(\"aria-activedescendant\", \"\"); // Clear aria-activedescendant\n this.#inputElement.blur();\n }\n\n this.#allSuggestions = [];\n this.#currentSuggestion = -1;\n if (this.#ul) {\n this.#ul.innerHTML = \"\"; // Clear existing suggestions\n this.#ul.style.display = \"none\";\n }\n if (refresh) {\n this._refreshToken();\n }\n }\n /**\n * Removes the 'current' highlighting classes from all suggestion list items (li) and their links (a).\n */\n _resetLiClasses() {\n if (!this.#ul) return;\n Array.from(this.#ul.children).forEach((li) => {\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => li.classList.remove(cl));\n const link = li.querySelector(\"button\");\n if (link) {\n this.#options.classes.li_button_current\n .split(\" \")\n .forEach((cl) => link.classList.remove(cl));\n }\n });\n }\n\n /**\n * Handles keyboard events (ArrowDown, ArrowUp, Enter, Escape) for navigating\n * and selecting suggestions or closing the list.\n * @param {KeyboardEvent} e - The keyboard event object.\n */\n _onKeyDown(e) {\n this._resetLiClasses(); // Reset classes on any key press within the suggestions\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.remove(cl)),\n 300,\n );\n\n this._reset(true); // Reset search input and results, refresh token\n }\n\n if (\n !this.#allSuggestions.length ||\n !this.#ul ||\n this.#ul.style.display === \"none\"\n )\n return;\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.min(\n this.#currentSuggestion + 1,\n this.#allSuggestions.length - 1,\n );\n this._highlightSuggestion();\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.max(this.#currentSuggestion - 1, 0); // Stay at 0 if already there\n this._highlightSuggestion();\n } else if (e.key === \"Home\") {\n e.preventDefault();\n this.#currentSuggestion = 0;\n this._highlightSuggestion();\n } else if (e.key === \"End\") {\n e.preventDefault();\n this.#currentSuggestion = this.#allSuggestions.length - 1;\n this._highlightSuggestion();\n } else if (e.key === \"Enter\") {\n e.preventDefault(); // Prevent form submission if applicable\n if (\n this.#currentSuggestion >= 0 &&\n this.#currentSuggestion < this.#allSuggestions.length\n ) {\n this._onPlaceSelected(\n this.#allSuggestions[this.#currentSuggestion].place,\n );\n // Reset is handled within onPlaceSelected via reset(true)\n }\n }\n }\n\n /**\n * Highlights the current suggestion in the UI.\n * @private\n */\n _highlightSuggestion() {\n if (this.#currentSuggestion < 0) return;\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentButton = currentLi.querySelector(\"button\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentButton) {\n this.#options.classes.li_button_current\n .split(\" \")\n .forEach((cl) => currentButton.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n this.#inputElement.setAttribute(\"aria-activedescendant\", currentLi.id); // Update aria-activedescendant\n\n // Visual feedback for key press\n const kbd =\n this.#currentSuggestion === 0\n ? this.#kbdUp\n : this.#kbdDown;\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => kbd?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => kbd?.classList.remove(cl)),\n 300,\n );\n }\n }\n\n // Helper function to find a specific address component\n _getAddressComponent(response, type) {\n return (\n response.addressComponents?.find((c) => c.types.includes(type))\n ?.longText || \"\"\n );\n }\n\n /**\n * Creates a button element for a suggestion item.\n * @returns {HTMLButtonElement} The created button element.\n */\n _createButtonElement(index) {\n const button = document.createElement(\"button\");\n button.tabIndex = index + 1;\n button.className = this.#options.classes.li_button; // block w-full flex justify-between\n return button;\n }\n\n /**\n * Creates a div container for suggestion item.\n * @returns {HTMLDivElement} The created div container element.\n */\n _createDivElement(className) {\n // create div elements pac-li-div-container\n const divContainer = document.createElement(\"div\");\n if (className) {\n divContainer.className = className;\n }\n return divContainer;\n }\n\n /**\n * Creates an SVG element representing a map pin icon.\n * @returns {SVGSVGElement} The created SVG element.\n */\n _createMapPinIconElement() {\n const svgIcon = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"svg\",\n );\n svgIcon.setAttribute(\"xmlns\", \"http://www.w3.org/2000/svg\");\n svgIcon.setAttribute(\"width\", \"24\");\n svgIcon.setAttribute(\"height\", \"24\");\n svgIcon.setAttribute(\"viewBox\", \"0 0 24 24\");\n svgIcon.setAttribute(\"fill\", \"none\");\n svgIcon.setAttribute(\"stroke\", \"currentColor\");\n svgIcon.setAttribute(\"stroke-width\", \"2\");\n svgIcon.setAttribute(\"stroke-linecap\", \"round\");\n svgIcon.setAttribute(\"stroke-linejoin\", \"round\");\n svgIcon.setAttribute(\"class\", this.#options.classes.map_icon_svg);\n // insert map pin icon path\n svgIcon.innerHTML = this.#options.classes.map_pin_icon;\n return svgIcon;\n }\n\n /**\n * Creates a paragraph (P) element with an optional class name.\n * @param {string} className\n * @returns {HTMLParagraphElement}\n */\n _createPElement(className) {\n const p = document.createElement(\"p\");\n if (className) {\n p.className = className;\n }\n return p;\n }\n /**\n * Creates an array of list item (LI) elements for the suggestions dropdown.\n * Each LI contains a link (A) with the place prediction details and distance.\n * Handles highlighting the matched parts of the suggestion text.\n * @param {Array<google.maps.places.AutocompleteSuggestion>} suggestions - Array of suggestion objects from the API.\n * @returns {Array<HTMLLIElement>} An array of LI elements to be added to the suggestions UL.\n */\n _createSuggestionElements(suggestions) {\n this.#allSuggestions = []; // Reset before populating\n // Map suggestions to LI elements\n return suggestions.map(async (suggestion, index) => {\n // Fetch place details for each suggestion\n let place = suggestion.placePrediction.toPlace();\n\n const li = document.createElement(\"li\");\n li.id = `option-${index + 1}`;\n li.className = this.#options.classes.li;\n li.setAttribute(\"role\", \"option\");\n\n // create button element\n const button = this._createButtonElement(index);\n\n // create div elements pac-li-div-container\n const divContainer = this._createDivElement(\n this.#options.classes.li_div_container,\n );\n\n // create li div one element - place name\n const liDivOne = this._createDivElement(this.#options.classes.li_div_one);\n const liDivTwo = this._createDivElement(this.#options.classes.li_div_two);\n // create map pin icon element\n const mapPinIcon = this._createMapPinIconElement();\n // append map pin icon to liDivOne\n liDivOne.appendChild(mapPinIcon);\n\n // create div p container\n const divPContainer = this._createDivElement(\n this.#options.classes.li_div_p_container,\n );\n // append div p container to liDivOne\n liDivOne.appendChild(divPContainer);\n\n // create p element - place name\n const pOne = this._createPElement(this.#options.classes.li_div_one_p);\n // create p element - secondary text\n const pTwo = this._createPElement(\n this.#options.classes.li_div_one_p_secondaryText,\n );\n // create p element - distance\n // Try to get distanceMeters from placePrediction or directly from suggestion\n const distanceMeters =\n suggestion.placePrediction?.distanceMeters ?? suggestion.distanceMeters;\n const distanceValue = this._formatDistance(\n distanceMeters,\n this.#options.distance_units ?? \"km\",\n );\n\n // append p element to div p container\n divPContainer.appendChild(pOne);\n divPContainer.appendChild(pTwo);\n\n // Add place type display and/or distance if enabled\n this._renderSuggestionMeta(liDivTwo, suggestion, distanceValue);\n\n // append liDivOne to divContainer\n divContainer.appendChild(liDivOne);\n divContainer.appendChild(liDivTwo);\n // append divContainer to button\n button.appendChild(divContainer);\n // append button to li\n li.appendChild(button);\n\n this._renderHighlightText(pOne, suggestion.placePrediction.mainText);\n\n // set secondary text if available\n const secondaryText =\n suggestion.placePrediction?.secondaryText?.text ?? \"\";\n\n if (secondaryText) {\n pTwo.textContent = secondaryText;\n }\n\n this.#allSuggestions.push({\n id: index + 1,\n place: place,\n mainText: suggestion.placePrediction.mainText.text,\n secondaryText: secondaryText,\n description: suggestion.placePrediction.toString(),\n });\n\n return li;\n });\n }\n\n /**\n * Renders meta information (place type, distance) for a suggestion.\n * @private\n */\n _renderSuggestionMeta(container, suggestion, distanceValue) {\n if (this.#options.show_place_type || this.#options.distance) {\n const metaContainer = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type,\n );\n\n // Place Type display\n if (\n this.#options.show_place_type &&\n Array.isArray(suggestion.placePrediction?.types) &&\n suggestion.placePrediction.types.length > 0\n ) {\n const placeTypeWrapper = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type_item,\n );\n\n const placeTypeIcon = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_icon,\n );\n\n const placeTypeLabel = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_label,\n );\n\n // Look through the array until we find a type we actually recognize\n const matchedType = suggestion.placePrediction.types.find(\n (type) => typeof type === \"string\" && type in ITINERARY_CATEGORIES,\n );\n\n placeTypeLabel.textContent = matchedType\n ? ITINERARY_CATEGORIES[matchedType]\n : \"Default\";\n\n placeTypeIcon.innerHTML =\n ITINERARY_SVG_ICONS[placeTypeLabel.textContent] ||\n ITINERARY_SVG_ICONS[\"Default\"];\n\n placeTypeWrapper.appendChild(placeTypeIcon);\n placeTypeWrapper.appendChild(placeTypeLabel);\n metaContainer.appendChild(placeTypeWrapper);\n }\n\n // Distance display\n if (this.#options.distance) {\n const distanceWrapper = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type_item,\n );\n\n const distanceIcon = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_icon,\n );\n distanceIcon.innerHTML = ITINERARY_SVG_ICONS[\"Distance\"];\n\n const pThree = this._createPElement(this.#options.classes.li_div_two_p);\n pThree.textContent = distanceValue ?? \"-\";\n\n distanceWrapper.appendChild(distanceIcon);\n distanceWrapper.appendChild(pThree);\n metaContainer.appendChild(distanceWrapper);\n }\n\n if (metaContainer.hasChildNodes()) {\n container.appendChild(metaContainer);\n }\n }\n }\n\n /**\n * Renders highlighted text for a suggestion.\n * @private\n */\n _renderHighlightText(element, predictionText) {\n const originalText = predictionText.text;\n const matches = predictionText.matches;\n let lastIndex = 0;\n\n matches.sort((a, b) => a.startOffset - b.startOffset);\n\n const outerSpan = document.createElement(\"span\");\n const innerSpan = document.createElement(\"span\");\n innerSpan.classList = this.#options.classes.highlight ?? \"font-bold\";\n\n for (const match of matches) {\n outerSpan.textContent += originalText.substring(\n lastIndex,\n match.startOffset,\n );\n if (match.startOffset > 0) {\n const prevChar = originalText.charAt(match.startOffset - 1);\n if (prevChar === \" \") {\n innerSpan.textContent += \" \";\n }\n }\n innerSpan.textContent += originalText.substring(\n match.startOffset,\n match.endOffset,\n );\n lastIndex = match.endOffset;\n }\n\n outerSpan.appendChild(innerSpan);\n outerSpan.appendChild(\n document.createTextNode(originalText.substring(lastIndex)),\n );\n element.appendChild(outerSpan);\n }\n\n /**\n * Handles the selection of a place. Fetches required fields\n * (displayName, formattedAddress, addressComponents) and calls the\n * user-defined `onPacData` callback.\n * @param {google.maps.places.Place} place - The selected Place object.\n */\n async _onPlaceSelected(place) {\n let data = null;\n try {\n // Fetch necessary details for the selected place\n await place.fetchFields({\n fields: this.#fetchFields, //[\"displayName\", \"formattedAddress\", \"addressComponents\"], // Add more fields as needed\n });\n // Call the user-provided callback with the place data\n // Handle response_type option\n if (this.#options.response_type === \"place\") {\n data = place; // Return the Place instance\n this.#onDataCallback(place);\n } else {\n // eslint-disable-next-line no-undef\n data = place.toJSON(); // Convert to plain JSON object (default)\n this.#onDataCallback(data);\n }\n } catch (error) {\n console.error(\"Error fetching place details:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n } finally {\n // Reset the input and suggestions regardless of success/error\n this._reset(true, data); // Refresh token after selection\n }\n }\n\n /**\n * Creates a new Google Places Autocomplete Session Token.\n * This should be called before starting a new series of autocomplete requests.\n */\n _refreshToken() {\n try {\n // eslint-disable-next-line no-undef\n this.#request.sessionToken =\n new google.maps.places.AutocompleteSessionToken();\n } catch (error) {\n console.error(\"Error creating session token:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to be fetched for the selected place.\n * This allows you to specify which details you want to retrieve\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @param {Array<string>} fields - Array of field names to fetch.\n */\n setFetchFields(fields) {\n this._setFetchFields(fields);\n }\n /**\n * Gets the current fields that will be fetched for the selected place.\n * This is useful for understanding what details will be available\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @returns {Array<string>} The current fetch fields.\n */\n getFetchFields() {\n return this.#fetchFields;\n }\n\n /**\n * Sets the request parameters for the Places Autocomplete instance.\n * This method allows you to update the request parameters dynamically,\n * such as the input value, region codes, language, etc.\n * It merges the provided parameters with the default request parameters,\n * allowing you to override specific values while keeping the defaults intact.\n * This is useful for updating the search criteria without needing to recreate the instance.\n * @param {*} params\n */\n setRequestParams(params) {\n if (\n typeof params === \"object\" &&\n !Array.isArray(params) &&\n params !== null\n ) {\n // if params.input is provided, set it to the input element\n if (params.input && typeof params.input === \"string\") {\n this.#inputElement.value = params.input; // Set input value if provided\n }\n // Merge provided params with default request parameters\n // This allows overriding specific request parameters while keeping defaults\n this.#request = {\n ...this.#defaultRequestParams,\n ...params,\n };\n }\n }\n\n /**\n * Returns the current request parameters used by the Places Autocomplete instance.\n * This includes the input value, included region codes, language, and other settings.\n * It is useful for debugging or when you need to know the current search criteria.\n * @returns {Object} The current request parameters.\n */\n getRequestParams() {\n return this.#request;\n }\n\n /**\n * Sets the options for the Places Autocomplete instance.\n * This method allows you to change the appearance and behavior of the autocomplete widget,\n * such as classes, placeholder text, debounce time, etc.\n * It merges the provided options with the default options, allowing you to override specific values\n * while keeping the defaults intact.\n * This is useful for updating the widget's configuration without needing to recreate the instance.\n * @param {*} options\n */\n setOptions(options) {\n if (\n typeof options === \"object\" &&\n !Array.isArray(options) &&\n options !== null\n ) {\n this._detachEventListeners(); // Detach event listeners\n\n // // Ensure classes are deeply merged if user provides partial classes\n const tmpClasses = options.classes || {};\n delete options.classes; // Remove classes from options to avoid overwriting\n\n // Merge provided options with default options\n // This allows overriding specific options while keeping defaults\n this.#options = {\n ...this.#defaultOptions,\n ...options,\n };\n\n // Merge classes with defaults\n // This allows overriding specific classes while keeping defaults\n if (\n tmpClasses &&\n typeof tmpClasses === \"object\" &&\n Object.keys(tmpClasses).length > 0\n ) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...tmpClasses,\n };\n } else {\n this.#options.classes = { ...this.#defaultClasses }; // Use defaults if no classes provided\n }\n\n this._initialiseDebouncedRequest(); // Reinitialize the debounced request function\n this._createPACStructure(); // Recreate the structure with new options\n // Reattach the input event listener to the input element\n // This is necessary to ensure the new input element is ready for events\n if (this.#inputElement) {\n this._attachedEventListeners();\n } // Reinitialize the autocomplete functionality\n }\n }\n\n /**\n * Gets the current options used by the Places Autocomplete instance.\n * @returns {Object} The current options.\n */\n getOptions() {\n /**\n * Returns the current options used by the Places Autocomplete instance.\n * This includes classes, placeholder text, debounce time, and other settings.\n * It is useful for debugging or when you need to know the current configuration of the widget.\n * @returns {Object} The current options.\n */\n return this.#options;\n }\n\n /**\n * Sets the input value by reverse geocoding coordinates.\n * Performs reverse geocoding to convert lat/lng to a place, then triggers onResponse.\n * Requires the Geocoding API to be enabled in your Google Cloud Console project.\n * @param {number} latitude - Latitude coordinate\n * @param {number} longitude - Longitude coordinate\n * @returns {Promise<void>}\n */\n async setInputValue(latitude, longitude) {\n try {\n // Import the geocoding library\n const { Geocoder } = await google.maps.importLibrary(\"geocoding\");\n const geocoder = new Geocoder();\n\n // Perform reverse geocoding\n const response = await geocoder.geocode({\n location: { lat: latitude, lng: longitude },\n });\n\n if (response.results && response.results.length > 0) {\n const placeId = response.results[0].place_id;\n const place = new google.maps.places.Place({ id: placeId });\n\n // Fetch the configured fields\n await place.fetchFields({ fields: this.#fetchFields });\n\n // Update input field if clear_input is false\n if (!this.#options.clear_input && place.formattedAddress) {\n this.#inputElement.value = place.formattedAddress;\n }\n\n // Trigger the callback with appropriate response type\n if (this.#options.response_type === \"place\") {\n this.#onDataCallback(place);\n } else {\n this.#onDataCallback(place.toJSON());\n }\n } else {\n throw new Error(\"No results found for the provided coordinates\");\n }\n } catch (error) {\n console.error(\"Error in setInputValue:\", error);\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Clears the autocomplete input field and suggestions list.\n * This method resets the state of the autocomplete widget,\n * allowing the user to start a new search without any previous input or suggestions.\n * It also refreshes the Google Places session token to ensure a new session.\n * @returns {void}\n */\n clear() {\n this.#cache.clear();\n this._reset(true);\n }\n\n /**\n * Sets focus on the autocomplete input field.\n * This method allows programmatic control of the input focus,\n * useful for improving user experience and accessibility.\n * @returns {void}\n */\n focus() {\n if (this.#inputElement) {\n this.#inputElement.focus();\n }\n }\n\n /**\n * Destroys the PacAutocomplete instance.\n * Removes event listeners, clears the DOM, and nullifies properties.\n * This method should be called when the autocomplete widget is no longer needed.\n * It ensures that all resources are cleaned up to prevent memory leaks.\n * @returns {void}\n */\n destroy() {\n // Remove event listeners, remove elements from DOM\n this._detachEventListeners(); // Detach event listeners\n // Nullify properties\n this.#containerId = null;\n this.#pacEl = null;\n this.#googleMapsApiKey = null;\n this.#googleMapsApiVersion = null;\n this.#options = null;\n this.#request = null;\n this.#inputElement = null;\n this.#container = null;\n this.#ul = null;\n this.#ariaStatus = null;\n this.#cache = null;\n this.#kbdEscape = null;\n this.#kbdUp = null;\n this.#kbdDown = null;\n this.#allSuggestions = null;\n this.#currentSuggestion = -1;\n this.#onDataCallback = null;\n this.#onErrorCallback = null;\n this.#debouncedMakeAcRequest = null;\n }\n}\n"],"mappings":";AAAA,IAAa,IAAuB;CAElC,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,mCAAmC;CACnC,SAAS;CACT,SAAS;CACT,aAAa;CACb,eAAe;CACf,gBAAgB;CAChB,YAAY;CACZ,gBAAgB;CAGhB,YAAY;CACZ,MAAM;CACN,aAAa;CACb,KAAK;CACL,KAAK;CACL,YAAY;CACZ,QAAQ;CACR,sBAAsB;CACtB,gBAAgB;CAChB,kBAAkB;CAClB,aAAa;CACb,kBAAkB;CAGlB,OAAO;CACP,QAAQ;CACR,OAAO;CACP,cAAc;CACd,mBAAmB;CACnB,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS;CACT,KAAK;CACL,aAAa;CAGb,oBAAoB;CACpB,QAAQ;CACR,aAAa;CACb,mBAAmB;CACnB,qBAAqB;CACrB,UAAU;CACV,yBAAyB;CACzB,UAAU;CACV,KAAK;CACL,gBAAgB;CAChB,aAAa;CACb,UAAU;CACV,kBAAkB;CAGlB,MAAM;CACN,eAAe;CACf,YAAY;CACZ,OAAO;CACP,aAAa;CACb,gBAAgB;CAChB,YAAY;CACZ,kBAAkB;CAClB,aAAa;CACb,KAAK;CACL,iBAAiB;CAGjB,eAAe;CACf,aAAa;CACb,eAAe;CACf,gBAAgB;CAChB,mBAAmB;CACnB,eAAe;CACf,WAAW;CACX,iBAAiB;CAGjB,UAAU;CACV,UAAU;CACV,KAAK;CACL,MAAM;CACN,aAAa;CACb,QAAQ;CAGR,cAAc;CACd,aAAa;CAGb,OAAO;CACP,gBAAgB;CAChB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AA,IAAqB,MACrB,MAAA,IAAkB,MAClB,MAAA,IAAW,MACX,MAAA,IAAmB,MACnB,MAAA,IAAc,MACd,MAAA,IAAkB,MAClB,MAAA,IAAc,MACd,MAAA,IAAgB,MAChB,MAAA,IAAuB,MACvB,MAAA,IAA0B,IAC1B,MAAA,IAAuB,MACvB,MAAA,IAAwB,MACxB,MAAA,IAA+B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.PlacesAutocomplete={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t={car_rental:`Automotive`,car_dealer:`Automotive`,gas_station:`Automotive`,electric_vehicle_charging_station:`Automotive`,parking:`Automotive`,airport:`Airport`,bus_station:`Transport`,train_station:`Train Station`,subway_station:`Subway Station`,taxi_stand:`Transport`,ferry_terminal:`Transport`,restaurant:`Food and Drink`,cafe:`Food and Drink`,coffee_shop:`Food and Drink`,bar:`Food and Drink`,pub:`Food and Drink`,night_club:`Food and Drink`,bakery:`Food and Drink`,fast_food_restaurant:`Food and Drink`,ice_cream_shop:`Food and Drink`,pizza_restaurant:`Food and Drink`,steak_house:`Food and Drink`,sushi_restaurant:`Food and Drink`,hotel:`Lodging`,hostel:`Lodging`,motel:`Lodging`,resort_hotel:`Lodging`,bed_and_breakfast:`Lodging`,campground:`Lodging`,rv_park:`Lodging`,lodging:`Lodging`,cottage:`Lodging`,inn:`Lodging`,guest_house:`Lodging`,tourist_attraction:`Sightseeing`,museum:`Sightseeing`,art_gallery:`Sightseeing`,cultural_landmark:`Sightseeing`,historical_landmark:`Sightseeing`,monument:`Sightseeing`,performing_arts_theater:`Sightseeing`,aquarium:`Sightseeing`,zoo:`Sightseeing`,visitor_center:`Sightseeing`,town_square:`Sightseeing`,landmark:`Sightseeing`,place_of_worship:`Sightseeing`,park:`Recreation`,national_park:`Recreation`,state_park:`Recreation`,beach:`Recreation`,hiking_area:`Recreation`,amusement_park:`Recreation`,water_park:`Recreation`,botanical_garden:`Recreation`,golf_course:`Recreation`,gym:`Recreation`,natural_feature:`Recreation`,shopping_mall:`Shopping`,supermarket:`Shopping`,grocery_store:`Shopping`,clothing_store:`Shopping`,electronics_store:`Shopping`,souvenir_shop:`Shopping`,gift_shop:`Shopping`,duty_free_store:`Shopping`,hospital:`Health`,pharmacy:`Health`,atm:`Finance`,bank:`Finance`,post_office:`Services`,police:`Services`,neighborhood:`Geographical`,sublocality:`Geographical`,route:`Navigation`,street_address:`Navigation`,intersection:`Navigation`,locality:`City`,administrative_area_level_4:`City`,country:`Country`,administrative_area_level_1:`City`,administrative_area_level_2:`City`,administrative_area_level_3:`City`,administrative_area_level_5:`City`,sublocality_level_1:`Neighborhood`,sublocality_level_2:`Neighborhood`,sublocality_level_3:`Neighborhood`,sublocality_level_4:`Neighborhood`,sublocality_level_5:`Neighborhood`,default:`Default`},n={Automotive:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2"/><circle cx="7" cy="17" r="2"/><path d="M9 17h6"/><circle cx="17" cy="17" r="2"/></svg>`,Transport:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z"/></svg>`,"Food and Drink":`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2"/><path d="M7 2v20"/><path d="M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7"/></svg>`,Lodging:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 4v16"/><path d="M2 8h18a2 2 0 0 1 2 2v10"/><path d="M2 17h20"/><path d="M6 8v9"/></svg>`,Sightseeing:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-binoculars-icon lucide-binoculars"><path d="M10 10h4"/><path d="M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3"/><path d="M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z"/><path d="M 22 16 L 2 16"/><path d="M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z"/><path d="M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3"/></svg>`,Recreation:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-kayak-icon lucide-kayak"><path d="M18 17a1 1 0 0 0-1 1v1a2 2 0 1 0 2-2z"/><path d="M20.97 3.61a.45.45 0 0 0-.58-.58C10.2 6.6 6.6 10.2 3.03 20.39a.45.45 0 0 0 .58.58C13.8 17.4 17.4 13.8 20.97 3.61"/><path d="m6.707 6.707 10.586 10.586"/><path d="M7 5a2 2 0 1 0-2 2h1a1 1 0 0 0 1-1z"/></svg>`,Shopping:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"/><path d="M3 6h18"/><path d="M16 10a4 4 0 0 1-8 0"/></svg>`,Health:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 7v4"/><path d="M14 21v-3a2 2 0 0 0-4 0v3"/><path d="M14 9h-4"/><path d="M18 11h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2"/><path d="M18 21V5a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16"/></svg>`,Finance:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" y1="10" x2="22" y2="10"/></svg>`,Geographical:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m20 20-6-10.6c-.4-.7-1.5-.7-1.9 0L6 20"/><path d="M7 16h10"/><path d="M12 4a8 8 0 0 1 8 8v2a2 2 0 0 1-2 2h-1"/><path d="M7 16H6a2 2 0 0 1-2-2v-2a8 8 0 0 1 8-8"/></svg>`,Navigation:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-navigation-icon lucide-navigation"><polygon points="3 11 22 2 13 21 11 13 3 11"/></svg>`,City:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-building2-icon lucide-building-2"><path d="M10 12h4"/><path d="M10 8h4"/><path d="M14 21v-3a2 2 0 0 0-4 0v3"/><path d="M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2"/><path d="M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16"/></svg>`,District:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-land-plot-icon lucide-land-plot"><path d="m12 8 6-3-6-3v10"/><path d="m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12"/><path d="m6.49 12.85 11.02 6.3"/><path d="M17.51 12.85 6.5 19.15"/></svg>`,Airport:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plane-icon lucide-plane"><path d="M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z"/></svg>`,"Subway Station":`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-subway-icon lucide-subway"><path d="M12 22a10 10 0 0 0 10-10V8l-5-5H7L2 8v4a10 10 0 0 0 10 10Z"/><path d="M12 22V8"/><path d="M7 13h10"/><path d="M7 17h10"/></svg>`,"Train Station":`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-train-icon lucide-train"><path d="M2 10h20"/><path d="M2 10a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5Z"/><circle cx="7" cy="15" r="2"/><circle cx="17" cy="15" r="2"/></svg>`,Default:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"/><circle cx="12" cy="10" r="3"/></svg>`};e.PlacesAutocomplete=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u=new Map;#d;#f;#p;#m=[];#h=-1;#g;#_;#v;#y={autofocus:!1,autocomplete:`off`,placeholder:`Start typing your address ...`,distance:!1,distance_units:`km`,label:``,debounce:100,clear_input:!1,debug:!1,response_type:`json`,show_place_type:!1};#b={section:`pac-section`,container:`pac-container`,icon_container:`pac-icon-container`,icon:`<svg xmlns="http://www.w3.org/2000/svg" class="pac-w-5 pac-h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8" /><path d="m21 21-4.3-4.3" /></svg>`,input:`pac-input`,kbd_container:`pac-kbd-container`,kbd_escape:`pac-kbd-escape`,kbd_up:`pac-kbd-up`,kbd_down:`pac-kbd-down`,kbd_active:`pac-kbd-active`,ul:`pac-ul`,li:`pac-li`,li_current:`pac-li-current`,li_button:`pac-li-button`,li_button_current:`pac-li-button-current`,li_div_container:`pac-li-div-container`,li_div_p_container:`pac-li-div-p-container`,li_div_one:`pac-li-div-one`,li_div_one_p:`pac-li-div-one-p`,map_icon_svg:`pac-map-icon-svg`,map_pin_icon:`<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>`,li_div_one_p_secondaryText:`pac-li-div-one-p-secondaryText`,li_div_two:`pac-li-div-two`,li_div_two_p:`pac-li-div-two-p`,li_div_two_p_place_type:`pac-li-div-two-p-place_type`,li_div_two_p_place_type_item:`pac-li-div-two-p-place_type-item`,li_div_two_p_place_type_icon:`pac-li-div-two-p-place_type-icon`,li_div_two_p_place_type_label:`pac-li-div-two-p-place_type-label`,highlight:`pac-highlight`};#x={input:``,includedRegionCodes:[`GB`],language:`en-gb`};#S=[`formattedAddress`,`addressComponents`];#C=[`formattedAddress`,`addressComponents`];constructor(e){if(!e||!e.containerId||!e.googleMapsApiKey)throw Error(`PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).`);if(this.#e=e.containerId,this.#t=document.getElementById(e.containerId),!this.#t)throw Error(`PacAutocomplete: Container element with ID "${e.containerId}" not found.`);this.#n=e.googleMapsApiKey,this.#r=e.googleMapsApiVersion||`weekly`,this.#i={...this.#y,...e.options},e.options&&e.options.classes?this.#i.classes={...this.#b,...e.options.classes}:this.#i.classes=this.#b,this.#i.debug&&(console.log(`___debug constructor options:`),console.log(this.#i)),e.fetchFields&&Array.isArray(e.fetchFields)&&this._setFetchFields(e.fetchFields),this.#g=e.onResponse||(e=>{console.info(`---------Default onResponse not provided---------`),console.info(`Selected Place:`,JSON.stringify(e,null,2))}),this.#_=e.onError||(e=>{console.error(`---------Default onError not provided---------`),console.error(`PAC Error:`,e)}),e.requestParams&&Object.keys(e.requestParams).length>0?this.#a={...this.#x,...e.requestParams}:this.#a={...this.#x},this.#i.debug&&console.log(`___debug constructor requestParams:`,this.#a),this._initialiseDebouncedRequest(),this._init()}async _init(){try{(typeof google>`u`||!google.maps)&&await this._loadGoogleMapsApi({key:this.#n,v:this.#r}),this._createPACStructure(),await this._initializeAutocomplete()}catch(e){this.#_(e)}}_initialiseDebouncedRequest(){this.#v=this._debounce(async()=>{let e=this.#o?.value;if(!e){this._reset(),this.#o&&this.#o.setAttribute(`aria-expanded`,`false`);return}if(this.#u.has(e)){await this._renderSuggestions(this.#u.get(e));return}this.#a.input=e;try{let{suggestions:t}=await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(this.#a);t&&t.length>0?(this.#u.set(e,t),await this._renderSuggestions(t)):(this._reset(),this.#o.setAttribute(`aria-expanded`,`false`),this._announceStatus(`No suggestions found.`))}catch(e){this.#_(e),this._reset()}},this.#i.debounce)}async _renderSuggestions(e){let t=await Promise.all(this._createSuggestionElements(e));this.#c.replaceChildren(...t),this.#c.style.display=`block`,this.#o.setAttribute(`aria-expanded`,`true`),this._announceStatus(`${e.length} suggestions found.`)}_announceStatus(e){this.#l&&(this.#l.textContent=e)}_setFetchFields(e){Array.isArray(e)&&e.length>0&&(this.#S=[...new Set([...this.#C,...e])].filter(e=>e))}_debounce(e,t){let n=null;return function(...r){n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,e(...r)},t??100)}}_formatDistance(e,t){if(!this.#i.distance)return null;if(typeof e!=`number`)return`Origin required for distance`;let n,r;return t===`km`?(n=(e/1e3).toFixed(2),r=`km`):(n=(e/1609.34).toFixed(2),r=`miles`),n=n.replace(/\.00$/,``),`${n} ${r}`}async _loadGoogleMapsApi(e){var t,n,r,i=`The Google Maps JavaScript API`,a=`google`,o=`importLibrary`,s=`__ib__`,c=document,l=window;l=l[a]||(l[a]={});var u=l.maps||={},d=new Set,f=new URLSearchParams,p=()=>t||=new Promise(async(o,l)=>{for(r in n=c.createElement(`script`),f.set(`libraries`,[...d].join(`,`)),e)f.set(r.replace(/[A-Z]/g,e=>`_`+e[0].toLowerCase()),e[r]);f.set(`callback`,a+`.maps.`+s),n.src=`https://maps.${a}apis.com/maps/api/js?`+f,u[s]=o,n.onerror=()=>t=l(Error(`${i} could not load. Check your API key and network connection.`)),n.nonce=c.querySelector(`script[nonce]`)?.nonce||``,c.head.append(n)});u[o]?console.warn(i+` only loads once. Ignoring:`,e):u[o]=(e,...t)=>d.add(e)&&p().then(()=>u[o](e,...t))}_createPACStructure(){let e=document.createElement(`section`);e.className=this.#i.classes.section,this.#s=document.createElement(`div`),this.#s.className=this.#i.classes.container,this.#s.setAttribute(`id`,this.#e+`-div`),e.appendChild(this.#s),this.#l=document.createElement(`div`),this.#l.setAttribute(`aria-live`,`polite`),this.#l.setAttribute(`role`,`status`),this.#l.className=`pac-sr-only`,this.#s.appendChild(this.#l);let t=document.createElement(`div`);t.className=this.#i.classes.icon_container,this.#s.appendChild(t);let n=document.createElement(`div`);if(n.innerHTML=this.#i.classes.icon,t.appendChild(n.firstElementChild),this.#o=document.createElement(`input`),this.#o.id=this.#e+`-input`,this.#o.type=`text`,this.#o.name=`search`,this.#o.placeholder=this.#i.placeholder,this.#o.autocomplete=this.#i.autocomplete,this.#o.className=this.#i.classes.input,this.#o.setAttribute(`role`,`combobox`),this.#o.setAttribute(`aria-autocomplete`,`list`),this.#o.setAttribute(`aria-expanded`,`false`),this.#o.setAttribute(`aria-controls`,`pacSuggestions`),this.#o.setAttribute(`aria-activedescendant`,``),this.#i.autofocus&&(this.#o.autofocus=!0),this.#i.label){let t=document.createElement(`label`);t.htmlFor=this.#o.id,t.textContent=this.#i.label,e.prepend(t)}this.#s.appendChild(this.#o);let r=document.createElement(`div`);r.className=this.#i.classes.kbd_container,this.#d=document.createElement(`kbd`),this.#d.className=this.#i.classes.kbd_escape,this.#d.textContent=`Esc`,r.appendChild(this.#d),this.#f=document.createElement(`kbd`),this.#f.className=this.#i.classes.kbd_up,this.#f.innerHTML=`↑`,r.appendChild(this.#f),this.#p=document.createElement(`kbd`),this.#p.className=this.#i.classes.kbd_down,this.#p.innerHTML=`↓`,r.appendChild(this.#p),this.#s.appendChild(r),this.#c=document.createElement(`ul`),this.#c.id=`pacSuggestions`,this.#c.className=this.#i.classes.ul,this.#c.style.display=`none`,this.#c.setAttribute(`role`,`listbox`),this.#c.setAttribute(`aria-labelledby`,this.#o.id),this.#s.appendChild(this.#c),this.#c.addEventListener(`click`,e=>{let t=e.target.closest(`li`);if(t&&this.#c.contains(t)){let e=Array.from(this.#c.children).indexOf(t);e!==-1&&this.#m[e]&&this._onPlaceSelected(this.#m[e].place)}}),this.#t.appendChild(e),e.addEventListener(`keydown`,this._onKeyDown.bind(this))}_attachedEventListeners(){this.#o.addEventListener(`input`,this.#v),this.#o.addEventListener(`blur`,()=>{setTimeout(()=>{this.#c&&!this.#c.contains(document.activeElement)&&(this.#c.style.display=`none`,this.#o.setAttribute(`aria-expanded`,`false`))},200)}),this.#o.addEventListener(`focus`,()=>{this.#o.value&&this.#m.length>0&&(this.#c.style.display=`block`,this.#o.setAttribute(`aria-expanded`,`true`))})}_detachEventListeners(){this.#o&&this.#o.removeEventListener(`input`,this.#v),this.#t&&this.#s&&this.#t.removeChild(this.#s.parentElement)}async _initializeAutocomplete(){try{await google.maps.importLibrary(`places`),this._refreshToken(),this.#o?this._attachedEventListeners():this.#_(Error(`Input element not found during initialization.`))}catch(e){console.error(`Error initializing Google Places Autocomplete:`,e),this.#_(Error(`Google Maps Places library not available.`))}}_reset(e=!1,t=null){this.#h=-1,this.#o&&this.#i.clear_input==0&&t&&t.formattedAddress?this.#o.value=t.formattedAddress:this.#o&&(this.#o.value=``),this.#o&&(this.#o.setAttribute(`aria-expanded`,`false`),this.#o.setAttribute(`aria-activedescendant`,``),this.#o.blur()),this.#m=[],this.#h=-1,this.#c&&(this.#c.innerHTML=``,this.#c.style.display=`none`),e&&this._refreshToken()}_resetLiClasses(){this.#c&&Array.from(this.#c.children).forEach(e=>{this.#i.classes.li_current.split(` `).forEach(t=>e.classList.remove(t));let t=e.querySelector(`button`);t&&this.#i.classes.li_button_current.split(` `).forEach(e=>t.classList.remove(e))})}_onKeyDown(e){this._resetLiClasses(),e.key===`Escape`&&(e.preventDefault(),this.#i.classes.kbd_active.split(` `).forEach(e=>this.#d?.classList.add(e)),setTimeout(()=>this.#i.classes.kbd_active.split(` `).forEach(e=>this.#d?.classList.remove(e)),300),this._reset(!0)),!(!this.#m.length||!this.#c||this.#c.style.display===`none`)&&(e.key===`ArrowDown`?(e.preventDefault(),this.#h=Math.min(this.#h+1,this.#m.length-1),this._highlightSuggestion()):e.key===`ArrowUp`?(e.preventDefault(),this.#h=Math.max(this.#h-1,0),this._highlightSuggestion()):e.key===`Home`?(e.preventDefault(),this.#h=0,this._highlightSuggestion()):e.key===`End`?(e.preventDefault(),this.#h=this.#m.length-1,this._highlightSuggestion()):e.key===`Enter`&&(e.preventDefault(),this.#h>=0&&this.#h<this.#m.length&&this._onPlaceSelected(this.#m[this.#h].place)))}_highlightSuggestion(){if(this.#h<0)return;let e=this.#c.children.item(this.#h);if(e){let t=e.querySelector(`button`);this.#i.classes.li_current.split(` `).forEach(t=>e.classList.add(t)),t&&this.#i.classes.li_button_current.split(` `).forEach(e=>t.classList.add(e)),e.scrollIntoView({block:`nearest`}),this.#o.setAttribute(`aria-activedescendant`,e.id);let n=this.#h===0?this.#f:this.#p;this.#i.classes.kbd_active.split(` `).forEach(e=>n?.classList.add(e)),setTimeout(()=>this.#i.classes.kbd_active.split(` `).forEach(e=>n?.classList.remove(e)),300)}}_getAddressComponent(e,t){return e.addressComponents?.find(e=>e.types.includes(t))?.longText||``}_createButtonElement(e){let t=document.createElement(`button`);return t.tabIndex=e+1,t.className=this.#i.classes.li_button,t}_createDivElement(e){let t=document.createElement(`div`);return e&&(t.className=e),t}_createMapPinIconElement(){let e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return e.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),e.setAttribute(`width`,`24`),e.setAttribute(`height`,`24`),e.setAttribute(`viewBox`,`0 0 24 24`),e.setAttribute(`fill`,`none`),e.setAttribute(`stroke`,`currentColor`),e.setAttribute(`stroke-width`,`2`),e.setAttribute(`stroke-linecap`,`round`),e.setAttribute(`stroke-linejoin`,`round`),e.setAttribute(`class`,this.#i.classes.map_icon_svg),e.innerHTML=this.#i.classes.map_pin_icon,e}_createPElement(e){let t=document.createElement(`p`);return e&&(t.className=e),t}_createSuggestionElements(e){return this.#m=[],e.map(async(e,t)=>{let n=e.placePrediction.toPlace(),r=document.createElement(`li`);r.id=`option-${t+1}`,r.className=this.#i.classes.li,r.setAttribute(`role`,`option`);let i=this._createButtonElement(t),a=this._createDivElement(this.#i.classes.li_div_container),o=this._createDivElement(this.#i.classes.li_div_one),s=this._createDivElement(this.#i.classes.li_div_two),c=this._createMapPinIconElement();o.appendChild(c);let l=this._createDivElement(this.#i.classes.li_div_p_container);o.appendChild(l);let u=this._createPElement(this.#i.classes.li_div_one_p),d=this._createPElement(this.#i.classes.li_div_one_p_secondaryText),f=e.placePrediction?.distanceMeters??e.distanceMeters,p=this._formatDistance(f,this.#i.distance_units??`km`);l.appendChild(u),l.appendChild(d),this._renderSuggestionMeta(s,e,p),a.appendChild(o),a.appendChild(s),i.appendChild(a),r.appendChild(i),this._renderHighlightText(u,e.placePrediction.mainText);let m=e.placePrediction?.secondaryText?.text??``;return m&&(d.textContent=m),this.#m.push({id:t+1,place:n,mainText:e.placePrediction.mainText.text,secondaryText:m,description:e.placePrediction.toString()}),r})}_renderSuggestionMeta(e,r,i){if(this.#i.show_place_type||this.#i.distance){let a=this._createDivElement(this.#i.classes.li_div_two_p_place_type);if(this.#i.show_place_type&&Array.isArray(r.placePrediction?.types)&&r.placePrediction.types.length>0){let e=this._createDivElement(this.#i.classes.li_div_two_p_place_type_item),i=this._createPElement(this.#i.classes.li_div_two_p_place_type_icon),o=this._createPElement(this.#i.classes.li_div_two_p_place_type_label),s=r.placePrediction.types.find(e=>typeof e==`string`&&e in t);o.textContent=s?t[s]:`Default`,i.innerHTML=n[o.textContent]||n.Default,e.appendChild(i),e.appendChild(o),a.appendChild(e)}if(this.#i.distance&&i!==null){let e=this._createDivElement(this.#i.classes.li_div_two_p_place_type_item),t=this._createPElement(this.#i.classes.li_div_two_p);t.textContent=i,e.appendChild(t),a.appendChild(e)}a.hasChildNodes()&&e.appendChild(a)}}_renderHighlightText(e,t){let n=t.text,r=t.matches,i=0;r.sort((e,t)=>e.startOffset-t.startOffset);let a=document.createElement(`span`),o=document.createElement(`span`);o.classList=this.#i.classes.highlight??`font-bold`;for(let e of r)a.textContent+=n.substring(i,e.startOffset),e.startOffset>0&&n.charAt(e.startOffset-1)===` `&&(o.textContent+=` `),o.textContent+=n.substring(e.startOffset,e.endOffset),i=e.endOffset;a.appendChild(o),a.appendChild(document.createTextNode(n.substring(i))),e.appendChild(a)}async _onPlaceSelected(e){let t=null;try{await e.fetchFields({fields:this.#S}),this.#i.response_type===`place`?(t=e,this.#g(e)):(t=e.toJSON(),this.#g(t))}catch(e){console.error(`Error fetching place details:`,e),this.#_(e)}finally{this._reset(!0,t)}}_refreshToken(){try{this.#a.sessionToken=new google.maps.places.AutocompleteSessionToken}catch(e){console.error(`Error creating session token:`,e),this.#_(e)}}setFetchFields(e){this._setFetchFields(e)}getFetchFields(){return this.#S}setRequestParams(e){typeof e==`object`&&!Array.isArray(e)&&e!==null&&(e.input&&typeof e.input==`string`&&(this.#o.value=e.input),this.#a={...this.#x,...e})}getRequestParams(){return this.#a}setOptions(e){if(typeof e==`object`&&!Array.isArray(e)&&e!==null){this._detachEventListeners();let t=e.classes||{};delete e.classes,this.#i={...this.#y,...e},t&&typeof t==`object`&&Object.keys(t).length>0?this.#i.classes={...this.#b,...t}:this.#i.classes={...this.#b},this._initialiseDebouncedRequest(),this._createPACStructure(),this.#o&&this._attachedEventListeners()}}getOptions(){return this.#i}async setInputValue(e,t){try{let{Geocoder:n}=await google.maps.importLibrary(`geocoding`),r=await new n().geocode({location:{lat:e,lng:t}});if(r.results&&r.results.length>0){let e=r.results[0].place_id,t=new google.maps.places.Place({id:e});await t.fetchFields({fields:this.#S}),!this.#i.clear_input&&t.formattedAddress&&(this.#o.value=t.formattedAddress),this.#i.response_type===`place`?this.#g(t):this.#g(t.toJSON())}else throw Error(`No results found for the provided coordinates`)}catch(e){console.error(`Error in setInputValue:`,e),this.#_(e)}}clear(){this.#u.clear(),this._reset(!0)}focus(){this.#o&&this.#o.focus()}destroy(){this._detachEventListeners(),this.#e=null,this.#t=null,this.#n=null,this.#r=null,this.#i=null,this.#a=null,this.#o=null,this.#s=null,this.#c=null,this.#l=null,this.#u=null,this.#d=null,this.#f=null,this.#p=null,this.#m=null,this.#h=-1,this.#g=null,this.#_=null,this.#v=null}}});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.PlacesAutocomplete={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t={car_rental:`Automotive`,car_dealer:`Automotive`,gas_station:`Automotive`,electric_vehicle_charging_station:`Automotive`,parking:`Automotive`,airport:`Airport`,bus_station:`Transport`,train_station:`Train Station`,subway_station:`Subway Station`,taxi_stand:`Transport`,ferry_terminal:`Transport`,restaurant:`Food and Drink`,cafe:`Food and Drink`,coffee_shop:`Food and Drink`,bar:`Food and Drink`,pub:`Food and Drink`,night_club:`Food and Drink`,bakery:`Food and Drink`,fast_food_restaurant:`Food and Drink`,ice_cream_shop:`Food and Drink`,pizza_restaurant:`Food and Drink`,steak_house:`Food and Drink`,sushi_restaurant:`Food and Drink`,hotel:`Lodging`,hostel:`Lodging`,motel:`Lodging`,resort_hotel:`Lodging`,bed_and_breakfast:`Lodging`,campground:`Lodging`,rv_park:`Lodging`,lodging:`Lodging`,cottage:`Lodging`,inn:`Lodging`,guest_house:`Lodging`,tourist_attraction:`Sightseeing`,museum:`Sightseeing`,art_gallery:`Sightseeing`,cultural_landmark:`Sightseeing`,historical_landmark:`Sightseeing`,monument:`Sightseeing`,performing_arts_theater:`Sightseeing`,aquarium:`Sightseeing`,zoo:`Sightseeing`,visitor_center:`Sightseeing`,town_square:`Sightseeing`,landmark:`Sightseeing`,place_of_worship:`Sightseeing`,park:`Recreation`,national_park:`Recreation`,state_park:`Recreation`,beach:`Recreation`,hiking_area:`Recreation`,amusement_park:`Recreation`,water_park:`Recreation`,botanical_garden:`Recreation`,golf_course:`Recreation`,gym:`Recreation`,natural_feature:`Recreation`,shopping_mall:`Shopping`,supermarket:`Shopping`,grocery_store:`Shopping`,clothing_store:`Shopping`,electronics_store:`Shopping`,souvenir_shop:`Shopping`,gift_shop:`Shopping`,duty_free_store:`Shopping`,hospital:`Health`,pharmacy:`Health`,atm:`Finance`,bank:`Finance`,post_office:`Services`,police:`Services`,neighborhood:`Geographical`,sublocality:`Geographical`,route:`Navigation`,street_address:`Navigation`,intersection:`Navigation`,locality:`City`,administrative_area_level_4:`City`,country:`Country`,administrative_area_level_1:`City`,administrative_area_level_2:`City`,administrative_area_level_3:`City`,administrative_area_level_5:`City`,sublocality_level_1:`Neighborhood`,sublocality_level_2:`Neighborhood`,sublocality_level_3:`Neighborhood`,sublocality_level_4:`Neighborhood`,sublocality_level_5:`Neighborhood`,default:`Default`},n={Distance:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-route-icon lucide-route"><circle cx="6" cy="19" r="3"/><path d="M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15"/><circle cx="18" cy="5" r="3"/></svg>`,Automotive:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2"/><circle cx="7" cy="17" r="2"/><path d="M9 17h6"/><circle cx="17" cy="17" r="2"/></svg>`,Transport:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z"/></svg>`,"Food and Drink":`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2"/><path d="M7 2v20"/><path d="M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7"/></svg>`,Lodging:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 4v16"/><path d="M2 8h18a2 2 0 0 1 2 2v10"/><path d="M2 17h20"/><path d="M6 8v9"/></svg>`,Sightseeing:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-binoculars-icon lucide-binoculars"><path d="M10 10h4"/><path d="M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3"/><path d="M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z"/><path d="M 22 16 L 2 16"/><path d="M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z"/><path d="M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3"/></svg>`,Recreation:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-kayak-icon lucide-kayak"><path d="M18 17a1 1 0 0 0-1 1v1a2 2 0 1 0 2-2z"/><path d="M20.97 3.61a.45.45 0 0 0-.58-.58C10.2 6.6 6.6 10.2 3.03 20.39a.45.45 0 0 0 .58.58C13.8 17.4 17.4 13.8 20.97 3.61"/><path d="m6.707 6.707 10.586 10.586"/><path d="M7 5a2 2 0 1 0-2 2h1a1 1 0 0 0 1-1z"/></svg>`,Shopping:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"/><path d="M3 6h18"/><path d="M16 10a4 4 0 0 1-8 0"/></svg>`,Health:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 7v4"/><path d="M14 21v-3a2 2 0 0 0-4 0v3"/><path d="M14 9h-4"/><path d="M18 11h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2"/><path d="M18 21V5a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16"/></svg>`,Finance:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" y1="10" x2="22" y2="10"/></svg>`,Geographical:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m20 20-6-10.6c-.4-.7-1.5-.7-1.9 0L6 20"/><path d="M7 16h10"/><path d="M12 4a8 8 0 0 1 8 8v2a2 2 0 0 1-2 2h-1"/><path d="M7 16H6a2 2 0 0 1-2-2v-2a8 8 0 0 1 8-8"/></svg>`,Navigation:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-navigation-icon lucide-navigation"><polygon points="3 11 22 2 13 21 11 13 3 11"/></svg>`,City:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-building2-icon lucide-building-2"><path d="M10 12h4"/><path d="M10 8h4"/><path d="M14 21v-3a2 2 0 0 0-4 0v3"/><path d="M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2"/><path d="M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16"/></svg>`,District:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-land-plot-icon lucide-land-plot"><path d="m12 8 6-3-6-3v10"/><path d="m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12"/><path d="m6.49 12.85 11.02 6.3"/><path d="M17.51 12.85 6.5 19.15"/></svg>`,Airport:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plane-icon lucide-plane"><path d="M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z"/></svg>`,"Subway Station":`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-subway-icon lucide-subway"><path d="M12 22a10 10 0 0 0 10-10V8l-5-5H7L2 8v4a10 10 0 0 0 10 10Z"/><path d="M12 22V8"/><path d="M7 13h10"/><path d="M7 17h10"/></svg>`,"Train Station":`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-train-icon lucide-train"><path d="M2 10h20"/><path d="M2 10a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5Z"/><circle cx="7" cy="15" r="2"/><circle cx="17" cy="15" r="2"/></svg>`,Default:`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display:inline-block"; viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"/><circle cx="12" cy="10" r="3"/></svg>`};e.PlacesAutocomplete=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u=new Map;#d;#f;#p;#m=[];#h=-1;#g;#_;#v;#y={autofocus:!1,autocomplete:`off`,placeholder:`Start typing your address ...`,distance:!1,distance_units:`km`,label:``,debounce:100,clear_input:!1,debug:!1,response_type:`json`,show_place_type:!1};#b={section:`pac-section`,container:`pac-container`,icon_container:`pac-icon-container`,icon:`<svg xmlns="http://www.w3.org/2000/svg" class="pac-w-5 pac-h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8" /><path d="m21 21-4.3-4.3" /></svg>`,input:`pac-input`,kbd_container:`pac-kbd-container`,kbd_escape:`pac-kbd-escape`,kbd_up:`pac-kbd-up`,kbd_down:`pac-kbd-down`,kbd_active:`pac-kbd-active`,ul:`pac-ul`,li:`pac-li`,li_current:`pac-li-current`,li_button:`pac-li-button`,li_button_current:`pac-li-button-current`,li_div_container:`pac-li-div-container`,li_div_p_container:`pac-li-div-p-container`,li_div_one:`pac-li-div-one`,li_div_one_p:`pac-li-div-one-p`,map_icon_svg:`pac-map-icon-svg`,map_pin_icon:`<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>`,li_div_one_p_secondaryText:`pac-li-div-one-p-secondaryText`,li_div_two:`pac-li-div-two`,li_div_two_p:`pac-li-div-two-p`,li_div_two_p_place_type:`pac-li-div-two-p-place_type`,li_div_two_p_place_type_item:`pac-li-div-two-p-place_type-item`,li_div_two_p_place_type_icon:`pac-li-div-two-p-place_type-icon`,li_div_two_p_place_type_label:`pac-li-div-two-p-place_type-label`,highlight:`pac-highlight`};#x={input:``,includedRegionCodes:[`GB`],language:`en-gb`};#S=[`formattedAddress`,`addressComponents`];#C=[`formattedAddress`,`addressComponents`];constructor(e){if(!e||!e.containerId||!e.googleMapsApiKey)throw Error(`PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).`);if(this.#e=e.containerId,this.#t=document.getElementById(e.containerId),!this.#t)throw Error(`PacAutocomplete: Container element with ID "${e.containerId}" not found.`);this.#n=e.googleMapsApiKey,this.#r=e.googleMapsApiVersion||`weekly`,this.#i={...this.#y,...e.options},e.options&&e.options.classes?this.#i.classes={...this.#b,...e.options.classes}:this.#i.classes=this.#b,this.#i.debug&&(console.log(`___debug constructor options:`),console.log(this.#i)),e.fetchFields&&Array.isArray(e.fetchFields)&&this._setFetchFields(e.fetchFields),this.#g=e.onResponse||(e=>{console.info(`---------Default onResponse not provided---------`),console.info(`Selected Place:`,JSON.stringify(e,null,2))}),this.#_=e.onError||(e=>{console.error(`---------Default onError not provided---------`),console.error(`PAC Error:`,e)}),e.requestParams&&Object.keys(e.requestParams).length>0?this.#a={...this.#x,...e.requestParams}:this.#a={...this.#x},this.#i.debug&&console.log(`___debug constructor requestParams:`,this.#a),this._initialiseDebouncedRequest(),this._init()}async _init(){try{(typeof google>`u`||!google.maps)&&await this._loadGoogleMapsApi({key:this.#n,v:this.#r}),this._createPACStructure(),await this._initializeAutocomplete()}catch(e){this.#_(e)}}_initialiseDebouncedRequest(){this.#v=this._debounce(async()=>{let e=this.#o?.value;if(!e){this._reset(),this.#o&&this.#o.setAttribute(`aria-expanded`,`false`);return}if(this.#u.has(e)){await this._renderSuggestions(this.#u.get(e));return}this.#a.input=e;try{let{suggestions:t}=await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(this.#a);t&&t.length>0?(this.#u.set(e,t),await this._renderSuggestions(t)):(this._reset(),this.#o.setAttribute(`aria-expanded`,`false`),this._announceStatus(`No suggestions found.`))}catch(e){this.#_(e),this._reset()}},this.#i.debounce)}async _renderSuggestions(e){let t=await Promise.all(this._createSuggestionElements(e));this.#c.replaceChildren(...t),this.#c.style.display=`block`,this.#o.setAttribute(`aria-expanded`,`true`),this._announceStatus(`${e.length} suggestions found.`)}_announceStatus(e){this.#l&&(this.#l.textContent=e)}_setFetchFields(e){Array.isArray(e)&&e.length>0&&(this.#S=[...new Set([...this.#C,...e])].filter(e=>e))}_debounce(e,t){let n=null;return function(...r){n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,e(...r)},t??100)}}_formatDistance(e,t){if(!this.#i.distance||typeof e!=`number`)return null;let n,r;return t===`km`?(n=(e/1e3).toFixed(2),r=`km`):(n=(e/1609.34).toFixed(2),r=`miles`),n=n.replace(/\.00$/,``),`${n} ${r}`}async _loadGoogleMapsApi(e){var t,n,r,i=`The Google Maps JavaScript API`,a=`google`,o=`importLibrary`,s=`__ib__`,c=document,l=window;l=l[a]||(l[a]={});var u=l.maps||={},d=new Set,f=new URLSearchParams,p=()=>t||=new Promise(async(o,l)=>{for(r in n=c.createElement(`script`),f.set(`libraries`,[...d].join(`,`)),e)f.set(r.replace(/[A-Z]/g,e=>`_`+e[0].toLowerCase()),e[r]);f.set(`callback`,a+`.maps.`+s),n.src=`https://maps.${a}apis.com/maps/api/js?`+f,u[s]=o,n.onerror=()=>t=l(Error(`${i} could not load. Check your API key and network connection.`)),n.nonce=c.querySelector(`script[nonce]`)?.nonce||``,c.head.append(n)});u[o]?console.warn(i+` only loads once. Ignoring:`,e):u[o]=(e,...t)=>d.add(e)&&p().then(()=>u[o](e,...t))}_createPACStructure(){let e=document.createElement(`section`);e.className=this.#i.classes.section,this.#s=document.createElement(`div`),this.#s.className=this.#i.classes.container,this.#s.setAttribute(`id`,this.#e+`-div`),e.appendChild(this.#s),this.#l=document.createElement(`div`),this.#l.setAttribute(`aria-live`,`polite`),this.#l.setAttribute(`role`,`status`),this.#l.className=`pac-sr-only`,this.#s.appendChild(this.#l);let t=document.createElement(`div`);t.className=this.#i.classes.icon_container,this.#s.appendChild(t);let n=document.createElement(`div`);if(n.innerHTML=this.#i.classes.icon,t.appendChild(n.firstElementChild),this.#o=document.createElement(`input`),this.#o.id=this.#e+`-input`,this.#o.type=`text`,this.#o.name=`search`,this.#o.placeholder=this.#i.placeholder,this.#o.autocomplete=this.#i.autocomplete,this.#o.className=this.#i.classes.input,this.#o.setAttribute(`role`,`combobox`),this.#o.setAttribute(`aria-autocomplete`,`list`),this.#o.setAttribute(`aria-expanded`,`false`),this.#o.setAttribute(`aria-controls`,`pacSuggestions`),this.#o.setAttribute(`aria-activedescendant`,``),this.#i.autofocus&&(this.#o.autofocus=!0),this.#i.label){let t=document.createElement(`label`);t.htmlFor=this.#o.id,t.textContent=this.#i.label,e.prepend(t)}this.#s.appendChild(this.#o);let r=document.createElement(`div`);r.className=this.#i.classes.kbd_container,this.#d=document.createElement(`kbd`),this.#d.className=this.#i.classes.kbd_escape,this.#d.textContent=`Esc`,r.appendChild(this.#d),this.#f=document.createElement(`kbd`),this.#f.className=this.#i.classes.kbd_up,this.#f.innerHTML=`↑`,r.appendChild(this.#f),this.#p=document.createElement(`kbd`),this.#p.className=this.#i.classes.kbd_down,this.#p.innerHTML=`↓`,r.appendChild(this.#p),this.#s.appendChild(r),this.#c=document.createElement(`ul`),this.#c.id=`pacSuggestions`,this.#c.className=this.#i.classes.ul,this.#c.style.display=`none`,this.#c.setAttribute(`role`,`listbox`),this.#c.setAttribute(`aria-labelledby`,this.#o.id),this.#s.appendChild(this.#c),this.#c.addEventListener(`click`,e=>{let t=e.target.closest(`li`);if(t&&this.#c.contains(t)){let e=Array.from(this.#c.children).indexOf(t);e!==-1&&this.#m[e]&&this._onPlaceSelected(this.#m[e].place)}}),this.#t.appendChild(e),e.addEventListener(`keydown`,this._onKeyDown.bind(this))}_attachedEventListeners(){this.#o.addEventListener(`input`,this.#v),this.#o.addEventListener(`blur`,()=>{setTimeout(()=>{this.#c&&!this.#c.contains(document.activeElement)&&(this.#c.style.display=`none`,this.#o.setAttribute(`aria-expanded`,`false`))},200)}),this.#o.addEventListener(`focus`,()=>{this.#o.value&&this.#m.length>0&&(this.#c.style.display=`block`,this.#o.setAttribute(`aria-expanded`,`true`))})}_detachEventListeners(){this.#o&&this.#o.removeEventListener(`input`,this.#v),this.#t&&this.#s&&this.#t.removeChild(this.#s.parentElement)}async _initializeAutocomplete(){try{await google.maps.importLibrary(`places`),this._refreshToken(),this.#o?this._attachedEventListeners():this.#_(Error(`Input element not found during initialization.`))}catch(e){console.error(`Error initializing Google Places Autocomplete:`,e),this.#_(Error(`Google Maps Places library not available.`))}}_reset(e=!1,t=null){this.#h=-1,this.#o&&this.#i.clear_input==0&&t&&t.formattedAddress?this.#o.value=t.formattedAddress:this.#o&&(this.#o.value=``),this.#o&&(this.#o.setAttribute(`aria-expanded`,`false`),this.#o.setAttribute(`aria-activedescendant`,``),this.#o.blur()),this.#m=[],this.#h=-1,this.#c&&(this.#c.innerHTML=``,this.#c.style.display=`none`),e&&this._refreshToken()}_resetLiClasses(){this.#c&&Array.from(this.#c.children).forEach(e=>{this.#i.classes.li_current.split(` `).forEach(t=>e.classList.remove(t));let t=e.querySelector(`button`);t&&this.#i.classes.li_button_current.split(` `).forEach(e=>t.classList.remove(e))})}_onKeyDown(e){this._resetLiClasses(),e.key===`Escape`&&(e.preventDefault(),this.#i.classes.kbd_active.split(` `).forEach(e=>this.#d?.classList.add(e)),setTimeout(()=>this.#i.classes.kbd_active.split(` `).forEach(e=>this.#d?.classList.remove(e)),300),this._reset(!0)),!(!this.#m.length||!this.#c||this.#c.style.display===`none`)&&(e.key===`ArrowDown`?(e.preventDefault(),this.#h=Math.min(this.#h+1,this.#m.length-1),this._highlightSuggestion()):e.key===`ArrowUp`?(e.preventDefault(),this.#h=Math.max(this.#h-1,0),this._highlightSuggestion()):e.key===`Home`?(e.preventDefault(),this.#h=0,this._highlightSuggestion()):e.key===`End`?(e.preventDefault(),this.#h=this.#m.length-1,this._highlightSuggestion()):e.key===`Enter`&&(e.preventDefault(),this.#h>=0&&this.#h<this.#m.length&&this._onPlaceSelected(this.#m[this.#h].place)))}_highlightSuggestion(){if(this.#h<0)return;let e=this.#c.children.item(this.#h);if(e){let t=e.querySelector(`button`);this.#i.classes.li_current.split(` `).forEach(t=>e.classList.add(t)),t&&this.#i.classes.li_button_current.split(` `).forEach(e=>t.classList.add(e)),e.scrollIntoView({block:`nearest`}),this.#o.setAttribute(`aria-activedescendant`,e.id);let n=this.#h===0?this.#f:this.#p;this.#i.classes.kbd_active.split(` `).forEach(e=>n?.classList.add(e)),setTimeout(()=>this.#i.classes.kbd_active.split(` `).forEach(e=>n?.classList.remove(e)),300)}}_getAddressComponent(e,t){return e.addressComponents?.find(e=>e.types.includes(t))?.longText||``}_createButtonElement(e){let t=document.createElement(`button`);return t.tabIndex=e+1,t.className=this.#i.classes.li_button,t}_createDivElement(e){let t=document.createElement(`div`);return e&&(t.className=e),t}_createMapPinIconElement(){let e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return e.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),e.setAttribute(`width`,`24`),e.setAttribute(`height`,`24`),e.setAttribute(`viewBox`,`0 0 24 24`),e.setAttribute(`fill`,`none`),e.setAttribute(`stroke`,`currentColor`),e.setAttribute(`stroke-width`,`2`),e.setAttribute(`stroke-linecap`,`round`),e.setAttribute(`stroke-linejoin`,`round`),e.setAttribute(`class`,this.#i.classes.map_icon_svg),e.innerHTML=this.#i.classes.map_pin_icon,e}_createPElement(e){let t=document.createElement(`p`);return e&&(t.className=e),t}_createSuggestionElements(e){return this.#m=[],e.map(async(e,t)=>{let n=e.placePrediction.toPlace(),r=document.createElement(`li`);r.id=`option-${t+1}`,r.className=this.#i.classes.li,r.setAttribute(`role`,`option`);let i=this._createButtonElement(t),a=this._createDivElement(this.#i.classes.li_div_container),o=this._createDivElement(this.#i.classes.li_div_one),s=this._createDivElement(this.#i.classes.li_div_two),c=this._createMapPinIconElement();o.appendChild(c);let l=this._createDivElement(this.#i.classes.li_div_p_container);o.appendChild(l);let u=this._createPElement(this.#i.classes.li_div_one_p),d=this._createPElement(this.#i.classes.li_div_one_p_secondaryText),f=e.placePrediction?.distanceMeters??e.distanceMeters,p=this._formatDistance(f,this.#i.distance_units??`km`);l.appendChild(u),l.appendChild(d),this._renderSuggestionMeta(s,e,p),a.appendChild(o),a.appendChild(s),i.appendChild(a),r.appendChild(i),this._renderHighlightText(u,e.placePrediction.mainText);let m=e.placePrediction?.secondaryText?.text??``;return m&&(d.textContent=m),this.#m.push({id:t+1,place:n,mainText:e.placePrediction.mainText.text,secondaryText:m,description:e.placePrediction.toString()}),r})}_renderSuggestionMeta(e,r,i){if(this.#i.show_place_type||this.#i.distance){let a=this._createDivElement(this.#i.classes.li_div_two_p_place_type);if(this.#i.show_place_type&&Array.isArray(r.placePrediction?.types)&&r.placePrediction.types.length>0){let e=this._createDivElement(this.#i.classes.li_div_two_p_place_type_item),i=this._createPElement(this.#i.classes.li_div_two_p_place_type_icon),o=this._createPElement(this.#i.classes.li_div_two_p_place_type_label),s=r.placePrediction.types.find(e=>typeof e==`string`&&e in t);o.textContent=s?t[s]:`Default`,i.innerHTML=n[o.textContent]||n.Default,e.appendChild(i),e.appendChild(o),a.appendChild(e)}if(this.#i.distance){let e=this._createDivElement(this.#i.classes.li_div_two_p_place_type_item),t=this._createPElement(this.#i.classes.li_div_two_p_place_type_icon);t.innerHTML=n.Distance;let r=this._createPElement(this.#i.classes.li_div_two_p);r.textContent=i??`-`,e.appendChild(t),e.appendChild(r),a.appendChild(e)}a.hasChildNodes()&&e.appendChild(a)}}_renderHighlightText(e,t){let n=t.text,r=t.matches,i=0;r.sort((e,t)=>e.startOffset-t.startOffset);let a=document.createElement(`span`),o=document.createElement(`span`);o.classList=this.#i.classes.highlight??`font-bold`;for(let e of r)a.textContent+=n.substring(i,e.startOffset),e.startOffset>0&&n.charAt(e.startOffset-1)===` `&&(o.textContent+=` `),o.textContent+=n.substring(e.startOffset,e.endOffset),i=e.endOffset;a.appendChild(o),a.appendChild(document.createTextNode(n.substring(i))),e.appendChild(a)}async _onPlaceSelected(e){let t=null;try{await e.fetchFields({fields:this.#S}),this.#i.response_type===`place`?(t=e,this.#g(e)):(t=e.toJSON(),this.#g(t))}catch(e){console.error(`Error fetching place details:`,e),this.#_(e)}finally{this._reset(!0,t)}}_refreshToken(){try{this.#a.sessionToken=new google.maps.places.AutocompleteSessionToken}catch(e){console.error(`Error creating session token:`,e),this.#_(e)}}setFetchFields(e){this._setFetchFields(e)}getFetchFields(){return this.#S}setRequestParams(e){typeof e==`object`&&!Array.isArray(e)&&e!==null&&(e.input&&typeof e.input==`string`&&(this.#o.value=e.input),this.#a={...this.#x,...e})}getRequestParams(){return this.#a}setOptions(e){if(typeof e==`object`&&!Array.isArray(e)&&e!==null){this._detachEventListeners();let t=e.classes||{};delete e.classes,this.#i={...this.#y,...e},t&&typeof t==`object`&&Object.keys(t).length>0?this.#i.classes={...this.#b,...t}:this.#i.classes={...this.#b},this._initialiseDebouncedRequest(),this._createPACStructure(),this.#o&&this._attachedEventListeners()}}getOptions(){return this.#i}async setInputValue(e,t){try{let{Geocoder:n}=await google.maps.importLibrary(`geocoding`),r=await new n().geocode({location:{lat:e,lng:t}});if(r.results&&r.results.length>0){let e=r.results[0].place_id,t=new google.maps.places.Place({id:e});await t.fetchFields({fields:this.#S}),!this.#i.clear_input&&t.formattedAddress&&(this.#o.value=t.formattedAddress),this.#i.response_type===`place`?this.#g(t):this.#g(t.toJSON())}else throw Error(`No results found for the provided coordinates`)}catch(e){console.error(`Error in setInputValue:`,e),this.#_(e)}}clear(){this.#u.clear(),this._reset(!0)}focus(){this.#o&&this.#o.focus()}destroy(){this._detachEventListeners(),this.#e=null,this.#t=null,this.#n=null,this.#r=null,this.#i=null,this.#a=null,this.#o=null,this.#s=null,this.#c=null,this.#l=null,this.#u=null,this.#d=null,this.#f=null,this.#p=null,this.#m=null,this.#h=-1,this.#g=null,this.#_=null,this.#v=null}}});
|
|
2
2
|
//# sourceMappingURL=places-autocomplete.umd.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"places-autocomplete.umd.cjs","names":["#containerId","#pacEl","#googleMapsApiKey","#googleMapsApiVersion","#options","#defaultOptions","#defaultClasses","#onDataCallback","#onErrorCallback","#request","#defaultRequestParams","#debouncedMakeAcRequest","#inputElement","#cache","#ul","#ariaStatus","#fetchFields","#defaultFetchFields","#container","#kbdEscape","#kbdUp","#kbdDown","#allSuggestions","#currentSuggestion"],"sources":["../constants.js","../PlacesAutocomplete.js"],"sourcesContent":["export const ITINERARY_CATEGORIES = {\n // --- TRANSPORT & AUTO ---\n car_rental: \"Automotive\",\n car_dealer: \"Automotive\",\n gas_station: \"Automotive\",\n electric_vehicle_charging_station: \"Automotive\",\n parking: \"Automotive\",\n airport: \"Airport\",\n bus_station: \"Transport\",\n train_station: \"Train Station\",\n subway_station: \"Subway Station\",\n taxi_stand: \"Transport\",\n ferry_terminal: \"Transport\",\n\n // --- DINING & NIGHTLIFE ---\n restaurant: \"Food and Drink\",\n cafe: \"Food and Drink\",\n coffee_shop: \"Food and Drink\",\n bar: \"Food and Drink\",\n pub: \"Food and Drink\",\n night_club: \"Food and Drink\",\n bakery: \"Food and Drink\",\n fast_food_restaurant: \"Food and Drink\",\n ice_cream_shop: \"Food and Drink\",\n pizza_restaurant: \"Food and Drink\",\n steak_house: \"Food and Drink\",\n sushi_restaurant: \"Food and Drink\",\n\n // --- LODGING ---\n hotel: \"Lodging\",\n hostel: \"Lodging\",\n motel: \"Lodging\",\n resort_hotel: \"Lodging\",\n bed_and_breakfast: \"Lodging\",\n campground: \"Lodging\",\n rv_park: \"Lodging\",\n lodging: \"Lodging\",\n cottage: \"Lodging\",\n inn: \"Lodging\",\n guest_house: \"Lodging\",\n\n // --- SIGHTSEEING & CULTURE ---\n tourist_attraction: \"Sightseeing\",\n museum: \"Sightseeing\",\n art_gallery: \"Sightseeing\",\n cultural_landmark: \"Sightseeing\",\n historical_landmark: \"Sightseeing\",\n monument: \"Sightseeing\",\n performing_arts_theater: \"Sightseeing\",\n aquarium: \"Sightseeing\",\n zoo: \"Sightseeing\",\n visitor_center: \"Sightseeing\",\n town_square: \"Sightseeing\",\n landmark: \"Sightseeing\",\n place_of_worship: \"Sightseeing\",\n\n // --- RECREATION & PARKS ---\n park: \"Recreation\",\n national_park: \"Recreation\",\n state_park: \"Recreation\",\n beach: \"Recreation\",\n hiking_area: \"Recreation\",\n amusement_park: \"Recreation\",\n water_park: \"Recreation\",\n botanical_garden: \"Recreation\",\n golf_course: \"Recreation\",\n gym: \"Recreation\",\n natural_feature: \"Recreation\",\n\n // --- SHOPPING ---\n shopping_mall: \"Shopping\",\n supermarket: \"Shopping\",\n grocery_store: \"Shopping\",\n clothing_store: \"Shopping\",\n electronics_store: \"Shopping\",\n souvenir_shop: \"Shopping\",\n gift_shop: \"Shopping\",\n duty_free_store: \"Shopping\",\n\n // --- ESSENTIAL SERVICES ---\n hospital: \"Health\",\n pharmacy: \"Health\",\n atm: \"Finance\",\n bank: \"Finance\",\n post_office: \"Services\",\n police: \"Services\",\n\n // --- GEOGRAPHICAL ---\n neighborhood: \"Geographical\",\n sublocality: \"Geographical\",\n\n // --- NAVIGATION ---\n route: \"Navigation\",\n street_address: \"Navigation\",\n intersection: \"Navigation\",\n\n // -- CITY --\n locality: \"City\",\n administrative_area_level_4: \"City\",\n country: \"Country\",\n administrative_area_level_1: \"City\",\n administrative_area_level_2: \"City\",\n administrative_area_level_3: \"City\",\n administrative_area_level_5: \"City\",\n sublocality_level_1: \"Neighborhood\",\n sublocality_level_2: \"Neighborhood\",\n sublocality_level_3: \"Neighborhood\",\n sublocality_level_4: \"Neighborhood\",\n sublocality_level_5: \"Neighborhood\",\n\n // --- DEFAULT ---\n default: \"Default\",\n};\n\nexport const ITINERARY_SVG_ICONS = {\n Automotive: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2\"/><circle cx=\"7\" cy=\"17\" r=\"2\"/><path d=\"M9 17h6\"/><circle cx=\"17\" cy=\"17\" r=\"2\"/></svg>`,\n\n Transport: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z\"/></svg>`,\n\n \"Food and Drink\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2\"/><path d=\"M7 2v20\"/><path d=\"M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7\"/></svg>`,\n\n Lodging: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2 4v16\"/><path d=\"M2 8h18a2 2 0 0 1 2 2v10\"/><path d=\"M2 17h20\"/><path d=\"M6 8v9\"/></svg>`,\n\n Sightseeing: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-binoculars-icon lucide-binoculars\"><path d=\"M10 10h4\"/><path d=\"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3\"/><path d=\"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z\"/><path d=\"M 22 16 L 2 16\"/><path d=\"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z\"/><path d=\"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3\"/></svg>`,\n\n Recreation: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-kayak-icon lucide-kayak\"><path d=\"M18 17a1 1 0 0 0-1 1v1a2 2 0 1 0 2-2z\"/><path d=\"M20.97 3.61a.45.45 0 0 0-.58-.58C10.2 6.6 6.6 10.2 3.03 20.39a.45.45 0 0 0 .58.58C13.8 17.4 17.4 13.8 20.97 3.61\"/><path d=\"m6.707 6.707 10.586 10.586\"/><path d=\"M7 5a2 2 0 1 0-2 2h1a1 1 0 0 0 1-1z\"/></svg>`,\n\n Shopping: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z\"/><path d=\"M3 6h18\"/><path d=\"M16 10a4 4 0 0 1-8 0\"/></svg>`,\n\n Health: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 7v4\"/><path d=\"M14 21v-3a2 2 0 0 0-4 0v3\"/><path d=\"M14 9h-4\"/><path d=\"M18 11h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2\"/><path d=\"M18 21V5a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16\"/></svg>`,\n\n Finance: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect width=\"20\" height=\"14\" x=\"2\" y=\"5\" rx=\"2\"/><line x1=\"2\" y1=\"10\" x2=\"22\" y2=\"10\"/></svg>`,\n\n Geographical: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"m20 20-6-10.6c-.4-.7-1.5-.7-1.9 0L6 20\"/><path d=\"M7 16h10\"/><path d=\"M12 4a8 8 0 0 1 8 8v2a2 2 0 0 1-2 2h-1\"/><path d=\"M7 16H6a2 2 0 0 1-2-2v-2a8 8 0 0 1 8-8\"/></svg>`,\n\n Navigation: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-navigation-icon lucide-navigation\"><polygon points=\"3 11 22 2 13 21 11 13 3 11\"/></svg>`,\n\n City: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-building2-icon lucide-building-2\"><path d=\"M10 12h4\"/><path d=\"M10 8h4\"/><path d=\"M14 21v-3a2 2 0 0 0-4 0v3\"/><path d=\"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2\"/><path d=\"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16\"/></svg>`,\n\n District: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-land-plot-icon lucide-land-plot\"><path d=\"m12 8 6-3-6-3v10\"/><path d=\"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12\"/><path d=\"m6.49 12.85 11.02 6.3\"/><path d=\"M17.51 12.85 6.5 19.15\"/></svg>`,\n\n Airport: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-plane-icon lucide-plane\"><path d=\"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z\"/></svg>`,\n\n \"Subway Station\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-subway-icon lucide-subway\"><path d=\"M12 22a10 10 0 0 0 10-10V8l-5-5H7L2 8v4a10 10 0 0 0 10 10Z\"/><path d=\"M12 22V8\"/><path d=\"M7 13h10\"/><path d=\"M7 17h10\"/></svg>`,\n\n \"Train Station\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-train-icon lucide-train\"><path d=\"M2 10h20\"/><path d=\"M2 10a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5Z\"/><circle cx=\"7\" cy=\"15\" r=\"2\"/><circle cx=\"17\" cy=\"15\" r=\"2\"/></svg>`,\n\n Default: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z\"/><circle cx=\"12\" cy=\"10\" r=\"3\"/></svg>`,\n};\n","import \"./places-autocomplete.css\";\nimport { ITINERARY_CATEGORIES, ITINERARY_SVG_ICONS } from \"./constants.js\";\n\n/**\n * A flexible and customisable Places Autocomplete widget powered by the Google Maps Places API.\n *\n * Features:\n * - Dynamic Google Maps API loading\n * - Debounced input for optimized API requests\n * - Keyboard navigation (Arrow keys, Enter, Escape)\n * - Session token management for cost-effective API usage\n * - Customizable styling and behavior\n *\n * @author Alexander Pechkarev <alexpechkarev@gmail.com>\n * @license MIT\n */\nexport class PlacesAutocomplete {\n // --- Private Properties (using # or _ prefix by convention) ---\n #containerId; // Container ID where the autocomplete widget will be rendered.\n #pacEl;\n #googleMapsApiKey;\n #googleMapsApiVersion;\n #options;\n #request;\n #inputElement;\n #container;\n #ul;\n #ariaStatus; // For screen reader announcements\n #cache = new Map(); // Simple cache for suggestions\n #kbdEscape;\n #kbdUp;\n #kbdDown;\n #allSuggestions = [];\n #currentSuggestion = -1;\n #onDataCallback; // For user-provided data callback\n #onErrorCallback; // For user-provided error callback\n #debouncedMakeAcRequest; // Declare without initializing here\n #defaultOptions = {\n // Default options for the autocomplete widget.\n autofocus: false, // Automatically focus the input on load.\n autocomplete: \"off\", // HTML autocomplete attribute for the input.\n placeholder: \"Start typing your address ...\", // Placeholder text for the input.\n distance: false, // Show distance in suggestions (requires origin in request).\n distance_units: \"km\", // Units for distance ('km' or 'miles').\n label: \"\", // Optional label text above the input.\n debounce: 100, // Debounce delay (ms) for API requests.\n clear_input: false, // Clear input .\n debug: false, // Enable debug mode (not implemented in this version).\n response_type: \"json\", // Return format: 'json' for JSON object, 'place' for Google Maps Place instance.\n show_place_type: false, // Display place type icons (mutually exclusive with distance).\n };\n #defaultClasses = {\n // CSS classes for various parts of the widget.\n section: \"pac-section\", // Outer section container.\n container: \"pac-container\", // Main container div.\n icon_container: \"pac-icon-container\", // Container for the search icon.\n icon: '<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"pac-w-5 pac-h-5\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\" /><path d=\"m21 21-4.3-4.3\" /></svg>', // SVG for the search icon.\n input: \"pac-input\", // Input field.\n kbd_container: \"pac-kbd-container\", // Container for keyboard hints.\n kbd_escape: \"pac-kbd-escape\", // Escape key hint.\n kbd_up: \"pac-kbd-up\", // Up arrow key hint.\n kbd_down: \"pac-kbd-down\", // Down arrow key hint.\n kbd_active: \"pac-kbd-active\", // Class for active keyboard hint.\n ul: \"pac-ul\", // Suggestions list (ul).\n li: \"pac-li\", // Suggestion item (li).\n li_current: \"pac-li-current\", // Class for the currently selected suggestion item.\n li_button: \"pac-li-button\", // Link element within a suggestion item.\n li_button_current: \"pac-li-button-current\", // Class for the link in the currently selected suggestion item.\n li_div_container: \"pac-li-div-container\", // Container div within the suggestion link.\n li_div_p_container: \"pac-li-div-p-container\",\n li_div_one: \"pac-li-div-one\", // First inner div (for place name).\n li_div_one_p: \"pac-li-div-one-p\", // Paragraph for the place name.\n map_icon_svg: \"pac-map-icon-svg\",\n map_pin_icon:\n '<path d=\"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\"/><circle cx=\"12\" cy=\"10\" r=\"3\"/>',\n li_div_one_p_secondaryText: \"pac-li-div-one-p-secondaryText\",\n li_div_two: \"pac-li-div-two\", // Second inner div (for distance).\n li_div_two_p: \"pac-li-div-two-p\", // Paragraph for the distance.\n li_div_two_p_place_type: \"pac-li-div-two-p-place_type\", // Container for place type display.\n li_div_two_p_place_type_item: \"pac-li-div-two-p-place_type-item\", // Wrapper for individual options within the place type container.\n li_div_two_p_place_type_icon: \"pac-li-div-two-p-place_type-icon\", // The place type icon element.\n li_div_two_p_place_type_label: \"pac-li-div-two-p-place_type-label\", // The place type label text.\n highlight: \"pac-highlight\", // Class for highlighting matched text in suggestions.\n };\n #defaultRequestParams = {\n // Default parameters for the autocomplete request.\n input: \"\", // Initial input value (empty).\n includedRegionCodes: [\"GB\"], // Default region codes to include in suggestions.\n language: \"en-gb\",\n // region: \"GB\",\n };\n #fetchFields = [\"formattedAddress\", \"addressComponents\"];\n #defaultFetchFields = [\"formattedAddress\", \"addressComponents\"]; // Fields to fetch for the selected place (can be extended).\n\n /**\n * Class constructor for PacAutocomplete.\n * Initializes the autocomplete widget with the provided configuration.\n * @param {Object} config - Configuration object for the autocomplete widget.\n * @param {string} config.containerId - ID of the container element for the widget.\n * @param {string} config.googleMapsApiKey - Google Maps API key.\n * @param {string} [config.googleMapsApiVersion] - Version of the Google Maps API to use (default: \"weekly\").\n * @param {Object} [config.options] - Additional options for the widget (e.g., classes, callbacks).\n * @param {Object} [config.requestParams] - Parameters for the autocomplete request (e.g., input, region).\n * @param {*} config\n */\n constructor(config) {\n if (!config || !config.containerId || !config.googleMapsApiKey) {\n throw new Error(\n \"PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).\",\n );\n }\n\n this.#containerId = config.containerId; // Store the configuration object\n this.#pacEl = document.getElementById(config.containerId);\n if (!this.#pacEl) {\n throw new Error(\n `PacAutocomplete: Container element with ID \"${config.containerId}\" not found.`,\n );\n }\n\n this.#googleMapsApiKey = config.googleMapsApiKey;\n this.#googleMapsApiVersion = config.googleMapsApiVersion || \"weekly\";\n\n // Merge user options with defaults\n this.#options = {\n ...this.#defaultOptions, // Default options\n ...config.options, // User-defined options override defaults\n };\n // Ensure classes are deeply merged if user provides partial classes\n if (config.options && config.options.classes) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...config.options.classes,\n };\n } else {\n this.#options.classes = this.#defaultClasses; // Use default classes if none provided\n }\n\n if (this.#options.debug) {\n console.log(\"___debug constructor options:\");\n console.log(this.#options);\n }\n\n if (config.fetchFields && Array.isArray(config.fetchFields)) {\n this._setFetchFields(config.fetchFields); // Set fetch fields from user config\n }\n\n // Set default response and error callbacks if not provided\n this.#onDataCallback =\n config.onResponse ||\n ((place) => {\n console.info(\"---------Default onResponse not provided---------\");\n console.info(\"Selected Place:\", JSON.stringify(place, null, 2));\n });\n this.#onErrorCallback =\n config.onError ||\n ((error) => {\n console.error(\"---------Default onError not provided---------\");\n console.error(\"PAC Error:\", error);\n });\n\n if (config.requestParams && Object.keys(config.requestParams).length > 0) {\n this.#request = {\n ...this.#defaultRequestParams,\n ...config.requestParams,\n };\n } else {\n this.#request = { ...this.#defaultRequestParams }; // Use defaults if no requestParams provided\n }\n\n if (this.#options.debug) {\n console.log(\"___debug constructor requestParams:\", this.#request);\n }\n\n this._initialiseDebouncedRequest(); // Initialize the debounced request function\n\n this._init(); // Underscore prefix for internal initialization method\n }\n\n // --- Private Initialization Method ---\n async _init() {\n try {\n // check if google maps api is already loaded\n if (typeof google === \"undefined\" || !google.maps) {\n // Load the Google Maps API dynamically\n await this._loadGoogleMapsApi({\n key: this.#googleMapsApiKey,\n v: this.#googleMapsApiVersion,\n });\n }\n this._createPACStructure();\n await this._initializeAutocomplete();\n } catch (error) {\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Initializes the debounced request function for fetching autocomplete suggestions.\n * This function is called on initialization and when options are updated.\n *\n * @private\n */\n _initialiseDebouncedRequest() {\n this.#debouncedMakeAcRequest = this._debounce(async () => {\n const query = this.#inputElement?.value;\n if (!query) {\n this._reset();\n if (this.#inputElement)\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n return;\n }\n\n // Check cache\n if (this.#cache.has(query)) {\n await this._renderSuggestions(this.#cache.get(query));\n return;\n }\n\n this.#request.input = query;\n\n try {\n const { suggestions } =\n // eslint-disable-next-line no-undef\n await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(\n this.#request,\n );\n\n // Cache and display suggestions\n if (suggestions && suggestions.length > 0) {\n this.#cache.set(query, suggestions);\n await this._renderSuggestions(suggestions);\n } else {\n // No suggestions found\n this._reset(); // Clear any old suggestions\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this._announceStatus(\"No suggestions found.\");\n }\n } catch (error) {\n this.#onErrorCallback(error);\n this._reset();\n }\n }, this.#options.debounce); // Default debounce to 100ms if not set\n }\n\n /**\n * Renders the suggestions list.\n * @private\n */\n async _renderSuggestions(suggestions) {\n const suggestionElements = await Promise.all(\n this._createSuggestionElements(suggestions),\n );\n this.#ul.replaceChildren(...suggestionElements);\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n this._announceStatus(`${suggestions.length} suggestions found.`);\n }\n\n /**\n * Announces a message to screen readers using aria-live.\n * @private\n */\n _announceStatus(message) {\n if (this.#ariaStatus) {\n this.#ariaStatus.textContent = message;\n }\n }\n\n /**\n * Sets the fields to fetch for the selected place.\n * @param {Array<string>} fields - The fields to fetch.\n */\n _setFetchFields(fields) {\n if (Array.isArray(fields) && fields.length > 0) {\n this.#fetchFields = [\n ...new Set([...this.#defaultFetchFields, ...fields]),\n ].filter((e) => e); // Ensure unique and non-empty fields\n }\n }\n\n /**\n * Creates a debounced version of a function.\n *\n * @private\n * @param {Function} func - The function to debounce\n * @param {number} wait - Delay in milliseconds\n * @returns {Function} Debounced function\n */\n _debounce(func, wait) {\n let timeout = null;\n return function executedFunction(...args) {\n const later = () => {\n timeout = null;\n func(...args); // Call original function\n };\n if (timeout !== null) {\n clearTimeout(timeout); // Clear the previous timeout\n }\n timeout = setTimeout(later, wait ?? 100); // Set the new timeout\n };\n }\n /**\n * Formats a distance value from meters to the specified unit.\n *\n * @private\n * @param {number|null|undefined} distance - Distance in meters\n * @param {('km'|'miles')} units - Target unit for conversion\n * @returns {string|null} Formatted distance string or null if invalid\n */\n _formatDistance(distance, units) {\n if (!this.#options.distance) {\n return null;\n }\n if (typeof distance !== \"number\") {\n return \"Origin required for distance\"; // Return informative message if distance requested but missing\n }\n let value;\n let unitLabel;\n if (units === \"km\") {\n value = (distance / 1000).toFixed(2);\n unitLabel = \"km\";\n } else {\n // Default to miles if not 'km'\n value = (distance / 1609.34).toFixed(2);\n unitLabel = \"miles\";\n }\n // Avoid showing \".00\"\n value = value.replace(/\\.00$/, \"\");\n return `${value} ${unitLabel}`;\n }\n\n /**\n * Dynamically loads the Google Maps JavaScript API using the importLibrary method.\n * This is the standard approach recommended by Google.\n * @see https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n * @param {object} g - Configuration object for the API loader (key, v, libraries, etc.).\n */\n async _loadGoogleMapsApi(g) {\n var h, // Promise tracking API load\n a, // Script element\n k, // Loop variable for config keys\n p = \"The Google Maps JavaScript API\", // Error message prefix\n c = \"google\", // Global namespace\n l = \"importLibrary\", // Loader function name\n q = \"__ib__\", // Internal callback name\n m = document, // Document reference\n b = window; // Window reference\n b = b[c] || (b[c] = {}); // Ensure google namespace exists\n var d = b.maps || (b.maps = {}), // Ensure google.maps namespace exists\n r = new Set(), // Set to track requested libraries\n e = new URLSearchParams(), // URL parameters for the API script\n u = () =>\n // Function to initiate API loading (if not already started)\n h ||\n // eslint-disable-next-line no-async-promise-executor\n (h = new Promise(async (f, n) => {\n // Create script element (done async to potentially wait for nonce)\n // await (a = m.createElement('script')); // Original Google code had await here, might not be needed\n a = m.createElement(\"script\"); // Create script tag\n e.set(\"libraries\", [...r].join(\",\")); // Add accumulated libraries\n // Add other parameters from the config object 'g'\n for (k in g)\n e.set(\n k.replace(/[A-Z]/g, (t) => \"_\" + t[0].toLowerCase()), // Convert camelCase to snake_case\n g[k],\n );\n e.set(\"callback\", c + \".maps.\" + q); // Set the internal callback function name\n a.src = `https://maps.${c}apis.com/maps/api/js?` + e; // Construct the API URL\n d[q] = f; // Assign the promise resolver to the callback name on google.maps\n // Error handling for script loading failure\n a.onerror = () =>\n (h = n(\n new Error(\n `${p} could not load. Check your API key and network connection.`,\n ),\n )); // Use onerror for load failures\n // Nonce for Content Security Policy\n a.nonce = m.querySelector(\"script[nonce]\")?.nonce || \"\";\n m.head.append(a); // Append the script to the document head\n }));\n // Define or reuse the importLibrary function on google.maps\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n d[l]\n ? console.warn(p + \" only loads once. Ignoring:\", g) // Warn if called again\n : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n))); // The actual importLibrary implementation\n }\n\n // --- UI Creation ---\n _createPACStructure() {\n const section = document.createElement(\"section\");\n section.className = this.#options.classes.section;\n\n // Main container\n this.#container = document.createElement(\"div\");\n this.#container.className = this.#options.classes.container;\n this.#container.setAttribute(\"id\", this.#containerId + \"-div\");\n section.appendChild(this.#container);\n\n // Live region for a11y status updates\n this.#ariaStatus = document.createElement(\"div\");\n this.#ariaStatus.setAttribute(\"aria-live\", \"polite\");\n this.#ariaStatus.setAttribute(\"role\", \"status\");\n this.#ariaStatus.className = \"pac-sr-only\"; // Screen reader only\n this.#container.appendChild(this.#ariaStatus);\n\n // Icon\n const iconContainer = document.createElement(\"div\");\n iconContainer.className = this.#options.classes.icon_container;\n this.#container.appendChild(iconContainer);\n const icon = document.createElement(\"div\");\n icon.innerHTML = this.#options.classes.icon;\n iconContainer.appendChild(icon.firstElementChild); // Append the actual SVG element\n\n // Input field\n this.#inputElement = document.createElement(\"input\");\n this.#inputElement.id = this.#containerId + \"-input\"; // Assign ID for label association\n this.#inputElement.type = \"text\";\n this.#inputElement.name = \"search\"; // Consider making name configurable\n this.#inputElement.placeholder = this.#options.placeholder;\n this.#inputElement.autocomplete = this.#options.autocomplete;\n this.#inputElement.className = this.#options.classes.input;\n this.#inputElement.setAttribute(\"role\", \"combobox\");\n this.#inputElement.setAttribute(\"aria-autocomplete\", \"list\");\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\"); // Will be updated dynamically\n this.#inputElement.setAttribute(\"aria-controls\", \"pacSuggestions\"); // Links to the suggestions list\n this.#inputElement.setAttribute(\"aria-activedescendant\", \"\"); // Will be updated dynamically\n\n if (this.#options.autofocus) {\n this.#inputElement.autofocus = true;\n }\n if (this.#options.label) {\n const label = document.createElement(\"label\");\n label.htmlFor = this.#inputElement.id; // Correctly link label to input by ID\n label.textContent = this.#options.label;\n // Add label classes if needed from opts.classes\n section.prepend(label); // Append label before input or adjust structure\n }\n this.#container.appendChild(this.#inputElement);\n\n // Keyboard hints container\n const kbdContainer = document.createElement(\"div\");\n kbdContainer.className = this.#options.classes.kbd_container;\n this.#kbdEscape = document.createElement(\"kbd\");\n this.#kbdEscape.className = this.#options.classes.kbd_escape;\n this.#kbdEscape.textContent = \"Esc\";\n kbdContainer.appendChild(this.#kbdEscape);\n this.#kbdUp = document.createElement(\"kbd\");\n this.#kbdUp.className = this.#options.classes.kbd_up;\n this.#kbdUp.innerHTML = \"↑\"; // Up arrow HTML entity\n kbdContainer.appendChild(this.#kbdUp);\n this.#kbdDown = document.createElement(\"kbd\");\n this.#kbdDown.className = this.#options.classes.kbd_down;\n this.#kbdDown.innerHTML = \"↓\"; // Down arrow HTML entity\n kbdContainer.appendChild(this.#kbdDown);\n this.#container.appendChild(kbdContainer);\n\n // Suggestions list (initially hidden)\n this.#ul = document.createElement(\"ul\");\n this.#ul.id = \"pacSuggestions\"; // Must match aria-controls\n this.#ul.className = this.#options.classes.ul;\n this.#ul.style.display = \"none\";\n this.#ul.setAttribute(\"role\", \"listbox\");\n this.#ul.setAttribute(\"aria-labelledby\", this.#inputElement.id); // Link listbox to input for accessibility\n this.#container.appendChild(this.#ul);\n\n // Event Delegation for suggestion selection\n this.#ul.addEventListener(\"click\", (e) => {\n const li = e.target.closest(\"li\");\n if (li && this.#ul.contains(li)) {\n const index = Array.from(this.#ul.children).indexOf(li);\n if (index !== -1 && this.#allSuggestions[index]) {\n this._onPlaceSelected(this.#allSuggestions[index].place);\n }\n }\n });\n\n this.#pacEl.appendChild(section);\n section.addEventListener(\"keydown\", this._onKeyDown.bind(this)); // Bind 'this'\n }\n\n /**\n * Attaches event listeners to the input element for handling user input.\n * This includes debounced input handling, focus/blur events, and keyboard navigation.\n */\n _attachedEventListeners() {\n this.#inputElement.addEventListener(\"input\", this.#debouncedMakeAcRequest);\n // Add focus/blur listeners if needed to manage suggestion visibility\n this.#inputElement.addEventListener(\"blur\", () => {\n // Delay hiding suggestions to allow click events on them\n setTimeout(() => {\n if (this.#ul && !this.#ul.contains(document.activeElement)) {\n // Check if focus moved outside suggestions\n this.#ul.style.display = \"none\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, 200); // Adjust delay as needed\n });\n this.#inputElement.addEventListener(\"focus\", () => {\n // Potentially show suggestions again if input has value\n if (this.#inputElement.value && this.#allSuggestions.length > 0) {\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n }\n });\n }\n\n _detachEventListeners() {\n // Remove event listeners, remove elements from DOM\n if (this.#inputElement) {\n this.#inputElement.removeEventListener(\n \"input\",\n this.#debouncedMakeAcRequest,\n );\n // remove other listeners\n }\n if (this.#pacEl && this.#container) {\n this.#pacEl.removeChild(this.#container.parentElement); // remove the whole section\n }\n }\n\n /**\n * Initializes the core autocomplete functionality after the API is loaded.\n * Imports necessary libraries and sets up the input event listener.\n */\n async _initializeAutocomplete() {\n try {\n // Ensure the 'places' library is available via the dynamic loader\n // eslint-disable-next-line no-undef\n await google.maps.importLibrary(\"places\");\n // console.log('Places library imported successfully.'); // For debugging\n\n // Initial token generation\n this._refreshToken();\n\n // Attach the debounced request function to the input element's 'input' event\n if (this.#inputElement) {\n this._attachedEventListeners();\n } else {\n this.#onErrorCallback(\n new Error(\"Input element not found during initialization.\"),\n );\n }\n } catch (error) {\n console.error(\"Error initializing Google Places Autocomplete:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(\n new Error(\"Google Maps Places library not available.\"),\n );\n }\n }\n\n /**\n * Resets the autocomplete input field, clears suggestions, and optionally refreshes the session token.\n * @param {boolean} [refresh=false] - Whether to refresh the Google Places session token.\n */\n _reset(refresh = false, placeData = null) {\n this.#currentSuggestion = -1;\n\n /**\n * If the input element exists and clear_input is false, set its value to the formatted address\n * from placeData. Otherwise, clear the input value.\n * This allows the user to keep the input value if they selected a place,\n * but still allows clearing it if clear_input is true or placeData is not provided.\n * @type {HTMLInputElement}\n * @property {string} value - The value of the input element.\n * @property {boolean} clear_input - Whether to clear the input value after selection.\n * @property {Object} placeData - The data of the selected place, containing formattedAddress.\n */\n if (\n this.#inputElement &&\n this.#options.clear_input == false &&\n placeData &&\n placeData.formattedAddress\n ) {\n this.#inputElement.value = placeData.formattedAddress; // Set input value to formatted address\n } else if (this.#inputElement) {\n this.#inputElement.value = \"\";\n }\n\n if (this.#inputElement) {\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this.#inputElement.setAttribute(\"aria-activedescendant\", \"\"); // Clear aria-activedescendant\n this.#inputElement.blur();\n }\n\n this.#allSuggestions = [];\n this.#currentSuggestion = -1;\n if (this.#ul) {\n this.#ul.innerHTML = \"\"; // Clear existing suggestions\n this.#ul.style.display = \"none\";\n }\n if (refresh) {\n this._refreshToken();\n }\n }\n /**\n * Removes the 'current' highlighting classes from all suggestion list items (li) and their links (a).\n */\n _resetLiClasses() {\n if (!this.#ul) return;\n Array.from(this.#ul.children).forEach((li) => {\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => li.classList.remove(cl));\n const link = li.querySelector(\"button\");\n if (link) {\n this.#options.classes.li_button_current\n .split(\" \")\n .forEach((cl) => link.classList.remove(cl));\n }\n });\n }\n\n /**\n * Handles keyboard events (ArrowDown, ArrowUp, Enter, Escape) for navigating\n * and selecting suggestions or closing the list.\n * @param {KeyboardEvent} e - The keyboard event object.\n */\n _onKeyDown(e) {\n this._resetLiClasses(); // Reset classes on any key press within the suggestions\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.remove(cl)),\n 300,\n );\n\n this._reset(true); // Reset search input and results, refresh token\n }\n\n if (\n !this.#allSuggestions.length ||\n !this.#ul ||\n this.#ul.style.display === \"none\"\n )\n return;\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.min(\n this.#currentSuggestion + 1,\n this.#allSuggestions.length - 1,\n );\n this._highlightSuggestion();\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.max(this.#currentSuggestion - 1, 0); // Stay at 0 if already there\n this._highlightSuggestion();\n } else if (e.key === \"Home\") {\n e.preventDefault();\n this.#currentSuggestion = 0;\n this._highlightSuggestion();\n } else if (e.key === \"End\") {\n e.preventDefault();\n this.#currentSuggestion = this.#allSuggestions.length - 1;\n this._highlightSuggestion();\n } else if (e.key === \"Enter\") {\n e.preventDefault(); // Prevent form submission if applicable\n if (\n this.#currentSuggestion >= 0 &&\n this.#currentSuggestion < this.#allSuggestions.length\n ) {\n this._onPlaceSelected(\n this.#allSuggestions[this.#currentSuggestion].place,\n );\n // Reset is handled within onPlaceSelected via reset(true)\n }\n }\n }\n\n /**\n * Highlights the current suggestion in the UI.\n * @private\n */\n _highlightSuggestion() {\n if (this.#currentSuggestion < 0) return;\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentButton = currentLi.querySelector(\"button\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentButton) {\n this.#options.classes.li_button_current\n .split(\" \")\n .forEach((cl) => currentButton.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n this.#inputElement.setAttribute(\"aria-activedescendant\", currentLi.id); // Update aria-activedescendant\n\n // Visual feedback for key press\n const kbd =\n this.#currentSuggestion === 0\n ? this.#kbdUp\n : this.#kbdDown;\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => kbd?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => kbd?.classList.remove(cl)),\n 300,\n );\n }\n }\n\n // Helper function to find a specific address component\n _getAddressComponent(response, type) {\n return (\n response.addressComponents?.find((c) => c.types.includes(type))\n ?.longText || \"\"\n );\n }\n\n /**\n * Creates a button element for a suggestion item.\n * @returns {HTMLButtonElement} The created button element.\n */\n _createButtonElement(index) {\n const button = document.createElement(\"button\");\n button.tabIndex = index + 1;\n button.className = this.#options.classes.li_button; // block w-full flex justify-between\n return button;\n }\n\n /**\n * Creates a div container for suggestion item.\n * @returns {HTMLDivElement} The created div container element.\n */\n _createDivElement(className) {\n // create div elements pac-li-div-container\n const divContainer = document.createElement(\"div\");\n if (className) {\n divContainer.className = className;\n }\n return divContainer;\n }\n\n /**\n * Creates an SVG element representing a map pin icon.\n * @returns {SVGSVGElement} The created SVG element.\n */\n _createMapPinIconElement() {\n const svgIcon = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"svg\",\n );\n svgIcon.setAttribute(\"xmlns\", \"http://www.w3.org/2000/svg\");\n svgIcon.setAttribute(\"width\", \"24\");\n svgIcon.setAttribute(\"height\", \"24\");\n svgIcon.setAttribute(\"viewBox\", \"0 0 24 24\");\n svgIcon.setAttribute(\"fill\", \"none\");\n svgIcon.setAttribute(\"stroke\", \"currentColor\");\n svgIcon.setAttribute(\"stroke-width\", \"2\");\n svgIcon.setAttribute(\"stroke-linecap\", \"round\");\n svgIcon.setAttribute(\"stroke-linejoin\", \"round\");\n svgIcon.setAttribute(\"class\", this.#options.classes.map_icon_svg);\n // insert map pin icon path\n svgIcon.innerHTML = this.#options.classes.map_pin_icon;\n return svgIcon;\n }\n\n /**\n * Creates a paragraph (P) element with an optional class name.\n * @param {string} className\n * @returns {HTMLParagraphElement}\n */\n _createPElement(className) {\n const p = document.createElement(\"p\");\n if (className) {\n p.className = className;\n }\n return p;\n }\n /**\n * Creates an array of list item (LI) elements for the suggestions dropdown.\n * Each LI contains a link (A) with the place prediction details and distance.\n * Handles highlighting the matched parts of the suggestion text.\n * @param {Array<google.maps.places.AutocompleteSuggestion>} suggestions - Array of suggestion objects from the API.\n * @returns {Array<HTMLLIElement>} An array of LI elements to be added to the suggestions UL.\n */\n _createSuggestionElements(suggestions) {\n this.#allSuggestions = []; // Reset before populating\n // Map suggestions to LI elements\n return suggestions.map(async (suggestion, index) => {\n // Fetch place details for each suggestion\n let place = suggestion.placePrediction.toPlace();\n\n const li = document.createElement(\"li\");\n li.id = `option-${index + 1}`;\n li.className = this.#options.classes.li;\n li.setAttribute(\"role\", \"option\");\n\n // create button element\n const button = this._createButtonElement(index);\n\n // create div elements pac-li-div-container\n const divContainer = this._createDivElement(\n this.#options.classes.li_div_container,\n );\n\n // create li div one element - place name\n const liDivOne = this._createDivElement(this.#options.classes.li_div_one);\n const liDivTwo = this._createDivElement(this.#options.classes.li_div_two);\n // create map pin icon element\n const mapPinIcon = this._createMapPinIconElement();\n // append map pin icon to liDivOne\n liDivOne.appendChild(mapPinIcon);\n\n // create div p container\n const divPContainer = this._createDivElement(\n this.#options.classes.li_div_p_container,\n );\n // append div p container to liDivOne\n liDivOne.appendChild(divPContainer);\n\n // create p element - place name\n const pOne = this._createPElement(this.#options.classes.li_div_one_p);\n // create p element - secondary text\n const pTwo = this._createPElement(\n this.#options.classes.li_div_one_p_secondaryText,\n );\n // create p element - distance\n // Try to get distanceMeters from placePrediction or directly from suggestion\n const distanceMeters =\n suggestion.placePrediction?.distanceMeters ?? suggestion.distanceMeters;\n const distanceValue = this._formatDistance(\n distanceMeters,\n this.#options.distance_units ?? \"km\",\n );\n\n // append p element to div p container\n divPContainer.appendChild(pOne);\n divPContainer.appendChild(pTwo);\n\n // Add place type display and/or distance if enabled\n this._renderSuggestionMeta(liDivTwo, suggestion, distanceValue);\n\n // append liDivOne to divContainer\n divContainer.appendChild(liDivOne);\n divContainer.appendChild(liDivTwo);\n // append divContainer to button\n button.appendChild(divContainer);\n // append button to li\n li.appendChild(button);\n\n this._renderHighlightText(pOne, suggestion.placePrediction.mainText);\n\n // set secondary text if available\n const secondaryText =\n suggestion.placePrediction?.secondaryText?.text ?? \"\";\n\n if (secondaryText) {\n pTwo.textContent = secondaryText;\n }\n\n this.#allSuggestions.push({\n id: index + 1,\n place: place,\n mainText: suggestion.placePrediction.mainText.text,\n secondaryText: secondaryText,\n description: suggestion.placePrediction.toString(),\n });\n\n return li;\n });\n }\n\n /**\n * Renders meta information (place type, distance) for a suggestion.\n * @private\n */\n _renderSuggestionMeta(container, suggestion, distanceValue) {\n if (this.#options.show_place_type || this.#options.distance) {\n const metaContainer = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type,\n );\n\n // Place Type display\n if (\n this.#options.show_place_type &&\n Array.isArray(suggestion.placePrediction?.types) &&\n suggestion.placePrediction.types.length > 0\n ) {\n const placeTypeWrapper = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type_item,\n );\n\n const placeTypeIcon = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_icon,\n );\n\n const placeTypeLabel = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_label,\n );\n\n // Look through the array until we find a type we actually recognize\n const matchedType = suggestion.placePrediction.types.find(\n (type) => typeof type === \"string\" && type in ITINERARY_CATEGORIES,\n );\n\n placeTypeLabel.textContent = matchedType\n ? ITINERARY_CATEGORIES[matchedType]\n : \"Default\";\n\n placeTypeIcon.innerHTML =\n ITINERARY_SVG_ICONS[placeTypeLabel.textContent] ||\n ITINERARY_SVG_ICONS[\"Default\"];\n\n placeTypeWrapper.appendChild(placeTypeIcon);\n placeTypeWrapper.appendChild(placeTypeLabel);\n metaContainer.appendChild(placeTypeWrapper);\n }\n\n // Distance display\n if (this.#options.distance && distanceValue !== null) {\n const distanceWrapper = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type_item,\n );\n const pThree = this._createPElement(this.#options.classes.li_div_two_p);\n pThree.textContent = distanceValue;\n distanceWrapper.appendChild(pThree);\n metaContainer.appendChild(distanceWrapper);\n }\n\n if (metaContainer.hasChildNodes()) {\n container.appendChild(metaContainer);\n }\n }\n }\n\n /**\n * Renders highlighted text for a suggestion.\n * @private\n */\n _renderHighlightText(element, predictionText) {\n const originalText = predictionText.text;\n const matches = predictionText.matches;\n let lastIndex = 0;\n\n matches.sort((a, b) => a.startOffset - b.startOffset);\n\n const outerSpan = document.createElement(\"span\");\n const innerSpan = document.createElement(\"span\");\n innerSpan.classList = this.#options.classes.highlight ?? \"font-bold\";\n\n for (const match of matches) {\n outerSpan.textContent += originalText.substring(\n lastIndex,\n match.startOffset,\n );\n if (match.startOffset > 0) {\n const prevChar = originalText.charAt(match.startOffset - 1);\n if (prevChar === \" \") {\n innerSpan.textContent += \" \";\n }\n }\n innerSpan.textContent += originalText.substring(\n match.startOffset,\n match.endOffset,\n );\n lastIndex = match.endOffset;\n }\n\n outerSpan.appendChild(innerSpan);\n outerSpan.appendChild(\n document.createTextNode(originalText.substring(lastIndex)),\n );\n element.appendChild(outerSpan);\n }\n\n /**\n * Handles the selection of a place. Fetches required fields\n * (displayName, formattedAddress, addressComponents) and calls the\n * user-defined `onPacData` callback.\n * @param {google.maps.places.Place} place - The selected Place object.\n */\n async _onPlaceSelected(place) {\n let data = null;\n try {\n // Fetch necessary details for the selected place\n await place.fetchFields({\n fields: this.#fetchFields, //[\"displayName\", \"formattedAddress\", \"addressComponents\"], // Add more fields as needed\n });\n // Call the user-provided callback with the place data\n // Handle response_type option\n if (this.#options.response_type === \"place\") {\n data = place; // Return the Place instance\n this.#onDataCallback(place);\n } else {\n // eslint-disable-next-line no-undef\n data = place.toJSON(); // Convert to plain JSON object (default)\n this.#onDataCallback(data);\n }\n } catch (error) {\n console.error(\"Error fetching place details:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n } finally {\n // Reset the input and suggestions regardless of success/error\n this._reset(true, data); // Refresh token after selection\n }\n }\n\n /**\n * Creates a new Google Places Autocomplete Session Token.\n * This should be called before starting a new series of autocomplete requests.\n */\n _refreshToken() {\n try {\n // eslint-disable-next-line no-undef\n this.#request.sessionToken =\n new google.maps.places.AutocompleteSessionToken();\n } catch (error) {\n console.error(\"Error creating session token:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to be fetched for the selected place.\n * This allows you to specify which details you want to retrieve\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @param {Array<string>} fields - Array of field names to fetch.\n */\n setFetchFields(fields) {\n this._setFetchFields(fields);\n }\n /**\n * Gets the current fields that will be fetched for the selected place.\n * This is useful for understanding what details will be available\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @returns {Array<string>} The current fetch fields.\n */\n getFetchFields() {\n return this.#fetchFields;\n }\n\n /**\n * Sets the request parameters for the Places Autocomplete instance.\n * This method allows you to update the request parameters dynamically,\n * such as the input value, region codes, language, etc.\n * It merges the provided parameters with the default request parameters,\n * allowing you to override specific values while keeping the defaults intact.\n * This is useful for updating the search criteria without needing to recreate the instance.\n * @param {*} params\n */\n setRequestParams(params) {\n if (\n typeof params === \"object\" &&\n !Array.isArray(params) &&\n params !== null\n ) {\n // if params.input is provided, set it to the input element\n if (params.input && typeof params.input === \"string\") {\n this.#inputElement.value = params.input; // Set input value if provided\n }\n // Merge provided params with default request parameters\n // This allows overriding specific request parameters while keeping defaults\n this.#request = {\n ...this.#defaultRequestParams,\n ...params,\n };\n }\n }\n\n /**\n * Returns the current request parameters used by the Places Autocomplete instance.\n * This includes the input value, included region codes, language, and other settings.\n * It is useful for debugging or when you need to know the current search criteria.\n * @returns {Object} The current request parameters.\n */\n getRequestParams() {\n return this.#request;\n }\n\n /**\n * Sets the options for the Places Autocomplete instance.\n * This method allows you to change the appearance and behavior of the autocomplete widget,\n * such as classes, placeholder text, debounce time, etc.\n * It merges the provided options with the default options, allowing you to override specific values\n * while keeping the defaults intact.\n * This is useful for updating the widget's configuration without needing to recreate the instance.\n * @param {*} options\n */\n setOptions(options) {\n if (\n typeof options === \"object\" &&\n !Array.isArray(options) &&\n options !== null\n ) {\n this._detachEventListeners(); // Detach event listeners\n\n // // Ensure classes are deeply merged if user provides partial classes\n const tmpClasses = options.classes || {};\n delete options.classes; // Remove classes from options to avoid overwriting\n\n // Merge provided options with default options\n // This allows overriding specific options while keeping defaults\n this.#options = {\n ...this.#defaultOptions,\n ...options,\n };\n\n // Merge classes with defaults\n // This allows overriding specific classes while keeping defaults\n if (\n tmpClasses &&\n typeof tmpClasses === \"object\" &&\n Object.keys(tmpClasses).length > 0\n ) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...tmpClasses,\n };\n } else {\n this.#options.classes = { ...this.#defaultClasses }; // Use defaults if no classes provided\n }\n\n this._initialiseDebouncedRequest(); // Reinitialize the debounced request function\n this._createPACStructure(); // Recreate the structure with new options\n // Reattach the input event listener to the input element\n // This is necessary to ensure the new input element is ready for events\n if (this.#inputElement) {\n this._attachedEventListeners();\n } // Reinitialize the autocomplete functionality\n }\n }\n\n /**\n * Gets the current options used by the Places Autocomplete instance.\n * @returns {Object} The current options.\n */\n getOptions() {\n /**\n * Returns the current options used by the Places Autocomplete instance.\n * This includes classes, placeholder text, debounce time, and other settings.\n * It is useful for debugging or when you need to know the current configuration of the widget.\n * @returns {Object} The current options.\n */\n return this.#options;\n }\n\n /**\n * Sets the input value by reverse geocoding coordinates.\n * Performs reverse geocoding to convert lat/lng to a place, then triggers onResponse.\n * Requires the Geocoding API to be enabled in your Google Cloud Console project.\n * @param {number} latitude - Latitude coordinate\n * @param {number} longitude - Longitude coordinate\n * @returns {Promise<void>}\n */\n async setInputValue(latitude, longitude) {\n try {\n // Import the geocoding library\n const { Geocoder } = await google.maps.importLibrary(\"geocoding\");\n const geocoder = new Geocoder();\n\n // Perform reverse geocoding\n const response = await geocoder.geocode({\n location: { lat: latitude, lng: longitude },\n });\n\n if (response.results && response.results.length > 0) {\n const placeId = response.results[0].place_id;\n const place = new google.maps.places.Place({ id: placeId });\n\n // Fetch the configured fields\n await place.fetchFields({ fields: this.#fetchFields });\n\n // Update input field if clear_input is false\n if (!this.#options.clear_input && place.formattedAddress) {\n this.#inputElement.value = place.formattedAddress;\n }\n\n // Trigger the callback with appropriate response type\n if (this.#options.response_type === \"place\") {\n this.#onDataCallback(place);\n } else {\n this.#onDataCallback(place.toJSON());\n }\n } else {\n throw new Error(\"No results found for the provided coordinates\");\n }\n } catch (error) {\n console.error(\"Error in setInputValue:\", error);\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Clears the autocomplete input field and suggestions list.\n * This method resets the state of the autocomplete widget,\n * allowing the user to start a new search without any previous input or suggestions.\n * It also refreshes the Google Places session token to ensure a new session.\n * @returns {void}\n */\n clear() {\n this.#cache.clear();\n this._reset(true);\n }\n\n /**\n * Sets focus on the autocomplete input field.\n * This method allows programmatic control of the input focus,\n * useful for improving user experience and accessibility.\n * @returns {void}\n */\n focus() {\n if (this.#inputElement) {\n this.#inputElement.focus();\n }\n }\n\n /**\n * Destroys the PacAutocomplete instance.\n * Removes event listeners, clears the DOM, and nullifies properties.\n * This method should be called when the autocomplete widget is no longer needed.\n * It ensures that all resources are cleaned up to prevent memory leaks.\n * @returns {void}\n */\n destroy() {\n // Remove event listeners, remove elements from DOM\n this._detachEventListeners(); // Detach event listeners\n // Nullify properties\n this.#containerId = null;\n this.#pacEl = null;\n this.#googleMapsApiKey = null;\n this.#googleMapsApiVersion = null;\n this.#options = null;\n this.#request = null;\n this.#inputElement = null;\n this.#container = null;\n this.#ul = null;\n this.#ariaStatus = null;\n this.#cache = null;\n this.#kbdEscape = null;\n this.#kbdUp = null;\n this.#kbdDown = null;\n this.#allSuggestions = null;\n this.#currentSuggestion = -1;\n this.#onDataCallback = null;\n this.#onErrorCallback = null;\n this.#debouncedMakeAcRequest = null;\n }\n}\n"],"mappings":"0RAAA,IAAa,EAAuB,CAElC,WAAY,aACZ,WAAY,aACZ,YAAa,aACb,kCAAmC,aACnC,QAAS,aACT,QAAS,UACT,YAAa,YACb,cAAe,gBACf,eAAgB,iBAChB,WAAY,YACZ,eAAgB,YAGhB,WAAY,iBACZ,KAAM,iBACN,YAAa,iBACb,IAAK,iBACL,IAAK,iBACL,WAAY,iBACZ,OAAQ,iBACR,qBAAsB,iBACtB,eAAgB,iBAChB,iBAAkB,iBAClB,YAAa,iBACb,iBAAkB,iBAGlB,MAAO,UACP,OAAQ,UACR,MAAO,UACP,aAAc,UACd,kBAAmB,UACnB,WAAY,UACZ,QAAS,UACT,QAAS,UACT,QAAS,UACT,IAAK,UACL,YAAa,UAGb,mBAAoB,cACpB,OAAQ,cACR,YAAa,cACb,kBAAmB,cACnB,oBAAqB,cACrB,SAAU,cACV,wBAAyB,cACzB,SAAU,cACV,IAAK,cACL,eAAgB,cAChB,YAAa,cACb,SAAU,cACV,iBAAkB,cAGlB,KAAM,aACN,cAAe,aACf,WAAY,aACZ,MAAO,aACP,YAAa,aACb,eAAgB,aAChB,WAAY,aACZ,iBAAkB,aAClB,YAAa,aACb,IAAK,aACL,gBAAiB,aAGjB,cAAe,WACf,YAAa,WACb,cAAe,WACf,eAAgB,WAChB,kBAAmB,WACnB,cAAe,WACf,UAAW,WACX,gBAAiB,WAGjB,SAAU,SACV,SAAU,SACV,IAAK,UACL,KAAM,UACN,YAAa,WACb,OAAQ,WAGR,aAAc,eACd,YAAa,eAGb,MAAO,aACP,eAAgB,aAChB,aAAc,aAGd,SAAU,OACV,4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SAAW,EAAS,QAAQ,OAAS,EAAG,CACnD,IAAM,EAAU,EAAS,QAAQ,GAAG,SAC9B,EAAQ,IAAI,OAAO,KAAK,OAAO,MAAM,CAAE,GAAI,EAAS,CAAC,CAG3D,MAAM,EAAM,YAAY,CAAE,OAAQ,MAAA,EAAmB,CAAC,CAGlD,CAAC,MAAA,EAAc,aAAe,EAAM,mBACtC,MAAA,EAAmB,MAAQ,EAAM,kBAI/B,MAAA,EAAc,gBAAkB,QAClC,MAAA,EAAqB,EAAM,CAE3B,MAAA,EAAqB,EAAM,QAAQ,CAAC,MAGtC,MAAU,MAAM,gDAAgD,OAE3D,EAAO,CACd,QAAQ,MAAM,0BAA2B,EAAM,CAC/C,MAAA,EAAsB,EAAM,EAWhC,OAAQ,CACN,MAAA,EAAY,OAAO,CACnB,KAAK,OAAO,GAAK,CASnB,OAAQ,CACF,MAAA,GACF,MAAA,EAAmB,OAAO,CAW9B,SAAU,CAER,KAAK,uBAAuB,CAE5B,MAAA,EAAoB,KACpB,MAAA,EAAc,KACd,MAAA,EAAyB,KACzB,MAAA,EAA6B,KAC7B,MAAA,EAAgB,KAChB,MAAA,EAAgB,KAChB,MAAA,EAAqB,KACrB,MAAA,EAAkB,KAClB,MAAA,EAAW,KACX,MAAA,EAAmB,KACnB,MAAA,EAAc,KACd,MAAA,EAAkB,KAClB,MAAA,EAAc,KACd,MAAA,EAAgB,KAChB,MAAA,EAAuB,KACvB,MAAA,EAA0B,GAC1B,MAAA,EAAuB,KACvB,MAAA,EAAwB,KACxB,MAAA,EAA+B"}
|
|
1
|
+
{"version":3,"file":"places-autocomplete.umd.cjs","names":["#containerId","#pacEl","#googleMapsApiKey","#googleMapsApiVersion","#options","#defaultOptions","#defaultClasses","#onDataCallback","#onErrorCallback","#request","#defaultRequestParams","#debouncedMakeAcRequest","#inputElement","#cache","#ul","#ariaStatus","#fetchFields","#defaultFetchFields","#container","#kbdEscape","#kbdUp","#kbdDown","#allSuggestions","#currentSuggestion"],"sources":["../constants.js","../PlacesAutocomplete.js"],"sourcesContent":["export const ITINERARY_CATEGORIES = {\n // --- TRANSPORT & AUTO ---\n car_rental: \"Automotive\",\n car_dealer: \"Automotive\",\n gas_station: \"Automotive\",\n electric_vehicle_charging_station: \"Automotive\",\n parking: \"Automotive\",\n airport: \"Airport\",\n bus_station: \"Transport\",\n train_station: \"Train Station\",\n subway_station: \"Subway Station\",\n taxi_stand: \"Transport\",\n ferry_terminal: \"Transport\",\n\n // --- DINING & NIGHTLIFE ---\n restaurant: \"Food and Drink\",\n cafe: \"Food and Drink\",\n coffee_shop: \"Food and Drink\",\n bar: \"Food and Drink\",\n pub: \"Food and Drink\",\n night_club: \"Food and Drink\",\n bakery: \"Food and Drink\",\n fast_food_restaurant: \"Food and Drink\",\n ice_cream_shop: \"Food and Drink\",\n pizza_restaurant: \"Food and Drink\",\n steak_house: \"Food and Drink\",\n sushi_restaurant: \"Food and Drink\",\n\n // --- LODGING ---\n hotel: \"Lodging\",\n hostel: \"Lodging\",\n motel: \"Lodging\",\n resort_hotel: \"Lodging\",\n bed_and_breakfast: \"Lodging\",\n campground: \"Lodging\",\n rv_park: \"Lodging\",\n lodging: \"Lodging\",\n cottage: \"Lodging\",\n inn: \"Lodging\",\n guest_house: \"Lodging\",\n\n // --- SIGHTSEEING & CULTURE ---\n tourist_attraction: \"Sightseeing\",\n museum: \"Sightseeing\",\n art_gallery: \"Sightseeing\",\n cultural_landmark: \"Sightseeing\",\n historical_landmark: \"Sightseeing\",\n monument: \"Sightseeing\",\n performing_arts_theater: \"Sightseeing\",\n aquarium: \"Sightseeing\",\n zoo: \"Sightseeing\",\n visitor_center: \"Sightseeing\",\n town_square: \"Sightseeing\",\n landmark: \"Sightseeing\",\n place_of_worship: \"Sightseeing\",\n\n // --- RECREATION & PARKS ---\n park: \"Recreation\",\n national_park: \"Recreation\",\n state_park: \"Recreation\",\n beach: \"Recreation\",\n hiking_area: \"Recreation\",\n amusement_park: \"Recreation\",\n water_park: \"Recreation\",\n botanical_garden: \"Recreation\",\n golf_course: \"Recreation\",\n gym: \"Recreation\",\n natural_feature: \"Recreation\",\n\n // --- SHOPPING ---\n shopping_mall: \"Shopping\",\n supermarket: \"Shopping\",\n grocery_store: \"Shopping\",\n clothing_store: \"Shopping\",\n electronics_store: \"Shopping\",\n souvenir_shop: \"Shopping\",\n gift_shop: \"Shopping\",\n duty_free_store: \"Shopping\",\n\n // --- ESSENTIAL SERVICES ---\n hospital: \"Health\",\n pharmacy: \"Health\",\n atm: \"Finance\",\n bank: \"Finance\",\n post_office: \"Services\",\n police: \"Services\",\n\n // --- GEOGRAPHICAL ---\n neighborhood: \"Geographical\",\n sublocality: \"Geographical\",\n\n // --- NAVIGATION ---\n route: \"Navigation\",\n street_address: \"Navigation\",\n intersection: \"Navigation\",\n\n // -- CITY --\n locality: \"City\",\n administrative_area_level_4: \"City\",\n country: \"Country\",\n administrative_area_level_1: \"City\",\n administrative_area_level_2: \"City\",\n administrative_area_level_3: \"City\",\n administrative_area_level_5: \"City\",\n sublocality_level_1: \"Neighborhood\",\n sublocality_level_2: \"Neighborhood\",\n sublocality_level_3: \"Neighborhood\",\n sublocality_level_4: \"Neighborhood\",\n sublocality_level_5: \"Neighborhood\",\n\n // --- DEFAULT ---\n default: \"Default\",\n};\n\nexport const ITINERARY_SVG_ICONS = {\n Distance:\n '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-route-icon lucide-route\"><circle cx=\"6\" cy=\"19\" r=\"3\"/><path d=\"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15\"/><circle cx=\"18\" cy=\"5\" r=\"3\"/></svg>',\n\n Automotive: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2\"/><circle cx=\"7\" cy=\"17\" r=\"2\"/><path d=\"M9 17h6\"/><circle cx=\"17\" cy=\"17\" r=\"2\"/></svg>`,\n\n Transport: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z\"/></svg>`,\n\n \"Food and Drink\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2\"/><path d=\"M7 2v20\"/><path d=\"M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7\"/></svg>`,\n\n Lodging: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2 4v16\"/><path d=\"M2 8h18a2 2 0 0 1 2 2v10\"/><path d=\"M2 17h20\"/><path d=\"M6 8v9\"/></svg>`,\n\n Sightseeing: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-binoculars-icon lucide-binoculars\"><path d=\"M10 10h4\"/><path d=\"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3\"/><path d=\"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z\"/><path d=\"M 22 16 L 2 16\"/><path d=\"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z\"/><path d=\"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3\"/></svg>`,\n\n Recreation: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-kayak-icon lucide-kayak\"><path d=\"M18 17a1 1 0 0 0-1 1v1a2 2 0 1 0 2-2z\"/><path d=\"M20.97 3.61a.45.45 0 0 0-.58-.58C10.2 6.6 6.6 10.2 3.03 20.39a.45.45 0 0 0 .58.58C13.8 17.4 17.4 13.8 20.97 3.61\"/><path d=\"m6.707 6.707 10.586 10.586\"/><path d=\"M7 5a2 2 0 1 0-2 2h1a1 1 0 0 0 1-1z\"/></svg>`,\n\n Shopping: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z\"/><path d=\"M3 6h18\"/><path d=\"M16 10a4 4 0 0 1-8 0\"/></svg>`,\n\n Health: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 7v4\"/><path d=\"M14 21v-3a2 2 0 0 0-4 0v3\"/><path d=\"M14 9h-4\"/><path d=\"M18 11h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2\"/><path d=\"M18 21V5a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16\"/></svg>`,\n\n Finance: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect width=\"20\" height=\"14\" x=\"2\" y=\"5\" rx=\"2\"/><line x1=\"2\" y1=\"10\" x2=\"22\" y2=\"10\"/></svg>`,\n\n Geographical: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"m20 20-6-10.6c-.4-.7-1.5-.7-1.9 0L6 20\"/><path d=\"M7 16h10\"/><path d=\"M12 4a8 8 0 0 1 8 8v2a2 2 0 0 1-2 2h-1\"/><path d=\"M7 16H6a2 2 0 0 1-2-2v-2a8 8 0 0 1 8-8\"/></svg>`,\n\n Navigation: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-navigation-icon lucide-navigation\"><polygon points=\"3 11 22 2 13 21 11 13 3 11\"/></svg>`,\n\n City: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-building2-icon lucide-building-2\"><path d=\"M10 12h4\"/><path d=\"M10 8h4\"/><path d=\"M14 21v-3a2 2 0 0 0-4 0v3\"/><path d=\"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2\"/><path d=\"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16\"/></svg>`,\n\n District: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-land-plot-icon lucide-land-plot\"><path d=\"m12 8 6-3-6-3v10\"/><path d=\"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12\"/><path d=\"m6.49 12.85 11.02 6.3\"/><path d=\"M17.51 12.85 6.5 19.15\"/></svg>`,\n\n Airport: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-plane-icon lucide-plane\"><path d=\"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z\"/></svg>`,\n\n \"Subway Station\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-subway-icon lucide-subway\"><path d=\"M12 22a10 10 0 0 0 10-10V8l-5-5H7L2 8v4a10 10 0 0 0 10 10Z\"/><path d=\"M12 22V8\"/><path d=\"M7 13h10\"/><path d=\"M7 17h10\"/></svg>`,\n\n \"Train Station\": `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-train-icon lucide-train\"><path d=\"M2 10h20\"/><path d=\"M2 10a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5Z\"/><circle cx=\"7\" cy=\"15\" r=\"2\"/><circle cx=\"17\" cy=\"15\" r=\"2\"/></svg>`,\n\n Default: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" style=\"display:inline-block\"; viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z\"/><circle cx=\"12\" cy=\"10\" r=\"3\"/></svg>`,\n};\n","import \"./places-autocomplete.css\";\nimport { ITINERARY_CATEGORIES, ITINERARY_SVG_ICONS } from \"./constants.js\";\n\n/**\n * A flexible and customisable Places Autocomplete widget powered by the Google Maps Places API.\n *\n * Features:\n * - Dynamic Google Maps API loading\n * - Debounced input for optimized API requests\n * - Keyboard navigation (Arrow keys, Enter, Escape)\n * - Session token management for cost-effective API usage\n * - Customizable styling and behavior\n *\n * @author Alexander Pechkarev <alexpechkarev@gmail.com>\n * @license MIT\n */\nexport class PlacesAutocomplete {\n // --- Private Properties (using # or _ prefix by convention) ---\n #containerId; // Container ID where the autocomplete widget will be rendered.\n #pacEl;\n #googleMapsApiKey;\n #googleMapsApiVersion;\n #options;\n #request;\n #inputElement;\n #container;\n #ul;\n #ariaStatus; // For screen reader announcements\n #cache = new Map(); // Simple cache for suggestions\n #kbdEscape;\n #kbdUp;\n #kbdDown;\n #allSuggestions = [];\n #currentSuggestion = -1;\n #onDataCallback; // For user-provided data callback\n #onErrorCallback; // For user-provided error callback\n #debouncedMakeAcRequest; // Declare without initializing here\n #defaultOptions = {\n // Default options for the autocomplete widget.\n autofocus: false, // Automatically focus the input on load.\n autocomplete: \"off\", // HTML autocomplete attribute for the input.\n placeholder: \"Start typing your address ...\", // Placeholder text for the input.\n distance: false, // Show distance in suggestions (requires origin in request).\n distance_units: \"km\", // Units for distance ('km' or 'miles').\n label: \"\", // Optional label text above the input.\n debounce: 100, // Debounce delay (ms) for API requests.\n clear_input: false, // Clear input .\n debug: false, // Enable debug mode (not implemented in this version).\n response_type: \"json\", // Return format: 'json' for JSON object, 'place' for Google Maps Place instance.\n show_place_type: false, // Display place type icons (mutually exclusive with distance).\n };\n #defaultClasses = {\n // CSS classes for various parts of the widget.\n section: \"pac-section\", // Outer section container.\n container: \"pac-container\", // Main container div.\n icon_container: \"pac-icon-container\", // Container for the search icon.\n icon: '<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"pac-w-5 pac-h-5\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\" /><path d=\"m21 21-4.3-4.3\" /></svg>', // SVG for the search icon.\n input: \"pac-input\", // Input field.\n kbd_container: \"pac-kbd-container\", // Container for keyboard hints.\n kbd_escape: \"pac-kbd-escape\", // Escape key hint.\n kbd_up: \"pac-kbd-up\", // Up arrow key hint.\n kbd_down: \"pac-kbd-down\", // Down arrow key hint.\n kbd_active: \"pac-kbd-active\", // Class for active keyboard hint.\n ul: \"pac-ul\", // Suggestions list (ul).\n li: \"pac-li\", // Suggestion item (li).\n li_current: \"pac-li-current\", // Class for the currently selected suggestion item.\n li_button: \"pac-li-button\", // Link element within a suggestion item.\n li_button_current: \"pac-li-button-current\", // Class for the link in the currently selected suggestion item.\n li_div_container: \"pac-li-div-container\", // Container div within the suggestion link.\n li_div_p_container: \"pac-li-div-p-container\",\n li_div_one: \"pac-li-div-one\", // First inner div (for place name).\n li_div_one_p: \"pac-li-div-one-p\", // Paragraph for the place name.\n map_icon_svg: \"pac-map-icon-svg\",\n map_pin_icon:\n '<path d=\"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\"/><circle cx=\"12\" cy=\"10\" r=\"3\"/>',\n li_div_one_p_secondaryText: \"pac-li-div-one-p-secondaryText\",\n li_div_two: \"pac-li-div-two\", // Second inner div (for distance).\n li_div_two_p: \"pac-li-div-two-p\", // Paragraph for the distance.\n li_div_two_p_place_type: \"pac-li-div-two-p-place_type\", // Container for place type display.\n li_div_two_p_place_type_item: \"pac-li-div-two-p-place_type-item\", // Wrapper for individual options within the place type container.\n li_div_two_p_place_type_icon: \"pac-li-div-two-p-place_type-icon\", // The place type icon element.\n li_div_two_p_place_type_label: \"pac-li-div-two-p-place_type-label\", // The place type label text.\n highlight: \"pac-highlight\", // Class for highlighting matched text in suggestions.\n };\n #defaultRequestParams = {\n // Default parameters for the autocomplete request.\n input: \"\", // Initial input value (empty).\n includedRegionCodes: [\"GB\"], // Default region codes to include in suggestions.\n language: \"en-gb\",\n // region: \"GB\",\n };\n #fetchFields = [\"formattedAddress\", \"addressComponents\"];\n #defaultFetchFields = [\"formattedAddress\", \"addressComponents\"]; // Fields to fetch for the selected place (can be extended).\n\n /**\n * Class constructor for PacAutocomplete.\n * Initializes the autocomplete widget with the provided configuration.\n * @param {Object} config - Configuration object for the autocomplete widget.\n * @param {string} config.containerId - ID of the container element for the widget.\n * @param {string} config.googleMapsApiKey - Google Maps API key.\n * @param {string} [config.googleMapsApiVersion] - Version of the Google Maps API to use (default: \"weekly\").\n * @param {Object} [config.options] - Additional options for the widget (e.g., classes, callbacks).\n * @param {Object} [config.requestParams] - Parameters for the autocomplete request (e.g., input, region).\n * @param {*} config\n */\n constructor(config) {\n if (!config || !config.containerId || !config.googleMapsApiKey) {\n throw new Error(\n \"PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).\",\n );\n }\n\n this.#containerId = config.containerId; // Store the configuration object\n this.#pacEl = document.getElementById(config.containerId);\n if (!this.#pacEl) {\n throw new Error(\n `PacAutocomplete: Container element with ID \"${config.containerId}\" not found.`,\n );\n }\n\n this.#googleMapsApiKey = config.googleMapsApiKey;\n this.#googleMapsApiVersion = config.googleMapsApiVersion || \"weekly\";\n\n // Merge user options with defaults\n this.#options = {\n ...this.#defaultOptions, // Default options\n ...config.options, // User-defined options override defaults\n };\n // Ensure classes are deeply merged if user provides partial classes\n if (config.options && config.options.classes) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...config.options.classes,\n };\n } else {\n this.#options.classes = this.#defaultClasses; // Use default classes if none provided\n }\n\n if (this.#options.debug) {\n console.log(\"___debug constructor options:\");\n console.log(this.#options);\n }\n\n if (config.fetchFields && Array.isArray(config.fetchFields)) {\n this._setFetchFields(config.fetchFields); // Set fetch fields from user config\n }\n\n // Set default response and error callbacks if not provided\n this.#onDataCallback =\n config.onResponse ||\n ((place) => {\n console.info(\"---------Default onResponse not provided---------\");\n console.info(\"Selected Place:\", JSON.stringify(place, null, 2));\n });\n this.#onErrorCallback =\n config.onError ||\n ((error) => {\n console.error(\"---------Default onError not provided---------\");\n console.error(\"PAC Error:\", error);\n });\n\n if (config.requestParams && Object.keys(config.requestParams).length > 0) {\n this.#request = {\n ...this.#defaultRequestParams,\n ...config.requestParams,\n };\n } else {\n this.#request = { ...this.#defaultRequestParams }; // Use defaults if no requestParams provided\n }\n\n if (this.#options.debug) {\n console.log(\"___debug constructor requestParams:\", this.#request);\n }\n\n this._initialiseDebouncedRequest(); // Initialize the debounced request function\n\n this._init(); // Underscore prefix for internal initialization method\n }\n\n // --- Private Initialization Method ---\n async _init() {\n try {\n // check if google maps api is already loaded\n if (typeof google === \"undefined\" || !google.maps) {\n // Load the Google Maps API dynamically\n await this._loadGoogleMapsApi({\n key: this.#googleMapsApiKey,\n v: this.#googleMapsApiVersion,\n });\n }\n this._createPACStructure();\n await this._initializeAutocomplete();\n } catch (error) {\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Initializes the debounced request function for fetching autocomplete suggestions.\n * This function is called on initialization and when options are updated.\n *\n * @private\n */\n _initialiseDebouncedRequest() {\n this.#debouncedMakeAcRequest = this._debounce(async () => {\n const query = this.#inputElement?.value;\n if (!query) {\n this._reset();\n if (this.#inputElement)\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n return;\n }\n\n // Check cache\n if (this.#cache.has(query)) {\n await this._renderSuggestions(this.#cache.get(query));\n return;\n }\n\n this.#request.input = query;\n\n try {\n const { suggestions } =\n // eslint-disable-next-line no-undef\n await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(\n this.#request,\n );\n\n // Cache and display suggestions\n if (suggestions && suggestions.length > 0) {\n this.#cache.set(query, suggestions);\n await this._renderSuggestions(suggestions);\n } else {\n // No suggestions found\n this._reset(); // Clear any old suggestions\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this._announceStatus(\"No suggestions found.\");\n }\n } catch (error) {\n this.#onErrorCallback(error);\n this._reset();\n }\n }, this.#options.debounce); // Default debounce to 100ms if not set\n }\n\n /**\n * Renders the suggestions list.\n * @private\n */\n async _renderSuggestions(suggestions) {\n const suggestionElements = await Promise.all(\n this._createSuggestionElements(suggestions),\n );\n this.#ul.replaceChildren(...suggestionElements);\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n this._announceStatus(`${suggestions.length} suggestions found.`);\n }\n\n /**\n * Announces a message to screen readers using aria-live.\n * @private\n */\n _announceStatus(message) {\n if (this.#ariaStatus) {\n this.#ariaStatus.textContent = message;\n }\n }\n\n /**\n * Sets the fields to fetch for the selected place.\n * @param {Array<string>} fields - The fields to fetch.\n */\n _setFetchFields(fields) {\n if (Array.isArray(fields) && fields.length > 0) {\n this.#fetchFields = [\n ...new Set([...this.#defaultFetchFields, ...fields]),\n ].filter((e) => e); // Ensure unique and non-empty fields\n }\n }\n\n /**\n * Creates a debounced version of a function.\n *\n * @private\n * @param {Function} func - The function to debounce\n * @param {number} wait - Delay in milliseconds\n * @returns {Function} Debounced function\n */\n _debounce(func, wait) {\n let timeout = null;\n return function executedFunction(...args) {\n const later = () => {\n timeout = null;\n func(...args); // Call original function\n };\n if (timeout !== null) {\n clearTimeout(timeout); // Clear the previous timeout\n }\n timeout = setTimeout(later, wait ?? 100); // Set the new timeout\n };\n }\n /**\n * Formats a distance value from meters to the specified unit.\n *\n * @private\n * @param {number|null|undefined} distance - Distance in meters\n * @param {('km'|'miles')} units - Target unit for conversion\n * @returns {string|null} Formatted distance string or null if invalid\n */\n _formatDistance(distance, units) {\n if (!this.#options.distance) {\n return null;\n }\n if (typeof distance !== \"number\") {\n return null;\n }\n let value;\n let unitLabel;\n if (units === \"km\") {\n value = (distance / 1000).toFixed(2);\n unitLabel = \"km\";\n } else {\n // Default to miles if not 'km'\n value = (distance / 1609.34).toFixed(2);\n unitLabel = \"miles\";\n }\n // Avoid showing \".00\"\n value = value.replace(/\\.00$/, \"\");\n return `${value} ${unitLabel}`;\n }\n\n /**\n * Dynamically loads the Google Maps JavaScript API using the importLibrary method.\n * This is the standard approach recommended by Google.\n * @see https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n * @param {object} g - Configuration object for the API loader (key, v, libraries, etc.).\n */\n async _loadGoogleMapsApi(g) {\n var h, // Promise tracking API load\n a, // Script element\n k, // Loop variable for config keys\n p = \"The Google Maps JavaScript API\", // Error message prefix\n c = \"google\", // Global namespace\n l = \"importLibrary\", // Loader function name\n q = \"__ib__\", // Internal callback name\n m = document, // Document reference\n b = window; // Window reference\n b = b[c] || (b[c] = {}); // Ensure google namespace exists\n var d = b.maps || (b.maps = {}), // Ensure google.maps namespace exists\n r = new Set(), // Set to track requested libraries\n e = new URLSearchParams(), // URL parameters for the API script\n u = () =>\n // Function to initiate API loading (if not already started)\n h ||\n // eslint-disable-next-line no-async-promise-executor\n (h = new Promise(async (f, n) => {\n // Create script element (done async to potentially wait for nonce)\n // await (a = m.createElement('script')); // Original Google code had await here, might not be needed\n a = m.createElement(\"script\"); // Create script tag\n e.set(\"libraries\", [...r].join(\",\")); // Add accumulated libraries\n // Add other parameters from the config object 'g'\n for (k in g)\n e.set(\n k.replace(/[A-Z]/g, (t) => \"_\" + t[0].toLowerCase()), // Convert camelCase to snake_case\n g[k],\n );\n e.set(\"callback\", c + \".maps.\" + q); // Set the internal callback function name\n a.src = `https://maps.${c}apis.com/maps/api/js?` + e; // Construct the API URL\n d[q] = f; // Assign the promise resolver to the callback name on google.maps\n // Error handling for script loading failure\n a.onerror = () =>\n (h = n(\n new Error(\n `${p} could not load. Check your API key and network connection.`,\n ),\n )); // Use onerror for load failures\n // Nonce for Content Security Policy\n a.nonce = m.querySelector(\"script[nonce]\")?.nonce || \"\";\n m.head.append(a); // Append the script to the document head\n }));\n // Define or reuse the importLibrary function on google.maps\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n d[l]\n ? console.warn(p + \" only loads once. Ignoring:\", g) // Warn if called again\n : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n))); // The actual importLibrary implementation\n }\n\n // --- UI Creation ---\n _createPACStructure() {\n const section = document.createElement(\"section\");\n section.className = this.#options.classes.section;\n\n // Main container\n this.#container = document.createElement(\"div\");\n this.#container.className = this.#options.classes.container;\n this.#container.setAttribute(\"id\", this.#containerId + \"-div\");\n section.appendChild(this.#container);\n\n // Live region for a11y status updates\n this.#ariaStatus = document.createElement(\"div\");\n this.#ariaStatus.setAttribute(\"aria-live\", \"polite\");\n this.#ariaStatus.setAttribute(\"role\", \"status\");\n this.#ariaStatus.className = \"pac-sr-only\"; // Screen reader only\n this.#container.appendChild(this.#ariaStatus);\n\n // Icon\n const iconContainer = document.createElement(\"div\");\n iconContainer.className = this.#options.classes.icon_container;\n this.#container.appendChild(iconContainer);\n const icon = document.createElement(\"div\");\n icon.innerHTML = this.#options.classes.icon;\n iconContainer.appendChild(icon.firstElementChild); // Append the actual SVG element\n\n // Input field\n this.#inputElement = document.createElement(\"input\");\n this.#inputElement.id = this.#containerId + \"-input\"; // Assign ID for label association\n this.#inputElement.type = \"text\";\n this.#inputElement.name = \"search\"; // Consider making name configurable\n this.#inputElement.placeholder = this.#options.placeholder;\n this.#inputElement.autocomplete = this.#options.autocomplete;\n this.#inputElement.className = this.#options.classes.input;\n this.#inputElement.setAttribute(\"role\", \"combobox\");\n this.#inputElement.setAttribute(\"aria-autocomplete\", \"list\");\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\"); // Will be updated dynamically\n this.#inputElement.setAttribute(\"aria-controls\", \"pacSuggestions\"); // Links to the suggestions list\n this.#inputElement.setAttribute(\"aria-activedescendant\", \"\"); // Will be updated dynamically\n\n if (this.#options.autofocus) {\n this.#inputElement.autofocus = true;\n }\n if (this.#options.label) {\n const label = document.createElement(\"label\");\n label.htmlFor = this.#inputElement.id; // Correctly link label to input by ID\n label.textContent = this.#options.label;\n // Add label classes if needed from opts.classes\n section.prepend(label); // Append label before input or adjust structure\n }\n this.#container.appendChild(this.#inputElement);\n\n // Keyboard hints container\n const kbdContainer = document.createElement(\"div\");\n kbdContainer.className = this.#options.classes.kbd_container;\n this.#kbdEscape = document.createElement(\"kbd\");\n this.#kbdEscape.className = this.#options.classes.kbd_escape;\n this.#kbdEscape.textContent = \"Esc\";\n kbdContainer.appendChild(this.#kbdEscape);\n this.#kbdUp = document.createElement(\"kbd\");\n this.#kbdUp.className = this.#options.classes.kbd_up;\n this.#kbdUp.innerHTML = \"↑\"; // Up arrow HTML entity\n kbdContainer.appendChild(this.#kbdUp);\n this.#kbdDown = document.createElement(\"kbd\");\n this.#kbdDown.className = this.#options.classes.kbd_down;\n this.#kbdDown.innerHTML = \"↓\"; // Down arrow HTML entity\n kbdContainer.appendChild(this.#kbdDown);\n this.#container.appendChild(kbdContainer);\n\n // Suggestions list (initially hidden)\n this.#ul = document.createElement(\"ul\");\n this.#ul.id = \"pacSuggestions\"; // Must match aria-controls\n this.#ul.className = this.#options.classes.ul;\n this.#ul.style.display = \"none\";\n this.#ul.setAttribute(\"role\", \"listbox\");\n this.#ul.setAttribute(\"aria-labelledby\", this.#inputElement.id); // Link listbox to input for accessibility\n this.#container.appendChild(this.#ul);\n\n // Event Delegation for suggestion selection\n this.#ul.addEventListener(\"click\", (e) => {\n const li = e.target.closest(\"li\");\n if (li && this.#ul.contains(li)) {\n const index = Array.from(this.#ul.children).indexOf(li);\n if (index !== -1 && this.#allSuggestions[index]) {\n this._onPlaceSelected(this.#allSuggestions[index].place);\n }\n }\n });\n\n this.#pacEl.appendChild(section);\n section.addEventListener(\"keydown\", this._onKeyDown.bind(this)); // Bind 'this'\n }\n\n /**\n * Attaches event listeners to the input element for handling user input.\n * This includes debounced input handling, focus/blur events, and keyboard navigation.\n */\n _attachedEventListeners() {\n this.#inputElement.addEventListener(\"input\", this.#debouncedMakeAcRequest);\n // Add focus/blur listeners if needed to manage suggestion visibility\n this.#inputElement.addEventListener(\"blur\", () => {\n // Delay hiding suggestions to allow click events on them\n setTimeout(() => {\n if (this.#ul && !this.#ul.contains(document.activeElement)) {\n // Check if focus moved outside suggestions\n this.#ul.style.display = \"none\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, 200); // Adjust delay as needed\n });\n this.#inputElement.addEventListener(\"focus\", () => {\n // Potentially show suggestions again if input has value\n if (this.#inputElement.value && this.#allSuggestions.length > 0) {\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n }\n });\n }\n\n _detachEventListeners() {\n // Remove event listeners, remove elements from DOM\n if (this.#inputElement) {\n this.#inputElement.removeEventListener(\n \"input\",\n this.#debouncedMakeAcRequest,\n );\n // remove other listeners\n }\n if (this.#pacEl && this.#container) {\n this.#pacEl.removeChild(this.#container.parentElement); // remove the whole section\n }\n }\n\n /**\n * Initializes the core autocomplete functionality after the API is loaded.\n * Imports necessary libraries and sets up the input event listener.\n */\n async _initializeAutocomplete() {\n try {\n // Ensure the 'places' library is available via the dynamic loader\n // eslint-disable-next-line no-undef\n await google.maps.importLibrary(\"places\");\n // console.log('Places library imported successfully.'); // For debugging\n\n // Initial token generation\n this._refreshToken();\n\n // Attach the debounced request function to the input element's 'input' event\n if (this.#inputElement) {\n this._attachedEventListeners();\n } else {\n this.#onErrorCallback(\n new Error(\"Input element not found during initialization.\"),\n );\n }\n } catch (error) {\n console.error(\"Error initializing Google Places Autocomplete:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(\n new Error(\"Google Maps Places library not available.\"),\n );\n }\n }\n\n /**\n * Resets the autocomplete input field, clears suggestions, and optionally refreshes the session token.\n * @param {boolean} [refresh=false] - Whether to refresh the Google Places session token.\n */\n _reset(refresh = false, placeData = null) {\n this.#currentSuggestion = -1;\n\n /**\n * If the input element exists and clear_input is false, set its value to the formatted address\n * from placeData. Otherwise, clear the input value.\n * This allows the user to keep the input value if they selected a place,\n * but still allows clearing it if clear_input is true or placeData is not provided.\n * @type {HTMLInputElement}\n * @property {string} value - The value of the input element.\n * @property {boolean} clear_input - Whether to clear the input value after selection.\n * @property {Object} placeData - The data of the selected place, containing formattedAddress.\n */\n if (\n this.#inputElement &&\n this.#options.clear_input == false &&\n placeData &&\n placeData.formattedAddress\n ) {\n this.#inputElement.value = placeData.formattedAddress; // Set input value to formatted address\n } else if (this.#inputElement) {\n this.#inputElement.value = \"\";\n }\n\n if (this.#inputElement) {\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this.#inputElement.setAttribute(\"aria-activedescendant\", \"\"); // Clear aria-activedescendant\n this.#inputElement.blur();\n }\n\n this.#allSuggestions = [];\n this.#currentSuggestion = -1;\n if (this.#ul) {\n this.#ul.innerHTML = \"\"; // Clear existing suggestions\n this.#ul.style.display = \"none\";\n }\n if (refresh) {\n this._refreshToken();\n }\n }\n /**\n * Removes the 'current' highlighting classes from all suggestion list items (li) and their links (a).\n */\n _resetLiClasses() {\n if (!this.#ul) return;\n Array.from(this.#ul.children).forEach((li) => {\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => li.classList.remove(cl));\n const link = li.querySelector(\"button\");\n if (link) {\n this.#options.classes.li_button_current\n .split(\" \")\n .forEach((cl) => link.classList.remove(cl));\n }\n });\n }\n\n /**\n * Handles keyboard events (ArrowDown, ArrowUp, Enter, Escape) for navigating\n * and selecting suggestions or closing the list.\n * @param {KeyboardEvent} e - The keyboard event object.\n */\n _onKeyDown(e) {\n this._resetLiClasses(); // Reset classes on any key press within the suggestions\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.remove(cl)),\n 300,\n );\n\n this._reset(true); // Reset search input and results, refresh token\n }\n\n if (\n !this.#allSuggestions.length ||\n !this.#ul ||\n this.#ul.style.display === \"none\"\n )\n return;\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.min(\n this.#currentSuggestion + 1,\n this.#allSuggestions.length - 1,\n );\n this._highlightSuggestion();\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.max(this.#currentSuggestion - 1, 0); // Stay at 0 if already there\n this._highlightSuggestion();\n } else if (e.key === \"Home\") {\n e.preventDefault();\n this.#currentSuggestion = 0;\n this._highlightSuggestion();\n } else if (e.key === \"End\") {\n e.preventDefault();\n this.#currentSuggestion = this.#allSuggestions.length - 1;\n this._highlightSuggestion();\n } else if (e.key === \"Enter\") {\n e.preventDefault(); // Prevent form submission if applicable\n if (\n this.#currentSuggestion >= 0 &&\n this.#currentSuggestion < this.#allSuggestions.length\n ) {\n this._onPlaceSelected(\n this.#allSuggestions[this.#currentSuggestion].place,\n );\n // Reset is handled within onPlaceSelected via reset(true)\n }\n }\n }\n\n /**\n * Highlights the current suggestion in the UI.\n * @private\n */\n _highlightSuggestion() {\n if (this.#currentSuggestion < 0) return;\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentButton = currentLi.querySelector(\"button\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentButton) {\n this.#options.classes.li_button_current\n .split(\" \")\n .forEach((cl) => currentButton.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n this.#inputElement.setAttribute(\"aria-activedescendant\", currentLi.id); // Update aria-activedescendant\n\n // Visual feedback for key press\n const kbd =\n this.#currentSuggestion === 0\n ? this.#kbdUp\n : this.#kbdDown;\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => kbd?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => kbd?.classList.remove(cl)),\n 300,\n );\n }\n }\n\n // Helper function to find a specific address component\n _getAddressComponent(response, type) {\n return (\n response.addressComponents?.find((c) => c.types.includes(type))\n ?.longText || \"\"\n );\n }\n\n /**\n * Creates a button element for a suggestion item.\n * @returns {HTMLButtonElement} The created button element.\n */\n _createButtonElement(index) {\n const button = document.createElement(\"button\");\n button.tabIndex = index + 1;\n button.className = this.#options.classes.li_button; // block w-full flex justify-between\n return button;\n }\n\n /**\n * Creates a div container for suggestion item.\n * @returns {HTMLDivElement} The created div container element.\n */\n _createDivElement(className) {\n // create div elements pac-li-div-container\n const divContainer = document.createElement(\"div\");\n if (className) {\n divContainer.className = className;\n }\n return divContainer;\n }\n\n /**\n * Creates an SVG element representing a map pin icon.\n * @returns {SVGSVGElement} The created SVG element.\n */\n _createMapPinIconElement() {\n const svgIcon = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"svg\",\n );\n svgIcon.setAttribute(\"xmlns\", \"http://www.w3.org/2000/svg\");\n svgIcon.setAttribute(\"width\", \"24\");\n svgIcon.setAttribute(\"height\", \"24\");\n svgIcon.setAttribute(\"viewBox\", \"0 0 24 24\");\n svgIcon.setAttribute(\"fill\", \"none\");\n svgIcon.setAttribute(\"stroke\", \"currentColor\");\n svgIcon.setAttribute(\"stroke-width\", \"2\");\n svgIcon.setAttribute(\"stroke-linecap\", \"round\");\n svgIcon.setAttribute(\"stroke-linejoin\", \"round\");\n svgIcon.setAttribute(\"class\", this.#options.classes.map_icon_svg);\n // insert map pin icon path\n svgIcon.innerHTML = this.#options.classes.map_pin_icon;\n return svgIcon;\n }\n\n /**\n * Creates a paragraph (P) element with an optional class name.\n * @param {string} className\n * @returns {HTMLParagraphElement}\n */\n _createPElement(className) {\n const p = document.createElement(\"p\");\n if (className) {\n p.className = className;\n }\n return p;\n }\n /**\n * Creates an array of list item (LI) elements for the suggestions dropdown.\n * Each LI contains a link (A) with the place prediction details and distance.\n * Handles highlighting the matched parts of the suggestion text.\n * @param {Array<google.maps.places.AutocompleteSuggestion>} suggestions - Array of suggestion objects from the API.\n * @returns {Array<HTMLLIElement>} An array of LI elements to be added to the suggestions UL.\n */\n _createSuggestionElements(suggestions) {\n this.#allSuggestions = []; // Reset before populating\n // Map suggestions to LI elements\n return suggestions.map(async (suggestion, index) => {\n // Fetch place details for each suggestion\n let place = suggestion.placePrediction.toPlace();\n\n const li = document.createElement(\"li\");\n li.id = `option-${index + 1}`;\n li.className = this.#options.classes.li;\n li.setAttribute(\"role\", \"option\");\n\n // create button element\n const button = this._createButtonElement(index);\n\n // create div elements pac-li-div-container\n const divContainer = this._createDivElement(\n this.#options.classes.li_div_container,\n );\n\n // create li div one element - place name\n const liDivOne = this._createDivElement(this.#options.classes.li_div_one);\n const liDivTwo = this._createDivElement(this.#options.classes.li_div_two);\n // create map pin icon element\n const mapPinIcon = this._createMapPinIconElement();\n // append map pin icon to liDivOne\n liDivOne.appendChild(mapPinIcon);\n\n // create div p container\n const divPContainer = this._createDivElement(\n this.#options.classes.li_div_p_container,\n );\n // append div p container to liDivOne\n liDivOne.appendChild(divPContainer);\n\n // create p element - place name\n const pOne = this._createPElement(this.#options.classes.li_div_one_p);\n // create p element - secondary text\n const pTwo = this._createPElement(\n this.#options.classes.li_div_one_p_secondaryText,\n );\n // create p element - distance\n // Try to get distanceMeters from placePrediction or directly from suggestion\n const distanceMeters =\n suggestion.placePrediction?.distanceMeters ?? suggestion.distanceMeters;\n const distanceValue = this._formatDistance(\n distanceMeters,\n this.#options.distance_units ?? \"km\",\n );\n\n // append p element to div p container\n divPContainer.appendChild(pOne);\n divPContainer.appendChild(pTwo);\n\n // Add place type display and/or distance if enabled\n this._renderSuggestionMeta(liDivTwo, suggestion, distanceValue);\n\n // append liDivOne to divContainer\n divContainer.appendChild(liDivOne);\n divContainer.appendChild(liDivTwo);\n // append divContainer to button\n button.appendChild(divContainer);\n // append button to li\n li.appendChild(button);\n\n this._renderHighlightText(pOne, suggestion.placePrediction.mainText);\n\n // set secondary text if available\n const secondaryText =\n suggestion.placePrediction?.secondaryText?.text ?? \"\";\n\n if (secondaryText) {\n pTwo.textContent = secondaryText;\n }\n\n this.#allSuggestions.push({\n id: index + 1,\n place: place,\n mainText: suggestion.placePrediction.mainText.text,\n secondaryText: secondaryText,\n description: suggestion.placePrediction.toString(),\n });\n\n return li;\n });\n }\n\n /**\n * Renders meta information (place type, distance) for a suggestion.\n * @private\n */\n _renderSuggestionMeta(container, suggestion, distanceValue) {\n if (this.#options.show_place_type || this.#options.distance) {\n const metaContainer = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type,\n );\n\n // Place Type display\n if (\n this.#options.show_place_type &&\n Array.isArray(suggestion.placePrediction?.types) &&\n suggestion.placePrediction.types.length > 0\n ) {\n const placeTypeWrapper = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type_item,\n );\n\n const placeTypeIcon = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_icon,\n );\n\n const placeTypeLabel = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_label,\n );\n\n // Look through the array until we find a type we actually recognize\n const matchedType = suggestion.placePrediction.types.find(\n (type) => typeof type === \"string\" && type in ITINERARY_CATEGORIES,\n );\n\n placeTypeLabel.textContent = matchedType\n ? ITINERARY_CATEGORIES[matchedType]\n : \"Default\";\n\n placeTypeIcon.innerHTML =\n ITINERARY_SVG_ICONS[placeTypeLabel.textContent] ||\n ITINERARY_SVG_ICONS[\"Default\"];\n\n placeTypeWrapper.appendChild(placeTypeIcon);\n placeTypeWrapper.appendChild(placeTypeLabel);\n metaContainer.appendChild(placeTypeWrapper);\n }\n\n // Distance display\n if (this.#options.distance) {\n const distanceWrapper = this._createDivElement(\n this.#options.classes.li_div_two_p_place_type_item,\n );\n\n const distanceIcon = this._createPElement(\n this.#options.classes.li_div_two_p_place_type_icon,\n );\n distanceIcon.innerHTML = ITINERARY_SVG_ICONS[\"Distance\"];\n\n const pThree = this._createPElement(this.#options.classes.li_div_two_p);\n pThree.textContent = distanceValue ?? \"-\";\n\n distanceWrapper.appendChild(distanceIcon);\n distanceWrapper.appendChild(pThree);\n metaContainer.appendChild(distanceWrapper);\n }\n\n if (metaContainer.hasChildNodes()) {\n container.appendChild(metaContainer);\n }\n }\n }\n\n /**\n * Renders highlighted text for a suggestion.\n * @private\n */\n _renderHighlightText(element, predictionText) {\n const originalText = predictionText.text;\n const matches = predictionText.matches;\n let lastIndex = 0;\n\n matches.sort((a, b) => a.startOffset - b.startOffset);\n\n const outerSpan = document.createElement(\"span\");\n const innerSpan = document.createElement(\"span\");\n innerSpan.classList = this.#options.classes.highlight ?? \"font-bold\";\n\n for (const match of matches) {\n outerSpan.textContent += originalText.substring(\n lastIndex,\n match.startOffset,\n );\n if (match.startOffset > 0) {\n const prevChar = originalText.charAt(match.startOffset - 1);\n if (prevChar === \" \") {\n innerSpan.textContent += \" \";\n }\n }\n innerSpan.textContent += originalText.substring(\n match.startOffset,\n match.endOffset,\n );\n lastIndex = match.endOffset;\n }\n\n outerSpan.appendChild(innerSpan);\n outerSpan.appendChild(\n document.createTextNode(originalText.substring(lastIndex)),\n );\n element.appendChild(outerSpan);\n }\n\n /**\n * Handles the selection of a place. Fetches required fields\n * (displayName, formattedAddress, addressComponents) and calls the\n * user-defined `onPacData` callback.\n * @param {google.maps.places.Place} place - The selected Place object.\n */\n async _onPlaceSelected(place) {\n let data = null;\n try {\n // Fetch necessary details for the selected place\n await place.fetchFields({\n fields: this.#fetchFields, //[\"displayName\", \"formattedAddress\", \"addressComponents\"], // Add more fields as needed\n });\n // Call the user-provided callback with the place data\n // Handle response_type option\n if (this.#options.response_type === \"place\") {\n data = place; // Return the Place instance\n this.#onDataCallback(place);\n } else {\n // eslint-disable-next-line no-undef\n data = place.toJSON(); // Convert to plain JSON object (default)\n this.#onDataCallback(data);\n }\n } catch (error) {\n console.error(\"Error fetching place details:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n } finally {\n // Reset the input and suggestions regardless of success/error\n this._reset(true, data); // Refresh token after selection\n }\n }\n\n /**\n * Creates a new Google Places Autocomplete Session Token.\n * This should be called before starting a new series of autocomplete requests.\n */\n _refreshToken() {\n try {\n // eslint-disable-next-line no-undef\n this.#request.sessionToken =\n new google.maps.places.AutocompleteSessionToken();\n } catch (error) {\n console.error(\"Error creating session token:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to be fetched for the selected place.\n * This allows you to specify which details you want to retrieve\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @param {Array<string>} fields - Array of field names to fetch.\n */\n setFetchFields(fields) {\n this._setFetchFields(fields);\n }\n /**\n * Gets the current fields that will be fetched for the selected place.\n * This is useful for understanding what details will be available\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @returns {Array<string>} The current fetch fields.\n */\n getFetchFields() {\n return this.#fetchFields;\n }\n\n /**\n * Sets the request parameters for the Places Autocomplete instance.\n * This method allows you to update the request parameters dynamically,\n * such as the input value, region codes, language, etc.\n * It merges the provided parameters with the default request parameters,\n * allowing you to override specific values while keeping the defaults intact.\n * This is useful for updating the search criteria without needing to recreate the instance.\n * @param {*} params\n */\n setRequestParams(params) {\n if (\n typeof params === \"object\" &&\n !Array.isArray(params) &&\n params !== null\n ) {\n // if params.input is provided, set it to the input element\n if (params.input && typeof params.input === \"string\") {\n this.#inputElement.value = params.input; // Set input value if provided\n }\n // Merge provided params with default request parameters\n // This allows overriding specific request parameters while keeping defaults\n this.#request = {\n ...this.#defaultRequestParams,\n ...params,\n };\n }\n }\n\n /**\n * Returns the current request parameters used by the Places Autocomplete instance.\n * This includes the input value, included region codes, language, and other settings.\n * It is useful for debugging or when you need to know the current search criteria.\n * @returns {Object} The current request parameters.\n */\n getRequestParams() {\n return this.#request;\n }\n\n /**\n * Sets the options for the Places Autocomplete instance.\n * This method allows you to change the appearance and behavior of the autocomplete widget,\n * such as classes, placeholder text, debounce time, etc.\n * It merges the provided options with the default options, allowing you to override specific values\n * while keeping the defaults intact.\n * This is useful for updating the widget's configuration without needing to recreate the instance.\n * @param {*} options\n */\n setOptions(options) {\n if (\n typeof options === \"object\" &&\n !Array.isArray(options) &&\n options !== null\n ) {\n this._detachEventListeners(); // Detach event listeners\n\n // // Ensure classes are deeply merged if user provides partial classes\n const tmpClasses = options.classes || {};\n delete options.classes; // Remove classes from options to avoid overwriting\n\n // Merge provided options with default options\n // This allows overriding specific options while keeping defaults\n this.#options = {\n ...this.#defaultOptions,\n ...options,\n };\n\n // Merge classes with defaults\n // This allows overriding specific classes while keeping defaults\n if (\n tmpClasses &&\n typeof tmpClasses === \"object\" &&\n Object.keys(tmpClasses).length > 0\n ) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...tmpClasses,\n };\n } else {\n this.#options.classes = { ...this.#defaultClasses }; // Use defaults if no classes provided\n }\n\n this._initialiseDebouncedRequest(); // Reinitialize the debounced request function\n this._createPACStructure(); // Recreate the structure with new options\n // Reattach the input event listener to the input element\n // This is necessary to ensure the new input element is ready for events\n if (this.#inputElement) {\n this._attachedEventListeners();\n } // Reinitialize the autocomplete functionality\n }\n }\n\n /**\n * Gets the current options used by the Places Autocomplete instance.\n * @returns {Object} The current options.\n */\n getOptions() {\n /**\n * Returns the current options used by the Places Autocomplete instance.\n * This includes classes, placeholder text, debounce time, and other settings.\n * It is useful for debugging or when you need to know the current configuration of the widget.\n * @returns {Object} The current options.\n */\n return this.#options;\n }\n\n /**\n * Sets the input value by reverse geocoding coordinates.\n * Performs reverse geocoding to convert lat/lng to a place, then triggers onResponse.\n * Requires the Geocoding API to be enabled in your Google Cloud Console project.\n * @param {number} latitude - Latitude coordinate\n * @param {number} longitude - Longitude coordinate\n * @returns {Promise<void>}\n */\n async setInputValue(latitude, longitude) {\n try {\n // Import the geocoding library\n const { Geocoder } = await google.maps.importLibrary(\"geocoding\");\n const geocoder = new Geocoder();\n\n // Perform reverse geocoding\n const response = await geocoder.geocode({\n location: { lat: latitude, lng: longitude },\n });\n\n if (response.results && response.results.length > 0) {\n const placeId = response.results[0].place_id;\n const place = new google.maps.places.Place({ id: placeId });\n\n // Fetch the configured fields\n await place.fetchFields({ fields: this.#fetchFields });\n\n // Update input field if clear_input is false\n if (!this.#options.clear_input && place.formattedAddress) {\n this.#inputElement.value = place.formattedAddress;\n }\n\n // Trigger the callback with appropriate response type\n if (this.#options.response_type === \"place\") {\n this.#onDataCallback(place);\n } else {\n this.#onDataCallback(place.toJSON());\n }\n } else {\n throw new Error(\"No results found for the provided coordinates\");\n }\n } catch (error) {\n console.error(\"Error in setInputValue:\", error);\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Clears the autocomplete input field and suggestions list.\n * This method resets the state of the autocomplete widget,\n * allowing the user to start a new search without any previous input or suggestions.\n * It also refreshes the Google Places session token to ensure a new session.\n * @returns {void}\n */\n clear() {\n this.#cache.clear();\n this._reset(true);\n }\n\n /**\n * Sets focus on the autocomplete input field.\n * This method allows programmatic control of the input focus,\n * useful for improving user experience and accessibility.\n * @returns {void}\n */\n focus() {\n if (this.#inputElement) {\n this.#inputElement.focus();\n }\n }\n\n /**\n * Destroys the PacAutocomplete instance.\n * Removes event listeners, clears the DOM, and nullifies properties.\n * This method should be called when the autocomplete widget is no longer needed.\n * It ensures that all resources are cleaned up to prevent memory leaks.\n * @returns {void}\n */\n destroy() {\n // Remove event listeners, remove elements from DOM\n this._detachEventListeners(); // Detach event listeners\n // Nullify properties\n this.#containerId = null;\n this.#pacEl = null;\n this.#googleMapsApiKey = null;\n this.#googleMapsApiVersion = null;\n this.#options = null;\n this.#request = null;\n this.#inputElement = null;\n this.#container = null;\n this.#ul = null;\n this.#ariaStatus = null;\n this.#cache = null;\n this.#kbdEscape = null;\n this.#kbdUp = null;\n this.#kbdDown = null;\n this.#allSuggestions = null;\n this.#currentSuggestion = -1;\n this.#onDataCallback = null;\n this.#onErrorCallback = null;\n this.#debouncedMakeAcRequest = null;\n }\n}\n"],"mappings":"0RAAA,IAAa,EAAu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OAAQ,MAAA,EAAmB,CAAC,CAGlD,CAAC,MAAA,EAAc,aAAe,EAAM,mBACtC,MAAA,EAAmB,MAAQ,EAAM,kBAI/B,MAAA,EAAc,gBAAkB,QAClC,MAAA,EAAqB,EAAM,CAE3B,MAAA,EAAqB,EAAM,QAAQ,CAAC,MAGtC,MAAU,MAAM,gDAAgD,OAE3D,EAAO,CACd,QAAQ,MAAM,0BAA2B,EAAM,CAC/C,MAAA,EAAsB,EAAM,EAWhC,OAAQ,CACN,MAAA,EAAY,OAAO,CACnB,KAAK,OAAO,GAAK,CASnB,OAAQ,CACF,MAAA,GACF,MAAA,EAAmB,OAAO,CAW9B,SAAU,CAER,KAAK,uBAAuB,CAE5B,MAAA,EAAoB,KACpB,MAAA,EAAc,KACd,MAAA,EAAyB,KACzB,MAAA,EAA6B,KAC7B,MAAA,EAAgB,KAChB,MAAA,EAAgB,KAChB,MAAA,EAAqB,KACrB,MAAA,EAAkB,KAClB,MAAA,EAAW,KACX,MAAA,EAAmB,KACnB,MAAA,EAAc,KACd,MAAA,EAAkB,KAClB,MAAA,EAAc,KACd,MAAA,EAAgB,KAChB,MAAA,EAAuB,KACvB,MAAA,EAA0B,GAC1B,MAAA,EAAuB,KACvB,MAAA,EAAwB,KACxB,MAAA,EAA+B"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "places-autocomplete-js",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.2.
|
|
5
|
+
"version": "1.2.2",
|
|
6
6
|
"description": "Google Maps Platform Awards 2025 Winner - A flexible, accessible, and secure vanilla JavaScript library that brings the power of Google's address search to your application in minutes.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"place-autocomplete",
|