export function findComponentsWithNavigationProperty(data, result = []) {
  if (!Array.isArray(data)) data = [data];
  for (const item of data) {
    if ("components" in item) {
      findComponentsWithNavigationProperty(item.components, result);
    }
    if ("children" in item) {
      findComponentsWithNavigationProperty(item.children, result);
    }
    if (
      "props" in item &&
      "to" in item.props &&
      item.props.onclick == "navigation"
    ) {
      result.push(item);
    }
  }
  return result;
}

export function findComponentsWithBackNavigationProperty(data, result = []) {
  if (!Array.isArray(data)) data = [data];
  for (const item of data) {
    if ("components" in item) {
      findComponentsWithBackNavigationProperty(item.components, result);
    }
    if ("props" in item && item.props.onclick === "back") {
      result.push(item);
    }
  }
  return result;
}
