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pack://_N_E/./utils/mapbox.ts"],"sourcesContent":["import { Feature, GeoJsonProperties, Geometry } from 'geojson';\nimport mapboxgl from 'mapbox-gl';\n\nimport {\n MapboxPlacesResult,\n MapboxPlacesResultTranslated,\n} from '@/app/api/mapbox-places/types';\nimport { CustomOption } from '@/components/form/CustomSelect/types';\nimport {\n LocationPhases,\n SimpleLocationDto,\n SimpleLocationSearchDto,\n} from '@/lib/locations/dto';\nimport { SearchMeetingRoomsPricesDto } from '@/lib/meeting-rooms/dto/search-meeting-rooms-prices.dto';\nimport { SimpleMeetingRoomDto } from '@/lib/meeting-rooms/dto/simple-meeting-room.dto';\n\nimport { isExternalLocation, isIndustriousLocation } from './locations';\n\nexport type LocationMapFeatureProps = Pick<\n SimpleLocationSearchDto,\n 'id' | 'slug' | 'name' | 'address' | 'city' | 'zipCode' | 'phone'\n> & {\n imageUrl?: string;\n imageAltText?: string | null;\n lat: number;\n lng: number;\n external?: boolean;\n externalLink?: string;\n state: string | null;\n phase?: LocationPhases;\n};\n\nexport type MeetingRoomMapFeatureProps = Pick<\n SimpleMeetingRoomDto,\n | 'slug'\n | 'name'\n | 'locationName'\n | 'seats'\n | 'amenities'\n | 'currencyIsoCode'\n | 'city'\n | 'locationTier'\n> & {\n imageUrl?: string;\n imageAltText?: string | null;\n prices?: SearchMeetingRoomsPricesDto['key'];\n lat: number;\n lng: number;\n};\n\nexport function getMapboxFeaturesLocations(\n locations: (SimpleLocationSearchDto | SimpleLocationDto)[]\n): Feature[] {\n return locations\n .filter(\n (loc) =>\n (isIndustriousLocation(loc) && !!loc.slug) || !!loc.geolocalization\n )\n .map((loc) => ({\n type: 'Feature',\n properties: {\n id: loc.id,\n slug: loc.slug,\n imageUrl: loc.image?.url,\n imageAltText: loc.image?.altText,\n name: loc.name,\n address: loc.address,\n city: loc.city,\n state: isIndustriousLocation(loc) ? loc.state : null,\n zipCode: loc.zipCode,\n phone: loc.phone,\n lat: loc.geolocalization.lat,\n lng: loc.geolocalization.lng,\n isExternal: loc.isExternal,\n externalLink: isExternalLocation(loc) ? loc.externalLink : undefined,\n phase: isIndustriousLocation(loc) ? loc.phase : undefined,\n },\n geometry: {\n type: 'Point',\n coordinates: [loc.geolocalization.lng, loc.geolocalization.lat],\n },\n }));\n}\n\nexport function getMapboxFeaturesMeetingRooms(\n meetingRooms: SimpleMeetingRoomDto[],\n prices?: SearchMeetingRoomsPricesDto\n): Feature[] {\n return meetingRooms.map((room) => ({\n type: 'Feature',\n properties: {\n slug: room.slug,\n name: room.name,\n seats: room.seats,\n amenities: room.amenities,\n locationName: room.locationName,\n imageUrl: room.image?.url,\n imageAltText: room.image?.altText,\n prices: prices?.[room.slug] || undefined,\n lat: room.geolocalization.lat,\n lng: room.geolocalization.lng,\n currencyIsoCode: room.currencyIsoCode,\n city: room.city,\n },\n geometry: {\n type: 'Point',\n coordinates: [room.geolocalization.lng, room.geolocalization.lat],\n },\n }));\n}\n\n// Because features come from tiled vector data, feature geometries may be split\n// or duplicated across tile boundaries. As a result, features may appear multiple times in query results.\nexport function getUniqueFeatures(\n features: Feature[]\n): Feature[] {\n const uniqueIds = new Set();\n const uniqueFeatures = [];\n for (const feature of features) {\n const id = feature.id || feature.properties?.slug;\n if (!uniqueIds.has(id)) {\n uniqueIds.add(id);\n uniqueFeatures.push(feature);\n }\n }\n return uniqueFeatures;\n}\n\nfunction getClusterLeavesOfSource(\n cluster_id: number,\n limit: number,\n offset: number,\n source: mapboxgl.GeoJSONSource\n): Promise[]> {\n return new Promise((resolve, reject) => {\n source.getClusterLeaves(cluster_id, limit, offset, (err, features) => {\n if (err) reject(err);\n else resolve(features);\n });\n });\n}\n\nexport const getArrayOfKeyRenderedFeaturesWithinView = async (\n source: mapboxgl.GeoJSONSource,\n renderedFeatures: Feature[],\n key: string\n) => {\n let arrayOfKeyRendered: string[] = [];\n try {\n for await (const feature of renderedFeatures) {\n const props = feature.properties!;\n const isACluster = props.cluster;\n if (isACluster) {\n const aFeatures = await getClusterLeavesOfSource(\n props.cluster_id,\n props.point_count,\n 0,\n source\n );\n const allInCluster = aFeatures.map((f) => f.properties![key]);\n arrayOfKeyRendered = [...arrayOfKeyRendered, ...allInCluster];\n } else {\n arrayOfKeyRendered = [...arrayOfKeyRendered, props[key]];\n }\n }\n } catch (error) {\n return arrayOfKeyRendered;\n }\n return arrayOfKeyRendered;\n};\n\nexport function getCenterFromFeatures(\n featuresLocations: Feature[]\n) {\n const bounds = new mapboxgl.LngLatBounds();\n\n for (const feature of featuresLocations) {\n if (feature.geometry.type === 'Point') {\n bounds.extend(feature.geometry.coordinates as [number, number]);\n }\n }\n\n return bounds.getCenter();\n}\n\nexport const getPlaceNameArrayFromFeature = (\n feature: MapboxPlacesResult,\n locale: string\n) => {\n const name =\n feature[`place_name_${locale}` as keyof MapboxPlacesResultTranslated] ||\n feature.place_name;\n const placeName = name.split(',');\n\n return placeName;\n};\n\nexport const mapResultsToOptions = (\n results: MapboxPlacesResult[],\n locale: string\n): CustomOption[] =>\n results.map((feat) => {\n const placeNameArray = getPlaceNameArrayFromFeature(feat, locale);\n return {\n label: placeNameArray.shift() as string,\n description: placeNameArray.join(','),\n value: feat.id as string,\n };\n });\n"],"names":["getMapboxFeaturesLocations","locations","filter","_locations__WEBPACK_IMPORTED_MODULE_1__","jS","loc","slug","geolocalization","map","type","properties","id","imageUrl","image","url","imageAltText","altText","name","address","city","state","isIndustriousLocation","zipCode","phone","lat","lng","isExternal","externalLink","isExternalLocation","undefined","phase","geometry","coordinates","getMapboxFeaturesMeetingRooms","meetingRooms","prices","room","seats","amenities","locationName","currencyIsoCode","getUniqueFeatures","features","uniqueIds","Set","uniqueFeatures","feature","has","add","push","getArrayOfKeyRenderedFeaturesWithinView","source","renderedFeatures","key","arrayOfKeyRendered","props","cluster","allInCluster","aFeatures","getClusterLeavesOfSource","cluster_id","limit","offset","Promise","resolve","reject","getClusterLeaves","err","point_count","f","error","getCenterFromFeatures","featuresLocations","bounds","mapboxgl","extend","getCenter","getPlaceNameArrayFromFeature","locale","concat","place_name","split","mapResultsToOptions","results","placeNameArray","feat","label","shift","description","join","value"],"sourceRoot":""}