import { newComponentActionsTexts } from '@dvn/alaca/components/dvn-rich-editor/constants';
import { Component, h, Host, Prop } from '@stencil/core';
const actions = [{
    name: 'delete',
    title: 'Delete',
    icon: 'uil-trash-alt',
  }];
export class DvnRichEditorComponentOptions {
  render() {
    const conversionOptions = getConversionOptions(this.componentType)
      .filter(co => this.editorSettings.blockTypes.includes(co.name));
    const actionsToShow = actions.filter(a => this.editorSettings.enableBlockDeletion || a.name !== 'delete');
    if (conversionOptions.length === 0 && actionsToShow.length === 0) {
      // no need to show the menu if no option is available
      return null;
    }
    return (h(Host, null,
      h("dvn-dropdown", { placement: "rightTop", trigger: "click", leaned: true },
        h("dvn-icon-button", { iconName: "uil-angle-right-b", view: "ghost", iconScale: "large" }),
        h("div", { slot: "content" },
          h("dvn-menu", { leaned: true, width: "200px" },
            conversionOptions.map(action => (h("dvn-menu-item", { highlighted: action.name === this.componentType, onClick: () => this.onActionClick(action.name) },
              h("dvn-info-summary", { extraClass: action.name === this.componentType ? 'highlighted' : undefined, title: action.name === this.componentType ? h("b", null, action.title) : action.title, leaned: true }, action.icon &&
                h("dvn-icon", { slot: "media", iconName: `uil ${action.icon}`, scale: action.iconSize }))))),
            conversionOptions.length > 0 &&
              h("hr", { class: "leaned-vertically" }),
            actionsToShow.map(action => (h("dvn-menu-item", { onClick: () => this.onActionClick(action.name) },
              h("dvn-info-summary", { title: action.title, leaned: true },
                h("dvn-icon", { slot: "media", iconName: `uil ${action.icon}` }))))))))));
  }
  static get is() { return "dvn-rich-editor-component-options"; }
  static get originalStyleUrls() { return {
    "$": ["./dvn-rich-editor-component-options.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["dvn-rich-editor-component-options.css"]
  }; }
  static get properties() { return {
    "componentType": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "ComponentType",
        "resolved": "\"h1\" | \"h2\" | \"h3\" | \"text\"",
        "references": {
          "ComponentType": {
            "location": "import",
            "path": "@dvn/alaca/components/dvn-rich-editor/constants"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "component-type",
      "reflect": false
    },
    "editorSettings": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "EditorSettings",
        "resolved": "{ enableDrag?: boolean; enableBlockCreation?: boolean; enableBlockDeletion?: boolean; hideDragControls?: boolean; blockTypes?: ComponentType[]; blockSettings?: { text?: { textSelectionOptions?: OverlayMenuActionName[]; }; }; }",
        "references": {
          "EditorSettings": {
            "location": "import",
            "path": "@dvn/alaca/components/dvn-rich-editor/constants"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "onActionClick": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "(action: ComponentMenuActionName) => void",
        "resolved": "(action: ComponentMenuActionName) => void",
        "references": {
          "ComponentMenuActionName": {
            "location": "import",
            "path": "@dvn/alaca/components/dvn-rich-editor/constants"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
}
const getConversionOptions = (componentType) => {
  if (['text', 'h1', 'h2', 'h3'].includes(componentType)) {
    return newComponentActionsTexts;
  }
  return [];
};
