/*
 * Returns true if the schema supports nesting tables inside table cells.
 * This is determined by checking if table cells can contain table nodes in their content model.
 *
 * ```typescript
 * const supportsNestedTables = isNestedTablesSupported(state.schema);
 * ```
 */
export const isNestedTablesSupported = schema => {
  var _tableCell$contentMat, _tableHeader$contentM;
  const {
    table,
    tableCell,
    tableHeader
  } = schema.nodes;
  if (!table || !tableCell || !tableHeader) {
    return false;
  }

  // Check if table cells can contain table nodes by testing their content match
  const tableCellCanContainTable = ((_tableCell$contentMat = tableCell.contentMatch.matchType(table)) === null || _tableCell$contentMat === void 0 ? void 0 : _tableCell$contentMat.validEnd) === true;
  const tableHeaderCanContainTable = ((_tableHeader$contentM = tableHeader.contentMatch.matchType(table)) === null || _tableHeader$contentM === void 0 ? void 0 : _tableHeader$contentM.validEnd) === true;
  return tableCellCanContainTable || tableHeaderCanContainTable;
};