import { FilterValueFormatter , GeoPolygonFilter , FILTERS , Filter , isGeoPolygonFilter , } from '../../../../../common' ; const POINTS_SEPARATOR = ', ' ; const getFormattedValueFn = ( points ) => { return ( formatter ? ) => { return points . map ( ( point ) => ( formatter ? formatter . convert ( point ) : JSON . stringify ( point ) ) ) . join ( POINTS_SEPARATOR ) ; } ; } ; function getParams ( filter ) { const key = Object . keys ( filter . geo_polygon ) . filter ( ( k ) => k !== 'ignore_unmapped' ) [ 0 ] ; const params = filter . geo_polygon [ key ] ; return { key , params , type : FILTERS . GEO_POLYGON , value : getFormattedValueFn ( params . points || [ ] ) , } ; } export function mapGeoPolygon ( filter ) { if ( ! isGeoPolygonFilter ( filter ) ) { throw filter ; } return getParams ( filter ) ; }