/**
 * @since Last modified: 2024-07-20 16:03:41
 * @function slideToggle
 * @description Toggle slideDown and slideUp.
 * @param {object} options  - The parameters of slide.
 * @param {getEl} [options.el]  - The target node.The writing is the same as getEl.
 * @param {string} [options.display=block]  - The display of box.Can be filled in:'block'|'flex'|'inline-flex'|'inline-block'|'grid'.
 * @param {curve} [options.curve=easeOut]  - Animation curve.Can be filled in:'linear'|'ease'|'easeIn'|'easeOut'|'easeInOut'|'easeOutIn'.
 * @param {boolean} [options.cut=true]  - Forced overflow truncation,means to add the style attribute of the element:"overflow:hidden".
 * @param {number} [options.duration]  - The duration of slide up.The unit is ms.The default is automatically calculated by the element height.
 * @param {object} [options.doing]  - The cbs in progress.Properties include "down" and  "up".
 * @param {fn_cb_ease_app} [options.doing.down]  - The call back in slide down.Support parameters:"frame"(animation frame) , "step"(progress) and "value" (height).
 * @param {fn_cb_ease_app} [options.doing.up]  - The call back in slide up.Support parameters:"frame"(animation frame) , "step"(progress) and "value" (height).
 * @param {fn_cb_ease_app} [options.done]  - The call back in progress.Support parameters:"frame"(animation frame) , "step"(progress) and "value" (height).
 * @returns {*} - The the target dom.
 * @see {@link https://codepen.io/axui/pen/rNPRmdm|demo @ codepen}
 * @example
 * ax.slideToggle({el:'#demo'});
 * <!--return the target dom-->
 */
'use strict';
import getEl from "./getEl";
import slideDown from "./slideDown";
import slideUp from "./slideUp";
import elState from "./elState";
let slideToggle = ({ el, display = 'block', doing, done, duration, curve = 'easeOut', cut = true }) => {
    let target = getEl(el);
    if (!target) {
        throw new Error('The target node does not exist!');
    }
    if (elState(target).isHidden) {
        slideDown({ el: target, display, duration, curve, cut, doing: doing?.down, done });
    }
    else if (elState(target).isCalc) {
        slideUp({ el: target, display, duration, curve, cut, doing: doing?.up, done });
    }
    return target;
};
export default slideToggle;
