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 { MapToComponentField, MapToComponentMethod, VegaSlimmer } from 'vega-slimmer/core';
import { DARK_MODE_CHANGE } from '../change-manager/subject/static-subject/static-subject-title';
import { Observer } from '../change-manager/observer/observer';
import ChangeManager from '../change-manager/change-manager';
/** The `DarkModeStateControllerSlimmer` class monitors dark mode changes and updates the state accordingly. */
export class DarkModeStateControllerSlimmer extends VegaSlimmer {
  /**
   * Component lifecycle - [connectedCallback]
   * Register an observer to watch for dark mode updates, which will cause the component to update.
   */
  connectedCallback() {
    this.observer = new Observer(this.isAcceptObserver.bind(this), (isDark) => {
      this.isInDarkMode = isDark;
    });
    ChangeManager.register(DARK_MODE_CHANGE, this.observer);
  }
  /**
   * cancel dark mode observer when disconnectedCallback
   */
  disconnectResizeObserver() {
    ChangeManager.unregister(DARK_MODE_CHANGE, this.observer);
  }
  /**
   * Determines whether the observer should accept changes.
   *
   * @returns {boolean} Always returns true in the current implementation.
   */
  isAcceptObserver() {
    return true;
  }
}
__decorate([
  MapToComponentField({ writable: true })
], DarkModeStateControllerSlimmer.prototype, "isInDarkMode", void 0);
__decorate([
  MapToComponentMethod('connectedCallback')
], DarkModeStateControllerSlimmer.prototype, "connectedCallback", null);
__decorate([
  MapToComponentMethod('disconnectedCallback')
], DarkModeStateControllerSlimmer.prototype, "disconnectResizeObserver", null);
