/**
 * @since Last modified: 2024-09-10 10:56:14
 * @function allToEls
 * @description Convert any data to an array of nodes.
 * @param {string|HTMLElement|Nodelist|any[]} data  - The data.Supports multiple data formats.
 * @returns {HTMLElement|null} Return a node array.
 * @see {@link https://codepen.io/axui/pen/OJGaXQp|demo @ codepen}
 * @example
 * ax.allToEls('#demo');
 * <!--return the target node-->
 */
'use strict';
import config from '../global/config';
import getDataType from './getDataType';
import getEl from './getEl';
import isEmpty from './isEmpty';
import trim from './trim';
const allToEls = (data, parent) => {
    if (isEmpty(data))
        return [];
    let result = [], type = getDataType(data);
    if (type.includes('HTML')) {
        result.push(data);
    }
    else if (type === 'String') {
        let str = trim(data), separator = str.includes(config.splitHyphen) ? config.splitHyphen : config.wordHyphen;
        str.split(separator).forEach(k => {
            let el = getEl(k, parent);
            el && result.push(el);
        });
    }
    else if (type === 'Array') {
        data.forEach(k => {
            let el = getEl(k, parent);
            el && result.push(el);
        });
    }
    else if (type === 'NodeList') {
        result = [...data];
    }
    return result;
};
export default allToEls;
