import { __decorate } from "tslib";
import { html } from "lit";
import { property } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import elementStyles from './Switch.styles.js';
import CheckedElement from "./CheckedElement.js";
import { check, close } from '../icons/Icons.js';
export default class SwitchElement extends CheckedElement {
    static get styles() {
        return elementStyles;
    }
    renderOnIcon() {
        return check;
    }
    renderOffIcon() {
        return close;
    }
    /**
     * Whether any icon is rendered.
     */
    get _rendersIcons() {
        if (this.checked) {
            return !!this.onIcon;
        }
        return !!this.offIcon;
    }
    get _currentIcon() {
        if (!this._rendersIcons) {
            return html ``;
        }
        if (this.checked) {
            const { onIconInstance } = this;
            return onIconInstance || this.renderOnIcon();
        }
        const { offIconInstance } = this;
        return offIconInstance || this.renderOffIcon();
    }
    render() {
        const { pressed = false, _rendersIcons } = this;
        const surfaceClasses = classMap({
            surface: true,
            pressed,
            withIcon: _rendersIcons,
        });
        return html `
    <div class="${surfaceClasses}">
      <div class="container track"></div>
      <div class="state"></div>
      <div class="content">
        <div class="thumb">
          ${this._rendersIcons ? this._iconsTemplate() : html ``}
        </div>
      </div>
    </div>
    `;
    }
    _iconsTemplate() {
        return html `
    <div class="icon">${this._currentIcon}</div>
    `;
    }
}
__decorate([
    property({ type: Boolean, reflect: true })
], SwitchElement.prototype, "onIcon", void 0);
__decorate([
    property({ type: Boolean, reflect: true })
], SwitchElement.prototype, "offIcon", void 0);
__decorate([
    property({ type: Object })
], SwitchElement.prototype, "offIconInstance", void 0);
__decorate([
    property({ type: Object })
], SwitchElement.prototype, "onIconInstance", void 0);
//# sourceMappingURL=SwitchElement.js.map