import type { JSONSupport, JSONSupportMixinProperties } from "../../core/JSONSupport.js";

export interface LabelExpressionInfoProperties extends JSONSupportMixinProperties, Partial<Pick<LabelExpressionInfo, "expression" | "title">> {}

export default abstract class LabelExpressionInfo extends JSONSupport {
  /**
   * An [Arcade](https://developers.arcgis.com/javascript/latest/arcade/) expression following the specification
   * defined by the [Arcade Labeling Profile](https://developers.arcgis.com/javascript/latest/arcade/#labeling). Expressions
   * in labels may reference field values using the `$feature` profile variable and must return a string.
   *
   * For example, to label a layer
   * of cities with their names, simply reference the field value with the global
   * variable: `$feature.CITY_NAME`. Expressions can be more sophisticated and use
   * logical functions. This may be useful if you want to use classed labels.
   * For example, the following expression appends `city` to the end of the label
   * if the feature's population field contains a number greater than 10,000. Otherwise,
   * `town` is appended to the end of the label. Additionally, you can use `TextFormatting.NewLine`
   * to add a new line to the label.
   *
   * `IIF($feature.POPULATION > 10000, $feature.NAME + ' city', $feature.NAME + ' town')`
   */
  accessor expression: string | null | undefined;
  /** The title of the label expression. This is particularly useful in the case of multiple label classes. */
  accessor title: string | null | undefined;
}