import { ref } from 'vue';
import { defineStore } from 'pinia';
import { useSessionStorage, tryOnMounted } from '@vueuse/core';
import '../../../api/shopAdmin/index.mjs';
import { postShopAdminStoreFilter } from '../../../api/shopAdmin/store/postShopAdminStoreFilter.mjs';

const useLineListStore = defineStore("gmLineList", () => {
  const lineList = useSessionStorage("gmLineList", [], { listenToStorageChanges: false });
  const isLoading = ref(false);
  const getLineList = async () => {
    if (lineList.value.length !== 0) {
      isLoading.value = false;
      return;
    }
    if (isLoading.value) {
      return;
    }
    try {
      isLoading.value = true;
      const { data } = await postShopAdminStoreFilter({ keys: "line" });
      isLoading.value = false;
      if (data.code !== 0) {
        return;
      }
      lineList.value = data.data.line;
    } catch (e) {
      console.error(e);
      isLoading.value = false;
    }
  };
  tryOnMounted(() => {
    getLineList();
  });
  return {
    lineList,
    isLoading,
    getLineList
  };
});

export { useLineListStore };
//# sourceMappingURL=index.mjs.map
