"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    getRectByTaro: function() {
        return getRectByTaro;
    },
    makeRect: function() {
        return makeRect;
    }
});
var _async_to_generator = require("@swc/helpers/_/_async_to_generator");
var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
var _ts_generator = require("@swc/helpers/_/_ts_generator");
var _taro = require("@tarojs/taro");
var _useclientrect = require("../hooks/use-client-rect");
function makeRect(width, height) {
    return {
        top: 0,
        left: 0,
        right: width,
        bottom: height,
        width: width,
        height: height
    };
}
var getRectByTaro = /*#__PURE__*/ function() {
    var _ref = (0, _async_to_generator._)(function(element) {
        return (0, _ts_generator._)(this, function(_state) {
            if (element) {
                if (_useclientrect.inBrowser) {
                    return [
                        2,
                        Promise.resolve((0, _useclientrect.getRect)(element))
                    ];
                }
                // 小程序下的逻辑
                return [
                    2,
                    new Promise(function(resolve, reject) {
                        (0, _taro.createSelectorQuery)().select("#".concat(element.uid)).boundingClientRect().exec(function(param) {
                            var _param = (0, _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);
    };
}();
