import 'package:fis_i18n/i18n.dart';

import 'desktop/names.dart';
import 'router.dart';

typedef _FTrStrGetter = FTrStr Function();

/// 路由翻译
class RouteTranslator {
  static final _map = <String, _FTrStrGetter>{
    RouteNames.Home.MainPage: () => i18nBook.homePage.homePage,
    // 用户
    RouteNames.User.Center: () => i18nBook.user.userCenter,
    RouteNames.User.Setting: () => i18nBook.user.setting,
    RouteNames.User.Entry: () => i18nBook.user.myEntry,
    RouteNames.User.Device: () => i18nBook.user.myDevices,
    RouteNames.User.GroupList: () => i18nBook.user.myGroups,
    RouteNames.User.ReportTemplate: () => i18nBook.user.myTemplate,
    RouteNames.User.ReportTemplateDesigner: () =>
        i18nBook.user.editReportTemplate,

    // 机构
    RouteNames.Org.Personnel: () => i18nBook.organization.orgStructure,
    RouteNames.Org.Device: () => i18nBook.homePage.organizationDevices,
    RouteNames.Org.Entry: () => i18nBook.homePage.organizationEntries,
    RouteNames.Org.ReportTemplate: () => i18nBook.user.orgTemplate,

    // 诊断
    RouteNames.Remedical.Consultation: () =>
        i18nBook.remedical.patientManagement,
    RouteNames.Remedical.ConsultationPatientView: () =>
        i18nBook.remedical.patientManagement,
    RouteNames.Remedical.ConsultationRecordView: () =>
        i18nBook.homePage.remoteDiagnosis,
    RouteNames.Remedical.ImagePool: () => i18nBook.remedical.scanImageData,
    RouteNames.Remedical.Measure: () => i18nBook.remedical.measure,
    RouteNames.Remedical.ReportEdit: () => i18nBook.remedical.editReport,
    RouteNames.Remedical.ReportPreview: () => i18nBook.remedical.previewReport,

    // 实时诊断
    RouteNames.RealTimeRemedical.RealTimeConsultation: () =>
        i18nBook.homePage.consultation,
    // 实时诊断-日历视图
    RouteNames.RealTimeRemedical.CalendarPage: () =>
        i18nBook.calendar.calendarView,
    // 会诊间
    RouteNames.RealTimeRemedical.LiveConsultation: () =>
        i18nBook.realTimeConsultation.consultationRoom,
    //反馈系统
    RouteNames.Thirdparty.ThirdpartyPage: () {
      final args = router.getParams(NavIds.HOME) ?? {};
      if (args.containsKey('name')) {
        return FTrStr(args['name']!);
      }
      return i18nBook.common.feedbackSystem;
    },
    // 实验室
    RouteNames.Laboratory.LaboratoryFolder: () =>
        i18nBook.laboratory.laboratoryName,
    RouteNames.Laboratory.AiLaboratoryFolder: () =>
        i18nBook.laboratory.feifeiAIAnalysisAssistant,
    RouteNames.Laboratory.LaboratoryReportFolder: () =>
        i18nBook.laboratory.comprehensiveImageAnalysis,
    // i18nBook.laboratory.laboratoryName,
    //杏聆荟学院
    RouteNames.College.PastVideos: () => i18nBook.college.pastVideo,
    RouteNames.College.PastVideoPlayer: () => i18nBook.college.videoDetail,
    RouteNames.College.FlyinsonoCollege: () {
      return i18nBook.common.flyinsonoCollege;
    },
    RouteNames.College.LiveCourseDetail: () {
      return i18nBook.college.liveCourse;
    },
    // 直播列表
    RouteNames.Live.DeviceList: () => i18nBook.live.deviceLive,
    //直播
    RouteNames.Live.DeviceList: () => i18nBook.live.deviceLive,
  };

  /// 翻译
  static String? translate(String name) {
    if (_map.containsKey(name)) {
      return _map[name]!.call().t;
    }
    return null;
  }
}
