import "../../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
import { useChartEditStore } from "../../../../../store/modules/chartEditStore/chartEditStore.mjs";
import { useDesignStore } from "../../../../../store/modules/designStore/designStore.mjs";
import { useComponentStyle, useSizeStyle } from "../../hooks/useStyle.hook.mjs";
import { selectBoxIndex } from "../../../../../settings/designSetting.mjs";
import { defineComponent, computed, watch, openBlock, createElementBlock, createCommentVNode, pushScopeId, popScopeId, createElementVNode as createBaseVNode } from "../../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.mjs";
import { useCssVars } from "../../../../../../node_modules/.pnpm/@vue_runtime-dom@3.3.4/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.mjs";
import { toRefs, ref, unref } from "../../../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.mjs";
import { normalizeStyle } from "../../../../../../node_modules/.pnpm/@vue_shared@3.3.4/node_modules/@vue/shared/dist/shared.esm-bundler.mjs";
const _withScopeId = (n) => (pushScopeId("data-v-fd03a995"), n = n(), popScopeId(), n);
const _hoisted_1 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBaseVNode("div", { class: "select-background" }, null, -1));
const _hoisted_2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBaseVNode("div", { class: "select-border" }, null, -1));
const _hoisted_3 = [
  _hoisted_1,
  _hoisted_2
];
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  setup(__props) {
    useCssVars((_ctx) => ({
      "3a6a09b6": themeColor.value
    }));
    const designStore = useDesignStore();
    const chartEditStore = useChartEditStore();
    const { isSelect, scale } = toRefs(chartEditStore.getEditCanvas);
    const themeColor = computed(() => {
      return designStore.getAppTheme;
    });
    const positionStyle = ref();
    watch(
      () => chartEditStore.getMousePosition,
      (positionInfo) => {
        if (!isSelect.value)
          return;
        const { startX, startY, x, y } = positionInfo;
        const attr = {
          zIndex: selectBoxIndex,
          // left
          x: 0,
          // top
          y: 0,
          // 宽
          w: 0,
          // 高
          h: 0,
          // 偏移
          offsetX: 0,
          offsetY: 0
        };
        if (x > startX && y > startY) {
          attr.x = startX;
          attr.y = startY;
          attr.w = Math.round((x - startX) / scale.value);
          attr.h = Math.round((y - startY) / scale.value);
        } else if (x > startX && y < startY) {
          attr.x = startX;
          attr.w = Math.round((x - startX) / scale.value);
          attr.h = Math.round((startY - y) / scale.value);
          attr.y = startY - attr.h;
        } else if (x < startX && y > startY) {
          attr.y = startY;
          attr.w = Math.round((startX - x) / scale.value);
          attr.h = Math.round((y - startY) / scale.value);
          attr.x = startX - attr.w;
        } else {
          attr.w = Math.round((startX - x) / scale.value);
          attr.h = Math.round((startY - y) / scale.value);
          attr.x = startX - attr.w;
          attr.y = startY - attr.h;
        }
        positionStyle.value = {
          ...useComponentStyle(attr, selectBoxIndex),
          ...useSizeStyle(attr)
        };
      },
      {
        deep: true
      }
    );
    return (_ctx, _cache) => {
      return unref(isSelect) ? (openBlock(), createElementBlock("div", {
        key: 0,
        class: "go-edit-select",
        style: normalizeStyle(positionStyle.value)
      }, _hoisted_3, 4)) : createCommentVNode("", true);
    };
  }
});
export {
  _sfc_main as default
};
