import { __esDecorate, __runInitializers } from "tslib";
import { html } from 'lit';
import { property } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import CheckedElement from '../../checkbox/internals/CheckedElement.js';
import { check, close } from '../../icons/Icons.js';
let SwitchElement = (() => {
    let _classSuper = CheckedElement;
    let _onIcon_decorators;
    let _onIcon_initializers = [];
    let _onIcon_extraInitializers = [];
    let _offIcon_decorators;
    let _offIcon_initializers = [];
    let _offIcon_extraInitializers = [];
    let _offIconInstance_decorators;
    let _offIconInstance_initializers = [];
    let _offIconInstance_extraInitializers = [];
    let _onIconInstance_decorators;
    let _onIconInstance_initializers = [];
    let _onIconInstance_extraInitializers = [];
    return class SwitchElement extends _classSuper {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _onIcon_decorators = [property({ type: Boolean, reflect: true })];
            _offIcon_decorators = [property({ type: Boolean, reflect: true })];
            _offIconInstance_decorators = [property({ type: Object })];
            _onIconInstance_decorators = [property({ type: Object })];
            __esDecorate(this, null, _onIcon_decorators, { kind: "accessor", name: "onIcon", static: false, private: false, access: { has: obj => "onIcon" in obj, get: obj => obj.onIcon, set: (obj, value) => { obj.onIcon = value; } }, metadata: _metadata }, _onIcon_initializers, _onIcon_extraInitializers);
            __esDecorate(this, null, _offIcon_decorators, { kind: "accessor", name: "offIcon", static: false, private: false, access: { has: obj => "offIcon" in obj, get: obj => obj.offIcon, set: (obj, value) => { obj.offIcon = value; } }, metadata: _metadata }, _offIcon_initializers, _offIcon_extraInitializers);
            __esDecorate(this, null, _offIconInstance_decorators, { kind: "accessor", name: "offIconInstance", static: false, private: false, access: { has: obj => "offIconInstance" in obj, get: obj => obj.offIconInstance, set: (obj, value) => { obj.offIconInstance = value; } }, metadata: _metadata }, _offIconInstance_initializers, _offIconInstance_extraInitializers);
            __esDecorate(this, null, _onIconInstance_decorators, { kind: "accessor", name: "onIconInstance", static: false, private: false, access: { has: obj => "onIconInstance" in obj, get: obj => obj.onIconInstance, set: (obj, value) => { obj.onIconInstance = value; } }, metadata: _metadata }, _onIconInstance_initializers, _onIconInstance_extraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        renderOnIcon() {
            return check;
        }
        renderOffIcon() {
            return close;
        }
        #onIcon_accessor_storage = __runInitializers(this, _onIcon_initializers, void 0);
        /**
         * When true it renders the "on" icon
         * @attribute
         */
        get onIcon() { return this.#onIcon_accessor_storage; }
        set onIcon(value) { this.#onIcon_accessor_storage = value; }
        #offIcon_accessor_storage = (__runInitializers(this, _onIcon_extraInitializers), __runInitializers(this, _offIcon_initializers, void 0));
        /**
         * When true it renders the "off" icon
         * @attribute
         */
        get offIcon() { return this.#offIcon_accessor_storage; }
        set offIcon(value) { this.#offIcon_accessor_storage = value; }
        #offIconInstance_accessor_storage = (__runInitializers(this, _offIcon_extraInitializers), __runInitializers(this, _offIconInstance_initializers, void 0));
        /**
         * An instance of the `SVGTemplateResult` passed as a property that describes the `off` icon.
         */
        get offIconInstance() { return this.#offIconInstance_accessor_storage; }
        set offIconInstance(value) { this.#offIconInstance_accessor_storage = value; }
        #onIconInstance_accessor_storage = (__runInitializers(this, _offIconInstance_extraInitializers), __runInitializers(this, _onIconInstance_initializers, void 0));
        /**
         * An instance of the `SVGTemplateResult` passed as a property that describes the `on` icon.
         */
        get onIconInstance() { return this.#onIconInstance_accessor_storage; }
        set onIconInstance(value) { this.#onIconInstance_accessor_storage = value; }
        /**
         * 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 = {
                surface: true,
                pressed,
                withIcon: _rendersIcons,
            };
            return html `
      <div class="${classMap(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> `;
        }
        constructor() {
            super(...arguments);
            __runInitializers(this, _onIconInstance_extraInitializers);
        }
    };
})();
export default SwitchElement;
//# sourceMappingURL=SwitchElement.js.map