/*! 1.19.0 | © Algolia | github.com/algolia/places */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["placesAutocompleteDataset"] = factory(); else root["placesAutocompleteDataset"] = factory(); })(window, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 70); /******/ }) /************************************************************************/ /******/ ({ /***/ 1: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var extractParams = function extractParams(_ref) { var hitsPerPage = _ref.hitsPerPage, postcodeSearch = _ref.postcodeSearch, aroundLatLng = _ref.aroundLatLng, aroundRadius = _ref.aroundRadius, aroundLatLngViaIP = _ref.aroundLatLngViaIP, insideBoundingBox = _ref.insideBoundingBox, insidePolygon = _ref.insidePolygon, getRankingInfo = _ref.getRankingInfo, countries = _ref.countries, language = _ref.language, type = _ref.type; var extracted = { countries: countries, hitsPerPage: hitsPerPage || 5, language: language || navigator.language.split('-')[0], type: type }; if (Array.isArray(countries)) { extracted.countries = extracted.countries.map(function (country) { return country.toLowerCase(); }); } if (typeof extracted.language === 'string') { extracted.language = extracted.language.toLowerCase(); } if (aroundLatLng) { extracted.aroundLatLng = aroundLatLng; } else if (aroundLatLngViaIP !== undefined) { extracted.aroundLatLngViaIP = aroundLatLngViaIP; } if (postcodeSearch) { extracted.restrictSearchableAttributes = 'postcode'; } return _objectSpread(_objectSpread({}, extracted), {}, { aroundRadius: aroundRadius, insideBoundingBox: insideBoundingBox, insidePolygon: insidePolygon, getRankingInfo: getRankingInfo }); }; var extractControls = function extractControls(_ref2) { var _ref2$useDeviceLocati = _ref2.useDeviceLocation, useDeviceLocation = _ref2$useDeviceLocati === void 0 ? false : _ref2$useDeviceLocati, _ref2$computeQueryPar = _ref2.computeQueryParams, computeQueryParams = _ref2$computeQueryPar === void 0 ? function (params) { return params; } : _ref2$computeQueryPar, formatInputValue = _ref2.formatInputValue, _ref2$onHits = _ref2.onHits, onHits = _ref2$onHits === void 0 ? function () {} : _ref2$onHits, _ref2$onError = _ref2.onError, onError = _ref2$onError === void 0 ? function (e) { throw e; } : _ref2$onError, onRateLimitReached = _ref2.onRateLimitReached, onInvalidCredentials = _ref2.onInvalidCredentials; return { useDeviceLocation: useDeviceLocation, computeQueryParams: computeQueryParams, formatInputValue: formatInputValue, onHits: onHits, onError: onError, onRateLimitReached: onRateLimitReached, onInvalidCredentials: onInvalidCredentials }; }; var params = {}; var controls = {}; var configure = function configure(configuration) { params = extractParams(_objectSpread(_objectSpread({}, params), configuration)); controls = extractControls(_objectSpread(_objectSpread({}, controls), configuration)); return { params: params, controls: controls }; }; /* harmony default export */ __webpack_exports__["a"] = (configure); /***/ }), /***/ 15: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony default export */ __webpack_exports__["a"] = (".algolia-places {\n width: 100%;\n}\n\n.ap-input, .ap-hint {\n width: 100%;\n padding-right: 35px;\n padding-left: 16px;\n line-height: 40px;\n height: 40px;\n border: 1px solid #CCC;\n border-radius: 3px;\n outline: none;\n font: inherit;\n appearance: none;\n -webkit-appearance: none;\n box-sizing: border-box;\n}\n\n.ap-input::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n.ap-input::-ms-clear {\n display: none;\n}\n\n.ap-input:hover ~ .ap-input-icon svg,\n.ap-input:focus ~ .ap-input-icon svg,\n.ap-input-icon:hover svg {\n fill: #aaaaaa;\n}\n\n.ap-dropdown-menu {\n width: 100%;\n background: #ffffff;\n box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1);\n border-radius: 3px;\n margin-top: 3px;\n overflow: hidden;\n}\n\n.ap-suggestion {\n cursor: pointer;\n height: 46px;\n line-height: 46px;\n padding-left: 18px;\n overflow: hidden;\n}\n\n.ap-suggestion em {\n font-weight: bold;\n font-style: normal;\n}\n\n.ap-address {\n font-size: smaller;\n margin-left: 12px;\n color: #aaaaaa;\n}\n\n.ap-suggestion-icon {\n margin-right: 10px;\n width: 14px;\n height: 20px;\n vertical-align: middle;\n}\n\n.ap-suggestion-icon svg {\n display: inherit;\n -webkit-transform: scale(0.9) translateY(2px);\n transform: scale(0.9) translateY(2px);\n fill: #cfcfcf;\n}\n\n.ap-input-icon {\n border: 0;\n background: transparent;\n position: absolute;\n top: 0;\n bottom: 0;\n right: 16px;\n outline: none;\n}\n\n.ap-input-icon.ap-icon-pin {\n cursor: pointer;\n}\n\n.ap-input-icon svg {\n fill: #cfcfcf;\n position: absolute;\n top: 50%;\n right: 0;\n -webkit-transform: translateY(-50%);\n transform: translateY(-50%);\n}\n\n.ap-cursor {\n background: #efefef;\n}\n\n.ap-cursor .ap-suggestion-icon svg {\n -webkit-transform: scale(1) translateY(2px);\n transform: scale(1) translateY(2px);\n fill: #aaaaaa;\n}\n\n.ap-footer {\n opacity: .8;\n text-align: right;\n padding: .5em 1em .5em 0;\n font-size: 12px;\n line-height: 12px;\n}\n\n.ap-footer a {\n color: inherit;\n text-decoration: none;\n}\n\n.ap-footer a svg {\n vertical-align: middle;\n}\n\n.ap-footer:hover {\n opacity: 1;\n}\n"); /***/ }), /***/ 18: /***/ (function(module, exports) { var containers = []; // will store container HTMLElement references var styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement} var usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).'; function insertCss(css, options) { options = options || {}; if (css === undefined) { throw new Error(usage); } var position = options.prepend === true ? 'prepend' : 'append'; var container = options.container !== undefined ? options.container : document.querySelector('head'); var containerId = containers.indexOf(container); // first time we see this container, create the necessary entries if (containerId === -1) { containerId = containers.push(container) - 1; styleElements[containerId] = {}; } // try to get the correponding container + position styleElement, create it otherwise var styleElement; if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) { styleElement = styleElements[containerId][position]; } else { styleElement = styleElements[containerId][position] = createStyleElement(); if (position === 'prepend') { container.insertBefore(styleElement, container.childNodes[0]); } else { container.appendChild(styleElement); } } // strip potential UTF-8 BOM if css was read from a file if (css.charCodeAt(0) === 0xFEFF) { css = css.substr(1, css.length); } // actually add the stylesheet if (styleElement.styleSheet) { styleElement.styleSheet.cssText += css } else { styleElement.textContent += css; } return styleElement; }; function createStyleElement() { var styleElement = document.createElement('style'); styleElement.setAttribute('type', 'text/css'); return styleElement; } module.exports = insertCss; module.exports.insertCss = insertCss; /***/ }), /***/ 19: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ createAutocompleteDataset; }); // EXTERNAL MODULE: ./src/configure/index.js var configure = __webpack_require__(1); // EXTERNAL MODULE: ./src/formatHit.js + 2 modules var formatHit = __webpack_require__(9); // EXTERNAL MODULE: ./src/version.js var version = __webpack_require__(6); // CONCATENATED MODULE: ./src/createAutocompleteSource.js function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function createAutocompleteSource(_ref) { var algoliasearch = _ref.algoliasearch, clientOptions = _ref.clientOptions, apiKey = _ref.apiKey, appId = _ref.appId, hitsPerPage = _ref.hitsPerPage, postcodeSearch = _ref.postcodeSearch, aroundLatLng = _ref.aroundLatLng, aroundRadius = _ref.aroundRadius, aroundLatLngViaIP = _ref.aroundLatLngViaIP, insideBoundingBox = _ref.insideBoundingBox, insidePolygon = _ref.insidePolygon, getRankingInfo = _ref.getRankingInfo, countries = _ref.countries, formatInputValue = _ref.formatInputValue, _ref$computeQueryPara = _ref.computeQueryParams, computeQueryParams = _ref$computeQueryPara === void 0 ? function (params) { return params; } : _ref$computeQueryPara, _ref$useDeviceLocatio = _ref.useDeviceLocation, useDeviceLocation = _ref$useDeviceLocatio === void 0 ? false : _ref$useDeviceLocatio, _ref$language = _ref.language, language = _ref$language === void 0 ? navigator.language.split('-')[0] : _ref$language, _ref$onHits = _ref.onHits, onHits = _ref$onHits === void 0 ? function () {} : _ref$onHits, _ref$onError = _ref.onError, onError = _ref$onError === void 0 ? function (e) { throw e; } : _ref$onError, onRateLimitReached = _ref.onRateLimitReached, onInvalidCredentials = _ref.onInvalidCredentials, type = _ref.type; var placesClient = algoliasearch.initPlaces(appId, apiKey, clientOptions); placesClient.as.addAlgoliaAgent("Algolia Places ".concat(version["default"])); var configuration = Object(configure["a" /* default */])({ hitsPerPage: hitsPerPage, type: type, postcodeSearch: postcodeSearch, countries: countries, language: language, aroundLatLng: aroundLatLng, aroundRadius: aroundRadius, aroundLatLngViaIP: aroundLatLngViaIP, insideBoundingBox: insideBoundingBox, insidePolygon: insidePolygon, getRankingInfo: getRankingInfo, formatInputValue: formatInputValue, computeQueryParams: computeQueryParams, useDeviceLocation: useDeviceLocation, onHits: onHits, onError: onError, onRateLimitReached: onRateLimitReached, onInvalidCredentials: onInvalidCredentials }); var params = configuration.params; var controls = configuration.controls; var userCoords; var tracker = null; if (controls.useDeviceLocation) { tracker = navigator.geolocation.watchPosition(function (_ref2) { var coords = _ref2.coords; userCoords = "".concat(coords.latitude, ",").concat(coords.longitude); }); } function searcher(query, cb) { var searchParams = _objectSpread(_objectSpread({}, params), {}, { query: query }); if (userCoords) { searchParams.aroundLatLng = userCoords; } return placesClient.search(controls.computeQueryParams(searchParams)).then(function (content) { var hits = content.hits.map(function (hit, hitIndex) { return Object(formatHit["a" /* default */])({ formatInputValue: controls.formatInputValue, hit: hit, hitIndex: hitIndex, query: query, rawAnswer: content }); }); controls.onHits({ hits: hits, query: query, rawAnswer: content }); return hits; }).then(cb)["catch"](function (e) { if (e.statusCode === 403 && e.message === 'Invalid Application-ID or API key') { controls.onInvalidCredentials(); return; } else if (e.statusCode === 429) { controls.onRateLimitReached(); return; } controls.onError(e); }); } searcher.configure = function (partial) { var updated = Object(configure["a" /* default */])(_objectSpread(_objectSpread(_objectSpread({}, params), controls), partial)); params = updated.params; controls = updated.controls; if (controls.useDeviceLocation && tracker === null) { tracker = navigator.geolocation.watchPosition(function (_ref3) { var coords = _ref3.coords; userCoords = "".concat(coords.latitude, ",").concat(coords.longitude); }); } else if (!controls.useDeviceLocation && tracker !== null) { navigator.geolocation.clearWatch(tracker); tracker = null; userCoords = null; } }; return searcher; } // EXTERNAL MODULE: ./src/defaultTemplates.js + 10 modules var defaultTemplates = __webpack_require__(8); // CONCATENATED MODULE: ./src/createAutocompleteDataset.js function createAutocompleteDataset_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function createAutocompleteDataset_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { createAutocompleteDataset_ownKeys(Object(source), true).forEach(function (key) { createAutocompleteDataset_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { createAutocompleteDataset_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function createAutocompleteDataset_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function createAutocompleteDataset(options) { var templates = createAutocompleteDataset_objectSpread(createAutocompleteDataset_objectSpread({}, defaultTemplates["a" /* default */]), options.templates); var source = createAutocompleteSource(createAutocompleteDataset_objectSpread(createAutocompleteDataset_objectSpread({}, options), {}, { formatInputValue: templates.value, templates: undefined })); return { source: source, templates: templates, displayKey: 'value', name: 'places', cache: false }; } /***/ }), /***/ 30: /***/ (function(module, exports) { // polyfill for navigator.language (IE <= 10) // not polyfilled by https://cdn.polyfill.io/v2/docs/ // Defined: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#navigatorlanguage // with allowable values at http://www.ietf.org/rfc/bcp/bcp47.txt // Note that the HTML spec suggests that anonymizing services return "en-US" by default for // user privacy (so your app may wish to provide a means of changing the locale) if (!('language' in navigator)) { navigator.language = // IE 10 in IE8 mode on Windows 7 uses upper-case in // navigator.userLanguage country codes but per // http://msdn.microsoft.com/en-us/library/ie/ms533052.aspx (via // http://msdn.microsoft.com/en-us/library/ie/ms534713.aspx), they // appear to be in lower case, so we bring them into harmony with navigator.language. navigator.userLanguage && navigator.userLanguage.replace(/-[a-z]{2}$/, String.prototype.toUpperCase) || 'en-US'; // Default for anonymizing services: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#navigatorlanguage } /***/ }), /***/ 6: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony default export */ __webpack_exports__["default"] = ('1.19.0'); /***/ }), /***/ 7: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony default export */ __webpack_exports__["a"] = ("\n"); /***/ }), /***/ 70: /***/ (function(module, exports, __webpack_require__) { // we need to export using commonjs for ease of usage in all // JavaScript environments /* eslint-disable import/no-commonjs */ __webpack_require__(30); var createAutocompleteDataset = __webpack_require__(19)["default"]; var css = __webpack_require__(71)["default"]; var insertCss = __webpack_require__(18); insertCss(css, { prepend: true }); // must use module.exports to be commonJS compatible module.exports = createAutocompleteDataset; /* eslint-enable import/no-commonjs */ /***/ }), /***/ 71: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _src_places_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); // this is proxy file so that babel inlines src/places.css into the css variable // since it is not a commonjs file /* harmony default export */ __webpack_exports__["default"] = (_src_places_css__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]); /***/ }), /***/ 8: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // CONCATENATED MODULE: ./src/formatInputValue.js function formatInputValue(_ref) { var administrative = _ref.administrative, city = _ref.city, country = _ref.country, name = _ref.name, type = _ref.type; var out = "".concat(name).concat(type !== 'country' && country !== undefined ? ',' : '', "\n ").concat(city ? "".concat(city, ",") : '', "\n ").concat(administrative ? "".concat(administrative, ",") : '', "\n ").concat(country ? country : '').replace(/\s*\n\s*/g, ' ').trim(); return out; } // EXTERNAL MODULE: ./src/icons/address.svg var address = __webpack_require__(7); // CONCATENATED MODULE: ./src/icons/city.svg /* harmony default export */ var city = ("\n"); // CONCATENATED MODULE: ./src/icons/country.svg /* harmony default export */ var country = ("\n \n\n"); // CONCATENATED MODULE: ./src/icons/bus.svg /* harmony default export */ var bus = ("\n"); // CONCATENATED MODULE: ./src/icons/train.svg /* harmony default export */ var train = ("\n \n\n"); // CONCATENATED MODULE: ./src/icons/townhall.svg /* harmony default export */ var townhall = ("\n"); // CONCATENATED MODULE: ./src/icons/plane.svg /* harmony default export */ var plane = ("\n"); // CONCATENATED MODULE: ./src/formatDropdownValue.js var icons = { address: address["a" /* default */], city: city, country: country, busStop: bus, trainStation: train, townhall: townhall, airport: plane }; function formatDropdownValue(_ref) { var type = _ref.type, highlight = _ref.highlight; var name = highlight.name, administrative = highlight.administrative, city = highlight.city, country = highlight.country; var out = "".concat(icons[type].trim(), "\n").concat(name, "\n\n ").concat([city, administrative, country].filter(function (token) { return token !== undefined; }).join(', '), "").replace(/\s*\n\s*/g, ' '); return out; } // CONCATENATED MODULE: ./src/icons/algolia.svg /* harmony default export */ var algolia = (""); // CONCATENATED MODULE: ./src/icons/osm.svg /* harmony default export */ var osm = ("\n \n\n"); // CONCATENATED MODULE: ./src/defaultTemplates.js /* harmony default export */ var defaultTemplates = __webpack_exports__["a"] = ({ footer: "
\n ".concat(algolia.trim(), "\n using ").concat(osm.trim(), " data\n
"), value: formatInputValue, suggestion: formatDropdownValue }); /***/ }), /***/ 9: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ formatHit; }); // CONCATENATED MODULE: ./src/findCountryCode.js function findCountryCode(tags) { for (var tagIndex = 0; tagIndex < tags.length; tagIndex++) { var tag = tags[tagIndex]; var find = tag.match(/country\/(.*)?/); if (find) { return find[1]; } } return undefined; } // CONCATENATED MODULE: ./src/findType.js function findType(tags) { var types = { country: 'country', city: 'city', 'amenity/bus_station': 'busStop', 'amenity/townhall': 'townhall', 'railway/station': 'trainStation', 'aeroway/aerodrome': 'airport', 'aeroway/terminal': 'airport', 'aeroway/gate': 'airport' }; for (var t in types) { if (tags.indexOf(t) !== -1) { return types[t]; } } return 'address'; } // CONCATENATED MODULE: ./src/formatHit.js function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function getBestHighlightedForm(highlightedValues) { var defaultValue = highlightedValues[0].value; // collect all other matches var bestAttributes = []; for (var i = 1; i < highlightedValues.length; ++i) { if (highlightedValues[i].matchLevel !== 'none') { bestAttributes.push({ index: i, words: highlightedValues[i].matchedWords }); } } // no matches in this attribute, retrieve first value if (bestAttributes.length === 0) { return defaultValue; } // sort the matches by `desc(words), asc(index)` bestAttributes.sort(function (a, b) { if (a.words > b.words) { return -1; } else if (a.words < b.words) { return 1; } return a.index - b.index; }); // and append the best match to the first value return bestAttributes[0].index === 0 ? "".concat(defaultValue, " (").concat(highlightedValues[bestAttributes[1].index].value, ")") : "".concat(highlightedValues[bestAttributes[0].index].value, " (").concat(defaultValue, ")"); } function getBestPostcode(postcodes, highlightedPostcodes) { var defaultValue = highlightedPostcodes[0].value; // collect all other matches var bestAttributes = []; for (var i = 1; i < highlightedPostcodes.length; ++i) { if (highlightedPostcodes[i].matchLevel !== 'none') { bestAttributes.push({ index: i, words: highlightedPostcodes[i].matchedWords }); } } // no matches in this attribute, retrieve first value if (bestAttributes.length === 0) { return { postcode: postcodes[0], highlightedPostcode: defaultValue }; } // sort the matches by `desc(words)` bestAttributes.sort(function (a, b) { if (a.words > b.words) { return -1; } else if (a.words < b.words) { return 1; } return a.index - b.index; }); var postcode = postcodes[bestAttributes[0].index]; return { postcode: postcode, highlightedPostcode: highlightedPostcodes[bestAttributes[0].index].value }; } function formatHit(_ref) { var formatInputValue = _ref.formatInputValue, hit = _ref.hit, hitIndex = _ref.hitIndex, query = _ref.query, rawAnswer = _ref.rawAnswer; try { var name = hit.locale_names[0]; var country = hit.country; var administrative = hit.administrative && hit.administrative[0] !== name ? hit.administrative[0] : undefined; var city = hit.city && hit.city[0] !== name ? hit.city[0] : undefined; var suburb = hit.suburb && hit.suburb[0] !== name ? hit.suburb[0] : undefined; var county = hit.county && hit.county[0] !== name ? hit.county[0] : undefined; var _ref2 = hit.postcode && hit.postcode.length ? getBestPostcode(hit.postcode, hit._highlightResult.postcode) : { postcode: undefined, highlightedPostcode: undefined }, postcode = _ref2.postcode, highlightedPostcode = _ref2.highlightedPostcode; var highlight = { name: getBestHighlightedForm(hit._highlightResult.locale_names), city: city ? getBestHighlightedForm(hit._highlightResult.city) : undefined, administrative: administrative ? getBestHighlightedForm(hit._highlightResult.administrative) : undefined, country: country ? hit._highlightResult.country.value : undefined, suburb: suburb ? getBestHighlightedForm(hit._highlightResult.suburb) : undefined, county: county ? getBestHighlightedForm(hit._highlightResult.county) : undefined, postcode: highlightedPostcode }; var suggestion = { name: name, administrative: administrative, county: county, city: city, suburb: suburb, country: country, countryCode: findCountryCode(hit._tags), type: findType(hit._tags), latlng: { lat: hit._geoloc.lat, lng: hit._geoloc.lng }, postcode: postcode, postcodes: hit.postcode && hit.postcode.length ? hit.postcode : undefined }; // this is the value to put inside the