import { u as useChartEditStore, k as getLocalStorage, J as defineStore, L as setLocalStorage, n as StorageEnum } from "./index-e2623483.js";
import "vue";
var ChartModeEnum = /* @__PURE__ */ ((ChartModeEnum2) => {
  ChartModeEnum2["SINGLE"] = "single";
  ChartModeEnum2["DOUBLE"] = "double";
  return ChartModeEnum2;
})(ChartModeEnum || {});
var LayerModeEnum = /* @__PURE__ */ ((LayerModeEnum2) => {
  LayerModeEnum2["THUMBNAIL"] = "thumbnail";
  LayerModeEnum2["TEXT"] = "text";
  return LayerModeEnum2;
})(LayerModeEnum || {});
var ChartLayoutStoreEnum = /* @__PURE__ */ ((ChartLayoutStoreEnum2) => {
  ChartLayoutStoreEnum2["LAYERS"] = "layers";
  ChartLayoutStoreEnum2["CHARTS"] = "charts";
  ChartLayoutStoreEnum2["DETAILS"] = "details";
  ChartLayoutStoreEnum2["Chart_TYPE"] = "chartType";
  ChartLayoutStoreEnum2["LAYER_TYPE"] = "layerType";
  ChartLayoutStoreEnum2["PERCENTAGE"] = "percentage";
  ChartLayoutStoreEnum2["RE_POSITION_CANVAS"] = "rePositionCanvas";
  return ChartLayoutStoreEnum2;
})(ChartLayoutStoreEnum || {});
const chartEditStore = useChartEditStore();
const { GO_CHART_LAYOUT_STORE } = StorageEnum;
const storageChartLayout = getLocalStorage(GO_CHART_LAYOUT_STORE);
const useChartLayoutStore = defineStore({
  id: "useChartLayoutStore",
  state: () => ({
    // 图层控制
    layers: true,
    // 图表组件
    charts: true,
    // 详情设置（收缩为true）
    details: false,
    // 组件列表展示类型（默认单列）
    chartType: ChartModeEnum.SINGLE,
    // 图层类型（默认图片）
    layerType: LayerModeEnum.THUMBNAIL,
    // 当前加载数量
    percentage: 0,
    // 是否重置当前画布位置
    rePositionCanvas: false,
    // 防止值不存在
    ...storageChartLayout
  }),
  getters: {
    getLayers() {
      return this.layers;
    },
    getCharts() {
      return this.charts;
    },
    getDetails() {
      return this.details;
    },
    getChartType() {
      return this.chartType;
    },
    getLayerType() {
      return this.layerType;
    },
    getPercentage() {
      return this.percentage;
    },
    getRePositionCanvas() {
      return this.rePositionCanvas;
    }
  },
  actions: {
    setItem(key, value, computedScale = true) {
      this.$patch((state) => {
        state[key] = value;
      });
      setLocalStorage(GO_CHART_LAYOUT_STORE, this.$state);
      this.rePositionCanvas = true;
      if (computedScale) {
        setTimeout(() => {
          chartEditStore.computedScale();
        }, 500);
      }
    },
    setItemUnHandle(key, value) {
      this.$patch((state) => {
        state[key] = value;
      });
    }
  }
});
export {
  ChartLayoutStoreEnum as C,
  LayerModeEnum as L,
  ChartModeEnum as a,
  useChartLayoutStore as u
};
