import {
  BaseEntity,
  AITextEntity,
  RoleEntity,
  SceneEntity,
  VideoSegmentEntity
} from './Entities';
import { TagValueObject } from './valueObject';

/**
 * 可编辑项类型枚举
 */
export enum ItemType {
  /** 文本 */
  TEXT,
  /** 图片 */
  IMAGE,
  /** 视频 */
  VIDEO,
}

/**
 * 可编辑项抽象基类
 */
export abstract class EditItem<T extends BaseEntity> {
  /** 被包装的实体 */
  entity!: T;
  /** 编辑元数据 */
  metadata: Record<string, any>;
  /** 类型 */
  abstract type: ItemType;
  constructor(
    entity: T,
    metadata: Record<string, any> = {}
  ) {
    this.metadata = metadata;

    this.setEntity(entity);
  }

  /**
   * 设置元数据
   */
  setMetadata(metadata: Record<string, any>): void {
    this.metadata = metadata;
  }
  /**
   * 更新实体
   */
  setEntity(entity: T): void {
    this.entity = entity;
  }
}


/**
 * AI文本可编辑项
 */
export class TextItem extends EditItem<AITextEntity> {
  type: ItemType.TEXT = ItemType.TEXT;

  constructor(
    entity: AITextEntity,
    metadata: Record<string, any> = {}
  ) {
    super(entity, metadata);
  }
}

/**
 * 场景可编辑项
 */
export class SceneItem extends EditItem<SceneEntity> {
  type: ItemType.IMAGE = ItemType.IMAGE;

  constructor(
    entity: SceneEntity,
    metadata: Record<string, any> = {}
  ) {
    super(entity, metadata);
  }
}

/**
 * 标签可编辑项
 */
export class TagItem extends EditItem<TagValueObject> {
  type: ItemType.TEXT = ItemType.TEXT;

  constructor(
    entity: TagValueObject,
    metadata: Record<string, any> = {}
  ) {
    super(entity, metadata);
  }
}
