import type { AppLocale } from "../locale";
import { DEFAULT_LOCALE } from "../locale";

export type EditorMessages = {
  headerTitle: string;
  headerDescription: string;
  navProjects: string;
  navPreview: string;
  undoLabel: string;
  redoLabel: string;
  menuLabel: string;
  menuProjectSaveLoad: string;
  menuJsonImportExport: string;
  menuExportZip: string;
  menuClearCanvas: string;
  menuDeleteProject: string;
  confirmClearCanvas: string;
  confirmDeleteProject: string;
  modalProjectTitle: string;
  modalProjectTitleLabel: string;
  modalProjectSlugLabel: string;
  modalSaveButton: string;
  modalLoadButton: string;
  projectMessageSlugRequired: string;
  projectMessageSaveFailed: string;
  projectMessageSaveError: string;
  projectMessageSaveSuccessPrefix: string;
  projectMessageLoadSlugRequired: string;
  projectMessageLoadFailed: string;
  projectMessageLoadLocalSuccessPrefix: string;
  projectMessageLoadServerSuccessPrefix: string;
  projectMessageInvalidFormat: string;
  projectMessageLoadError: string;
  projectMessageDeleteSlugMissing: string;
  projectMessageDeleteFailed: string;
  projectMessageDeleteSuccess: string;
  projectMessageDeleteError: string;
  jsonModalTitle: string;
  jsonModalSubtitle: string;
  jsonExportButton: string;
  jsonClearCanvasButton: string;
  jsonEditorStateLabel: string;
  jsonImportLabel: string;
  jsonApplyButton: string;
  listItemToolbarMoveUpLabel: string;
  listItemToolbarMoveDownLabel: string;
  listItemToolbarIndentLabel: string;
  listItemToolbarOutdentLabel: string;

  imageBlockEmptyPreviewPlaceholder: string;
  columnAreaLabel: string;
};

const EDITOR_MESSAGES: Record<AppLocale, EditorMessages> = {
  en: {
    headerTitle: "Page Editor",
    headerDescription: "Build and edit your landing pages with a visual editor.",
    navProjects: "Projects",
    navPreview: "Open preview",
    undoLabel: "Undo",
    redoLabel: "Redo",
    menuLabel: "Menu",
    menuProjectSaveLoad: "Save / load project",
    menuJsonImportExport: "JSON export / import",
    menuExportZip: "Export as page files (ZIP)",
    menuClearCanvas: "Clear canvas",
    menuDeleteProject: "Delete project",
    confirmClearCanvas:
      "Clear all blocks on the canvas? This can only be undone with the undo history.",
    confirmDeleteProject:
      "Delete the current project? This cannot be undone. Local and autosave data will also be removed.",
    modalProjectTitle: "Save / load project",
    modalProjectTitleLabel: "Project title",
    modalProjectSlugLabel: "Project address (e.g. my-landing)",
    modalSaveButton: "Save (local + server)",
    modalLoadButton: "Load",
    projectMessageSlugRequired: "Please enter a project address.",
    projectMessageSaveFailed: "Failed to save the project.",
    projectMessageSaveError: "An error occurred while saving the project.",
    projectMessageSaveSuccessPrefix: "Project saved: ",
    projectMessageLoadSlugRequired: "Please enter an address to load.",
    projectMessageLoadFailed: "Failed to load the project.",
    projectMessageLoadLocalSuccessPrefix: "Loaded project from local: ",
    projectMessageLoadServerSuccessPrefix: "Loaded project from server: ",
    projectMessageInvalidFormat: "Project data format is invalid.",
    projectMessageLoadError: "An error occurred while loading the project.",
    projectMessageDeleteSlugMissing: "There is no project address to delete.",
    projectMessageDeleteFailed: "Failed to delete the project.",
    projectMessageDeleteSuccess: "Project deleted.",
    projectMessageDeleteError: "An error occurred while deleting the project.",
    jsonModalTitle: "JSON Export / Import",
    jsonModalSubtitle: "* Import or export the current editor state as JSON.",
    jsonExportButton: "Export JSON",
    jsonClearCanvasButton: "Clear canvas",
    jsonEditorStateLabel: "Editor state JSON",
    jsonImportLabel: "Import from JSON",
    jsonApplyButton: "Apply JSON",
    listItemToolbarMoveUpLabel: "Move item up",
    listItemToolbarMoveDownLabel: "Move item down",
    listItemToolbarIndentLabel: "Indent item",
    listItemToolbarOutdentLabel: "Outdent item",

    imageBlockEmptyPreviewPlaceholder:
      "Enter an image URL or upload a file to see the preview here.",
    columnAreaLabel: "Column area",
  },
  ko: {
    headerTitle: "페이지 에디터",
    headerDescription: "랜딩 페이지를 시각적으로 구성할 수 있는 에디터입니다.",
    navProjects: "프로젝트 목록",
    navPreview: "프리뷰 열기",
    undoLabel: "실행 취소",
    redoLabel: "다시 실행",
    menuLabel: "메뉴",
    menuProjectSaveLoad: "프로젝트 저장/불러오기",
    menuJsonImportExport: "JSON 내보내기/불러오기",
    menuExportZip: "페이지 파일로 내보내기 (ZIP)",
    menuClearCanvas: "캔버스 초기화",
    menuDeleteProject: "프로젝트 삭제",
    confirmClearCanvas:
      "캔버스를 모두 초기화할까요? 이 작업은 실행 취소 히스토리로만 되돌릴 수 있습니다.",
    confirmDeleteProject:
      "현재 프로젝트를 삭제할까요? 삭제 후에는 되돌릴 수 없습니다. (로컬 저장 및 자동저장 데이터도 함께 삭제됩니다.)",
    modalProjectTitle: "프로젝트 저장 / 불러오기",
    modalProjectTitleLabel: "프로젝트 제목",
    modalProjectSlugLabel: "프로젝트 주소 (예: my-landing)",
    modalSaveButton: "저장 (로컬 + 서버)",
    modalLoadButton: "불러오기",
    projectMessageSlugRequired: "프로젝트 주소를 입력해 주세요.",
    projectMessageSaveFailed: "프로젝트 저장에 실패했습니다.",
    projectMessageSaveError: "프로젝트 저장 중 오류가 발생했습니다.",
    projectMessageSaveSuccessPrefix: "프로젝트가 저장되었습니다: ",
    projectMessageLoadSlugRequired: "불러올 주소를 입력해 주세요.",
    projectMessageLoadFailed: "프로젝트를 불러오지 못했습니다.",
    projectMessageLoadLocalSuccessPrefix: "로컬에서 프로젝트를 불러왔습니다: ",
    projectMessageLoadServerSuccessPrefix: "프로젝트를 불러왔습니다: ",
    projectMessageInvalidFormat: "프로젝트 데이터 형식이 올바르지 않습니다.",
    projectMessageLoadError: "프로젝트 불러오기 중 오류가 발생했습니다.",
    projectMessageDeleteSlugMissing: "삭제할 프로젝트 주소가 없습니다.",
    projectMessageDeleteFailed: "프로젝트 삭제에 실패했습니다.",
    projectMessageDeleteSuccess: "프로젝트가 삭제되었습니다.",
    projectMessageDeleteError: "프로젝트 삭제 중 오류가 발생했습니다.",
    jsonModalTitle: "JSON Export / Import",
    jsonModalSubtitle: "* 에디터 내용을 가져오거나 내보낼 수 있습니다.",
    jsonExportButton: "JSON 내보내기",
    jsonClearCanvasButton: "캔버스 초기화",
    jsonEditorStateLabel: "에디터 상태 JSON",
    jsonImportLabel: "JSON에서 불러오기",
    jsonApplyButton: "JSON 적용하기",
    listItemToolbarMoveUpLabel: "아이템 위로 이동",
    listItemToolbarMoveDownLabel: "아이템 아래로 이동",
    listItemToolbarIndentLabel: "아이템 들여쓰기",
    listItemToolbarOutdentLabel: "아이템 내어쓰기",

    imageBlockEmptyPreviewPlaceholder:
      "이미지 URL 을 입력하거나 파일을 업로드하면 여기에서 미리보기가 표시됩니다.",
    columnAreaLabel: "컬럼 영역",
  },
};

export function getEditorMessages(locale: AppLocale | null | undefined): EditorMessages {
  const key = (locale ?? DEFAULT_LOCALE) as AppLocale;
  return EDITOR_MESSAGES[key] ?? EDITOR_MESSAGES[DEFAULT_LOCALE];
}
