import { type IndustrialParkStatus, type VietnamRegion } from '@prisma/client';
import { AggregateRoot } from '@modules/shared';

export interface IndustrialParkProps {
  name: string;
  nameEn: string | null;
  slug: string;
  developer: string;
  operator: string | null;
  status: IndustrialParkStatus;
  latitude: number;
  longitude: number;
  address: string;
  district: string;
  province: string;
  region: VietnamRegion;
  totalAreaHa: number;
  leasableAreaHa: number;
  occupancyRate: number;
  remainingAreaHa: number;
  tenantCount: number;
  establishedYear: number | null;
  landRentUsdM2Year: number | null;
  rbfRentUsdM2Month: number | null;
  rbwRentUsdM2Month: number | null;
  managementFeeUsd: number | null;
  infrastructure: Record<string, unknown> | null;
  connectivity: Record<string, unknown> | null;
  incentives: Record<string, unknown> | null;
  targetIndustries: string[];
  existingTenants: Record<string, unknown>[] | null;
  certifications: string[] | null;
  media: Record<string, unknown>[] | null;
  documents: Record<string, unknown>[] | null;
  description: string | null;
  descriptionEn: string | null;
  isVerified: boolean;
  ownerId: string | null;
}

export class IndustrialParkEntity extends AggregateRoot<string> {
  private _name: string;
  private _nameEn: string | null;
  private _slug: string;
  private _developer: string;
  private _operator: string | null;
  private _status: IndustrialParkStatus;
  private _latitude: number;
  private _longitude: number;
  private _address: string;
  private _district: string;
  private _province: string;
  private _region: VietnamRegion;
  private _totalAreaHa: number;
  private _leasableAreaHa: number;
  private _occupancyRate: number;
  private _remainingAreaHa: number;
  private _tenantCount: number;
  private _establishedYear: number | null;
  private _landRentUsdM2Year: number | null;
  private _rbfRentUsdM2Month: number | null;
  private _rbwRentUsdM2Month: number | null;
  private _managementFeeUsd: number | null;
  private _infrastructure: Record<string, unknown> | null;
  private _connectivity: Record<string, unknown> | null;
  private _incentives: Record<string, unknown> | null;
  private _targetIndustries: string[];
  private _existingTenants: Record<string, unknown>[] | null;
  private _certifications: string[] | null;
  private _media: Record<string, unknown>[] | null;
  private _documents: Record<string, unknown>[] | null;
  private _description: string | null;
  private _descriptionEn: string | null;
  private _isVerified: boolean;
  private _ownerId: string | null;

  constructor(id: string, props: IndustrialParkProps, createdAt: Date, updatedAt: Date) {
    super(id, createdAt, updatedAt);
    this._name = props.name;
    this._nameEn = props.nameEn;
    this._slug = props.slug;
    this._developer = props.developer;
    this._operator = props.operator;
    this._status = props.status;
    this._latitude = props.latitude;
    this._longitude = props.longitude;
    this._address = props.address;
    this._district = props.district;
    this._province = props.province;
    this._region = props.region;
    this._totalAreaHa = props.totalAreaHa;
    this._leasableAreaHa = props.leasableAreaHa;
    this._occupancyRate = props.occupancyRate;
    this._remainingAreaHa = props.remainingAreaHa;
    this._tenantCount = props.tenantCount;
    this._establishedYear = props.establishedYear;
    this._landRentUsdM2Year = props.landRentUsdM2Year;
    this._rbfRentUsdM2Month = props.rbfRentUsdM2Month;
    this._rbwRentUsdM2Month = props.rbwRentUsdM2Month;
    this._managementFeeUsd = props.managementFeeUsd;
    this._infrastructure = props.infrastructure;
    this._connectivity = props.connectivity;
    this._incentives = props.incentives;
    this._targetIndustries = props.targetIndustries;
    this._existingTenants = props.existingTenants;
    this._certifications = props.certifications;
    this._media = props.media;
    this._documents = props.documents;
    this._description = props.description;
    this._descriptionEn = props.descriptionEn;
    this._isVerified = props.isVerified;
    this._ownerId = props.ownerId;
  }

  get name() { return this._name; }
  get nameEn() { return this._nameEn; }
  get slug() { return this._slug; }
  get developer() { return this._developer; }
  get operator() { return this._operator; }
  get status() { return this._status; }
  get latitude() { return this._latitude; }
  get longitude() { return this._longitude; }
  get address() { return this._address; }
  get district() { return this._district; }
  get province() { return this._province; }
  get region() { return this._region; }
  get totalAreaHa() { return this._totalAreaHa; }
  get leasableAreaHa() { return this._leasableAreaHa; }
  get occupancyRate() { return this._occupancyRate; }
  get remainingAreaHa() { return this._remainingAreaHa; }
  get tenantCount() { return this._tenantCount; }
  get establishedYear() { return this._establishedYear; }
  get landRentUsdM2Year() { return this._landRentUsdM2Year; }
  get rbfRentUsdM2Month() { return this._rbfRentUsdM2Month; }
  get rbwRentUsdM2Month() { return this._rbwRentUsdM2Month; }
  get managementFeeUsd() { return this._managementFeeUsd; }
  get infrastructure() { return this._infrastructure; }
  get connectivity() { return this._connectivity; }
  get incentives() { return this._incentives; }
  get targetIndustries() { return this._targetIndustries; }
  get existingTenants() { return this._existingTenants; }
  get certifications() { return this._certifications; }
  get media() { return this._media; }
  get documents() { return this._documents; }
  get description() { return this._description; }
  get descriptionEn() { return this._descriptionEn; }
  get isVerified() { return this._isVerified; }
  get ownerId() { return this._ownerId; }

  updateDetails(props: Partial<IndustrialParkProps>): void {
    if (props.name !== undefined) this._name = props.name;
    if (props.nameEn !== undefined) this._nameEn = props.nameEn;
    if (props.developer !== undefined) this._developer = props.developer;
    if (props.operator !== undefined) this._operator = props.operator;
    if (props.status !== undefined) this._status = props.status;
    if (props.occupancyRate !== undefined) this._occupancyRate = props.occupancyRate;
    if (props.remainingAreaHa !== undefined) this._remainingAreaHa = props.remainingAreaHa;
    if (props.tenantCount !== undefined) this._tenantCount = props.tenantCount;
    if (props.landRentUsdM2Year !== undefined) this._landRentUsdM2Year = props.landRentUsdM2Year;
    if (props.rbfRentUsdM2Month !== undefined) this._rbfRentUsdM2Month = props.rbfRentUsdM2Month;
    if (props.rbwRentUsdM2Month !== undefined) this._rbwRentUsdM2Month = props.rbwRentUsdM2Month;
    if (props.managementFeeUsd !== undefined) this._managementFeeUsd = props.managementFeeUsd;
    if (props.infrastructure !== undefined) this._infrastructure = props.infrastructure;
    if (props.connectivity !== undefined) this._connectivity = props.connectivity;
    if (props.incentives !== undefined) this._incentives = props.incentives;
    if (props.targetIndustries !== undefined) this._targetIndustries = props.targetIndustries;
    if (props.existingTenants !== undefined) this._existingTenants = props.existingTenants;
    if (props.certifications !== undefined) this._certifications = props.certifications;
    if (props.media !== undefined) this._media = props.media;
    if (props.documents !== undefined) this._documents = props.documents;
    if (props.description !== undefined) this._description = props.description;
    if (props.descriptionEn !== undefined) this._descriptionEn = props.descriptionEn;
    if (props.isVerified !== undefined) this._isVerified = props.isVerified;
    if (props.ownerId !== undefined) this._ownerId = props.ownerId;
    this.updatedAt = new Date();
  }
}
