import { FormlyFieldConfig } from '@ngx-formly/core' ; export { cloneDeep , get , set , unset } from 'lodash-es' ; const keyPathMemberName = '_formlyDesignerKeyPath' ; export function getKeyPath ( field ) { if ( ! ( < any > field ) [ keyPathMemberName ] || ( < any > field ) [ keyPathMemberName ] . key !== field . key ) { let keyPath = [ ] ; if ( field . key ) { const pathElements = isArray ( field . key ) ? field . key : field . key . toString ( ) . split ( '.' ) ; for ( let pathElement of pathElements ) { if ( typeof pathElement === 'string' ) { pathElement = pathElement . replace ( /\[(\w+)\]/g , '.$1' ) ; keyPath = keyPath . concat ( pathElement . split ( '.' ) ) ; } else { keyPath . push ( pathElement ) ; } } for ( let i = 0 ; i < keyPath . length ; i ++ ) { const pathElement = keyPath [ i ] ; if ( typeof pathElement === 'string' && /^\d+$/ . test ( pathElement ) ) { keyPath [ i ] = parseInt ( pathElement , 10 ) ; } } } ( < any > field ) [ keyPathMemberName ] = { key : field . key , path : keyPath , } ; } return ( < any > field ) [ keyPathMemberName ] . path . slice ( ) ; } export function equalType ( a , b ) { return ( ! a . fieldArray === ! b . fieldArray ) && ( ! a . fieldGroup === ! b . fieldGroup ) ; } export const isArray = Array . isArray ; export const isEmpty = ( val ) : boolean => { if ( val == null ) { return true ; } else if ( typeof val === 'function' || typeof val === 'number' || typeof val === 'boolean' || Object . prototype . toString . call ( val ) === '[object Date]' ) { return false ; } else if ( val . length === 0 ) { return true ; } else if ( typeof val === 'object' ) { let r = true ; for ( const _ in val ) r = false ; return r ; } return false ; } ; export const isFunction = ( val ) : boolean => typeof val === 'function' ; export const isObject = ( val ) : boolean => val != null && typeof val === 'object' ; export const isString = ( val ) : boolean => typeof val === 'string' || val instanceof String ; /** Source:  https://stackoverflow.com/a/8809472 */ export const generateUuid = ( ) => { let d = new Date ( ) . getTime ( ) ; let d2 = ( performance ?. now && ( performance . now ( ) * 1000 ) ) || 0 ; return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( /[xy]/g , c => { let r = Math . random ( ) * 16 ; if ( d > 0 ) { r = ( d + r ) % 16 | 0 ; d = Math . floor ( d / 16 ) ; } else { r = ( d2 + r ) % 16 | 0 ; d2 = Math . floor ( d2 / 16 ) ; } return ( c == 'x' ? r : ( r & 0x7 | 0x8 ) ) . toString ( 16 ) ; } ) ; } ;