/**
 * A shape of a {@link foundry.documents.RegionDocument}.
 * @template {BaseShapeData} [ShapeData=BaseShapeData]
 * @deprecated since v14
 * @ignore
 */
export class RegionShape {

  /**
   * Create a RegionShape.
   * @param {ShapeData} data    The shape data.
   * @internal
   */
  constructor(data) {
    this.#data = data;
  }

  /* -------------------------------------------- */

  /**
   * Create the RegionShape from the shape data.
   * @param {CircleShapeData|EllipseShapeData|PolygonShapeData|RectangleShapeData} data    The shape data.
   * @returns {RegionShape}
   */
  static create(data) {
    foundry.utils.logCompatibilityWarning("RegionShape is deprecated. Use BaseShapeData subclasses instead.",
      {since: 14, until: 16, once: true});
    return this._create(data);
  }

  /** @ignore */
  static _create(data) {
    if ( !(data.type in foundry.data.BaseShapeData.TYPES) ) throw new Error("Invalid shape type");
    switch ( data.type ) {
      case "circle": return new RegionCircleShape(data);
      case "ellipse": return new RegionEllipseShape(data);
      case "polygon": return new RegionPolygonShape(data);
      case "rectangle": return new RegionRectangleShape(data);
      default: return new RegionShape(data);
    }
  }

  /* -------------------------------------------- */

  /**
   * The data of this shape.
   * It is owned by the shape and must not be modified.
   * @type {ShapeData}
   */
  get data() {
    return this.#data;
  }

  #data;

  /* -------------------------------------------- */

  /**
   * Is this a hole?
   * @type {boolean}
   */
  get isHole() {
    return this.data.hole;
  }

  /* -------------------------------------------- */

  /**
   * The Clipper paths of this shape.
   * The winding numbers are 1 or 0.
   * @type {ReadonlyArray<ReadonlyArray<ClipperLib.IntPoint>>}
   */
  get clipperPaths() {
    return this.data.clipperPaths;
  }

  /* -------------------------------------------- */

  /**
   * The Clipper polygon tree of this shape.
   * @type {ClipperLib.PolyTree}
   */
  get clipperPolyTree() {
    return this.data.clipperPolyTree;
  }
}

/* -------------------------------------------- */

/**
 * A circle of a {@link foundry.documents.RegionDocument}.
 * @extends {RegionShape<CircleShapeData>}
 * @deprecated since v14
 * @ignore
 */
export class RegionCircleShape extends RegionShape {}

/* -------------------------------------------- */

/**
 * An ellipse of a {@link foundry.documents.RegionDocument}.
 * @extends {RegionShape<EllipseShapeData>}
 * @deprecated since v14
 * @ignore
 */
export class RegionEllipseShape extends RegionShape {}

/* -------------------------------------------- */

/**
 * A polygon of a {@link foundry.documents.RegionDocument}.
 * @extends {RegionShape<PolygonShapeData>}
 * @deprecated since v14
 * @ignore
 */
export class RegionPolygonShape extends RegionShape {}

/* -------------------------------------------- */

/**
 * A rectangle of a {@link foundry.documents.RegionDocument}.
 * @extends {RegionShape<RectangleShapeData>}
 * @deprecated since v14
 * @ignore
 */
export class RegionRectangleShape extends RegionShape {}
