import { defineComponent, shallowRef, ref, computed, onMounted, openBlock, createElementBlock, normalizeStyle, unref, normalizeClass, renderSlot, createVNode, withCtx } from 'vue';
import { PsIcon } from '../../icon/index.mjs';
import '../../../utils/index.mjs';
import { CaretTop } from '@element-plus/icons-vue';
import '../../../hooks/index.mjs';
import { backtopProps } from './backtop.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { throwError } from '../../../utils/error.mjs';

const __default__ = {
  name: "PsBacktop"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: backtopProps,
  setup(__props) {
    const props = __props;
    const COMPONENT_NAME = "PsBacktop";
    const ns = useNamespace("backtop");
    const el = shallowRef();
    const container = shallowRef();
    const visible = ref(false);
    const backTopStyle = computed(() => ({
      right: `${props.right}px`,
      bottom: `${props.bottom}px`
    }));
    onMounted(() => {
      var _a;
      container.value = document;
      el.value = document.documentElement;
      if (props.target) {
        el.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
        if (!el.value) {
          throwError(COMPONENT_NAME, `target is not existed: ${props.target}`);
        }
        container.value = el.value;
      }
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        style: normalizeStyle(unref(backTopStyle)),
        class: normalizeClass(unref(ns).b())
      }, [
        renderSlot(_ctx.$slots, "default", {}, () => [
          createVNode(unref(PsIcon), {
            class: normalizeClass(unref(ns).e("icon"))
          }, {
            default: withCtx(() => [
              createVNode(unref(CaretTop))
            ]),
            _: 1
          }, 8, ["class"])
        ])
      ], 6);
    };
  }
});
var Backtop = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/Users/meng/workspace/element-ps/packages/components/backtop/src/backtop.vue"]]);

export { Backtop as default };
//# sourceMappingURL=backtop2.mjs.map
