var __decorate = (this && this.__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;
};
import { css, html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js';
const styles = css `
  :host {
    display: flex;
  }

  .switch {
    height: 0;
    width: 0;
    visibility: hidden;
    margin: 0;
  }

  label {
    cursor: pointer;
    text-indent: -9999px;
    width: 38px;
    height: 20px;
    background: var(--affine-icon-color);
    border: 1px solid var(--affine-black-10);
    display: block;
    border-radius: 20px;
    position: relative;
  }

  label:after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    background: var(--affine-white);
    border: 1px solid var(--affine-black-10);
    border-radius: 16px;
    transition: 0.1s;
  }

  label.on {
    background: var(--affine-primary-color);
  }

  label.on:after {
    left: calc(100% - 1px);
    transform: translateX(-100%);
  }

  label:active:after {
    width: 24px;
  }
`;
let ToggleSwitch = class ToggleSwitch extends LitElement {
    constructor() {
        super(...arguments);
        this.on = false;
    }
    _toggleSwitch() {
        this.on = !this.on;
        if (this.onChange) {
            this.onChange(this.on);
        }
    }
    render() {
        return html `
      <label class=${this.on ? 'on' : ''}>
        <input
          type="checkbox"
          class="switch"
          ?checked=${this.on}
          @change=${this._toggleSwitch}
        />
      </label>
    `;
    }
};
ToggleSwitch.styles = styles;
__decorate([
    property({ attribute: false })
], ToggleSwitch.prototype, "on", void 0);
__decorate([
    property({ attribute: false })
], ToggleSwitch.prototype, "onChange", void 0);
ToggleSwitch = __decorate([
    customElement('toggle-switch')
], ToggleSwitch);
export { ToggleSwitch };
//# sourceMappingURL=toggle-switch.js.map