import { BaseEntity } from '@modules/shared';

export interface PropertyMediaProps {
  propertyId: string;
  url: string;
  type: 'image' | 'video';
  order: number;
  caption: string | null;
  aiTags: unknown;
}

export class PropertyMediaEntity extends BaseEntity<string> {
  private _propertyId: string;
  private _url: string;
  private _type: 'image' | 'video';
  private _order: number;
  private _caption: string | null;
  private _aiTags: unknown;

  constructor(id: string, props: PropertyMediaProps, createdAt?: Date) {
    super(id, createdAt);
    this._propertyId = props.propertyId;
    this._url = props.url;
    this._type = props.type;
    this._order = props.order;
    this._caption = props.caption;
    this._aiTags = props.aiTags;
  }

  get propertyId(): string { return this._propertyId; }
  get url(): string { return this._url; }
  get type(): 'image' | 'video' { return this._type; }
  get order(): number { return this._order; }
  get caption(): string | null { return this._caption; }
  get aiTags(): unknown { return this._aiTags; }

  static createNew(
    id: string,
    propertyId: string,
    url: string,
    type: 'image' | 'video',
    order: number,
    caption?: string,
  ): PropertyMediaEntity {
    return new PropertyMediaEntity(id, {
      propertyId,
      url,
      type,
      order,
      caption: caption ?? null,
      aiTags: null,
    });
  }
}
