export type MinistryPlenaryLanguage = "en" | "kh";

export function normalizeMinistryPlenaryLanguage(
    language: string | null | undefined,
): MinistryPlenaryLanguage {
    return language === "kh" ? "kh" : "en";
}

export const ministryPlenaryText = {
    en: {
        allPlenaries: "All Plenaries",
        allPlenariesSubtitle: "Plenary data sent from CDC to your ministry.",
        filterByStatus: "Filter by Status",
        no: "No.",
        name: "Name",
        meetingDate: "Meeting Date",
        rgcDecisionCount: "# of RGC Decision",
        deadline: "Deadline",
        status: "Status",
        plenaryDocument: "Plenary Document",
        action: "Action",
        actions: "Actions",
        viewDetail: "View Detail",
        addRgcDecision: "Add RGC Decision",
        editRgcDecision: "Edit RGC Decision",
        previous: "Previous",
        next: "Next",
        noPlenaryRecords: "No plenary records found.",
        sent: "Sent",
        draft: "Draft",
        solved: "Solved",
        inProgress: "In Progress",
        notAddressed: "Not Addressed",
        pending: "Pending",

        plenaryDetail: "Plenary Detail",
        plenaryDetailSubtitle: "Detail information of plenary report.",
        back: "Back",
        submitToCdc: "Submit to CDC",
        createRgcDecision: "Create RGC Decision",
        numberOfRgcDecision: "Number of RGC Decision :",
        attachment: "Attachment :",
        deadlineLabel: "Deadline :",
        meetingDateLabel: "Meeting Date :",
        statusLabel: "Status :",
        plenaryRecordNotFound: "Plenary record not found",
        plenaryRecordNotFoundDescription: "The selected plenary does not exist.",
        backToAllPlenaries: "Back to All Plenaries",
        invalidPlenaryId: "Invalid plenary ID.",
        submitDialogMessage: "Submit RGC Decisions to CDC G-PSF?",
        cancel: "Cancel",
        submit: "Submit",
        noDraftToSubmit: "No Save Draft RGC Decision to submit to CDC.",
        submitSuccess: "RGC Decision submitted to CDC G-PSF. Status changed to Submit.",
        submitError: "Unable to submit RGC Decision to CDC.",
        saveDraftSuccess: "RGC Decision saved as Draft successfully.",
        saveDraftError: "Unable to save RGC Decision draft.",
        sendSuccess: "RGC Decision sent to CDC G-PSF successfully.",
        sendError: "Unable to send RGC Decision to CDC.",
        savingRgcDecision: "Saving RGC Decision",
        submittingRgcDecision: "Submitting RGC Decision to CDC",

        rgcDecision: "RGC's Decision",
        linkedIssues: "Linked Issues",
        category: "Category",
        statusPlenary: "Status Plenary",
        indicator: "Indicator",
        focalPerson: "Focal Person (H.E)",
        sourceOfVerification: "Source of Verification",
        verificationLink: "Link to Verification Source",
        saveDraft: "Save Draft",
        submitted: "Submit",
        viewSource: "View Source",
        noRgcDecisions: "No RGC decisions found for this plenary.",

        createDialogTitle: "Create RGC Decision",
        saving: "Saving...",
        sending: "Sending...",
        sendNotification: "Send notification",
        selectCategory: "Select Category",
        loadingCategories: "Loading categories...",
        noCategories: "No categories found",
        selectIndicator: "Select Indicator",
        loadingIndicators: "Loading indicators...",
        noIndicators: "No indicators found",
        focalPersonPlaceholder: "Enter Focal Person (H.E)...",
        decisionPlaceholder: "Enter RGC's Decision",
        verificationPlaceholder: "Enter Source of Verification...",
        enterLinkUrl: "Enter link URL",
        bulletedList: "Bulleted list",
        numberedList: "Numbered list",
        undo: "Undo",
        redo: "Redo",
        listOptions: "List options",
        textColor: "Text color",
        bold: "Bold",
        italic: "Italic",
        underline: "Underline",
        strikethrough: "Strikethrough",
        code: "Code",
        clearFormatting: "Clear formatting",
        insertLink: "Insert link",
        codeBlock: "Code block",
        quote: "Quote",
        horizontalLine: "Horizontal line",
        categoryLoadError: "Unable to load categories.",
        indicatorLoadError: "Unable to load indicators.",
        createSavedSuccess: "RGC decision saved successfully.",
        createSaveError: "Unable to save RGC decision.",
        createSentSuccess: "RGC decision notification sent successfully.",
        createSendError: "Unable to send RGC decision notification.",

        editDialogTitle: "Edit RGC Decision",
        saveDecision: "Save Decision",
        selectCategoryError: "Please select a category.",
        selectIndicatorError: "Please select an indicator.",
        selectMeetingDateError: "Please select meeting date.",
        enterFocalPersonError: "Please enter focal person.",
        enterDecisionError: "Please enter RGC Decision.",
        enterVerificationSourceError: "Please enter Source of Verification.",
        createdDecisionIdMissing: "Created RGC Decision ID was not returned from API.",
        decisionRequiredError: "RGC's Decision is required.",
        loadFormError: "Unable to load form data.",
        updateError: "Unable to save RGC decision.",

        rgcDecisionDetail: "RGC Decision Detail",
        rgcDecisionDetailSubtitle: "Detail Information of RGC Decision",
        ministry: "Ministry",
        noVerificationLink: "No verification link provided",
        rgcDecisionNotFound: "RGC Decision not found",
        unableToLoadRgcDecision: "Unable to load RGC Decision.",
        backToPlenaryDetail: "Back to Plenary Detail",
        invalidDecisionId: "Invalid plenary or RGC Decision ID.",
        detailLoadError: "Unable to load RGC decision detail.",
        detailDataNotFound: "RGC decision detail data was not found.",
        updatedDataNotFound: "Updated RGC decision data was not found.",
        updatedSuccess: "RGC decision updated successfully.",
        updateDetailError: "Unable to update RGC decision.",
        loginUserNotFound: "Login user ID not found. Please login again.",
    },
    kh: {
        allPlenaries: "សម័យប្រជុំពេញអង្គទាំងអស់",
        allPlenariesSubtitle: "ទិន្នន័យសម័យប្រជុំពេញអង្គដែលបានផ្ញើពី CDC មកក្រសួងរបស់អ្នក។",
        filterByStatus: "តម្រងតាមស្ថានភាព",
        no: "ល.រ",
        name: "ឈ្មោះ",
        meetingDate: "កាលបរិច្ឆេទប្រជុំ",
        rgcDecisionCount: "ចំនួនសេចក្តីសម្រេច",
        deadline: "ថ្ងៃផុតកំណត់",
        status: "ស្ថានភាព",
        plenaryDocument: "ឯកសារសម័យប្រជុំពេញអង្គ",
        action: "សកម្មភាព",
        actions: "សកម្មភាព",
        viewDetail: "មើលលម្អិត",
        addRgcDecision: "បន្ថែមសេចក្តីសម្រេច",
        editRgcDecision: "កែសម្រួលសេចក្តីសម្រេច",
        previous: "មុន",
        next: "បន្ទាប់",
        noPlenaryRecords: "មិនមានទិន្នន័យសម័យប្រជុំពេញអង្គ។",
        sent: "បានផ្ញើ",
        draft: "ព្រាង",
        solved: "បានដោះស្រាយ",
        inProgress: "កំពុងដំណើរការ",
        notAddressed: "មិនទាន់ដោះស្រាយ",
        pending: "កំពុងរង់ចាំ",

        plenaryDetail: "ព័ត៌មានលម្អិតសម័យប្រជុំពេញអង្គ",
        plenaryDetailSubtitle: "ព័ត៌មានលម្អិតនៃរបាយការណ៍សម័យប្រជុំពេញអង្គ។",
        back: "ត្រឡប់ក្រោយ",
        submitToCdc: "បញ្ជូនទៅ CDC",
        createRgcDecision: "បង្កើតសេចក្តីសម្រេច",
        numberOfRgcDecision: "ចំនួនសេចក្តីសម្រេច :",
        attachment: "ឯកសារភ្ជាប់ :",
        deadlineLabel: "ថ្ងៃផុតកំណត់ :",
        meetingDateLabel: "កាលបរិច្ឆេទប្រជុំ :",
        statusLabel: "ស្ថានភាព :",
        plenaryRecordNotFound: "រកមិនឃើញសម័យប្រជុំពេញអង្គ",
        plenaryRecordNotFoundDescription: "មិនមានទិន្នន័យសម័យប្រជុំពេញអង្គដែលបានជ្រើសរើសទេ។",
        backToAllPlenaries: "ត្រឡប់ទៅសម័យប្រជុំទាំងអស់",
        invalidPlenaryId: "លេខសម្គាល់សម័យប្រជុំមិនត្រឹមត្រូវ។",
        submitDialogMessage: "តើអ្នកចង់បញ្ជូនសេចក្តីសម្រេចទៅ CDC G-PSF ដែរឬទេ?",
        cancel: "បោះបង់",
        submit: "បញ្ជូន",
        noDraftToSubmit: "មិនមានសេចក្តីសម្រេចព្រាងសម្រាប់បញ្ជូនទៅ CDC ទេ។",
        submitSuccess: "បានបញ្ជូនសេចក្តីសម្រេចទៅ CDC G-PSF ដោយជោគជ័យ។ ស្ថានភាពបានប្ដូរទៅ បានបញ្ជូន។",
        submitError: "មិនអាចបញ្ជូនសេចក្តីសម្រេចទៅ CDC បានទេ។",
        saveDraftSuccess: "បានរក្សាទុកសេចក្តីសម្រេចជាព្រាងដោយជោគជ័យ។",
        saveDraftError: "មិនអាចរក្សាទុកសេចក្តីសម្រេចជាព្រាងបានទេ។",
        sendSuccess: "បានផ្ញើសេចក្តីសម្រេចទៅ CDC G-PSF ដោយជោគជ័យ។",
        sendError: "មិនអាចផ្ញើសេចក្តីសម្រេចទៅ CDC បានទេ។",
        savingRgcDecision: "កំពុងរក្សាទុកសេចក្តីសម្រេច",
        submittingRgcDecision: "កំពុងបញ្ជូនសេចក្តីសម្រេចទៅ CDC",

        rgcDecision: "សេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល",
        linkedIssues: "បញ្ហាដែលបានភ្ជាប់",
        category: "ប្រភេទ",
        statusPlenary: "ស្ថានភាពសម័យប្រជុំ",
        indicator: "សូចនាករ",
        focalPerson: "មន្ត្រីទទួលបន្ទុក (ឯកឧត្តម)",
        sourceOfVerification: "ប្រភពផ្ទៀងផ្ទាត់",
        verificationLink: "តំណភ្ជាប់ប្រភពផ្ទៀងផ្ទាត់",
        saveDraft: "រក្សាទុកព្រាង",
        submitted: "បានបញ្ជូន",
        viewSource: "មើលប្រភព",
        noRgcDecisions: "មិនមានសេចក្តីសម្រេចសម្រាប់សម័យប្រជុំនេះទេ។",

        createDialogTitle: "បង្កើតសេចក្តីសម្រេច",
        saving: "កំពុងរក្សាទុក...",
        sending: "កំពុងផ្ញើ...",
        sendNotification: "ផ្ញើការជូនដំណឹង",
        selectCategory: "ជ្រើសរើសប្រភេទ",
        loadingCategories: "កំពុងទាញប្រភេទ...",
        noCategories: "មិនមានប្រភេទ",
        selectIndicator: "ជ្រើសរើសសូចនាករ",
        loadingIndicators: "កំពុងទាញសូចនាករ...",
        noIndicators: "មិនមានសូចនាករ",
        focalPersonPlaceholder: "បញ្ចូលមន្ត្រីទទួលបន្ទុក (ឯកឧត្តម)...",
        decisionPlaceholder: "បញ្ចូលសេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល",
        verificationPlaceholder: "បញ្ចូលប្រភពផ្ទៀងផ្ទាត់...",
        enterLinkUrl: "បញ្ចូលតំណ URL",
        bulletedList: "បញ្ជីចំណុច",
        numberedList: "បញ្ជីលេខរៀង",
        undo: "ត្រឡប់ក្រោយ",
        redo: "ធ្វើឡើងវិញ",
        listOptions: "ជម្រើសបញ្ជី",
        textColor: "ពណ៌អក្សរ",
        bold: "អក្សរដិត",
        italic: "អក្សរទ្រេត",
        underline: "គូសបន្ទាត់ក្រោម",
        strikethrough: "គូសបន្ទាត់កាត់",
        code: "កូដ",
        clearFormatting: "សម្អាតទម្រង់",
        insertLink: "បញ្ចូលតំណ",
        codeBlock: "ប្លុកកូដ",
        quote: "សម្រង់",
        horizontalLine: "បន្ទាត់ផ្ដេក",
        categoryLoadError: "មិនអាចទាញទិន្នន័យប្រភេទបានទេ។",
        indicatorLoadError: "មិនអាចទាញទិន្នន័យសូចនាករបានទេ។",
        createSavedSuccess: "បានរក្សាទុកសេចក្តីសម្រេចដោយជោគជ័យ។",
        createSaveError: "មិនអាចរក្សាទុកសេចក្តីសម្រេចបានទេ។",
        createSentSuccess: "បានផ្ញើការជូនដំណឹងអំពីសេចក្តីសម្រេចដោយជោគជ័យ។",
        createSendError: "មិនអាចផ្ញើការជូនដំណឹងអំពីសេចក្តីសម្រេចបានទេ។",

        editDialogTitle: "កែសម្រួលសេចក្តីសម្រេច",
        saveDecision: "រក្សាទុកសេចក្តីសម្រេច",
        selectCategoryError: "សូមជ្រើសរើសប្រភេទ។",
        selectIndicatorError: "សូមជ្រើសរើសសូចនាករ។",
        selectMeetingDateError: "សូមជ្រើសរើសកាលបរិច្ឆេទប្រជុំ។",
        enterFocalPersonError: "សូមបញ្ចូលមន្ត្រីទទួលបន្ទុក។",
        enterDecisionError: "សូមបញ្ចូលសេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល។",
        enterVerificationSourceError: "សូមបញ្ចូលប្រភពផ្ទៀងផ្ទាត់។",
        createdDecisionIdMissing: "API មិនបានបញ្ជូនលេខសម្គាល់សេចក្តីសម្រេចដែលបានបង្កើតមកវិញទេ។",
        decisionRequiredError: "ត្រូវបញ្ចូលសេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល។",
        loadFormError: "មិនអាចទាញទិន្នន័យទម្រង់បានទេ។",
        updateError: "មិនអាចរក្សាទុកសេចក្តីសម្រេចបានទេ។",

        rgcDecisionDetail: "ព័ត៌មានលម្អិតសេចក្តីសម្រេច",
        rgcDecisionDetailSubtitle: "ព័ត៌មានលម្អិតនៃសេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល",
        ministry: "ក្រសួង",
        noVerificationLink: "មិនមានតំណភ្ជាប់ប្រភពផ្ទៀងផ្ទាត់",
        rgcDecisionNotFound: "រកមិនឃើញសេចក្តីសម្រេច",
        unableToLoadRgcDecision: "មិនអាចទាញទិន្នន័យសេចក្តីសម្រេចបានទេ។",
        backToPlenaryDetail: "ត្រឡប់ទៅព័ត៌មានលម្អិតសម័យប្រជុំ",
        invalidDecisionId: "លេខសម្គាល់សម័យប្រជុំ ឬសេចក្តីសម្រេចមិនត្រឹមត្រូវ។",
        detailLoadError: "មិនអាចទាញព័ត៌មានលម្អិតសេចក្តីសម្រេចបានទេ។",
        detailDataNotFound: "រកមិនឃើញទិន្នន័យលម្អិតសេចក្តីសម្រេច។",
        updatedDataNotFound: "រកមិនឃើញទិន្នន័យសេចក្តីសម្រេចដែលបានកែ។",
        updatedSuccess: "បានកែសម្រួលសេចក្តីសម្រេចដោយជោគជ័យ។",
        updateDetailError: "មិនអាចកែសម្រួលសេចក្តីសម្រេចបានទេ។",
        loginUserNotFound: "រកមិនឃើញអ្នកប្រើដែលបានចូលប្រព័ន្ធ។ សូមចូលម្តងទៀត។",
    },
} as const;

export function getMinistryPlenaryText(
    language: string | null | undefined,
) {
    return ministryPlenaryText[normalizeMinistryPlenaryLanguage(language)];
}

export function translatePlenaryStatus(
    status: string,
    language: string | null | undefined,
): string {
    const text = getMinistryPlenaryText(language);
    const normalized = status.trim().toLowerCase().replace(/[_-]+/g, " ");

    if (normalized === "sent") return text.sent;
    if (normalized === "draft") return text.draft;
    if (normalized === "solved") return text.solved;
    if (normalized === "in progress") return text.inProgress;
    if (normalized === "not addressed") return text.notAddressed;
    if (normalized === "pending") return text.pending;

    return status;
}