'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: 42
    }
  }, _react2.default.createElement(_gradient.GradientOrangeRed, { id: 'voronoi_orange_red', __source: {
      fileName: _jsxFileName,
      lineNumber: 43
    }
  }), _react2.default.createElement(_gradient.GradientPinkRed, { id: 'voronoi_pink_red', __source: {
      fileName: _jsxFileName,
      lineNumber: 44
    }
  }), _react2.default.createElement(_clipPath.RectClipPath, { id: 'voronoi_clip', width: innerWidth, height: innerHeight, rx: 14, __source: {
      fileName: _jsxFileName,
      lineNumber: 45
    }
  }), _react2.default.createElement(_group.Group, { top: margin.top, left: margin.left, clipPath: 'url(#voronoi_clip)', __source: {
      fileName: _jsxFileName,
      lineNumber: 46
    }
  }, 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: 48
      }
    });
  }), 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: 59
      }
    });
  })));
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvdGlsZXMvdm9yb25vaS5qcyJdLCJuYW1lcyI6WyJSZWFjdCIsIkdyb3VwIiwiR3JhZGllbnRPcmFuZ2VSZWQiLCJHcmFkaWVudFBpbmtSZWQiLCJSZWN0Q2xpcFBhdGgiLCJ2b3Jvbm9pIiwiVm9yb25vaVBvbHlnb24iLCJ3aWR0aCIsImhlaWdodCIsIm1hcmdpbiIsInRvcCIsImxlZnQiLCJyaWdodCIsImJvdHRvbSIsImlubmVyV2lkdGgiLCJpbm5lckhlaWdodCIsImRhdGEiLCJBcnJheSIsImZpbGwiLCJtYXAiLCJ4IiwiTWF0aCIsInJhbmRvbSIsInkiLCJpZCIsInRvU3RyaW5nIiwic2xpY2UiLCJ2b3Jvbm9pTGF5b3V0IiwiZCIsInBvbHlnb25zIiwicG9seWdvbiIsInRvTG93ZXJDYXNlIl0sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSxBQUFPOzs7O0FBQ1AsQUFBUzs7QUFDVCxBQUFTLEFBQW1COztBQUM1QixBQUFTOztBQUVULEFBQVMsQUFBUyxBQUVsQjs7Ozs7O2tCQUFlLGdCQVNUO01BUkosQUFRSSxhQVJKLEFBUUk7TUFQSixBQU9JLGNBUEosQUFPSTt5QkFOSixBQU1JO01B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