import { findChildren, findChildrenByType, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType, } from "../../../pm/utils.js";
import { TableNode } from "./const.js";
export const isIntoTable = (state) => hasParentNodeOfType(state.schema.nodes[TableNode.Table])(state.selection);
export const findParentTable = (state) => findParentNodeOfType(state.schema.nodes[TableNode.Table])(state.selection);
export const findParentTableOnPosOnPos = ($pos) => findParentNodeOfTypeClosestToPos($pos, $pos.doc.type.schema.nodes[TableNode.Table]);
export const findParentHeadOnPos = ($pos) => findParentNodeOfTypeClosestToPos($pos, $pos.doc.type.schema.nodes[TableNode.Head]);
export const findParentBody = (state) => findParentNodeOfType(state.schema.nodes[TableNode.Body])(state.selection);
export const findParentBodyOnPos = ($pos) => findParentNodeOfTypeClosestToPos($pos, $pos.doc.type.schema.nodes[TableNode.Body]);
export const findParentRow = (state) => findParentNodeOfType(state.schema.nodes[TableNode.Row])(state.selection);
export const findParentRowOnPos = ($pos) => findParentNodeOfTypeClosestToPos($pos, $pos.doc.type.schema.nodes[TableNode.Row]);
export const findParentCell = (state) => findParentNodeOfType([
    state.schema.nodes[TableNode.HeaderCell],
    state.schema.nodes[TableNode.DataCell],
])(state.selection);
export const findParentCellOnPos = ($pos) => findParentNodeOfTypeClosestToPos($pos, [
    $pos.doc.type.schema.nodes[TableNode.HeaderCell],
    $pos.doc.type.schema.nodes[TableNode.DataCell],
]);
export const findTableRows = (table, schema) => findChildrenByType(table, schema.nodes[TableNode.Row]);
export const findTableCells = (table, schema) => findChildren(table, (node) => [schema.nodes[TableNode.HeaderCell].name, schema.nodes[TableNode.DataCell].name].includes(node.type.name));
//# sourceMappingURL=helpers.js.map
