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); }

/*
Copyright (c) 2018-2019 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import * as flags from './flags/index.js';
import { styled } from '../styles/index.js';
import { SIZE } from './constants.js';
export default function Flag(props) {
  const {
    $iso,
    iso: oldIsoProp,
    width = '16px',
    ...restProps
  } = props;
  const iso = oldIsoProp || $iso;
  const FlagComponent = flags[`Flag${iso.toUpperCase()}`];
  return React.createElement(FlagComponent, _extends({
    width: width,
    "data-iso": iso
  }, restProps));
}
export const StyledFlag = styled(Flag, ({
  $size = SIZE.default,
  $theme: {
    sizing
  }
}) => {
  const sizeToWidth = {
    [SIZE.compact]: sizing.scale800,
    [SIZE.default]: sizing.scale900,
    [SIZE.large]: sizing.scale1000
  };
  return {
    width: sizeToWidth[$size]
  };
});
StyledFlag.displayName = "StyledFlag";