import { p as proxyCustomElement, H, e as createEvent, h, c as Host } from './p-ae373651.js';
import { e as defaultIconPack, i as useLanguage } from './p-5b3a7f00.js';
import { S as SyncWithStore } from './p-070aa695.js';

const rtkSwitchCss = ":host{line-height:initial;font-family:var(--rtk-font-family, sans-serif);font-feature-settings:normal;font-variation-settings:normal}p{margin:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}:host{box-sizing:border-box;display:inline-flex;height:var(--rtk-space-6, 24px);width:var(--rtk-space-10, 40px);align-items:center;padding:var(--rtk-space-1, 4px);border-radius:9999px;background-color:rgb(var(--rtk-colors-text-600, 255 255 255 / 0.52));cursor:pointer}.switch{box-sizing:border-box;height:var(--rtk-space-4, 16px);width:var(--rtk-space-4, 16px);background-color:rgb(var(--rtk-colors-text-on-brand-1000, var(--rtk-colors-text-1000, 255 255 255)));border-radius:9999px;transition-property:var(--rtk-transition-property, all);transition-duration:200ms}:host(.checked){--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-brand-500, 33 96 253) / var(--tw-bg-opacity))}:host(.checked) .switch{transform:translateX(100%)}:host([readonly]),:host([disabled]){cursor:not-allowed;opacity:0.6}";
const RtkSwitchStyle0 = rtkSwitchCss;

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        r = Reflect.decorate(decorators, target, key, desc);
    else
        for (var i = decorators.length - 1; i >= 0; i--)
            if (d = decorators[i])
                r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const RtkSwitch = /*@__PURE__*/ proxyCustomElement(class RtkSwitch extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.onChange = createEvent(this, "rtkChange", 4);
        /** Whether the switch is enabled/checked */
        this.checked = false;
        /** Whether switch is readonly */
        this.readonly = false;
        /** Whether switch is readonly */
        this.disabled = false;
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.onClick = () => {
            if (!this.readonly && !this.disabled) {
                this.checked = !this.checked;
            }
        };
        this.onKeyPress = (e) => {
            if (this.readonly)
                return;
            switch (e.key) {
                // Enter or Space
                case 'Enter':
                case ' ':
                    this.checked = !this.checked;
                    break;
            }
        };
    }
    connectedCallback() {
        this.checkedChange(this.checked);
    }
    checkedChange(checked) {
        this.checked = checked;
        this.onChange.emit(checked);
    }
    render() {
        return (h(Host, { key: 'af0bcf0202cda77f3ec27510b867ed149c478bdf', role: "switch", tabIndex: this.disabled && 0, "aria-readonly": this.readonly, "aria-checked": this.checked, "aria-disabled": this.disabled, class: { checked: this.checked }, onClick: this.onClick, onKeyPress: this.onKeyPress }, h("div", { key: 'e6f5eeb8acf33e9f058b029423eddc099033053c', class: "switch", part: "switch" })));
    }
    static get watchers() { return {
        "checked": ["checkedChange"]
    }; }
    static get style() { return RtkSwitchStyle0; }
}, [1, "rtk-switch", {
        "checked": [1028],
        "readonly": [4],
        "disabled": [516],
        "iconPack": [16],
        "t": [16]
    }, undefined, {
        "checked": ["checkedChange"]
    }]);
__decorate([
    SyncWithStore()
], RtkSwitch.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkSwitch.prototype, "t", void 0);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-switch"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-switch":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkSwitch);
            }
            break;
    } });
}
defineCustomElement();

export { RtkSwitch as R, defineCustomElement as d };
