/**
 * @since Last modified: 2024-07-21 23:04:24
 * @function elState
 * @description Determine the state of the node.
 * @param {getEl} elem - Node or node selector.
 * @returns  {object} - Return state object,include properties:isExist,isVirtual,isHidden and isUncalc.
 * @see {@link https://codepen.io/axui/pen/PoVxWrd|demo @ codepen}
 * @example
 * ax.elState('#demo');
 * <!--return { isExist:true, isVirtual:true, isHidden:false, isCalc:false,isUncalc: true }-->
 */
'use strict';
import { T_obj } from '../../../types/ax';
import getEl from './getEl';
type T_elstate_result = { isExist: boolean, isCalc: boolean, isUncalc: boolean, isVirtual?: boolean, isHidden?: boolean, isVisible?: boolean }
const elState = (elem: any): T_elstate_result => {
    let dom = getEl(elem),
        isExist = dom ? true : false,
        result;
    if (!dom) {
        result = { isExist, isCalc: false, isUncalc: true }
    } else {
        let style = getComputedStyle(dom as Element),
            isVirtual = !style.display,
            isHidden = (style.display === 'none' || style.visibility === 'hidden'),
            isCalc = !!(style.display && style.display !== 'none'),
            isVisible = !!(isCalc && style.visibility === 'visible');
        result = { isExist, isVirtual, isHidden, isVisible, isCalc, isUncalc: isVirtual || isHidden }
    }
    return result;
}
export default elState;
