import { html, repeat } from '@ni/fast-element';
import { TableCellView } from '.';
import { uniquifySlotNameForColumn } from '../../../table/models/utilities';
const validateCellViewTemplate = (cellViewTag) => {
    let instance;
    try {
        instance = document.createElement(cellViewTag);
    }
    catch (_ex) {
        // Swallow construction error to report a better one
    }
    if (!(instance instanceof TableCellView)) {
        throw new Error(`Cell view tag name (${cellViewTag}) must evaluate to an element extending TableCellView`);
    }
};
export const createCellViewTemplate = (cellViewTag) => {
    validateCellViewTemplate(cellViewTag);
    return html `
        <${cellViewTag}
            :cellRecord="${y => y.cellState?.cellRecord}"
            :columnConfig="${y => y.cellState?.columnConfig}"
            :column="${y => y.column}"
            :recordId="${y => y.recordId}"
            class="cell-view"
        >
            ${repeat(y => y.column?.columnInternals.slotNames || [], html `
                <slot
                    name="${(x, c) => uniquifySlotNameForColumn(c.parent.column, x)}"
                    slot="${x => x}"
                ></slot>
            `)}
        </${cellViewTag}>
    `;
};
//# sourceMappingURL=template.js.map