import { reactive, ref } from "vue";

export type LegacyName = "update-info" | "media-types";

export function createLegacyStore() {
  const sync = ref<any>(null);
  const documents = reactive<Record<LegacyName, any | null>>({ "update-info": null, "media-types": null });
  const modal = reactive({
    open: false,
    type: "",
    categoryIndex: -1,
    itemIndex: -1,
    draft: {} as any,
  });
  const activeMediaCategoryIndex = ref(0);
  const drafts = reactive<Record<LegacyName, { raw: string; note: string; preview: any | null; tab: "form" | "raw" | "preview" | "history"; form: any }>>({
    "update-info": { raw: "", note: "", preview: null, tab: "form", form: {} },
    "media-types": { raw: "", note: "", preview: null, tab: "form", form: { categories: [] } },
  });

  return { sync, documents, drafts, modal, activeMediaCategoryIndex };
}
