import type {
  AddressInput,
  MothershipAddressCandidate,
} from "@/lib/frontend/types";

/** 将用户确认的 MotherShip 候选项合并进询价地址 */
export function applyMothershipCandidate(
  base: AddressInput,
  candidate: MothershipAddressCandidate,
): AddressInput {
  return {
    ...base,
    street: candidate.street,
    city: candidate.city,
    state: candidate.state,
    zip: candidate.zip || base.zip,
    formatted_address: candidate.formatted_address,
    mothership_option_id: candidate.option_id,
    mothership_display_label: candidate.display_label,
    selected_from_mothership: true,
  };
}
