/**
 * Copyright Aquera Inc 2025
 *
 * 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-grid-cell-item.css';
import NileElement from '../../internal/nile-element';
import { initCellResize, cellResizeMove, cellResizeDone, } from './nile-grid-cell-item.utils';
/**
 * Nile grid-cell component.
 *
 * @tag nile-grid-cell-item
 *
 */
let NileGridCellItem = class NileGridCellItem extends NileElement {
    constructor() {
        super(...arguments);
        this.colspan = 1;
        this.rowspan = 1;
        this.resizable = false;
        this.onHandlePointerDown = (ev) => {
            const el = this;
            const downXRef = { value: 0 };
            const startWRef = { value: 0 };
            const result = initCellResize(el, ev, downXRef, startWRef);
            if (!result)
                return;
            const { target, col } = result;
            const move = (e) => cellResizeMove(el, col, startWRef.value, downXRef.value, e);
            const done = () => cellResizeDone(el, col, ev, target, move);
            target.addEventListener('pointermove', move);
            target.addEventListener('pointerup', done, { once: true });
            target.addEventListener('pointercancel', done, { once: true });
        };
        /* #endregion */
    }
    /**
     * The styles for nile-grid-cell-item
     * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
     */
    static get styles() {
        return [styles];
    }
    connectedCallback() {
        super.connectedCallback();
        this.setAttribute('role', 'cell');
    }
    render() {
        return html `
      <div class="cell-item-base" part="grid-cell-item-base">
        <slot></slot>
        ${this.resizable
            ? html `
              <div
                aria-hidden="false"
                class="resize-handle"
                @pointerdown=${this.onHandlePointerDown}
              ></div>
            `
            : null}
      </div>
    `;
    }
};
__decorate([
    property({ type: Number, reflect: true, attribute: true })
], NileGridCellItem.prototype, "colspan", void 0);
__decorate([
    property({ type: Number, reflect: true, attribute: true })
], NileGridCellItem.prototype, "rowspan", void 0);
__decorate([
    property({ type: Boolean, reflect: true, attribute: true })
], NileGridCellItem.prototype, "resizable", void 0);
NileGridCellItem = __decorate([
    customElement('nile-grid-cell-item')
], NileGridCellItem);
export { NileGridCellItem };
export default NileGridCellItem;
//# sourceMappingURL=nile-grid-cell-item.js.map