import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-090d31ca.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { I as ItemToggleTransitionMillisecond } from './ui-93922c59.js';
import { D as DomNodeSubjectObserverFactory } from './dom-node-subject-observer-factory-aca0116e.js';
import { O as VegaToggleStatus, a as VegaClick } from './vega-event-id-a6ccca66.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-1c57093d.js';
import { I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-46020a03.js';
import { c as createDeprecatedPropertySlimmer } from './deprecated-property-slimmer-ea34fa7b.js';
import './change-manager-6a7eb88c.js';
import './observer-3959f9dd.js';
import './ui-b7600a48.js';
import './dynamic-slimmer-90b8af32.js';
import './internal-vega-event-manager-7cdf3c28.js';
import './try-get-document-bef0f526.js';
import './object-0c277f57.js';

const VegaItemToggleRuntimeMetricsPayloadDefinition = [
  {
    payloadKey: 'ITEM_TOGGLE_STATUS_MAP_IS_DEFAULT_VALUE',
    payloadDescription: '@deprecated Defines the labels and icons associated with the toggle states.',
    /**
     * The function checks if the `itemToggleStatusMap` property of the `host` element is default value.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.itemToggleStatusMap.unToggledIcon === 'plus-sign' &&
      host.itemToggleStatusMap.toggledIcon === 'delete-bin' &&
      host.itemToggleStatusMap.unToggledLabel === 'Add' &&
      host.itemToggleStatusMap.togglingLabel === 'Added' &&
      host.itemToggleStatusMap.toggledLabel === 'Remove' &&
      host.itemToggleStatusMap.unTogglingLabel === 'Removed',
  },
  {
    payloadKey: 'ITEM_TOGGLE_STATUS_MAP_IS_NOT_DEFAULT_VALUE',
    payloadDescription: '@deprecated Defines the labels and icons associated with the toggle states.',
    /**
     * The function checks if the `itemToggleStatusMap` property of the `host` element is not default value.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.itemToggleStatusMap.unToggledIcon !== 'plus-sign' ||
      host.itemToggleStatusMap.toggledIcon !== 'delete-bin' ||
      host.itemToggleStatusMap.unToggledLabel !== 'Add' ||
      host.itemToggleStatusMap.togglingLabel !== 'Added' ||
      host.itemToggleStatusMap.toggledLabel !== 'Remove' ||
      host.itemToggleStatusMap.unTogglingLabel !== 'Removed',
  },
];

const vegaItemToggleCss = ":host{display:inline-block;text-align:left;line-height:normal}div{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px;color:rgba(var(--v-text-link, 19, 98, 226, 1));padding-right:8px;display:inline-block}@media screen and (min-width: 768px) and (max-width: 1023px){div{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){div{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){div{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}div:hover{color:rgba(var(--v-text-link-hover, 4, 112, 236, 1))}vega-button-circle::part(button):hover{background-color:rgba(var(--v-bg-action-secondary, 252, 252, 252, 1))}vega-button-circle::part(button):active{background-color:rgba(var(--v-bg-action-secondary, 252, 252, 252, 1))}:host(.vega-toggled-status)>div,:host(.vega-toggled-status) vega-button-circle{animation:fadein 1.4s ease}:host(.vega-toggled-status)>div{cursor:default;color:rgba(var(--v-text-success, 1, 128, 31, 1))}:host(.vega-toggled-status)>div:hover{color:rgba(var(--v-text-success, 1, 128, 31, 1))}:host(.vega-toggled-status) vega-button-circle::part(button){border:2px solid rgba(var(--v-border-success, 1, 128, 31, 1));cursor:default;box-shadow:0 0 0 0}:host(.vega-toggled-status) vega-button-circle::part(button):hover{border:2px solid rgba(var(--v-border-success, 1, 128, 31, 1))}:host(.vega-toggled-status) vega-button-circle::part(icon){color:rgba(var(--v-text-success, 1, 128, 31, 1))}@keyframes fadein{0%{opacity:0}10%{opacity:0.1}50%{opacity:0.5}80%{opacity:0.8}100%{opacity:1}}";

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 VegaItemToggle = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaToggleStatus = createEvent(this, "vegaToggleStatus", 7);
    this.toggleStatus = createEvent(this, "toggleStatus", 7);
    this.globalSlimmers = {};
    this.toggleStatusEventEmitter = createEventEmitSlimmer(VegaItemToggle, VegaToggleStatus);
    this.deprecatedPropertySlimmer = createDeprecatedPropertySlimmer(VegaItemToggle, 'statusMap', 'itemToggleStatusMap', VegaItemToggle.defaultStatusMap);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer(VegaItemToggleRuntimeMetricsPayloadDefinition);
    this.toggleItemStatus = 'unToggled';
    /**
     * Defines the labels and icons associated with the toggle states.
     * @deprecated This property will be removed soon and replaced by prop statusMap
     *
     * @vegaVersion 1.3.0
     * @defaultValue {unToggledIcon: 'plus-sign', toggledIcon: 'delete-bin', unToggledLabel: 'Add', togglingLabel: 'Added', toggledLabel: 'Remove', unTogglingLabel: 'Removed'}
     */
    this.itemToggleStatusMap = VegaItemToggle.defaultStatusMap;
    /**
     * Defines the labels and icons associated with the toggle states.
     *
     * @vegaVersion 2.2.0
     * @defaultValue {unToggledIcon: 'plus-sign', toggledIcon: 'delete-bin', unToggledLabel: 'Add', togglingLabel: 'Added', toggledLabel: 'Remove', unTogglingLabel: 'Removed'}
     */
    this.statusMap = VegaItemToggle.defaultStatusMap;
    /**
     * Determines whether the item is toggled on.
     *
     * @vegaVersion 1.3.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isToggled = false;
    this.handleToggle = () => {
      if (!this.isTogglingOrUnToggling()) {
        this.updateToggleStatus();
      }
    };
  }
  onToggledPropsChange() {
    this.updateTransitionStatus();
  }
  componentWillLoad() {
    this.updateTransitionStatus();
  }
  render() {
    return sanitizeVegaComponent(h(Host, { class: {
        'vega-toggled-status': this.isTogglingOrUnToggling(),
      } }, this.renderLabelDom(), h("vega-button-circle", { size: "small", variant: "secondary", icon: this.toggleItemStatus === 'unToggled'
        ? this.deprecatedPropertySlimmer.getValue().unToggledIcon || 'plus-sign'
        : this.toggleItemStatus === 'toggled'
          ? this.deprecatedPropertySlimmer.getValue().toggledIcon || 'delete-bin'
          : 'checkmark', ref: (ref) => {
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaClick, this.handleToggle);
      } })), this.host);
  }
  renderLabelDom() {
    let label;
    switch (this.toggleItemStatus) {
      case 'unToggled':
        label = this.deprecatedPropertySlimmer.getValue().unToggledLabel;
        break;
      case 'toggling':
        label = this.deprecatedPropertySlimmer.getValue().togglingLabel;
        break;
      case 'toggled':
        label = this.deprecatedPropertySlimmer.getValue().toggledLabel;
        break;
      case 'unToggling':
        label = this.deprecatedPropertySlimmer.getValue().unTogglingLabel;
        break;
    }
    return h("div", null, label || 'No label defined');
  }
  isTogglingOrUnToggling() {
    return this.toggleItemStatus === 'toggling' || this.toggleItemStatus === 'unToggling';
  }
  updateToggleStatus() {
    switch (this.toggleItemStatus) {
      case 'unToggled':
        this.toggleItemStatus = 'toggling';
        setTimeout(() => {
          this.isToggled = true;
        }, ItemToggleTransitionMillisecond);
        break;
      case 'toggled':
        this.toggleItemStatus = 'unToggling';
        setTimeout(() => {
          this.isToggled = false;
        }, ItemToggleTransitionMillisecond);
        break;
    }
  }
  updateTransitionStatus() {
    this.isToggled ? (this.toggleItemStatus = 'toggled') : (this.toggleItemStatus = 'unToggled');
    this.toggleStatusEventEmitter.emit(this.isToggled);
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "isToggled": ["onToggledPropsChange"]
  }; }
};
VegaItemToggle.defaultStatusMap = {
  unToggledIcon: 'plus-sign',
  toggledIcon: 'delete-bin',
  unToggledLabel: 'Add',
  togglingLabel: 'Added',
  toggledLabel: 'Remove',
  unTogglingLabel: 'Removed',
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaItemToggle.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaItemToggle.prototype, "toggleStatusEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaItemToggle.prototype, "deprecatedPropertySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaItemToggle.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaItemToggle.style = vegaItemToggleCss;

export { VegaItemToggle as vega_item_toggle };
