import { c as d } from "../../chunks/runtime.js";
import { css as g, html as i } from "lit";
import { LitElement as o, safeClassMap as t } from "@arcgis/lumina";
import { classes as m } from "@arcgis/toolkit/dom";
import { H as h } from "../../chunks/heading.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
v4.34.7 */
const _ = g`.esri-widget__heading{color:var(--calcite-color-text-2);margin:0 0 .5rem;font-weight:var(--calcite-font-weight-semibold)}h1.esri-widget__heading{font-size:var(--calcite-font-size-xl)}h2.esri-widget__heading{font-size:var(--calcite-font-size-md)}h3.esri-widget__heading,h4.esri-widget__heading,h5.esri-widget__heading,h6.esri-widget__heading{font-size:var(--calcite-font-size)}:host{display:block}.arcgis-legend__no-legend{padding:var(--calcite-spacing-sm) var(--calcite-spacing-md)}.arcgis-legend__layer{border-bottom:1px solid var(--calcite-color-border-2);padding:var(--calcite-spacing-sm);word-wrap:break-word}.arcgis-legend__layer:last-child{border-bottom:none}.arcgis-legend__layer--elements{margin-left:var(--calcite-spacing-sm);overflow:auto}.arcgis-legend__layer-child{margin-left:var(--calcite-spacing-sm);padding-right:0;padding-left:0}:dir(rtl) .arcgis-legend__layer--elements,:dir(rtl) .arcgis-legend__layer-child{margin-right:var(--calcite-spacing-sm);margin-left:0;overflow:auto}`, l = {
  layer: "arcgis-legend__layer",
  layerElements: "arcgis-legend__layer--elements",
  layerChild: "arcgis-legend__layer-child",
  noLegend: "arcgis-legend__no-legend"
};
class y extends o {
  constructor() {
    super(...arguments), this.headingLevel = 3, this.type = "classic";
  }
  static {
    this.properties = { activeLayerInfos: 0, headingLevel: 9, type: 32, messages: 0 };
  }
  static {
    this.styles = _;
  }
  render() {
    const s = this.activeLayerInfos?.toArray().map((r) => this._renderLegendForLayer(r)).filter(Boolean);
    return s?.length ? i`<section>${s}</section>` : i`<div class=${t(l.noLegend)}>${this.messages.noLegend}</div>`;
  }
  _renderLegendForLayer(e) {
    if (!e.ready)
      return null;
    const s = e.title ? h({
      level: this.headingLevel,
      children: e.title
    }) : null;
    if (e.children.length) {
      const r = e.children.toArray().map((a) => this._renderLegendForLayer(a));
      return i`<section class=${t(l.layer)}>${s}${r}</section>`;
    }
    return this._renderLegendElementsForLayer(e, s);
  }
  _renderLegendElementsForLayer(e, s) {
    const r = e.legendElements?.filter(Boolean);
    if (!r?.length)
      return null;
    const a = r.map((c) => i`<arcgis-legend-classic-element .cssEffectFilter=${e.cssEffectFilter ?? void 0} .layer=${e.layer} .legendElement=${c} .messages=${this.messages}></arcgis-legend-classic-element>`), n = { [l.layerChild]: !!e.parent };
    return i`<section class=${t(m(l.layer, n))}>${s}<div class=${t(l.layerElements)}>${a}</div></section>`;
  }
}
d("arcgis-legend-classic-view", y);
export {
  y as LegendClassicView
};
