import {
  __decorateClass
} from "../../chunks/chunk.QU3DSPNU.js";
import { html } from "lit";
import { property } from "lit/decorators.js";
import { unsafeHTML } from "lit/directives/unsafe-html.js";
import { GdsElement } from "../../gds-element.js";
import { tokens } from "../../tokens.style.js";
import { styleExpressionProperty } from "../../utils/decorators/style-expression-property.js";
import {
  forColorTokens,
  forSpaceTokensAndCustomValues
} from "../../utils/helpers/index.js";
import {
  withLayoutChildProps,
  withMarginProps
} from "../../utils/mixins/declarative-layout-mixins.js";
import IconStyles from "./icon.styles.js";
class GdsIcon extends withMarginProps(withLayoutChildProps(GdsElement)) {
  constructor() {
    super(...arguments);
    this.solid = false;
    this.level = "2";
    this.label = "";
  }
  /**
   * Generates the SVG attributes for the icon
   * @private
   */
  get svgAttributes() {
    const constructor = this.constructor;
    const baseAttrs = {
      fill: "none",
      xmlns: "http://www.w3.org/2000/svg",
      viewBox: constructor._viewBox,
      part: "icon"
    };
    if (this.label) {
      return {
        ...baseAttrs,
        "aria-label": this.label
      };
    } else {
      return {
        ...baseAttrs,
        role: "presentation"
      };
    }
  }
  /**
   * Gets the appropriate SVG content based on the solid property
   * @private
   */
  get svgContent() {
    const constructor = this.constructor;
    return this.solid ? constructor._solidSVG : constructor._regularSVG;
  }
  /**
   * Applies stroke width to SVG paths if stroke property is set
   * @private
   */
  applyStroke(content) {
    if (!this.stroke) return content;
    return content.replace(
      /<(path|rect|circle|ellipse|line|polyline|polygon)/g,
      `<$1 stroke-width="${this.stroke}"`
    );
  }
  /**
   * Generates the SVG attributes string
   * @private
   */
  generateAttributesString(attrs) {
    return Object.entries(attrs).filter(([_, value]) => value !== void 0).map(([key, value]) => `${key}="${value}"`).join("\n      ");
  }
  render() {
    const attrs = this.svgAttributes;
    let content = this.svgContent || "";
    if (this.stroke) {
      content = this.applyStroke(content);
    }
    const svg = `
      <svg ${this.generateAttributesString(attrs)}>
        ${content}
      </svg>
    `;
    return html`${unsafeHTML(svg)}`;
  }
}
GdsIcon.styles = [tokens, IconStyles];
__decorateClass([
  styleExpressionProperty({
    ...forSpaceTokensAndCustomValues,
    property: "height",
    selector: "svg"
  })
], GdsIcon.prototype, "size", 2);
__decorateClass([
  property({ type: Boolean })
], GdsIcon.prototype, "solid", 2);
__decorateClass([
  property({ type: Number })
], GdsIcon.prototype, "stroke", 2);
__decorateClass([
  property()
], GdsIcon.prototype, "level", 2);
__decorateClass([
  styleExpressionProperty(forColorTokens("content"))
], GdsIcon.prototype, "color", 2);
__decorateClass([
  property({ type: String })
], GdsIcon.prototype, "label", 2);
export {
  GdsIcon
};
