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 { Component, Element, Method, Prop, State, Watch } from '@stencil/core';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer, methodPlaceholder, } from 'vega-slimmer/core';
import { sanitizeVegaComponent } from '../../utils/component';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../helpers/slimmers/component-usage-runtime-metrics';
import { VegaRichTextContentRenderer } from './slimmers/renderers/vega-rich-text-content-renderer';
import { VegaRichTextContentStateController } from './slimmers/controllers/vega-rich-text-content-state-controller';
import { findParent } from '../../utils/ui';
import { waitForComponentDidRender } from '../../helpers/common/wait-for-component-did-render';
import { RTEExtensionStylesController } from './slimmers/controllers/vega-rich-text-content-extensions-styles-controller';
import { DarkModeStateControllerSlimmer } from '../../helpers/slimmers/dark-mode-state-controller-slimmer';
import { VegaInternalThemeManager } from '../../helpers/theme/internal-theme-manager';
/**
 * @vegaVersion 2.34.0
 */
export class VegaRichTextContent {
  constructor() {
    this.globalSlimmers = {};
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.vegaRichTextContentRenderer = new VegaRichTextContentRenderer();
    this.vegaRichTextContentStateController = new VegaRichTextContentStateController();
    this.vegaRichTextContentExtensionsStylesController = new RTEExtensionStylesController();
    this.darkModeStateControllerSlimmer = new DarkModeStateControllerSlimmer();
    /**
     * Specifies whether the rich text content is editable.
     *
     * @vegaVersion 2.34.0
     */
    this.contentEditable = false;
    /**
     * Holds the custom styles generated by extensions.
     */
    this.extensionStyles = '';
    this.isInDarkMode = VegaInternalThemeManager.isDarkMode();
    /**
     * Defines the configuration for rich text content extensions.
     * It enables support for custom nodes, ensuring that extended content is rendered correctly.
     *
     * @vegaVersion 2.62.0
     */
    this.extensions = [];
  }
  watchValueUpdate() {
    methodPlaceholder();
  }
  watchExtensions(newValue, oldValue) {
    methodPlaceholder(newValue, oldValue);
  }
  /**
   * Invoke this method to focus on rich text content editable div
   *
   * @vegaVersion 2.34.0
   */
  async vegaFocus() {
    this.vegaRichTextContentRenderer.getRichTextContentRef().focus();
    const richTextEditorRef = findParent(this.host, 'vega-rich-text-editor');
    if (richTextEditorRef) {
      await waitForComponentDidRender(richTextEditorRef);
    }
  }
  render() {
    return sanitizeVegaComponent(this.vegaRichTextContentRenderer.render(), this.host);
  }
  static get is() { return "vega-rich-text-content"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-rich-text-content.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-rich-text-content.css"]
  }; }
  static get properties() { return {
    "content": {
      "type": "unknown",
      "mutable": true,
      "complexType": {
        "original": "VegaRTEContent",
        "resolved": "VegaRTEContent",
        "references": {
          "VegaRTEContent": {
            "location": "import",
            "path": "../vega-rich-text-editor/dto/content-state"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.34.0"
          }],
        "text": "Specifies the text or formatted information displayed by the rich text content, which can be either VegaRTEContent or VegaRTEContentBlock.\nIt is recommended to use the VegaRTEContent type.\nOnly in exceptional cases should the original data in the VegaRTEContentBlock type be used."
      }
    },
    "extensions": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "VegaRTEExtension[]",
        "resolved": "VegaRTEExtension[]",
        "references": {
          "VegaRTEExtension": {
            "location": "import",
            "path": "../vega-rich-text-editor/extensions/extension.abstract"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.62.0"
          }],
        "text": "Defines the configuration for rich text content extensions.\nIt enables support for custom nodes, ensuring that extended content is rendered correctly."
      },
      "defaultValue": "[]"
    }
  }; }
  static get states() { return {
    "placeholder": {},
    "contentEditable": {},
    "extensionStyles": {},
    "isInDarkMode": {}
  }; }
  static get methods() { return {
    "vegaFocus": {
      "complexType": {
        "signature": "() => Promise<void>",
        "parameters": [],
        "references": {
          "Promise": {
            "location": "global"
          },
          "Nullable": {
            "location": "import",
            "path": "../../types/general"
          },
          "HTMLVegaRichTextEditorElement": {
            "location": "global"
          }
        },
        "return": "Promise<void>"
      },
      "docs": {
        "text": "Invoke this method to focus on rich text content editable div",
        "tags": [{
            "name": "vegaVersion",
            "text": "2.34.0"
          }]
      }
    }
  }; }
  static get elementRef() { return "host"; }
  static get watchers() { return [{
      "propName": "content",
      "methodName": "watchValueUpdate"
    }, {
      "propName": "extensions",
      "methodName": "watchExtensions"
    }]; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaRichTextContent.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextContent.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextContent.prototype, "vegaRichTextContentRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextContent.prototype, "vegaRichTextContentStateController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextContent.prototype, "vegaRichTextContentExtensionsStylesController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextContent.prototype, "darkModeStateControllerSlimmer", void 0);
