<commit_before>/**
 * @module Inferno
 */ /** TypeDoc Comment */

import {
  combineFrom,
  isArray,
  isInvalid,
  isNull,
  isStatefulComponent,
  isStringOrNumber,
  isUndefined
} from "inferno-shared";
import VNodeFlags from "inferno-vnode-flags";
import { EMPTY_OBJ } from "../DOM/utils";
import { normalize } from "./normalization";
import { options } from "./options";

export type InfernoInput = VNode | null | string | number;
export type Ref = (node?: Element | null) => void | null;
export type InfernoChildren =
  | string
  | number
  | boolean
  | undefined
  | VNode
  | Array<string | number | VNode>
  | null;
export type Type = string | null | Function;

export interface Props {
  children?: InfernoChildren;
  ref?: Ref;
  key?: any;
  className?: string;
  [k: string]: any;
}

export interface Refs {
  onComponentDidMount?: (domNode: Element) => void;
  onComponentWillMount?(): void;
  onComponentShouldUpdate?(lastProps, nextProps): boolean;
  onComponentWillUpdate?(lastProps, nextProps): void;
  onComponentDidUpdate?(lastProps, nextProps): void;
  onComponentWillUnmount?(domNode: Element): void;
}

export interface VNode {
  children: InfernoChildren;
  dom: Element | null;
  className: string | null;
  flags: number;
  key: any;
  props: Props | null;
  ref: Ref;
  type: Type;
  parentVNode?: VNode;
}

function VNode(children, className, flags, key, props, ref, type) {
  this.children = children;
  this.className = className;
  this.dom = null;
  this.flags = flags;
  this.key = key;
  this.props = props;
  this.ref = ref;
  this.type = type;
}

/**
 * Creates virtual node
 * @param {number} flags
 * @param {string|Function|null} type
 * @param {string|null=} className
 * @param {object=} children
 * @param {object=} props
 * @param {*=} key
 * @param {object|Function=} ref
 * @param {boolean=} noNormalise
 * @returns {VNode} returns new virtual node
 */
export function createVNode(
  flags: number,
  type: Type,
  className?: string | null,
  children?: InfernoChildren,
  props?: Props | null,
  key?: any,
  ref?: Ref,
  noNormalise?: boolean
) {
  if (flags & VNodeFlags.ComponentUnknown) {
    flags = isStatefulComponent(type)
      ? VNodeFlags.ComponentClass
      : VNodeFlags.ComponentFunction;
  }

  const vNode = new VNode(
    children === void 0 ? null : children,
    className === void 0 ? null : className,
    flags,
    key === void 0 ? null : key,
    props === void 0 ? null : props,
    ref === void 0 ? null : ref,
    type
  );
  if (noNormalise !== true) {
    normalize(vNode);
  }
  if (options.createVNode !== null) {
    options.createVNode(vNode);
  }

  return vNode;
}

export function directClone(vNodeToClone: VNode): VNode {
  let newVNode;
  const flags = vNodeToClone.flags;

  if (flags & VNodeFlags.Component) {
    let props;
    const propsToClone = vNodeToClone.props;

    if (isNull(propsToClone)) {<commit_msg>optimization: use object literal for vNode creation for more reliable performance on v8 (TurboFan & Ignition) and Safari<commit_after>/**
 * @module Inferno
 */ /** TypeDoc Comment */

import {
  combineFrom,
  isArray,
  isInvalid,
  isNull,
  isStatefulComponent,
  isStringOrNumber,
  isUndefined
} from "inferno-shared";
import VNodeFlags from "inferno-vnode-flags";
import { EMPTY_OBJ } from "../DOM/utils";
import { normalize } from "./normalization";
import { options } from "./options";

export type InfernoInput = VNode | null | string | number;
export type Ref = (node?: Element | null) => void;
export type InfernoChildren =
  | string
  | number
  | boolean
  | undefined
  | VNode
  | Array<string | number | VNode>
  | null;
export type Type = string | null | Function;

export interface Props {
  children?: InfernoChildren;
  ref?: Ref | null;
  key?: any;
  className?: string;
  [k: string]: any;
}

export interface Refs {
  onComponentDidMount?: (domNode: Element) => void;
  onComponentWillMount?(): void;
  onComponentShouldUpdate?(lastProps, nextProps): boolean;
  onComponentWillUpdate?(lastProps, nextProps): void;
  onComponentDidUpdate?(lastProps, nextProps): void;
  onComponentWillUnmount?(domNode: Element): void;
}

export interface VNode {
  children: InfernoChildren;
  dom: Element | null;
  className: string | null;
  flags: number;
  key: any;
  props: Props | null;
  ref: Ref | null;
  type: Type;
  parentVNode?: VNode;
}

/**
 * Creates virtual node
 * @param {number} flags
 * @param {string|Function|null} type
 * @param {string|null=} className
 * @param {object=} children
 * @param {object=} props
 * @param {*=} key
 * @param {object|Function=} ref
 * @param {boolean=} noNormalise
 * @returns {VNode} returns new virtual node
 */
export function createVNode(
  flags: number,
  type: Type,
  className?: string | null,
  children?: InfernoChildren,
  props?: Props | null,
  key?: any,
  ref?: Ref | null,
  noNormalise?: boolean
): VNode {
  if (flags & VNodeFlags.ComponentUnknown) {
    flags = isStatefulComponent(type)
      ? VNodeFlags.ComponentClass
      : VNodeFlags.ComponentFunction;
  }

  const vNode: VNode = {
    children: children === void 0 ? null : children,
    className: className === void 0 ? null : className,
    dom: null,
    flags,
    key: key === void 0 ? null : key,
    props: props === void 0 ? null : props,
    ref: ref === void 0 ? null : ref,
    type
  };
  if (noNormalise !== true) {
    normalize(vNode);
  }
  if (options.createVNode !== null) {
    options.createVNode(vNode);
  }

  return vNode;
}

export function directClone(vNodeToClone: VNode): VNode {
  let newVNode;
  const flags = vNodeToClone.flags;

  if (flags & VNodeFlags.Component) {
    let props;
    const propsToClone = vNodeToClone.props;

    if (isNull(propsToClone)) {
{'fraction_non_alphanumeric': 0.12846435419208646, 'fraction_numerical': 0.0019173784207774098, 'mean_word_length': 3.7304204451772467, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4993408', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1875, 'n_words': 537}