/**
 * Copyright Aquera Inc 2023
 *
 * This source code is licensed under the BSD-3-Clause license found in the
 * LICENSE file in the root directory of this source tree.
 */
import { __decorate } from "tslib";
import { html, } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { styles } from './nile-table-cell-item.css';
import NileElement from '../internal/nile-element';
import { HasSlotController } from '../internal/slot';
import { createResizeHandler, resetAllColumnWidths } from '../internal/resizable-table-helper';
/**
 * Nile table Cell Item component.
 *
 * @tag nile-table-cell-item
 *
 */
let NileTableCellItem = class NileTableCellItem extends NileElement {
    constructor() {
        super(...arguments);
        this.hasSlotController = new HasSlotController(this, '[default]');
        /** Enables the resize functionality. */
        this.resizable = false;
        /* #endregion */
        /* #region Methods */
        this.handleResizeStart = createResizeHandler(this, 50);
        /* #endregion */
    }
    /**
     * The styles for TableCellItem
     * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
     */
    static get styles() {
        return [styles];
    }
    updated(changedProperties) {
        super.updated(changedProperties);
        if (changedProperties.has('resizable')) {
            if (!this.resizable) {
                const tableBody = this.closest('nile-table-body');
                if (tableBody) {
                    resetAllColumnWidths(tableBody);
                }
            }
        }
    }
    /**
     * Render method
     * @slot This is a slot test
     */
    render() {
        if (this.resizable) {
            return html `
        <div class="cell__wrapper" part="nile__table-cell">
          ${this.hasSlotController.test('[default]')
                ? html ` <div class="column" part="nile__table-cell"><slot></slot></div>`
                : ''}
          <div class="resizer" @mousedown=${this.handleResizeStart}></div>
        </div>
      `;
        }
        else {
            return html `
        ${this.hasSlotController.test('[default]')
                ? html ` <slot class="column" part="nile__table-cell"> </slot>`
                : ''}
      `;
        }
    }
};
__decorate([
    property({ type: Boolean, reflect: true })
], NileTableCellItem.prototype, "resizable", void 0);
NileTableCellItem = __decorate([
    customElement('nile-table-cell-item')
], NileTableCellItem);
export { NileTableCellItem };
export default NileTableCellItem;
//# sourceMappingURL=nile-table-cell-item.js.map