import * as React from 'react' ; import { equals as structEq } from './equals' ; export { equals as structEq } from './equals' ; export const DEV_ENV = typeof process !== 'undefined' && process . env . NODE_ENV !== 'production' ; export function setKey < T , K extends keyof T > ( k , v , o ) { if ( k in o && structEq ( v , o [ k ] ) ) { return o ; } else { const r = { } as any ; for ( const p in o ) r [ p ] = o [ p ] ; r [ k ] = v ; return r ; } } /**
 * 'Conserve' a value's identity if its structure doesn't change.
 */ function conserve < T > ( x , y ) { return structEq ( x , y ) ? y : x ; } /**
 * Make a fold function's behaviour conservative in its input value's
 * identity.
 */ export function conservatively < T , U > ( fn ) { return ( y , c0 ) => conserve ( fn ( y , c0 ) , c0 ) ; } export function findIndex < T > ( xs , p ) { for ( let i = 0 ; i < xs . length ; i ++ ) { if ( p ( xs [ i ] ) ) return i ; } return - 1 ; } export function warning ( message ) { if ( typeof console !== 'undefined' && typeof console . error === 'function' ) { console . error ( '[Focal]: ' + message ) ; } try { throw new Error ( message ) ; } catch ( _ ) { } } export function getReactComponentName ( component ) { return typeof component === 'string' ? component : ( component as React . ComponentClass < any > ) . displayName !== undefined ? ( component as React . ComponentClass < any > ) . displayName : ( component as React . StatelessComponent < any > ) . name !== undefined ? ( component as React . StatelessComponent < any > ) . name : component . constructor && component . constructor . name !== undefined ? component . constructor . name : undefined ; } export type Option < T > = T | undefined ;