import { c as v } from "../../chunks/runtime.js";
import { css as $, html as a } from "lit";
import { LitElement as w, safeClassMap as t, nothing as g, safeStyleMap as f } from "@arcgis/lumina";
import { classes as d } from "@arcgis/toolkit/dom";
import { b as u, s as p, i as E, a as m, g as h } from "../../chunks/utils2.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 L = $`.arcgis-legend__layer-table{display:flex;flex-flow:column;margin-bottom:var(--calcite-spacing-md);width:100%}.arcgis-legend__layer-table--size-ramp{display:table}.arcgis-legend__layer-table--size-ramp .arcgis-legend__layer-cell{display:table-cell}.arcgis-legend__layer-caption{display:table-caption;padding:var(--calcite-spacing-sm) 0;word-break:break-word}.arcgis-legend__layer-body{margin-left:var(--calcite-spacing-sm)}:dir(rtl) .arcgis-legend__layer-body{margin-right:var(--calcite-spacing-sm);margin-left:0;overflow:auto}.arcgis-legend__layer-row{display:flex}.arcgis-legend__layer-table--size-ramp .arcgis-legend__layer-row{display:table-row}.arcgis-legend__layer-cell{padding:var(--calcite-spacing-xxs) 0;min-width:100px;vertical-align:middle;word-break:break-word;display:flex;align-items:center}.arcgis-legend__layer-cell--info{padding-right:var(--calcite-spacing-sm);padding-left:var(--calcite-spacing-sm);max-width:250px;word-break:normal;word-wrap:normal;font-size:var(--calcite-font-size-sm)}.arcgis-legend__imagery-layer-image--stretched{display:block;margin-bottom:-2px}.arcgis-legend__imagery-layer-info--stretched{padding:0 2px;vertical-align:top}.arcgis-legend__layer-cell--symbols{min-width:10px;text-align:center}.arcgis-legend__symbol{display:flex;justify-content:center}`, s = {
  layerTable: "arcgis-legend__layer-table",
  layerTableSizeRamp: "arcgis-legend__layer-table--size-ramp",
  layerCaption: "arcgis-legend__layer-caption",
  layerBody: "arcgis-legend__layer-body",
  layerRow: "arcgis-legend__layer-row",
  layerInfo: "arcgis-legend__layer-cell arcgis-legend__layer-cell--info",
  imageryLayerStretchedImage: "arcgis-legend__imagery-layer-image--stretched",
  imageryLayerInfoStretched: "arcgis-legend__imagery-layer-info--stretched",
  symbolContainer: "arcgis-legend__layer-cell arcgis-legend__layer-cell--symbols",
  symbol: "arcgis-legend__symbol"
};
class x extends w {
  static {
    this.properties = { cssEffectFilter: 1, layer: 0, legendElement: 0, messages: 0 };
  }
  static {
    this.styles = L;
  }
  render() {
    const e = this._renderLegendElement(), r = u(this.legendElement, this.messages), l = r ? a`<div class=${t(s.layerCaption)}>${r}</div>` : null, i = {
      [s.layerTableSizeRamp]: this.legendElement.type === "size-ramp"
    };
    return a`<section class=${t(d(s.layerTable, i))}>${l}${e}</section>`;
  }
  _renderLegendElement() {
    switch (this.legendElement.type) {
      case "symbol-table":
        return this._renderSymbolTable(this.legendElement);
      case "size-ramp":
        return a`<arcgis-legend-classic-size-ramp .legendElement=${this.legendElement} .messages=${this.messages}></arcgis-legend-classic-size-ramp>`;
      case "color-ramp":
      case "opacity-ramp":
      case "heatmap-ramp":
      case "stretch-ramp":
        return a`<arcgis-legend-classic-color-ramp .legendElement=${this.legendElement} .messages=${this.messages} .opacity=${this.layer.opacity}></arcgis-legend-classic-color-ramp>`;
      case "relationship-ramp":
        return a`<arcgis-legend-relationship-ramp .cssEffectFilter=${this.cssEffectFilter} .legendElement=${this.legendElement} .opacity=${this.layer.opacity} .messages=${this.messages}></arcgis-legend-relationship-ramp>`;
      case "pie-chart-ramp": {
        const { preview: e } = this.legendElement;
        return p(e, this.messages.previewPieChartAriaLabel), a`<div>${e}</div>`;
      }
      case "univariate-above-and-below-ramp":
        return a`<arcgis-legend-classic-univariate-above-and-below-ramp .cssEffectFilter=${this.cssEffectFilter} .legendElement=${this.legendElement} .messages=${this.messages} .opacity=${this.layer.opacity}></arcgis-legend-classic-univariate-above-and-below-ramp>`;
      case "univariate-color-size-ramp":
        return a`<arcgis-legend-classic-univariate-color-size-ramp .cssEffectFilter=${this.cssEffectFilter} .legendElement=${this.legendElement} .messages=${this.messages} .opacity=${this.layer.opacity}></arcgis-legend-classic-univariate-color-size-ramp>`;
      default:
        return null;
    }
  }
  _renderSymbolTable(e) {
    const r = e.infos.map((l) => this._renderElementInfo(l, e.legendType)).filter(Boolean);
    return r.length ? a`<div class=${t(s.layerBody)}>${r}</div>` : null;
  }
  _renderElementInfo(e, r) {
    const { layer: l } = this, i = "label" in e ? e.label : null;
    if ("type" in e && e.type)
      return e ? a`<arcgis-legend-classic-element .cssEffectFilter=${this.cssEffectFilter} .layer=${l} .legendElement=${e} .messages=${this.messages}></arcgis-legend-classic-element>` : null;
    if (!("preview" in e && e.preview) && !("src" in e && e.src))
      return null;
    const c = E(l, r), n = {
      [s.imageryLayerInfoStretched]: c
    }, o = {
      [s.imageryLayerInfoStretched]: c
    };
    return a`<div class=${t(s.layerRow)}><div class=${t(d(s.symbolContainer, o))}>${this._renderPreview(e, c)}</div><div class=${t(d(s.layerInfo, n))}>${m(this.messages, i, !1) || ""}</div></div>`;
  }
  _renderPreview(e, r) {
    const { layer: l } = this;
    if ("preview" in e && e.preview) {
      const { preview: i } = e, c = "previewAriaLabel" in e ? e.previewAriaLabel : null, n = "label" in e ? m(this.messages, e.label, !1) : null;
      return p(i, h(this.messages, c || n)), a`<div class=${t(s.symbol)}>${i}</div>`;
    }
    return "src" in e && e.src ? this._renderImage(e, l, r) : null;
  }
  _renderImage(e, r, l) {
    const { previewAriaLabel: i, src: c, opacity: n } = e, o = m(this.messages, e.label, !1), b = {
      [s.imageryLayerStretchedImage]: l,
      [s.symbol]: !l
    }, _ = {
      opacity: `${n ?? r.opacity}`
    }, y = h(this.messages, i || o);
    return a`<img alt=${y ?? g} .ariaLabel=${y} class=${t(d(b))} height=${e.height ?? void 0 ?? g} src=${c ?? g} style=${f(_)} width=${e.width ?? void 0 ?? g}>`;
  }
}
v("arcgis-legend-classic-element", x);
export {
  x as ArcgisLegendClassicElement
};
