<commit_before>"use strict"

import {Renderer} from "microReact";
import {clone} from "./util";
import {client, indexes} from "./client";

//type RecordElementCollection = HTMLCollection | SVGColl
interface RecordElement extends Element { entity?: string, sort?: any, _parent?: RecordElement|null, style?: CSSStyleDeclaration };
interface RDocument extends Document { activeElement: RecordElement };
declare var document: RDocument;

function isInputElem<T extends Element>(elem:T): elem is T&HTMLInputElement {
  return elem && elem.tagName === "INPUT";
}
function isSelectElem<T extends Element>(elem:T): elem is T&HTMLSelectElement {
  return elem && elem.tagName === "SELECT";
}

export function setActiveIds(ids) {
  for(let k in activeIds) {
    activeIds[k] = undefined;
  }
  for(let k in ids) {
    activeIds[k] = ids[k];
  }
}


//---------------------------------------------------------
// MicroReact-based record renderer
//---------------------------------------------------------
export var renderer = new Renderer();
document.body.appendChild(renderer.content);
renderer.content.classList.add("application-root");

// These will get maintained by the client as diffs roll in
export var sentInputValues = {};
export var activeIds = {};

// root will get added to the dom by the program microReact element in renderEditor
export var activeElements:{[id : string]: RecordElement|null, root: RecordElement} = {"root": document.createElement("div")};
activeElements.root.className = "program";

var supportedTags = {
  "div": true, "span": true, "input": true, "ul": true, "li": true, "label": true, "button": true, "header": true, "footer": true, "a": true, "strong": true,
  "h1": true, "h2": true, "h3": true, "h4": true, "h5": true, "h6": true,
  "ol": true, "p": true, "pre": true, "em": true, "img": true, "canvas": true, "script": true, "style": true, "video": true,
  "table": true, "tbody": true, "thead": true, "tr": true, "th": true, "td": true,
  "form": true, "optgroup": true, "option": true, "select": true, "textarea": true, "datalist": true,
  "title": true, "meta": true, "link": true,
  "svg": true, "circle": true, "line": true, "rect": true, "polygon":true, "text": true, "image": true, "defs": true, "pattern": true, "linearGradient": true, "g": true, "path": true
};
var svgs = {"svg": true, "circle": true, "line": true, "rect": true, "polygon":true, "text": true, "image": true, "defs": true, "pattern": true, "linearGradient": true, "g": true, "path": true};
// Map of input entities to a queue of their values which originated from the client and have not been received from the server yet.

var lastFocusPath:string[]|null = null;
var selectableTypes = {"": true, undefined: true, text: true, search: true, password: true, tel: true, url: true};

var previousCheckedRadios = {};

function insertSorted(parent:Node, child:RecordElement) {
  let current;
  for(let curIx = 0; curIx < parent.childNodes.length; curIx++) {
    let cur = parent.childNodes[curIx] as RecordElement;
    if(cur.sort !== undefined && cur.sort > child.sort) {
      current = cur;
      break;
    }
  }
  if(current) {
    parent.insertBefore(child, current);
  } else  {
    parent.appendChild(child);
  }<commit_msg>Add missing HTML5 and SVG tags<commit_after>"use strict"

import {Renderer} from "microReact";
import {clone} from "./util";
import {client, indexes} from "./client";

//type RecordElementCollection = HTMLCollection | SVGColl
interface RecordElement extends Element { entity?: string, sort?: any, _parent?: RecordElement|null, style?: CSSStyleDeclaration };
interface RDocument extends Document { activeElement: RecordElement };
declare var document: RDocument;

function isInputElem<T extends Element>(elem:T): elem is T&HTMLInputElement {
  return elem && elem.tagName === "INPUT";
}
function isSelectElem<T extends Element>(elem:T): elem is T&HTMLSelectElement {
  return elem && elem.tagName === "SELECT";
}

export function setActiveIds(ids) {
  for(let k in activeIds) {
    activeIds[k] = undefined;
  }
  for(let k in ids) {
    activeIds[k] = ids[k];
  }
}


//---------------------------------------------------------
// MicroReact-based record renderer
//---------------------------------------------------------
export var renderer = new Renderer();
document.body.appendChild(renderer.content);
renderer.content.classList.add("application-root");

// These will get maintained by the client as diffs roll in
export var sentInputValues = {};
export var activeIds = {};

// root will get added to the dom by the program microReact element in renderEditor
export var activeElements:{[id : string]: RecordElement|null, root: RecordElement} = {"root": document.createElement("div")};
activeElements.root.className = "program";

// Obtained from http://w3c.github.io/html-reference/elements.html
var supportedTagsArr = [
  "a",
  "abbr",
  "address",
  "area",
  "article",
  "aside",
  "audio",
  "b",
  "base",
  "bdi",
  "bdo",
  "blockquote",
  "body",
  "br",
  "button",
  "canvas",
  "caption",
  "cite",
  "code",
  "col",
  "colgroup",
  "command",
  "datalist",
  "dd",
  "del",
  "details",
  "dfn",
  "div",
  "dl",
  "dt",
  "em",
  "embed",
  "fieldset",
  "figcaption",
  "figure",
  "footer",
  "form",
  "h1",
  "h2",
  "h3",
  "h4",
  "h5",
  "h6",
  "head",
  "header",
  "hgroup",
  "hr",
  "html",
  "i",
  "iframe",
  "img",
  "input",
  "ins",
  "kbd",
  "keygen",
  "label",
  "legend",
  "li",
  "link",
  "map",
  "mark",
  "menu",
  "meta",
  "meter",
  "nav",
  "noscript",
  "object",
  "ol",
  "optgroup",
  "option",
  "output",
  "p",
  "param",
  "pre",
  "progress",
  "q",
  "rp",
  "rt",
  "ruby",
  "s",
  "samp",
  "script",
  "section",
  "select",
  "small",
  "source",
  "span",
  "strong",
  "style",
  "sub",
  "summary",
  "sup",
  "table",
  "tbody",
  "td",
  "textarea",
  "tfoot",
  "th",
  "thead",
  "time",
  "title",
  "tr",
  "track",
  "u",
  "ul",
  "var",
  "video",
  "wbr"
];

// Obtained from https://www.w3.org/TR/SVG/eltindex.html
var svgsArr = [
  "a",
  "altGlyph",
  "altGlyphDef",
  "altGlyphItem",
  "animate",
  "animateColor",
  "animateMotion",
  "animateTransform",
  "circle",
  "clipPath",
  "color-profile",
  "cursor",
  "defs",
  "desc",
  "ellipse",
  "feBlend",
  "feColorMatrix",
  "feComponentTransfer",
  "feComposite",
  "feConvolveMatrix",
  "feDiffuseLighting",
  "feDisplacementMap",
  "feDistantLight",
  "feFlood",
  "feFuncA",
  "feFuncB",
  "feFuncG",
  "feFuncR",
  "feGaussianBlur",
  "feImage",
  "feMerge",
  "feMergeNode",
  "feMorphology",
  "feOffset",
  "fePointLight",
  "feSpecularLighting",
  "feSpotLight",
  "feTile",
  "feTurbulence",
  "filter",
  "font",
  "font-face",
  "font-face-format",
  "font-face-name",
  "font-face-src",
  "font-face-uri",
  "foreignObject",
  "g",
  "glyph",
  "glyphRef",
  "hkern",
  "image",
  "line",
  "linearGradient",
  "marker",
  "mask",
  "metadata",
  "missing-glyph",
  "mpath",
  "path",
  "pattern",
  "polygon",
  "polyline",
  "radialGradient",
  "rect",
  "script",
  "set",
  "stop",
  "style",
  "svg",
  "switch",
  "symbol",
  "text",
  "textPath",
  "title",
  "tref",
  "tspan",
  "use",
  "view",
  "vkern"
];

supportedTagsArr.push.apply(supportedTagsArr, svgsArr);

function toKeys(arr) {
  var obj = {};
  for (var el of arr) {
    obj[el] = true;
  }
  return obj
}

var supportedTags = toKeys(supportedTagsArr);
var svgs = toKeys(svgsArr);

// Map of input entities to a queue of their values which originated from the client and have not been received from the server yet.
var lastFocusPath:string[]|null = null;
var selectableTypes = {"": true, undefined: true, text: true, search: true, password: true, tel: true, url: true};

var previousCheckedRadios = {};

function insertSorted(parent:Node, child:RecordElement) {
  let current;
  for(let curIx = 0; curIx < parent.childNodes.length; curIx++) {
    let cur = parent.childNodes[curIx] as RecordElement;
    if(cur.sort !== undefined && cur.sort > child.sort) {
      current = cur;
      break;
    }
  }
  if(current) {
    parent.insertBefore(child, current);
  } else  {
    parent.appendChild(child);
  }
{'fraction_non_alphanumeric': 0.201984321411073, 'fraction_numerical': 0.002082312591866732, 'mean_word_length': 3.5487465181058497, 'pattern_counts': {'":': 69, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '2526240', 'n_tokens_mistral': 2847, 'n_tokens_neox': 2818, 'n_words': 760}