import { cubicOut } from 'svelte/easing';
export { blur, crossfade, draw, fade, fly, scale } from 'svelte/transition';
export function fadeDown(node, { delay = 0, duration = 200, easing = cubicOut, distance = 25, direction = -1 }) {
    const style = getComputedStyle(node);
    const opacity = +style.opacity;
    return {
        delay,
        duration,
        easing,
        css: (t) => {
            return ('overflow: hidden;' +
                `opacity: ${t * opacity};` +
                `transform: translate(0, ${direction * (1 - t) * distance}%);`);
        },
    };
}
export function fadeUp(node, params = {}) {
    params.direction = 1;
    return fadeDown(node, params);
}
export function slide(node, { fadeStart = 0.5, delay = 0, duration = 200, easing = cubicOut }) {
    const style = getComputedStyle(node);
    const opacity = +style.opacity;
    const height = parseFloat(style.height);
    const padding_top = parseFloat(style.paddingTop);
    const padding_bottom = parseFloat(style.paddingBottom);
    const margin_top = parseFloat(style.marginTop);
    const margin_bottom = parseFloat(style.marginBottom);
    const border_top_width = parseFloat(style.borderTopWidth);
    const border_bottom_width = parseFloat(style.borderBottomWidth);
    const fade = 1 / fadeStart;
    return {
        delay,
        duration,
        easing,
        css: t => 'overflow: hidden;' +
            `opacity: ${Math.min(t * fade, 1) * opacity};` +
            `height: ${t * height}px;` +
            `padding-top: ${t * padding_top}px;` +
            `padding-bottom: ${t * padding_bottom}px;` +
            `margin-top: ${t * margin_top}px;` +
            `margin-bottom: ${t * margin_bottom}px;` +
            `border-top-width: ${t * border_top_width}px;` +
            `border-bottom-width: ${t * border_bottom_width}px;`,
    };
}
export function grow(node, { defaultWidth = 0, fadeStart = 0.5, delay = 0, duration = 200, easing = cubicOut }) {
    const style = getComputedStyle(node);
    const opacity = +style.opacity;
    const width = parseFloat(style.width);
    const height = parseFloat(style.height);
    const padding_left = parseFloat(style.paddingLeft);
    const padding_right = parseFloat(style.paddingRight);
    const padding_top = parseFloat(style.paddingTop);
    const padding_bottom = parseFloat(style.paddingBottom);
    const margin_left = parseFloat(style.marginLeft);
    const margin_right = parseFloat(style.marginRight);
    const margin_top = parseFloat(style.marginTop);
    const margin_bottom = parseFloat(style.marginBottom);
    const border_left_width = parseFloat(style.borderLeftWidth);
    const border_right_width = parseFloat(style.borderRightWidth);
    const border_top_width = parseFloat(style.borderTopWidth);
    const border_bottom_width = parseFloat(style.borderBottomWidth);
    const fade = 1 / fadeStart;
    return {
        delay,
        duration,
        easing,
        css: t => 'overflow: hidden;' +
            `opacity: ${Math.min(t * fade, 1) * opacity};` +
            `width: ${defaultWidth + t * (width - defaultWidth)}px;` +
            `height: ${t * height}px;` +
            `padding-left: ${t * padding_left}px;` +
            `padding-right: ${t * padding_right}px;` +
            `padding-top: ${t * padding_top}px;` +
            `padding-bottom: ${t * padding_bottom}px;` +
            `margin-left: ${t * margin_left}px;` +
            `margin-right: ${t * margin_right}px;` +
            `margin-top: ${t * margin_top}px;` +
            `margin-bottom: ${t * margin_bottom}px;` +
            `border-left-width: ${t * border_left_width}px;` +
            `border-right-width: ${t * border_right_width}px;` +
            `border-top-width: ${t * border_top_width}px;` +
            `border-bottom-width: ${t * border_bottom_width}px;`,
    };
}
export function slideH(node, { delay = 0, duration = 200, easing = cubicOut }) {
    const style = getComputedStyle(node);
    const width = parseFloat(style.width);
    const paddingLeft = parseFloat(style.paddingLeft);
    const paddingRight = parseFloat(style.paddingRight);
    const marginLeft = parseFloat(style.marginLeft);
    const marginRight = parseFloat(style.marginRight);
    const borderLeftWidth = parseFloat(style.borderLeftWidth);
    const borderRightWidth = parseFloat(style.borderRightWidth);
    return {
        delay,
        duration,
        easing,
        css: (t) => {
            return ('overflow: hidden;' +
                `width: ${t * width}px;` +
                `padding-left: ${t * paddingLeft}px;` +
                `padding-right: ${t * paddingRight}px;` +
                `margin-left: ${t * marginLeft}px;` +
                `margin-right: ${t * marginRight}px;` +
                `border-left-width: ${t * borderLeftWidth}px;` +
                `border-right-width: ${t * borderRightWidth}px;`);
        },
    };
}
export function slideIn(node, { delay = 0, duration = 250, easing = cubicOut } = {}) {
    const style = getComputedStyle(node);
    const height = parseFloat(style.height);
    const width = parseFloat(style.width);
    return {
        delay,
        duration,
        easing,
        css: t => 'position: fixed;' + `height: ${height}px;` + `width: ${width}px;` + `left: ${(1 - t) * -width}px;`,
    };
}
