function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import Shape from './Shape';
import { PolylinePainter } from '../../modules/painters/PolylinePainter';
import { createLineFeature, createPointFeature } from '../../utils/common';

/**
 * Polyline props
 *
 * @category Props
 */

/**
  @category Component
 */
const Polyline = props => {
  const {
    id,
    onError,
    onFinish,
    ...styles
  } = props;
  const paitner = new PolylinePainter();
  const toFeatures = async points => {
    const drawingFeatures = [];
    if (points.length) {
      drawingFeatures.push(...points.map(p => createPointFeature(p, {
        type: 0
      })));
      if (points.length > 1) {
        drawingFeatures.push(createLineFeature(points, {
          type: 0
        }));
      }
    }
    return drawingFeatures;
  };
  return /*#__PURE__*/React.createElement(Shape, _extends({
    id: id
  }, styles, {
    paintner: paitner,
    toFeatures: toFeatures,
    onError: onError,
    onFinish: onFinish
  }));
};
export default Polyline;
//# sourceMappingURL=Polyline.js.map