// @flow
import { getCountryCodes } from '../functions/countries'

export type ObjStringKeyValuesType = { [key: string]: string }

export type CssModuleType = ObjStringKeyValuesType

export type FlagIconSizesType =
  | "lg"
  | "2x"
  | "3x"
  | "4x"
  | "5x"

export type FlagIconRotateType =
  | 30
  | 60
  | 90
  | 180
  | 270

export type FlagIconFlipType =
  | "horizontal"
  | "vertical"

export type FlagIconPropsType = {
  code: string,
  squared?: boolean,
  size?: FlagIconSizesType,
  rotate?: FlagIconRotateType,
  flip?: FlagIconFlipType,
  Component?: string,
  children?: React$Element<*>
}

export type FlagIconOptionsType = {
  useCssModules?: boolean,
  themeStyles?: CssModuleType
}

export type KeyCallbackType = (key: string) => string

const countryCodesEnum = getCountryCodes().reduce(
  (arReturn: ObjStringKeyValuesType, countryCode: string): ObjStringKeyValuesType =>
    ({ ...arReturn, [countryCode]: countryCode })
  , {},
)

// SEE: https://github.com/facebook/flow/issues/627
export type FlagIconCodeType = $Keys<typeof countryCodesEnum>

export type FlagIconReturnType = (props: FlagIconPropsType) => React$Element<*>

export type FlagIconFactoryReturnType = FlagIconReturnType

export type CountryType = {
  name: string,
  code: FlagIconCodeType
}

@@ -60,16 +60,184 @@
 tries'%0A%0A
+// Workaround for exact types because: %22Exact fails when doing es6 object spread%22.%0A// SEE: https://github.com/facebook/flow/issues/2405%0Atype Exact%3CT%3E = T & $Shape%3CT%3E;%0A%0A
 export t
@@ -799,24 +799,30 @@
 tionsType = 
+Exact%3C
 %7B%0A  useCssMo
@@ -869,16 +869,17 @@
 leType%0A%7D
+%3E
 %0A%0Aexport

make FlagIconOptionsType exact