{"version":3,"file":"Src_Scripts_models_map-location-types_map-location_js.7d5e44400c5b51410862.js","sources":["webpack://haveselskabet/./Src/Scripts/components/media-swiper.js","webpack://haveselskabet/./Src/Scripts/models/map-location-types/map-location.js"],"sourcesContent":["import Swiper, { Navigation, Scrollbar, Thumbs } from 'swiper/core';\nSwiper.use([Navigation]);\nSwiper.use([Thumbs]);\nSwiper.use([Scrollbar]);\n\nexport default class MediaSwiper {\n constructor(elm, args) {\n if (elm.querySelectorAll('.swiper-slide').length == 0) return;\n\n this.elm = elm;\n this.options = {\n observer: true,\n observeParents: true,\n loadPrevNext: true,\n parallax: true,\n loop: false,\n slidesPerView: 1,\n navigation: {\n nextEl: elm.querySelector('.swiper-button-media-next'),\n prevEl: elm.querySelector('.swiper-button-media-prev'),\n },\n };\n\n if (args.style == 1 || args.style == 3) {\n Swiper.use([Scrollbar]);\n this.options.scrollbar = {\n el: elm.querySelector('.swiper-scrollbar'),\n draggable: true,\n };\n }\n\n if (args.style == 2 || args.style == 4) {\n this.options.allowTouchMove = false;\n this.options.spaceBetween = 4;\n }\n\n if (args.style == 3) {\n this.options.spaceBetween = 20;\n }\n\n if (args.thumbs) {\n this.options.thumbs = {\n swiper: args.thumbs\n }\n }\n\n this.swiper = import('swiper').then(slider => new slider.Swiper(this.elm, this.options));\n\n elm.swiperElm = this.swiper;\n // Hide arrows is there is only one image\n const slides = elm.querySelectorAll('.swiper-slide');\n const arrowContainer = elm.querySelector('.swiper-arrow-wrapper');\n\n if (arrowContainer && slides.length < 2) {\n arrowContainer.style.display = \"none\";\n }\n }\n\n update() {\n this.swiper.update();\n }\n\n destroy() {\n this.swiper.destroy();\n }\n\n\n}\n","import MediaSwiper from '../../components/media-swiper';\n/*\nARGS:\n-latitude: float\n-longitude: float\n-component: (optional) string alias of a component that holds logic of specific location type.\n-pinIcon: (optional) object that specifies the marker for the location Ex: { url: '/Static/assets/images/marker.png', width: 50, height: 70}\n-typeProperties: (optional) object with properties for the specific location type\n*/\nexport default class MapLocation {\n constructor(args) {\n const self = this;\n this.latitude = args.latitude;\n this.longitude = args.longitude;\n this.label = args.label;\n this.pinIcon = args.pinIcon ? args.pinIcon : null;\n this.htmlInfoWindow = args.htmlInfoWindow;\n this.htmlListView = args.htmlListView;\n this.nodeId = args.nodeId;\n this.interests = args.interests;\n\n const periodAccepted = false;\n let checkPeriod = false;\n let checkPeriodFrom;\n let checkPeriodTo;\n\n if (args.startDate) {\n this.startDate = new Date(args.startDate);\n }\n\n if (args.endDate) {\n this.endDate = new Date(args.endDate);\n }\n\n this.location = args.location;\n this.district = args.district;\n this.union = args.union;\n this.type = args.type;\n\n this.openGardenDecoration = args.openGardenDecoration;\n this.openGardenSize = args.openGardenSize;\n this.openGardenActivities = args.openGardenActivities;\n\n // This can be overridden with a method in a subclass to override the default behaviour when a map marker is clicked.\n // By default when a map marker is clicked the getInfoWindowContent will be invoked and the content shown in a map marker.\n // If this method is overridden the default behaviour disappears and it would have to be manually replicated if so desired.\n // The function is invoked with the following arguments: (infoWindow, marker, map, event)\n this.onMarkerClick = null;\n\n // This can be overridden with a method in a subclass add logic that happens with the location\n // when the map is clicked (outside the marker or info window).\n // The function is invoked with the following arguments: (infowindow, event)\n this.onMapClick = null;\n\n // Default method that returns the markup displayed on the map when the marker is clicked.\n // This method should be overriden in the specific Location Subclass\n this.getInfoWindowContent = function (location) {\n return new Promise(resolve => {\n fetch(`/umbraco/surface/maps/RenderInfoWindow?node=${location.nodeId}`)\n .then(x => x.text())\n .then(text => {\n const boxText = document.createElement('div');\n boxText.innerHTML = text;\n const mediaSwiper = boxText.querySelector('[data-component=\"media-swiper\"]');\n if (mediaSwiper) {\n new MediaSwiper(mediaSwiper, { style: 2 });\n }\n resolve(boxText);\n });\n });\n };\n\n function containsInterest(interest) {\n return self.interests.map(x => x.toString())?.includes(interest.toString());\n }\n\n function filterByInterest(interests) {\n if (!self.interests) { return false; }\n\n return interests.some(containsInterest);\n }\n\n function filterByType(types) {\n return types.includes(self.type);\n }\n\n function filterByOpenGardenDecoration(decorations) {\n return decorations.includes(self.openGardenDecoration);\n }\n\n function filterByLocation(locations) {\n return locations.includes(self.location.toString());\n }\n\n function filterByOpenGardenActivity(activities) {\n return self.openGardenActivities.some(x => { return activities.includes(x.toString()); });\n }\n\n function filterByDistrict(districts) {\n return districts.includes(self.district.toString());\n }\n\n function filterByUnion(unions) {\n return unions.includes(self.union.toString());\n }\n\n function filterByFromDate(fromDate, fromDateString) {\n const stupidFormatDate = formatDateToStupidFormat(fromDateString[0]);\n if (args.component == 'eventPage') {\n return (self.endDate >= (new Date(stupidFormatDate)));\n }\n checkPeriod = true;\n checkPeriodFrom = new Date(stupidFormatDate);\n return true;\n\n }\n\n function formatDateToStupidFormat(niceFormatDate) {\n const parts = niceFormatDate.replace('-', '/').split('/');\n return `${parts[1]}/${parts[0]}/${parts[2]}`;\n }\n\n function filterByToDate(id, toDateString) {\n const stupidFormatDate = formatDateToStupidFormat(toDateString[0]);\n if (args.component == 'eventPage') {\n return (self.startDate <= (new Date(stupidFormatDate)));\n }\n checkPeriod = true;\n\n checkPeriodTo = new Date(stupidFormatDate);\n return true;\n\n }\n\n function checkOpenGardenPeriod() {\n // Open garden page\n if (!self.openDates) {\n InitializeOpenGardenDates();\n }\n\n return self.openDates.some(x => (!checkPeriodTo || x <= checkPeriodTo) && (!checkPeriodFrom || x >= checkPeriodFrom));\n }\n\n function InitializeOpenGardenDates() {\n self.openDates = args.openDates.map(x => new Date(x));\n }\n\n function filterBySizeRangeFrom(id, fromRange, sizeMapping) {\n if (!args.openGardenSize) { return true; }\n\n const currentSize = sizeMapping[args.openGardenSize];\n if (currentSize.max < parseInt(fromRange)) { return false; }\n\n return true;\n }\n\n function filterBySizeRangeTo(id, toRange, sizeMapping) {\n if (!args.openGardenSize) { return true; }\n\n const currentSize = sizeMapping[args.openGardenSize];\n if (currentSize.min > parseInt(toRange)) { return false; }\n\n return true;\n }\n\n const map = [];\n map.Interest = filterByInterest;\n map.OpenGardenType = filterByType;\n map.OpenGardenDecoration = filterByOpenGardenDecoration;\n map.Location = filterByLocation;\n map.OpenGardenActivity = filterByOpenGardenActivity;\n map.District = filterByDistrict;\n map.Union = filterByUnion;\n map.EventType = filterByType;\n map.FromPeriod = filterByFromDate;\n map.ToPeriod = filterByToDate;\n map.FromRange = filterBySizeRangeFrom;\n map.ToRange = filterBySizeRangeTo;\n\n const groupBy = (x, f) => x.reduce((a, b) => ((a[f(b)] ||= []).push(b), a), {});\n\n // Default method with with logic that tests if a location matches a specific filter.\n // This method should be overriden in the specific Location Subclass\n this.filterMatch = function (filterData, inputNameMapping, sizeMapping) {\n checkPeriod = false;\n checkPeriodFrom = null;\n checkPeriodTo = null;\n\n const groupedFiltering = groupBy([...filterData.entries()].filter(x => x[1] != ''), pair => inputNameMapping[pair[0]].Type);\n for (const item in groupedFiltering) {\n const mapItemFunction = map[item];\n const ids = groupedFiltering[item].map(x => x[0]);\n const states = groupedFiltering[item].map(x => x[1]);\n //console.log(ids);\n if (mapItemFunction && !mapItemFunction(ids, states, sizeMapping)) {\n return false;\n }\n }\n\n if (checkPeriod) {\n return checkOpenGardenPeriod();\n }\n\n return true;\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAGA;AAAA;;A;;;;;;;;;;;;;;;;;;;;ACnEA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAEA;AACA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AAAA;AAAA;AAEA;AACA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;;A;;A","sourceRoot":""}