import {
  importBrandProgram as importBrandProgramMvp,
  parseAbbRapid,
  parseFanucLs,
  parseKukaKrl,
  type BrandImportOptions,
  type BrandImportResult,
  type BrandProgramFile,
  type ImportBrand
} from "./brandImport.js";
import {
  importBrandProgram as importLegacyBrandProgram,
  type BrandImportResult as LegacyBrandImportResult
} from "./brandImporter.js";
import type { OlpProjectModel } from "../olp/index.js";

export function importBrandProgram(
  brand: ImportBrand,
  files: BrandProgramFile[],
  options?: BrandImportOptions
): BrandImportResult;
export function importBrandProgram(
  brand: ImportBrand,
  text: string,
  baseModel: OlpProjectModel,
  options?: { operationId?: string; pathId?: string; robotId?: string }
): LegacyBrandImportResult;
export function importBrandProgram(
  brand: ImportBrand,
  filesOrText: BrandProgramFile[] | string,
  optionsOrBaseModel?: BrandImportOptions | OlpProjectModel,
  legacyOptions?: { operationId?: string; pathId?: string; robotId?: string }
): BrandImportResult | LegacyBrandImportResult {
  if (typeof filesOrText === "string") {
    return importLegacyBrandProgram(
      brand,
      filesOrText,
      optionsOrBaseModel as OlpProjectModel,
      legacyOptions
    );
  }
  return importBrandProgramMvp(brand, filesOrText, optionsOrBaseModel as BrandImportOptions | undefined);
}

export {
  importLegacyBrandProgram,
  parseAbbRapid,
  parseFanucLs,
  parseKukaKrl,
  type BrandImportOptions,
  type BrandImportResult,
  type BrandProgramFile,
  type ImportBrand,
  type LegacyBrandImportResult
};
