function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
import { useEffect, useMemo, useState } from "react";
/**
 * 响应式尺寸 Hook
 *
 * 用于计算图表的响应式宽度和高度，并监听窗口大小变化。
 * 在移动端（宽度 <= 768px）时自动调整为全宽和自适应高度。
 *
 * @param {number | string} width - 图表宽度，默认600px
 * @param {number | string} height - 图表高度，默认400px
 * @returns {object} 包含响应式尺寸和移动端标识的对象
 *
 * @example
 * ```typescript
 * const { responsiveWidth, responsiveHeight, isMobile } = useResponsiveSize(800, 400);
 * ```
 *
 * @since 1.0.0
 */ export var useResponsiveSize = function() {
    var width = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 600, height = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 400;
    var _useState = _sliced_to_array(useState(typeof window !== 'undefined' ? window.innerWidth : 768), 2), windowWidth = _useState[0], setWindowWidth = _useState[1];
    var isMobile = windowWidth <= 768;
    var responsiveWidth = isMobile ? '100%' : width;
    var responsiveHeight = isMobile ? Math.min(windowWidth * 0.8, 400) : height;
    useEffect(function() {
        var handleResize = function() {
            setWindowWidth(window.innerWidth);
        };
        if (typeof window !== 'undefined') {
            window.addEventListener('resize', handleResize);
            return function() {
                return window.removeEventListener('resize', handleResize);
            };
        }
    }, []);
    return useMemo(function() {
        return {
            responsiveWidth: responsiveWidth,
            responsiveHeight: responsiveHeight,
            isMobile: isMobile,
            windowWidth: windowWidth
        };
    }, [
        responsiveWidth,
        responsiveHeight,
        isMobile,
        windowWidth
    ]);
};
