import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
import { createSelectorQuery } from "@tarojs/taro";
import { getRect, inBrowser } from "../hooks/use-client-rect";
export function makeRect(width, height) {
    return {
        top: 0,
        left: 0,
        right: width,
        bottom: height,
        width: width,
        height: height
    };
}
export var getRectByTaro = /*#__PURE__*/ function() {
    var _ref = _async_to_generator(function(element) {
        return _ts_generator(this, function(_state) {
            if (element) {
                if (inBrowser) {
                    return [
                        2,
                        Promise.resolve(getRect(element))
                    ];
                }
                // 小程序下的逻辑
                return [
                    2,
                    new Promise(function(resolve, reject) {
                        createSelectorQuery().select("#".concat(element.uid)).boundingClientRect().exec(function(param) {
                            var _param = _sliced_to_array(param, 1), rects = _param[0];
                            resolve(rects);
                        });
                    })
                ];
            }
            return [
                2,
                Promise.resolve(makeRect(0, 0))
            ];
        });
    });
    return function getRectByTaro(element) {
        return _ref.apply(this, arguments);
    };
}();
