1"use strict";(self.webpackChunkkunstmaan_edition=self.webpackChunkkunstmaan_edition||[]).push([[9686],{5471:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("{/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nfunction calculateDistance(pos1, pos2) {\n const toRad = value => value * Math.PI / 180;\n const deltaLat = toRad(pos2.latitude - pos1.latitude);\n const deltaLon = toRad(pos2.longitude - pos1.longitude);\n const a = Math.sin(deltaLat / 2) ** 2 + Math.cos(toRad(pos1.latitude)) * Math.cos(toRad(pos2.latitude)) * Math.sin(deltaLon / 2) ** 2;\n const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n return 6371 * c; // Earth's radius in km\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (calculateDistance);\n\n//# sourceURL=webpack://kunstmaan-edition/./vendor/insiders/kunstmaan-application/kunstmaan-bundles/KunstmaanCoreBundle/Resources/ui/frontend/js/calculateDistance.module.js?\n}")},9686:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("{/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2891);\n/* harmony import */ var _calculateDistance_module__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5471);\n\n\n\n/* stimulusFetch: 'lazy' */\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (class extends _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__/* .Controller */ .xI {\n static values = {\n to: String,\n longUnit: String,\n shortUnit: String,\n label: String\n };\n connect() {\n this.locale = document.documentElement.lang || 'en';\n const storedPosition = window.localStorage.getItem('geolocation');\n if (storedPosition) {\n try {\n this.currentPosition = JSON.parse(storedPosition);\n this.updateDistance();\n } catch (e) {\n this.currentPosition = null;\n }\n }\n this.getCurrentPosition();\n }\n getCurrentPosition() {\n if (!navigator.geolocation) {\n return;\n }\n navigator.geolocation.getCurrentPosition(position => {\n this.currentPosition = {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude\n };\n window.localStorage.setItem('geolocation', JSON.stringify(this.currentPosition));\n this.updateDistance();\n }, () => {\n window.localStorage.removeItem('geolocation');\n });\n }\n updateDistance() {\n if (!this.toValue || !this.currentPosition) {\n return;\n }\n const [lat, lng] = this.toValue.split(',').map(parseFloat);\n const distanceKm = (0,_calculateDistance_module__WEBPACK_IMPORTED_MODULE_1__/* [\"default\"] */ .A)(this.currentPosition, {\n latitude: lat,\n longitude: lng\n });\n let distanceText;\n if (distanceKm < 1) {\n distanceText = `${(distanceKm * 1000).toFixed(0).toLocaleString(this.locale)}${this.shortUnitValue}`;\n } else {\n distanceText = `${distanceKm.toFixed(1).toLocaleString(this.locale)}${this.longUnitValue}`;\n }\n const text = `${distanceText} ${this.labelValue}`;\n this.element.textContent = text;\n }\n});\n\n//# sourceURL=webpack://kunstmaan-edition/./vendor/insiders/kunstmaan-application/kunstmaan-bundles/KunstmaanCoreBundle/Resources/ui/frontend/js/controllers/distance-controller.js?\n}")}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.