"use client";

import React, { useMemo, useState, useEffect } from "react";
import dynamic from "next/dynamic";
import { Loader2 } from "lucide-react";
import { ScreenViewPageWrapper } from "@/app/(main)/screens/[screenId]/page";
import { apiClient } from "@/lib/api/client";
import { useAuth } from "@/hooks/useAuth";

const LoadingFallback = () => (
  <div className="flex h-full items-center justify-center">
    <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
  </div>
);

function ScreenCodeResolver({ screenCode }: { screenCode: string }) {
  const [screenId, setScreenId] = useState<number | null>(null);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    const numericId = parseInt(screenCode);
    if (!isNaN(numericId)) {
      setScreenId(numericId);
      setLoading(false);
      return;
    }
    const resolve = async () => {
      try {
        const res = await apiClient.get("/screen-management/screens", {
          params: { searchTerm: screenCode, size: 50 },
        });
        const items = res.data?.data?.data || res.data?.data || [];
        const arr = Array.isArray(items) ? items : [];
        const exact = arr.find((s: any) => s.screenCode === screenCode);
        const target = exact || arr[0];
        if (target) setScreenId(target.screenId || target.screen_id);
      } catch {
        console.error("스크린 코드 변환 실패:", screenCode);
      } finally {
        setLoading(false);
      }
    };
    resolve();
  }, [screenCode]);

  if (loading) return <LoadingFallback />;
  if (!screenId) {
    return (
      <div className="flex h-full items-center justify-center">
        <p className="text-sm text-muted-foreground">화면을 찾을 수 없습니다 (코드: {screenCode})</p>
      </div>
    );
  }
  return <ScreenViewPageWrapper screenIdProp={screenId} />;
}

const DashboardViewPage = dynamic(
  () => import("@/app/(main)/dashboard/[dashboardId]/page"),
  { ssr: false, loading: LoadingFallback },
);

const ADMIN_PAGE_REGISTRY: Record<string, React.ComponentType<any>> = {
  // 관리자 메인
  "/admin": dynamic(() => import("@/app/(main)/admin/page"), { ssr: false, loading: LoadingFallback }),

  // 메뉴 관리
  "/admin/menu": dynamic(() => import("@/app/(main)/admin/menu/page"), { ssr: false, loading: LoadingFallback }),

  // 사용자 관리
  "/admin/userMng/userMngList": dynamic(() => import("@/app/(main)/admin/userMng/userMngList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/userMng/rolesList": dynamic(() => import("@/app/(main)/admin/userMng/rolesList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/userMng/userAuthList": dynamic(() => import("@/app/(main)/admin/userMng/userAuthList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/userMng/companyList": dynamic(() => import("@/app/(main)/admin/userMng/companyList/page"), { ssr: false, loading: LoadingFallback }),

  // 화면 관리
  "/admin/screenMng/screenMngList": dynamic(() => import("@/app/(main)/admin/screenMng/screenMngList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/screenMng/dashboardList": dynamic(() => import("@/app/(main)/admin/screenMng/dashboardList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/screenMng/reportList": dynamic(() => import("@/app/(main)/admin/screenMng/reportList/page"), { ssr: false, loading: LoadingFallback }),

  // 시스템 관리
  "/admin/systemMng/commonCodeList": dynamic(() => import("@/app/(main)/admin/systemMng/commonCodeList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/systemMng/tableMngList": dynamic(() => import("@/app/(main)/admin/systemMng/tableMngList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/systemMng/i18nList": dynamic(() => import("@/app/(main)/admin/systemMng/i18nList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/systemMng/collection-managementList": dynamic(() => import("@/app/(main)/admin/systemMng/collection-managementList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/systemMng/cascading-managementList": dynamic(() => import("@/app/(main)/admin/cascading-management/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/systemMng/dataflow": dynamic(() => import("@/app/(main)/admin/systemMng/dataflow/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/systemMng/dataflow/node-editorList": dynamic(() => import("@/app/(main)/admin/systemMng/dataflow/page"), { ssr: false, loading: LoadingFallback }),

  // 자동화 관리
  "/admin/automaticMng/flowMgmtList": dynamic(() => import("@/app/(main)/admin/automaticMng/flowMgmtList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/batchmngList": dynamic(() => import("@/app/(main)/admin/automaticMng/batchmngList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/crawlingList": dynamic(() => import("@/app/(main)/admin/automaticMng/crawlingList/page"), { ssr: false, loading: LoadingFallback }),

  // === COMPANY_7 (탑씰) ===
  "/COMPANY_7/master-data/item-info": dynamic(() => import("@/app/(main)/COMPANY_7/master-data/item-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/master-data/department": dynamic(() => import("@/app/(main)/COMPANY_7/master-data/department/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/master-data/company": dynamic(() => import("@/app/(main)/COMPANY_7/master-data/company/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/master-data/options": dynamic(() => import("@/app/(main)/COMPANY_7/master-data/options/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/sales/order": dynamic(() => import("@/app/(main)/COMPANY_7/sales/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/sales/customer": dynamic(() => import("@/app/(main)/COMPANY_7/sales/customer/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/sales/sales-item": dynamic(() => import("@/app/(main)/COMPANY_7/sales/sales-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/sales/shipping-order": dynamic(() => import("@/app/(main)/COMPANY_7/sales/shipping-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/sales/shipping-plan": dynamic(() => import("@/app/(main)/COMPANY_7/sales/shipping-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/sales/claim": dynamic(() => import("@/app/(main)/COMPANY_7/sales/claim/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/sales/quote": dynamic(() => import("@/app/(main)/COMPANY_7/sales/quote/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/production/process-info": dynamic(() => import("@/app/(main)/COMPANY_7/production/process-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/production/result": dynamic(() => import("@/app/(main)/COMPANY_7/production/result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/production/work-instruction": dynamic(() => import("@/app/(main)/COMPANY_7/production/work-instruction/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/production/plan-management": dynamic(() => import("@/app/(main)/COMPANY_7/production/plan-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/production/bom": dynamic(() => import("@/app/(main)/COMPANY_7/production/bom/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/equipment/info": dynamic(() => import("@/app/(main)/COMPANY_7/equipment/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/equipment/inspection-record": dynamic(() => import("@/app/(main)/COMPANY_7/equipment/inspection-record/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/equipment/plc-settings": dynamic(() => import("@/app/(main)/COMPANY_7/equipment/plc-settings/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/logistics/material-status": dynamic(() => import("@/app/(main)/COMPANY_7/logistics/material-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/logistics/outbound": dynamic(() => import("@/app/(main)/COMPANY_7/logistics/outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/logistics/inbound-outbound": dynamic(() => import("@/app/(main)/COMPANY_7/logistics/inbound-outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/logistics/receiving": dynamic(() => import("@/app/(main)/COMPANY_7/logistics/receiving/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/logistics/packaging": dynamic(() => import("@/app/(main)/COMPANY_7/logistics/packaging/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/logistics/info": dynamic(() => import("@/app/(main)/COMPANY_7/logistics/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/logistics/inventory": dynamic(() => import("@/app/(main)/COMPANY_7/logistics/inventory/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/logistics/warehouse": dynamic(() => import("@/app/(main)/COMPANY_7/logistics/warehouse/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/outsourcing/subcontractor": dynamic(() => import("@/app/(main)/COMPANY_7/outsourcing/subcontractor/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/outsourcing/subcontractor-item": dynamic(() => import("@/app/(main)/COMPANY_7/outsourcing/subcontractor-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/outsourcing/purchase-order": dynamic(() => import("@/app/(main)/COMPANY_7/outsourcing/purchase-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/outsourcing/purchase-status": dynamic(() => import("@/app/(main)/COMPANY_7/outsourcing/purchase-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/outsourcing/vendor-stock": dynamic(() => import("@/app/(main)/COMPANY_7/outsourcing/vendor-stock/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/design/project": dynamic(() => import("@/app/(main)/COMPANY_7/design/project/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/design/change-management": dynamic(() => import("@/app/(main)/COMPANY_7/design/change-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/design/my-work": dynamic(() => import("@/app/(main)/COMPANY_7/design/my-work/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/design/design-request": dynamic(() => import("@/app/(main)/COMPANY_7/design/design-request/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/design/task-management": dynamic(() => import("@/app/(main)/COMPANY_7/design/task-management/page"), { ssr: false, loading: LoadingFallback }),
  // === COMPANY_16 (하이큐마그) ===
  "/COMPANY_16/master-data/options": dynamic(() => import("@/app/(main)/COMPANY_16/master-data/options/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/master-data/item-info": dynamic(() => import("@/app/(main)/COMPANY_16/master-data/item-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/master-data/department": dynamic(() => import("@/app/(main)/COMPANY_16/master-data/department/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/master-data/company": dynamic(() => import("@/app/(main)/COMPANY_16/master-data/company/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/sales/order": dynamic(() => import("@/app/(main)/COMPANY_16/sales/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/sales/customer": dynamic(() => import("@/app/(main)/COMPANY_16/sales/customer/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/sales/sales-item": dynamic(() => import("@/app/(main)/COMPANY_16/sales/sales-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/sales/shipping-order": dynamic(() => import("@/app/(main)/COMPANY_16/sales/shipping-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/sales/shipping-plan": dynamic(() => import("@/app/(main)/COMPANY_16/sales/shipping-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/sales/claim": dynamic(() => import("@/app/(main)/COMPANY_16/sales/claim/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/sales/quote": dynamic(() => import("@/app/(main)/COMPANY_16/sales/quote/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/production/process-info": dynamic(() => import("@/app/(main)/COMPANY_16/production/process-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/production/result": dynamic(() => import("@/app/(main)/COMPANY_16/production/result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/production/work-instruction": dynamic(() => import("@/app/(main)/COMPANY_16/production/work-instruction/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/production/plan-management": dynamic(() => import("@/app/(main)/COMPANY_16/production/plan-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/production/bom": dynamic(() => import("@/app/(main)/COMPANY_16/production/bom/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/equipment/info": dynamic(() => import("@/app/(main)/COMPANY_16/equipment/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/equipment/inspection-record": dynamic(() => import("@/app/(main)/COMPANY_16/equipment/inspection-record/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/equipment/plc-settings": dynamic(() => import("@/app/(main)/COMPANY_16/equipment/plc-settings/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/monitoring/production": dynamic(() => import("@/app/(main)/COMPANY_16/monitoring/production/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/monitoring/equipment": dynamic(() => import("@/app/(main)/COMPANY_16/monitoring/equipment/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/monitoring/quality": dynamic(() => import("@/app/(main)/COMPANY_16/monitoring/quality/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/monitoring/settings": dynamic(() => import("@/components/monitoring/MonitoringSettingsPage"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/monitoring/production": dynamic(() => import("@/app/(main)/COMPANY_7/monitoring/production/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/monitoring/equipment": dynamic(() => import("@/app/(main)/COMPANY_7/monitoring/equipment/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/monitoring/quality": dynamic(() => import("@/app/(main)/COMPANY_7/monitoring/quality/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/monitoring/settings": dynamic(() => import("@/components/monitoring/MonitoringSettingsPage"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/purchase/order": dynamic(() => import("@/app/(main)/COMPANY_7/purchase/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/purchase/purchase-item": dynamic(() => import("@/app/(main)/COMPANY_7/purchase/purchase-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/purchase/supplier": dynamic(() => import("@/app/(main)/COMPANY_7/purchase/supplier/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/quality/inspection": dynamic(() => import("@/app/(main)/COMPANY_7/quality/inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/quality/inspection-result": dynamic(() => import("@/app/(main)/COMPANY_7/quality/inspection-result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/quality/item-inspection": dynamic(() => import("@/app/(main)/COMPANY_7/quality/item-inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_7/mold/info": dynamic(() => import("@/app/(main)/COMPANY_7/mold/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/logistics/material-status": dynamic(() => import("@/app/(main)/COMPANY_16/logistics/material-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/logistics/outbound": dynamic(() => import("@/app/(main)/COMPANY_16/logistics/outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/logistics/inbound-outbound": dynamic(() => import("@/app/(main)/COMPANY_16/logistics/inbound-outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/logistics/receiving": dynamic(() => import("@/app/(main)/COMPANY_16/logistics/receiving/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/logistics/packaging": dynamic(() => import("@/app/(main)/COMPANY_16/logistics/packaging/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/logistics/inventory": dynamic(() => import("@/app/(main)/COMPANY_16/logistics/inventory/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/logistics/warehouse": dynamic(() => import("@/app/(main)/COMPANY_16/logistics/warehouse/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/logistics/info": dynamic(() => import("@/app/(main)/COMPANY_16/logistics/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/outsourcing/subcontractor": dynamic(() => import("@/app/(main)/COMPANY_16/outsourcing/subcontractor/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/outsourcing/subcontractor-item": dynamic(() => import("@/app/(main)/COMPANY_16/outsourcing/subcontractor-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/outsourcing/outbound": dynamic(() => import("@/app/(main)/COMPANY_16/outsourcing/outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/outsourcing/purchase-order": dynamic(() => import("@/app/(main)/COMPANY_16/outsourcing/purchase-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/outsourcing/purchase-status": dynamic(() => import("@/app/(main)/COMPANY_16/outsourcing/purchase-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/purchase/order": dynamic(() => import("@/app/(main)/COMPANY_16/purchase/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/purchase/purchase-item": dynamic(() => import("@/app/(main)/COMPANY_16/purchase/purchase-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/purchase/supplier": dynamic(() => import("@/app/(main)/COMPANY_16/purchase/supplier/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/quality/inspection": dynamic(() => import("@/app/(main)/COMPANY_16/quality/inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/quality/inspection-result": dynamic(() => import("@/app/(main)/COMPANY_16/quality/inspection-result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/quality/item-inspection": dynamic(() => import("@/app/(main)/COMPANY_16/quality/item-inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/mold/info": dynamic(() => import("@/app/(main)/COMPANY_16/mold/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/design/project": dynamic(() => import("@/app/(main)/COMPANY_16/design/project/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/design/change-management": dynamic(() => import("@/app/(main)/COMPANY_16/design/change-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/design/my-work": dynamic(() => import("@/app/(main)/COMPANY_16/design/my-work/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/design/design-request": dynamic(() => import("@/app/(main)/COMPANY_16/design/design-request/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/design/task-management": dynamic(() => import("@/app/(main)/COMPANY_16/design/task-management/page"), { ssr: false, loading: LoadingFallback }),
  // === COMPANY_8 (대진산업) ===
  "/COMPANY_8/master-data/options": dynamic(() => import("@/app/(main)/COMPANY_8/master-data/options/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/master-data/item-info": dynamic(() => import("@/app/(main)/COMPANY_8/master-data/item-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/master-data/department": dynamic(() => import("@/app/(main)/COMPANY_8/master-data/department/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/master-data/company": dynamic(() => import("@/app/(main)/COMPANY_8/master-data/company/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/sales/order": dynamic(() => import("@/app/(main)/COMPANY_8/sales/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/sales/customer": dynamic(() => import("@/app/(main)/COMPANY_8/sales/customer/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/sales/sales-item": dynamic(() => import("@/app/(main)/COMPANY_8/sales/sales-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/sales/shipping-order": dynamic(() => import("@/app/(main)/COMPANY_8/sales/shipping-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/sales/shipping-plan": dynamic(() => import("@/app/(main)/COMPANY_8/sales/shipping-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/sales/claim": dynamic(() => import("@/app/(main)/COMPANY_8/sales/claim/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/sales/quote": dynamic(() => import("@/app/(main)/COMPANY_8/sales/quote/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/production/process-info": dynamic(() => import("@/app/(main)/COMPANY_8/production/process-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/production/result": dynamic(() => import("@/app/(main)/COMPANY_8/production/result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/production/work-instruction": dynamic(() => import("@/app/(main)/COMPANY_8/production/work-instruction/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/production/plan-management": dynamic(() => import("@/app/(main)/COMPANY_8/production/plan-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/production/bom": dynamic(() => import("@/app/(main)/COMPANY_8/production/bom/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/equipment/info": dynamic(() => import("@/app/(main)/COMPANY_8/equipment/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/equipment/inspection-record": dynamic(() => import("@/app/(main)/COMPANY_8/equipment/inspection-record/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/equipment/plc-settings": dynamic(() => import("@/app/(main)/COMPANY_8/equipment/plc-settings/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/monitoring/production": dynamic(() => import("@/app/(main)/COMPANY_8/monitoring/production/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/monitoring/equipment": dynamic(() => import("@/app/(main)/COMPANY_8/monitoring/equipment/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/monitoring/quality": dynamic(() => import("@/app/(main)/COMPANY_8/monitoring/quality/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/monitoring/settings": dynamic(() => import("@/components/monitoring/MonitoringSettingsPage"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/logistics/material-status": dynamic(() => import("@/app/(main)/COMPANY_8/logistics/material-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/logistics/outbound": dynamic(() => import("@/app/(main)/COMPANY_8/logistics/outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/logistics/inbound-outbound": dynamic(() => import("@/app/(main)/COMPANY_8/logistics/inbound-outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/logistics/receiving": dynamic(() => import("@/app/(main)/COMPANY_8/logistics/receiving/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/logistics/packaging": dynamic(() => import("@/app/(main)/COMPANY_8/logistics/packaging/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/logistics/inventory": dynamic(() => import("@/app/(main)/COMPANY_8/logistics/inventory/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/logistics/warehouse": dynamic(() => import("@/app/(main)/COMPANY_8/logistics/warehouse/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/logistics/info": dynamic(() => import("@/app/(main)/COMPANY_8/logistics/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/outsourcing/subcontractor": dynamic(() => import("@/app/(main)/COMPANY_8/outsourcing/subcontractor/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/outsourcing/subcontractor-item": dynamic(() => import("@/app/(main)/COMPANY_8/outsourcing/subcontractor-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/outsourcing/purchase-order": dynamic(() => import("@/app/(main)/COMPANY_8/outsourcing/purchase-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/outsourcing/purchase-status": dynamic(() => import("@/app/(main)/COMPANY_8/outsourcing/purchase-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/purchase/order": dynamic(() => import("@/app/(main)/COMPANY_8/purchase/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/purchase/purchase-item": dynamic(() => import("@/app/(main)/COMPANY_8/purchase/purchase-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/purchase/supplier": dynamic(() => import("@/app/(main)/COMPANY_8/purchase/supplier/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/quality/inspection": dynamic(() => import("@/app/(main)/COMPANY_8/quality/inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/quality/inspection-result": dynamic(() => import("@/app/(main)/COMPANY_8/quality/inspection-result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/quality/item-inspection": dynamic(() => import("@/app/(main)/COMPANY_8/quality/item-inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/mold/info": dynamic(() => import("@/app/(main)/COMPANY_8/mold/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/design/project": dynamic(() => import("@/app/(main)/COMPANY_8/design/project/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/design/change-management": dynamic(() => import("@/app/(main)/COMPANY_8/design/change-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/design/my-work": dynamic(() => import("@/app/(main)/COMPANY_8/design/my-work/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/design/design-request": dynamic(() => import("@/app/(main)/COMPANY_8/design/design-request/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_8/design/task-management": dynamic(() => import("@/app/(main)/COMPANY_8/design/task-management/page"), { ssr: false, loading: LoadingFallback }),
  // === COMPANY_10 (큐앤씨) ===
  "/COMPANY_10/master-data/options": dynamic(() => import("@/app/(main)/COMPANY_10/master-data/options/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/master-data/item-info": dynamic(() => import("@/app/(main)/COMPANY_10/master-data/item-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/master-data/department": dynamic(() => import("@/app/(main)/COMPANY_10/master-data/department/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/master-data/company": dynamic(() => import("@/app/(main)/COMPANY_10/master-data/company/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/sales/order": dynamic(() => import("@/app/(main)/COMPANY_10/sales/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/sales/customer": dynamic(() => import("@/app/(main)/COMPANY_10/sales/customer/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/sales/sales-item": dynamic(() => import("@/app/(main)/COMPANY_10/sales/sales-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/sales/shipping-order": dynamic(() => import("@/app/(main)/COMPANY_10/sales/shipping-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/sales/shipping-plan": dynamic(() => import("@/app/(main)/COMPANY_10/sales/shipping-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/sales/claim": dynamic(() => import("@/app/(main)/COMPANY_10/sales/claim/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/sales/quote": dynamic(() => import("@/app/(main)/COMPANY_10/sales/quote/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/production/process-info": dynamic(() => import("@/app/(main)/COMPANY_10/production/process-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/production/result": dynamic(() => import("@/app/(main)/COMPANY_10/production/result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/production/work-instruction": dynamic(() => import("@/app/(main)/COMPANY_10/production/work-instruction/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/production/plan-management": dynamic(() => import("@/app/(main)/COMPANY_10/production/plan-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/production/bom": dynamic(() => import("@/app/(main)/COMPANY_10/production/bom/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/equipment/info": dynamic(() => import("@/app/(main)/COMPANY_10/equipment/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/equipment/inspection-record": dynamic(() => import("@/app/(main)/COMPANY_10/equipment/inspection-record/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/equipment/plc-settings": dynamic(() => import("@/app/(main)/COMPANY_10/equipment/plc-settings/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/monitoring/production": dynamic(() => import("@/app/(main)/COMPANY_10/monitoring/production/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/monitoring/equipment": dynamic(() => import("@/app/(main)/COMPANY_10/monitoring/equipment/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/monitoring/quality": dynamic(() => import("@/app/(main)/COMPANY_10/monitoring/quality/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/monitoring/settings": dynamic(() => import("@/components/monitoring/MonitoringSettingsPage"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/logistics/material-status": dynamic(() => import("@/app/(main)/COMPANY_10/logistics/material-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/logistics/outbound": dynamic(() => import("@/app/(main)/COMPANY_10/logistics/outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/logistics/inbound-outbound": dynamic(() => import("@/app/(main)/COMPANY_10/logistics/inbound-outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/logistics/receiving": dynamic(() => import("@/app/(main)/COMPANY_10/logistics/receiving/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/logistics/packaging": dynamic(() => import("@/app/(main)/COMPANY_10/logistics/packaging/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/logistics/inventory": dynamic(() => import("@/app/(main)/COMPANY_10/logistics/inventory/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/logistics/warehouse": dynamic(() => import("@/app/(main)/COMPANY_10/logistics/warehouse/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/logistics/info": dynamic(() => import("@/app/(main)/COMPANY_10/logistics/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/outsourcing/subcontractor": dynamic(() => import("@/app/(main)/COMPANY_10/outsourcing/subcontractor/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/outsourcing/subcontractor-item": dynamic(() => import("@/app/(main)/COMPANY_10/outsourcing/subcontractor-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/outsourcing/purchase-order": dynamic(() => import("@/app/(main)/COMPANY_10/outsourcing/purchase-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/outsourcing/purchase-status": dynamic(() => import("@/app/(main)/COMPANY_10/outsourcing/purchase-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/purchase/order": dynamic(() => import("@/app/(main)/COMPANY_10/purchase/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/purchase/purchase-item": dynamic(() => import("@/app/(main)/COMPANY_10/purchase/purchase-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/purchase/supplier": dynamic(() => import("@/app/(main)/COMPANY_10/purchase/supplier/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/quality/inspection": dynamic(() => import("@/app/(main)/COMPANY_10/quality/inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/quality/inspection-result": dynamic(() => import("@/app/(main)/COMPANY_10/quality/inspection-result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/quality/item-inspection": dynamic(() => import("@/app/(main)/COMPANY_10/quality/item-inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/mold/info": dynamic(() => import("@/app/(main)/COMPANY_10/mold/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/design/project": dynamic(() => import("@/app/(main)/COMPANY_10/design/project/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/design/change-management": dynamic(() => import("@/app/(main)/COMPANY_10/design/change-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/design/my-work": dynamic(() => import("@/app/(main)/COMPANY_10/design/my-work/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/design/design-request": dynamic(() => import("@/app/(main)/COMPANY_10/design/design-request/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_10/design/task-management": dynamic(() => import("@/app/(main)/COMPANY_10/design/task-management/page"), { ssr: false, loading: LoadingFallback }),
  // === COMPANY_28 (엔키드) ===
  "/COMPANY_28/master-data/company": dynamic(() => import("@/app/(main)/COMPANY_28/master-data/company/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/master-data/department": dynamic(() => import("@/app/(main)/COMPANY_28/master-data/department/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/master-data/item-info": dynamic(() => import("@/app/(main)/COMPANY_28/master-data/item-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/master-data/options": dynamic(() => import("@/app/(main)/COMPANY_28/master-data/options/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/sales/order": dynamic(() => import("@/app/(main)/COMPANY_28/sales/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/sales/customer": dynamic(() => import("@/app/(main)/COMPANY_28/sales/customer/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/sales/sales-item": dynamic(() => import("@/app/(main)/COMPANY_28/sales/sales-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/sales/shipping-order": dynamic(() => import("@/app/(main)/COMPANY_28/sales/shipping-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/sales/shipping-plan": dynamic(() => import("@/app/(main)/COMPANY_28/sales/shipping-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/sales/claim": dynamic(() => import("@/app/(main)/COMPANY_28/sales/claim/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/sales/quote": dynamic(() => import("@/app/(main)/COMPANY_28/sales/quote/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/production/process-info": dynamic(() => import("@/app/(main)/COMPANY_28/production/process-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/production/result": dynamic(() => import("@/app/(main)/COMPANY_28/production/result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/production/work-instruction": dynamic(() => import("@/app/(main)/COMPANY_28/production/work-instruction/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/production/plan-management": dynamic(() => import("@/app/(main)/COMPANY_28/production/plan-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/production/bom": dynamic(() => import("@/app/(main)/COMPANY_28/production/bom/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/equipment/info": dynamic(() => import("@/app/(main)/COMPANY_28/equipment/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/equipment/inspection-record": dynamic(() => import("@/app/(main)/COMPANY_28/equipment/inspection-record/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/equipment/plc-settings": dynamic(() => import("@/app/(main)/COMPANY_28/equipment/plc-settings/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/monitoring/production": dynamic(() => import("@/app/(main)/COMPANY_28/monitoring/production/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/monitoring/equipment": dynamic(() => import("@/app/(main)/COMPANY_28/monitoring/equipment/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/monitoring/quality": dynamic(() => import("@/app/(main)/COMPANY_28/monitoring/quality/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/monitoring/settings": dynamic(() => import("@/components/monitoring/MonitoringSettingsPage"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/logistics/material-status": dynamic(() => import("@/app/(main)/COMPANY_28/logistics/material-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/logistics/outbound": dynamic(() => import("@/app/(main)/COMPANY_28/logistics/outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/logistics/inbound-outbound": dynamic(() => import("@/app/(main)/COMPANY_28/logistics/inbound-outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/logistics/receiving": dynamic(() => import("@/app/(main)/COMPANY_28/logistics/receiving/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/logistics/packaging": dynamic(() => import("@/app/(main)/COMPANY_28/logistics/packaging/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/logistics/inventory": dynamic(() => import("@/app/(main)/COMPANY_28/logistics/inventory/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/logistics/warehouse": dynamic(() => import("@/app/(main)/COMPANY_28/logistics/warehouse/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/logistics/info": dynamic(() => import("@/app/(main)/COMPANY_28/logistics/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/outsourcing/subcontractor": dynamic(() => import("@/app/(main)/COMPANY_28/outsourcing/subcontractor/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/outsourcing/subcontractor-item": dynamic(() => import("@/app/(main)/COMPANY_28/outsourcing/subcontractor-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/outsourcing/purchase-order": dynamic(() => import("@/app/(main)/COMPANY_28/outsourcing/purchase-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/outsourcing/purchase-status": dynamic(() => import("@/app/(main)/COMPANY_28/outsourcing/purchase-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/purchase/order": dynamic(() => import("@/app/(main)/COMPANY_28/purchase/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/purchase/purchase-item": dynamic(() => import("@/app/(main)/COMPANY_28/purchase/purchase-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/purchase/supplier": dynamic(() => import("@/app/(main)/COMPANY_28/purchase/supplier/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/quality/inspection": dynamic(() => import("@/app/(main)/COMPANY_28/quality/inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/quality/inspection-result": dynamic(() => import("@/app/(main)/COMPANY_28/quality/inspection-result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/quality/item-inspection": dynamic(() => import("@/app/(main)/COMPANY_28/quality/item-inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/mold/info": dynamic(() => import("@/app/(main)/COMPANY_28/mold/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/design/project": dynamic(() => import("@/app/(main)/COMPANY_28/design/project/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/design/change-management": dynamic(() => import("@/app/(main)/COMPANY_28/design/change-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/design/my-work": dynamic(() => import("@/app/(main)/COMPANY_28/design/my-work/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/design/design-request": dynamic(() => import("@/app/(main)/COMPANY_28/design/design-request/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_28/design/task-management": dynamic(() => import("@/app/(main)/COMPANY_28/design/task-management/page"), { ssr: false, loading: LoadingFallback }),
  // === COMPANY_29 (시연용 회사) ===
  "/COMPANY_29/master-data/options": dynamic(() => import("@/app/(main)/COMPANY_29/master-data/options/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/master-data/item-info": dynamic(() => import("@/app/(main)/COMPANY_29/master-data/item-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/master-data/department": dynamic(() => import("@/app/(main)/COMPANY_29/master-data/department/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/master-data/company": dynamic(() => import("@/app/(main)/COMPANY_29/master-data/company/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/sales/order": dynamic(() => import("@/app/(main)/COMPANY_29/sales/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/sales/customer": dynamic(() => import("@/app/(main)/COMPANY_29/sales/customer/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/sales/sales-item": dynamic(() => import("@/app/(main)/COMPANY_29/sales/sales-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/sales/shipping-order": dynamic(() => import("@/app/(main)/COMPANY_29/sales/shipping-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/sales/shipping-plan": dynamic(() => import("@/app/(main)/COMPANY_29/sales/shipping-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/sales/claim": dynamic(() => import("@/app/(main)/COMPANY_29/sales/claim/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/sales/quote": dynamic(() => import("@/app/(main)/COMPANY_29/sales/quote/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/production/process-info": dynamic(() => import("@/app/(main)/COMPANY_29/production/process-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/production/result": dynamic(() => import("@/app/(main)/COMPANY_29/production/result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/production/work-instruction": dynamic(() => import("@/app/(main)/COMPANY_29/production/work-instruction/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/production/plan-management": dynamic(() => import("@/app/(main)/COMPANY_29/production/plan-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/production/bom": dynamic(() => import("@/app/(main)/COMPANY_29/production/bom/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/equipment/info": dynamic(() => import("@/app/(main)/COMPANY_29/equipment/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/equipment/inspection-record": dynamic(() => import("@/app/(main)/COMPANY_29/equipment/inspection-record/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/equipment/plc-settings": dynamic(() => import("@/app/(main)/COMPANY_29/equipment/plc-settings/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/monitoring/production": dynamic(() => import("@/app/(main)/COMPANY_29/monitoring/production/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/monitoring/equipment": dynamic(() => import("@/app/(main)/COMPANY_29/monitoring/equipment/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/monitoring/quality": dynamic(() => import("@/app/(main)/COMPANY_29/monitoring/quality/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/monitoring/settings": dynamic(() => import("@/components/monitoring/MonitoringSettingsPage"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/logistics/material-status": dynamic(() => import("@/app/(main)/COMPANY_29/logistics/material-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/logistics/outbound": dynamic(() => import("@/app/(main)/COMPANY_29/logistics/outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/logistics/inbound-outbound": dynamic(() => import("@/app/(main)/COMPANY_29/logistics/inbound-outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/logistics/receiving": dynamic(() => import("@/app/(main)/COMPANY_29/logistics/receiving/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/logistics/packaging": dynamic(() => import("@/app/(main)/COMPANY_29/logistics/packaging/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/logistics/inventory": dynamic(() => import("@/app/(main)/COMPANY_29/logistics/inventory/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/logistics/warehouse": dynamic(() => import("@/app/(main)/COMPANY_29/logistics/warehouse/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/logistics/info": dynamic(() => import("@/app/(main)/COMPANY_29/logistics/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/outsourcing/subcontractor": dynamic(() => import("@/app/(main)/COMPANY_29/outsourcing/subcontractor/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/outsourcing/subcontractor-item": dynamic(() => import("@/app/(main)/COMPANY_29/outsourcing/subcontractor-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/outsourcing/purchase-order": dynamic(() => import("@/app/(main)/COMPANY_29/outsourcing/purchase-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/outsourcing/purchase-status": dynamic(() => import("@/app/(main)/COMPANY_29/outsourcing/purchase-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/purchase/order": dynamic(() => import("@/app/(main)/COMPANY_29/purchase/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/purchase/purchase-item": dynamic(() => import("@/app/(main)/COMPANY_29/purchase/purchase-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/purchase/supplier": dynamic(() => import("@/app/(main)/COMPANY_29/purchase/supplier/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/quality/inspection": dynamic(() => import("@/app/(main)/COMPANY_29/quality/inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/quality/inspection-result": dynamic(() => import("@/app/(main)/COMPANY_29/quality/inspection-result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/quality/item-inspection": dynamic(() => import("@/app/(main)/COMPANY_29/quality/item-inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/mold/info": dynamic(() => import("@/app/(main)/COMPANY_29/mold/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/design/project": dynamic(() => import("@/app/(main)/COMPANY_29/design/project/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/design/change-management": dynamic(() => import("@/app/(main)/COMPANY_29/design/change-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/design/my-work": dynamic(() => import("@/app/(main)/COMPANY_29/design/my-work/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/design/design-request": dynamic(() => import("@/app/(main)/COMPANY_29/design/design-request/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_29/design/task-management": dynamic(() => import("@/app/(main)/COMPANY_29/design/task-management/page"), { ssr: false, loading: LoadingFallback }),
  // === COMPANY_9 (제일그라스) ===
  "/COMPANY_9/master-data/item-info": dynamic(() => import("@/app/(main)/COMPANY_9/master-data/item-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/master-data/department": dynamic(() => import("@/app/(main)/COMPANY_9/master-data/department/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/master-data/company": dynamic(() => import("@/app/(main)/COMPANY_9/master-data/company/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/master-data/options": dynamic(() => import("@/app/(main)/COMPANY_9/master-data/options/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/sales/order": dynamic(() => import("@/app/(main)/COMPANY_9/sales/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/sales/customer": dynamic(() => import("@/app/(main)/COMPANY_9/sales/customer/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/sales/sales-item": dynamic(() => import("@/app/(main)/COMPANY_9/sales/sales-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/sales/shipping-order": dynamic(() => import("@/app/(main)/COMPANY_9/sales/shipping-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/sales/shipping-plan": dynamic(() => import("@/app/(main)/COMPANY_9/sales/shipping-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/sales/claim": dynamic(() => import("@/app/(main)/COMPANY_9/sales/claim/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/sales/quote": dynamic(() => import("@/app/(main)/COMPANY_9/sales/quote/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/production/process-info": dynamic(() => import("@/app/(main)/COMPANY_9/production/process-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/production/result": dynamic(() => import("@/app/(main)/COMPANY_9/production/result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/production/work-instruction": dynamic(() => import("@/app/(main)/COMPANY_9/production/work-instruction/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/production/plan-management": dynamic(() => import("@/app/(main)/COMPANY_9/production/plan-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/production/bom": dynamic(() => import("@/app/(main)/COMPANY_9/production/bom/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/production/cutting-plan": dynamic(() => import("@/app/(main)/COMPANY_9/production/cutting-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/equipment/info": dynamic(() => import("@/app/(main)/COMPANY_9/equipment/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/equipment/inspection-record": dynamic(() => import("@/app/(main)/COMPANY_9/equipment/inspection-record/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/equipment/plc-settings": dynamic(() => import("@/app/(main)/COMPANY_9/equipment/plc-settings/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/monitoring/production": dynamic(() => import("@/app/(main)/COMPANY_9/monitoring/production/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/monitoring/equipment": dynamic(() => import("@/app/(main)/COMPANY_9/monitoring/equipment/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/monitoring/quality": dynamic(() => import("@/app/(main)/COMPANY_9/monitoring/quality/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/monitoring/settings": dynamic(() => import("@/components/monitoring/MonitoringSettingsPage"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/logistics/material-status": dynamic(() => import("@/app/(main)/COMPANY_9/logistics/material-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/logistics/outbound": dynamic(() => import("@/app/(main)/COMPANY_9/logistics/outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/logistics/inbound-outbound": dynamic(() => import("@/app/(main)/COMPANY_9/logistics/inbound-outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/logistics/receiving": dynamic(() => import("@/app/(main)/COMPANY_9/logistics/receiving/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/logistics/packaging": dynamic(() => import("@/app/(main)/COMPANY_9/logistics/packaging/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/logistics/info": dynamic(() => import("@/app/(main)/COMPANY_9/logistics/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/logistics/inventory": dynamic(() => import("@/app/(main)/COMPANY_9/logistics/inventory/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/logistics/warehouse": dynamic(() => import("@/app/(main)/COMPANY_9/logistics/warehouse/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/outsourcing/subcontractor": dynamic(() => import("@/app/(main)/COMPANY_9/outsourcing/subcontractor/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/outsourcing/subcontractor-item": dynamic(() => import("@/app/(main)/COMPANY_9/outsourcing/subcontractor-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/outsourcing/purchase-order": dynamic(() => import("@/app/(main)/COMPANY_9/outsourcing/purchase-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/outsourcing/purchase-status": dynamic(() => import("@/app/(main)/COMPANY_9/outsourcing/purchase-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/purchase/order": dynamic(() => import("@/app/(main)/COMPANY_9/purchase/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/purchase/purchase-item": dynamic(() => import("@/app/(main)/COMPANY_9/purchase/purchase-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/purchase/supplier": dynamic(() => import("@/app/(main)/COMPANY_9/purchase/supplier/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/quality/inspection": dynamic(() => import("@/app/(main)/COMPANY_9/quality/inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/quality/inspection-result": dynamic(() => import("@/app/(main)/COMPANY_9/quality/inspection-result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/quality/item-inspection": dynamic(() => import("@/app/(main)/COMPANY_9/quality/item-inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/mold/info": dynamic(() => import("@/app/(main)/COMPANY_9/mold/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/design/project": dynamic(() => import("@/app/(main)/COMPANY_9/design/project/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/design/change-management": dynamic(() => import("@/app/(main)/COMPANY_9/design/change-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/design/my-work": dynamic(() => import("@/app/(main)/COMPANY_9/design/my-work/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/design/design-request": dynamic(() => import("@/app/(main)/COMPANY_9/design/design-request/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_9/design/task-management": dynamic(() => import("@/app/(main)/COMPANY_9/design/task-management/page"), { ssr: false, loading: LoadingFallback }),

  // === COMPANY_30 ===
  "/COMPANY_30/kpi/production/daily": dynamic(() => import("@/app/(main)/COMPANY_30/kpi/production/daily/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_16/kpi/production/daily": dynamic(() => import("@/app/(main)/COMPANY_16/kpi/production/daily/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/master-data/item-info": dynamic(() => import("@/app/(main)/COMPANY_30/master-data/item-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/master-data/department": dynamic(() => import("@/app/(main)/COMPANY_30/master-data/department/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/master-data/company": dynamic(() => import("@/app/(main)/COMPANY_30/master-data/company/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/master-data/options": dynamic(() => import("@/app/(main)/COMPANY_30/master-data/options/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/sales/order": dynamic(() => import("@/app/(main)/COMPANY_30/sales/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/sales/customer": dynamic(() => import("@/app/(main)/COMPANY_30/sales/customer/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/sales/sales-item": dynamic(() => import("@/app/(main)/COMPANY_30/sales/sales-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/sales/shipping-order": dynamic(() => import("@/app/(main)/COMPANY_30/sales/shipping-order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/sales/shipping-plan": dynamic(() => import("@/app/(main)/COMPANY_30/sales/shipping-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/sales/claim": dynamic(() => import("@/app/(main)/COMPANY_30/sales/claim/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/sales/quote": dynamic(() => import("@/app/(main)/COMPANY_30/sales/quote/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/production/process-info": dynamic(() => import("@/app/(main)/COMPANY_30/production/process-info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/production/result": dynamic(() => import("@/app/(main)/COMPANY_30/production/result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/production/work-instruction": dynamic(() => import("@/app/(main)/COMPANY_30/production/work-instruction/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/production/plan-management": dynamic(() => import("@/app/(main)/COMPANY_30/production/plan-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/production/bom": dynamic(() => import("@/app/(main)/COMPANY_30/production/bom/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/production/cutting-plan": dynamic(() => import("@/app/(main)/COMPANY_30/production/cutting-plan/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/equipment/info": dynamic(() => import("@/app/(main)/COMPANY_30/equipment/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/equipment/inspection-record": dynamic(() => import("@/app/(main)/COMPANY_30/equipment/inspection-record/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/equipment/plc-settings": dynamic(() => import("@/app/(main)/COMPANY_30/equipment/plc-settings/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/monitoring/production": dynamic(() => import("@/app/(main)/COMPANY_30/monitoring/production/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/monitoring/equipment": dynamic(() => import("@/app/(main)/COMPANY_30/monitoring/equipment/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/monitoring/quality": dynamic(() => import("@/app/(main)/COMPANY_30/monitoring/quality/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/monitoring/settings": dynamic(() => import("@/components/monitoring/MonitoringSettingsPage"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/logistics/material-status": dynamic(() => import("@/app/(main)/COMPANY_30/logistics/material-status/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/logistics/outbound": dynamic(() => import("@/app/(main)/COMPANY_30/logistics/outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/logistics/inbound-outbound": dynamic(() => import("@/app/(main)/COMPANY_30/logistics/inbound-outbound/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/logistics/receiving": dynamic(() => import("@/app/(main)/COMPANY_30/logistics/receiving/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/logistics/packaging": dynamic(() => import("@/app/(main)/COMPANY_30/logistics/packaging/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/logistics/info": dynamic(() => import("@/app/(main)/COMPANY_30/logistics/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/logistics/inventory": dynamic(() => import("@/app/(main)/COMPANY_30/logistics/inventory/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/logistics/warehouse": dynamic(() => import("@/app/(main)/COMPANY_30/logistics/warehouse/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/outsourcing/subcontractor": dynamic(() => import("@/app/(main)/COMPANY_30/outsourcing/subcontractor/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/outsourcing/subcontractor-item": dynamic(() => import("@/app/(main)/COMPANY_30/outsourcing/subcontractor-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/purchase/order": dynamic(() => import("@/app/(main)/COMPANY_30/purchase/order/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/purchase/purchase-item": dynamic(() => import("@/app/(main)/COMPANY_30/purchase/purchase-item/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/purchase/supplier": dynamic(() => import("@/app/(main)/COMPANY_30/purchase/supplier/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/quality/inspection": dynamic(() => import("@/app/(main)/COMPANY_30/quality/inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/quality/inspection-result": dynamic(() => import("@/app/(main)/COMPANY_30/quality/inspection-result/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/quality/item-inspection": dynamic(() => import("@/app/(main)/COMPANY_30/quality/item-inspection/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/mold/info": dynamic(() => import("@/app/(main)/COMPANY_30/mold/info/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/design/project": dynamic(() => import("@/app/(main)/COMPANY_30/design/project/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/design/change-management": dynamic(() => import("@/app/(main)/COMPANY_30/design/change-management/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/design/my-work": dynamic(() => import("@/app/(main)/COMPANY_30/design/my-work/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/design/design-request": dynamic(() => import("@/app/(main)/COMPANY_30/design/design-request/page"), { ssr: false, loading: LoadingFallback }),
  "/COMPANY_30/design/task-management": dynamic(() => import("@/app/(main)/COMPANY_30/design/task-management/page"), { ssr: false, loading: LoadingFallback }),

  "/admin/automaticMng/exconList": dynamic(() => import("@/app/(main)/admin/automaticMng/exconList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/exCallConfList": dynamic(() => import("@/app/(main)/admin/automaticMng/exCallConfList/page"), { ssr: false, loading: LoadingFallback }),

  // 메일
  "/admin/automaticMng/mail/send": dynamic(() => import("@/app/(main)/admin/automaticMng/mail/send/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/mail/receive": dynamic(() => import("@/app/(main)/admin/automaticMng/mail/receive/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/mail/sent": dynamic(() => import("@/app/(main)/admin/automaticMng/mail/sent/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/mail/drafts": dynamic(() => import("@/app/(main)/admin/automaticMng/mail/drafts/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/mail/trash": dynamic(() => import("@/app/(main)/admin/automaticMng/mail/trash/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/mail/accounts": dynamic(() => import("@/app/(main)/admin/automaticMng/mail/accounts/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/mail/templates": dynamic(() => import("@/app/(main)/admin/automaticMng/mail/templates/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/mail/dashboardList": dynamic(() => import("@/app/(main)/admin/automaticMng/mail/dashboardList/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/automaticMng/mail/bulk-send": dynamic(() => import("@/app/(main)/admin/automaticMng/mail/bulk-send/page"), { ssr: false, loading: LoadingFallback }),
  "/mail/imap": dynamic(() => import("@/app/(main)/mail/imap/page"), { ssr: false, loading: LoadingFallback }),

  // 배치 관리
  "/admin/batch-management": dynamic(() => import("@/app/(main)/admin/batch-management/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/batch-management-new": dynamic(() => import("@/app/(main)/admin/batch-management-new/page"), { ssr: false, loading: LoadingFallback }),

  // 결재 관리
  "/admin/approvalTemplate": dynamic(() => import("@/app/(main)/admin/approvalTemplate/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/approvalBox": dynamic(() => import("@/app/(main)/admin/approvalBox/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/approvalMng": dynamic(() => import("@/app/(main)/admin/approvalMng/page"), { ssr: false, loading: LoadingFallback }),

  // 시스템
  "/admin/audit-log": dynamic(() => import("@/app/(main)/admin/audit-log/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/system-notices": dynamic(() => import("@/app/(main)/admin/system-notices/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/aiAssistant": dynamic(() => import("@/app/(main)/admin/aiAssistant/page"), { ssr: false, loading: LoadingFallback }),

  // 기타
  "/admin/cascading-management": dynamic(() => import("@/app/(main)/admin/cascading-management/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/cascading-relations": dynamic(() => import("@/app/(main)/admin/cascading-management/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/layouts": dynamic(() => import("@/app/(main)/admin/layouts/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/templates": dynamic(() => import("@/app/(main)/admin/templates/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/monitoring": dynamic(() => import("@/app/(main)/admin/monitoring/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/standards": dynamic(() => import("@/app/(main)/admin/standards/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/flow-external-db": dynamic(() => import("@/app/(main)/admin/flow-external-db/page"), { ssr: false, loading: LoadingFallback }),
  "/admin/auto-fill": dynamic(() => import("@/app/(main)/admin/cascading-management/page"), { ssr: false, loading: LoadingFallback }),
};

const DYNAMIC_ADMIN_IMPORTS: Record<string, () => Promise<any>> = {
  "/admin/aiAssistant/dashboard": () => import("@/app/(main)/admin/aiAssistant/dashboard/page"),
  "/admin/aiAssistant/history": () => import("@/app/(main)/admin/aiAssistant/history/page"),
  "/admin/aiAssistant/api-keys": () => import("@/app/(main)/admin/aiAssistant/api-keys/page"),
  "/admin/aiAssistant/api-test": () => import("@/app/(main)/admin/aiAssistant/api-test/page"),
  "/admin/aiAssistant/usage": () => import("@/app/(main)/admin/aiAssistant/usage/page"),
  "/admin/aiAssistant/chat": () => import("@/app/(main)/admin/aiAssistant/chat/page"),
  "/admin/screenMng/barcodeList": () => import("@/app/(main)/admin/screenMng/barcodeList/page"),
  "/admin/automaticMng/batchmngList/create": () => import("@/app/(main)/admin/automaticMng/batchmngList/create/page"),
  "/admin/systemMng/dataflow/node-editorList": () => import("@/app/(main)/admin/systemMng/dataflow/page"),
  "/admin/standards/new": () => import("@/app/(main)/admin/standards/new/page"),

  // === 회사별 커스텀 페이지 (resolvedUrl로 매칭) ===
  // COMPANY_7 (탑씰)
  "/COMPANY_7/master-data/item-info": () => import("@/app/(main)/COMPANY_7/master-data/item-info/page"),
  "/COMPANY_7/master-data/department": () => import("@/app/(main)/COMPANY_7/master-data/department/page"),
  "/COMPANY_7/master-data/company": () => import("@/app/(main)/COMPANY_7/master-data/company/page"),
  "/COMPANY_7/master-data/options": () => import("@/app/(main)/COMPANY_7/master-data/options/page"),
  "/COMPANY_7/sales/order": () => import("@/app/(main)/COMPANY_7/sales/order/page"),
  "/COMPANY_7/sales/customer": () => import("@/app/(main)/COMPANY_7/sales/customer/page"),
  "/COMPANY_7/sales/sales-item": () => import("@/app/(main)/COMPANY_7/sales/sales-item/page"),
  "/COMPANY_7/sales/shipping-order": () => import("@/app/(main)/COMPANY_7/sales/shipping-order/page"),
  "/COMPANY_7/sales/shipping-plan": () => import("@/app/(main)/COMPANY_7/sales/shipping-plan/page"),
  "/COMPANY_7/sales/claim": () => import("@/app/(main)/COMPANY_7/sales/claim/page"),
  "/COMPANY_7/production/process-info": () => import("@/app/(main)/COMPANY_7/production/process-info/page"),
  "/COMPANY_7/production/result": () => import("@/app/(main)/COMPANY_7/production/result/page"),
  "/COMPANY_7/production/work-instruction": () => import("@/app/(main)/COMPANY_7/production/work-instruction/page"),
  "/COMPANY_7/production/plan-management": () => import("@/app/(main)/COMPANY_7/production/plan-management/page"),
  "/COMPANY_7/production/bom": () => import("@/app/(main)/COMPANY_7/production/bom/page"),
  "/COMPANY_7/equipment/info": () => import("@/app/(main)/COMPANY_7/equipment/info/page"),
  "/COMPANY_7/equipment/plc-settings": () => import("@/app/(main)/COMPANY_7/equipment/plc-settings/page"),
  "/COMPANY_7/logistics/material-status": () => import("@/app/(main)/COMPANY_7/logistics/material-status/page"),
  "/COMPANY_7/logistics/outbound": () => import("@/app/(main)/COMPANY_7/logistics/outbound/page"),
  "/COMPANY_7/logistics/inbound-outbound": () => import("@/app/(main)/COMPANY_7/logistics/inbound-outbound/page"),
  "/COMPANY_7/logistics/receiving": () => import("@/app/(main)/COMPANY_7/logistics/receiving/page"),
  "/COMPANY_7/logistics/packaging": () => import("@/app/(main)/COMPANY_7/logistics/packaging/page"),
  "/COMPANY_7/logistics/info": () => import("@/app/(main)/COMPANY_7/logistics/info/page"),
  "/COMPANY_7/logistics/inventory": () => import("@/app/(main)/COMPANY_7/logistics/inventory/page"),
  "/COMPANY_7/logistics/warehouse": () => import("@/app/(main)/COMPANY_7/logistics/warehouse/page"),
  "/COMPANY_7/outsourcing/subcontractor": () => import("@/app/(main)/COMPANY_7/outsourcing/subcontractor/page"),
  "/COMPANY_7/outsourcing/subcontractor-item": () => import("@/app/(main)/COMPANY_7/outsourcing/subcontractor-item/page"),
  "/COMPANY_7/design/project": () => import("@/app/(main)/COMPANY_7/design/project/page"),
  "/COMPANY_7/design/change-management": () => import("@/app/(main)/COMPANY_7/design/change-management/page"),
  "/COMPANY_7/design/my-work": () => import("@/app/(main)/COMPANY_7/design/my-work/page"),
  "/COMPANY_7/design/design-request": () => import("@/app/(main)/COMPANY_7/design/design-request/page"),
  "/COMPANY_7/design/task-management": () => import("@/app/(main)/COMPANY_7/design/task-management/page"),
  // COMPANY_10 (큐앤씨)
  "/COMPANY_10/master-data/item-info": () => import("@/app/(main)/COMPANY_10/master-data/item-info/page"),
  "/COMPANY_10/master-data/department": () => import("@/app/(main)/COMPANY_10/master-data/department/page"),
  "/COMPANY_10/sales/order": () => import("@/app/(main)/COMPANY_10/sales/order/page"),
  "/COMPANY_10/sales/customer": () => import("@/app/(main)/COMPANY_10/sales/customer/page"),
  "/COMPANY_10/sales/sales-item": () => import("@/app/(main)/COMPANY_10/sales/sales-item/page"),
  "/COMPANY_10/sales/shipping-order": () => import("@/app/(main)/COMPANY_10/sales/shipping-order/page"),
  "/COMPANY_10/sales/shipping-plan": () => import("@/app/(main)/COMPANY_10/sales/shipping-plan/page"),
  "/COMPANY_10/sales/claim": () => import("@/app/(main)/COMPANY_10/sales/claim/page"),
  "/COMPANY_10/production/process-info": () => import("@/app/(main)/COMPANY_10/production/process-info/page"),
  "/COMPANY_10/production/result": () => import("@/app/(main)/COMPANY_10/production/result/page"),
  "/COMPANY_10/production/work-instruction": () => import("@/app/(main)/COMPANY_10/production/work-instruction/page"),
  "/COMPANY_10/production/plan-management": () => import("@/app/(main)/COMPANY_10/production/plan-management/page"),
  "/COMPANY_10/equipment/info": () => import("@/app/(main)/COMPANY_10/equipment/info/page"),
  "/COMPANY_10/logistics/material-status": () => import("@/app/(main)/COMPANY_10/logistics/material-status/page"),
  "/COMPANY_10/logistics/outbound": () => import("@/app/(main)/COMPANY_10/logistics/outbound/page"),
  "/COMPANY_10/logistics/inbound-outbound": () => import("@/app/(main)/COMPANY_10/logistics/inbound-outbound/page"),
  "/COMPANY_10/logistics/receiving": () => import("@/app/(main)/COMPANY_10/logistics/receiving/page"),
  "/COMPANY_10/logistics/packaging": () => import("@/app/(main)/COMPANY_10/logistics/packaging/page"),
  "/COMPANY_10/outsourcing/subcontractor": () => import("@/app/(main)/COMPANY_10/outsourcing/subcontractor/page"),
  "/COMPANY_10/outsourcing/subcontractor-item": () => import("@/app/(main)/COMPANY_10/outsourcing/subcontractor-item/page"),
  "/COMPANY_10/design/project": () => import("@/app/(main)/COMPANY_10/design/project/page"),
  "/COMPANY_10/design/change-management": () => import("@/app/(main)/COMPANY_10/design/change-management/page"),
  "/COMPANY_10/design/my-work": () => import("@/app/(main)/COMPANY_10/design/my-work/page"),
  "/COMPANY_10/design/design-request": () => import("@/app/(main)/COMPANY_10/design/design-request/page"),
  "/COMPANY_10/design/task-management": () => import("@/app/(main)/COMPANY_10/design/task-management/page"),
  // COMPANY_9 (제일그라스)
  "/COMPANY_9/master-data/item-info": () => import("@/app/(main)/COMPANY_9/master-data/item-info/page"),
  "/COMPANY_9/master-data/department": () => import("@/app/(main)/COMPANY_9/master-data/department/page"),
  "/COMPANY_9/master-data/company": () => import("@/app/(main)/COMPANY_9/master-data/company/page"),
  "/COMPANY_9/master-data/options": () => import("@/app/(main)/COMPANY_9/master-data/options/page"),
  "/COMPANY_9/sales/order": () => import("@/app/(main)/COMPANY_9/sales/order/page"),
  "/COMPANY_9/sales/customer": () => import("@/app/(main)/COMPANY_9/sales/customer/page"),
  "/COMPANY_9/sales/sales-item": () => import("@/app/(main)/COMPANY_9/sales/sales-item/page"),
  "/COMPANY_9/sales/shipping-order": () => import("@/app/(main)/COMPANY_9/sales/shipping-order/page"),
  "/COMPANY_9/sales/shipping-plan": () => import("@/app/(main)/COMPANY_9/sales/shipping-plan/page"),
  "/COMPANY_9/sales/claim": () => import("@/app/(main)/COMPANY_9/sales/claim/page"),
  "/COMPANY_9/sales/quote": () => import("@/app/(main)/COMPANY_9/sales/quote/page"),
  "/COMPANY_9/production/process-info": () => import("@/app/(main)/COMPANY_9/production/process-info/page"),
  "/COMPANY_9/production/result": () => import("@/app/(main)/COMPANY_9/production/result/page"),
  "/COMPANY_9/production/work-instruction": () => import("@/app/(main)/COMPANY_9/production/work-instruction/page"),
  "/COMPANY_9/production/plan-management": () => import("@/app/(main)/COMPANY_9/production/plan-management/page"),
  "/COMPANY_9/production/bom": () => import("@/app/(main)/COMPANY_9/production/bom/page"),
  "/COMPANY_9/production/cutting-plan": () => import("@/app/(main)/COMPANY_9/production/cutting-plan/page"),
  "/COMPANY_9/equipment/info": () => import("@/app/(main)/COMPANY_9/equipment/info/page"),
  "/COMPANY_9/equipment/plc-settings": () => import("@/app/(main)/COMPANY_9/equipment/plc-settings/page"),
  "/COMPANY_9/monitoring/production": () => import("@/app/(main)/COMPANY_9/monitoring/production/page"),
  "/COMPANY_9/monitoring/equipment": () => import("@/app/(main)/COMPANY_9/monitoring/equipment/page"),
  "/COMPANY_9/monitoring/quality": () => import("@/app/(main)/COMPANY_9/monitoring/quality/page"),
  "/COMPANY_9/logistics/material-status": () => import("@/app/(main)/COMPANY_9/logistics/material-status/page"),
  "/COMPANY_9/logistics/outbound": () => import("@/app/(main)/COMPANY_9/logistics/outbound/page"),
  "/COMPANY_9/logistics/inbound-outbound": () => import("@/app/(main)/COMPANY_9/logistics/inbound-outbound/page"),
  "/COMPANY_9/logistics/receiving": () => import("@/app/(main)/COMPANY_9/logistics/receiving/page"),
  "/COMPANY_9/logistics/packaging": () => import("@/app/(main)/COMPANY_9/logistics/packaging/page"),
  "/COMPANY_9/logistics/info": () => import("@/app/(main)/COMPANY_9/logistics/info/page"),
  "/COMPANY_9/logistics/inventory": () => import("@/app/(main)/COMPANY_9/logistics/inventory/page"),
  "/COMPANY_9/logistics/warehouse": () => import("@/app/(main)/COMPANY_9/logistics/warehouse/page"),
  "/COMPANY_9/outsourcing/subcontractor": () => import("@/app/(main)/COMPANY_9/outsourcing/subcontractor/page"),
  "/COMPANY_9/outsourcing/subcontractor-item": () => import("@/app/(main)/COMPANY_9/outsourcing/subcontractor-item/page"),
  "/COMPANY_9/purchase/order": () => import("@/app/(main)/COMPANY_9/purchase/order/page"),
  "/COMPANY_9/purchase/purchase-item": () => import("@/app/(main)/COMPANY_9/purchase/purchase-item/page"),
  "/COMPANY_9/purchase/supplier": () => import("@/app/(main)/COMPANY_9/purchase/supplier/page"),
  "/COMPANY_9/quality/inspection": () => import("@/app/(main)/COMPANY_9/quality/inspection/page"),
  "/COMPANY_9/quality/item-inspection": () => import("@/app/(main)/COMPANY_9/quality/item-inspection/page"),
  "/COMPANY_9/mold/info": () => import("@/app/(main)/COMPANY_9/mold/info/page"),
  "/COMPANY_9/design/project": () => import("@/app/(main)/COMPANY_9/design/project/page"),
  "/COMPANY_9/design/change-management": () => import("@/app/(main)/COMPANY_9/design/change-management/page"),
  "/COMPANY_9/design/my-work": () => import("@/app/(main)/COMPANY_9/design/my-work/page"),
  "/COMPANY_9/design/design-request": () => import("@/app/(main)/COMPANY_9/design/design-request/page"),
  "/COMPANY_9/design/task-management": () => import("@/app/(main)/COMPANY_9/design/task-management/page"),
  // COMPANY_30
  "/COMPANY_30/kpi/production/daily": () => import("@/app/(main)/COMPANY_30/kpi/production/daily/page"),
  "/COMPANY_16/kpi/production/daily": () => import("@/app/(main)/COMPANY_16/kpi/production/daily/page"),
  "/COMPANY_30/master-data/item-info": () => import("@/app/(main)/COMPANY_30/master-data/item-info/page"),
  "/COMPANY_30/master-data/department": () => import("@/app/(main)/COMPANY_30/master-data/department/page"),
  "/COMPANY_30/master-data/company": () => import("@/app/(main)/COMPANY_30/master-data/company/page"),
  "/COMPANY_30/master-data/options": () => import("@/app/(main)/COMPANY_30/master-data/options/page"),
  "/COMPANY_30/sales/order": () => import("@/app/(main)/COMPANY_30/sales/order/page"),
  "/COMPANY_30/sales/customer": () => import("@/app/(main)/COMPANY_30/sales/customer/page"),
  "/COMPANY_30/sales/sales-item": () => import("@/app/(main)/COMPANY_30/sales/sales-item/page"),
  "/COMPANY_30/sales/shipping-order": () => import("@/app/(main)/COMPANY_30/sales/shipping-order/page"),
  "/COMPANY_30/sales/shipping-plan": () => import("@/app/(main)/COMPANY_30/sales/shipping-plan/page"),
  "/COMPANY_30/sales/claim": () => import("@/app/(main)/COMPANY_30/sales/claim/page"),
  "/COMPANY_30/sales/quote": () => import("@/app/(main)/COMPANY_30/sales/quote/page"),
  "/COMPANY_30/production/process-info": () => import("@/app/(main)/COMPANY_30/production/process-info/page"),
  "/COMPANY_30/production/result": () => import("@/app/(main)/COMPANY_30/production/result/page"),
  "/COMPANY_30/production/work-instruction": () => import("@/app/(main)/COMPANY_30/production/work-instruction/page"),
  "/COMPANY_30/production/plan-management": () => import("@/app/(main)/COMPANY_30/production/plan-management/page"),
  "/COMPANY_30/production/bom": () => import("@/app/(main)/COMPANY_30/production/bom/page"),
  "/COMPANY_30/production/cutting-plan": () => import("@/app/(main)/COMPANY_30/production/cutting-plan/page"),
  "/COMPANY_30/equipment/info": () => import("@/app/(main)/COMPANY_30/equipment/info/page"),
  "/COMPANY_30/equipment/plc-settings": () => import("@/app/(main)/COMPANY_30/equipment/plc-settings/page"),
  "/COMPANY_30/monitoring/production": () => import("@/app/(main)/COMPANY_30/monitoring/production/page"),
  "/COMPANY_30/monitoring/equipment": () => import("@/app/(main)/COMPANY_30/monitoring/equipment/page"),
  "/COMPANY_30/monitoring/quality": () => import("@/app/(main)/COMPANY_30/monitoring/quality/page"),
  "/COMPANY_30/logistics/material-status": () => import("@/app/(main)/COMPANY_30/logistics/material-status/page"),
  "/COMPANY_30/logistics/outbound": () => import("@/app/(main)/COMPANY_30/logistics/outbound/page"),
  "/COMPANY_30/logistics/inbound-outbound": () => import("@/app/(main)/COMPANY_30/logistics/inbound-outbound/page"),
  "/COMPANY_30/logistics/receiving": () => import("@/app/(main)/COMPANY_30/logistics/receiving/page"),
  "/COMPANY_30/logistics/packaging": () => import("@/app/(main)/COMPANY_30/logistics/packaging/page"),
  "/COMPANY_30/logistics/info": () => import("@/app/(main)/COMPANY_30/logistics/info/page"),
  "/COMPANY_30/logistics/inventory": () => import("@/app/(main)/COMPANY_30/logistics/inventory/page"),
  "/COMPANY_30/logistics/warehouse": () => import("@/app/(main)/COMPANY_30/logistics/warehouse/page"),
  "/COMPANY_30/outsourcing/subcontractor": () => import("@/app/(main)/COMPANY_30/outsourcing/subcontractor/page"),
  "/COMPANY_30/outsourcing/subcontractor-item": () => import("@/app/(main)/COMPANY_30/outsourcing/subcontractor-item/page"),
  "/COMPANY_30/purchase/order": () => import("@/app/(main)/COMPANY_30/purchase/order/page"),
  "/COMPANY_30/purchase/purchase-item": () => import("@/app/(main)/COMPANY_30/purchase/purchase-item/page"),
  "/COMPANY_30/purchase/supplier": () => import("@/app/(main)/COMPANY_30/purchase/supplier/page"),
  "/COMPANY_30/quality/inspection": () => import("@/app/(main)/COMPANY_30/quality/inspection/page"),
  "/COMPANY_30/quality/item-inspection": () => import("@/app/(main)/COMPANY_30/quality/item-inspection/page"),
  "/COMPANY_30/mold/info": () => import("@/app/(main)/COMPANY_30/mold/info/page"),
  "/COMPANY_30/design/project": () => import("@/app/(main)/COMPANY_30/design/project/page"),
  "/COMPANY_30/design/change-management": () => import("@/app/(main)/COMPANY_30/design/change-management/page"),
  "/COMPANY_30/design/my-work": () => import("@/app/(main)/COMPANY_30/design/my-work/page"),
  "/COMPANY_30/design/design-request": () => import("@/app/(main)/COMPANY_30/design/design-request/page"),
  "/COMPANY_30/design/task-management": () => import("@/app/(main)/COMPANY_30/design/task-management/page"),
  // COMPANY_29
  "/COMPANY_29/master-data/item-info": () => import("@/app/(main)/COMPANY_29/master-data/item-info/page"),
  "/COMPANY_29/master-data/department": () => import("@/app/(main)/COMPANY_29/master-data/department/page"),
  "/COMPANY_29/sales/order": () => import("@/app/(main)/COMPANY_29/sales/order/page"),
  "/COMPANY_29/sales/customer": () => import("@/app/(main)/COMPANY_29/sales/customer/page"),
  "/COMPANY_29/sales/sales-item": () => import("@/app/(main)/COMPANY_29/sales/sales-item/page"),
  "/COMPANY_29/sales/shipping-order": () => import("@/app/(main)/COMPANY_29/sales/shipping-order/page"),
  "/COMPANY_29/sales/shipping-plan": () => import("@/app/(main)/COMPANY_29/sales/shipping-plan/page"),
  "/COMPANY_29/sales/claim": () => import("@/app/(main)/COMPANY_29/sales/claim/page"),
  "/COMPANY_29/production/process-info": () => import("@/app/(main)/COMPANY_29/production/process-info/page"),
  "/COMPANY_29/production/result": () => import("@/app/(main)/COMPANY_29/production/result/page"),
  "/COMPANY_29/production/work-instruction": () => import("@/app/(main)/COMPANY_29/production/work-instruction/page"),
  "/COMPANY_29/production/plan-management": () => import("@/app/(main)/COMPANY_29/production/plan-management/page"),
  "/COMPANY_29/equipment/info": () => import("@/app/(main)/COMPANY_29/equipment/info/page"),
  "/COMPANY_29/logistics/material-status": () => import("@/app/(main)/COMPANY_29/logistics/material-status/page"),
  "/COMPANY_29/logistics/outbound": () => import("@/app/(main)/COMPANY_29/logistics/outbound/page"),
  "/COMPANY_29/logistics/inbound-outbound": () => import("@/app/(main)/COMPANY_29/logistics/inbound-outbound/page"),
  "/COMPANY_29/logistics/receiving": () => import("@/app/(main)/COMPANY_29/logistics/receiving/page"),
  "/COMPANY_29/logistics/packaging": () => import("@/app/(main)/COMPANY_29/logistics/packaging/page"),
  "/COMPANY_29/outsourcing/subcontractor": () => import("@/app/(main)/COMPANY_29/outsourcing/subcontractor/page"),
  "/COMPANY_29/outsourcing/subcontractor-item": () => import("@/app/(main)/COMPANY_29/outsourcing/subcontractor-item/page"),
  "/COMPANY_29/design/project": () => import("@/app/(main)/COMPANY_29/design/project/page"),
  "/COMPANY_29/design/change-management": () => import("@/app/(main)/COMPANY_29/design/change-management/page"),
  "/COMPANY_29/design/my-work": () => import("@/app/(main)/COMPANY_29/design/my-work/page"),
  "/COMPANY_29/design/design-request": () => import("@/app/(main)/COMPANY_29/design/design-request/page"),
  "/COMPANY_29/design/task-management": () => import("@/app/(main)/COMPANY_29/design/task-management/page"),
};

const DYNAMIC_ADMIN_PATTERNS: Array<{
  pattern: RegExp;
  getImport: (match: RegExpMatchArray) => Promise<any>;
  extractParams: (match: RegExpMatchArray) => Record<string, string>;
}> = [
  {
    pattern: /^\/admin\/userMng\/rolesList\/([^/]+)$/,
    getImport: () => import("@/app/(main)/admin/userMng/rolesList/[id]/page"),
    extractParams: (m) => ({ id: m[1] }),
  },
  {
    pattern: /^\/admin\/screenMng\/dashboardList\/([^/]+)$/,
    getImport: () => import("@/app/(main)/admin/screenMng/dashboardList/[id]/page"),
    extractParams: (m) => ({ id: m[1] }),
  },
  {
    pattern: /^\/admin\/automaticMng\/flowMgmtList\/([^/]+)$/,
    getImport: () => import("@/app/(main)/admin/automaticMng/flowMgmtList/[id]/page"),
    extractParams: (m) => ({ id: m[1] }),
  },
  {
    pattern: /^\/admin\/automaticMng\/batchmngList\/edit\/([^/]+)$/,
    getImport: () => import("@/app/(main)/admin/automaticMng/batchmngList/edit/[id]/page"),
    extractParams: (m) => ({ id: m[1] }),
  },
  {
    pattern: /^\/admin\/screenMng\/barcodeList\/designer\/([^/]+)$/,
    getImport: () => import("@/app/(main)/admin/screenMng/barcodeList/designer/[labelId]/page"),
    extractParams: (m) => ({ labelId: m[1] }),
  },
  {
    pattern: /^\/admin\/screenMng\/reportList\/designer\/([^/]+)$/,
    getImport: () => import("@/app/(main)/admin/screenMng/reportList/designer/[reportId]/page"),
    extractParams: (m) => ({ reportId: m[1] }),
  },
  {
    pattern: /^\/admin\/systemMng\/dataflow\/edit\/([^/]+)$/,
    getImport: () => import("@/app/(main)/admin/systemMng/dataflow/edit/[diagramId]/page"),
    extractParams: (m) => ({ diagramId: m[1] }),
  },
  {
    pattern: /^\/admin\/userMng\/companyList\/([^/]+)\/departments$/,
    getImport: () => import("@/app/(main)/admin/userMng/companyList/[companyCode]/departments/page"),
    extractParams: (m) => ({ companyCode: m[1] }),
  },
  {
    pattern: /^\/admin\/standards\/([^/]+)\/edit$/,
    getImport: () => import("@/app/(main)/admin/standards/[webType]/edit/page"),
    extractParams: (m) => ({ webType: m[1] }),
  },
  {
    pattern: /^\/admin\/standards\/([^/]+)$/,
    getImport: () => import("@/app/(main)/admin/standards/[webType]/page"),
    extractParams: (m) => ({ webType: m[1] }),
  },
];

function DynamicAdminLoader({ url, params }: { url: string; params?: Record<string, string> }) {
  const [Component, setComponent] = useState<React.ComponentType<any> | null>(null);
  const [failed, setFailed] = useState(false);

  useEffect(() => {
    let cancelled = false;

    const tryLoad = async () => {
      // 1) 정적 import 목록
      const staticImport = DYNAMIC_ADMIN_IMPORTS[url];
      if (staticImport) {
        try {
          const mod = await staticImport();
          if (!cancelled) setComponent(() => mod.default);
        } catch {
          if (!cancelled) setFailed(true);
        }
        return;
      }

      // 2) 동적 라우트 패턴 매칭
      for (const { pattern, getImport } of DYNAMIC_ADMIN_PATTERNS) {
        const match = url.match(pattern);
        if (match) {
          try {
            const mod = await getImport();
            if (!cancelled) setComponent(() => mod.default);
          } catch {
            if (!cancelled) setFailed(true);
          }
          return;
        }
      }

      // 3) URL 경로 기반 자동 import 시도
      const pagePath = url.replace(/^\//, "");
      try {
        const mod = await import(
          /* webpackMode: "lazy" */
          /* webpackInclude: /\/page\.tsx$/ */
          `@/app/(main)/${pagePath}/page`
        );
        if (!cancelled) setComponent(() => mod.default);
      } catch {
        console.warn("[DynamicAdminLoader] 자동 import 실패:", url);
        if (!cancelled) setFailed(true);
      }
    };

    tryLoad();
    return () => { cancelled = true; };
  }, [url]);

  if (failed) return <AdminPageFallback url={url} />;
  if (!Component) return <LoadingFallback />;
  if (params) return <Component params={Promise.resolve(params)} adminParams={params} />;
  return <Component />;
}

function AdminPageFallback({ url }: { url: string }) {
  return (
    <div className="flex h-full items-center justify-center">
      <div className="text-center">
        <p className="text-lg font-semibold text-foreground">페이지 로딩 불가</p>
        <p className="mt-1 text-sm text-muted-foreground">경로: {url}</p>
        <p className="mt-2 text-xs text-muted-foreground">해당 페이지가 존재하지 않습니다.</p>
      </div>
    </div>
  );
}

interface AdminPageRendererProps {
  url: string;
}

// 회사별 커스텀 페이지 경로 prefix 목록
// 이 prefix로 시작하는 URL은 회사코드 폴더에서 로드
const COMPANY_PAGE_PREFIXES = [
  "/sales/",
  "/master-data/",
  "/production/",
  "/equipment/",
  "/logistics/",
  "/outsourcing/",
  "/design/",
  "/purchase/",
  "/quality/",
  "/mold/",
  "/monitoring/",
  "/kpi/",
];

function isCompanyPage(url: string): boolean {
  return COMPANY_PAGE_PREFIXES.some((prefix) => url.startsWith(prefix));
}

export function AdminPageRenderer({ url }: AdminPageRendererProps) {
  const { user } = useAuth();
  const companyCode = user?.companyCode || user?.company_code;
  const cleanUrl = url.split("?")[0].split("#")[0].replace(/\/$/, "");

  // 회사별 커스텀 페이지: companyCode를 prefix로 붙여 경로 변환
  // 예: /sales/order → /COMPANY_7/sales/order
  const resolvedUrl = (companyCode && isCompanyPage(cleanUrl))
    ? `/${companyCode}${cleanUrl}`
    : cleanUrl;

  console.log("[AdminPageRenderer] 렌더링:", { url, cleanUrl, resolvedUrl, companyCode });

  // 화면 할당: /screens/[id]
  const screensIdMatch = cleanUrl.match(/^\/screens\/(\d+)$/);
  if (screensIdMatch) {
    console.log("[AdminPageRenderer] → /screens/[id] 매칭:", screensIdMatch[1]);
    return <ScreenViewPageWrapper screenIdProp={parseInt(screensIdMatch[1])} />;
  }

  // 화면 할당: /screen/[code] (구 형식)
  const screenCodeMatch = cleanUrl.match(/^\/screen\/([^/]+)$/);
  if (screenCodeMatch) {
    console.log("[AdminPageRenderer] → /screen/[code] 매칭:", screenCodeMatch[1]);
    return <ScreenCodeResolver screenCode={screenCodeMatch[1]} />;
  }

  // 대시보드 할당: /dashboard/[id]
  const dashboardMatch = cleanUrl.match(/^\/dashboard\/([^/]+)$/);
  if (dashboardMatch) {
    console.log("[AdminPageRenderer] → /dashboard/[id] 매칭:", dashboardMatch[1]);
    return <DashboardViewPage params={Promise.resolve({ dashboardId: dashboardMatch[1] })} />;
  }

  // URL 직접 입력: 레지스트리 매칭 (resolvedUrl 우선, cleanUrl 폴백)
  const PageComponent = useMemo(() => {
    return ADMIN_PAGE_REGISTRY[resolvedUrl] || ADMIN_PAGE_REGISTRY[cleanUrl] || null;
  }, [resolvedUrl, cleanUrl]);

  if (PageComponent) {
    console.log("[AdminPageRenderer] → 레지스트리 매칭:", resolvedUrl || cleanUrl);
    return <PageComponent />;
  }

  // 레지스트리에 없으면 동적 import 시도
  // 동적 라우트 패턴 매칭 (params 추출)
  for (const { pattern, extractParams } of DYNAMIC_ADMIN_PATTERNS) {
    const match = cleanUrl.match(pattern);
    if (match) {
      const params = extractParams(match);
      console.log("[AdminPageRenderer] → 동적 라우트 매칭:", cleanUrl, params);
      return <DynamicAdminLoader url={cleanUrl} params={params} />;
    }
  }

  // 레지스트리/패턴에 없으면 DynamicAdminLoader가 자동 import 시도
  // 회사별 페이지는 resolvedUrl로 import (예: COMPANY_7/sales/order/page)
  console.log("[AdminPageRenderer] → 자동 import 시도:", resolvedUrl);
  return <DynamicAdminLoader url={resolvedUrl} />;
}
