/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import { g as p, s as b, a as _, b as L } from "./bar-chart-series.js";
import { m as a } from "./model-setter.js";
import { g as u, a as k, e as C, b as v, f as M, s as z, h as O, c as B, i as V, d as D, j as F, k as A, n as H, o as d, p as j, q as W, r as w, W as P } from "./negative-values-stacked-to-baseline.js";
import { S as T, s as N } from "./serial-chart-model.js";
import { a as q } from "./utils.js";
import { W as S } from "./series-types.js";
import { o as R, j as l, l as g } from "./index4.js";
import { bk as E, bd as y, bR as f, ba as m } from "./index.js";
var G = Object.defineProperty, J = Object.getOwnPropertyDescriptor, n = (c, e, i, s) => {
  for (var t = J(e, i), r = c.length - 1, h; r >= 0; r--)
    (h = c[r]) && (t = h(e, i, t) || t);
  return t && G(e, i, t), t;
};
class o extends T {
  constructor() {
    super(...arguments), this._chartType = S.ComboLineAndBarSeries;
  }
  async setup(e) {
    await this.loadConfigFromLayer(e), this.setupLocalProps(), e.config !== void 0 && (R(e.config?.series) && this.initDefaultSeries(), await this.updateSeriesFromLayerFilter()), typeof this.resolveSetup == "function" && this.resolveSetup();
  }
  // ---------------------------------------------------------------------------------------------
  // Protected Methods
  // ---------------------------------------------------------------------------------------------
  /** @private */
  generateDefaultConfig() {
    const e = E(this.commonStrings);
    return e.series = [
      y({
        commonStrings: this.commonStrings,
        objectIDField: f(this.layerInfo.layer).idField
      })
    ], e;
  }
  /**
   * Initializes the default series for the combo bar-line chart. Used in resetting the series styling.
   *
   * @private
   */
  initDefaultSeries() {
    this.defaultSeries = m({
      commonStrings: this.commonStrings,
      objectIDField: f(this.layerInfo.layer).idField
    });
  }
  setSeriesType(e, i) {
    if (e < this._config.series.length && e >= 0) {
      const s = this._config.series[e];
      let t;
      if (i === S.BarSeries && l(s)) {
        const r = { ...s };
        delete r.lineSymbol, delete r.markerSymbol, delete r.lineSmoothed, delete r.markerVisible, delete r.areaColor, delete r.stackNegativeValuesToBaseline, t = {
          ...y({
            commonStrings: this.commonStrings,
            objectIDField: f(this.layerInfo.layer).idField
          }),
          ...r,
          type: S.BarSeries,
          y: [s.y].flat()[0]
        }, t.fillSymbol && (t.fillSymbol = {
          ...t.fillSymbol,
          color: s.lineSymbol?.color
        });
      } else if (i === S.LineSeries && g(s)) {
        const r = { ...s };
        delete r.fillSymbol, delete r.hideOversizedStackedLabels, delete r.hideOversizedSideBySideLabels, t = {
          ...m({
            commonStrings: this.commonStrings,
            objectIDField: f(this.layerInfo.layer).idField
          }),
          ...r,
          type: S.LineSeries
        }, t.lineSymbol && (t.lineSymbol = {
          ...t.lineSymbol,
          color: s.fillSymbol?.color
        });
      }
      t !== void 0 && (this._config.series[e] = t);
    }
  }
  /**
   * Gets the line style of the series based on the series index.
   * If the index is out of bounds, it will return `undefined`.
   *
   * @param seriesIndex The index of the series.
   */
  getSeriesLineStyle(e) {
    return u(e, this._config);
  }
  setSeriesLineStyle(e, i) {
    const s = this._config.series?.[i];
    l(s) && k(e, i, this._config);
  }
  /**
   * Gets the line width of the series based on the series index.
   * If the index is out of bounds, it will return `undefined`.
   *
   * @param seriesIndex - The index of the series.
   */
  getSeriesLineWidth(e) {
    return C(e, this._config);
  }
  setSeriesLineWidth(e, i) {
    const s = this._config.series?.[i];
    l(s) && v(e, i, this._config);
  }
  /**
   * Gets the marker color of the series based on the series index.
   * If the index is out of bounds, it will return `undefined`.
   *
   * @param seriesIndex - The index of the series.
   */
  getSeriesMarkerColor(e) {
    return M(e, this._config);
  }
  setSeriesMarkerColor(e, i) {
    const s = this._config.series?.[i];
    l(s) && z(e, i, this._config);
  }
  /**
   * Gets the marker style of the series based on the series index.
   * If the index is out of bounds, it will return `undefined`.
   *
   * @param seriesIndex - The index of the series.
   */
  getSeriesMarkerStyle(e) {
    return O(e, this._config);
  }
  setSeriesMarkerStyle(e, i) {
    const s = this._config.series?.[i];
    l(s) && B(e, i, this._config);
  }
  /**
   * Gets the marker size of the series based on the series index.
   * If the index is out of bounds, it will return `undefined`.
   * @param seriesIndex - The index of the series.
   */
  getSeriesMarkerSize(e) {
    return V(e, this._config);
  }
  setSeriesMarkerSize(e, i) {
    const s = this._config.series?.[i];
    l(s) && D(e, i, this._config);
  }
  /**
   * Specify whether line segments of the series should be smoothed.
   *
   * @param seriesIndex - The index of the series.
   */
  isLineSmoothed(e) {
    return F(e, this._config);
  }
  setLineSmoothed(e, i) {
    const s = this._config.series?.[i];
    l(s) && A({
      smoothed: e,
      seriesIndex: i,
      config: this._config
    });
  }
  /**
   * Indicate whether the area is visible for the line series.
   *
   * @param seriesIndex - The index of the series.
   */
  isAreaVisible(e) {
    return H(e, this._config);
  }
  setAreaVisible(e, i) {
    const s = this._config.series?.[i];
    l(s) && d({
      visible: e,
      seriesIndex: i,
      config: this._config
    });
  }
  /**
   * Indicate whether to show or hide the markers/bullets of the line series.
   *
   * @param seriesIndex - The index of the series.
   */
  isMarkerVisible(e) {
    return j(e, this._config);
  }
  setMarkerVisible(e, i) {
    const s = this._config.series?.[i];
    l(s) && W({
      visible: e,
      seriesIndex: i,
      config: this._config
    });
  }
  /**
   * Gets the color of the filled area for line chart.
   * **Note:** `areaColor` will be applied only if `showArea` is true, and is defaulted to the line color if not provided.
   *
   * @param seriesIndex - The index of the series.
   */
  getAreaColor(e) {
    return w(e, this._config);
  }
  setAreaColor(e, i) {
    const s = this._config.series?.[i];
    l(s) && (d({
      visible: !0,
      seriesIndex: i,
      config: this._config
    }), N(e, i, this._config));
  }
  /**
   * Gets whether to hide oversized data labels of the side-by-side series based on the series index. '
   *
   * If the index is out of bounds, it will return `undefined`.
   *
   * @param seriesIndex - The index of the series.
   */
  getSeriesHideOversizedSideBySideLabels(e) {
    return p(e, this._config);
  }
  setSeriesHideOversizedSideBySideLabels(e, i) {
    const s = this._config.series?.[i];
    g(s) && b(e, i, this._config);
  }
  /**
   * Gets whether to hide oversized data labels of the stacked series based on the series index.
   * If the index is out of bounds, it will return `undefined`.
   *
   * @param seriesIndex - The index of the series.
   */
  getSeriesHideOversizedStackedLabels(e) {
    return _(e, this._config);
  }
  setSeriesHideOversizedStackedLabels(e, i) {
    const s = this._config.series?.[i];
    g(s) && L(e, i, this._config);
  }
}
n([
  a
], o.prototype, "setSeriesType");
n([
  a
], o.prototype, "setSeriesLineStyle");
n([
  a
], o.prototype, "setSeriesLineWidth");
n([
  a
], o.prototype, "setSeriesMarkerColor");
n([
  a
], o.prototype, "setSeriesMarkerStyle");
n([
  a
], o.prototype, "setSeriesMarkerSize");
n([
  a
], o.prototype, "setLineSmoothed");
n([
  a
], o.prototype, "setAreaVisible");
n([
  a
], o.prototype, "setMarkerVisible");
n([
  a
], o.prototype, "setAreaColor");
n([
  a
], o.prototype, "setSeriesHideOversizedSideBySideLabels");
n([
  a
], o.prototype, "setSeriesHideOversizedStackedLabels");
const K = [P];
q(o, K);
export {
  o as ComboBarLineChartModel
};
