import { ApplicationContext, Action as DUAction, ElementIDUtils, KeyboardManager, StringUtils } from '@sankhyalabs/core';
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
import { buildFieldSearch } from '@sankhyalabs/ezui/dist/collection/utils';
import { Fragment, h, } from '@stencil/core';
import { CrudUtils } from '../../lib';
import { ExporterStrategy, PresentationMode } from '../../lib/@types';
import { ConfigStorage } from '../../lib/configs/ConfigStorage';
import RmPrecisionCustomValueFormatter from '../../lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter';
import store from "../../lib/store";
import { ContinuousInsertUtils } from '../../lib/utils/ContinuousInsertUtils';
import ClientSideExporterProvider from '../snk-data-exporter/providers/ClientSideExporterProvider';
import ServerSideExporterProvider from '../snk-data-exporter/providers/ServerSideExporterProvider';
import { validateFilters } from '../snk-filter-bar/utils/filter-validate';
import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
import TaskbarProcessor from '../snk-taskbar/processor/taskbar-processor';
import SnkMultiSelectionListDataSource from './filtercolumn/SnkMultiSelectionListDataSource';
export class SnkGrid {
  constructor() {
    this._customEditors = new Map();
    this._customRenders = new Map();
    this._keyboardManager = new KeyboardManager();
    this._topTaskbarProcessor = new TaskbarProcessor({
      'snkGridTopTaskbar.regular': ['FORM_MODE', 'CONFIGURATOR', 'INSERT'],
      'snkGridTopTaskbar.regular.secondary': ['FORM_MODE', 'CONFIGURATOR', 'INSERT'],
      'snkGridTopTaskbar.regular.singleTaskbar': [],
      'snkGridTopTaskbar.finish_edition': ['CANCEL', 'SAVE', this.handleAddFormMode()],
      'snkGridTopTaskbar.finish_edition.secondary': [],
      'snkGridTopTaskbar.finish_edition.singleTaskbar': [],
    });
    this._headerTaskbarProcessor = new TaskbarProcessor({
      'snkGridHeaderTaskbar.unselected': ['REFRESH', 'DATA_EXPORTER', 'ACTIONS_BUTTON', 'MORE_OPTIONS'],
      'snkGridHeaderTaskbar.selected': this.getGridHeaderSelectedBtns(),
      'snkGridHeaderTaskbar.detail.unselected': ['REFRESH', 'ACTIONS_BUTTON', 'MORE_OPTIONS'],
      'snkGridHeaderTaskbar.detail.selected': ['UPDATE', 'ATTACH', 'CLONE', 'REMOVE', 'MORE_OPTIONS', 'DIVIDER', 'REFRESH', 'ACTIONS_BUTTON'],
      'snkGridHeaderTaskbar.singleTaskbar.unselected': ['INSERT', 'FORM_MODE', 'CONFIGURATOR', 'REFRESH', 'DATA_EXPORTER', 'ACTIONS_BUTTON', 'MORE_OPTIONS'],
      'snkGridHeaderTaskbar.singleTaskbar.selected': ['UPDATE', 'CLONE', 'REMOVE', 'MORE_OPTIONS', 'DIVIDER', 'ATTACH', 'FORM_MODE', 'CONFIGURATOR', 'REFRESH', 'DATA_EXPORTER', 'ACTIONS_BUTTON'],
      'snkGridHeaderTaskbar.singleTaskbar.detail.unselected': ['INSERT', 'FORM_MODE', 'CONFIGURATOR', 'REFRESH', 'ACTIONS_BUTTON', 'MORE_OPTIONS'],
      'snkGridHeaderTaskbar.singleTaskbar.detail.selected': ['UPDATE', 'ATTACH', 'CLONE', 'REMOVE', 'MORE_OPTIONS', 'DIVIDER', 'FORM_MODE', 'CONFIGURATOR', 'REFRESH', 'ACTIONS_BUTTON'],
      'snkGridHeaderTaskbar.singleTaskbar.finish_edition': ['CANCEL', 'SAVE', this.handleAddFormMode()],
    });
    this.dataUnitInterceptor = {
      interceptAction: async (action) => {
        if (action.type === DUAction.METADATA_LOADED) {
          return await this.interceptMetadataLoaded(action);
        }
        if (action.type === DUAction.LOADING_DATA) {
          return await this.interceptLoadData(action);
        }
        return action;
      },
    };
    this._dataUnit = undefined;
    this._dataState = undefined;
    this._gridConfig = undefined;
    this._popUpGridConfig = false;
    this._showSnkFilterBar = true;
    this._enableContinuousInsert = false;
    this.columnFilterDataSource = new SnkMultiSelectionListDataSource();
    this.enableLockManagerLoadingComp = false;
    this.enableLockManagerTaskbarClick = false;
    this.configName = undefined;
    this.filterBarTitle = undefined;
    this.resourceID = undefined;
    this.selectionToastConfig = undefined;
    this.actionsList = undefined;
    this.isDetail = undefined;
    this.taskbarManager = undefined;
    this.statusResolver = undefined;
    this.multipleSelection = undefined;
    this.presentationMode = PresentationMode.PRIMARY;
    this.messagesBuilder = undefined;
    this.useEnterLikeTab = false;
    this.recordsValidator = undefined;
    this.canEdit = true;
    this.taskbarCustomContainerId = undefined;
    this.gridHeaderCustomSlotId = 'GRID_HEADER_CUSTOM_ELEMENTS';
    this.topTaskbarCustomSlotId = 'GRID_TASKBAR_CUSTOM_ELEMENTS';
    this.disablePersonalizedFilter = undefined;
    this.gridLegacyConfigName = undefined;
    this.filterBarLegacyConfigName = undefined;
    this.autoLoad = undefined;
    this.autoFocus = true;
    this.enableGridInsert = false;
    this.outlineMode = false;
    this.suppressHorizontalScroll = false;
    this.strategyExporter = ExporterStrategy.SERVER_SIDE;
    this.useSearchColumn = true;
    this.multipleEditionEnabled = true;
    this.paginationCounterMode = 'auto';
    this.suppressCheckboxColumn = undefined;
    this.suppressFilterColumn = false;
    this.compact = undefined;
    this.filterCustomConfig = undefined;
    this.filterCustomConfigInterceptor = undefined;
  }
  getGridHeaderSelectedBtns() {
    const btns = [
      TaskbarElement.UPDATE, TaskbarElement.CLONE, TaskbarElement.REMOVE,
      TaskbarElement.MORE_OPTIONS, TaskbarElement.DIVIDER, TaskbarElement.ATTACH, TaskbarElement.FORM_MODE,
      TaskbarElement.CONFIGURATOR, TaskbarElement.REFRESH, TaskbarElement.DATA_EXPORTER, TaskbarElement.ACTIONS_BUTTON,
    ];
    if (this.multipleEditionEnabled)
      btns.unshift(TaskbarElement.UPDATE_MULTIPLE);
    return btns;
  }
  async refreshColumnFilterDataSource() {
    await this._grid.refreshColumnFilterDataSource();
  }
  /**
   * Recarrega a configuração da grade.
   * @description Este método força o recarregamento da configuração da grade a partir do `ConfigStorage`. A operação é assíncrona, mas o método não aguarda sua conclusão.
   */
  reloadConfig() {
    this.loadConfig();
  }
  /**
   * Exibe a janela de configurações da grade.
   * @async
   * @description Este método abre o pop-up de configuração de colunas da grade, permitindo ao usuário ajustar a visibilidade, ordem e largura das colunas.
   * @returns {Promise<void>} Uma promessa que é resolvida quando a janela de configuração é exibida.
   */
  async showConfig() {
    if (this._grid == undefined) {
      return;
    }
    this.openGridConfig();
  }
  /**
   * Fecha a janela de configurações da grade.
   * @async
   * @description Este método fecha o pop-up de configuração de colunas da grade.
   * @returns {Promise<void>} Uma promessa que é resolvida quando a janela de configuração é fechada.
   */
  async hideConfig() {
    if (this._grid == undefined) {
      return;
    }
    this.closeGridConfig();
  }
  /**
   * Define a configuração da grade.
   * @async
   * @description Aplica uma nova configuração de colunas e ordenação à grade.
   * @param {IGridConfig} config O objeto de configuração a ser aplicado na grade.
   * @returns {Promise<void>} Uma promessa que é resolvida quando a configuração é aplicada.
   */
  async setConfig(config) {
    this.setGridConfig(config);
  }
  /**
   * Recarrega a barra de filtros da grade, buscando o estado do servidor.
   * @async
   * @description Força o recarregamento da barra de filtros, atualizando suas configurações e filtros a partir do servidor.
   * @returns {Promise<void>} Uma promessa que é resolvida quando a barra de filtros é recarregada.
   */
  async reloadFilterBar() {
    var _a;
    (_a = this._snkFilterBar) === null || _a === void 0 ? void 0 : _a.reload();
  }
  /**
   * Retorna o elemento da barra de filtros da grade.
   * @async
   * @description Este método permite acessar o elemento da barra de filtros, que pode ser útil para manipulações adicionais ou para obter o estado atual dos filtros aplicados.
   * @returns {Promise<HTMLSnkFilterBarElement>} O elemento da barra de filtros.
   */
  async getFilterBar() {
    return this._snkFilterBar;
  }
  /**
   * Registra um editor customizado para um campo da grade ou formulário.
   * @async
   * @description Adiciona um componente de edição personalizado para um campo específico. Este editor será usado tanto na edição em linha na grade quanto em formulários de detalhe.
   * @param {string} fieldName O nome do campo que receberá o editor customizado.
   * @param {ICustomEditor} customEditor A instância do editor customizado.
   * @param {string} [detailContext] O contexto de detalhe onde o editor será aplicado (opcional).
   * @returns {Promise<void>} Uma promessa que é resolvida quando o editor é registrado.
   */
  async addCustomEditor(fieldName, customEditor, detailContext) {
    if (this._grid) {
      this._grid.addCustomEditor(fieldName, customEditor, detailContext);
      return;
    }
    const newCustomEditors = new Map(this._customEditors);
    newCustomEditors.set(fieldName, { customEditor, detailContext });
    this._customEditors = newCustomEditors;
  }
  /**
   * Registra um renderizador customizado para uma coluna da grade.
   * @async
   * @description Adiciona um componente de renderização personalizado para uma coluna específica, permitindo a exibição de conteúdo customizado nas células.
   * @param {string} fieldName O nome do campo (coluna) que receberá o renderizador customizado.
   * @param {ICustomRender} customRender A instância do renderizador customizado.
   * @param {string} [detailContext] O contexto de detalhe onde o renderizador será aplicado (opcional).
   * @returns {Promise<void>} Uma promessa que é resolvida quando o renderizador é registrado.
   */
  async addGridCustomRender(fieldName, customRender, detailContext) {
    if (this._grid) {
      this._grid.addGridCustomRender(fieldName, customRender, detailContext);
      return;
    }
    const newCustomRenders = new Map(this._customRenders);
    newCustomRenders.set(fieldName, { customRender, detailContext });
    this._customRenders = newCustomRenders;
  }
  /**
   * Registra um formatador de valor customizado para uma coluna da grade.
   * @async
   * @description Adiciona uma função de formatação personalizada para os valores de uma coluna específica, afetando como os dados são exibidos.
   * @param {string} columnName O nome da coluna que receberá o formatador.
   * @param {ICustomFormatter} customFormatter A instância do formatador de valor.
   * @returns {Promise<void>} Uma promessa que é resolvida quando o formatador é registrado.
   */
  async addCustomValueFormatter(columnName, customFormatter) {
    this._grid.addCustomValueFormatter(columnName, customFormatter);
  }
  /**
   * Remove um formatador de valor customizado de uma coluna da grade.
   * @async
   * @description Remove uma função de formatação personalizada previamente registrada para uma coluna.
   * @param {string} columnName O nome da coluna da qual o formatador será removido.
   * @returns {Promise<void>} Uma promessa que é resolvida quando o formatador é removido.
   */
  async removeCustomValueFormatter(columnName) {
    this._grid.removeCustomValueFormatter(columnName);
  }
  /**
   * Atribui o foco para a grade.
   * @async
   * @description Move o foco do navegador para o componente da grade, permitindo a navegação por teclado.
   * @returns {Promise<void>} Uma promessa que é resolvida quando o foco é atribuído.
   */
  async setFocus() {
    this._grid.setFocus();
  }
  async handleClick(event) {
    var _a;
    if (this.hasToBlockEvent(event)) {
      event.preventDefault();
      event.stopPropagation();
      if (!await this._dataUnit.cancelEdition())
        return;
      const newEvent = new event.constructor(event.type, event);
      (_a = event.target) === null || _a === void 0 ? void 0 : _a.dispatchEvent(newEvent);
    }
    if (this._grid && !this._grid.contains(event.target)) {
      this._grid.stopEdit();
    }
  }
  hasToBlockEvent(event) {
    var _a;
    return ((_a = this._snkFilterBar) === null || _a === void 0 ? void 0 : _a.contains(event.target)) && this.enableGridInsert && this._dataUnit.hasNewRecord();
  }
  async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
    if (!newLegacyConfig) {
      return;
    }
    if (newLegacyConfig === oldLegacyConfig) {
      return;
    }
    this.addGridLegacyConfigName();
    this.loadConfig();
  }
  handleAddFormMode() {
    return this.enableGridInsert ? TaskbarElement.FORM_MODE : '';
  }
  openGridConfig() {
    this._grid.getColumnsState()
      .then((gridColumns) => {
      this._snkGridConfig.columns = gridColumns.filter(c => c.name);
      this._popUpGridConfig = true;
    });
  }
  closeGridConfig() {
    this._popUpGridConfig = false;
  }
  setGridConfig(config) {
    this._gridConfig = config;
    CrudUtils.assertDefaultSorting(this._gridConfig, this._dataUnit);
  }
  fixColumNameCharset(columnName) {
    try {
      return decodeURIComponent(escape(columnName));
    }
    catch (e) {
      return columnName;
    }
  }
  normalizeGridConfig(config) {
    if (!config)
      return config;
    const columnsMapped = config.columns.map(column => (Object.assign(Object.assign({}, column), { name: this.fixColumNameCharset(column.name) })));
    return Object.assign(Object.assign({}, config), { columns: columnsMapped });
  }
  loadConfig() {
    ConfigStorage.loadGridConfig(this.configName, this.resourceID)
      .then((config) => {
      this.setGridConfig(this.normalizeGridConfig(config));
    })
      .catch((error) => {
      console.warn(error);
    });
  }
  addGridLegacyConfigName() {
    if (this.gridLegacyConfigName && this.configName) {
      ConfigStorage.addGridLegacyConfig(this.configName, this.gridLegacyConfigName);
    }
  }
  hasCalculatedFields(columnNames) {
    let hasCalculatedFields = false;
    columnNames.forEach(name => {
      var _a;
      const field = this._dataUnit.getField(name);
      if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.calculated) === 'true') {
        hasCalculatedFields = true;
      }
    });
    return hasCalculatedFields;
  }
  gridConfigChangeHandler(evt) {
    const config = this.normalizeGridConfig(evt.detail);
    ConfigStorage.saveGridConfig(config, this.configName, this.resourceID);
    evt.stopPropagation();
  }
  modalConfigChangeHandler(evt) {
    const config = this.normalizeGridConfig(evt.detail);
    this._grid.setColumnsState(config.columns)
      .then(() => {
      this.setGridConfig(config);
      this.closeGridConfig();
      this.dataExporterProviderStore();
    });
    evt.stopPropagation();
  }
  async hasToForceClientSideExporter() {
    if (!this._grid) {
      return false;
    }
    const filters = await this._grid.getAppliedColumnFilters();
    const columnNames = filters.map(filter => filter.name.replace('FILTRO_COLUNA_', ''));
    return this.hasCalculatedFields(columnNames);
  }
  async dataExporterProviderStore() {
    /**
     * O ServerSideExporterProvider do SankhyaOm não suporta a filtragem de campos calculados.
     * Por esse motivo, precisamos verificar os filtros aplicados no momento e recriar o dataExporterProvider conforme necessário.
     * Se houver campos calculados, forçamos o uso do clientSide, caso contrário é seguido o fluxo padrão.
     */
    const forceClientSide = await this.hasToForceClientSideExporter();
    const dataExporterProvider = (forceClientSide || this.strategyExporter === ExporterStrategy.CLIENT_SIDE)
      ? new ClientSideExporterProvider(this._dataUnit, this._grid)
      : new ServerSideExporterProvider(this._dataUnit, this._grid);
    store.set('exporterProviders', Object.assign(Object.assign({}, store.get('exporterProviders')), { [this.configName]: dataExporterProvider }));
  }
  addElementID() {
    const dataInfo = { dataUnit: this._dataUnit };
    ElementIDUtils.addIDInfo(this._element, null, dataInfo);
  }
  loadGridCustomFormatters(fields) {
    if (!fields || !this._grid) {
      return;
    }
    fields.forEach((field) => {
      var _a;
      if ((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) {
        this.addCustomValueFormatter(field.name, this._rmPrecisionCustomValueFormatter);
      }
    });
  }
  async interceptMetadataLoaded(action) {
    this.loadGridCustomFormatters(action.payload.fields);
    return action;
  }
  async interceptLoadData(action) {
    var _a;
    const hasInvalidFilters = !validateFilters((_a = this._snkFilterBar) === null || _a === void 0 ? void 0 : _a.filterConfig);
    if (hasInvalidFilters) {
      const errorTitle = this.messagesBuilder.getMessage("snkGrid.requiredFiltersNotFilled.title", {});
      const errorMessage = this.messagesBuilder.getMessage("snkGrid.requiredFiltersNotFilled.message", {});
      await this._application.error(errorTitle, errorMessage);
      return;
    }
    return action;
  }
  finishLoading() {
    this._dataUnit.addInterceptor(this.dataUnitInterceptor);
    CrudUtils.assertDefaultSorting(this._gridConfig, this._dataUnit);
    this.addElementID();
    if (this.columnFilterDataSource != undefined) {
      this.columnFilterDataSource.setApplication(this._application);
      this.columnFilterDataSource.setDataUnit(this._dataUnit);
    }
  }
  setCustomRenders() {
    if (!this._grid) {
      return;
    }
    for (const [fieldName, customRenderProps] of this._customRenders) {
      this._grid.addGridCustomRender(fieldName, customRenderProps.customRender, customRenderProps.detailContext);
      this._customRenders.delete(fieldName);
    }
  }
  setCustomEditors() {
    if (!this._grid) {
      return;
    }
    for (const [fieldName, customEditorProps] of this._customEditors) {
      this._grid.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
      this._customEditors.delete(fieldName);
    }
  }
  componentWillLoad() {
    this._application = ApplicationContext.getContextValue('__SNK__APPLICATION__');
    //TODO: substituir pelo metodo nativo closest
    let parent = this._element.parentElement;
    while (parent) {
      if (parent.tagName.toUpperCase() === 'SNK-DATA-UNIT') {
        this._snkDataUnit = parent;
        this._dataUnit = this._snkDataUnit.dataUnit;
        if (!this._dataUnit) {
          this._snkDataUnit.addEventListener('dataUnitReady', (evt) => {
            this._dataUnit = evt.detail;
            this.finishLoading();
          });
        }
        else {
          this.finishLoading();
        }
        if (!this.messagesBuilder)
          this.messagesBuilder = this._snkDataUnit.messagesBuilder;
        this._snkDataUnit.addEventListener('dataStateChange', this.handleDataStateChange.bind(this));
        this._snkDataUnit.addEventListener('cancelEdition', () => {
          var _a;
          if ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.recordsIsEmpty) {
            this._dataUnit.clearSelection();
          }
        });
        break;
      }
      parent = parent.parentElement;
    }
    this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
    this.addGridLegacyConfigName();
    this.loadConfig();
    this._continuousInsertUtils = new ContinuousInsertUtils(this._application, this.resourceID, this.configName);
    if (this.enableGridInsert) {
      this._continuousInsertUtils.getConfig().then(value => this._enableContinuousInsert = value);
    }
  }
  componentDidRender() {
    var _a, _b;
    this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
    this.loadGridCustomFormatters((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.fields);
    this.setCustomRenders();
    this.setCustomEditors();
  }
  async handleDataStateChange(evt) {
    this._dataState = evt.detail;
    this._rmPrecisionCustomValueFormatter.setDataState(this._dataState);
  }
  getHeaderDisabledButtons() {
    var _a;
    const disabledButtons = [];
    if ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.selectionInfo) {
      if (this._dataState.selectionInfo.length > 1) {
        disabledButtons.push(TaskbarElement.CLONE, TaskbarElement.ATTACH, TaskbarElement.UPDATE);
      }
      if (this._dataState.selectionInfo.isAllRecords()) {
        disabledButtons.push(TaskbarElement.REMOVE);
      }
    }
    return disabledButtons;
  }
  getInvisibleButtons() {
    var _a, _b;
    let invisibleButtons = [];
    if (!this._dataUnit || this._dataUnit.records.length === 0)
      invisibleButtons.push(TaskbarElement.DATA_EXPORTER);
    if (((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.selectionInfo.mode) === SelectionMode.ALL_RECORDS)
      invisibleButtons.push(TaskbarElement.ACTIONS_BUTTON);
    if (((_b = this._dataState) === null || _b === void 0 ? void 0 : _b.selectionInfo.length) === 1)
      invisibleButtons.push(TaskbarElement.UPDATE_MULTIPLE);
    return invisibleButtons;
  }
  componentWillRender() {
    const invisibleButtons = this.getInvisibleButtons();
    this._headerTaskbarProcessor.process(this.getHeaderTaskbarId(), this.taskbarManager, this._dataState, this.getHeaderDisabledButtons(), invisibleButtons);
    this._topTaskbarProcessor.process(this.getTopTaskBarId(), this.taskbarManager, this._dataState, undefined, invisibleButtons);
    this.dataExporterProviderStore();
  }
  getHeaderTaskbarId() {
    var _a, _b;
    const hasSelectedRecord = this._dataState && !!((_a = this._dataState.selectionInfo) === null || _a === void 0 ? void 0 : _a.length);
    const taskbarIdPrefixLookup = {
      primary: this.isDetail ? 'snkGridHeaderTaskbar.detail' : 'snkGridHeaderTaskbar',
      secondary: this.isDetail ? 'snkGridHeaderTaskbar.detail' : 'snkGridHeaderTaskbar',
      singleTaskbar: this.isDetail ? 'snkGridHeaderTaskbar.singleTaskbar.detail' : 'snkGridHeaderTaskbar.singleTaskbar',
    };
    const taskbarIdPrefix = taskbarIdPrefixLookup[this.presentationMode];
    let headerTaskbarId = hasSelectedRecord ? `${taskbarIdPrefix}.selected` : `${taskbarIdPrefix}.unselected`;
    if (((_b = this._dataState) === null || _b === void 0 ? void 0 : _b.isDirty) && this.presentationMode === PresentationMode.SINGLE_TASKBAR) {
      headerTaskbarId = 'snkGridHeaderTaskbar.singleTaskbar.finish_edition';
    }
    return headerTaskbarId;
  }
  getTopTaskBarId() {
    var _a;
    const suffixLookup = {
      primary: '',
      secondary: '.secondary',
      singleTaskbar: '.singleTaskbar',
    };
    const sufix = suffixLookup[this.presentationMode];
    if ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
      return `snkGridTopTaskbar.finish_edition${sufix}`;
    }
    return `snkGridTopTaskbar.regular${sufix}`;
  }
  getPrimaryButton() {
    const primaryButtonLookup = {
      primary: 'INSERT',
      secondary: '',
      singleTaskbar: 'INSERT',
    };
    return primaryButtonLookup[this.presentationMode];
  }
  getColumnSearch(item) {
    if (this._columnSearch != undefined) {
      return this._columnSearch;
    }
    this._columnSearch = buildFieldSearch(item, ({ argument }) => new Promise(accept => {
      this._grid.filterColumns(argument).then((columns) => {
        accept(columns
          .filter(column => !column.hidden)
          .map(column => ({ label: column.label, value: column.name })));
      });
    }), (option) => {
      if (option != undefined) {
        this._grid.locateColumn(option.value);
      }
    });
    return this._columnSearch;
  }
  getActionsList() {
    const hardList = [];
    if (this.enableGridInsert) {
      hardList.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert, () => {
        this._enableContinuousInsert = !this._enableContinuousInsert;
        this._continuousInsertUtils.handleSaveConfig(this._enableContinuousInsert);
      }));
    }
    if (this.isGridInsertActive())
      return hardList;
    if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
      const taskbarID = this.getTopTaskBarId();
      return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this._dataState, this.actionsList));
    }
    return hardList.concat(this.actionsList);
  }
  getActionsSettingsList() {
    const hardList = [{
        value: StringUtils.generateUUID(),
        label: this.messagesBuilder.getMessage('snkGrid.findColumn', {}),
        disableCloseOnSelect: true,
        eagerInitialize: true,
        itemBuilder: (_, item) => this.getColumnSearch(item),
      }];
    return hardList;
  }
  handleFilterConfigUpdated(filterConfig) {
    if (!filterConfig.length) {
      this._showSnkFilterBar = false;
      return;
    }
    if (filterConfig.length === 1 && filterConfig[0].id === 'PERSONALIZED_FILTER_GROUP') {
      this._showSnkFilterBar = filterConfig[0].groupedItems.length > 0;
      return;
    }
    this._showSnkFilterBar = true;
  }
  getGridHeaderButtons() {
    if (this.isGridInsertActive())
      return TaskbarElement.MORE_OPTIONS;
    return this._headerTaskbarProcessor.buttons;
  }
  isGridInsertActive() {
    return this.enableGridInsert && this._dataUnit.hasNewRecord();
  }
  render() {
    if (!this._dataUnit) {
      return undefined;
    }
    return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large ez-box--no-outline", tabindex: "0" }, h("div", { class: "snk-grid__header" }, this._showSnkFilterBar &&
      h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad, enableLockManagerLoadingComp: this.enableLockManagerLoadingComp, filterCustomConfig: this.filterCustomConfig, filterCustomConfigInterceptor: this.filterCustomConfigInterceptor }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium ez-padding-top--extra-small", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none', actionsSettingsList: this.getActionsSettingsList() }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? 'snk-grid-container__without-shadow ' : '') + 'snk-grid__table', "data-element-id": "embedded", dataUnit: this._dataUnit, key: 'grid-' + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => {
        this.gridConfigChangeHandler(evt);
      }, onEzColumnFilterChanged: async () => await this.dataExporterProviderStore(), onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManagerTaskbarClick: this.enableLockManagerTaskbarClick, enableLockManagerLoadingComp: this.enableLockManagerLoadingComp, outlineMode: this.outlineMode, useSearchColumn: this.useSearchColumn, suppressHorizontalScroll: this.suppressHorizontalScroll, paginationCounterMode: this.paginationCounterMode, suppressCheckboxColumn: this.suppressCheckboxColumn, suppressFilterColumn: this.suppressFilterColumn, compact: this.compact }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this.getGridHeaderButtons(), presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId, actionsSettingsList: this.getActionsSettingsList() }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12 snk-grid-container__footer" }, h("slot", { name: "SnkGridFooter" })), h("ez-popup", { size: "medium", heightMode: "auto", useHeader: false, opened: this._popUpGridConfig, onEzClosePopup: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
  }
  static get is() { return "snk-grid"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() {
    return {
      "$": ["snk-grid.css"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["snk-grid.css"]
    };
  }
  static get properties() {
    return {
      "columnFilterDataSource": {
        "type": "unknown",
        "mutable": true,
        "complexType": {
          "original": "IMultiSelectionListDataSource",
          "resolved": "IMultiSelectionListDataSource",
          "references": {
            "IMultiSelectionListDataSource": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/components/ez-multi-selection-list/interfaces/IMultiSelectionListDataSource"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o data source para o filtro de colunas."
        },
        "defaultValue": "new SnkMultiSelectionListDataSource()"
      },
      "enableLockManagerLoadingComp": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Define se o componente deve usar o LockManager para controle de carregamento da aplica\u00E7\u00E3o."
        },
        "attribute": "enable-lock-manager-loading-comp",
        "reflect": false,
        "defaultValue": "false"
      },
      "enableLockManagerTaskbarClick": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Ativa o gerenciamento de locks na grade pela Taskbar."
        },
        "attribute": "enable-lock-manager-taskbar-click",
        "reflect": false,
        "defaultValue": "false"
      },
      "configName": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Nome usado para salvar e recuperar a configura\u00E7\u00E3o da grade."
        },
        "attribute": "config-name",
        "reflect": false
      },
      "filterBarTitle": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "T\u00EDtulo que ser\u00E1 apresentado na barra de filtros."
        },
        "attribute": "filter-bar-title",
        "reflect": false
      },
      "resourceID": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Identificador de recursos, como configura\u00E7\u00F5es e permiss\u00F5es de acesso."
        },
        "attribute": "resource-i-d",
        "reflect": false
      },
      "selectionToastConfig": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "ISelectionToastConfig",
          "resolved": "ISelectionToastConfig",
          "references": {
            "ISelectionToastConfig": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/components/ez-grid/interfaces"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Configura\u00E7\u00E3o do toast de sele\u00E7\u00E3o da grade."
        }
      },
      "actionsList": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "Array<Action>",
          "resolved": "Action[]",
          "references": {
            "Array": {
              "location": "global"
            },
            "Action": {
              "location": "import",
              "path": "../snk-taskbar/snk-taskbar"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Lista de a\u00E7\u00F5es que devem ser usadas no bot\u00E3o \"Mais op\u00E7\u00F5es\" do `snk-taskbar`."
        }
      },
      "isDetail": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Determina se a grade est\u00E1 vinculada a um detalhe de outra tela."
        },
        "attribute": "is-detail",
        "reflect": false
      },
      "taskbarManager": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "TaskbarManager",
          "resolved": "TaskbarManager",
          "references": {
            "TaskbarManager": {
              "location": "import",
              "path": "../snk-taskbar/snk-taskbar"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Gerenciador das barras de tarefas. Permite determinar bot\u00F5es espec\u00EDficos\nou gerenciar o estado dos bot\u00F5es."
        }
      },
      "statusResolver": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "IStatusResolver | StatusResolverFunction",
          "resolved": "((data: object) => string) | IStatusResolver",
          "references": {
            "IStatusResolver": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/components/ez-grid/controller/EzGridController"
            },
            "StatusResolverFunction": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/components/ez-grid/controller/EzGridController"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [{
              "name": "example",
              "text": "```json\n'{ \"RECDESP\": { \"-1\" : \"#BD0025\", \"1\" : \"#157A00\" } }'\n```"
            }],
          "text": "Define a configura\u00E7\u00E3o de cores para a coluna de status."
        }
      },
      "multipleSelection": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Determina se a sele\u00E7\u00E3o de m\u00FAltiplas linhas \u00E9 permitida."
        },
        "attribute": "multiple-selection",
        "reflect": false
      },
      "presentationMode": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "PresentationMode",
          "resolved": "PresentationMode.PRIMARY | PresentationMode.SECONDARY | PresentationMode.SINGLE_TASKBAR",
          "references": {
            "PresentationMode": {
              "location": "import",
              "path": "../../lib/@types"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Altera o modo de apresenta\u00E7\u00E3o dos bot\u00F5es do `snk-taskbar`."
        },
        "attribute": "presentation-mode",
        "reflect": false,
        "defaultValue": "PresentationMode.PRIMARY"
      },
      "messagesBuilder": {
        "type": "unknown",
        "mutable": true,
        "complexType": {
          "original": "SnkMessageBuilder",
          "resolved": "SnkMessageBuilder",
          "references": {
            "SnkMessageBuilder": {
              "location": "import",
              "path": "../../lib/message/SnkMessageBuilder"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Respons\u00E1vel por flexibilizar e padronizar o uso de mensagens nos blocos de constru\u00E7\u00E3o."
        }
      },
      "useEnterLikeTab": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Quando `true`, a tecla ENTER navega entre as c\u00E9lulas como a tecla TAB."
        },
        "attribute": "use-enter-like-tab",
        "reflect": false,
        "defaultValue": "false"
      },
      "recordsValidator": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "IRecordValidator",
          "resolved": "IRecordValidator",
          "references": {
            "IRecordValidator": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/utils/form/interfaces"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Validador respons\u00E1vel por verificar a integridade dos dados de um registro."
        }
      },
      "canEdit": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define se a edi\u00E7\u00E3o de dados na grade est\u00E1 habilitada."
        },
        "attribute": "can-edit",
        "reflect": false,
        "defaultValue": "true"
      },
      "taskbarCustomContainerId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o identificador do cont\u00EAiner de elementos customizados da `Taskbar`."
        },
        "attribute": "taskbar-custom-container-id",
        "reflect": false
      },
      "gridHeaderCustomSlotId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o nome do slot para elementos customizados na `Taskbar` do cabe\u00E7alho da grade."
        },
        "attribute": "grid-header-custom-slot-id",
        "reflect": false,
        "defaultValue": "'GRID_HEADER_CUSTOM_ELEMENTS'"
      },
      "topTaskbarCustomSlotId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o nome do slot para elementos customizados na `Taskbar` principal do componente."
        },
        "attribute": "top-taskbar-custom-slot-id",
        "reflect": false,
        "defaultValue": "'GRID_TASKBAR_CUSTOM_ELEMENTS'"
      },
      "disablePersonalizedFilter": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Desabilita a apresenta\u00E7\u00E3o da op\u00E7\u00E3o de filtros personalizados na barra de filtros (chip de filtros)\ne no modal lateral de filtros (cont\u00EAiner de filtros personalizados)."
        },
        "attribute": "disable-personalized-filter",
        "reflect": false
      },
      "gridLegacyConfigName": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Chave da configura\u00E7\u00E3o legada da grade."
        },
        "attribute": "grid-legacy-config-name",
        "reflect": false
      },
      "filterBarLegacyConfigName": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Chave da configura\u00E7\u00E3o legada da barra de filtros."
        },
        "attribute": "filter-bar-legacy-config-name",
        "reflect": false
      },
      "autoLoad": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Define se os dados ser\u00E3o carregados automaticamente na inicializa\u00E7\u00E3o do componente."
        },
        "attribute": "auto-load",
        "reflect": false
      },
      "autoFocus": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Define se a grade receber\u00E1 o foco automaticamente ao ser carregada."
        },
        "attribute": "auto-focus",
        "reflect": false,
        "defaultValue": "true"
      },
      "enableGridInsert": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Habilita a inser\u00E7\u00E3o de registros diretamente na grade."
        },
        "attribute": "enable-grid-insert",
        "reflect": false,
        "defaultValue": "false"
      },
      "outlineMode": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Altera a apar\u00EAncia das bordas e sombras do componente.\nSe `false`, aplica o padr\u00E3o de sombras (ideal para o elemento principal do layout).\nSe `true`, aplica um contorno (ideal para quando o componente est\u00E1 dentro de outro, como um painel ou pop-up)."
        },
        "attribute": "outline-mode",
        "reflect": false,
        "defaultValue": "false"
      },
      "suppressHorizontalScroll": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define se a grade deve suprimir a barra de rolagem horizontal."
        },
        "attribute": "suppress-horizontal-scroll",
        "reflect": false,
        "defaultValue": "false"
      },
      "strategyExporter": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "IExporterStrategyMode",
          "resolved": "\"ClientSideExporterStrategy\" | \"ServerSideExporterStrategy\"",
          "references": {
            "IExporterStrategyMode": {
              "location": "import",
              "path": "../snk-data-exporter/interfaces/IRecordID"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o modo de exporta\u00E7\u00E3o dos dados."
        },
        "attribute": "strategy-exporter",
        "reflect": false,
        "defaultValue": "ExporterStrategy.SERVER_SIDE"
      },
      "useSearchColumn": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define se a grade deve exibir um buscador de colunas ao pressionar `Ctrl+F`."
        },
        "attribute": "use-search-column",
        "reflect": false,
        "defaultValue": "true"
      },
      "multipleEditionEnabled": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Habilita a edi\u00E7\u00E3o de m\u00FAltiplos registros simultaneamente."
        },
        "attribute": "multiple-edition-enabled",
        "reflect": false,
        "defaultValue": "true"
      },
      "paginationCounterMode": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "'show' | 'hidden' | 'auto'",
          "resolved": "\"auto\" | \"hidden\" | \"show\"",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Define o modo de exibi\u00E7\u00E3o do contador de pagina\u00E7\u00E3o."
        },
        "attribute": "pagination-counter-mode",
        "reflect": false,
        "defaultValue": "'auto'"
      },
      "suppressCheckboxColumn": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Informa se a coluna de checkbox deve ser suprimida."
        },
        "attribute": "suppress-checkbox-column",
        "reflect": false
      },
      "suppressFilterColumn": {
        "type": "boolean",
        "mutable": true,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Informa se a grade deve suprimir o filtro de coluna."
        },
        "attribute": "suppress-filter-column",
        "reflect": false,
        "defaultValue": "false"
      },
      "compact": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define se a grade deve ser exibida em modo compacto."
        },
        "attribute": "compact",
        "reflect": false
      },
      "filterCustomConfig": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "Array<SnkFilterItemConfig>",
          "resolved": "SnkFilterItemConfig[]",
          "references": {
            "Array": {
              "location": "global"
            },
            "SnkFilterItemConfig": {
              "location": "import",
              "path": "../snk-filter-bar/filter-item/snk-filter-item"
            }
          }
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [{
              "name": "description",
              "text": "Configura\u00E7\u00E3o customizada dos filtros."
            }, {
              "name": "param",
              "text": "config - Lista de configura\u00E7\u00F5es de filtros."
            }],
          "text": ""
        }
      },
      "filterCustomConfigInterceptor": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "(config: Array<SnkFilterItemConfig>) => Array<SnkFilterItemConfig>",
          "resolved": "(config: SnkFilterItemConfig[]) => SnkFilterItemConfig[]",
          "references": {
            "Array": {
              "location": "global"
            },
            "SnkFilterItemConfig": {
              "location": "import",
              "path": "../snk-filter-bar/filter-item/snk-filter-item"
            }
          }
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [{
              "name": "description",
              "text": "Intercepta a configura\u00E7\u00E3o dos filtros antes de serem aplicadas."
            }, {
              "name": "param",
              "text": "config - Lista de configura\u00E7\u00F5es de filtros."
            }, {
              "name": "returns",
              "text": "Retorna a lista de configura\u00E7\u00F5es de filtros."
            }],
          "text": ""
        }
      }
    };
  }
  static get states() {
    return {
      "_dataUnit": {},
      "_dataState": {},
      "_gridConfig": {},
      "_popUpGridConfig": {},
      "_showSnkFilterBar": {},
      "_enableContinuousInsert": {}
    };
  }
  static get events() {
    return [{
        "method": "actionClick",
        "name": "actionClick",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [{
              "name": "description",
              "text": "Este evento \u00E9 acionado quando o usu\u00E1rio clica em um bot\u00E3o de a\u00E7\u00E3o ou item de menu na grade, permitindo a execu\u00E7\u00E3o de a\u00E7\u00F5es espec\u00EDficas."
            }, {
              "name": "param",
              "text": "detail - O identificador da a\u00E7\u00E3o clicada, que pode ser usado para determinar qual a\u00E7\u00E3o executar."
            }],
          "text": "Emitido ao clicar em um bot\u00E3o de a\u00E7\u00E3o ou item de menu."
        },
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        }
      }, {
        "method": "gridDoubleClick",
        "name": "gridDoubleClick",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [{
              "name": "description",
              "text": "Este evento \u00E9 acionado quando o usu\u00E1rio clica duas vezes em uma linha da grade, permitindo a\u00E7\u00F5es como edi\u00E7\u00E3o r\u00E1pida ou visualiza\u00E7\u00E3o de detalhes."
            }, {
              "name": "param",
              "text": "detail - Detalhes do evento, contendo a linha clicada."
            }],
          "text": "Emitido ao realizar um duplo clique em uma linha da grade."
        },
        "complexType": {
          "original": "any",
          "resolved": "any",
          "references": {}
        }
      }, {
        "method": "componentReady",
        "name": "componentReady",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": "Emitido quando o componente estiver completamente carregado."
        },
        "complexType": {
          "original": "void",
          "resolved": "void",
          "references": {}
        }
      }];
  }
  static get methods() {
    return {
      "refreshColumnFilterDataSource": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "",
          "tags": []
        }
      },
      "reloadConfig": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {},
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Recarrega a configura\u00E7\u00E3o da grade.",
          "tags": [{
              "name": "description",
              "text": "Este m\u00E9todo for\u00E7a o recarregamento da configura\u00E7\u00E3o da grade a partir do `ConfigStorage`. A opera\u00E7\u00E3o \u00E9 ass\u00EDncrona, mas o m\u00E9todo n\u00E3o aguarda sua conclus\u00E3o."
            }]
        }
      },
      "showConfig": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Exibe a janela de configura\u00E7\u00F5es da grade.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "Este m\u00E9todo abre o pop-up de configura\u00E7\u00E3o de colunas da grade, permitindo ao usu\u00E1rio ajustar a visibilidade, ordem e largura das colunas."
            }, {
              "name": "returns",
              "text": "Uma promessa que \u00E9 resolvida quando a janela de configura\u00E7\u00E3o \u00E9 exibida."
            }]
        }
      },
      "hideConfig": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Fecha a janela de configura\u00E7\u00F5es da grade.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "Este m\u00E9todo fecha o pop-up de configura\u00E7\u00E3o de colunas da grade."
            }, {
              "name": "returns",
              "text": "Uma promessa que \u00E9 resolvida quando a janela de configura\u00E7\u00E3o \u00E9 fechada."
            }]
        }
      },
      "setConfig": {
        "complexType": {
          "signature": "(config: IGridConfig) => Promise<void>",
          "parameters": [{
              "tags": [{
                  "name": "param",
                  "text": "config O objeto de configura\u00E7\u00E3o a ser aplicado na grade."
                }],
              "text": "O objeto de configura\u00E7\u00E3o a ser aplicado na grade."
            }],
          "references": {
            "Promise": {
              "location": "global"
            },
            "IGridConfig": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/components/ez-grid/controller/EzGridController"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Define a configura\u00E7\u00E3o da grade.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "Aplica uma nova configura\u00E7\u00E3o de colunas e ordena\u00E7\u00E3o \u00E0 grade."
            }, {
              "name": "param",
              "text": "config O objeto de configura\u00E7\u00E3o a ser aplicado na grade."
            }, {
              "name": "returns",
              "text": "Uma promessa que \u00E9 resolvida quando a configura\u00E7\u00E3o \u00E9 aplicada."
            }]
        }
      },
      "reloadFilterBar": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Recarrega a barra de filtros da grade, buscando o estado do servidor.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "For\u00E7a o recarregamento da barra de filtros, atualizando suas configura\u00E7\u00F5es e filtros a partir do servidor."
            }, {
              "name": "returns",
              "text": "Uma promessa que \u00E9 resolvida quando a barra de filtros \u00E9 recarregada."
            }]
        }
      },
      "getFilterBar": {
        "complexType": {
          "signature": "() => Promise<HTMLSnkFilterBarElement>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            },
            "HTMLSnkFilterBarElement": {
              "location": "global"
            }
          },
          "return": "Promise<HTMLSnkFilterBarElement>"
        },
        "docs": {
          "text": "Retorna o elemento da barra de filtros da grade.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "Este m\u00E9todo permite acessar o elemento da barra de filtros, que pode ser \u00FAtil para manipula\u00E7\u00F5es adicionais ou para obter o estado atual dos filtros aplicados."
            }, {
              "name": "returns",
              "text": "O elemento da barra de filtros."
            }]
        }
      },
      "addCustomEditor": {
        "complexType": {
          "signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
          "parameters": [{
              "tags": [{
                  "name": "param",
                  "text": "fieldName O nome do campo que receber\u00E1 o editor customizado."
                }],
              "text": "O nome do campo que receber\u00E1 o editor customizado."
            }, {
              "tags": [{
                  "name": "param",
                  "text": "customEditor A inst\u00E2ncia do editor customizado."
                }],
              "text": "A inst\u00E2ncia do editor customizado."
            }, {
              "tags": [{
                  "name": "param",
                  "text": "detailContext O contexto de detalhe onde o editor ser\u00E1 aplicado (opcional)."
                }],
              "text": "O contexto de detalhe onde o editor ser\u00E1 aplicado (opcional)."
            }],
          "references": {
            "Promise": {
              "location": "global"
            },
            "ICustomEditor": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/utils"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Registra um editor customizado para um campo da grade ou formul\u00E1rio.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "Adiciona um componente de edi\u00E7\u00E3o personalizado para um campo espec\u00EDfico. Este editor ser\u00E1 usado tanto na edi\u00E7\u00E3o em linha na grade quanto em formul\u00E1rios de detalhe."
            }, {
              "name": "param",
              "text": "fieldName O nome do campo que receber\u00E1 o editor customizado."
            }, {
              "name": "param",
              "text": "customEditor A inst\u00E2ncia do editor customizado."
            }, {
              "name": "param",
              "text": "detailContext O contexto de detalhe onde o editor ser\u00E1 aplicado (opcional)."
            }, {
              "name": "returns",
              "text": "Uma promessa que \u00E9 resolvida quando o editor \u00E9 registrado."
            }]
        }
      },
      "addGridCustomRender": {
        "complexType": {
          "signature": "(fieldName: string, customRender: ICustomRender, detailContext?: string) => Promise<void>",
          "parameters": [{
              "tags": [{
                  "name": "param",
                  "text": "fieldName O nome do campo (coluna) que receber\u00E1 o renderizador customizado."
                }],
              "text": "O nome do campo (coluna) que receber\u00E1 o renderizador customizado."
            }, {
              "tags": [{
                  "name": "param",
                  "text": "customRender A inst\u00E2ncia do renderizador customizado."
                }],
              "text": "A inst\u00E2ncia do renderizador customizado."
            }, {
              "tags": [{
                  "name": "param",
                  "text": "detailContext O contexto de detalhe onde o renderizador ser\u00E1 aplicado (opcional)."
                }],
              "text": "O contexto de detalhe onde o renderizador ser\u00E1 aplicado (opcional)."
            }],
          "references": {
            "Promise": {
              "location": "global"
            },
            "ICustomRender": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/utils"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Registra um renderizador customizado para uma coluna da grade.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "Adiciona um componente de renderiza\u00E7\u00E3o personalizado para uma coluna espec\u00EDfica, permitindo a exibi\u00E7\u00E3o de conte\u00FAdo customizado nas c\u00E9lulas."
            }, {
              "name": "param",
              "text": "fieldName O nome do campo (coluna) que receber\u00E1 o renderizador customizado."
            }, {
              "name": "param",
              "text": "customRender A inst\u00E2ncia do renderizador customizado."
            }, {
              "name": "param",
              "text": "detailContext O contexto de detalhe onde o renderizador ser\u00E1 aplicado (opcional)."
            }, {
              "name": "returns",
              "text": "Uma promessa que \u00E9 resolvida quando o renderizador \u00E9 registrado."
            }]
        }
      },
      "addCustomValueFormatter": {
        "complexType": {
          "signature": "(columnName: string, customFormatter: ICustomFormatter) => Promise<void>",
          "parameters": [{
              "tags": [{
                  "name": "param",
                  "text": "columnName O nome da coluna que receber\u00E1 o formatador."
                }],
              "text": "O nome da coluna que receber\u00E1 o formatador."
            }, {
              "tags": [{
                  "name": "param",
                  "text": "customFormatter A inst\u00E2ncia do formatador de valor."
                }],
              "text": "A inst\u00E2ncia do formatador de valor."
            }],
          "references": {
            "Promise": {
              "location": "global"
            },
            "ICustomFormatter": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/components/ez-grid/interfaces"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Registra um formatador de valor customizado para uma coluna da grade.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "Adiciona uma fun\u00E7\u00E3o de formata\u00E7\u00E3o personalizada para os valores de uma coluna espec\u00EDfica, afetando como os dados s\u00E3o exibidos."
            }, {
              "name": "param",
              "text": "columnName O nome da coluna que receber\u00E1 o formatador."
            }, {
              "name": "param",
              "text": "customFormatter A inst\u00E2ncia do formatador de valor."
            }, {
              "name": "returns",
              "text": "Uma promessa que \u00E9 resolvida quando o formatador \u00E9 registrado."
            }]
        }
      },
      "removeCustomValueFormatter": {
        "complexType": {
          "signature": "(columnName: string) => Promise<void>",
          "parameters": [{
              "tags": [{
                  "name": "param",
                  "text": "columnName O nome da coluna da qual o formatador ser\u00E1 removido."
                }],
              "text": "O nome da coluna da qual o formatador ser\u00E1 removido."
            }],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Remove um formatador de valor customizado de uma coluna da grade.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "Remove uma fun\u00E7\u00E3o de formata\u00E7\u00E3o personalizada previamente registrada para uma coluna."
            }, {
              "name": "param",
              "text": "columnName O nome da coluna da qual o formatador ser\u00E1 removido."
            }, {
              "name": "returns",
              "text": "Uma promessa que \u00E9 resolvida quando o formatador \u00E9 removido."
            }]
        }
      },
      "setFocus": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Atribui o foco para a grade.",
          "tags": [{
              "name": "async",
              "text": undefined
            }, {
              "name": "description",
              "text": "Move o foco do navegador para o componente da grade, permitindo a navega\u00E7\u00E3o por teclado."
            }, {
              "name": "returns",
              "text": "Uma promessa que \u00E9 resolvida quando o foco \u00E9 atribu\u00EDdo."
            }]
        }
      }
    };
  }
  static get elementRef() { return "_element"; }
  static get watchers() {
    return [{
        "propName": "gridLegacyConfigName",
        "methodName": "handleGridLegacyConfigName"
      }];
  }
  static get listeners() {
    return [{
        "name": "click",
        "method": "handleClick",
        "target": undefined,
        "capture": true,
        "passive": false
      }];
  }
}
