'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _group = require('@vx/group');

var _gradient = require('@vx/gradient');

var _clipPath = require('@vx/clip-path');

var _voronoi = require('@vx/voronoi');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _jsxFileName = '/Users/hshoff/code/vx/packages/vx-demo/components/tiles/voronoi.js';

exports.default = function (_ref) {
  var width = _ref.width,
      height = _ref.height,
      _ref$margin = _ref.margin,
      margin = _ref$margin === undefined ? {
    top: 0,
    left: 0,
    right: 0,
    bottom: 76
  } : _ref$margin;

  if (width < 10) return _react2.default.createElement('div', {
    __source: {
      fileName: _jsxFileName,
      lineNumber: 18
    }
  });
  var innerWidth = width - margin.left - margin.right;
  var innerHeight = height - margin.top - margin.bottom;

  var data = Array(150).fill(null).map(function () {
    return {
      x: Math.random() * innerWidth,
      y: Math.random() * innerHeight,
      id: Math.random().toString(36).slice(2)
    };
  });

  var voronoiLayout = (0, _voronoi.voronoi)({
    x: function x(d) {
      return d.x;
    },
    y: function y(d) {
      return d.y;
    },
    width: innerWidth,
    height: innerHeight
  });

  var polygons = voronoiLayout.polygons(data);

  return _react2.default.createElement('svg', { width: width, height: height, __source: {
      fileName: _jsxFileName,
      lineNumber: 38
    }
  }, _react2.default.createElement(_gradient.GradientOrangeRed, { id: 'voronoi_orange_red', __source: {
      fileName: _jsxFileName,
      lineNumber: 39
    }
  }), _react2.default.createElement(_gradient.GradientPinkRed, { id: 'voronoi_pink_red', __source: {
      fileName: _jsxFileName,
      lineNumber: 40
    }
  }), _react2.default.createElement(_clipPath.RectClipPath, {
    id: 'voronoi_clip',
    width: innerWidth,
    height: innerHeight,
    rx: 14,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 41
    }
  }), _react2.default.createElement(_group.Group, {
    top: margin.top,
    left: margin.left,
    clipPath: 'url(#voronoi_clip)',
    __source: {
      fileName: _jsxFileName,
      lineNumber: 47
    }
  }, polygons.map(function (polygon) {
    return _react2.default.createElement(_voronoi.VoronoiPolygon, {
      key: 'polygon-' + polygon.data.id,
      polygon: polygon,
      fill: function fill(d) {
        return d.id.toLowerCase() <= 'a' ? 'url(#voronoi_orange_red)' : 'url(#voronoi_pink_red)';
      },
      stroke: '#fff',
      strokeWidth: 1,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 53
      }
    });
  }), data.map(function (d) {
    return _react2.default.createElement('circle', {
      key: 'circle-' + d.id,
      r: 2,
      cx: d.x,
      cy: d.y,
      fill: '#ffffff',
      fillOpacity: 0.2,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 65
      }
    });
  })));
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvdGlsZXMvdm9yb25vaS5qcyJdLCJuYW1lcyI6WyJSZWFjdCIsIkdyb3VwIiwiR3JhZGllbnRPcmFuZ2VSZWQiLCJHcmFkaWVudFBpbmtSZWQiLCJSZWN0Q2xpcFBhdGgiLCJ2b3Jvbm9pIiwiVm9yb25vaVBvbHlnb24iLCJ3aWR0aCIsImhlaWdodCIsIm1hcmdpbiIsInRvcCIsImxlZnQiLCJyaWdodCIsImJvdHRvbSIsImlubmVyV2lkdGgiLCJpbm5lckhlaWdodCIsImRhdGEiLCJBcnJheSIsImZpbGwiLCJtYXAiLCJ4IiwiTWF0aCIsInJhbmRvbSIsInkiLCJpZCIsInRvU3RyaW5nIiwic2xpY2UiLCJ2b3Jvbm9pTGF5b3V0IiwiZCIsInBvbHlnb25zIiwicG9seWdvbiIsInRvTG93ZXJDYXNlIl0sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSxBQUFPOzs7O0FBQ1AsQUFBUzs7QUFDVCxBQUFTLEFBQW1COztBQUM1QixBQUFTOztBQUVULEFBQVMsQUFBUyxBQUVsQjs7Ozs7O2tCQUFlLGdCQVNUO01BUkosQUFRSSxhQVJKLEFBUUk7TUFQSixBQU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