/**
 * @since Last modified: 2024/06/10 18:26:14
 * @constant spreadBool
 * @description Expand the parameters of "true" into a real default parameters.Support infinite depth.
 * @param {object|boolean} host  - The host options.
 * @param {object} params  - default parameters.
 * @returns {object} - The host options expanded.
 * @see {@link https://codepen.io/axui/pen/RwvmpJG|demo @ codepen}
 * @example
 * ax.spreadBool(options,{a:{},b:{}});
 * <!--options.a=true,options.b=true -> options.a={},options.b={}-->
 * ax.spreadBool(options,{a:[],b:{}});
 * <!--options.a=false,options.b=false -> options.a=false,options.b={enable:false}-->
 */
'use strict';
import getDataType from "./getDataType";
const spreadBool = (host, params) => {
    let result = host, hostType = getDataType(host), paramsType = getDataType(params);
    if (paramsType === 'Object') {
        if (hostType === 'Boolean') {
            Reflect.deleteProperty(params, 'enable');
            result = { enable: host, ...params };
        }
        else if (hostType === 'Object') {
            if (host.hasOwnProperty('enable')) {
                host = Object.assign({}, params, host);
            }
            else {
                for (let k in params) {
                    if (params.hasOwnProperty(k) && host.hasOwnProperty(k)) {
                        host[k] = spreadBool(host[k], params[k]);
                    }
                }
            }
        }
    }
    return result;
};
export default spreadBool;
