import { __decorate } from "tslib";
import { observable, volatile } from '@ni/fast-element';
import { DesignSystem } from '@ni/fast-foundation';
import { TableCellView } from '../../base/cell-view';
import { styles } from './styles';
import { template } from './template';
/**
 * A cell view for displaying links
 */
export class TableColumnAnchorCellView extends TableCellView {
    constructor() {
        super(...arguments);
        /** @internal */
        this.hasOverflow = false;
        /** @internal */
        this.isPlaceholder = false;
    }
    get text() {
        const displayedText = this.cellRecord?.label ?? this.cellRecord?.href;
        if ((displayedText === undefined || displayedText === null)
            && this.columnConfig?.placeholder) {
            this.isPlaceholder = true;
            return this.columnConfig.placeholder;
        }
        this.isPlaceholder = false;
        if (typeof this.cellRecord?.label === 'string') {
            return this.cellRecord.label;
        }
        if (typeof this.cellRecord?.href === 'string') {
            return this.cellRecord.href;
        }
        return '';
    }
    /** @internal */
    get showAnchor() {
        return typeof this.cellRecord?.href === 'string';
    }
    get tabbableChildren() {
        if (this.showAnchor) {
            return [this.anchor];
        }
        return [];
    }
}
__decorate([
    observable
], TableColumnAnchorCellView.prototype, "hasOverflow", void 0);
__decorate([
    observable
], TableColumnAnchorCellView.prototype, "isPlaceholder", void 0);
__decorate([
    volatile
], TableColumnAnchorCellView.prototype, "text", null);
__decorate([
    volatile
], TableColumnAnchorCellView.prototype, "showAnchor", null);
const anchorCellView = TableColumnAnchorCellView.compose({
    baseName: 'table-column-anchor-cell-view',
    template,
    styles
});
DesignSystem.getOrCreate().withPrefix('nimble').register(anchorCellView());
export const tableColumnAnchorCellViewTag = 'nimble-table-column-anchor-cell-view';
//# sourceMappingURL=index.js.map