/**
 * @since Last modified: 2024/03/19 09:16:43
 * @function toggle
 * @description Toggle show and hide.
 * @param {object} options  - The parameters of fade.
 * @param {getEl} [options.el]  - The target node.The writing is the same as getEl.
 * @param {string} [options.show="block"]  - The show method of box.Can be filled in:'block'|'flex'|'inline-flex'|'inline-block'|'grid'|'visible'.
 * @param {string} [options.hide="none"]  - The hide method of box.Can be filled in:'none'|'hidden'.
 * @param {object} [options.done]  - The cbs in progress.Properties include "show" and  "hide".
 * @param {function} [options.doing.show]  - The call back in show.No parameters.
 * @param {function} [options.doing.hide]  - The call back in hide.No parameters.
 * @returns {*} - The the target dom.
 * @see {@link https://codepen.io/axui/pen/ZEwPVLw|demo @ codepen}
 * @example
 * ax.toggle({el:'#demo'});
 * <!--return the target dom-->
 */
'use strict';
import elState from "./elState";
import getEl from "./getEl";
import hide from "./hide";
import show from "./show";
let toggle = ({ el, display = { show: 'block', hide: 'none' }, done }) => {
    let target = getEl(el);
    if (!target) {
        throw new Error('The target node does not exist!');
    }
    elState(target).isVisible ? hide({ el: target, display: display.hide, done: done?.hide }) : show({ el: target, display: display.show, done: done?.show });
    return target;
};
export default toggle;
