import type { AppRouteRecordRaw } from "@/types/router";

/**
 * Static routes that don't require authentication
 */
export const staticRoutes: AppRouteRecordRaw[] = [
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login/index.vue"),
    meta: {
      title: "login.title",
      requiresAuth: false,
      hidden: true,
    },
  },
  {
    path: "/404",
    name: "NotFound",
    component: () => import("@/views/error/404.vue"),
    meta: {
      title: "error.404",
      requiresAuth: false,
      hidden: true,
    },
  },
  {
    path: "/403",
    name: "Forbidden",
    component: () => import("@/views/error/403.vue"),
    meta: {
      title: "error.403",
      requiresAuth: false,
      hidden: true,
    },
  },
  {
    path: "/500",
    name: "ServerError",
    component: () => import("@/views/error/500.vue"),
    meta: {
      title: "error.500",
      requiresAuth: false,
      hidden: true,
    },
  },
];

/**
 * Basic routes that require authentication
 */
export const basicRoutes: AppRouteRecordRaw[] = [
  {
    path: "/",
    name: "Root",
    redirect: "/dashboard",
    component: () => import("@/components/Layout/AdminLayout.vue"),
    meta: {
      title: "Dashboard",
      requiresAuth: true,
    },
    children: [
      {
        path: "/redirect/:path(.*)",
        name: "Redirect",
        component: () => import("@/views/redirect/index.vue"),
        meta: {
          title: "Redirect",
          hidden: true,
        },
      },
      {
        path: "dashboard",
        name: "Dashboard",
        component: () => import("@/views/dashboard/index.vue"),
        meta: {
          title: "menu.dashboard",
          icon: "DashboardOutlined",
          requiresAuth: true,
          affix: true,
          order: 1,
        },
      },
      {
        path: "profile",
        name: "Profile",
        component: () => import("@/views/profile/index.vue"),
        meta: {
          title: "menu.profile",
          icon: "UserOutlined",
          requiresAuth: true,
          hidden: true,
        },
      },
      {
        path: "notifications",
        name: "Notifications",
        component: () => import("@/views/notification/index.vue"),
        meta: {
          title: "layout.notifications",
          icon: "BellOutlined",
          requiresAuth: true,
          hidden: true,
        },
      },
      {
        path: "about",
        name: "About",
        component: () => import("@/views/about/index.vue"),
        meta: {
          title: "menu.about",
          icon: "InfoCircleOutlined",
          requiresAuth: true,
          order: 5,
        },
      },
    ],
  },
];

/**
 * Async routes that require permission checking
 */
export const asyncRoutes: AppRouteRecordRaw[] = [
  {
    path: "/system",
    name: "System",
    redirect: "/system/user",
    component: () => import("@/components/Layout/AdminLayout.vue"),
    meta: {
      title: "menu.system",
      icon: "SettingOutlined",
      requiresAuth: true,
      order: 2,
    },
    children: [
      {
        path: "user",
        name: "SystemUser",
        component: () => import("@/views/system/user/index.vue"),
        meta: {
          title: "menu.user",
          icon: "UserOutlined",
          requiresAuth: true,
        },
      },
      {
        path: "role",
        name: "SystemRole",
        component: () => import("@/views/system/role/index.vue"),
        meta: {
          title: "menu.role",
          icon: "TeamOutlined",
          requiresAuth: true,
        },
      },
      {
        path: "dept",
        name: "SystemDept",
        component: () => import("@/views/system/dept/index.vue"),
        meta: {
          title: "menu.dept",
          icon: "ApartmentOutlined",
          requiresAuth: true,
        },
      },
      {
        path: "menu",
        name: "SystemMenu",
        component: () => import("@/views/system/menu/index.vue"),
        meta: {
          title: "menu.menu",
          icon: "MenuOutlined",
          requiresAuth: true,
        },
      },
      {
        path: "permission",
        name: "SystemPermission",
        component: () => import("@/views/system/permission/index.vue"),
        meta: {
          title: "menu.permission",
          icon: "SafetyCertificateOutlined",
          requiresAuth: true,
        },
      },
      {
        path: "dict",
        name: "SystemDict",
        component: () => import("@/views/system/dict/index.vue"),
        meta: {
          title: "menu.dict",
          icon: "BookOutlined",
          requiresAuth: true,
        },
      },
    ],
  },
  {
    path: "/asset",
    name: "Asset",
    redirect: "/asset/device",
    component: () => import("@/components/Layout/AdminLayout.vue"),
    meta: {
      title: "menu.asset",
      icon: "HddOutlined",
      requiresAuth: true,
      order: 3,
    },
    children: [
      {
        path: "device",
        name: "AssetDevice",
        component: () => import("@/views/asset/device/index.vue"),
        meta: { title: "menu.assetDevice", icon: "DesktopOutlined", requiresAuth: true },
      },
      {
        path: "license",
        name: "AssetLicense",
        component: () => import("@/views/asset/license/index.vue"),
        meta: { title: "menu.assetLicense", icon: "SafetyOutlined", requiresAuth: true },
      },
      {
        path: "accessory",
        name: "AssetAccessory",
        component: () => import("@/views/asset/accessory/index.vue"),
        meta: { title: "menu.assetAccessory", icon: "ToolOutlined", requiresAuth: true },
      },
      {
        path: "consumable",
        name: "AssetConsumable",
        component: () => import("@/views/asset/consumable/index.vue"),
        meta: { title: "menu.assetConsumable", icon: "ExperimentOutlined", requiresAuth: true },
      },
      {
        path: "depreciation",
        name: "AssetDepreciation",
        component: () => import("@/views/asset/depreciation/index.vue"),
        meta: { title: "menu.assetDepreciation", icon: "ClockCircleOutlined", requiresAuth: true },
      },
      {
        path: "offering",
        name: "AssetOffering",
        component: () => import("@/views/asset/offering/index.vue"),
        meta: { title: "menu.assetOffering", icon: "CloudServerOutlined", requiresAuth: true },
      },
    ],
  },
  {
    path: "/base",
    name: "Base",
    redirect: "/base/category",
    component: () => import("@/components/Layout/AdminLayout.vue"),
    meta: {
      title: "menu.base",
      icon: "DatabaseOutlined",
      requiresAuth: true,
      order: 4,
    },
    children: [
      {
        path: "category",
        name: "BaseCategory",
        component: () => import("@/views/asset/base/category/index.vue"),
        meta: { title: "menu.baseCategory", icon: "TagOutlined", requiresAuth: true },
      },
      {
        path: "location",
        name: "BaseLocation",
        component: () => import("@/views/asset/base/location/index.vue"),
        meta: { title: "menu.baseLocation", icon: "EnvironmentOutlined", requiresAuth: true },
      },
      {
        path: "manufacturer",
        name: "BaseManufacturer",
        component: () => import("@/views/asset/base/manufacturer/index.vue"),
        meta: { title: "menu.baseManufacturer", icon: "BuildOutlined", requiresAuth: true },
      },
      {
        path: "model",
        name: "BaseModel",
        component: () => import("@/views/asset/base/model/index.vue"),
        meta: { title: "menu.baseModel", icon: "BarcodeOutlined", requiresAuth: true },
      },
      {
        path: "supplier",
        name: "BaseSupplier",
        component: () => import("@/views/asset/base/supplier/index.vue"),
        meta: { title: "menu.baseSupplier", icon: "ShopOutlined", requiresAuth: true },
      },
    ],
  },
  {
    path: "/biz",
    name: "Biz",
    redirect: "/biz/failure",
    component: () => import("@/components/Layout/AdminLayout.vue"),
    meta: {
      title: "menu.biz",
      icon: "ProfileOutlined",
      requiresAuth: true,
      order: 5,
    },
    children: [
      {
        path: "failure",
        name: "BizFailure",
        component: () => import("@/views/asset/biz/failure/index.vue"),
        meta: { title: "menu.bizFailure", icon: "WarningOutlined", requiresAuth: true },
      },
      {
        path: "stocktake",
        name: "BizStocktake",
        component: () => import("@/views/asset/biz/stocktake/index.vue"),
        meta: { title: "menu.bizStocktake", icon: "CheckSquareOutlined", requiresAuth: true },
      },
      {
        path: "transaction",
        name: "BizTransaction",
        component: () => import("@/views/asset/biz/transaction/index.vue"),
        meta: { title: "menu.bizTransaction", icon: "SwapOutlined", requiresAuth: true },
      },
      {
        path: "allocation",
        name: "BizAllocation",
        component: () => import("@/views/asset/biz/allocation/index.vue"),
        meta: { title: "menu.bizAllocation", icon: "SendOutlined", requiresAuth: true },
      },
      {
        path: "request",
        name: "BizRequest",
        component: () => import("@/views/asset/biz/request/index.vue"),
        meta: { title: "menu.bizRequest", icon: "FileAddOutlined", requiresAuth: true },
      },
    ],
  },
  {
    path: "/examples",
    name: "Examples",
    redirect: "/examples/table",
    component: () => import("@/components/Layout/AdminLayout.vue"),
    meta: {
      title: "menu.examples",
      icon: "AppstoreOutlined",
      requiresAuth: true,
      order: 99,
    },
    children: [
      {
        path: "quick-start",
        name: "ExamplesQuickStartGroup",
        redirect: "/examples/pro-table-advanced",
        component: () => import("@/components/RouteView.vue"),
        meta: {
          title: "menu.examplesQuickStart",
          icon: "ThunderboltOutlined",
          requiresAuth: true,
          order: 1,
        },
        children: [
          {
            path: "/examples/pro-table-advanced",
            name: "ExamplesProTableAdvanced",
            component: () =>
              import("@/views/examples/scaffold/pro-table-advanced/index.vue"),
            meta: {
              title: "menu.proTableAdvanced",
              icon: "TableOutlined",
              requiresAuth: true,
              order: 1,
            },
          },
          {
            path: "/examples/complex-form",
            name: "ExamplesComplexForm",
            component: () =>
              import("@/views/examples/scaffold/complex-form/index.vue"),
            meta: {
              title: "menu.complexForm",
              icon: "FormOutlined",
              requiresAuth: true,
              order: 2,
            },
          },
          {
            path: "/examples/master-detail",
            name: "ExamplesMasterDetail",
            component: () =>
              import("@/views/examples/scaffold/master-detail/index.vue"),
            meta: {
              title: "menu.masterDetail",
              icon: "ProfileOutlined",
              requiresAuth: true,
              order: 3,
            },
          },
          {
            path: "/examples/virtual-table",
            name: "ExamplesVirtualTable",
            component: () =>
              import("@/views/examples/scaffold/virtual-table/index.vue"),
            meta: {
              title: "menu.virtualTable",
              icon: "TableOutlined",
              requiresAuth: true,
              order: 4,
            },
          },
        ],
      },
      {
        path: "form-input",
        name: "ExamplesFormInputGroup",
        redirect: "/examples/form",
        component: () => import("@/components/RouteView.vue"),
        meta: {
          title: "menu.examplesFormInput",
          icon: "FormOutlined",
          requiresAuth: true,
          order: 2,
        },
        children: [
          {
            path: "/examples/form",
            name: "ExamplesForm",
            component: () => import("@/views/examples/form/index.vue"),
            meta: {
              title: "menu.form",
              icon: "FormOutlined",
              requiresAuth: true,
              order: 1,
            },
          },
          {
            path: "/examples/json-input",
            name: "ExamplesJsonInput",
            component: () => import("@/views/examples/json-input/index.vue"),
            meta: {
              title: "menu.jsonInput",
              icon: "CodeOutlined",
              requiresAuth: true,
              order: 2,
            },
          },
          {
            path: "/examples/i18n-input",
            name: "ExamplesI18nInput",
            component: () => import("@/views/examples/i18n-input/index.vue"),
            meta: {
              title: "menu.i18nInput",
              icon: "GlobalOutlined",
              requiresAuth: true,
              order: 3,
            },
          },
          {
            path: "/examples/advanced-filter",
            name: "ExamplesAdvancedFilter",
            component: () =>
              import("@/views/examples/scaffold/advanced-filter/index.vue"),
            meta: {
              title: "menu.advancedFilter",
              icon: "ControlOutlined",
              requiresAuth: true,
              order: 4,
            },
          },
        ],
      },
      {
        path: "content-editors",
        name: "ExamplesContentGroup",
        redirect: "/examples/editor",
        component: () => import("@/components/RouteView.vue"),
        meta: {
          title: "menu.examplesContent",
          icon: "EditOutlined",
          requiresAuth: true,
          order: 3,
        },
        children: [
          {
            path: "/examples/editor",
            name: "ExamplesEditor",
            component: () => import("@/views/examples/editor/index.vue"),
            meta: {
              title: "menu.editor",
              icon: "EditOutlined",
              requiresAuth: true,
              order: 1,
            },
          },
          {
            path: "/examples/milkdown",
            name: "ExamplesMilkdown",
            component: () => import("@/views/examples/milkdown/index.vue"),
            meta: {
              title: "menu.milkdown",
              icon: "FileMarkdownOutlined",
              requiresAuth: true,
              order: 2,
            },
          },
          {
            path: "/examples/code-editor",
            name: "ExamplesCodeEditor",
            component: () => import("@/views/examples/code-editor/index.vue"),
            meta: {
              title: "menu.codeEditor",
              icon: "CodeOutlined",
              requiresAuth: true,
              order: 3,
            },
          },
        ],
      },
      {
        path: "basic-interaction",
        name: "ExamplesInteractionGroup",
        redirect: "/examples/table",
        component: () => import("@/components/RouteView.vue"),
        meta: {
          title: "menu.examplesInteraction",
          icon: "AppstoreAddOutlined",
          requiresAuth: true,
          order: 4,
        },
        children: [
          {
            path: "/examples/table",
            name: "ExamplesTable",
            component: () => import("@/views/examples/table/index.vue"),
            meta: {
              title: "menu.table",
              icon: "TableOutlined",
              requiresAuth: true,
              order: 1,
            },
          },
          {
            path: "/examples/modal",
            name: "ExamplesModal",
            component: () => import("@/views/examples/modal/index.vue"),
            meta: {
              title: "menu.modal",
              icon: "ExpandOutlined",
              requiresAuth: true,
              order: 2,
            },
          },
          {
            path: "/examples/icon",
            name: "ExamplesIcon",
            component: () => import("@/views/examples/icon/index.vue"),
            meta: {
              title: "menu.icon",
              icon: "SmileOutlined",
              requiresAuth: true,
              order: 3,
            },
          },
          {
            path: "/examples/spin",
            name: "ExamplesSpin",
            component: () => import("@/views/examples/spin/index.vue"),
            meta: {
              title: "menu.spin",
              icon: "LoadingOutlined",
              requiresAuth: true,
              order: 4,
            },
          },
          {
            path: "/examples/captcha",
            name: "ExamplesCaptcha",
            component: () => import("@/views/examples/captcha/index.vue"),
            meta: {
              title: "menu.captcha",
              icon: "SafetyCertificateOutlined",
              requiresAuth: true,
              order: 5,
            },
          },
          {
            path: "/examples/watermark",
            name: "ExamplesWatermark",
            component: () => import("@/views/examples/watermark/index.vue"),
            meta: {
              title: "menu.watermark",
              icon: "HighlightOutlined",
              requiresAuth: true,
              order: 6,
            },
          },
          {
            path: "/examples/splitter",
            name: "ExamplesSplitter",
            component: () => import("@/views/examples/splitter/index.vue"),
            meta: {
              title: "menu.splitter",
              icon: "ColumnHeightOutlined",
              requiresAuth: true,
              order: 7,
            },
          },
          {
            path: "/examples/tour",
            name: "ExamplesTour",
            component: () => import("@/views/examples/tour/index.vue"),
            meta: {
              title: "menu.tour",
              icon: "CompassOutlined",
              requiresAuth: true,
              order: 8,
            },
          },
          {
            path: "/examples/qrcode",
            name: "ExamplesQRCode",
            component: () => import("@/views/examples/qrcode/index.vue"),
            meta: {
              title: "menu.qrcode",
              icon: "QrcodeOutlined",
              requiresAuth: true,
              order: 9,
            },
          },
          {
            path: "/examples/segmented",
            name: "ExamplesSegmented",
            component: () => import("@/views/examples/segmented/index.vue"),
            meta: {
              title: "menu.segmented",
              icon: "AppstoreOutlined",
              requiresAuth: true,
              order: 10,
            },
          },
          {
            path: "/examples/color-picker",
            name: "ExamplesColorPicker",
            component: () => import("@/views/examples/color-picker/index.vue"),
            meta: {
              title: "menu.colorPicker",
              icon: "BgColorsOutlined",
              requiresAuth: true,
              order: 11,
            },
          },
        ],
      },
      {
        path: "business-scaffold",
        name: "ExamplesBusinessScaffoldGroup",
        redirect: "/examples/upload-system",
        component: () => import("@/components/RouteView.vue"),
        meta: {
          title: "menu.examplesBusinessScaffold",
          icon: "ProfileOutlined",
          requiresAuth: true,
          order: 5,
        },
        children: [
          {
            path: "/examples/upload-system",
            name: "ExamplesUploadSystem",
            component: () =>
              import("@/views/examples/scaffold/upload-system/index.vue"),
            meta: {
              title: "menu.uploadSystem",
              icon: "CloudUploadOutlined",
              requiresAuth: true,
              order: 1,
            },
          },
          {
            path: "/examples/state-cache",
            name: "ExamplesStateCache",
            component: () =>
              import("@/views/examples/scaffold/state-cache/index.vue"),
            meta: {
              title: "menu.stateCache",
              icon: "DatabaseOutlined",
              requiresAuth: true,
              order: 2,
            },
          },
          {
            path: "/examples/import-export",
            name: "ExamplesImportExport",
            component: () =>
              import("@/views/examples/scaffold/import-export/index.vue"),
            meta: {
              title: "menu.importExport",
              icon: "FileTextOutlined",
              requiresAuth: true,
              order: 3,
            },
          },
        ],
      },
      {
        path: "security-engineering",
        name: "ExamplesSecurityEngineeringGroup",
        redirect: "/examples/request-auth",
        component: () => import("@/components/RouteView.vue"),
        meta: {
          title: "menu.examplesSecurityEngineering",
          icon: "SafetyOutlined",
          requiresAuth: true,
          order: 6,
        },
        children: [
          {
            path: "/examples/request-auth",
            name: "ExamplesRequestAuth",
            component: () =>
              import("@/views/examples/scaffold/request-auth/index.vue"),
            meta: {
              title: "menu.requestAuth",
              icon: "SafetyOutlined",
              requiresAuth: true,
              order: 1,
            },
          },
          {
            path: "/examples/rbac-flow",
            name: "ExamplesRbacFlow",
            component: () => import("@/views/examples/scaffold/rbac/index.vue"),
            meta: {
              title: "menu.rbacFlow",
              icon: "SafetyCertificateOutlined",
              requiresAuth: true,
              order: 2,
            },
          },
          {
            path: "/examples/observability",
            name: "ExamplesObservability",
            component: () =>
              import("@/views/examples/scaffold/observability/index.vue"),
            meta: {
              title: "menu.observability",
              icon: "LineChartOutlined",
              requiresAuth: true,
              order: 3,
            },
          },
          {
            path: "/examples/testing",
            name: "ExamplesTesting",
            component: () =>
              import("@/views/examples/scaffold/testing/index.vue"),
            meta: {
              title: "menu.testing",
              icon: "CheckCircleOutlined",
              requiresAuth: true,
              order: 4,
            },
          },
        ],
      },
      {
        path: "integration-navigation",
        name: "ExamplesIntegrationGroup",
        redirect: "/examples/external/iframe/typescript",
        component: () => import("@/components/RouteView.vue"),
        meta: {
          title: "menu.examplesIntegration",
          icon: "LinkOutlined",
          requiresAuth: true,
          order: 7,
        },
        children: [
          {
            path: "iframe",
            name: "ExamplesExternalIframe",
            redirect: "/examples/external/iframe/typescript",
            component: () => import("@/components/RouteView.vue"),
            meta: {
              title: "menu.externalIframe",
              icon: "AppstoreAddOutlined",
              requiresAuth: true,
              order: 1,
            },
            children: [
              {
                path: "/examples/external/iframe/typescript",
                name: "ExamplesExternalIframeTypescript",
                component: () =>
                  import("@/views/examples/external/iframe/typescript.vue"),
                meta: {
                  title: "menu.externalTypescript",
                  icon: "CodeOutlined",
                  requiresAuth: true,
                  order: 1,
                },
              },
              {
                path: "/examples/external/iframe/antdv-next",
                name: "ExamplesExternalIframeAntdvNext",
                component: () =>
                  import("@/views/examples/external/iframe/antdv-next.vue"),
                meta: {
                  title: "menu.externalAntdvNext",
                  icon: "AntDesignOutlined",
                  requiresAuth: true,
                  order: 2,
                },
              },
            ],
          },
          {
            path: "link",
            name: "ExamplesExternalLink",
            component: () => import("@/components/RouteView.vue"),
            meta: {
              title: "menu.externalLink",
              icon: "LinkOutlined",
              requiresAuth: true,
              order: 2,
            },
            children: [
              {
                path: "/examples/external/link/vite",
                name: "ExamplesExternalLinkVite",
                component: () =>
                  import("@/views/examples/external/link/vite.vue"),
                meta: {
                  title: "menu.externalVite",
                  icon: "ThunderboltOutlined",
                  requiresAuth: true,
                  externalLink: "https://vite.dev",
                  order: 1,
                },
              },
              {
                path: "/examples/external/link/vue",
                name: "ExamplesExternalLinkVue",
                component: () =>
                  import("@/views/examples/external/link/vue.vue"),
                meta: {
                  title: "menu.externalVue",
                  icon: "CoffeeOutlined",
                  requiresAuth: true,
                  externalLink: "https://vuejs.org",
                  order: 2,
                },
              },
            ],
          },
        ],
      },
      {
        path: "exception-pages",
        name: "ExamplesExceptionGroup",
        redirect: "/examples/exception/403",
        component: () => import("@/components/RouteView.vue"),
        meta: {
          title: "menu.examplesExceptionPages",
          icon: "WarningOutlined",
          requiresAuth: true,
          order: 8,
        },
        children: [
          {
            path: "/examples/exception/403",
            name: "ExamplesException403",
            component: () => import("@/views/examples/exception/403.vue"),
            meta: {
              title: "menu.exception403",
              icon: "StopOutlined",
              requiresAuth: true,
              order: 1,
            },
          },
          {
            path: "/examples/exception/404",
            name: "ExamplesException404",
            component: () => import("@/views/examples/exception/404.vue"),
            meta: {
              title: "menu.exception404",
              icon: "FileUnknownOutlined",
              requiresAuth: true,
              order: 2,
            },
          },
          {
            path: "/examples/exception/500",
            name: "ExamplesException500",
            component: () => import("@/views/examples/exception/500.vue"),
            meta: {
              title: "menu.exception500",
              icon: "BugOutlined",
              requiresAuth: true,
              order: 3,
            },
          },
        ],
      },
    ],
  },
];

/**
 * Catch-all route
 */
export const notFoundRoute: AppRouteRecordRaw = {
  path: "/:pathMatch(.*)*",
  name: "NotFoundCatchAll",
  redirect: "/404",
  meta: {
    title: "Not Found",
    requiresAuth: false,
    hidden: true,
  },
};
