/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import { s as m, a as S, b as d, c, d as y, W as g } from "./negative-values-stacked-to-baseline.js";
import { S as u, s as p, a as b } from "./serial-chart-model.js";
import { g as n } from "./serial-chart-data.js";
import { a as I } from "./utils.js";
import { m as v } from "./model-setter.js";
import { W as _ } from "./series-types.js";
import { bm as C, ba as f, bR as a, aJ as L, ar as M } from "./index.js";
import { M as k } from "./model-with-line-marker-styling.js";
var D = Object.defineProperty, F = Object.getOwnPropertyDescriptor, x = (o, e, s, t) => {
  for (var i = F(e, s), r = o.length - 1, l; r >= 0; r--)
    (l = o[r]) && (i = l(e, s, i) || i);
  return i && D(e, s, i), i;
};
class h extends u {
  constructor() {
    super(...arguments), this._chartType = _.LineSeries;
  }
  async setup(e) {
    await this.loadConfigFromLayer(e), this.setupLocalProps(), e.config !== void 0 && await this.updateSeriesFromLayerFilter(), this.initDefaultSeries(), typeof this.resolveSetup == "function" && this.resolveSetup();
  }
  // #end region
  // ---------------------------------------------------------------------------------------------
  // #region Protected methods
  // ---------------------------------------------------------------------------------------------
  /** @private */
  generateDefaultConfig() {
    const e = C(this.commonStrings);
    return e.series = [
      f({
        commonStrings: this.commonStrings,
        objectIDField: a(this.layerInfo.layer).idField
      })
    ], e;
  }
  /**
   * Initializes the default series for the line chart. Used in resetting the series styling.
   * @private
   */
  initDefaultSeries() {
    this.defaultSeries = f({
      commonStrings: this.commonStrings,
      objectIDField: a(this.layerInfo.layer).idField
    });
  }
  resetSeriesStyling() {
    for (let e = 0; e < this.seriesLength; e += 1) {
      const s = L({
        colorIndex: e,
        opacity: M
      });
      if (p(s, e, this._config), m(s, e, this._config), this.layerInfo !== void 0) {
        const t = this.getSeriesId(e), i = n({
          config: this._config,
          seriesIndex: e,
          layerInfo: this.layerInfo,
          commonStrings: this.commonStrings
        });
        i !== a(this.layerInfo.layer).idField && b(i ?? t, e, this._config);
      }
      S(this.defaultSeries?.lineSymbol?.style, e, this._config), d(this.defaultSeries?.lineSymbol?.width, e, this._config), c(this.defaultSeries?.markerSymbol?.style, e, this._config), y(this.defaultSeries?.markerSymbol?.size, e, this._config);
    }
    this._config.colorMatch = !0;
  }
  /**
   * Returns whether the series styling is able to be reset.
   */
  resetAvailable() {
    const e = !this.colorMatch;
    let s = !1;
    if (!e)
      for (let t = 0; t < this.seriesLength; t += 1) {
        if (this.layerInfo !== void 0) {
          const i = n({
            config: this._config,
            seriesIndex: t,
            layerInfo: this.layerInfo,
            commonStrings: this.commonStrings
          }), r = this.getSeriesName(t);
          i !== void 0 && i !== this.layerInfo.objectIdField && i !== r && (s = !0);
        }
        if (this.defaultSeries?.lineSymbol?.style !== void 0 && this.defaultSeries?.lineSymbol.style !== this.getSeriesLineStyle(t) || this.defaultSeries?.lineSymbol?.width !== void 0 && this.defaultSeries?.lineSymbol.width !== this.getSeriesLineWidth(t) || this.defaultSeries?.markerSymbol?.style !== void 0 && this.defaultSeries?.markerSymbol?.style !== this.getSeriesMarkerStyle(t) || this.defaultSeries?.markerSymbol?.size !== void 0 && this.defaultSeries?.markerSymbol?.size !== this.getSeriesMarkerSize(t)) {
          s = !0;
          break;
        }
      }
    return e || s;
  }
}
x([
  v
], h.prototype, "resetSeriesStyling");
const w = [g, k];
I(h, w);
export {
  h as LineChartModel
};
