/**
 * @since Last modified: 2024/06/01 11:03:43
 * @function getAttrArr
 * @description Gets a array value from a node attribute.
 * @param {string} value  - The value obtained through the "getAttribute" method.
 * @param {string} [default='']  - The value obtained through the "getAttribute" method.
 * @returns {array} Return a array value.
 * @see {@link https://codepen.io/axui/pen/ZENBYNL|demo @ codepen}
 * @example
 * ax.getAttrArr('true');
 * <!--return []-->
 * ax.getAttrArr('true','close');
 * <!--return ['close']-->
 * ax.getAttrArr(null);
 * <!--return []-->
 * ax.getAttrArr('','close');
 * <!--return ['close']-->
* ax.getAttrArr('close,toggle');
 * <!--return ['close','toggle']-->
 * ax.getAttrArr('['toggle']','close');
 * <!--return ['toggle']-->
 */
'use strict';
const getAttrArr = (val, dft = '') => {
    let result = [];
    if (val !== null) {
        let tmp = val.trim();
        try {
            if (tmp === '' || tmp === 'true') {
                result = dft.split(',').filter(Boolean);
            }
            else {
                let val = new Function('return ' + tmp)();
                result = Array.isArray(val) ? val : [tmp];
            }
        }
        catch (err) {
            result = tmp.split(',');
        }
    }
    return result;
};
export default getAttrArr;
