import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { ApplicationContext, StringUtils, ErrorException, WarningException, ObjectUtils, DateUtils, ServiceUtils, StorageType, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
import { D as DataFetcher } from './DataFetcher.js';
import { P as ParamType } from './ParamType.js';
import './ISave.js';
import '@sankhyalabs/ezui/dist/collection/utils/constants';
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
import './dataunit-fetcher.js';
import './filter-item-type.enum.js';
import './form-config-fetcher.js';
import './constants.js';
import { g as getSelectedRecordsIDsInfo } from './GetSelectedRecordsIDsInfo.js';
import { R as ResourceIDUtils } from './ResourceIDUtils.js';

const SERVICE_ACTION_EXECUTE_JAVA = 'ActionButtonsSP.executeJava';
class JavaExecutor {
  execute(action) {
    var _a;
    const execSource = {
      actionID: action.actionID,
      refreshType: (_a = action.actionConfig.javaCall) === null || _a === void 0 ? void 0 : _a.refreshType
    };
    return new Promise((resolve) => {
      resolve({ execSource, callback: this.callExecJava });
    });
  }
  async callExecJava(execSource) {
    const request = {
      requestBody: {
        javaCall: execSource
      }
    };
    await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_JAVA, JSON.stringify(request));
  }
}

const SERVICE_ACTION_EXECUTE_SCRIPT = 'ActionButtonsSP.executeScript';
class JavascriptExecutor {
  execute(action) {
    var _a;
    const execSource = {
      actionID: action.actionID,
      refreshType: (_a = action.actionConfig.runScript) === null || _a === void 0 ? void 0 : _a.refreshType
    };
    return new Promise((resolve) => {
      resolve({ execSource, callback: this.callExecScript });
    });
  }
  async callExecScript(execSource) {
    const request = {
      runScript: execSource
    };
    await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_SCRIPT, request);
  }
}

class LaunchScreenExecutor {
  constructor() {
    this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
  }
  async execute(action, dataUnit) {
    const resourceID = action.resourceID;
    if (!resourceID)
      return;
    let launchObject = await this.buildLaunchObject(action, dataUnit);
    this._application.openApp(resourceID, launchObject);
    return null;
  }
  buildLaunchObject(action, dataUnit) {
    return new Promise((resolve) => {
      let params = action.actionConfig.params.param;
      if (params && params.length > 0) {
        let launchObject = {};
        let processedParams = [];
        params.forEach(param => {
          const localField = param.localField;
          let value = dataUnit.getFieldValue(localField);
          if (!value) {
            let localFieldLabel = dataUnit.getField(localField).label;
            localFieldLabel = StringUtils.isEmpty(dataUnit.getField(localField).label) ? localField : localFieldLabel;
            throw new ErrorException(this._application.messagesBuilder.getMessage("snkActionsButton.title.error", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField", { description: action.description, localFieldLabel: localFieldLabel }));
          }
          if (value !== null && typeof value === 'object' && 'value' in value) {
            value = value.value;
          }
          const finalValue = StringUtils.isEmpty(value === null || value === void 0 ? void 0 : value.toString()) ? undefined : value.toString();
          launchObject[param.targetField] = finalValue;
          processedParams.push({
            fieldName: param.targetField,
            value: finalValue
          });
        });
        launchObject.ACTION_PARAMETERS = processedParams;
        launchObject.call_time = Date.now();
        resolve(launchObject);
      }
      resolve(null);
    });
  }
}

const SERVICE_ACTION_EXECUTE_STP = 'ActionButtonsSP.executeSTP';
class ProcedureExecutor {
  execute(action) {
    var _a, _b, _c;
    const procName = (_a = action.actionConfig.dbCall) === null || _a === void 0 ? void 0 : _a.name;
    const rootEntity = (_b = action.actionConfig.dbCall) === null || _b === void 0 ? void 0 : _b.rootEntity;
    const execSource = {
      actionID: action.actionID,
      refreshType: (_c = action.actionConfig.dbCall) === null || _c === void 0 ? void 0 : _c.refreshType,
      procName: procName,
      rootEntity: rootEntity
    };
    return new Promise((resolve) => {
      resolve({ execSource, callback: this.callExecProcedure });
    });
  }
  async callExecProcedure(execSource) {
    const request = {
      requestBody: {
        stpCall: execSource
      }
    };
    await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_STP, JSON.stringify(request));
  }
}

var ActionsType;
(function (ActionsType) {
  ActionsType["LAUNCH_SCREEN"] = "LC";
  ActionsType["JAVASCRIPT"] = "SC";
  ActionsType["JAVA"] = "RJ";
  ActionsType["PROCEDURE"] = "SP";
  ActionsType["EMBEDDED"] = "EB";
})(ActionsType || (ActionsType = {}));

class ExecutorFactory {
  constructor(actionType) {
    this.actionType = actionType;
    this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
  }
  get executor() {
    switch (this.actionType) {
      case ActionsType.LAUNCH_SCREEN:
        return new LaunchScreenExecutor();
      case ActionsType.JAVASCRIPT:
        return new JavascriptExecutor();
      case ActionsType.JAVA:
        return new JavaExecutor();
      case ActionsType.PROCEDURE:
        return new ProcedureExecutor();
      default:
        throw new ErrorException(this._application.messagesBuilder.getMessage("snkActionsButton.title.error", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType", { actionType: this.actionType }));
    }
  }
}

var RefreshType;
(function (RefreshType) {
  RefreshType["NONE"] = "NONE";
  RefreshType["PARENT"] = "PARENT";
  RefreshType["MASTER"] = "MASTER";
  RefreshType["ALL"] = "ALL";
})(RefreshType || (RefreshType = {}));

const MASTER_ROW_PROPERTY = "__MASTER_ROW__";
const ENTITY_NAME_PROPERTY = '__ENTITY_NAME__';
const SERVICE_GET_CONFIGURATIONS = 'SystemUtilsSP.getConf';
class Actions {
  constructor(actionsExecuteInterface, dataUnit, appResourceId) {
    var _a;
    this._lastValuesCache = {};
    this._actionsExecuteInterface = actionsExecuteInterface;
    this._dataUnit = dataUnit;
    this._selectedRows = ((_a = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getSelectionInfo()) === null || _a === void 0 ? void 0 : _a.isAllRecords()) ? [] : dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getSelectionInfo().records;
    this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
    this._appResourceId = appResourceId;
  }
  getPrimaryKeys() {
    const ids = getSelectedRecordsIDsInfo(this._dataUnit);
    return ids.map(({ name }) => name);
  }
  apply(action, hasParamsToSave) {
    this._application.closePopUp();
    this._actionsExecuteInterface.execute(action, this._dataUnit)
      .then(({ execSource, callback }) => {
      this.resolvePromptParams(action, execSource, hasParamsToSave)
        .then(() => {
        this.actionExecute(execSource, callback);
      });
    });
  }
  ;
  async execute(action) {
    var _a;
    if (!action.actionConfig) {
      throw new WarningException(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction", { description: action.description }));
    }
    if (!!((_a = action.actionConfig.params) === null || _a === void 0 ? void 0 : _a.promptParam)) {
      const paramsSource = action.actionConfig.params.promptParam;
      let hasParamsToSave = false;
      for (let i = 0; i < paramsSource.length; i++) {
        let paramSource = paramsSource[i];
        if (!hasParamsToSave && paramSource.saveLast === 'true') {
          hasParamsToSave = true;
          break;
        }
      }
      if (hasParamsToSave) {
        action.actionConfig.params.promptParam = await this.loadSavedValuesIntoParams(action);
      }
      const form = document.createElement("snk-actions-form");
      window.document.body.appendChild(form);
      form.action = ObjectUtils.copy(action);
      form.applyParameters = (resultAction) => {
        this.apply(resultAction, hasParamsToSave);
      };
      form.openPopup();
    }
    else if (action.type != ActionsType.LAUNCH_SCREEN) {
      this._actionsExecuteInterface.execute(action, this._dataUnit)
        .then(({ execSource, callback }) => {
        this.actionExecute(execSource, callback);
      });
    }
    else {
      this._actionsExecuteInterface.execute(action, this._dataUnit);
    }
  }
  loadSavedValuesIntoParams(action) {
    return this.loadLastValues(action)
      .then((lastParams) => {
      let resultParams = action.actionConfig.params.promptParam;
      if (lastParams) {
        lastParams.param.forEach(lastParam => {
          resultParams = resultParams.map((param) => {
            if (param.name !== lastParam.paramName)
              return param;
            if (param.paramType === 'B') {
              return Object.assign(Object.assign({}, param), { value: lastParam.$ === 'S' });
            }
            return Object.assign(Object.assign({}, param), { value: lastParam.$ });
          });
        });
      }
      return resultParams;
    });
  }
  async actionExecute(execSource, callback) {
    execSource.virtualPage = this.buildVirtualPage();
    await this.prepareAndExecute(execSource, callback);
    this.recordsReloader(execSource.refreshType);
  }
  resolvePromptParams(action, execSource, hasParamsToSave) {
    return new Promise(resolve => {
      const paramsSource = action.actionConfig.params.promptParam;
      let params = [];
      paramsSource.forEach(paramSource => {
        params.push(this.buildPromptParam(paramSource));
      });
      this.putParamsOnExecSource(params, execSource);
      if (hasParamsToSave) {
        this.saveLastValues(action, params);
      }
      resolve();
    });
  }
  buildPromptParam(param) {
    let type = param.paramType;
    let isCheckbox = false;
    let fieldProps;
    let entityPK;
    let value = param.value;
    switch (type) {
      case ParamType.DATE:
        type = 'D';
        break;
      case ParamType.DATETIME:
        type = 'H';
        break;
      case ParamType.DECIMAL:
        type = 'F';
        fieldProps = {
          'sk-precision': Number(param.precision)
        };
        break;
      case ParamType.BOOLEAN:
        type = 'S';
        isCheckbox = true;
        value = param.value ? 'S' : 'N';
        break;
      case ParamType.ENTITY:
        fieldProps = {
          'sk-entity-name': param.entityName,
          'sk-allow-show-hierarchical-mode': param.hierarchyEntity,
          'sk-data-type': 'S'
        };
        if (param.hierarchyEntity && param.entityPK) {
          entityPK = param.entityPK;
        }
        value = param.value ? Number(param.value) : null;
        break;
      case ParamType.OPTIONS:
        type = 'O';
        let options = param.options.split(';').map(function (opc, index) {
          let data;
          let value;
          if (opc.indexOf('=') > -1) {
            let opcArr = opc.split('=');
            data = opcArr[0];
            value = opcArr[1];
          }
          else {
            data = (index + 1);
            value = opc;
          }
          return {
            data: data,
            value: value
          };
        });
        fieldProps = {
          'sk-options': options
        };
        break;
    }
    return {
      description: param.label,
      required: param.required == 'true',
      fieldName: param.name,
      fieldNameOri: param.name,
      entityPK: entityPK,
      paramType: param.paramType,
      type: type,
      isCheckbox: isCheckbox,
      saveLast: param.saveLast,
      fieldProp: fieldProps,
      value: value,
      isGeneratedName: param.isGeneratedName
    };
  }
  putParamsOnExecSource(params, execSource) {
    execSource.params = {
      param: []
    };
    params.forEach(param => {
      if (param.isGeneratedName && param.value) {
        throw new ErrorException(this._application.messagesBuilder.getMessage("snkActionsButton.title.error", undefined), this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName", undefined));
      }
      if (!StringUtils.isEmpty(param.value)) {
        execSource.params.param.push({
          type: this.getParamDataType(param.paramType),
          paramName: param.fieldName,
          $: this.getParamValue(param)
        });
      }
    });
  }
  getParamDataType(type) {
    let dataType;
    switch (type) {
      case "D":
        dataType = "F";
        break;
      case "DT":
      case "DH":
        dataType = "D";
        break;
      case "B":
      case "ENTITY":
      case "SO":
        dataType = "S";
        break;
      default:
        dataType = type;
    }
    return dataType;
  }
  getParamValue(param) {
    let value = param.value;
    if (!value) {
      return value;
    }
    if (param.paramType == 'DT') {
      value = DateUtils.formatDate(value);
    }
    else if (param.paramType == 'DH') {
      value = DateUtils.formatDateTime(value);
    }
    return value;
  }
  async loadLastValues(action) {
    const resourceId = await this.buildResourceId(action.actionID);
    return new Promise((resolve, reject) => {
      if (this._lastValuesCache[resourceId]) {
        resolve(this._lastValuesCache[resourceId]);
      }
      else {
        const config = {
          config: {
            chave: resourceId,
            tipo: 'T'
          }
        };
        DataFetcher.get().callServiceBroker(SERVICE_GET_CONFIGURATIONS, config)
          .then((result) => {
          var _a, _b;
          let lastParams;
          if ((_b = (_a = result.config) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.params) {
            lastParams = result.config.data.params;
            if (!Array.isArray(lastParams.param)) {
              lastParams.param = [lastParams.param];
            }
          }
          this._lastValuesCache[resourceId] = lastParams;
          resolve(lastParams);
        }).catch((error) => {
          reject(error);
        });
      }
    });
  }
  async saveLastValues(action, params) {
    if (this._application) {
      let config = {
        params: {
          param: []
        }
      };
      params.forEach(param => {
        if (param.saveLast == 'true') {
          config.params.param.push({
            paramName: param.fieldName,
            $: param.value
          });
        }
      });
      const resourceId = await this.buildResourceId(action.actionID);
      this._lastValuesCache[resourceId] = config.params;
      this._application.saveConfig(resourceId, config);
    }
  }
  async buildResourceId(actionId) {
    return this._appResourceId + '.actionconfig.' + actionId;
  }
  async prepareAndExecute(execSource, executeAction) {
    this.addRows(execSource);
    await executeAction(execSource);
  }
  addRows(execSource) {
    const primaryKeys = this.getPrimaryKeys();
    const rows = {
      row: []
    };
    const sourceRows = this._selectedRows;
    for (const i in sourceRows) {
      const sourceRow = sourceRows[i];
      const row = {};
      if (sourceRow.hasOwnProperty(MASTER_ROW_PROPERTY)) {
        row.master = 'S';
        row.entityName = sourceRow.__ENTITY_NAME__;
        delete sourceRow[MASTER_ROW_PROPERTY];
        delete sourceRow[ENTITY_NAME_PROPERTY];
      }
      if (!row.field) {
        row.field = [];
      }
      for (const primaryKey of primaryKeys) {
        row.field.push({
          fieldName: primaryKey,
          $: sourceRow[primaryKey]
        });
      }
      rows.row.push(row);
    }
    if (rows.row.length > 0) {
      execSource.rows = rows;
    }
  }
  recordsReloader(refreshType) {
    switch (refreshType) {
      case RefreshType.NONE:
        break;
      case RefreshType.PARENT:
      case RefreshType.MASTER:
      case RefreshType.ALL:
        this._dataUnit.loadData();
        break;
      default:
        this._dataUnit.reloadCurrentRecord();
    }
  }
  ;
  buildVirtualPage() {
    var _a, _b, _c, _d;
    if ((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo()) === null || _b === void 0 ? void 0 : _b.isAllRecords()) {
      const virtualPage = {
        filters: { filters: (_c = this._dataUnit) === null || _c === void 0 ? void 0 : _c.getAppliedFilters() },
        orders: { orders: (_d = this._dataUnit) === null || _d === void 0 ? void 0 : _d.getSort() },
      };
      return virtualPage;
    }
  }
}

const CONFIRMACAO = "__CONFIRMACAO__";
const ESCOLHA_SIM_NAO = "__ESCOLHA_SIMNAO__";
class ClientEventConfirm {
  async clientConfirm(clientEvent, recaller) {
    return new Promise((resolve) => {
      var _a, _b;
      const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
      let actionType = "";
      if (clientEvent.content.event.hasOwnProperty('stpCall')) {
        recaller.requestBody = clientEvent.content.event.stpCall;
        actionType = ActionsType.PROCEDURE;
      }
      else if (clientEvent.content.event.hasOwnProperty('runScript')) {
        recaller.requestBody = clientEvent.content.event.runScript;
        actionType = ActionsType.JAVASCRIPT;
      }
      else if (clientEvent.content.event.hasOwnProperty('javaCall')) {
        recaller.requestBody = clientEvent.content.event.javaCall;
        actionType = ActionsType.JAVA;
      }
      let param = {
        type: 'S',
        sequence: clientEvent.content.event.sequence
      };
      if (!recaller.requestBody.params) {
        recaller.requestBody.params = {
          param: []
        };
      }
      else {
        if (!Array.isArray(recaller.requestBody.params.param)) {
          recaller.requestBody.params.param = [recaller.requestBody.params.param];
        }
      }
      recaller.requestBody.params.param.push(param);
      const title = clientEvent.content.event.title.$;
      const message = clientEvent.content.event.message.$;
      let requestBody;
      switch (actionType) {
        case ActionsType.JAVASCRIPT:
          requestBody = { runScript: recaller.requestBody };
          break;
        case ActionsType.PROCEDURE:
          requestBody = {
            requestBody: {
              stpCall: recaller.requestBody
            }
          };
          break;
        case ActionsType.JAVA:
          requestBody = {
            requestBody: {
              javaCall: recaller.requestBody
            }
          };
          break;
      }
      if (clientEvent.content.event.showNoOption == 'S') {
        param.paramName = ESCOLHA_SIM_NAO;
        const form = document.createElement("snk-client-confirm");
        window.document.body.appendChild(form);
        form.titleMessage = title;
        form.message = message;
        form.accept = async () => {
          param.$ = 'S';
          await recaller.reCall(requestBody);
          resolve();
        };
        form.cancel = async () => {
          param.$ = 'N';
          await recaller.reCall(requestBody);
          resolve();
        };
        form.openPopup();
      }
      else {
        application.confirm(title, message, null, 'warn', {
          labelCancel: (_a = application === null || application === void 0 ? void 0 : application.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage("snkActionsButton.clientEvent.labelCancel"),
          labelConfirm: (_b = application === null || application === void 0 ? void 0 : application.messagesBuilder) === null || _b === void 0 ? void 0 : _b.getMessage("snkActionsButton.clientEvent.labelConfirm")
        }).then(async (confirmResult) => {
          if (confirmResult) {
            param.paramName = CONFIRMACAO;
            param.$ = 'S';
            await recaller.reCall(requestBody);
            resolve();
          }
        });
      }
    });
  }
}

const snkActionsButtonCss = ".sc-snk-actions-button-h{display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";

const SnkActionsButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.CLIENT_EVENT_CONFIRM_NAME = "br.com.sankhya.actionbutton.clientconfirm";
    this._actions = [];
    this.handleClick = (evt) => {
      const selectedAction = this._actions.find((action) => action.actionID == evt.detail.id);
      const executor = new ExecutorFactory(selectedAction.type).executor;
      const action = new Actions(executor, this._dataUnit, this._resourceID);
      action.execute(Object.assign({}, selectedAction));
      this._showDropdown = false;
    };
    this._items = [];
    this._showDropdown = false;
  }
  async getActions() {
    const actions = await ServiceUtils.useCacheWithService(`SnkActionsButton_${this._entityName}-${this._resourceID}`, async () => {
      var _a;
      const param = {
        param: {
          entityName: this._entityName,
          resourceID: this._resourceID,
        },
      };
      const result = await DataFetcher.get().callServiceBroker('ActionButtonsSP.getActions', param);
      return ((_a = result.actions) === null || _a === void 0 ? void 0 : _a.action) || [];
    }, StorageType.IN_MEMORY_CACHE);
    this._actions = SnkActionsButton.parameters.isOrderActions
      ? ArrayUtils.sortAlphabetically(actions, 'description')
      : actions;
  }
  controlDropdown() {
    this._showDropdown = !this._showDropdown;
  }
  canShowDropdown() {
    var _a;
    return this._showDropdown && ((_a = this._items) === null || _a === void 0 ? void 0 : _a.length) > 0;
  }
  positionDropdown() {
    var _a;
    const bounding = (_a = this._ezButton) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
    if (!bounding || !this._dropdownParent)
      return;
    this._dropdownParent.style.top = (bounding.y + bounding.height + 5) + "px";
    this._dropdownParent.style.left = bounding.x + "px";
  }
  closeDropdown(evt) {
    const target = evt === null || evt === void 0 ? void 0 : evt.target;
    if (!target)
      return;
    if (!target.closest(".snk-actions-button")) {
      this._showDropdown = false;
    }
  }
  setEvents() {
    document.removeEventListener("click", this.closeDropdown.bind(this));
    document.addEventListener("click", this.closeDropdown.bind(this));
    document.removeEventListener("scroll", this.positionDropdown.bind(this));
    document.addEventListener("scroll", this.positionDropdown.bind(this));
  }
  async componentWillLoad() {
    var _a, _b;
    this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
    await this.loadParameters();
    const snkDataUnit = this._element.parentElement;
    this._dataUnit = snkDataUnit === null || snkDataUnit === void 0 ? void 0 : snkDataUnit.dataUnit;
    this._resourceID = snkDataUnit === null || snkDataUnit === void 0 ? void 0 : snkDataUnit.resourceID;
    this._entityName = (_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.split('/')[2];
    if (this._resourceID == undefined) {
      this._resourceID = await ResourceIDUtils.getResourceID();
    }
    this.setEvents();
    await this.getActions();
    this.loadItems();
  }
  async componentDidLoad() {
    if (!this._element)
      return;
    ElementIDUtils.addIDInfo(this._element);
    this.positionDropdown();
    if (!(await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))) {
      const clientEventConfirm = new ClientEventConfirm();
      this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME, clientEventConfirm.clientConfirm);
    }
  }
  componentDidUpdate() {
    this.positionDropdown();
  }
  loadItems() {
    if (!this._actions || this._actions.length == 0)
      return;
    this._actions.forEach(action => {
      this._items.push({ id: action.actionID, label: action.description });
    });
  }
  getElementID(sufix) {
    return {
      [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(sufix)
    };
  }
  async loadParameters() {
    if (SnkActionsButton.parameters.isOrderActions != null)
      return;
    SnkActionsButton.parameters.isOrderActions = await this._application.getBooleanParam('global.ordenar.acoes.personalizadas');
  }
  render() {
    return (h(Host, null, (this._actions && this._actions.length > 0) &&
      (h("div", { class: `ez-padding-left--medium snk-actions-button
                            ${this.canShowDropdown() ? " ez-elevation--16" : ""}
                        ` }, h("ez-button", Object.assign({ ref: (ref) => this._ezButton = ref, iconName: "acao", size: "small", mode: "icon", title: this._application.messagesBuilder.getMessage("snkActionsButton.title.actions", undefined), onClick: () => this.controlDropdown() }, this.getElementID("button"))), h("div", Object.assign({ ref: (ref) => this._dropdownParent = ref, class: `${this.canShowDropdown() ?
          "snk-actions-button__dropdown--show" :
          "snk-actions-button__dropdown"}
                            ` }, this.getElementID("dropdown")), (this.canShowDropdown()) &&
        (h("ez-dropdown", Object.assign({ items: this._items, onEzClick: (evt) => this.handleClick(evt) }, this.getElementID("dropdown"))))))), (this.canShowDropdown()) &&
      (h("div", Object.assign({ class: "ez-scrim ez-scrim--light" }, this.getElementID("ezScrim"))))));
  }
  get _element() { return this; }
  static get style() { return snkActionsButtonCss; }
}, [2, "snk-actions-button", {
    "_items": [32],
    "_showDropdown": [32]
  }]);
SnkActionsButton.parameters = {
  isOrderActions: null
};
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["snk-actions-button"];
  components.forEach(tagName => { switch (tagName) {
    case "snk-actions-button":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, SnkActionsButton);
      }
      break;
  } });
}

export { SnkActionsButton as S, defineCustomElement as d };
