"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SVGIcon = void 0;

var _react = _interopRequireDefault(require("react"));

var _theme = require("../../../theme");

var _native = _interopRequireDefault(require("styled-components/native"));

var _styledSystem = require("styled-system");

var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

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

function _extends() { _extends = Object.assign || 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); }

const SVG = (0, _native.default)(_reactNativeSvg.default)(_styledSystem.color, _styledSystem.space, _styledSystem.typography);

const SVGIcon = ({
  viewBox,
  color: colorProp,
  stroke,
  strokeWidth,
  children,
  focusable,
  size,
  style
}) => {
  const newProps = (0, _theme.usePropsConfig)('Icon', {
    size
  });
  let strokeColor = (0, _theme.useToken)('colors', stroke || '');
  return /*#__PURE__*/_react.default.createElement(SVG, {
    height: parseInt(newProps.dimension || newProps.size, 10),
    width: parseInt(newProps.dimension || newProps.size, 10),
    viewBox: viewBox,
    color: colorProp,
    stroke: strokeColor,
    strokeWidth: strokeWidth,
    focusable: focusable,
    accessibilityRole: 'image',
    style: style
  }, _react.default.Children.count(children) > 0 ? /*#__PURE__*/_react.default.createElement(_reactNativeSvg.G, null, _react.default.Children.map(children, ({
    props: childProps,
    type
  }) => type.name === 'Path' ? /*#__PURE__*/_react.default.createElement(ChildPath, childProps) : null)) : getDefaultIcon());
};

exports.SVGIcon = SVGIcon;

const ChildPath = ({
  fill,
  stroke: pathStroke,
  ...remainingProps
}) => {
  let pathStrokeColor = (0, _theme.useToken)('colors', pathStroke || '');
  let fillColor = (0, _theme.useToken)('colors', fill || '');
  return /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Path, _extends({}, remainingProps, {
    fill: fillColor ? fillColor : 'currentColor',
    stroke: pathStrokeColor
  }));
};

const getDefaultIcon = () => {
  return /*#__PURE__*/_react.default.createElement(_reactNativeSvg.G, {
    strokeWidth: 1.5,
    stroke: "currentColor"
  }, /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Path, {
    d: 'M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25',
    fill: "none"
  }), /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Path, {
    d: 'M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0',
    fill: "none"
  }), /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Circle, {
    cx: "12",
    cy: "12",
    r: "11.25",
    fill: "none"
  }));
};
//# sourceMappingURL=SVGIcon.js.map