diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..42765851f67e460d370e8baed8a80bb4998717c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +src/_build +grammar.html +src/generated_parser.ml +src/config.ml +**/*.native +skeleton +src/.vscode/ +.vscode/ +Makefile.config \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000000000000000000000000000000000000..00919710614e7cf2d5965f9ff8850b7ed7007890 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,19 @@ +# Install with opam +1. Install opam (Ocaml PAckage Manager) + - https://opam.ocaml.org/doc/Install.html +2. Get sufficient version of ocaml + > opam switch create 4.08.0 (or higher) +3. Install packages with opam + > opam install package-name + - stdlib-shims + - ocamlbuild + - ocamlfind + - menhir + - lwt + - logs + - batteries + - yojson + - websocket + - websocket-lwt-unix +4. Build the project + > make diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..47838aaa427e07b026212bc5925c802c5f333d09 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +all: ecomp + +include opts.mk + +.PHONY: ecomp + +src/config.ml: configure opts.mk + ./configure ${CONF_OPTS} + +.PHONY: alpaga +alpaga/alpaga: + make -C alpaga + +src/generated_parser.ml: expr_grammar_action.g alpaga/alpaga + ./alpaga/alpaga \ + -g expr_grammar_action.g \ + -pml src/generated_parser.ml \ + -t grammar.html + +ecomp: src/generated_parser.ml src/config.ml + make -C src + ln -sf src/_build/default/main.exe ecomp + +clean: + make -C alpaga clean + rm -f src/generated_parser.ml + rm -f grammar.html + make -C src clean + rm -f ecomp + make -C tests clean + +test: ecomp + make -C tests diff --git a/Sujet.pdf b/Sujet.pdf new file mode 100644 index 0000000000000000000000000000000000000000..30b20f5f343fd8f0a6a8dbb775fd34446c4fe3e9 Binary files /dev/null and b/Sujet.pdf differ diff --git a/alpaga/.gitignore b/alpaga/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..6aa1efe5015e93d3152a904efb1b37e01b34c336 --- /dev/null +++ b/alpaga/.gitignore @@ -0,0 +1,4 @@ +ml_parser_generator +alpaga +ml_parser_generator.native +_build/ \ No newline at end of file diff --git a/alpaga/Makefile b/alpaga/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..caabc9f71a78cf343e81be2a7e14f7a30581e452 --- /dev/null +++ b/alpaga/Makefile @@ -0,0 +1,21 @@ +#OCB=ocamlbuild -use-ocamlfind -cflag -g + +SRC=ml_parser_generator.ml \ + grammar_parser.ml \ + ll_parser.ml \ + list_utils.ml \ + grammar.ml \ + grammar_lexer.mll \ + grammar_parser_yacc.mly + +TG = alpaga + +all: $(TG) + +$(TG): $(SRC) + dune build ml_parser_generator.exe + ln -sf _build/default/ml_parser_generator.exe alpaga + +clean: + rm -f ml_parser_generator.native $(TG) + rm -rf _build diff --git a/alpaga/README.md b/alpaga/README.md new file mode 100644 index 0000000000000000000000000000000000000000..87f1e36f459b8424335528542d6b89b191c6d92e --- /dev/null +++ b/alpaga/README.md @@ -0,0 +1,121 @@ +# ALPAGA (An Ll(1) PArser GenerAtor) + +ALPAGA est un générateur d'analyseurs syntaxiques LL(1). + +Le format d'entrée (simple) est le suivant : + +Premièrement, on définit les terminaux du langage : + +''' +tokens SYM_EOF SYM_IF SYM_IDENTIFIER<string> SYM_INTEGER<int> SYM_PLUS SYM_MINUS +tokens SYM_ASTERISK SYM_DIV +''' + +Les "SYM_XXX" correspondent aux symboles définis dans src/symbols.ml + +Lorsqu'un symbole n'est pas constant (i.e. est paramétré par une chaîne de +caractères ou un entier, n indique son type entre chevrons < et >. + +Ensuite, on définit les non-terminaux du langage : + +''' +non-terminals S EXPR TERM FACTOR +non-terminals EXPRS TERMS +''' + +Puis le non-terminal distingué qui sert d'axiome à la grammaire : + +''' +axiom S +''' + +Ensuite le mot clé 'rules' indique le début des règles de la grammaire + +'''rules''' + +Une règle est simplement de la forme 'N -> SYM_TRUC AUTRE_NON_TERMINAL SYM_MACHIN' + +Par exemple, + +''' +S -> EXPR SYM_EOF +EXPR -> TERM EXPRS +EXPRS -> SYM_PLUS TERM EXPRS +EXPRS -> SYM_MINUS TERM EXPRS +EXPRS -> +''' + +La dernière ligne de cette grammaire indique une règle qui produit le mot vide +(Epsilon) pour le non-terminal EXPRS. + +Vous pouvez lancer ALPAGA avec la commande suivante : + +''' +./ml_parser_generator -g <votre_fichier_de_grammaire.g> -t <table.html> +''' + +Cela va analyser votre grammaire et produire un fichier HTML, que vous pouvez +ouvrir avec un navigateur web, et qui contient les tables Null, First et Follow +relatives à votre grammaire. + +Ce fichier contient aussi la table de prédiction LL(1) avec dans chaque case +(NT, t) la règle à appliquer lorsque l'analyseur doit reconnaître le +non-terminal NT, et a le lexème t en entrée. + +Si la case est vide, il s'agit d'une erreur de syntaxe : on ne s'attendait pas à +voir ce lexème-ci dans cet état. + +Si la case contient plusieurs règles, c'est un conflit : votre grammaire est +ambigüe. Sans doute avez-vous utilisé de la récursivité à gauche ? + +Dans la case (NT,t), une règle affichée en bleu signifie que cette règle est +présente car t appartient à First(NT), tandis qu'une règle affichée en rouge +signifie que NT est Nullable et que t appartient à Follow(NT). + + +## Actions dans la grammaire + +Maintenant que vous avez une grammaire sans conflits, il est temps de générer un +arbre de syntaxe abstraite. Pour ce faire, vous avez deux choses à faire : + +- sur les lignes avant le mot-clé 'rules', insérez un bloc de code entre + accolades, qui sera copié au début du code source généré pour l'analyseur + syntaxique. (en fait dans le squelette qui vous est fourni, ce bloc de code + est déjà présent, et vous n'avez qu'à le remplir.) + +- après chaque règle 'X -> w1 w2 ... wn', ajoutez du code entre accolades qui + construit le sous-arbre correspondant à la dérivation effectuée par cette + règle. On appelle ce code une **action**. + + Le code que vous écrivez correspond donc à la construction d'un terme OCaml. + + Par exemple, le morceau suivant vous est fourni : + ''' + S -> GLOBDEF SYM_EOF { Node (Tlistglobdef, [$1]) } + IDENTIFIER -> SYM_IDENTIFIER { StringLeaf ($1) } + INTEGER -> SYM_INTEGER { IntLeaf ($1) } + GLOBDEF -> IDENTIFIER SYM_LPARENTHESIS LPARAMS SYM_RPARENTHESIS INSTR { + let fargs = $3 in + let instr = $5 in + Node (Tfundef, [$1; Node (Tfunargs, fargs) ; instr ]) + } + ''' + + Pour une règle X -> w1 w2 ... wn, les variables $i correspondent aux actions + générées par le symbole wi. Par exemple, dans l'action de la première règle, + la variable $1 correspond à l'arbre rendu par le non-terminal GLOBDEF. + + Les définitions des arbres et nÅ“uds sont trouvées dans le fichier src/ast.ml. + + Ces actions vont servir à générer le parser, ce qui se fera avec la commande : + + ''' +./ml_parser_generator -g <votre_fichier_de_grammaire.g> -t <table.html> -pml <generated_parser.ml> + ''' + + Cela créera le fichier <generated_parser.ml> à l'endroit où vous l'avez + indiqué. + + En fait, les différents Makefile de ce projet font que vous n'aurez + normalement pas à écrire cette commande à la main : un simple 'make test' à la + racine de ce projet devrait faire tout ce dont vous avez besoin. diff --git a/alpaga/dune b/alpaga/dune new file mode 100644 index 0000000000000000000000000000000000000000..c1980e29d4a2ce8f8c69cbec0da8baf77ccee6de --- /dev/null +++ b/alpaga/dune @@ -0,0 +1,14 @@ +(menhir + (modules grammar_parser_yacc) +) +(ocamllex grammar_lexer) + +(executable + (name ml_parser_generator) + (libraries + batteries + menhirLib + ) + (flags (:standard -warn-error -A -w -27 -w -33 -w -9 -w -39)) + +) diff --git a/alpaga/dune-project b/alpaga/dune-project new file mode 100644 index 0000000000000000000000000000000000000000..192d77fdc7853a217a9338cf6209a8cdf00597c5 --- /dev/null +++ b/alpaga/dune-project @@ -0,0 +1,2 @@ +(lang dune 2.9) +(using menhir 2.1) diff --git a/alpaga/grammar.ml b/alpaga/grammar.ml new file mode 100644 index 0000000000000000000000000000000000000000..e747d158cea5ae006756492cabe3f4a2a1bccdc1 --- /dev/null +++ b/alpaga/grammar.ml @@ -0,0 +1,29 @@ +open List_utils + +type tokent = string +type nonterm = string + +type action = string option + +type rule = { rule_nt: nonterm; + rule_prods: string list; + rule_action: action + } + +type grammar = { tokens: (tokent * string option) list; + nonterms: (nonterm * string option) list; + rules: rule list; + mlcode: string option; + axiom: nonterm option + } + + +let dump_grammar oc (toks, nts, rules) = + Printf.fprintf oc "tokens"; + List.iter (fun n -> Printf.fprintf oc " %s" n) toks; + Printf.fprintf oc "\nnon-terminals "; + List.iter (fun n -> Printf.fprintf oc " %s" n) nts; + Printf.fprintf oc "\nrules\n"; + List.iter (fun (n,lt,_) -> + Printf.fprintf oc "%s ->%s\n" n (print_seq (fun x -> x) lt)) rules + diff --git a/alpaga/grammar_lexer.mll b/alpaga/grammar_lexer.mll new file mode 100644 index 0000000000000000000000000000000000000000..1ea896e2d4dee9c578c3416336f40caff0ecc7ff --- /dev/null +++ b/alpaga/grammar_lexer.mll @@ -0,0 +1,43 @@ +{ +open Grammar_parser_yacc +open Lexing +} + +let digit = ['0'-'9'] +let letter = ['a'-'z' 'A'-'Z'] +let id = letter (digit|letter|'_')* + +rule token = parse + | [' ' '\t'] { token lexbuf } + | "//" { comment lexbuf } + | "/*" { comment_multiline lexbuf } + | '\n' { Lexing.new_line lexbuf; EOL } + | '{' { action 0 "" lexbuf } + | '<' { ttype "" lexbuf } + | "->" { ARROW } + | "axiom" { AXIOM } + | "tokens" { TOK } + | "non-terminals" { NT } + | "rules" { RULES } + | id as s { IDENTIFIER s } + | eof { EOF } + | _ as x { let open Lexing in + failwith (Printf.sprintf "unexpected char '%c' at line %d col %d\n" x + (lexbuf.lex_curr_p.pos_lnum) + (lexbuf.lex_curr_p.pos_cnum - lexbuf.lex_curr_p.pos_bol))} +and action level s = parse + | '}' { if level = 0 then CODE s else action (level-1) (s ^ "}") lexbuf } + | '{' { action (level + 1) (s ^ "{") lexbuf } + | _ as x { if x = '\n' then Lexing.new_line lexbuf; + action level (Printf.sprintf "%s%c" s x) lexbuf } +and ttype s = parse + | '>' { TTYPE s } + | _ as x { if x = '\n' then Lexing.new_line lexbuf; + ttype (Printf.sprintf "%s%c" s x) lexbuf } +and comment = parse + | '\n' { Lexing.new_line lexbuf; token lexbuf } + | _ { comment lexbuf } +and comment_multiline = parse + | '\n' { Lexing.new_line lexbuf; comment_multiline lexbuf } + | "*/" { token lexbuf } + | _ { comment_multiline lexbuf } diff --git a/alpaga/grammar_parser.ml b/alpaga/grammar_parser.ml new file mode 100644 index 0000000000000000000000000000000000000000..e3a504d228c098bfad32c79c30652307ab5fe5b3 --- /dev/null +++ b/alpaga/grammar_parser.ml @@ -0,0 +1,63 @@ +open Str +open List_utils +open Lexing +open Grammar_lexer +open Grammar_parser_yacc +open Grammar + +let print_position outx lexbuf = + let pos = lexbuf.lex_curr_p in + Printf.fprintf outx "%s:%d:%d" pos.pos_fname + pos.pos_lnum (pos.pos_cnum - pos.pos_bol + 1) + +let parse_with_error lexbuf = + try main token lexbuf with + | Error -> + Printf.fprintf stderr "%a: syntax error\n" print_position lexbuf; + exit (-1) + +let parse_grammar file : grammar * nonterm = + let ic = open_in file in + let lexbuf = Lexing.from_channel ic in + lexbuf.Lexing.lex_curr_p <- {lexbuf.Lexing.lex_curr_p with pos_fname = file}; + let gram : grammar = parse_with_error lexbuf in + let (undefined_strings, used_strings) : string list * string list = + List.fold_left (fun (undef, used) rule -> + List.fold_left + (fun (undef, used) prod -> + let undef = + if not (List.mem_assoc prod gram.tokens || List.mem_assoc prod gram.nonterms || List.mem prod undef) + then prod::undef + else undef in + let used = + if List.mem prod used then used else prod::used in + (undef, used) + ) + (undef, used) (rule.rule_prods) + ) ([],[]) (gram.rules) in + + (* Error if undefined tokens or non-terminals are encountered *) + if undefined_strings <> [] + then (Printf.printf "Undefined tokens or non-terminals: %a\n" print_list undefined_strings; + failwith "Undefined tokens or non-terminals"); + + match gram.axiom with + | None -> failwith "No axiom was defined for the grammar.\n Aborting." + | Some axiom -> + + (* Warn if some non terminals are never seen on the right hand side of a rule. *) + let unused_nts = List.filter (fun nt -> not (List.mem nt used_strings) && Some nt <> gram.axiom) (List.map fst gram.nonterms) in + if unused_nts <> [] then Printf.printf "The following non-terminals are declared but never appear on the right hand-side of a rule:\n%a\n" print_list unused_nts; + + (* Warn if some tokens are never seen on the right hand side of a rule. *) + let unused_toks = (List.filter_map (fun (t,_) -> if not (List.mem t used_strings) then Some t else None) gram.tokens) in + if unused_toks <> [] then Printf.printf "The following tokens are declared but never appear on the right hand-side of a rule:\n%a\n" print_list unused_toks; + + let h : (nonterm , rule list) Hashtbl.t = + Hashtbl.create (List.length gram.nonterms) in + List.iter ( fun r -> + match Hashtbl.find_opt h r.rule_nt with + | None -> Hashtbl.add h r.rule_nt [r] + | Some lp -> Hashtbl.replace h r.rule_nt (lp@[r]) ) (gram.rules); + let rules = List.concat (List.map (fun n -> hashget_def h n []) (List.map fst gram.nonterms)) in + { gram with rules = rules }, axiom diff --git a/alpaga/grammar_parser_yacc.mly b/alpaga/grammar_parser_yacc.mly new file mode 100644 index 0000000000000000000000000000000000000000..c0161c25433b57a2da218c72c4f75ab2d98c5f3d --- /dev/null +++ b/alpaga/grammar_parser_yacc.mly @@ -0,0 +1,71 @@ +%{ + + open Grammar + + %} + +%token EOF EOL TOK NT RULES ARROW AXIOM //LT GT +%token<string> IDENTIFIER +%token<string> CODE +%token<string> TTYPE + +%start main +%type <Grammar.grammar> main + +%% + + main: + | AXIOM IDENTIFIER EOL main { let r = $4 in {r with axiom = Some $2 }} + | TOK list_tokens EOL main { let r = $4 in {r with tokens = r.tokens @ $2} } + | NT list_nts EOL main { let r = $4 in {r with nonterms = r.nonterms @ $2} } + | CODE main { let r = $2 in { r with mlcode = Some ($1) }} + | RULES EOL rules EOF { { tokens = []; nonterms = []; axiom = None; + rules = $3; mlcode = None } } + | EOL main { $2 } + ; + + typed_tokens: + | IDENTIFIER TTYPE { ($1, Some $2) } + | IDENTIFIER { ($1, None)} + ; + + + list_tokens: + | typed_tokens list_tokens { $1 :: $2} + | { [] } + ; + + + typed_nts: + | IDENTIFIER TTYPE { ($1, Some $2) } + | IDENTIFIER { ($1, None)} + ; + + + list_nts: + | typed_nts list_nts { $1 :: $2} + | { [] } + ; + + + + + list_ident: + | IDENTIFIER list_ident { $1 :: $2} + | { [] } + ; + + rules: + | rule rules { $1 :: $2 } + | EOL rules {$2} + | {[]} + ; + + rule: + | IDENTIFIER ARROW list_ident EOL { + { rule_nt = $1; rule_prods = $3; rule_action = None } } + | IDENTIFIER ARROW list_ident EOL? CODE EOL { + { rule_nt = $1; rule_prods = $3; rule_action = Some $5 } } + ; + +%% diff --git a/alpaga/list_utils.ml b/alpaga/list_utils.ml new file mode 100644 index 0000000000000000000000000000000000000000..7b932aa9049fda89fa42fdbbf0fa136f620c34f6 --- /dev/null +++ b/alpaga/list_utils.ml @@ -0,0 +1,51 @@ +open List + +(* Affiche une liste de string. *) +let print_list oc l = + List.iter (fun s -> Printf.fprintf oc "%s " s) l + + +let rec print_seq p = function + | [] -> "" + | a::r -> " " ^ p a ^ print_seq p r + +let hashget_def t k d = + match Hashtbl.find_opt t k with + | None -> d + | Some b -> b + +(* Teste si toutes les valeurs de [l1] sont dans [l2]. + (Relation "sous-ensemble") *) +let incl l1 l2 = + for_all (fun x -> mem x l2) l1 + +(* Relation "même ensemble". *) +let same_list l1 l2 = incl l1 l2 && incl l2 l1 + +(* L'ensemble des éléments de [l1] qui ne sont pas dans [l2]. *) +let diff l1 l2 = + filter (fun x -> not (mem x l2)) l1 + +(* Enlève les doublons dans une liste. *) +let rec cleardup l = + match l with + [] -> [] + | a::r -> if mem a r then cleardup r else a::cleardup r + +let inter l1 l2 = + filter (fun x -> mem x l2) l1 + +let disjoint l1 l2 = + inter l1 l2 = [] + +let rec filter_map f l = + match l with + [] -> [] + | a::r -> + match f a with + | Some fa -> fa :: filter_map f r + | _ -> filter_map f r + +let filter_mapi f l = + filter_map (fun (i,e) -> f i e) + (List.mapi (fun i e -> (i,e)) l) diff --git a/alpaga/ll_parser.ml b/alpaga/ll_parser.ml new file mode 100644 index 0000000000000000000000000000000000000000..b6f72c964c8b65757f10f1c5ed4719333f1e37d2 --- /dev/null +++ b/alpaga/ll_parser.ml @@ -0,0 +1,257 @@ +open Batteries +open List_utils +open List +open Grammar + + +let iter_until_fixpoint (f : unit -> bool) name = + let rec aux i = + if f () + then aux (i+1) + else Printf.printf "Finished %s after %d steps.\n" name i in + aux 1 + +let id x = x + +let apply_on_all f l = List.exists id (List.map f l) + +let nullt : (string, bool) Hashtbl.t = Hashtbl.create 20 +let firstt : (string, string Set.t) Hashtbl.t = Hashtbl.create 20 +let followt : (string, string Set.t) Hashtbl.t = Hashtbl.create 20 + +let nullable k = hashget_def nullt k false +let first n = hashget_def firstt n Set.empty +let follow n = hashget_def followt n Set.empty + +let null_nt (toks,nts,rules) (n: string) : bool = + if hashget_def nullt n false then false + else + begin + let r = List.filter (fun {rule_nt = x; _} -> x = n) rules in + let r = List.map (fun {rule_prods = x} -> x) r in + let can_be_null = List.exists (List.for_all nullable) r in + Hashtbl.replace nullt n can_be_null; can_be_null + end + +let null_all_nt (toks,nts,rules) () : bool = apply_on_all (null_nt (toks,nts,rules)) nts + +let iter_nullnt (toks,nts,rules) () = iter_until_fixpoint (null_all_nt (toks,nts,rules)) "nullnt" + +let rec first_prod (toks,nts,rules) (p: string list) : string Set.t = + match p with + | [] -> Set.empty + | s::r -> + if List.mem s toks then Set.singleton s + else begin Set.union (first s) (if nullable s then first_prod (toks,nts,rules) r else Set.empty) end + +let first_nt (toks,nts,rules) (n: string) : bool = + let old = first n in + let r = List.filter (fun {rule_nt = x} -> x = n) rules in + let r = List.map (fun {rule_prods = x} -> x) r in + let f = List.fold_left Set.union Set.empty (List.map (first_prod (toks,nts,rules)) r) in + Hashtbl.replace firstt n f; not (Set.equal old f) + +let iter_first (toks,nts,rules) () = + iter_until_fixpoint (fun () -> apply_on_all (first_nt (toks,nts,rules)) nts) "firstt" + +let rec cut_prod (x: string) (l: string list) : string list = + match l with + [] -> [] + | a::r -> if a = x then r else cut_prod x r + +let null_prodlist (toks,nts,rules)(pl: string list) = + List.for_all (fun p -> + if List.mem p toks then false + else nullable p) pl + +let follow_nt (toks,nts,rules) (n: string) : bool = + let old = follow n in + let l = List.filter (fun { rule_prods = x} -> List.mem n x) rules in + let l = List.map (fun {rule_nt = fx; rule_prods = sx} -> (fx, cut_prod n sx)) l in + let l = List.map (fun x -> Set.union (if null_prodlist (toks,nts,rules) (snd x) + then follow (fst x) + else Set.empty) (first_prod (toks,nts,rules) (snd x))) l in + let l = List.fold_left Set.union Set.empty l in + Hashtbl.add followt n l; + not (Set.equal old l) + +let follow_all_nt (toks,nts,rules) () = apply_on_all (follow_nt (toks,nts,rules)) nts + +let iter_follownt (toks,nts,rules) () = + iter_until_fixpoint (follow_all_nt (toks,nts,rules)) "follownt" + +type lltype = First of int | Follow of int + +let lltable : (string * string, lltype list) Hashtbl.t = Hashtbl.create 20 + +let add_into_table x t p = + Hashtbl.add lltable (x,t) (cleardup (hashget_def lltable (x,t) [] @ [p])) + + +let fill_lltable (toks,nts,rules) () = + List.iteri (fun i {rule_nt = x; rule_prods = gamma} -> + List.iter (fun t -> add_into_table x t (First (i+1))) (Set.to_list (first_prod (toks,nts,rules) gamma)); + if null_prodlist (toks,nts,rules) gamma + then + List.iter (fun t -> add_into_table x t (Follow (i+1))) (Set.to_list (follow x)) + ) rules + +let string_of_lltype = function + | First i -> Printf.sprintf "<a style='color:blue;' href=\"#rule-%d\">%d</a>" i i + | Follow i -> Printf.sprintf "<a style='color:red;' href=\"#rule-%d\">%d</a>" i i + + +let check_conflicts (toks,nts,rules) () = + List.fold_left + (fun acc x -> + List.fold_left (fun acc t -> + let rs = (hashget_def lltable (x,t) []) in + if List.length rs > 1 then true else acc + ) acc toks + ) false + nts + + +let print_table (toks,nts,rules) oc () = + Format.fprintf oc "<!DOCTYPE html>" ; + Format.fprintf oc "<html><head><link rel='stylesheet' type='text/css' href='style.css'/></head>\n"; + Format.fprintf oc "<body><table><tr><th></th>" ; + List.iter (fun t -> + Format.fprintf oc " <th class='bigth'><div class='verticalText'>%s</div></th> " t + ) toks; + Format.fprintf oc "</tr>\n"; + List.iteri + (fun i x -> + Format.fprintf oc "<tr><td style='text-align:center;'>%s</td> " x; + List.iter (fun t -> + let rs = (hashget_def lltable (x,t) []) in + Format.fprintf oc " <td style='text-align:center;%s'>%s</td> " + (if List.length rs > 1 then "background: rgba(255, 99, 71, 0.5);" else "") + (print_seq string_of_lltype rs) + ) toks; + ) + nts; + Format.fprintf oc "</table></body></html>\n" + +let str_replace s s1 s2 = + Str.global_replace (Str.regexp (Str.quote s1)) s2 s + + +let print_grammar (toks,nts,rules) oc () = + let counter = ref 1 in + Format.fprintf oc "<table>" ; + List.iter (fun nt -> + let rules : (string list * string) list = + filter_map (fun {rule_nt; rule_prods; rule_action} -> + if rule_nt = nt + then Some (rule_prods, match rule_action with Some a -> a | None -> "") + else None) rules + in + let first_rule = ref true in + List.iter (fun (rule,act) -> + Format.fprintf oc " <tr id='rule-%d' style='%s;'><td class='left'>(%d)</td> <td class='left'> %s </td class='left'> <td class='left'> -> </td> <td class='left'> %s</td><td class='left'><pre>%s</pre></td></tr>\n" + !counter + (if !first_rule then "border-top: solid 1px" else "border: none") + !counter + (if !first_rule then Format.sprintf "<span id='nt-%s'>%s</span>" nt nt else "") + (if rule = [] then "ε" else print_seq (fun x -> if List.mem x toks then x else Format.sprintf "<a href='#nt-%s' style='color: black;'>%s</a>" x x) rule) + act ; + first_rule := false; + counter:=!counter+1 + ) rules ; + Format.fprintf oc "\n" + + ) nts; + Format.fprintf oc "</table>\n" + + +let print_null (toks,nts,rules) oc () = + Format.fprintf oc "<br><table><tr><th>Non-terminal</th><th>Nullable</th></tr>\n" ; + List.iteri (fun i x -> + Format.fprintf oc "<tr><td> %s</td><td> %s</td></tr> \n" + x + (if nullable x then "true" else "false") + ) nts; + Format.fprintf oc "</table>\n<br>" + + +let print_first (toks,nts,rules) oc () = + Format.fprintf oc "<br><table><tr><th>Non-terminal</th><th>First</th></tr>\n" ; + List.iteri (fun i x -> + Format.fprintf oc " <tr><td>%s</td><td>%s</td></tr> \n" + x + (print_seq (fun y -> y) (Set.to_list (first x))) + ) nts; + Format.fprintf oc "</table>\n" + + +let print_follow (toks,nts,rules) oc () = + Format.fprintf oc "<table><tr><th> Non-terminal</th><th> Follow</th></tr>\n" ; + List.iteri (fun i x -> + Format.fprintf oc "<tr><td> %s </td><td> %s</td></tr> \n" + x + (print_seq (fun y -> y) (Set.to_list (follow x))) + ) nts; + Format.fprintf oc "</table>\n" + + + + +let print_html (toks,nts,rules) oc () = + Format.fprintf oc "<!DOCTYPE html>" ; + Format.fprintf oc "<html><head>\ + <style type=\"text/css\">\ + .bigth\ + {\ + text-align: center;\ + vertical-align: bottom;\ + height: 250px;\ + padding-bottom: 3px;\ + padding-left: 5px;\ + padding-right: 5px;\ + }\ + table {\ + display: inline-table;\ + margin: 1em;\ + border: solid 1px;\ + border-width: 1px;\ + border-collapse: collapse;\ + }\ + table th, table td {\ + border: solid 1px;\ + border-collapse: collapse;\ + }\ + .verticalText\ + {\ + text-align: center;\ + vertical-align: middle;\ + width: 20px;\ + margin: 0px;\ + padding: 0px;\ + padding-left: 3px;\ + padding-right: 3px;\ + padding-top: 10px;\ + white-space: nowrap;\ + -webkit-transform: rotate(-90deg);\ + -moz-transform: rotate(-90deg);\ + }\ + .left{\ + text-align: left;\ + border:none;\ + }\ + </style>\ + </head>\n"; + Format.fprintf oc "<body>\n" ; + Format.fprintf oc "<h1>Grammaire</h1>\n"; + print_grammar (toks,nts,rules) oc (); + Format.fprintf oc "<h1>Table Null</h1>\n"; + print_null (toks,nts,rules) oc (); + Format.fprintf oc "<h1>Table First</h1>\n"; + print_first (toks,nts,rules) oc (); + Format.fprintf oc "<h1>Table Follow</h1>\n"; + print_follow (toks,nts,rules) oc (); + Format.fprintf oc "<h1>Table LL</h1>\n"; + print_table (toks, nts, rules) oc (); + Format.fprintf oc "</body>\n</html>\n" + + diff --git a/alpaga/ml_parser_generator.ml b/alpaga/ml_parser_generator.ml new file mode 100644 index 0000000000000000000000000000000000000000..df837abdf4154dca69f510f41e4be85659604fce --- /dev/null +++ b/alpaga/ml_parser_generator.ml @@ -0,0 +1,187 @@ +open Grammar_parser +open Batteries +open Ll_parser +open List_utils +open Grammar + + +let int_of_lltype = function + | First i + | Follow i -> i + +let nth_rule (toks,nts,rules) a = + (List.nth rules (int_of_lltype a - 1)) + +let rec make_list l = + match l with + [] -> "[]" + | i::r -> Printf.sprintf "$%d :: %s" (i+1) (make_list r) + +(* Return the list of elements of the rule. *) +let default_action (pl: string list) : string = + (* make_list (List.mapi (fun i e -> i) pl) *) + "()" + +let resolve_vars s = + Str.global_replace (Str.regexp "\\$\\([0-9]+\\)") "p\\1" s + +let make_nt (table: string*string -> lltype list) (toks,nts,rules) oc (n,ot) () = + let t = match ot with | None -> "_" | Some t -> t in + let type_annot = Printf.sprintf ": ((%s) * ((token*Lexing.position option) list)) res" t + in + Printf.fprintf oc "and parse_%s (tokens: ((token*Lexing.position option) list)) () %s=\n" n type_annot; + Printf.fprintf oc " begin match tokens with\n"; + List.iteri + (fun i t -> + let rules = List.map (fun a -> nth_rule (toks,nts,rules) a) (table (n,t)) in + match rules with + [] -> () + | {rule_prods = pl; rule_action = act}::_ -> + Printf.fprintf oc " | (symbol, _) :: _ when is_%s symbol -> begin\n" t; + List.iteri + (fun i t -> + if List.mem t toks + then Printf.fprintf oc " eat_%s tokens >>= fun (p%d, tokens) ->\n" t (i + 1) + else Printf.fprintf oc " parse_%s tokens () >>= fun (p%d, tokens) ->\n" t (i+1)) + pl; + let act = match act with Some act -> act | _ -> default_action pl in + Printf.fprintf oc " let res = %s in\n" (resolve_vars act); + Printf.fprintf oc " OK (res, tokens)\n" ; + Printf.fprintf oc " end\n"; + ) + toks; + let expected = List.filter (fun t -> List.length (table (n,t)) > 0) toks in + Printf.fprintf oc " | tokens ->\n"; + Printf.fprintf oc " let got,lexpos =\n match tokens with\n [] -> \"EOF\",None\n | (symbol, lexpos) :: _ -> (string_of_symbol symbol, lexpos)\n in Error (\n"; + Printf.fprintf oc " (match lexpos with\n"; + Printf.fprintf oc " | Some lexpos -> Printf.sprintf \"At %%s, error while parsing %s\\n\" (string_of_position lexpos)\n" n; + Printf.fprintf oc " | None -> Printf.sprintf \"Error while parsing %s\\n\" )^\n" n; + Printf.fprintf oc " Printf.sprintf \"Expected one of {%%s}\"\n"; + Printf.fprintf oc " (String.concat \", \" (List.map string_of_symbol [%s])) ^\n" + (String.concat ";" (List.map (fun s -> "default_"^s) expected)) ; + Printf.fprintf oc " Printf.sprintf \" but got '%%s' instead.\\n\" got\n ^ "; + Printf.fprintf oc " Printf.sprintf \" '%%s' \\n\" (String.concat \",\" (List.map (fun (x, _) -> string_of_symbol x) (List.take 10 tokens)))\n"; + Printf.fprintf oc " )"; + Printf.fprintf oc "\n end\n\n" + +let make_parser (table: string*string -> lltype list) + (toks,nts,rules,mlcode) + (typ: (tokent * string) list) + (nttyp: (nonterm * string) list) + oc () = + Stdlib.Option.iter (fun mlcode -> Printf.fprintf oc "\n\n%s\n\n" mlcode) mlcode; + List.iter (fun t -> + begin match List.assoc_opt t typ with + | Some ty -> + begin + Printf.fprintf oc "let is_%s = function\n" t; + Printf.fprintf oc " | %s _ -> true\n" t; + Printf.fprintf oc " | _ -> false\n"; + + Printf.fprintf oc "let default_%s = %s %s\n" t t + (match ty with + "string" -> "\"\"" + | "int" -> "0" + | "bool" -> "false" + | "char" -> "'a'" + | _ -> failwith (Printf.sprintf "Don't know how to generate a default value of type %s" ty) + ) + end + | None -> begin + Printf.fprintf oc "let is_%s = function\n" t; + Printf.fprintf oc " | %s -> true\n" t; + Printf.fprintf oc " | _ -> false\n"; + Printf.fprintf oc "let default_%s = %s\n" t t + end + end; + ) toks; + List.iter (fun t -> + Printf.fprintf oc "let eat_%s = function\n" t; + begin match List.assoc_opt t typ with + | Some _ -> Printf.fprintf oc "| (%s(x),_) :: rtokens -> OK (x, rtokens)\n" t + | None -> Printf.fprintf oc "| (%s,_) :: rtokens -> OK ((), rtokens)\n" t + end; + Printf.fprintf oc "| (x,Some pos) :: _ -> Error (Printf.sprintf \"At position %%s, expected %%s, got %%s.\\n\"\n"; + Printf.fprintf oc " (string_of_position pos)\n"; + Printf.fprintf oc " (string_of_symbol default_%s)\n" t; + Printf.fprintf oc " (string_of_symbol x))\n"; + Printf.fprintf oc " | (x,None) :: _ -> Error (Printf.sprintf \"Expected %%s, got %%s.\\n\"\n"; + Printf.fprintf oc " (string_of_symbol default_%s)\n" t; + Printf.fprintf oc " (string_of_symbol x))\n"; + Printf.fprintf oc " | _ -> Error (Printf.sprintf \"Expected %%s, got EOF.\\n\" (string_of_symbol default_%s))\n" t; + + ) toks; + Printf.fprintf oc "let rec ____unused = ()\n"; + List.iter (fun n -> make_nt table (toks,nts,rules) oc (n, List.assoc_opt n nttyp) ()) nts + +let nts_ordered start (toks,nts,rules) = + let nts = + let rec aux acc nt = + if List.mem nt acc then acc + else let acc = nt::acc in + let rules : (string list * string) list = + filter_map (fun {rule_nt; rule_prods; rule_action} -> + if rule_nt = nt + then Some (rule_prods, match rule_action with Some a -> a | None -> "") + else None) rules + in + List.fold_left (fun acc (rule,act) -> + List.fold_left (fun acc tokornt -> + if List.mem tokornt toks then acc else aux acc tokornt + ) acc rule + ) acc rules + in List.rev (aux [] start) + in + let rules = + List.concat (List.map (fun nt -> List.filter (fun r -> r.rule_nt = nt) rules) nts) + in (nts,rules) + +let _ = + let grammar_file = ref None in + let table_file = ref None in + let parser_ml_file = ref None in + + Arg.parse + [("-g", Arg.String (fun s -> grammar_file := Some s), "Input grammar file (.g)"); + ("-t", Arg.String (fun s -> table_file := Some s), "Where to output tables (.html)"); + ("-pml", Arg.String (fun s -> parser_ml_file := Some s), "Where to output the parser code (.ml)"); + ] print_endline "Usage: "; + match !grammar_file with + | None -> failwith "Please specify a grammar file using '-g <grammar.g>'" + | Some gramfile -> + let gram, axiom = parse_grammar gramfile in + let (toks, nts, rules, mlcode) = + (gram.tokens, gram.nonterms, gram.rules, gram.mlcode) in + let toks = List.map fst gram.tokens in + let (nts, rules) = nts_ordered axiom (toks,nts,rules) in + iter_nullnt (toks, nts, rules) (); + iter_first (toks, nts, rules) (); + iter_follownt (toks, nts, rules) (); + fill_lltable (toks, nts, rules) (); + let has_conflict = check_conflicts (toks, nts, rules) () in + if has_conflict + then Printf.fprintf stderr "Warning! There is a conflict in your grammar. Check the prediction table for more details.\n"; + (match !table_file with + | Some tfile -> let oc = open_out tfile in + print_html (toks, nts, rules) (Format.formatter_of_out_channel oc) (); + close_out oc + | None -> ()); + (match !parser_ml_file with + | None -> Printf.fprintf stderr "Please specify where I should write the generated parser code using '-pml <generated_parser.ml>'" + | Some mlfile -> + let oc = open_out mlfile in + make_parser (fun (n,t) -> hashget_def lltable (n,t) []) + (toks, nts, rules, mlcode) + (List.filter_map (fun (t,o) -> + match o with + | None -> None + | Some typ -> Some (t,typ) + ) gram.tokens) + (List.filter_map (fun (t,o) -> + match o with + | None -> None + | Some typ -> Some (t,typ) + ) gram.nonterms) + oc (); + close_out oc + ) diff --git a/configure b/configure new file mode 100755 index 0000000000000000000000000000000000000000..b9ddeaf05f695d23fd2c3d7720bb2ae034c5f81e --- /dev/null +++ b/configure @@ -0,0 +1,48 @@ +#!/bin/bash + +LEX_HAND="true" +ALPAGA_PARSER="true" + +while [[ $# -gt 0 ]] +do + key="$1" + + case $key in + -l|--lex-hand) + LEX_HAND="true" + shift + ;; + -L|--lex-ocamllex) + LEX_HAND="false" + shift + ;; + -a|--alpaga-parser) + ALPAGA_PARSER="true" + shift + ;; + -m|--menhir-parser) + ALPAGA_PARSER="false" + shift + ;; + *) # unknown option + shift # past argument + ;; + esac +done + +RUNTIME=$(pwd)/runtime + +RVAS=$(which -a riscv64-unknown-linux-gnu-as riscv64-unknown-elf-as riscv64-linux-gnu-as 2>/dev/null | grep -v "not found" | head -n1) +RVLD=$(which -a riscv64-unknown-linux-gnu-ld riscv64-unknown-elf-ld riscv64-linux-gnu-ld 2>/dev/null | grep -v "not found" | head -n1) +QEMU32=$(which -a qemu-riscv32 qemu-riscv32-static 2>/dev/null | grep -v "not found" | head -n1) +QEMU64=$(which -a qemu-riscv64 qemu-riscv64-static 2>/dev/null | grep -v "not found" | head -n1) + + +echo "let runtime_dir = \"${RUNTIME}\"" > src/config.ml +echo "let qemu32 = \"${QEMU32}\"" >> src/config.ml +echo "let qemu64 = \"${QEMU64}\"" >> src/config.ml +echo "let rv_as = \"${RVAS}\"" >> src/config.ml +echo "let rv_ld = \"${RVLD}\"" >> src/config.ml +echo "let os_target = \"linux\"" >> src/config.ml +echo "let lex_hand = $LEX_HAND" >> src/config.ml +echo "let alpaga_parser = $ALPAGA_PARSER" >> src/config.ml diff --git a/expr_grammar_action.g b/expr_grammar_action.g new file mode 100644 index 0000000000000000000000000000000000000000..9ab7ecd32a798aa929d04416aa9706f289d1ce20 --- /dev/null +++ b/expr_grammar_action.g @@ -0,0 +1,32 @@ +tokens SYM_EOF SYM_IDENTIFIER<string> SYM_INTEGER<int> SYM_PLUS SYM_MINUS SYM_ASTERISK SYM_DIV SYM_MOD +tokens SYM_LPARENTHESIS SYM_RPARENTHESIS SYM_LBRACE SYM_RBRACE +tokens SYM_ASSIGN SYM_SEMICOLON SYM_RETURN SYM_IF SYM_WHILE SYM_ELSE SYM_COMMA SYM_PRINT +tokens SYM_EQUALITY SYM_NOTEQ SYM_LT SYM_LEQ SYM_GT SYM_GEQ +non-terminals S INSTR<tree> INSTRS<tree list> LINSTRS ELSE EXPR FACTOR +non-terminals LPARAMS REST_PARAMS +non-terminals IDENTIFIER INTEGER +non-terminals FUNDEF FUNDEFS +non-terminals ADD_EXPRS ADD_EXPR +non-terminals MUL_EXPRS MUL_EXPR +non-terminals CMP_EXPRS CMP_EXPR +non-terminals EQ_EXPRS EQ_EXPR +axiom S +{ + + open Symbols + open Ast + open BatPrintf + open BatBuffer + open Batteries + open Utils + + (* TODO *) + let resolve_associativity term other = + (* TODO *) + term + + +} + +rules +S -> FUNDEFS SYM_EOF { Node (Tlistglobdef, []) } diff --git a/ldb/d3.v5.min.js b/ldb/d3.v5.min.js new file mode 100644 index 0000000000000000000000000000000000000000..e9db321be9b032b038911f791456835a8ae1579c --- /dev/null +++ b/ldb/d3.v5.min.js @@ -0,0 +1,2 @@ +// https://d3js.org v5.12.0 Copyright 2019 Mike Bostock +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).d3=t.d3||{})}(this,function(t){"use strict";function n(t,n){return t<n?-1:t>n?1:t>=n?0:NaN}function e(t){var e;return 1===t.length&&(e=t,t=function(t,r){return n(e(t),r)}),{left:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r<i;){var o=r+i>>>1;t(n[o],e)<0?r=o+1:i=o}return r},right:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r<i;){var o=r+i>>>1;t(n[o],e)>0?i=o:r=o+1}return r}}}var r=e(n),i=r.right,o=r.left;function a(t,n){return[t,n]}function u(t){return null===t?NaN:+t}function c(t,n){var e,r,i=t.length,o=0,a=-1,c=0,f=0;if(null==n)for(;++a<i;)isNaN(e=u(t[a]))||(f+=(r=e-c)*(e-(c+=r/++o)));else for(;++a<i;)isNaN(e=u(n(t[a],a,t)))||(f+=(r=e-c)*(e-(c+=r/++o)));if(o>1)return f/(o-1)}function f(t,n){var e=c(t,n);return e?Math.sqrt(e):e}function s(t,n){var e,r,i,o=t.length,a=-1;if(null==n){for(;++a<o;)if(null!=(e=t[a])&&e>=e)for(r=i=e;++a<o;)null!=(e=t[a])&&(r>e&&(r=e),i<e&&(i=e))}else for(;++a<o;)if(null!=(e=n(t[a],a,t))&&e>=e)for(r=i=e;++a<o;)null!=(e=n(t[a],a,t))&&(r>e&&(r=e),i<e&&(i=e));return[r,i]}var l=Array.prototype,h=l.slice,d=l.map;function p(t){return function(){return t}}function v(t){return t}function g(t,n,e){t=+t,n=+n,e=(i=arguments.length)<2?(n=t,t=0,1):i<3?1:+e;for(var r=-1,i=0|Math.max(0,Math.ceil((n-t)/e)),o=new Array(i);++r<i;)o[r]=t+r*e;return o}var y=Math.sqrt(50),_=Math.sqrt(10),b=Math.sqrt(2);function m(t,n,e){var r,i,o,a,u=-1;if(e=+e,(t=+t)===(n=+n)&&e>0)return[t];if((r=n<t)&&(i=t,t=n,n=i),0===(a=x(t,n,e))||!isFinite(a))return[];if(a>0)for(t=Math.ceil(t/a),n=Math.floor(n/a),o=new Array(i=Math.ceil(n-t+1));++u<i;)o[u]=(t+u)*a;else for(t=Math.floor(t*a),n=Math.ceil(n*a),o=new Array(i=Math.ceil(t-n+1));++u<i;)o[u]=(t-u)/a;return r&&o.reverse(),o}function x(t,n,e){var r=(n-t)/Math.max(0,e),i=Math.floor(Math.log(r)/Math.LN10),o=r/Math.pow(10,i);return i>=0?(o>=y?10:o>=_?5:o>=b?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=y?10:o>=_?5:o>=b?2:1)}function w(t,n,e){var r=Math.abs(n-t)/Math.max(0,e),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=y?i*=10:o>=_?i*=5:o>=b&&(i*=2),n<t?-i:i}function M(t){return Math.ceil(Math.log(t.length)/Math.LN2)+1}function N(t,n,e){if(null==e&&(e=u),r=t.length){if((n=+n)<=0||r<2)return+e(t[0],0,t);if(n>=1)return+e(t[r-1],r-1,t);var r,i=(r-1)*n,o=Math.floor(i),a=+e(t[o],o,t);return a+(+e(t[o+1],o+1,t)-a)*(i-o)}}function A(t,n){var e,r,i=t.length,o=-1;if(null==n){for(;++o<i;)if(null!=(e=t[o])&&e>=e)for(r=e;++o<i;)null!=(e=t[o])&&e>r&&(r=e)}else for(;++o<i;)if(null!=(e=n(t[o],o,t))&&e>=e)for(r=e;++o<i;)null!=(e=n(t[o],o,t))&&e>r&&(r=e);return r}function T(t){for(var n,e,r,i=t.length,o=-1,a=0;++o<i;)a+=t[o].length;for(e=new Array(a);--i>=0;)for(n=(r=t[i]).length;--n>=0;)e[--a]=r[n];return e}function S(t,n){var e,r,i=t.length,o=-1;if(null==n){for(;++o<i;)if(null!=(e=t[o])&&e>=e)for(r=e;++o<i;)null!=(e=t[o])&&r>e&&(r=e)}else for(;++o<i;)if(null!=(e=n(t[o],o,t))&&e>=e)for(r=e;++o<i;)null!=(e=n(t[o],o,t))&&r>e&&(r=e);return r}function k(t){if(!(i=t.length))return[];for(var n=-1,e=S(t,E),r=new Array(e);++n<e;)for(var i,o=-1,a=r[n]=new Array(i);++o<i;)a[o]=t[o][n];return r}function E(t){return t.length}var C=Array.prototype.slice;function P(t){return t}var z=1,R=2,D=3,q=4,L=1e-6;function U(t){return"translate("+(t+.5)+",0)"}function O(t){return"translate(0,"+(t+.5)+")"}function B(){return!this.__axis}function Y(t,n){var e=[],r=null,i=null,o=6,a=6,u=3,c=t===z||t===q?-1:1,f=t===q||t===R?"x":"y",s=t===z||t===D?U:O;function l(l){var h=null==r?n.ticks?n.ticks.apply(n,e):n.domain():r,d=null==i?n.tickFormat?n.tickFormat.apply(n,e):P:i,p=Math.max(o,0)+u,v=n.range(),g=+v[0]+.5,y=+v[v.length-1]+.5,_=(n.bandwidth?function(t){var n=Math.max(0,t.bandwidth()-1)/2;return t.round()&&(n=Math.round(n)),function(e){return+t(e)+n}}:function(t){return function(n){return+t(n)}})(n.copy()),b=l.selection?l.selection():l,m=b.selectAll(".domain").data([null]),x=b.selectAll(".tick").data(h,n).order(),w=x.exit(),M=x.enter().append("g").attr("class","tick"),N=x.select("line"),A=x.select("text");m=m.merge(m.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),x=x.merge(M),N=N.merge(M.append("line").attr("stroke","currentColor").attr(f+"2",c*o)),A=A.merge(M.append("text").attr("fill","currentColor").attr(f,c*p).attr("dy",t===z?"0em":t===D?"0.71em":"0.32em")),l!==b&&(m=m.transition(l),x=x.transition(l),N=N.transition(l),A=A.transition(l),w=w.transition(l).attr("opacity",L).attr("transform",function(t){return isFinite(t=_(t))?s(t):this.getAttribute("transform")}),M.attr("opacity",L).attr("transform",function(t){var n=this.parentNode.__axis;return s(n&&isFinite(n=n(t))?n:_(t))})),w.remove(),m.attr("d",t===q||t==R?a?"M"+c*a+","+g+"H0.5V"+y+"H"+c*a:"M0.5,"+g+"V"+y:a?"M"+g+","+c*a+"V0.5H"+y+"V"+c*a:"M"+g+",0.5H"+y),x.attr("opacity",1).attr("transform",function(t){return s(_(t))}),N.attr(f+"2",c*o),A.attr(f,c*p).text(d),b.filter(B).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===R?"start":t===q?"end":"middle"),b.each(function(){this.__axis=_})}return l.scale=function(t){return arguments.length?(n=t,l):n},l.ticks=function(){return e=C.call(arguments),l},l.tickArguments=function(t){return arguments.length?(e=null==t?[]:C.call(t),l):e.slice()},l.tickValues=function(t){return arguments.length?(r=null==t?null:C.call(t),l):r&&r.slice()},l.tickFormat=function(t){return arguments.length?(i=t,l):i},l.tickSize=function(t){return arguments.length?(o=a=+t,l):o},l.tickSizeInner=function(t){return arguments.length?(o=+t,l):o},l.tickSizeOuter=function(t){return arguments.length?(a=+t,l):a},l.tickPadding=function(t){return arguments.length?(u=+t,l):u},l}var F={value:function(){}};function I(){for(var t,n=0,e=arguments.length,r={};n<e;++n){if(!(t=arguments[n]+"")||t in r)throw new Error("illegal type: "+t);r[t]=[]}return new H(r)}function H(t){this._=t}function j(t,n){return t.trim().split(/^|\s+/).map(function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})}function X(t,n){for(var e,r=0,i=t.length;r<i;++r)if((e=t[r]).name===n)return e.value}function G(t,n,e){for(var r=0,i=t.length;r<i;++r)if(t[r].name===n){t[r]=F,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=e&&t.push({name:n,value:e}),t}H.prototype=I.prototype={constructor:H,on:function(t,n){var e,r=this._,i=j(t+"",r),o=-1,a=i.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++o<a;)if(e=(t=i[o]).type)r[e]=G(r[e],t.name,n);else if(null==n)for(e in r)r[e]=G(r[e],t.name,null);return this}for(;++o<a;)if((e=(t=i[o]).type)&&(e=X(r[e],t.name)))return e},copy:function(){var t={},n=this._;for(var e in n)t[e]=n[e].slice();return new H(t)},call:function(t,n){if((e=arguments.length-2)>0)for(var e,r,i=new Array(e),o=0;o<e;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,e=(r=this._[t]).length;o<e;++o)r[o].value.apply(n,i)},apply:function(t,n,e){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(n,e)}};var V="http://www.w3.org/1999/xhtml",$={svg:"http://www.w3.org/2000/svg",xhtml:V,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function W(t){var n=t+="",e=n.indexOf(":");return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),$.hasOwnProperty(n)?{space:$[n],local:t}:t}function Z(t){var n=W(t);return(n.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===V&&n.documentElement.namespaceURI===V?n.createElement(t):n.createElementNS(e,t)}})(n)}function Q(){}function K(t){return null==t?Q:function(){return this.querySelector(t)}}function J(){return[]}function tt(t){return null==t?J:function(){return this.querySelectorAll(t)}}function nt(t){return function(){return this.matches(t)}}function et(t){return new Array(t.length)}function rt(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}rt.prototype={constructor:rt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var it="$";function ot(t,n,e,r,i,o){for(var a,u=0,c=n.length,f=o.length;u<f;++u)(a=n[u])?(a.__data__=o[u],r[u]=a):e[u]=new rt(t,o[u]);for(;u<c;++u)(a=n[u])&&(i[u]=a)}function at(t,n,e,r,i,o,a){var u,c,f,s={},l=n.length,h=o.length,d=new Array(l);for(u=0;u<l;++u)(c=n[u])&&(d[u]=f=it+a.call(c,c.__data__,u,n),f in s?i[u]=c:s[f]=c);for(u=0;u<h;++u)(c=s[f=it+a.call(t,o[u],u,o)])?(r[u]=c,c.__data__=o[u],s[f]=null):e[u]=new rt(t,o[u]);for(u=0;u<l;++u)(c=n[u])&&s[d[u]]===c&&(i[u]=c)}function ut(t,n){return t<n?-1:t>n?1:t>=n?0:NaN}function ct(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ft(t,n){return t.style.getPropertyValue(n)||ct(t).getComputedStyle(t,null).getPropertyValue(n)}function st(t){return t.trim().split(/^|\s+/)}function lt(t){return t.classList||new ht(t)}function ht(t){this._node=t,this._names=st(t.getAttribute("class")||"")}function dt(t,n){for(var e=lt(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function pt(t,n){for(var e=lt(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function vt(){this.textContent=""}function gt(){this.innerHTML=""}function yt(){this.nextSibling&&this.parentNode.appendChild(this)}function _t(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function bt(){return null}function mt(){var t=this.parentNode;t&&t.removeChild(this)}function xt(){return this.parentNode.insertBefore(this.cloneNode(!1),this.nextSibling)}function wt(){return this.parentNode.insertBefore(this.cloneNode(!0),this.nextSibling)}ht.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Mt={};(t.event=null,"undefined"!=typeof document)&&("onmouseenter"in document.documentElement||(Mt={mouseenter:"mouseover",mouseleave:"mouseout"}));function Nt(t,n,e){return t=At(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function At(n,e,r){return function(i){var o=t.event;t.event=i;try{n.call(this,this.__data__,e,r)}finally{t.event=o}}}function Tt(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;r<o;++r)e=n[r],t.type&&e.type!==t.type||e.name!==t.name?n[++i]=e:this.removeEventListener(e.type,e.listener,e.capture);++i?n.length=i:delete this.__on}}}function St(t,n,e){var r=Mt.hasOwnProperty(t.type)?Nt:At;return function(i,o,a){var u,c=this.__on,f=r(n,o,a);if(c)for(var s=0,l=c.length;s<l;++s)if((u=c[s]).type===t.type&&u.name===t.name)return this.removeEventListener(u.type,u.listener,u.capture),this.addEventListener(u.type,u.listener=f,u.capture=e),void(u.value=n);this.addEventListener(t.type,f,e),u={type:t.type,name:t.name,value:n,listener:f,capture:e},c?c.push(u):this.__on=[u]}}function kt(n,e,r,i){var o=t.event;n.sourceEvent=t.event,t.event=n;try{return e.apply(r,i)}finally{t.event=o}}function Et(t,n,e){var r=ct(t),i=r.CustomEvent;"function"==typeof i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}var Ct=[null];function Pt(t,n){this._groups=t,this._parents=n}function zt(){return new Pt([[document.documentElement]],Ct)}function Rt(t){return"string"==typeof t?new Pt([[document.querySelector(t)]],[document.documentElement]):new Pt([[t]],Ct)}Pt.prototype=zt.prototype={constructor:Pt,select:function(t){"function"!=typeof t&&(t=K(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a,u=n[i],c=u.length,f=r[i]=new Array(c),s=0;s<c;++s)(o=u[s])&&(a=t.call(o,o.__data__,s,u))&&("__data__"in o&&(a.__data__=o.__data__),f[s]=a);return new Pt(r,this._parents)},selectAll:function(t){"function"!=typeof t&&(t=tt(t));for(var n=this._groups,e=n.length,r=[],i=[],o=0;o<e;++o)for(var a,u=n[o],c=u.length,f=0;f<c;++f)(a=u[f])&&(r.push(t.call(a,a.__data__,f,u)),i.push(a));return new Pt(r,i)},filter:function(t){"function"!=typeof t&&(t=nt(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a=n[i],u=a.length,c=r[i]=[],f=0;f<u;++f)(o=a[f])&&t.call(o,o.__data__,f,a)&&c.push(o);return new Pt(r,this._parents)},data:function(t,n){if(!t)return d=new Array(this.size()),f=-1,this.each(function(t){d[++f]=t}),d;var e=n?at:ot,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var o=i.length,a=new Array(o),u=new Array(o),c=new Array(o),f=0;f<o;++f){var s=r[f],l=i[f],h=l.length,d=t.call(s,s&&s.__data__,f,r),p=d.length,v=u[f]=new Array(p),g=a[f]=new Array(p);e(s,l,v,g,c[f]=new Array(h),d,n);for(var y,_,b=0,m=0;b<p;++b)if(y=v[b]){for(b>=m&&(m=b+1);!(_=g[m])&&++m<p;);y._next=_||null}}return(a=new Pt(a,r))._enter=u,a._exit=c,a},enter:function(){return new Pt(this._enter||this._groups.map(et),this._parents)},exit:function(){return new Pt(this._exit||this._groups.map(et),this._parents)},join:function(t,n,e){var r=this.enter(),i=this,o=this.exit();return r="function"==typeof t?t(r):r.append(t+""),null!=n&&(i=n(i)),null==e?o.remove():e(o),r&&i?r.merge(i).order():i},merge:function(t){for(var n=this._groups,e=t._groups,r=n.length,i=e.length,o=Math.min(r,i),a=new Array(r),u=0;u<o;++u)for(var c,f=n[u],s=e[u],l=f.length,h=a[u]=new Array(l),d=0;d<l;++d)(c=f[d]||s[d])&&(h[d]=c);for(;u<r;++u)a[u]=n[u];return new Pt(a,this._parents)},order:function(){for(var t=this._groups,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,a=i[o];--o>=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=ut);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o<r;++o){for(var a,u=e[o],c=u.length,f=i[o]=new Array(c),s=0;s<c;++s)(a=u[s])&&(f[s]=a);f.sort(n)}return new Pt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){var t=new Array(this.size()),n=-1;return this.each(function(){t[++n]=this}),t},node:function(){for(var t=this._groups,n=0,e=t.length;n<e;++n)for(var r=t[n],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null},size:function(){var t=0;return this.each(function(){++t}),t},empty:function(){return!this.node()},each:function(t){for(var n=this._groups,e=0,r=n.length;e<r;++e)for(var i,o=n[e],a=0,u=o.length;a<u;++a)(i=o[a])&&t.call(i,i.__data__,a,o);return this},attr:function(t,n){var e=W(t);if(arguments.length<2){var r=this.node();return e.local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}return this.each((null==n?e.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}}:"function"==typeof n?e.local?function(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}:function(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}:e.local?function(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}:function(t,n){return function(){this.setAttribute(t,n)}})(e,n))},style:function(t,n,e){return arguments.length>1?this.each((null==n?function(t){return function(){this.style.removeProperty(t)}}:"function"==typeof n?function(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}:function(t,n,e){return function(){this.style.setProperty(t,n,e)}})(t,n,null==e?"":e)):ft(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?function(t){return function(){delete this[t]}}:"function"==typeof n?function(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}:function(t,n){return function(){this[t]=n}})(t,n)):this.node()[t]},classed:function(t,n){var e=st(t+"");if(arguments.length<2){for(var r=lt(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?function(t,n){return function(){(n.apply(this,arguments)?dt:pt)(this,t)}}:n?function(t){return function(){dt(this,t)}}:function(t){return function(){pt(this,t)}})(e,n))},text:function(t){return arguments.length?this.each(null==t?vt:("function"==typeof t?function(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}:function(t){return function(){this.textContent=t}})(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?gt:("function"==typeof t?function(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}:function(t){return function(){this.innerHTML=t}})(t)):this.node().innerHTML},raise:function(){return this.each(yt)},lower:function(){return this.each(_t)},append:function(t){var n="function"==typeof t?t:Z(t);return this.select(function(){return this.appendChild(n.apply(this,arguments))})},insert:function(t,n){var e="function"==typeof t?t:Z(t),r=null==n?bt:"function"==typeof n?n:K(n);return this.select(function(){return this.insertBefore(e.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(mt)},clone:function(t){return this.select(t?wt:xt)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,n,e){var r,i,o=function(t){return t.trim().split(/^|\s+/).map(function(t){var n="",e=t.indexOf(".");return e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}(t+""),a=o.length;if(!(arguments.length<2)){for(u=n?St:Tt,null==e&&(e=!1),r=0;r<a;++r)this.each(u(o[r],n,e));return this}var u=this.node().__on;if(u)for(var c,f=0,s=u.length;f<s;++f)for(r=0,c=u[f];r<a;++r)if((i=o[r]).type===c.type&&i.name===c.name)return c.value},dispatch:function(t,n){return this.each(("function"==typeof n?function(t,n){return function(){return Et(this,t,n.apply(this,arguments))}}:function(t,n){return function(){return Et(this,t,n)}})(t,n))}};var Dt=0;function qt(){return new Lt}function Lt(){this._="@"+(++Dt).toString(36)}function Ut(){for(var n,e=t.event;n=e.sourceEvent;)e=n;return e}function Ot(t,n){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();return r.x=n.clientX,r.y=n.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}var i=t.getBoundingClientRect();return[n.clientX-i.left-t.clientLeft,n.clientY-i.top-t.clientTop]}function Bt(t){var n=Ut();return n.changedTouches&&(n=n.changedTouches[0]),Ot(t,n)}function Yt(t,n,e){arguments.length<3&&(e=n,n=Ut().changedTouches);for(var r,i=0,o=n?n.length:0;i<o;++i)if((r=n[i]).identifier===e)return Ot(t,r);return null}function Ft(){t.event.stopImmediatePropagation()}function It(){t.event.preventDefault(),t.event.stopImmediatePropagation()}function Ht(t){var n=t.document.documentElement,e=Rt(t).on("dragstart.drag",It,!0);"onselectstart"in n?e.on("selectstart.drag",It,!0):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function jt(t,n){var e=t.document.documentElement,r=Rt(t).on("dragstart.drag",null);n&&(r.on("click.drag",It,!0),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in e?r.on("selectstart.drag",null):(e.style.MozUserSelect=e.__noselect,delete e.__noselect)}function Xt(t){return function(){return t}}function Gt(t,n,e,r,i,o,a,u,c,f){this.target=t,this.type=n,this.subject=e,this.identifier=r,this.active=i,this.x=o,this.y=a,this.dx=u,this.dy=c,this._=f}function Vt(){return!t.event.ctrlKey&&!t.event.button}function $t(){return this.parentNode}function Wt(n){return null==n?{x:t.event.x,y:t.event.y}:n}function Zt(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qt(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function Kt(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function Jt(){}Lt.prototype=qt.prototype={constructor:Lt,get:function(t){for(var n=this._;!(n in t);)if(!(t=t.parentNode))return;return t[n]},set:function(t,n){return t[this._]=n},remove:function(t){return this._ in t&&delete t[this._]},toString:function(){return this._}},Gt.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var tn="\\s*([+-]?\\d+)\\s*",nn="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",en="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",rn=/^#([0-9a-f]{3})$/,on=/^#([0-9a-f]{6})$/,an=new RegExp("^rgb\\("+[tn,tn,tn]+"\\)$"),un=new RegExp("^rgb\\("+[en,en,en]+"\\)$"),cn=new RegExp("^rgba\\("+[tn,tn,tn,nn]+"\\)$"),fn=new RegExp("^rgba\\("+[en,en,en,nn]+"\\)$"),sn=new RegExp("^hsl\\("+[nn,en,en]+"\\)$"),ln=new RegExp("^hsla\\("+[nn,en,en,nn]+"\\)$"),hn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function dn(){return this.rgb().formatHex()}function pn(){return this.rgb().formatRgb()}function vn(t){var n;return t=(t+"").trim().toLowerCase(),(n=rn.exec(t))?new mn((n=parseInt(n[1],16))>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):(n=on.exec(t))?gn(parseInt(n[1],16)):(n=an.exec(t))?new mn(n[1],n[2],n[3],1):(n=un.exec(t))?new mn(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=cn.exec(t))?yn(n[1],n[2],n[3],n[4]):(n=fn.exec(t))?yn(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=sn.exec(t))?Nn(n[1],n[2]/100,n[3]/100,1):(n=ln.exec(t))?Nn(n[1],n[2]/100,n[3]/100,n[4]):hn.hasOwnProperty(t)?gn(hn[t]):"transparent"===t?new mn(NaN,NaN,NaN,0):null}function gn(t){return new mn(t>>16&255,t>>8&255,255&t,1)}function yn(t,n,e,r){return r<=0&&(t=n=e=NaN),new mn(t,n,e,r)}function _n(t){return t instanceof Jt||(t=vn(t)),t?new mn((t=t.rgb()).r,t.g,t.b,t.opacity):new mn}function bn(t,n,e,r){return 1===arguments.length?_n(t):new mn(t,n,e,null==r?1:r)}function mn(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function xn(){return"#"+Mn(this.r)+Mn(this.g)+Mn(this.b)}function wn(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function Mn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Nn(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new Sn(t,n,e,r)}function An(t){if(t instanceof Sn)return new Sn(t.h,t.s,t.l,t.opacity);if(t instanceof Jt||(t=vn(t)),!t)return new Sn;if(t instanceof Sn)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,u=o-i,c=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e<r):e===o?(r-n)/u+2:(n-e)/u+4,u/=c<.5?o+i:2-o-i,a*=60):u=c>0&&c<1?0:a,new Sn(a,u,c,t.opacity)}function Tn(t,n,e,r){return 1===arguments.length?An(t):new Sn(t,n,e,null==r?1:r)}function Sn(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function kn(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}Qt(Jt,vn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:dn,formatHex:dn,formatHsl:function(){return An(this).formatHsl()},formatRgb:pn,toString:pn}),Qt(mn,bn,Kt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new mn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new mn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:xn,formatHex:xn,formatRgb:wn,toString:wn})),Qt(Sn,Tn,Kt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new Sn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new Sn(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new mn(kn(t>=240?t-240:t+120,i,r),kn(t,i,r),kn(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var En=Math.PI/180,Cn=180/Math.PI,Pn=.96422,zn=1,Rn=.82521,Dn=4/29,qn=6/29,Ln=3*qn*qn,Un=qn*qn*qn;function On(t){if(t instanceof Yn)return new Yn(t.l,t.a,t.b,t.opacity);if(t instanceof Vn)return $n(t);t instanceof mn||(t=_n(t));var n,e,r=jn(t.r),i=jn(t.g),o=jn(t.b),a=Fn((.2225045*r+.7168786*i+.0606169*o)/zn);return r===i&&i===o?n=e=a:(n=Fn((.4360747*r+.3850649*i+.1430804*o)/Pn),e=Fn((.0139322*r+.0971045*i+.7141733*o)/Rn)),new Yn(116*a-16,500*(n-a),200*(a-e),t.opacity)}function Bn(t,n,e,r){return 1===arguments.length?On(t):new Yn(t,n,e,null==r?1:r)}function Yn(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function Fn(t){return t>Un?Math.pow(t,1/3):t/Ln+Dn}function In(t){return t>qn?t*t*t:Ln*(t-Dn)}function Hn(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function jn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Xn(t){if(t instanceof Vn)return new Vn(t.h,t.c,t.l,t.opacity);if(t instanceof Yn||(t=On(t)),0===t.a&&0===t.b)return new Vn(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var n=Math.atan2(t.b,t.a)*Cn;return new Vn(n<0?n+360:n,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function Gn(t,n,e,r){return 1===arguments.length?Xn(t):new Vn(t,n,e,null==r?1:r)}function Vn(t,n,e,r){this.h=+t,this.c=+n,this.l=+e,this.opacity=+r}function $n(t){if(isNaN(t.h))return new Yn(t.l,0,0,t.opacity);var n=t.h*En;return new Yn(t.l,Math.cos(n)*t.c,Math.sin(n)*t.c,t.opacity)}Qt(Yn,Bn,Kt(Jt,{brighter:function(t){return new Yn(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new Yn(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,n=isNaN(this.a)?t:t+this.a/500,e=isNaN(this.b)?t:t-this.b/200;return new mn(Hn(3.1338561*(n=Pn*In(n))-1.6168667*(t=zn*In(t))-.4906146*(e=Rn*In(e))),Hn(-.9787684*n+1.9161415*t+.033454*e),Hn(.0719453*n-.2289914*t+1.4052427*e),this.opacity)}})),Qt(Vn,Gn,Kt(Jt,{brighter:function(t){return new Vn(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new Vn(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return $n(this).rgb()}}));var Wn=-.14861,Zn=1.78277,Qn=-.29227,Kn=-.90649,Jn=1.97294,te=Jn*Kn,ne=Jn*Zn,ee=Zn*Qn-Kn*Wn;function re(t,n,e,r){return 1===arguments.length?function(t){if(t instanceof ie)return new ie(t.h,t.s,t.l,t.opacity);t instanceof mn||(t=_n(t));var n=t.r/255,e=t.g/255,r=t.b/255,i=(ee*r+te*n-ne*e)/(ee+te-ne),o=r-i,a=(Jn*(e-i)-Qn*o)/Kn,u=Math.sqrt(a*a+o*o)/(Jn*i*(1-i)),c=u?Math.atan2(a,o)*Cn-120:NaN;return new ie(c<0?c+360:c,u,i,t.opacity)}(t):new ie(t,n,e,null==r?1:r)}function ie(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function oe(t,n,e,r,i){var o=t*t,a=o*t;return((1-3*t+3*o-a)*n+(4-6*o+3*a)*e+(1+3*t+3*o-3*a)*r+a*i)/6}function ae(t){var n=t.length-1;return function(e){var r=e<=0?e=0:e>=1?(e=1,n-1):Math.floor(e*n),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,u=r<n-1?t[r+2]:2*o-i;return oe((e-r/n)*n,a,i,o,u)}}function ue(t){var n=t.length;return function(e){var r=Math.floor(((e%=1)<0?++e:e)*n),i=t[(r+n-1)%n],o=t[r%n],a=t[(r+1)%n],u=t[(r+2)%n];return oe((e-r/n)*n,i,o,a,u)}}function ce(t){return function(){return t}}function fe(t,n){return function(e){return t+e*n}}function se(t,n){var e=n-t;return e?fe(t,e>180||e<-180?e-360*Math.round(e/360):e):ce(isNaN(t)?n:t)}function le(t){return 1==(t=+t)?he:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):ce(isNaN(n)?e:n)}}function he(t,n){var e=n-t;return e?fe(t,e):ce(isNaN(t)?n:t)}Qt(ie,re,Kt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new ie(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new ie(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*En,n=+this.l,e=isNaN(this.s)?0:this.s*n*(1-n),r=Math.cos(t),i=Math.sin(t);return new mn(255*(n+e*(Wn*r+Zn*i)),255*(n+e*(Qn*r+Kn*i)),255*(n+e*(Jn*r)),this.opacity)}}));var de=function t(n){var e=le(n);function r(t,n){var r=e((t=bn(t)).r,(n=bn(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=he(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function pe(t){return function(n){var e,r,i=n.length,o=new Array(i),a=new Array(i),u=new Array(i);for(e=0;e<i;++e)r=bn(n[e]),o[e]=r.r||0,a[e]=r.g||0,u[e]=r.b||0;return o=t(o),a=t(a),u=t(u),r.opacity=1,function(t){return r.r=o(t),r.g=a(t),r.b=u(t),r+""}}}var ve=pe(ae),ge=pe(ue);function ye(t,n){var e,r=n?n.length:0,i=t?Math.min(r,t.length):0,o=new Array(i),a=new Array(r);for(e=0;e<i;++e)o[e]=Ne(t[e],n[e]);for(;e<r;++e)a[e]=n[e];return function(t){for(e=0;e<i;++e)a[e]=o[e](t);return a}}function _e(t,n){var e=new Date;return n-=t=+t,function(r){return e.setTime(t+n*r),e}}function be(t,n){return n-=t=+t,function(e){return t+n*e}}function me(t,n){var e,r={},i={};for(e in null!==t&&"object"==typeof t||(t={}),null!==n&&"object"==typeof n||(n={}),n)e in t?r[e]=Ne(t[e],n[e]):i[e]=n[e];return function(t){for(e in r)i[e]=r[e](t);return i}}var xe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,we=new RegExp(xe.source,"g");function Me(t,n){var e,r,i,o=xe.lastIndex=we.lastIndex=0,a=-1,u=[],c=[];for(t+="",n+="";(e=xe.exec(t))&&(r=we.exec(n));)(i=r.index)>o&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,c.push({i:a,x:be(e,r)})),o=we.lastIndex;return o<n.length&&(i=n.slice(o),u[a]?u[a]+=i:u[++a]=i),u.length<2?c[0]?function(t){return function(n){return t(n)+""}}(c[0].x):function(t){return function(){return t}}(n):(n=c.length,function(t){for(var e,r=0;r<n;++r)u[(e=c[r]).i]=e.x(t);return u.join("")})}function Ne(t,n){var e,r=typeof n;return null==n||"boolean"===r?ce(n):("number"===r?be:"string"===r?(e=vn(n))?(n=e,de):Me:n instanceof vn?de:n instanceof Date?_e:Array.isArray(n)?ye:"function"!=typeof n.valueOf&&"function"!=typeof n.toString||isNaN(n)?me:be)(t,n)}function Ae(t,n){return n-=t=+t,function(e){return Math.round(t+n*e)}}var Te,Se,ke,Ee,Ce=180/Math.PI,Pe={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ze(t,n,e,r,i,o){var a,u,c;return(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a),(c=t*e+n*r)&&(e-=t*c,r-=n*c),(u=Math.sqrt(e*e+r*r))&&(e/=u,r/=u,c/=u),t*r<n*e&&(t=-t,n=-n,c=-c,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(n,t)*Ce,skewX:Math.atan(c)*Ce,scaleX:a,scaleY:u}}function Re(t,n,e,r){function i(t){return t.length?t.pop()+" ":""}return function(o,a){var u=[],c=[];return o=t(o),a=t(a),function(t,r,i,o,a,u){if(t!==i||r!==o){var c=a.push("translate(",null,n,null,e);u.push({i:c-4,x:be(t,i)},{i:c-2,x:be(r,o)})}else(i||o)&&a.push("translate("+i+n+o+e)}(o.translateX,o.translateY,a.translateX,a.translateY,u,c),function(t,n,e,o){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:be(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,c),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:be(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,c),function(t,n,e,r,o,a){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:be(t,e)},{i:u-2,x:be(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,c),o=a=null,function(t){for(var n,e=-1,r=c.length;++e<r;)u[(n=c[e]).i]=n.x(t);return u.join("")}}}var De=Re(function(t){return"none"===t?Pe:(Te||(Te=document.createElement("DIV"),Se=document.documentElement,ke=document.defaultView),Te.style.transform=t,t=ke.getComputedStyle(Se.appendChild(Te),null).getPropertyValue("transform"),Se.removeChild(Te),ze(+(t=t.slice(7,-1).split(","))[0],+t[1],+t[2],+t[3],+t[4],+t[5]))},"px, ","px)","deg)"),qe=Re(function(t){return null==t?Pe:(Ee||(Ee=document.createElementNS("http://www.w3.org/2000/svg","g")),Ee.setAttribute("transform",t),(t=Ee.transform.baseVal.consolidate())?ze((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Pe)},", ",")",")"),Le=Math.SQRT2,Ue=2,Oe=4,Be=1e-12;function Ye(t){return((t=Math.exp(t))+1/t)/2}function Fe(t,n){var e,r,i=t[0],o=t[1],a=t[2],u=n[0],c=n[1],f=n[2],s=u-i,l=c-o,h=s*s+l*l;if(h<Be)r=Math.log(f/a)/Le,e=function(t){return[i+t*s,o+t*l,a*Math.exp(Le*t*r)]};else{var d=Math.sqrt(h),p=(f*f-a*a+Oe*h)/(2*a*Ue*d),v=(f*f-a*a-Oe*h)/(2*f*Ue*d),g=Math.log(Math.sqrt(p*p+1)-p),y=Math.log(Math.sqrt(v*v+1)-v);r=(y-g)/Le,e=function(t){var n=t*r,e=Ye(g),u=a/(Ue*d)*(e*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(Le*n+g)-function(t){return((t=Math.exp(t))-1/t)/2}(g));return[i+u*s,o+u*l,a*e/Ye(Le*n+g)]}}return e.duration=1e3*r,e}function Ie(t){return function(n,e){var r=t((n=Tn(n)).h,(e=Tn(e)).h),i=he(n.s,e.s),o=he(n.l,e.l),a=he(n.opacity,e.opacity);return function(t){return n.h=r(t),n.s=i(t),n.l=o(t),n.opacity=a(t),n+""}}}var He=Ie(se),je=Ie(he);function Xe(t){return function(n,e){var r=t((n=Gn(n)).h,(e=Gn(e)).h),i=he(n.c,e.c),o=he(n.l,e.l),a=he(n.opacity,e.opacity);return function(t){return n.h=r(t),n.c=i(t),n.l=o(t),n.opacity=a(t),n+""}}}var Ge=Xe(se),Ve=Xe(he);function $e(t){return function n(e){function r(n,r){var i=t((n=re(n)).h,(r=re(r)).h),o=he(n.s,r.s),a=he(n.l,r.l),u=he(n.opacity,r.opacity);return function(t){return n.h=i(t),n.s=o(t),n.l=a(Math.pow(t,e)),n.opacity=u(t),n+""}}return e=+e,r.gamma=n,r}(1)}var We=$e(se),Ze=$e(he);var Qe,Ke,Je=0,tr=0,nr=0,er=1e3,rr=0,ir=0,or=0,ar="object"==typeof performance&&performance.now?performance:Date,ur="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function cr(){return ir||(ur(fr),ir=ar.now()+or)}function fr(){ir=0}function sr(){this._call=this._time=this._next=null}function lr(t,n,e){var r=new sr;return r.restart(t,n,e),r}function hr(){cr(),++Je;for(var t,n=Qe;n;)(t=ir-n._time)>=0&&n._call.call(null,t),n=n._next;--Je}function dr(){ir=(rr=ar.now())+or,Je=tr=0;try{hr()}finally{Je=0,function(){var t,n,e=Qe,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Qe=n);Ke=t,vr(r)}(),ir=0}}function pr(){var t=ar.now(),n=t-rr;n>er&&(or-=n,rr=t)}function vr(t){Je||(tr&&(tr=clearTimeout(tr)),t-ir>24?(t<1/0&&(tr=setTimeout(dr,t-ar.now()-or)),nr&&(nr=clearInterval(nr))):(nr||(rr=ar.now(),nr=setInterval(pr,er)),Je=1,ur(dr)))}function gr(t,n,e){var r=new sr;return n=null==n?0:+n,r.restart(function(e){r.stop(),t(e+n)},n,e),r}sr.prototype=lr.prototype={constructor:sr,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?cr():+e)+(null==n?0:+n),this._next||Ke===this||(Ke?Ke._next=this:Qe=this,Ke=this),this._call=t,this._time=e,vr()},stop:function(){this._call&&(this._call=null,this._time=1/0,vr())}};var yr=I("start","end","cancel","interrupt"),_r=[],br=0,mr=1,xr=2,wr=3,Mr=4,Nr=5,Ar=6;function Tr(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(c){var f,s,l,h;if(e.state!==mr)return u();for(f in i)if((h=i[f]).name===e.name){if(h.state===wr)return gr(o);h.state===Mr?(h.state=Ar,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[f]):+f<n&&(h.state=Ar,h.timer.stop(),h.on.call("cancel",t,t.__data__,h.index,h.group),delete i[f])}if(gr(function(){e.state===wr&&(e.state=Mr,e.timer.restart(a,e.delay,e.time),a(c))}),e.state=xr,e.on.call("start",t,t.__data__,e.index,e.group),e.state===xr){for(e.state=wr,r=new Array(l=e.tween.length),f=0,s=-1;f<l;++f)(h=e.tween[f].value.call(t,t.__data__,e.index,e.group))&&(r[++s]=h);r.length=s+1}}function a(n){for(var i=n<e.duration?e.ease.call(null,n/e.duration):(e.timer.restart(u),e.state=Nr,1),o=-1,a=r.length;++o<a;)r[o].call(t,i);e.state===Nr&&(e.on.call("end",t,t.__data__,e.index,e.group),u())}function u(){for(var r in e.state=Ar,e.timer.stop(),delete i[n],i)return;delete t.__transition}i[n]=e,e.timer=lr(function(t){e.state=mr,e.timer.restart(o,e.delay,e.time),e.delay<=t&&o(t-e.delay)},0,e.time)}(t,e,{name:n,index:r,group:i,on:yr,tween:_r,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:br})}function Sr(t,n){var e=Er(t,n);if(e.state>br)throw new Error("too late; already scheduled");return e}function kr(t,n){var e=Er(t,n);if(e.state>wr)throw new Error("too late; already running");return e}function Er(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Cr(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>xr&&e.state<Nr,e.state=Ar,e.timer.stop(),e.on.call(r?"interrupt":"cancel",t,t.__data__,e.index,e.group),delete o[i]):a=!1;a&&delete t.__transition}}function Pr(t,n,e){var r=t._id;return t.each(function(){var t=kr(this,r);(t.value||(t.value={}))[n]=e.apply(this,arguments)}),function(t){return Er(t,r).value[n]}}function zr(t,n){var e;return("number"==typeof n?be:n instanceof vn?de:(e=vn(n))?(n=e,de):Me)(t,n)}var Rr=zt.prototype.constructor;function Dr(t){return function(){this.style.removeProperty(t)}}var qr=0;function Lr(t,n,e,r){this._groups=t,this._parents=n,this._name=e,this._id=r}function Ur(t){return zt().transition(t)}function Or(){return++qr}var Br=zt.prototype;function Yr(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}function Fr(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}Lr.prototype=Ur.prototype={constructor:Lr,select:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=K(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a<i;++a)for(var u,c,f=r[a],s=f.length,l=o[a]=new Array(s),h=0;h<s;++h)(u=f[h])&&(c=t.call(u,u.__data__,h,f))&&("__data__"in u&&(c.__data__=u.__data__),l[h]=c,Tr(l[h],n,e,h,l,Er(u,e)));return new Lr(o,this._parents,n,e)},selectAll:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=tt(t));for(var r=this._groups,i=r.length,o=[],a=[],u=0;u<i;++u)for(var c,f=r[u],s=f.length,l=0;l<s;++l)if(c=f[l]){for(var h,d=t.call(c,c.__data__,l,f),p=Er(c,e),v=0,g=d.length;v<g;++v)(h=d[v])&&Tr(h,n,e,v,d,p);o.push(d),a.push(c)}return new Lr(o,a,n,e)},filter:function(t){"function"!=typeof t&&(t=nt(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a=n[i],u=a.length,c=r[i]=[],f=0;f<u;++f)(o=a[f])&&t.call(o,o.__data__,f,a)&&c.push(o);return new Lr(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var n=this._groups,e=t._groups,r=n.length,i=e.length,o=Math.min(r,i),a=new Array(r),u=0;u<o;++u)for(var c,f=n[u],s=e[u],l=f.length,h=a[u]=new Array(l),d=0;d<l;++d)(c=f[d]||s[d])&&(h[d]=c);for(;u<r;++u)a[u]=n[u];return new Lr(a,this._parents,this._name,this._id)},selection:function(){return new Rr(this._groups,this._parents)},transition:function(){for(var t=this._name,n=this._id,e=Or(),r=this._groups,i=r.length,o=0;o<i;++o)for(var a,u=r[o],c=u.length,f=0;f<c;++f)if(a=u[f]){var s=Er(a,n);Tr(a,t,e,f,u,{time:s.time+s.delay+s.duration,delay:0,duration:s.duration,ease:s.ease})}return new Lr(r,this._parents,t,e)},call:Br.call,nodes:Br.nodes,node:Br.node,size:Br.size,empty:Br.empty,each:Br.each,on:function(t,n){var e=this._id;return arguments.length<2?Er(this.node(),e).on.on(t):this.each(function(t,n,e){var r,i,o=function(t){return(t+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?Sr:kr;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}(e,t,n))},attr:function(t,n){var e=W(t),r="transform"===e?qe:zr;return this.attrTween(t,"function"==typeof n?(e.local?function(t,n,e){var r,i,o;return function(){var a,u,c=e(this);if(null!=c)return(a=this.getAttributeNS(t.space,t.local))===(u=c+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,c));this.removeAttributeNS(t.space,t.local)}}:function(t,n,e){var r,i,o;return function(){var a,u,c=e(this);if(null!=c)return(a=this.getAttribute(t))===(u=c+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,c));this.removeAttribute(t)}})(e,r,Pr(this,"attr."+t,n)):null==n?(e.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}})(e):(e.local?function(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===o?null:a===r?i:i=n(r=a,e)}}:function(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttribute(t);return a===o?null:a===r?i:i=n(r=a,e)}})(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=W(t);return this.tween(e,(r.local?function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttributeNS(t.space,t.local,n(e))}}(t,i)),e}return i._value=n,i}:function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttribute(t,n(e))}}(t,i)),e}return i._value=n,i})(r,n))},style:function(t,n,e){var r="transform"==(t+="")?De:zr;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=ft(this,t),a=(this.style.removeProperty(t),ft(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,Dr(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=ft(this,t),u=e(this),c=u+"";return null==u&&(this.style.removeProperty(t),c=u=ft(this,t)),a===c?null:a===r&&c===i?o:(i=c,o=n(r=a,u))}}(t,r,Pr(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var c=kr(this,t),f=c.on,s=null==c.value[a]?o||(o=Dr(n)):void 0;f===e&&i===s||(r=(e=f).copy()).on(u,i=s),c.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=ft(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n(r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(Pr(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=Er(this.node(),e).tween,o=0,a=i.length;o<a;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==n?function(t,n){var e,r;return function(){var i=kr(this,t),o=i.tween;if(o!==e)for(var a=0,u=(r=e=o).length;a<u;++a)if(r[a].name===n){(r=r.slice()).splice(a,1);break}i.tween=r}}:function(t,n,e){var r,i;if("function"!=typeof e)throw new Error;return function(){var o=kr(this,t),a=o.tween;if(a!==r){i=(r=a).slice();for(var u={name:n,value:e},c=0,f=i.length;c<f;++c)if(i[c].name===n){i[c]=u;break}c===f&&i.push(u)}o.tween=i}})(e,t,n))},delay:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?function(t,n){return function(){Sr(this,t).delay=+n.apply(this,arguments)}}:function(t,n){return n=+n,function(){Sr(this,t).delay=n}})(n,t)):Er(this.node(),n).delay},duration:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?function(t,n){return function(){kr(this,t).duration=+n.apply(this,arguments)}}:function(t,n){return n=+n,function(){kr(this,t).duration=n}})(n,t)):Er(this.node(),n).duration},ease:function(t){var n=this._id;return arguments.length?this.each(function(t,n){if("function"!=typeof n)throw new Error;return function(){kr(this,t).ease=n}}(n,t)):Er(this.node(),n).ease},end:function(){var t,n,e=this,r=e._id,i=e.size();return new Promise(function(o,a){var u={value:a},c={value:function(){0==--i&&o()}};e.each(function(){var e=kr(this,r),i=e.on;i!==t&&((n=(t=i).copy())._.cancel.push(u),n._.interrupt.push(u),n._.end.push(c)),e.on=n})})}};var Ir=function t(n){function e(t){return Math.pow(t,n)}return n=+n,e.exponent=t,e}(3),Hr=function t(n){function e(t){return 1-Math.pow(1-t,n)}return n=+n,e.exponent=t,e}(3),jr=function t(n){function e(t){return((t*=2)<=1?Math.pow(t,n):2-Math.pow(2-t,n))/2}return n=+n,e.exponent=t,e}(3),Xr=Math.PI,Gr=Xr/2;function Vr(t){return(1-Math.cos(Xr*t))/2}function $r(t){return((t*=2)<=1?Math.pow(2,10*t-10):2-Math.pow(2,10-10*t))/2}function Wr(t){return((t*=2)<=1?1-Math.sqrt(1-t*t):Math.sqrt(1-(t-=2)*t)+1)/2}var Zr=4/11,Qr=6/11,Kr=8/11,Jr=.75,ti=9/11,ni=10/11,ei=.9375,ri=21/22,ii=63/64,oi=1/Zr/Zr;function ai(t){return(t=+t)<Zr?oi*t*t:t<Kr?oi*(t-=Qr)*t+Jr:t<ni?oi*(t-=ti)*t+ei:oi*(t-=ri)*t+ii}var ui=function t(n){function e(t){return t*t*((n+1)*t-n)}return n=+n,e.overshoot=t,e}(1.70158),ci=function t(n){function e(t){return--t*t*((n+1)*t+n)+1}return n=+n,e.overshoot=t,e}(1.70158),fi=function t(n){function e(t){return((t*=2)<1?t*t*((n+1)*t-n):(t-=2)*t*((n+1)*t+n)+2)/2}return n=+n,e.overshoot=t,e}(1.70158),si=2*Math.PI,li=function t(n,e){var r=Math.asin(1/(n=Math.max(1,n)))*(e/=si);function i(t){return n*Math.pow(2,10*--t)*Math.sin((r-t)/e)}return i.amplitude=function(n){return t(n,e*si)},i.period=function(e){return t(n,e)},i}(1,.3),hi=function t(n,e){var r=Math.asin(1/(n=Math.max(1,n)))*(e/=si);function i(t){return 1-n*Math.pow(2,-10*(t=+t))*Math.sin((t+r)/e)}return i.amplitude=function(n){return t(n,e*si)},i.period=function(e){return t(n,e)},i}(1,.3),di=function t(n,e){var r=Math.asin(1/(n=Math.max(1,n)))*(e/=si);function i(t){return((t=2*t-1)<0?n*Math.pow(2,10*t)*Math.sin((r-t)/e):2-n*Math.pow(2,-10*t)*Math.sin((r+t)/e))/2}return i.amplitude=function(n){return t(n,e*si)},i.period=function(e){return t(n,e)},i}(1,.3),pi={time:null,delay:0,duration:250,ease:Fr};function vi(t,n){for(var e;!(e=t.__transition)||!(e=e[n]);)if(!(t=t.parentNode))return pi.time=cr(),pi;return e}zt.prototype.interrupt=function(t){return this.each(function(){Cr(this,t)})},zt.prototype.transition=function(t){var n,e;t instanceof Lr?(n=t._id,t=t._name):(n=Or(),(e=pi).time=cr(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var a,u=r[o],c=u.length,f=0;f<c;++f)(a=u[f])&&Tr(a,t,n,f,u,e||vi(a,n));return new Lr(r,this._parents,t,n)};var gi=[null];function yi(t){return function(){return t}}function _i(t,n,e){this.target=t,this.type=n,this.selection=e}function bi(){t.event.stopImmediatePropagation()}function mi(){t.event.preventDefault(),t.event.stopImmediatePropagation()}var xi={name:"drag"},wi={name:"space"},Mi={name:"handle"},Ni={name:"center"};function Ai(t){return[+t[0],+t[1]]}function Ti(t){return[Ai(t[0]),Ai(t[1])]}var Si={name:"x",handles:["w","e"].map(qi),input:function(t,n){return null==t?null:[[+t[0],n[0][1]],[+t[1],n[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},ki={name:"y",handles:["n","s"].map(qi),input:function(t,n){return null==t?null:[[n[0][0],+t[0]],[n[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},Ei={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(qi),input:function(t){return null==t?null:Ti(t)},output:function(t){return t}},Ci={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Pi={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},zi={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},Ri={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},Di={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function qi(t){return{type:t}}function Li(){return!t.event.ctrlKey&&!t.event.button}function Ui(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function Oi(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bi(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function Yi(n){var e,r=Ui,i=Li,o=Oi,a=!0,u=I(f,"start","brush","end"),c=6;function f(t){var e=t.property("__brush",g).selectAll(".overlay").data([qi("overlay")]);e.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Ci.overlay).merge(e).each(function(){var t=Bi(this).extent;Rt(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])}),t.selectAll(".selection").data([qi("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Ci.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=t.selectAll(".handle").data(n.handles,function(t){return t.type});r.exit().remove(),r.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return Ci[t.type]}),t.each(s).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",d).filter(o).on("touchstart.brush",d).on("touchmove.brush",p).on("touchend.brush touchcancel.brush",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function s(){var t=Rt(this),n=Bi(this).selection;n?(t.selectAll(".selection").style("display",null).attr("x",n[0][0]).attr("y",n[0][1]).attr("width",n[1][0]-n[0][0]).attr("height",n[1][1]-n[0][1]),t.selectAll(".handle").style("display",null).attr("x",function(t){return"e"===t.type[t.type.length-1]?n[1][0]-c/2:n[0][0]-c/2}).attr("y",function(t){return"s"===t.type[0]?n[1][1]-c/2:n[0][1]-c/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?n[1][0]-n[0][0]+c:c}).attr("height",function(t){return"e"===t.type||"w"===t.type?n[1][1]-n[0][1]+c:c})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function l(t,n,e){return!e&&t.__brush.emitter||new h(t,n)}function h(t,n){this.that=t,this.args=n,this.state=t.__brush,this.active=0}function d(){if((!e||t.event.touches)&&i.apply(this,arguments)){var r,o,u,c,f,h,d,p,v,g,y,_,b=this,m=t.event.target.__data__.type,x="selection"===(a&&t.event.metaKey?m="overlay":m)?xi:a&&t.event.altKey?Ni:Mi,w=n===ki?null:Ri[m],M=n===Si?null:Di[m],N=Bi(b),A=N.extent,T=N.selection,S=A[0][0],k=A[0][1],E=A[1][0],C=A[1][1],P=0,z=0,R=w&&M&&a&&t.event.shiftKey,D=t.event.touches?(_=t.event.changedTouches[0].identifier,function(n){return Yt(n,t.event.touches,_)}):Bt,q=D(b),L=q,U=l(b,arguments,!0).beforestart();"overlay"===m?(T&&(v=!0),N.selection=T=[[r=n===ki?S:q[0],u=n===Si?k:q[1]],[f=n===ki?E:r,d=n===Si?C:u]]):(r=T[0][0],u=T[0][1],f=T[1][0],d=T[1][1]),o=r,c=u,h=f,p=d;var O=Rt(b).attr("pointer-events","none"),B=O.selectAll(".overlay").attr("cursor",Ci[m]);if(t.event.touches)U.moved=F,U.ended=H;else{var Y=Rt(t.event.view).on("mousemove.brush",F,!0).on("mouseup.brush",H,!0);a&&Y.on("keydown.brush",function(){switch(t.event.keyCode){case 16:R=w&&M;break;case 18:x===Mi&&(w&&(f=h-P*w,r=o+P*w),M&&(d=p-z*M,u=c+z*M),x=Ni,I());break;case 32:x!==Mi&&x!==Ni||(w<0?f=h-P:w>0&&(r=o-P),M<0?d=p-z:M>0&&(u=c-z),x=wi,B.attr("cursor",Ci.selection),I());break;default:return}mi()},!0).on("keyup.brush",function(){switch(t.event.keyCode){case 16:R&&(g=y=R=!1,I());break;case 18:x===Ni&&(w<0?f=h:w>0&&(r=o),M<0?d=p:M>0&&(u=c),x=Mi,I());break;case 32:x===wi&&(t.event.altKey?(w&&(f=h-P*w,r=o+P*w),M&&(d=p-z*M,u=c+z*M),x=Ni):(w<0?f=h:w>0&&(r=o),M<0?d=p:M>0&&(u=c),x=Mi),B.attr("cursor",Ci[m]),I());break;default:return}mi()},!0),Ht(t.event.view)}bi(),Cr(b),s.call(b),U.start()}function F(){var t=D(b);!R||g||y||(Math.abs(t[0]-L[0])>Math.abs(t[1]-L[1])?y=!0:g=!0),L=t,v=!0,mi(),I()}function I(){var t;switch(P=L[0]-q[0],z=L[1]-q[1],x){case wi:case xi:w&&(P=Math.max(S-r,Math.min(E-f,P)),o=r+P,h=f+P),M&&(z=Math.max(k-u,Math.min(C-d,z)),c=u+z,p=d+z);break;case Mi:w<0?(P=Math.max(S-r,Math.min(E-r,P)),o=r+P,h=f):w>0&&(P=Math.max(S-f,Math.min(E-f,P)),o=r,h=f+P),M<0?(z=Math.max(k-u,Math.min(C-u,z)),c=u+z,p=d):M>0&&(z=Math.max(k-d,Math.min(C-d,z)),c=u,p=d+z);break;case Ni:w&&(o=Math.max(S,Math.min(E,r-P*w)),h=Math.max(S,Math.min(E,f+P*w))),M&&(c=Math.max(k,Math.min(C,u-z*M)),p=Math.max(k,Math.min(C,d+z*M)))}h<o&&(w*=-1,t=r,r=f,f=t,t=o,o=h,h=t,m in Pi&&B.attr("cursor",Ci[m=Pi[m]])),p<c&&(M*=-1,t=u,u=d,d=t,t=c,c=p,p=t,m in zi&&B.attr("cursor",Ci[m=zi[m]])),N.selection&&(T=N.selection),g&&(o=T[0][0],h=T[1][0]),y&&(c=T[0][1],p=T[1][1]),T[0][0]===o&&T[0][1]===c&&T[1][0]===h&&T[1][1]===p||(N.selection=[[o,c],[h,p]],s.call(b),U.brush())}function H(){if(bi(),t.event.touches){if(t.event.touches.length)return;e&&clearTimeout(e),e=setTimeout(function(){e=null},500)}else jt(t.event.view,v),Y.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);O.attr("pointer-events","all"),B.attr("cursor",Ci.overlay),N.selection&&(T=N.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(T)&&(N.selection=null,s.call(b)),U.end()}}function p(){l(this,arguments).moved()}function v(){l(this,arguments).ended()}function g(){var t=this.__brush||{selection:null};return t.extent=Ti(r.apply(this,arguments)),t.dim=n,t}return f.move=function(t,e){t.selection?t.on("start.brush",function(){l(this,arguments).beforestart().start()}).on("interrupt.brush end.brush",function(){l(this,arguments).end()}).tween("brush",function(){var t=this,r=t.__brush,i=l(t,arguments),o=r.selection,a=n.input("function"==typeof e?e.apply(this,arguments):e,r.extent),u=Ne(o,a);function c(n){r.selection=1===n&&null===a?null:u(n),s.call(t),i.brush()}return null!==o&&null!==a?c:c(1)}):t.each(function(){var t=this,r=arguments,i=t.__brush,o=n.input("function"==typeof e?e.apply(t,r):e,i.extent),a=l(t,r).beforestart();Cr(t),i.selection=null===o?null:o,s.call(t),a.start().brush().end()})},f.clear=function(t){f.move(t,null)},h.prototype={beforestart:function(){return 1==++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(){return this.starting?(this.starting=!1,this.emit("start")):this.emit("brush"),this},brush:function(){return this.emit("brush"),this},end:function(){return 0==--this.active&&(delete this.state.emitter,this.emit("end")),this},emit:function(t){kt(new _i(f,t,n.output(this.state.selection)),u.apply,u,[t,this.that,this.args])}},f.extent=function(t){return arguments.length?(r="function"==typeof t?t:yi(Ti(t)),f):r},f.filter=function(t){return arguments.length?(i="function"==typeof t?t:yi(!!t),f):i},f.handleSize=function(t){return arguments.length?(c=+t,f):c},f.keyModifiers=function(t){return arguments.length?(a=!!t,f):a},f.on=function(){var t=u.on.apply(u,arguments);return t===u?f:t},f}var Fi=Math.cos,Ii=Math.sin,Hi=Math.PI,ji=Hi/2,Xi=2*Hi,Gi=Math.max;function Vi(t){return function(n,e){return t(n.source.value+n.target.value,e.source.value+e.target.value)}}var $i=Array.prototype.slice;function Wi(t){return function(){return t}}var Zi=Math.PI,Qi=2*Zi,Ki=Qi-1e-6;function Ji(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function to(){return new Ji}function no(t){return t.source}function eo(t){return t.target}function ro(t){return t.radius}function io(t){return t.startAngle}function oo(t){return t.endAngle}Ji.prototype=to.prototype={constructor:Ji,moveTo:function(t,n){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)},closePath:function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,n){this._+="L"+(this._x1=+t)+","+(this._y1=+n)},quadraticCurveTo:function(t,n,e,r){this._+="Q"+ +t+","+ +n+","+(this._x1=+e)+","+(this._y1=+r)},bezierCurveTo:function(t,n,e,r,i,o){this._+="C"+ +t+","+ +n+","+ +e+","+ +r+","+(this._x1=+i)+","+(this._y1=+o)},arcTo:function(t,n,e,r,i){t=+t,n=+n,e=+e,r=+r,i=+i;var o=this._x1,a=this._y1,u=e-t,c=r-n,f=o-t,s=a-n,l=f*f+s*s;if(i<0)throw new Error("negative radius: "+i);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=n);else if(l>1e-6)if(Math.abs(s*u-c*f)>1e-6&&i){var h=e-o,d=r-a,p=u*u+c*c,v=h*h+d*d,g=Math.sqrt(p),y=Math.sqrt(l),_=i*Math.tan((Zi-Math.acos((p+l-v)/(2*g*y)))/2),b=_/y,m=_/g;Math.abs(b-1)>1e-6&&(this._+="L"+(t+b*f)+","+(n+b*s)),this._+="A"+i+","+i+",0,0,"+ +(s*h>f*d)+","+(this._x1=t+m*u)+","+(this._y1=n+m*c)}else this._+="L"+(this._x1=t)+","+(this._y1=n);else;},arc:function(t,n,e,r,i,o){t=+t,n=+n,o=!!o;var a=(e=+e)*Math.cos(r),u=e*Math.sin(r),c=t+a,f=n+u,s=1^o,l=o?r-i:i-r;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+c+","+f:(Math.abs(this._x1-c)>1e-6||Math.abs(this._y1-f)>1e-6)&&(this._+="L"+c+","+f),e&&(l<0&&(l=l%Qi+Qi),l>Ki?this._+="A"+e+","+e+",0,1,"+s+","+(t-a)+","+(n-u)+"A"+e+","+e+",0,1,"+s+","+(this._x1=c)+","+(this._y1=f):l>1e-6&&(this._+="A"+e+","+e+",0,"+ +(l>=Zi)+","+s+","+(this._x1=t+e*Math.cos(i))+","+(this._y1=n+e*Math.sin(i))))},rect:function(t,n,e,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +r+"h"+-e+"Z"},toString:function(){return this._}};function ao(){}function uo(t,n){var e=new ao;if(t instanceof ao)t.each(function(t,n){e.set(n,t)});else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==n)for(;++i<o;)e.set(i,t[i]);else for(;++i<o;)e.set(n(r=t[i],i,t),r)}else if(t)for(var a in t)e.set(a,t[a]);return e}function co(){return{}}function fo(t,n,e){t[n]=e}function so(){return uo()}function lo(t,n,e){t.set(n,e)}function ho(){}ao.prototype=uo.prototype={constructor:ao,has:function(t){return"$"+t in this},get:function(t){return this["$"+t]},set:function(t,n){return this["$"+t]=n,this},remove:function(t){var n="$"+t;return n in this&&delete this[n]},clear:function(){for(var t in this)"$"===t[0]&&delete this[t]},keys:function(){var t=[];for(var n in this)"$"===n[0]&&t.push(n.slice(1));return t},values:function(){var t=[];for(var n in this)"$"===n[0]&&t.push(this[n]);return t},entries:function(){var t=[];for(var n in this)"$"===n[0]&&t.push({key:n.slice(1),value:this[n]});return t},size:function(){var t=0;for(var n in this)"$"===n[0]&&++t;return t},empty:function(){for(var t in this)if("$"===t[0])return!1;return!0},each:function(t){for(var n in this)"$"===n[0]&&t(this[n],n.slice(1),this)}};var po=uo.prototype;function vo(t,n){var e=new ho;if(t instanceof ho)t.each(function(t){e.add(t)});else if(t){var r=-1,i=t.length;if(null==n)for(;++r<i;)e.add(t[r]);else for(;++r<i;)e.add(n(t[r],r,t))}return e}ho.prototype=vo.prototype={constructor:ho,has:po.has,add:function(t){return this["$"+(t+="")]=t,this},remove:po.remove,clear:po.clear,values:po.keys,size:po.size,empty:po.empty,each:po.each};var go=Array.prototype.slice;function yo(t,n){return t-n}function _o(t){return function(){return t}}function bo(t,n){for(var e,r=-1,i=n.length;++r<i;)if(e=mo(t,n[r]))return e;return 0}function mo(t,n){for(var e=n[0],r=n[1],i=-1,o=0,a=t.length,u=a-1;o<a;u=o++){var c=t[o],f=c[0],s=c[1],l=t[u],h=l[0],d=l[1];if(xo(c,l,n))return 0;s>r!=d>r&&e<(h-f)*(r-s)/(d-s)+f&&(i=-i)}return i}function xo(t,n,e){var r,i,o,a;return function(t,n,e){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])}(t,n,e)&&(i=t[r=+(t[0]===n[0])],o=e[r],a=n[r],i<=o&&o<=a||a<=o&&o<=i)}function wo(){}var Mo=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function No(){var t=1,n=1,e=M,r=u;function i(t){var n=e(t);if(Array.isArray(n))n=n.slice().sort(yo);else{var r=s(t),i=r[0],a=r[1];n=w(i,a,n),n=g(Math.floor(i/n)*n,Math.floor(a/n)*n,n)}return n.map(function(n){return o(t,n)})}function o(e,i){var o=[],u=[];return function(e,r,i){var o,u,c,f,s,l,h=new Array,d=new Array;o=u=-1,f=e[0]>=r,Mo[f<<1].forEach(p);for(;++o<t-1;)c=f,f=e[o+1]>=r,Mo[c|f<<1].forEach(p);Mo[f<<0].forEach(p);for(;++u<n-1;){for(o=-1,f=e[u*t+t]>=r,s=e[u*t]>=r,Mo[f<<1|s<<2].forEach(p);++o<t-1;)c=f,f=e[u*t+t+o+1]>=r,l=s,s=e[u*t+o+1]>=r,Mo[c|f<<1|s<<2|l<<3].forEach(p);Mo[f|s<<3].forEach(p)}o=-1,s=e[u*t]>=r,Mo[s<<2].forEach(p);for(;++o<t-1;)l=s,s=e[u*t+o+1]>=r,Mo[s<<2|l<<3].forEach(p);function p(t){var n,e,r=[t[0][0]+o,t[0][1]+u],c=[t[1][0]+o,t[1][1]+u],f=a(r),s=a(c);(n=d[f])?(e=h[s])?(delete d[n.end],delete h[e.start],n===e?(n.ring.push(c),i(n.ring)):h[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete d[n.end],n.ring.push(c),d[n.end=s]=n):(n=h[s])?(e=d[f])?(delete h[n.start],delete d[e.end],n===e?(n.ring.push(c),i(n.ring)):h[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete h[n.start],n.ring.unshift(r),h[n.start=f]=n):h[f]=d[s]={start:f,end:s,ring:[r,c]}}Mo[s<<3].forEach(p)}(e,i,function(t){r(t,e,i),function(t){for(var n=0,e=t.length,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++n<e;)r+=t[n-1][1]*t[n][0]-t[n-1][0]*t[n][1];return r}(t)>0?o.push([t]):u.push(t)}),u.forEach(function(t){for(var n,e=0,r=o.length;e<r;++e)if(-1!==bo((n=o[e])[0],t))return void n.push(t)}),{type:"MultiPolygon",value:i,coordinates:o}}function a(n){return 2*n[0]+n[1]*(t+1)*4}function u(e,r,i){e.forEach(function(e){var o,a=e[0],u=e[1],c=0|a,f=0|u,s=r[f*t+c];a>0&&a<t&&c===a&&(o=r[f*t+c-1],e[0]=a+(i-o)/(s-o)-.5),u>0&&u<n&&f===u&&(o=r[(f-1)*t+c],e[1]=u+(i-o)/(s-o)-.5)})}return i.contour=o,i.size=function(e){if(!arguments.length)return[t,n];var r=Math.ceil(e[0]),o=Math.ceil(e[1]);if(!(r>0&&o>0))throw new Error("invalid size");return t=r,n=o,i},i.thresholds=function(t){return arguments.length?(e="function"==typeof t?t:Array.isArray(t)?_o(go.call(t)):_o(t),i):e},i.smooth=function(t){return arguments.length?(r=t?u:wo,i):r===u},i}function Ao(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a<i;++a)for(var u=0,c=0;u<r+e;++u)u<r&&(c+=t.data[u+a*r]),u>=e&&(u>=o&&(c-=t.data[u-o+a*r]),n.data[u-e+a*r]=c/Math.min(u+1,r-1+o-u,o))}function To(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a<r;++a)for(var u=0,c=0;u<i+e;++u)u<i&&(c+=t.data[a+u*r]),u>=e&&(u>=o&&(c-=t.data[a+(u-o)*r]),n.data[a+(u-e)*r]=c/Math.min(u+1,i-1+o-u,o))}function So(t){return t[0]}function ko(t){return t[1]}function Eo(){return 1}var Co={},Po={},zo=34,Ro=10,Do=13;function qo(t){return new Function("d","return {"+t.map(function(t,n){return JSON.stringify(t)+": d["+n+"]"}).join(",")+"}")}function Lo(t){var n=Object.create(null),e=[];return t.forEach(function(t){for(var r in t)r in n||e.push(n[r]=r)}),e}function Uo(t,n){var e=t+"",r=e.length;return r<n?new Array(n-r+1).join(0)+e:e}function Oo(t){var n=t.getUTCHours(),e=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":function(t){return t<0?"-"+Uo(-t,6):t>9999?"+"+Uo(t,6):Uo(t,4)}(t.getUTCFullYear())+"-"+Uo(t.getUTCMonth()+1,2)+"-"+Uo(t.getUTCDate(),2)+(i?"T"+Uo(n,2)+":"+Uo(e,2)+":"+Uo(r,2)+"."+Uo(i,3)+"Z":r?"T"+Uo(n,2)+":"+Uo(e,2)+":"+Uo(r,2)+"Z":e||n?"T"+Uo(n,2)+":"+Uo(e,2)+"Z":"")}function Bo(t){var n=new RegExp('["'+t+"\n\r]"),e=t.charCodeAt(0);function r(t,n){var r,i=[],o=t.length,a=0,u=0,c=o<=0,f=!1;function s(){if(c)return Po;if(f)return f=!1,Co;var n,r,i=a;if(t.charCodeAt(i)===zo){for(;a++<o&&t.charCodeAt(a)!==zo||t.charCodeAt(++a)===zo;);return(n=a)>=o?c=!0:(r=t.charCodeAt(a++))===Ro?f=!0:r===Do&&(f=!0,t.charCodeAt(a)===Ro&&++a),t.slice(i+1,n-1).replace(/""/g,'"')}for(;a<o;){if((r=t.charCodeAt(n=a++))===Ro)f=!0;else if(r===Do)f=!0,t.charCodeAt(a)===Ro&&++a;else if(r!==e)continue;return t.slice(i,n)}return c=!0,t.slice(i,o)}for(t.charCodeAt(o-1)===Ro&&--o,t.charCodeAt(o-1)===Do&&--o;(r=s())!==Po;){for(var l=[];r!==Co&&r!==Po;)l.push(r),r=s();n&&null==(l=n(l,u++))||i.push(l)}return i}function i(n,e){return n.map(function(n){return e.map(function(t){return a(n[t])}).join(t)})}function o(n){return n.map(a).join(t)}function a(t){return null==t?"":t instanceof Date?Oo(t):n.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,n){var e,i,o=r(t,function(t,r){if(e)return e(t,r-1);i=t,e=n?function(t,n){var e=qo(t);return function(r,i){return n(e(r),i,t)}}(t,n):qo(t)});return o.columns=i||[],o},parseRows:r,format:function(n,e){return null==e&&(e=Lo(n)),[e.map(a).join(t)].concat(i(n,e)).join("\n")},formatBody:function(t,n){return null==n&&(n=Lo(t)),i(t,n).join("\n")},formatRows:function(t){return t.map(o).join("\n")}}}var Yo=Bo(","),Fo=Yo.parse,Io=Yo.parseRows,Ho=Yo.format,jo=Yo.formatBody,Xo=Yo.formatRows,Go=Bo("\t"),Vo=Go.parse,$o=Go.parseRows,Wo=Go.format,Zo=Go.formatBody,Qo=Go.formatRows;function Ko(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.blob()}function Jo(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.arrayBuffer()}function ta(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.text()}function na(t,n){return fetch(t,n).then(ta)}function ea(t){return function(n,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=void 0),na(n,e).then(function(n){return t(n,r)})}}var ra=ea(Fo),ia=ea(Vo);function oa(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.json()}function aa(t){return function(n,e){return na(n,e).then(function(n){return(new DOMParser).parseFromString(n,t)})}}var ua=aa("application/xml"),ca=aa("text/html"),fa=aa("image/svg+xml");function sa(t){return function(){return t}}function la(){return 1e-6*(Math.random()-.5)}function ha(t,n,e,r){if(isNaN(n)||isNaN(e))return t;var i,o,a,u,c,f,s,l,h,d=t._root,p={data:r},v=t._x0,g=t._y0,y=t._x1,_=t._y1;if(!d)return t._root=p,t;for(;d.length;)if((f=n>=(o=(v+y)/2))?v=o:y=o,(s=e>=(a=(g+_)/2))?g=a:_=a,i=d,!(d=d[l=s<<1|f]))return i[l]=p,t;if(u=+t._x.call(null,d.data),c=+t._y.call(null,d.data),n===u&&e===c)return p.next=d,i?i[l]=p:t._root=p,t;do{i=i?i[l]=new Array(4):t._root=new Array(4),(f=n>=(o=(v+y)/2))?v=o:y=o,(s=e>=(a=(g+_)/2))?g=a:_=a}while((l=s<<1|f)==(h=(c>=a)<<1|u>=o));return i[h]=d,i[l]=p,t}function da(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function pa(t){return t[0]}function va(t){return t[1]}function ga(t,n,e){var r=new ya(null==n?pa:n,null==e?va:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function ya(t,n,e,r,i,o){this._x=t,this._y=n,this._x0=e,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function _a(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var ba=ga.prototype=ya.prototype;function ma(t){return t.x+t.vx}function xa(t){return t.y+t.vy}function wa(t){return t.index}function Ma(t,n){var e=t.get(n);if(!e)throw new Error("missing: "+n);return e}function Na(t){return t.x}function Aa(t){return t.y}ba.copy=function(){var t,n,e=new ya(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=_a(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=_a(n));return e},ba.add=function(t){var n=+this._x.call(null,t),e=+this._y.call(null,t);return ha(this.cover(n,e),n,e,t)},ba.addAll=function(t){var n,e,r,i,o=t.length,a=new Array(o),u=new Array(o),c=1/0,f=1/0,s=-1/0,l=-1/0;for(e=0;e<o;++e)isNaN(r=+this._x.call(null,n=t[e]))||isNaN(i=+this._y.call(null,n))||(a[e]=r,u[e]=i,r<c&&(c=r),r>s&&(s=r),i<f&&(f=i),i>l&&(l=i));if(c>s||f>l)return this;for(this.cover(c,f).cover(s,l),e=0;e<o;++e)ha(this,a[e],u[e],t[e]);return this},ba.cover=function(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var e=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(e))i=(e=Math.floor(t))+1,o=(r=Math.floor(n))+1;else{for(var a,u,c=i-e,f=this._root;e>t||t>=i||r>n||n>=o;)switch(u=(n<r)<<1|t<e,(a=new Array(4))[u]=f,f=a,c*=2,u){case 0:i=e+c,o=r+c;break;case 1:e=i-c,o=r+c;break;case 2:i=e+c,r=o-c;break;case 3:e=i-c,r=o-c}this._root&&this._root.length&&(this._root=f)}return this._x0=e,this._y0=r,this._x1=i,this._y1=o,this},ba.data=function(){var t=[];return this.visit(function(n){if(!n.length)do{t.push(n.data)}while(n=n.next)}),t},ba.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},ba.find=function(t,n,e){var r,i,o,a,u,c,f,s=this._x0,l=this._y0,h=this._x1,d=this._y1,p=[],v=this._root;for(v&&p.push(new da(v,s,l,h,d)),null==e?e=1/0:(s=t-e,l=n-e,h=t+e,d=n+e,e*=e);c=p.pop();)if(!(!(v=c.node)||(i=c.x0)>h||(o=c.y0)>d||(a=c.x1)<s||(u=c.y1)<l))if(v.length){var g=(i+a)/2,y=(o+u)/2;p.push(new da(v[3],g,y,a,u),new da(v[2],i,y,g,u),new da(v[1],g,o,a,y),new da(v[0],i,o,g,y)),(f=(n>=y)<<1|t>=g)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-f],p[p.length-1-f]=c)}else{var _=t-+this._x.call(null,v.data),b=n-+this._y.call(null,v.data),m=_*_+b*b;if(m<e){var x=Math.sqrt(e=m);s=t-x,l=n-x,h=t+x,d=n+x,r=v.data}}return r},ba.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var n,e,r,i,o,a,u,c,f,s,l,h,d=this._root,p=this._x0,v=this._y0,g=this._x1,y=this._y1;if(!d)return this;if(d.length)for(;;){if((f=o>=(u=(p+g)/2))?p=u:g=u,(s=a>=(c=(v+y)/2))?v=c:y=c,n=d,!(d=d[l=s<<1|f]))return this;if(!d.length)break;(n[l+1&3]||n[l+2&3]||n[l+3&3])&&(e=n,h=l)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):n?(i?n[l]=i:delete n[l],(d=n[0]||n[1]||n[2]||n[3])&&d===(n[3]||n[2]||n[1]||n[0])&&!d.length&&(e?e[h]=d:this._root=d),this):(this._root=i,this)},ba.removeAll=function(t){for(var n=0,e=t.length;n<e;++n)this.remove(t[n]);return this},ba.root=function(){return this._root},ba.size=function(){var t=0;return this.visit(function(n){if(!n.length)do{++t}while(n=n.next)}),t},ba.visit=function(t){var n,e,r,i,o,a,u=[],c=this._root;for(c&&u.push(new da(c,this._x0,this._y0,this._x1,this._y1));n=u.pop();)if(!t(c=n.node,r=n.x0,i=n.y0,o=n.x1,a=n.y1)&&c.length){var f=(r+o)/2,s=(i+a)/2;(e=c[3])&&u.push(new da(e,f,s,o,a)),(e=c[2])&&u.push(new da(e,r,s,f,a)),(e=c[1])&&u.push(new da(e,f,i,o,s)),(e=c[0])&&u.push(new da(e,r,i,f,s))}return this},ba.visitAfter=function(t){var n,e=[],r=[];for(this._root&&e.push(new da(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var i=n.node;if(i.length){var o,a=n.x0,u=n.y0,c=n.x1,f=n.y1,s=(a+c)/2,l=(u+f)/2;(o=i[0])&&e.push(new da(o,a,u,s,l)),(o=i[1])&&e.push(new da(o,s,u,c,l)),(o=i[2])&&e.push(new da(o,a,l,s,f)),(o=i[3])&&e.push(new da(o,s,l,c,f))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.y0,n.x1,n.y1);return this},ba.x=function(t){return arguments.length?(this._x=t,this):this._x},ba.y=function(t){return arguments.length?(this._y=t,this):this._y};var Ta=10,Sa=Math.PI*(3-Math.sqrt(5));function ka(t,n){if((e=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"))<0)return null;var e,r=t.slice(0,e);return[r.length>1?r[0]+r.slice(2):r,+t.slice(e+1)]}function Ea(t){return(t=ka(Math.abs(t)))?t[1]:NaN}var Ca,Pa=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function za(t){if(!(n=Pa.exec(t)))throw new Error("invalid format: "+t);var n;return new Ra({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}function Ra(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Da(t,n){var e=ka(t,n);if(!e)return t+"";var r=e[0],i=e[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}za.prototype=Ra.prototype,Ra.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var qa={"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return Da(100*t,n)},r:Da,s:function(t,n){var e=ka(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(Ca=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+ka(t,Math.max(0,n+o-1))[0]},X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}};function La(t){return t}var Ua,Oa=Array.prototype.map,Ba=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Ya(t){var n,e,r=void 0===t.grouping||void 0===t.thousands?La:(n=Oa.call(t.grouping,Number),e=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,u=n[0],c=0;i>0&&u>0&&(c+u+1>r&&(u=Math.max(1,r-c)),o.push(t.substring(i-=u,i+u)),!((c+=u+1)>r));)u=n[a=(a+1)%n.length];return o.reverse().join(e)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",u=void 0===t.numerals?La:function(t){return function(n){return n.replace(/[0-9]/g,function(n){return t[+n]})}}(Oa.call(t.numerals,String)),c=void 0===t.percent?"%":t.percent+"",f=void 0===t.minus?"-":t.minus+"",s=void 0===t.nan?"NaN":t.nan+"";function l(t){var n=(t=za(t)).fill,e=t.align,l=t.sign,h=t.symbol,d=t.zero,p=t.width,v=t.comma,g=t.precision,y=t.trim,_=t.type;"n"===_?(v=!0,_="g"):qa[_]||(void 0===g&&(g=12),y=!0,_="g"),(d||"0"===n&&"="===e)&&(d=!0,n="0",e="=");var b="$"===h?i:"#"===h&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",m="$"===h?o:/[%p]/.test(_)?c:"",x=qa[_],w=/[defgprs%]/.test(_);function M(t){var i,o,c,h=b,M=m;if("c"===_)M=x(t)+M,t="";else{var N=(t=+t)<0;if(t=isNaN(t)?s:x(Math.abs(t),g),y&&(t=function(t){t:for(var n,e=t.length,r=1,i=-1;r<e;++r)switch(t[r]){case".":i=n=r;break;case"0":0===i&&(i=r),n=r;break;default:if(i>0){if(!+t[r])break t;i=0}}return i>0?t.slice(0,i)+t.slice(n+1):t}(t)),N&&0==+t&&(N=!1),h=(N?"("===l?l:f:"-"===l||"("===l?"":l)+h,M=("s"===_?Ba[8+Ca/3]:"")+M+(N&&"("===l?")":""),w)for(i=-1,o=t.length;++i<o;)if(48>(c=t.charCodeAt(i))||c>57){M=(46===c?a+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}v&&!d&&(t=r(t,1/0));var A=h.length+t.length+M.length,T=A<p?new Array(p-A+1).join(n):"";switch(v&&d&&(t=r(T+t,T.length?p-M.length:1/0),T=""),e){case"<":t=h+t+M+T;break;case"=":t=h+T+t+M;break;case"^":t=T.slice(0,A=T.length>>1)+h+t+M+T.slice(A);break;default:t=T+h+t+M}return u(t)}return g=void 0===g?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),M.toString=function(){return t+""},M}return{format:l,formatPrefix:function(t,n){var e=l(((t=za(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Ea(n)/3))),i=Math.pow(10,-r),o=Ba[8+r/3];return function(t){return e(i*t)+o}}}}function Fa(n){return Ua=Ya(n),t.format=Ua.format,t.formatPrefix=Ua.formatPrefix,Ua}function Ia(t){return Math.max(0,-Ea(Math.abs(t)))}function Ha(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Ea(n)/3)))-Ea(Math.abs(t)))}function ja(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,Ea(n)-Ea(t))+1}function Xa(){return new Ga}function Ga(){this.reset()}Fa({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"}),Ga.prototype={constructor:Ga,reset:function(){this.s=this.t=0},add:function(t){$a(Va,t,this.t),$a(this,Va.s,this.s),this.s?this.t+=Va.t:this.s=Va.t},valueOf:function(){return this.s}};var Va=new Ga;function $a(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var Wa=1e-6,Za=1e-12,Qa=Math.PI,Ka=Qa/2,Ja=Qa/4,tu=2*Qa,nu=180/Qa,eu=Qa/180,ru=Math.abs,iu=Math.atan,ou=Math.atan2,au=Math.cos,uu=Math.ceil,cu=Math.exp,fu=Math.log,su=Math.pow,lu=Math.sin,hu=Math.sign||function(t){return t>0?1:t<0?-1:0},du=Math.sqrt,pu=Math.tan;function vu(t){return t>1?0:t<-1?Qa:Math.acos(t)}function gu(t){return t>1?Ka:t<-1?-Ka:Math.asin(t)}function yu(t){return(t=lu(t/2))*t}function _u(){}function bu(t,n){t&&xu.hasOwnProperty(t.type)&&xu[t.type](t,n)}var mu={Feature:function(t,n){bu(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r<i;)bu(e[r].geometry,n)}},xu={Sphere:function(t,n){n.sphere()},Point:function(t,n){t=t.coordinates,n.point(t[0],t[1],t[2])},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)t=e[r],n.point(t[0],t[1],t[2])},LineString:function(t,n){wu(t.coordinates,n,0)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)wu(e[r],n,0)},Polygon:function(t,n){Mu(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)Mu(e[r],n)},GeometryCollection:function(t,n){for(var e=t.geometries,r=-1,i=e.length;++r<i;)bu(e[r],n)}};function wu(t,n,e){var r,i=-1,o=t.length-e;for(n.lineStart();++i<o;)r=t[i],n.point(r[0],r[1],r[2]);n.lineEnd()}function Mu(t,n){var e=-1,r=t.length;for(n.polygonStart();++e<r;)wu(t[e],n,1);n.polygonEnd()}function Nu(t,n){t&&mu.hasOwnProperty(t.type)?mu[t.type](t,n):bu(t,n)}var Au,Tu,Su,ku,Eu,Cu=Xa(),Pu=Xa(),zu={point:_u,lineStart:_u,lineEnd:_u,polygonStart:function(){Cu.reset(),zu.lineStart=Ru,zu.lineEnd=Du},polygonEnd:function(){var t=+Cu;Pu.add(t<0?tu+t:t),this.lineStart=this.lineEnd=this.point=_u},sphere:function(){Pu.add(tu)}};function Ru(){zu.point=qu}function Du(){Lu(Au,Tu)}function qu(t,n){zu.point=Lu,Au=t,Tu=n,Su=t*=eu,ku=au(n=(n*=eu)/2+Ja),Eu=lu(n)}function Lu(t,n){var e=(t*=eu)-Su,r=e>=0?1:-1,i=r*e,o=au(n=(n*=eu)/2+Ja),a=lu(n),u=Eu*a,c=ku*o+u*au(i),f=u*r*lu(i);Cu.add(ou(f,c)),Su=t,ku=o,Eu=a}function Uu(t){return[ou(t[1],t[0]),gu(t[2])]}function Ou(t){var n=t[0],e=t[1],r=au(e);return[r*au(n),r*lu(n),lu(e)]}function Bu(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Yu(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function Fu(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Iu(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Hu(t){var n=du(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var ju,Xu,Gu,Vu,$u,Wu,Zu,Qu,Ku,Ju,tc,nc,ec,rc,ic,oc,ac,uc,cc,fc,sc,lc,hc,dc,pc,vc,gc=Xa(),yc={point:_c,lineStart:mc,lineEnd:xc,polygonStart:function(){yc.point=wc,yc.lineStart=Mc,yc.lineEnd=Nc,gc.reset(),zu.polygonStart()},polygonEnd:function(){zu.polygonEnd(),yc.point=_c,yc.lineStart=mc,yc.lineEnd=xc,Cu<0?(ju=-(Gu=180),Xu=-(Vu=90)):gc>Wa?Vu=90:gc<-Wa&&(Xu=-90),Ju[0]=ju,Ju[1]=Gu},sphere:function(){ju=-(Gu=180),Xu=-(Vu=90)}};function _c(t,n){Ku.push(Ju=[ju=t,Gu=t]),n<Xu&&(Xu=n),n>Vu&&(Vu=n)}function bc(t,n){var e=Ou([t*eu,n*eu]);if(Qu){var r=Yu(Qu,e),i=Yu([r[1],-r[0],0],r);Hu(i),i=Uu(i);var o,a=t-$u,u=a>0?1:-1,c=i[0]*nu*u,f=ru(a)>180;f^(u*$u<c&&c<u*t)?(o=i[1]*nu)>Vu&&(Vu=o):f^(u*$u<(c=(c+360)%360-180)&&c<u*t)?(o=-i[1]*nu)<Xu&&(Xu=o):(n<Xu&&(Xu=n),n>Vu&&(Vu=n)),f?t<$u?Ac(ju,t)>Ac(ju,Gu)&&(Gu=t):Ac(t,Gu)>Ac(ju,Gu)&&(ju=t):Gu>=ju?(t<ju&&(ju=t),t>Gu&&(Gu=t)):t>$u?Ac(ju,t)>Ac(ju,Gu)&&(Gu=t):Ac(t,Gu)>Ac(ju,Gu)&&(ju=t)}else Ku.push(Ju=[ju=t,Gu=t]);n<Xu&&(Xu=n),n>Vu&&(Vu=n),Qu=e,$u=t}function mc(){yc.point=bc}function xc(){Ju[0]=ju,Ju[1]=Gu,yc.point=_c,Qu=null}function wc(t,n){if(Qu){var e=t-$u;gc.add(ru(e)>180?e+(e>0?360:-360):e)}else Wu=t,Zu=n;zu.point(t,n),bc(t,n)}function Mc(){zu.lineStart()}function Nc(){wc(Wu,Zu),zu.lineEnd(),ru(gc)>Wa&&(ju=-(Gu=180)),Ju[0]=ju,Ju[1]=Gu,Qu=null}function Ac(t,n){return(n-=t)<0?n+360:n}function Tc(t,n){return t[0]-n[0]}function Sc(t,n){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:n<t[0]||t[1]<n}var kc={sphere:_u,point:Ec,lineStart:Pc,lineEnd:Dc,polygonStart:function(){kc.lineStart=qc,kc.lineEnd=Lc},polygonEnd:function(){kc.lineStart=Pc,kc.lineEnd=Dc}};function Ec(t,n){t*=eu;var e=au(n*=eu);Cc(e*au(t),e*lu(t),lu(n))}function Cc(t,n,e){ec+=(t-ec)/++tc,rc+=(n-rc)/tc,ic+=(e-ic)/tc}function Pc(){kc.point=zc}function zc(t,n){t*=eu;var e=au(n*=eu);dc=e*au(t),pc=e*lu(t),vc=lu(n),kc.point=Rc,Cc(dc,pc,vc)}function Rc(t,n){t*=eu;var e=au(n*=eu),r=e*au(t),i=e*lu(t),o=lu(n),a=ou(du((a=pc*o-vc*i)*a+(a=vc*r-dc*o)*a+(a=dc*i-pc*r)*a),dc*r+pc*i+vc*o);nc+=a,oc+=a*(dc+(dc=r)),ac+=a*(pc+(pc=i)),uc+=a*(vc+(vc=o)),Cc(dc,pc,vc)}function Dc(){kc.point=Ec}function qc(){kc.point=Uc}function Lc(){Oc(lc,hc),kc.point=Ec}function Uc(t,n){lc=t,hc=n,t*=eu,n*=eu,kc.point=Oc;var e=au(n);dc=e*au(t),pc=e*lu(t),vc=lu(n),Cc(dc,pc,vc)}function Oc(t,n){t*=eu;var e=au(n*=eu),r=e*au(t),i=e*lu(t),o=lu(n),a=pc*o-vc*i,u=vc*r-dc*o,c=dc*i-pc*r,f=du(a*a+u*u+c*c),s=gu(f),l=f&&-s/f;cc+=l*a,fc+=l*u,sc+=l*c,nc+=s,oc+=s*(dc+(dc=r)),ac+=s*(pc+(pc=i)),uc+=s*(vc+(vc=o)),Cc(dc,pc,vc)}function Bc(t){return function(){return t}}function Yc(t,n){function e(e,r){return e=t(e,r),n(e[0],e[1])}return t.invert&&n.invert&&(e.invert=function(e,r){return(e=n.invert(e,r))&&t.invert(e[0],e[1])}),e}function Fc(t,n){return[ru(t)>Qa?t+Math.round(-t/tu)*tu:t,n]}function Ic(t,n,e){return(t%=tu)?n||e?Yc(jc(t),Xc(n,e)):jc(t):n||e?Xc(n,e):Fc}function Hc(t){return function(n,e){return[(n+=t)>Qa?n-tu:n<-Qa?n+tu:n,e]}}function jc(t){var n=Hc(t);return n.invert=Hc(-t),n}function Xc(t,n){var e=au(t),r=lu(t),i=au(n),o=lu(n);function a(t,n){var a=au(n),u=au(t)*a,c=lu(t)*a,f=lu(n),s=f*e+u*r;return[ou(c*i-s*o,u*e-f*r),gu(s*i+c*o)]}return a.invert=function(t,n){var a=au(n),u=au(t)*a,c=lu(t)*a,f=lu(n),s=f*i-c*o;return[ou(c*i+f*o,u*e+s*r),gu(s*e-u*r)]},a}function Gc(t){function n(n){return(n=t(n[0]*eu,n[1]*eu))[0]*=nu,n[1]*=nu,n}return t=Ic(t[0]*eu,t[1]*eu,t.length>2?t[2]*eu:0),n.invert=function(n){return(n=t.invert(n[0]*eu,n[1]*eu))[0]*=nu,n[1]*=nu,n},n}function Vc(t,n,e,r,i,o){if(e){var a=au(n),u=lu(n),c=r*e;null==i?(i=n+r*tu,o=n-c/2):(i=$c(a,i),o=$c(a,o),(r>0?i<o:i>o)&&(i+=r*tu));for(var f,s=i;r>0?s>o:s<o;s-=c)f=Uu([a,-u*au(s),-u*lu(s)]),t.point(f[0],f[1])}}function $c(t,n){(n=Ou(n))[0]-=t,Hu(n);var e=vu(-n[1]);return((-n[2]<0?-e:e)+tu-Wa)%tu}function Wc(){var t,n=[];return{point:function(n,e){t.push([n,e])},lineStart:function(){n.push(t=[])},lineEnd:_u,rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function Zc(t,n){return ru(t[0]-n[0])<Wa&&ru(t[1]-n[1])<Wa}function Qc(t,n,e,r){this.x=t,this.z=n,this.o=e,this.e=r,this.v=!1,this.n=this.p=null}function Kc(t,n,e,r,i){var o,a,u=[],c=[];if(t.forEach(function(t){if(!((n=t.length-1)<=0)){var n,e,r=t[0],a=t[n];if(Zc(r,a)){for(i.lineStart(),o=0;o<n;++o)i.point((r=t[o])[0],r[1]);i.lineEnd()}else u.push(e=new Qc(r,t,null,!0)),c.push(e.o=new Qc(r,null,e,!1)),u.push(e=new Qc(a,t,null,!1)),c.push(e.o=new Qc(a,null,e,!0))}}),u.length){for(c.sort(n),Jc(u),Jc(c),o=0,a=c.length;o<a;++o)c[o].e=e=!e;for(var f,s,l=u[0];;){for(var h=l,d=!0;h.v;)if((h=h.n)===l)return;f=h.z,i.lineStart();do{if(h.v=h.o.v=!0,h.e){if(d)for(o=0,a=f.length;o<a;++o)i.point((s=f[o])[0],s[1]);else r(h.x,h.n.x,1,i);h=h.n}else{if(d)for(f=h.p.z,o=f.length-1;o>=0;--o)i.point((s=f[o])[0],s[1]);else r(h.x,h.p.x,-1,i);h=h.p}f=(h=h.o).z,d=!d}while(!h.v);i.lineEnd()}}}function Jc(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r<n;)i.n=e=t[r],e.p=i,i=e;i.n=e=t[0],e.p=i}}Fc.invert=Fc;var tf=Xa();function nf(t){return ru(t[0])<=Qa?t[0]:hu(t[0])*((ru(t[0])+Qa)%tu-Qa)}function ef(t,n){var e=nf(n),r=n[1],i=lu(r),o=[lu(e),-au(e),0],a=0,u=0;tf.reset(),1===i?r=Ka+Wa:-1===i&&(r=-Ka-Wa);for(var c=0,f=t.length;c<f;++c)if(l=(s=t[c]).length)for(var s,l,h=s[l-1],d=nf(h),p=h[1]/2+Ja,v=lu(p),g=au(p),y=0;y<l;++y,d=b,v=x,g=w,h=_){var _=s[y],b=nf(_),m=_[1]/2+Ja,x=lu(m),w=au(m),M=b-d,N=M>=0?1:-1,A=N*M,T=A>Qa,S=v*x;if(tf.add(ou(S*N*lu(A),g*w+S*au(A))),a+=T?M+N*tu:M,T^d>=e^b>=e){var k=Yu(Ou(h),Ou(_));Hu(k);var E=Yu(o,k);Hu(E);var C=(T^M>=0?-1:1)*gu(E[2]);(r>C||r===C&&(k[0]||k[1]))&&(u+=T^M>=0?1:-1)}}return(a<-Wa||a<Wa&&tf<-Wa)^1&u}function rf(t,n,e,r){return function(i){var o,a,u,c=n(i),f=Wc(),s=n(f),l=!1,h={point:d,lineStart:v,lineEnd:g,polygonStart:function(){h.point=y,h.lineStart=_,h.lineEnd=b,a=[],o=[]},polygonEnd:function(){h.point=d,h.lineStart=v,h.lineEnd=g,a=T(a);var t=ef(o,r);a.length?(l||(i.polygonStart(),l=!0),Kc(a,af,t,e,i)):t&&(l||(i.polygonStart(),l=!0),i.lineStart(),e(null,null,1,i),i.lineEnd()),l&&(i.polygonEnd(),l=!1),a=o=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function d(n,e){t(n,e)&&i.point(n,e)}function p(t,n){c.point(t,n)}function v(){h.point=p,c.lineStart()}function g(){h.point=d,c.lineEnd()}function y(t,n){u.push([t,n]),s.point(t,n)}function _(){s.lineStart(),u=[]}function b(){y(u[0][0],u[0][1]),s.lineEnd();var t,n,e,r,c=s.clean(),h=f.result(),d=h.length;if(u.pop(),o.push(u),u=null,d)if(1&c){if((n=(e=h[0]).length-1)>0){for(l||(i.polygonStart(),l=!0),i.lineStart(),t=0;t<n;++t)i.point((r=e[t])[0],r[1]);i.lineEnd()}}else d>1&&2&c&&h.push(h.pop().concat(h.shift())),a.push(h.filter(of))}return h}}function of(t){return t.length>1}function af(t,n){return((t=t.x)[0]<0?t[1]-Ka-Wa:Ka-t[1])-((n=n.x)[0]<0?n[1]-Ka-Wa:Ka-n[1])}var uf=rf(function(){return!0},function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var u=o>0?Qa:-Qa,c=ru(o-e);ru(c-Qa)<Wa?(t.point(e,r=(r+a)/2>0?Ka:-Ka),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&c>=Qa&&(ru(e-i)<Wa&&(e-=i*Wa),ru(o-u)<Wa&&(o-=u*Wa),r=function(t,n,e,r){var i,o,a=lu(t-e);return ru(a)>Wa?iu((lu(n)*(o=au(r))*lu(e)-lu(r)*(i=au(n))*lu(t))/(i*o*a)):(n+r)/2}(e,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),n=0),t.point(e=o,r=a),i=u},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}},function(t,n,e,r){var i;if(null==t)i=e*Ka,r.point(-Qa,i),r.point(0,i),r.point(Qa,i),r.point(Qa,0),r.point(Qa,-i),r.point(0,-i),r.point(-Qa,-i),r.point(-Qa,0),r.point(-Qa,i);else if(ru(t[0]-n[0])>Wa){var o=t[0]<n[0]?Qa:-Qa;i=e*o/2,r.point(-o,i),r.point(0,i),r.point(o,i)}else r.point(n[0],n[1])},[-Qa,-Ka]);function cf(t){var n=au(t),e=6*eu,r=n>0,i=ru(n)>Wa;function o(t,e){return au(t)*au(e)>n}function a(t,e,r){var i=[1,0,0],o=Yu(Ou(t),Ou(e)),a=Bu(o,o),u=o[0],c=a-u*u;if(!c)return!r&&t;var f=n*a/c,s=-n*u/c,l=Yu(i,o),h=Iu(i,f);Fu(h,Iu(o,s));var d=l,p=Bu(h,d),v=Bu(d,d),g=p*p-v*(Bu(h,h)-1);if(!(g<0)){var y=du(g),_=Iu(d,(-p-y)/v);if(Fu(_,h),_=Uu(_),!r)return _;var b,m=t[0],x=e[0],w=t[1],M=e[1];x<m&&(b=m,m=x,x=b);var N=x-m,A=ru(N-Qa)<Wa;if(!A&&M<w&&(b=w,w=M,M=b),A||N<Wa?A?w+M>0^_[1]<(ru(_[0]-m)<Wa?w:M):w<=_[1]&&_[1]<=M:N>Qa^(m<=_[0]&&_[0]<=x)){var T=Iu(d,(-p+y)/v);return Fu(T,h),[_,Uu(T)]}}}function u(n,e){var i=r?t:Qa-t,o=0;return n<-i?o|=1:n>i&&(o|=2),e<-i?o|=4:e>i&&(o|=8),o}return rf(o,function(t){var n,e,c,f,s;return{lineStart:function(){f=c=!1,s=1},point:function(l,h){var d,p=[l,h],v=o(l,h),g=r?v?0:u(l,h):v?u(l+(l<0?Qa:-Qa),h):0;if(!n&&(f=c=v)&&t.lineStart(),v!==c&&(!(d=a(n,p))||Zc(n,d)||Zc(p,d))&&(p[0]+=Wa,p[1]+=Wa,v=o(p[0],p[1])),v!==c)s=0,v?(t.lineStart(),d=a(p,n),t.point(d[0],d[1])):(d=a(n,p),t.point(d[0],d[1]),t.lineEnd()),n=d;else if(i&&n&&r^v){var y;g&e||!(y=a(p,n,!0))||(s=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!v||n&&Zc(n,p)||t.point(p[0],p[1]),n=p,c=v,e=g},lineEnd:function(){c&&t.lineEnd(),n=null},clean:function(){return s|(f&&c)<<1}}},function(n,r,i,o){Vc(o,t,e,i,n,r)},r?[0,-t]:[-Qa,t-Qa])}var ff=1e9,sf=-ff;function lf(t,n,e,r){function i(i,o){return t<=i&&i<=e&&n<=o&&o<=r}function o(i,o,u,f){var s=0,l=0;if(null==i||(s=a(i,u))!==(l=a(o,u))||c(i,o)<0^u>0)do{f.point(0===s||3===s?t:e,s>1?r:n)}while((s=(s+u+4)%4)!==l);else f.point(o[0],o[1])}function a(r,i){return ru(r[0]-t)<Wa?i>0?0:3:ru(r[0]-e)<Wa?i>0?2:1:ru(r[1]-n)<Wa?i>0?1:0:i>0?3:2}function u(t,n){return c(t.x,n.x)}function c(t,n){var e=a(t,1),r=a(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}return function(a){var c,f,s,l,h,d,p,v,g,y,_,b=a,m=Wc(),x={point:w,lineStart:function(){x.point=M,f&&f.push(s=[]);y=!0,g=!1,p=v=NaN},lineEnd:function(){c&&(M(l,h),d&&g&&m.rejoin(),c.push(m.result()));x.point=w,g&&b.lineEnd()},polygonStart:function(){b=m,c=[],f=[],_=!0},polygonEnd:function(){var n=function(){for(var n=0,e=0,i=f.length;e<i;++e)for(var o,a,u=f[e],c=1,s=u.length,l=u[0],h=l[0],d=l[1];c<s;++c)o=h,a=d,l=u[c],h=l[0],d=l[1],a<=r?d>r&&(h-o)*(r-a)>(d-a)*(t-o)&&++n:d<=r&&(h-o)*(r-a)<(d-a)*(t-o)&&--n;return n}(),e=_&&n,i=(c=T(c)).length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&Kc(c,u,n,o,a),a.polygonEnd());b=a,c=f=s=null}};function w(t,n){i(t,n)&&b.point(t,n)}function M(o,a){var u=i(o,a);if(f&&s.push([o,a]),y)l=o,h=a,d=u,y=!1,u&&(b.lineStart(),b.point(o,a));else if(u&&g)b.point(o,a);else{var c=[p=Math.max(sf,Math.min(ff,p)),v=Math.max(sf,Math.min(ff,v))],m=[o=Math.max(sf,Math.min(ff,o)),a=Math.max(sf,Math.min(ff,a))];!function(t,n,e,r,i,o){var a,u=t[0],c=t[1],f=0,s=1,l=n[0]-u,h=n[1]-c;if(a=e-u,l||!(a>0)){if(a/=l,l<0){if(a<f)return;a<s&&(s=a)}else if(l>0){if(a>s)return;a>f&&(f=a)}if(a=i-u,l||!(a<0)){if(a/=l,l<0){if(a>s)return;a>f&&(f=a)}else if(l>0){if(a<f)return;a<s&&(s=a)}if(a=r-c,h||!(a>0)){if(a/=h,h<0){if(a<f)return;a<s&&(s=a)}else if(h>0){if(a>s)return;a>f&&(f=a)}if(a=o-c,h||!(a<0)){if(a/=h,h<0){if(a>s)return;a>f&&(f=a)}else if(h>0){if(a<f)return;a<s&&(s=a)}return f>0&&(t[0]=u+f*l,t[1]=c+f*h),s<1&&(n[0]=u+s*l,n[1]=c+s*h),!0}}}}}(c,m,t,n,e,r)?u&&(b.lineStart(),b.point(o,a),_=!1):(g||(b.lineStart(),b.point(c[0],c[1])),b.point(m[0],m[1]),u||b.lineEnd(),_=!1)}p=o,v=a,g=u}return x}}var hf,df,pf,vf=Xa(),gf={sphere:_u,point:_u,lineStart:function(){gf.point=_f,gf.lineEnd=yf},lineEnd:_u,polygonStart:_u,polygonEnd:_u};function yf(){gf.point=gf.lineEnd=_u}function _f(t,n){hf=t*=eu,df=lu(n*=eu),pf=au(n),gf.point=bf}function bf(t,n){t*=eu;var e=lu(n*=eu),r=au(n),i=ru(t-hf),o=au(i),a=r*lu(i),u=pf*e-df*r*o,c=df*e+pf*r*o;vf.add(ou(du(a*a+u*u),c)),hf=t,df=e,pf=r}function mf(t){return vf.reset(),Nu(t,gf),+vf}var xf=[null,null],wf={type:"LineString",coordinates:xf};function Mf(t,n){return xf[0]=t,xf[1]=n,mf(wf)}var Nf={Feature:function(t,n){return Tf(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r<i;)if(Tf(e[r].geometry,n))return!0;return!1}},Af={Sphere:function(){return!0},Point:function(t,n){return Sf(t.coordinates,n)},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)if(Sf(e[r],n))return!0;return!1},LineString:function(t,n){return kf(t.coordinates,n)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)if(kf(e[r],n))return!0;return!1},Polygon:function(t,n){return Ef(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)if(Ef(e[r],n))return!0;return!1},GeometryCollection:function(t,n){for(var e=t.geometries,r=-1,i=e.length;++r<i;)if(Tf(e[r],n))return!0;return!1}};function Tf(t,n){return!(!t||!Af.hasOwnProperty(t.type))&&Af[t.type](t,n)}function Sf(t,n){return 0===Mf(t,n)}function kf(t,n){for(var e,r,i,o=0,a=t.length;o<a;o++){if(0===(r=Mf(t[o],n)))return!0;if(o>0&&(i=Mf(t[o],t[o-1]))>0&&e<=i&&r<=i&&(e+r-i)*(1-Math.pow((e-r)/i,2))<Za*i)return!0;e=r}return!1}function Ef(t,n){return!!ef(t.map(Cf),Pf(n))}function Cf(t){return(t=t.map(Pf)).pop(),t}function Pf(t){return[t[0]*eu,t[1]*eu]}function zf(t,n,e){var r=g(t,n-Wa,e).concat(n);return function(t){return r.map(function(n){return[t,n]})}}function Rf(t,n,e){var r=g(t,n-Wa,e).concat(n);return function(t){return r.map(function(n){return[n,t]})}}function Df(){var t,n,e,r,i,o,a,u,c,f,s,l,h=10,d=h,p=90,v=360,y=2.5;function _(){return{type:"MultiLineString",coordinates:b()}}function b(){return g(uu(r/p)*p,e,p).map(s).concat(g(uu(u/v)*v,a,v).map(l)).concat(g(uu(n/h)*h,t,h).filter(function(t){return ru(t%p)>Wa}).map(c)).concat(g(uu(o/d)*d,i,d).filter(function(t){return ru(t%v)>Wa}).map(f))}return _.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},_.outline=function(){return{type:"Polygon",coordinates:[s(r).concat(l(a).slice(1),s(e).reverse().slice(1),l(u).reverse().slice(1))]}},_.extent=function(t){return arguments.length?_.extentMajor(t).extentMinor(t):_.extentMinor()},_.extentMajor=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],u=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),u>a&&(t=u,u=a,a=t),_.precision(y)):[[r,u],[e,a]]},_.extentMinor=function(e){return arguments.length?(n=+e[0][0],t=+e[1][0],o=+e[0][1],i=+e[1][1],n>t&&(e=n,n=t,t=e),o>i&&(e=o,o=i,i=e),_.precision(y)):[[n,o],[t,i]]},_.step=function(t){return arguments.length?_.stepMajor(t).stepMinor(t):_.stepMinor()},_.stepMajor=function(t){return arguments.length?(p=+t[0],v=+t[1],_):[p,v]},_.stepMinor=function(t){return arguments.length?(h=+t[0],d=+t[1],_):[h,d]},_.precision=function(h){return arguments.length?(y=+h,c=zf(o,i,90),f=Rf(n,t,y),s=zf(u,a,90),l=Rf(r,e,y),_):y},_.extentMajor([[-180,-90+Wa],[180,90-Wa]]).extentMinor([[-180,-80-Wa],[180,80+Wa]])}function qf(t){return t}var Lf,Uf,Of,Bf,Yf=Xa(),Ff=Xa(),If={point:_u,lineStart:_u,lineEnd:_u,polygonStart:function(){If.lineStart=Hf,If.lineEnd=Gf},polygonEnd:function(){If.lineStart=If.lineEnd=If.point=_u,Yf.add(ru(Ff)),Ff.reset()},result:function(){var t=Yf/2;return Yf.reset(),t}};function Hf(){If.point=jf}function jf(t,n){If.point=Xf,Lf=Of=t,Uf=Bf=n}function Xf(t,n){Ff.add(Bf*t-Of*n),Of=t,Bf=n}function Gf(){Xf(Lf,Uf)}var Vf=1/0,$f=Vf,Wf=-Vf,Zf=Wf,Qf={point:function(t,n){t<Vf&&(Vf=t);t>Wf&&(Wf=t);n<$f&&($f=n);n>Zf&&(Zf=n)},lineStart:_u,lineEnd:_u,polygonStart:_u,polygonEnd:_u,result:function(){var t=[[Vf,$f],[Wf,Zf]];return Wf=Zf=-($f=Vf=1/0),t}};var Kf,Jf,ts,ns,es=0,rs=0,is=0,os=0,as=0,us=0,cs=0,fs=0,ss=0,ls={point:hs,lineStart:ds,lineEnd:gs,polygonStart:function(){ls.lineStart=ys,ls.lineEnd=_s},polygonEnd:function(){ls.point=hs,ls.lineStart=ds,ls.lineEnd=gs},result:function(){var t=ss?[cs/ss,fs/ss]:us?[os/us,as/us]:is?[es/is,rs/is]:[NaN,NaN];return es=rs=is=os=as=us=cs=fs=ss=0,t}};function hs(t,n){es+=t,rs+=n,++is}function ds(){ls.point=ps}function ps(t,n){ls.point=vs,hs(ts=t,ns=n)}function vs(t,n){var e=t-ts,r=n-ns,i=du(e*e+r*r);os+=i*(ts+t)/2,as+=i*(ns+n)/2,us+=i,hs(ts=t,ns=n)}function gs(){ls.point=hs}function ys(){ls.point=bs}function _s(){ms(Kf,Jf)}function bs(t,n){ls.point=ms,hs(Kf=ts=t,Jf=ns=n)}function ms(t,n){var e=t-ts,r=n-ns,i=du(e*e+r*r);os+=i*(ts+t)/2,as+=i*(ns+n)/2,us+=i,cs+=(i=ns*t-ts*n)*(ts+t),fs+=i*(ns+n),ss+=3*i,hs(ts=t,ns=n)}function xs(t){this._context=t}xs.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(t,n){switch(this._point){case 0:this._context.moveTo(t,n),this._point=1;break;case 1:this._context.lineTo(t,n);break;default:this._context.moveTo(t+this._radius,n),this._context.arc(t,n,this._radius,0,tu)}},result:_u};var ws,Ms,Ns,As,Ts,Ss=Xa(),ks={point:_u,lineStart:function(){ks.point=Es},lineEnd:function(){ws&&Cs(Ms,Ns),ks.point=_u},polygonStart:function(){ws=!0},polygonEnd:function(){ws=null},result:function(){var t=+Ss;return Ss.reset(),t}};function Es(t,n){ks.point=Cs,Ms=As=t,Ns=Ts=n}function Cs(t,n){As-=t,Ts-=n,Ss.add(du(As*As+Ts*Ts)),As=t,Ts=n}function Ps(){this._string=[]}function zs(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Rs(t){return function(n){var e=new Ds;for(var r in t)e[r]=t[r];return e.stream=n,e}}function Ds(){}function qs(t,n,e){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),Nu(e,t.stream(Qf)),n(Qf.result()),null!=r&&t.clipExtent(r),t}function Ls(t,n,e){return qs(t,function(e){var r=n[1][0]-n[0][0],i=n[1][1]-n[0][1],o=Math.min(r/(e[1][0]-e[0][0]),i/(e[1][1]-e[0][1])),a=+n[0][0]+(r-o*(e[1][0]+e[0][0]))/2,u=+n[0][1]+(i-o*(e[1][1]+e[0][1]))/2;t.scale(150*o).translate([a,u])},e)}function Us(t,n,e){return Ls(t,[[0,0],n],e)}function Os(t,n,e){return qs(t,function(e){var r=+n,i=r/(e[1][0]-e[0][0]),o=(r-i*(e[1][0]+e[0][0]))/2,a=-i*e[0][1];t.scale(150*i).translate([o,a])},e)}function Bs(t,n,e){return qs(t,function(e){var r=+n,i=r/(e[1][1]-e[0][1]),o=-i*e[0][0],a=(r-i*(e[1][1]+e[0][1]))/2;t.scale(150*i).translate([o,a])},e)}Ps.prototype={_radius:4.5,_circle:zs(4.5),pointRadius:function(t){return(t=+t)!==this._radius&&(this._radius=t,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._string.push("Z"),this._point=NaN},point:function(t,n){switch(this._point){case 0:this._string.push("M",t,",",n),this._point=1;break;case 1:this._string.push("L",t,",",n);break;default:null==this._circle&&(this._circle=zs(this._radius)),this._string.push("M",t,",",n,this._circle)}},result:function(){if(this._string.length){var t=this._string.join("");return this._string=[],t}return null}},Ds.prototype={constructor:Ds,point:function(t,n){this.stream.point(t,n)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var Ys=16,Fs=au(30*eu);function Is(t,n){return+n?function(t,n){function e(r,i,o,a,u,c,f,s,l,h,d,p,v,g){var y=f-r,_=s-i,b=y*y+_*_;if(b>4*n&&v--){var m=a+h,x=u+d,w=c+p,M=du(m*m+x*x+w*w),N=gu(w/=M),A=ru(ru(w)-1)<Wa||ru(o-l)<Wa?(o+l)/2:ou(x,m),T=t(A,N),S=T[0],k=T[1],E=S-r,C=k-i,P=_*E-y*C;(P*P/b>n||ru((y*E+_*C)/b-.5)>.3||a*h+u*d+c*p<Fs)&&(e(r,i,o,a,u,c,S,k,A,m/=M,x/=M,w,v,g),g.point(S,k),e(S,k,A,m,x,w,f,s,l,h,d,p,v,g))}}return function(n){var r,i,o,a,u,c,f,s,l,h,d,p,v={point:g,lineStart:y,lineEnd:b,polygonStart:function(){n.polygonStart(),v.lineStart=m},polygonEnd:function(){n.polygonEnd(),v.lineStart=y}};function g(e,r){e=t(e,r),n.point(e[0],e[1])}function y(){s=NaN,v.point=_,n.lineStart()}function _(r,i){var o=Ou([r,i]),a=t(r,i);e(s,l,f,h,d,p,s=a[0],l=a[1],f=r,h=o[0],d=o[1],p=o[2],Ys,n),n.point(s,l)}function b(){v.point=g,n.lineEnd()}function m(){y(),v.point=x,v.lineEnd=w}function x(t,n){_(r=t,n),i=s,o=l,a=h,u=d,c=p,v.point=_}function w(){e(s,l,f,h,d,p,i,o,r,a,u,c,Ys,n),v.lineEnd=b,b()}return v}}(t,n):function(t){return Rs({point:function(n,e){n=t(n,e),this.stream.point(n[0],n[1])}})}(t)}var Hs=Rs({point:function(t,n){this.stream.point(t*eu,n*eu)}});function js(t,n,e,r){var i=au(r),o=lu(r),a=i*t,u=o*t,c=i/t,f=o/t,s=(o*e-i*n)/t,l=(o*n+i*e)/t;function h(t,r){return[a*t-u*r+n,e-u*t-a*r]}return h.invert=function(t,n){return[c*t-f*n+s,l-f*t-c*n]},h}function Xs(t){return Gs(function(){return t})()}function Gs(t){var n,e,r,i,o,a,u,c,f,s,l=150,h=480,d=250,p=0,v=0,g=0,y=0,_=0,b=0,m=null,x=uf,w=null,M=qf,N=.5;function A(t){return c(t[0]*eu,t[1]*eu)}function T(t){return(t=c.invert(t[0],t[1]))&&[t[0]*nu,t[1]*nu]}function S(){var t=js(l,0,0,b).apply(null,n(p,v)),r=(b?js:function(t,n,e){function r(r,i){return[n+t*r,e-t*i]}return r.invert=function(r,i){return[(r-n)/t,(e-i)/t]},r})(l,h-t[0],d-t[1],b);return e=Ic(g,y,_),u=Yc(n,r),c=Yc(e,u),a=Is(u,N),k()}function k(){return f=s=null,A}return A.stream=function(t){return f&&s===t?f:f=Hs(function(t){return Rs({point:function(n,e){var r=t(n,e);return this.stream.point(r[0],r[1])}})}(e)(x(a(M(s=t)))))},A.preclip=function(t){return arguments.length?(x=t,m=void 0,k()):x},A.postclip=function(t){return arguments.length?(M=t,w=r=i=o=null,k()):M},A.clipAngle=function(t){return arguments.length?(x=+t?cf(m=t*eu):(m=null,uf),k()):m*nu},A.clipExtent=function(t){return arguments.length?(M=null==t?(w=r=i=o=null,qf):lf(w=+t[0][0],r=+t[0][1],i=+t[1][0],o=+t[1][1]),k()):null==w?null:[[w,r],[i,o]]},A.scale=function(t){return arguments.length?(l=+t,S()):l},A.translate=function(t){return arguments.length?(h=+t[0],d=+t[1],S()):[h,d]},A.center=function(t){return arguments.length?(p=t[0]%360*eu,v=t[1]%360*eu,S()):[p*nu,v*nu]},A.rotate=function(t){return arguments.length?(g=t[0]%360*eu,y=t[1]%360*eu,_=t.length>2?t[2]%360*eu:0,S()):[g*nu,y*nu,_*nu]},A.angle=function(t){return arguments.length?(b=t%360*eu,S()):b*nu},A.precision=function(t){return arguments.length?(a=Is(u,N=t*t),k()):du(N)},A.fitExtent=function(t,n){return Ls(A,t,n)},A.fitSize=function(t,n){return Us(A,t,n)},A.fitWidth=function(t,n){return Os(A,t,n)},A.fitHeight=function(t,n){return Bs(A,t,n)},function(){return n=t.apply(this,arguments),A.invert=n.invert&&T,S()}}function Vs(t){var n=0,e=Qa/3,r=Gs(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*eu,e=t[1]*eu):[n*nu,e*nu]},i}function $s(t,n){var e=lu(t),r=(e+lu(n))/2;if(ru(r)<Wa)return function(t){var n=au(t);function e(t,e){return[t*n,lu(e)/n]}return e.invert=function(t,e){return[t/n,gu(e*n)]},e}(t);var i=1+e*(2*r-e),o=du(i)/r;function a(t,n){var e=du(i-2*r*lu(n))/r;return[e*lu(t*=r),o-e*au(t)]}return a.invert=function(t,n){var e=o-n;return[ou(t,ru(e))/r*hu(e),gu((i-(t*t+e*e)*r*r)/(2*r))]},a}function Ws(){return Vs($s).scale(155.424).center([0,33.6442])}function Zs(){return Ws().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}function Qs(t){return function(n,e){var r=au(n),i=au(e),o=t(r*i);return[o*i*lu(n),o*lu(e)]}}function Ks(t){return function(n,e){var r=du(n*n+e*e),i=t(r),o=lu(i),a=au(i);return[ou(n*o,r*a),gu(r&&e*o/r)]}}var Js=Qs(function(t){return du(2/(1+t))});Js.invert=Ks(function(t){return 2*gu(t/2)});var tl=Qs(function(t){return(t=vu(t))&&t/lu(t)});function nl(t,n){return[t,fu(pu((Ka+n)/2))]}function el(t){var n,e,r,i=Xs(t),o=i.center,a=i.scale,u=i.translate,c=i.clipExtent,f=null;function s(){var o=Qa*a(),u=i(Gc(i.rotate()).invert([0,0]));return c(null==f?[[u[0]-o,u[1]-o],[u[0]+o,u[1]+o]]:t===nl?[[Math.max(u[0]-o,f),n],[Math.min(u[0]+o,e),r]]:[[f,Math.max(u[1]-o,n)],[e,Math.min(u[1]+o,r)]])}return i.scale=function(t){return arguments.length?(a(t),s()):a()},i.translate=function(t){return arguments.length?(u(t),s()):u()},i.center=function(t){return arguments.length?(o(t),s()):o()},i.clipExtent=function(t){return arguments.length?(null==t?f=n=e=r=null:(f=+t[0][0],n=+t[0][1],e=+t[1][0],r=+t[1][1]),s()):null==f?null:[[f,n],[e,r]]},s()}function rl(t){return pu((Ka+t)/2)}function il(t,n){var e=au(t),r=t===n?lu(t):fu(e/au(n))/fu(rl(n)/rl(t)),i=e*su(rl(t),r)/r;if(!r)return nl;function o(t,n){i>0?n<-Ka+Wa&&(n=-Ka+Wa):n>Ka-Wa&&(n=Ka-Wa);var e=i/su(rl(n),r);return[e*lu(r*t),i-e*au(r*t)]}return o.invert=function(t,n){var e=i-n,o=hu(r)*du(t*t+e*e);return[ou(t,ru(e))/r*hu(e),2*iu(su(i/o,1/r))-Ka]},o}function ol(t,n){return[t,n]}function al(t,n){var e=au(t),r=t===n?lu(t):(e-au(n))/(n-t),i=e/r+t;if(ru(r)<Wa)return ol;function o(t,n){var e=i-n,o=r*t;return[e*lu(o),i-e*au(o)]}return o.invert=function(t,n){var e=i-n;return[ou(t,ru(e))/r*hu(e),i-hu(r)*du(t*t+e*e)]},o}tl.invert=Ks(function(t){return t}),nl.invert=function(t,n){return[t,2*iu(cu(n))-Ka]},ol.invert=ol;var ul=1.340264,cl=-.081106,fl=893e-6,sl=.003796,ll=du(3)/2;function hl(t,n){var e=gu(ll*lu(n)),r=e*e,i=r*r*r;return[t*au(e)/(ll*(ul+3*cl*r+i*(7*fl+9*sl*r))),e*(ul+cl*r+i*(fl+sl*r))]}function dl(t,n){var e=au(n),r=au(t)*e;return[e*lu(t)/r,lu(n)/r]}function pl(t,n,e,r){return 1===t&&1===n&&0===e&&0===r?qf:Rs({point:function(i,o){this.stream.point(i*t+e,o*n+r)}})}function vl(t,n){var e=n*n,r=e*e;return[t*(.8707-.131979*e+r*(r*(.003971*e-.001529*r)-.013791)),n*(1.007226+e*(.015085+r*(.028874*e-.044475-.005916*r)))]}function gl(t,n){return[au(n)*lu(t),lu(n)]}function yl(t,n){var e=au(n),r=1+au(t)*e;return[e*lu(t)/r,lu(n)/r]}function _l(t,n){return[fu(pu((Ka+n)/2)),-t]}function bl(t,n){return t.parent===n.parent?1:2}function ml(t,n){return t+n.x}function xl(t,n){return Math.max(t,n.y)}function wl(t){var n=0,e=t.children,r=e&&e.length;if(r)for(;--r>=0;)n+=e[r].value;else n=1;t.value=n}function Ml(t,n){var e,r,i,o,a,u=new Sl(t),c=+t.value&&(u.value=t.value),f=[u];for(null==n&&(n=Nl);e=f.pop();)if(c&&(e.value=+e.data.value),(i=n(e.data))&&(a=i.length))for(e.children=new Array(a),o=a-1;o>=0;--o)f.push(r=e.children[o]=new Sl(i[o])),r.parent=e,r.depth=e.depth+1;return u.eachBefore(Tl)}function Nl(t){return t.children}function Al(t){t.data=t.data.data}function Tl(t){var n=0;do{t.height=n}while((t=t.parent)&&t.height<++n)}function Sl(t){this.data=t,this.depth=this.height=0,this.parent=null}hl.invert=function(t,n){for(var e,r=n,i=r*r,o=i*i*i,a=0;a<12&&(o=(i=(r-=e=(r*(ul+cl*i+o*(fl+sl*i))-n)/(ul+3*cl*i+o*(7*fl+9*sl*i)))*r)*i*i,!(ru(e)<Za));++a);return[ll*t*(ul+3*cl*i+o*(7*fl+9*sl*i))/au(r),gu(lu(r)/ll)]},dl.invert=Ks(iu),vl.invert=function(t,n){var e,r=n,i=25;do{var o=r*r,a=o*o;r-=e=(r*(1.007226+o*(.015085+a*(.028874*o-.044475-.005916*a)))-n)/(1.007226+o*(.045255+a*(.259866*o-.311325-.005916*11*a)))}while(ru(e)>Wa&&--i>0);return[t/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r]},gl.invert=Ks(gu),yl.invert=Ks(function(t){return 2*iu(t)}),_l.invert=function(t,n){return[-n,2*iu(cu(t))-Ka]},Sl.prototype=Ml.prototype={constructor:Sl,count:function(){return this.eachAfter(wl)},each:function(t){var n,e,r,i,o=this,a=[o];do{for(n=a.reverse(),a=[];o=n.pop();)if(t(o),e=o.children)for(r=0,i=e.length;r<i;++r)a.push(e[r])}while(a.length);return this},eachAfter:function(t){for(var n,e,r,i=this,o=[i],a=[];i=o.pop();)if(a.push(i),n=i.children)for(e=0,r=n.length;e<r;++e)o.push(n[e]);for(;i=a.pop();)t(i);return this},eachBefore:function(t){for(var n,e,r=this,i=[r];r=i.pop();)if(t(r),n=r.children)for(e=n.length-1;e>=0;--e)i.push(n[e]);return this},sum:function(t){return this.eachAfter(function(n){for(var e=+t(n.data)||0,r=n.children,i=r&&r.length;--i>=0;)e+=r[i].value;n.value=e})},sort:function(t){return this.eachBefore(function(n){n.children&&n.children.sort(t)})},path:function(t){for(var n=this,e=function(t,n){if(t===n)return t;var e=t.ancestors(),r=n.ancestors(),i=null;for(t=e.pop(),n=r.pop();t===n;)i=t,t=e.pop(),n=r.pop();return i}(n,t),r=[n];n!==e;)n=n.parent,r.push(n);for(var i=r.length;t!==e;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,n=[t];t=t.parent;)n.push(t);return n},descendants:function(){var t=[];return this.each(function(n){t.push(n)}),t},leaves:function(){var t=[];return this.eachBefore(function(n){n.children||t.push(n)}),t},links:function(){var t=this,n=[];return t.each(function(e){e!==t&&n.push({source:e.parent,target:e})}),n},copy:function(){return Ml(this).eachBefore(Al)}};var kl=Array.prototype.slice;function El(t){for(var n,e,r=0,i=(t=function(t){for(var n,e,r=t.length;r;)e=Math.random()*r--|0,n=t[r],t[r]=t[e],t[e]=n;return t}(kl.call(t))).length,o=[];r<i;)n=t[r],e&&zl(e,n)?++r:(e=Dl(o=Cl(o,n)),r=0);return e}function Cl(t,n){var e,r;if(Rl(n,t))return[n];for(e=0;e<t.length;++e)if(Pl(n,t[e])&&Rl(ql(t[e],n),t))return[t[e],n];for(e=0;e<t.length-1;++e)for(r=e+1;r<t.length;++r)if(Pl(ql(t[e],t[r]),n)&&Pl(ql(t[e],n),t[r])&&Pl(ql(t[r],n),t[e])&&Rl(Ll(t[e],t[r],n),t))return[t[e],t[r],n];throw new Error}function Pl(t,n){var e=t.r-n.r,r=n.x-t.x,i=n.y-t.y;return e<0||e*e<r*r+i*i}function zl(t,n){var e=t.r-n.r+1e-6,r=n.x-t.x,i=n.y-t.y;return e>0&&e*e>r*r+i*i}function Rl(t,n){for(var e=0;e<n.length;++e)if(!zl(t,n[e]))return!1;return!0}function Dl(t){switch(t.length){case 1:return function(t){return{x:t.x,y:t.y,r:t.r}}(t[0]);case 2:return ql(t[0],t[1]);case 3:return Ll(t[0],t[1],t[2])}}function ql(t,n){var e=t.x,r=t.y,i=t.r,o=n.x,a=n.y,u=n.r,c=o-e,f=a-r,s=u-i,l=Math.sqrt(c*c+f*f);return{x:(e+o+c/l*s)/2,y:(r+a+f/l*s)/2,r:(l+i+u)/2}}function Ll(t,n,e){var r=t.x,i=t.y,o=t.r,a=n.x,u=n.y,c=n.r,f=e.x,s=e.y,l=e.r,h=r-a,d=r-f,p=i-u,v=i-s,g=c-o,y=l-o,_=r*r+i*i-o*o,b=_-a*a-u*u+c*c,m=_-f*f-s*s+l*l,x=d*p-h*v,w=(p*m-v*b)/(2*x)-r,M=(v*g-p*y)/x,N=(d*b-h*m)/(2*x)-i,A=(h*y-d*g)/x,T=M*M+A*A-1,S=2*(o+w*M+N*A),k=w*w+N*N-o*o,E=-(T?(S+Math.sqrt(S*S-4*T*k))/(2*T):k/S);return{x:r+w+M*E,y:i+N+A*E,r:E}}function Ul(t,n,e){var r,i,o,a,u=t.x-n.x,c=t.y-n.y,f=u*u+c*c;f?(i=n.r+e.r,i*=i,a=t.r+e.r,i>(a*=a)?(r=(f+a-i)/(2*f),o=Math.sqrt(Math.max(0,a/f-r*r)),e.x=t.x-r*u-o*c,e.y=t.y-r*c+o*u):(r=(f+i-a)/(2*f),o=Math.sqrt(Math.max(0,i/f-r*r)),e.x=n.x+r*u-o*c,e.y=n.y+r*c+o*u)):(e.x=n.x+e.r,e.y=n.y)}function Ol(t,n){var e=t.r+n.r-1e-6,r=n.x-t.x,i=n.y-t.y;return e>0&&e*e>r*r+i*i}function Bl(t){var n=t._,e=t.next._,r=n.r+e.r,i=(n.x*e.r+e.x*n.r)/r,o=(n.y*e.r+e.y*n.r)/r;return i*i+o*o}function Yl(t){this._=t,this.next=null,this.previous=null}function Fl(t){if(!(i=t.length))return 0;var n,e,r,i,o,a,u,c,f,s,l;if((n=t[0]).x=0,n.y=0,!(i>1))return n.r;if(e=t[1],n.x=-e.r,e.x=n.r,e.y=0,!(i>2))return n.r+e.r;Ul(e,n,r=t[2]),n=new Yl(n),e=new Yl(e),r=new Yl(r),n.next=r.previous=e,e.next=n.previous=r,r.next=e.previous=n;t:for(u=3;u<i;++u){Ul(n._,e._,r=t[u]),r=new Yl(r),c=e.next,f=n.previous,s=e._.r,l=n._.r;do{if(s<=l){if(Ol(c._,r._)){e=c,n.next=e,e.previous=n,--u;continue t}s+=c._.r,c=c.next}else{if(Ol(f._,r._)){(n=f).next=e,e.previous=n,--u;continue t}l+=f._.r,f=f.previous}}while(c!==f.next);for(r.previous=n,r.next=e,n.next=e.previous=e=r,o=Bl(n);(r=r.next)!==e;)(a=Bl(r))<o&&(n=r,o=a);e=n.next}for(n=[e._],r=e;(r=r.next)!==e;)n.push(r._);for(r=El(n),u=0;u<i;++u)(n=t[u]).x-=r.x,n.y-=r.y;return r.r}function Il(t){return null==t?null:Hl(t)}function Hl(t){if("function"!=typeof t)throw new Error;return t}function jl(){return 0}function Xl(t){return function(){return t}}function Gl(t){return Math.sqrt(t.value)}function Vl(t){return function(n){n.children||(n.r=Math.max(0,+t(n)||0))}}function $l(t,n){return function(e){if(r=e.children){var r,i,o,a=r.length,u=t(e)*n||0;if(u)for(i=0;i<a;++i)r[i].r+=u;if(o=Fl(r),u)for(i=0;i<a;++i)r[i].r-=u;e.r=o+u}}}function Wl(t){return function(n){var e=n.parent;n.r*=t,e&&(n.x=e.x+t*n.x,n.y=e.y+t*n.y)}}function Zl(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function Ql(t,n,e,r,i){for(var o,a=t.children,u=-1,c=a.length,f=t.value&&(r-n)/t.value;++u<c;)(o=a[u]).y0=e,o.y1=i,o.x0=n,o.x1=n+=o.value*f}var Kl="$",Jl={depth:-1},th={};function nh(t){return t.id}function eh(t){return t.parentId}function rh(t,n){return t.parent===n.parent?1:2}function ih(t){var n=t.children;return n?n[0]:t.t}function oh(t){var n=t.children;return n?n[n.length-1]:t.t}function ah(t,n,e){var r=e/(n.i-t.i);n.c-=r,n.s+=e,t.c+=r,n.z+=e,n.m+=e}function uh(t,n,e){return t.a.parent===n.parent?t.a:e}function ch(t,n){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=n}function fh(t,n,e,r,i){for(var o,a=t.children,u=-1,c=a.length,f=t.value&&(i-e)/t.value;++u<c;)(o=a[u]).x0=n,o.x1=r,o.y0=e,o.y1=e+=o.value*f}ch.prototype=Object.create(Sl.prototype);var sh=(1+Math.sqrt(5))/2;function lh(t,n,e,r,i,o){for(var a,u,c,f,s,l,h,d,p,v,g,y=[],_=n.children,b=0,m=0,x=_.length,w=n.value;b<x;){c=i-e,f=o-r;do{s=_[m++].value}while(!s&&m<x);for(l=h=s,g=s*s*(v=Math.max(f/c,c/f)/(w*t)),p=Math.max(h/g,g/l);m<x;++m){if(s+=u=_[m].value,u<l&&(l=u),u>h&&(h=u),g=s*s*v,(d=Math.max(h/g,g/l))>p){s-=u;break}p=d}y.push(a={value:s,dice:c<f,children:_.slice(b,m)}),a.dice?Ql(a,e,r,i,w?r+=f*s/w:o):fh(a,e,r,w?e+=c*s/w:i,o),w-=s,b=m}return y}var hh=function t(n){function e(t,e,r,i,o){lh(n,t,e,r,i,o)}return e.ratio=function(n){return t((n=+n)>1?n:1)},e}(sh);var dh=function t(n){function e(t,e,r,i,o){if((a=t._squarify)&&a.ratio===n)for(var a,u,c,f,s,l=-1,h=a.length,d=t.value;++l<h;){for(c=(u=a[l]).children,f=u.value=0,s=c.length;f<s;++f)u.value+=c[f].value;u.dice?Ql(u,e,r,i,r+=(o-r)*u.value/d):fh(u,e,r,e+=(i-e)*u.value/d,o),d-=u.value}else t._squarify=a=lh(n,t,e,r,i,o),a.ratio=n}return e.ratio=function(n){return t((n=+n)>1?n:1)},e}(sh);function ph(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function vh(t,n){return t[0]-n[0]||t[1]-n[1]}function gh(t){for(var n=t.length,e=[0,1],r=2,i=2;i<n;++i){for(;r>1&&ph(t[e[r-2]],t[e[r-1]],t[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function yh(){return Math.random()}var _h=function t(n){function e(t,e){return t=null==t?0:+t,e=null==e?1:+e,1===arguments.length?(e=t,t=0):e-=t,function(){return n()*e+t}}return e.source=t,e}(yh),bh=function t(n){function e(t,e){var r,i;return t=null==t?0:+t,e=null==e?1:+e,function(){var o;if(null!=r)o=r,r=null;else do{r=2*n()-1,o=2*n()-1,i=r*r+o*o}while(!i||i>1);return t+e*o*Math.sqrt(-2*Math.log(i)/i)}}return e.source=t,e}(yh),mh=function t(n){function e(){var t=bh.source(n).apply(this,arguments);return function(){return Math.exp(t())}}return e.source=t,e}(yh),xh=function t(n){function e(t){return function(){for(var e=0,r=0;r<t;++r)e+=n();return e}}return e.source=t,e}(yh),wh=function t(n){function e(t){var e=xh.source(n)(t);return function(){return e()/t}}return e.source=t,e}(yh),Mh=function t(n){function e(t){return function(){return-Math.log(1-n())/t}}return e.source=t,e}(yh);function Nh(t,n){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(n).domain(t)}return this}function Ah(t,n){switch(arguments.length){case 0:break;case 1:this.interpolator(t);break;default:this.interpolator(n).domain(t)}return this}var Th=Array.prototype,Sh=Th.map,kh=Th.slice,Eh={name:"implicit"};function Ch(){var t=uo(),n=[],e=[],r=Eh;function i(i){var o=i+"",a=t.get(o);if(!a){if(r!==Eh)return r;t.set(o,a=n.push(i))}return e[(a-1)%e.length]}return i.domain=function(e){if(!arguments.length)return n.slice();n=[],t=uo();for(var r,o,a=-1,u=e.length;++a<u;)t.has(o=(r=e[a])+"")||t.set(o,n.push(r));return i},i.range=function(t){return arguments.length?(e=kh.call(t),i):e.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return Ch(n,e).unknown(r)},Nh.apply(i,arguments),i}function Ph(){var t,n,e=Ch().unknown(void 0),r=e.domain,i=e.range,o=[0,1],a=!1,u=0,c=0,f=.5;function s(){var e=r().length,s=o[1]<o[0],l=o[s-0],h=o[1-s];t=(h-l)/Math.max(1,e-u+2*c),a&&(t=Math.floor(t)),l+=(h-l-t*(e-u))*f,n=t*(1-u),a&&(l=Math.round(l),n=Math.round(n));var d=g(e).map(function(n){return l+t*n});return i(s?d.reverse():d)}return delete e.unknown,e.domain=function(t){return arguments.length?(r(t),s()):r()},e.range=function(t){return arguments.length?(o=[+t[0],+t[1]],s()):o.slice()},e.rangeRound=function(t){return o=[+t[0],+t[1]],a=!0,s()},e.bandwidth=function(){return n},e.step=function(){return t},e.round=function(t){return arguments.length?(a=!!t,s()):a},e.padding=function(t){return arguments.length?(u=Math.min(1,c=+t),s()):u},e.paddingInner=function(t){return arguments.length?(u=Math.min(1,t),s()):u},e.paddingOuter=function(t){return arguments.length?(c=+t,s()):c},e.align=function(t){return arguments.length?(f=Math.max(0,Math.min(1,t)),s()):f},e.copy=function(){return Ph(r(),o).round(a).paddingInner(u).paddingOuter(c).align(f)},Nh.apply(s(),arguments)}function zh(t){return+t}var Rh=[0,1];function Dh(t){return t}function qh(t,n){return(n-=t=+t)?function(e){return(e-t)/n}:function(t){return function(){return t}}(isNaN(n)?NaN:.5)}function Lh(t){var n,e=t[0],r=t[t.length-1];return e>r&&(n=e,e=r,r=n),function(t){return Math.max(e,Math.min(r,t))}}function Uh(t,n,e){var r=t[0],i=t[1],o=n[0],a=n[1];return i<r?(r=qh(i,r),o=e(a,o)):(r=qh(r,i),o=e(o,a)),function(t){return o(r(t))}}function Oh(t,n,e){var r=Math.min(t.length,n.length)-1,o=new Array(r),a=new Array(r),u=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),n=n.slice().reverse());++u<r;)o[u]=qh(t[u],t[u+1]),a[u]=e(n[u],n[u+1]);return function(n){var e=i(t,n,1,r)-1;return a[e](o[e](n))}}function Bh(t,n){return n.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Yh(){var t,n,e,r,i,o,a=Rh,u=Rh,c=Ne,f=Dh;function s(){return r=Math.min(a.length,u.length)>2?Oh:Uh,i=o=null,l}function l(n){return isNaN(n=+n)?e:(i||(i=r(a.map(t),u,c)))(t(f(n)))}return l.invert=function(e){return f(n((o||(o=r(u,a.map(t),be)))(e)))},l.domain=function(t){return arguments.length?(a=Sh.call(t,zh),f===Dh||(f=Lh(a)),s()):a.slice()},l.range=function(t){return arguments.length?(u=kh.call(t),s()):u.slice()},l.rangeRound=function(t){return u=kh.call(t),c=Ae,s()},l.clamp=function(t){return arguments.length?(f=t?Lh(a):Dh,l):f!==Dh},l.interpolate=function(t){return arguments.length?(c=t,s()):c},l.unknown=function(t){return arguments.length?(e=t,l):e},function(e,r){return t=e,n=r,s()}}function Fh(t,n){return Yh()(t,n)}function Ih(n,e,r,i){var o,a=w(n,e,r);switch((i=za(null==i?",f":i)).type){case"s":var u=Math.max(Math.abs(n),Math.abs(e));return null!=i.precision||isNaN(o=Ha(a,u))||(i.precision=o),t.formatPrefix(i,u);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=ja(a,Math.max(Math.abs(n),Math.abs(e))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=Ia(a))||(i.precision=o-2*("%"===i.type))}return t.format(i)}function Hh(t){var n=t.domain;return t.ticks=function(t){var e=n();return m(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){var r=n();return Ih(r[0],r[r.length-1],null==t?10:t,e)},t.nice=function(e){null==e&&(e=10);var r,i=n(),o=0,a=i.length-1,u=i[o],c=i[a];return c<u&&(r=u,u=c,c=r,r=o,o=a,a=r),(r=x(u,c,e))>0?r=x(u=Math.floor(u/r)*r,c=Math.ceil(c/r)*r,e):r<0&&(r=x(u=Math.ceil(u*r)/r,c=Math.floor(c*r)/r,e)),r>0?(i[o]=Math.floor(u/r)*r,i[a]=Math.ceil(c/r)*r,n(i)):r<0&&(i[o]=Math.ceil(u*r)/r,i[a]=Math.floor(c*r)/r,n(i)),t},t}function jh(t,n){var e,r=0,i=(t=t.slice()).length-1,o=t[r],a=t[i];return a<o&&(e=r,r=i,i=e,e=o,o=a,a=e),t[r]=n.floor(o),t[i]=n.ceil(a),t}function Xh(t){return Math.log(t)}function Gh(t){return Math.exp(t)}function Vh(t){return-Math.log(-t)}function $h(t){return-Math.exp(-t)}function Wh(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Zh(t){return function(n){return-t(-n)}}function Qh(n){var e,r,i=n(Xh,Gh),o=i.domain,a=10;function u(){return e=function(t){return t===Math.E?Math.log:10===t&&Math.log10||2===t&&Math.log2||(t=Math.log(t),function(n){return Math.log(n)/t})}(a),r=function(t){return 10===t?Wh:t===Math.E?Math.exp:function(n){return Math.pow(t,n)}}(a),o()[0]<0?(e=Zh(e),r=Zh(r),n(Vh,$h)):n(Xh,Gh),i}return i.base=function(t){return arguments.length?(a=+t,u()):a},i.domain=function(t){return arguments.length?(o(t),u()):o()},i.ticks=function(t){var n,i=o(),u=i[0],c=i[i.length-1];(n=c<u)&&(h=u,u=c,c=h);var f,s,l,h=e(u),d=e(c),p=null==t?10:+t,v=[];if(!(a%1)&&d-h<p){if(h=Math.round(h)-1,d=Math.round(d)+1,u>0){for(;h<d;++h)for(s=1,f=r(h);s<a;++s)if(!((l=f*s)<u)){if(l>c)break;v.push(l)}}else for(;h<d;++h)for(s=a-1,f=r(h);s>=1;--s)if(!((l=f*s)<u)){if(l>c)break;v.push(l)}}else v=m(h,d,Math.min(d-h,p)).map(r);return n?v.reverse():v},i.tickFormat=function(n,o){if(null==o&&(o=10===a?".0e":","),"function"!=typeof o&&(o=t.format(o)),n===1/0)return o;null==n&&(n=10);var u=Math.max(1,a*n/i.ticks().length);return function(t){var n=t/r(Math.round(e(t)));return n*a<a-.5&&(n*=a),n<=u?o(t):""}},i.nice=function(){return o(jh(o(),{floor:function(t){return r(Math.floor(e(t)))},ceil:function(t){return r(Math.ceil(e(t)))}}))},i}function Kh(t){return function(n){return Math.sign(n)*Math.log1p(Math.abs(n/t))}}function Jh(t){return function(n){return Math.sign(n)*Math.expm1(Math.abs(n))*t}}function td(t){var n=1,e=t(Kh(n),Jh(n));return e.constant=function(e){return arguments.length?t(Kh(n=+e),Jh(n)):n},Hh(e)}function nd(t){return function(n){return n<0?-Math.pow(-n,t):Math.pow(n,t)}}function ed(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function rd(t){return t<0?-t*t:t*t}function id(t){var n=t(Dh,Dh),e=1;function r(){return 1===e?t(Dh,Dh):.5===e?t(ed,rd):t(nd(e),nd(1/e))}return n.exponent=function(t){return arguments.length?(e=+t,r()):e},Hh(n)}function od(){var t=id(Yh());return t.copy=function(){return Bh(t,od()).exponent(t.exponent())},Nh.apply(t,arguments),t}var ad=new Date,ud=new Date;function cd(t,n,e,r){function i(n){return t(n=new Date(+n)),n}return i.floor=i,i.ceil=function(e){return t(e=new Date(e-1)),n(e,1),t(e),e},i.round=function(t){var n=i(t),e=i.ceil(t);return t-n<e-t?n:e},i.offset=function(t,e){return n(t=new Date(+t),null==e?1:Math.floor(e)),t},i.range=function(e,r,o){var a,u=[];if(e=i.ceil(e),o=null==o?1:Math.floor(o),!(e<r&&o>0))return u;do{u.push(a=new Date(+e)),n(e,o),t(e)}while(a<e&&e<r);return u},i.filter=function(e){return cd(function(n){if(n>=n)for(;t(n),!e(n);)n.setTime(n-1)},function(t,r){if(t>=t)if(r<0)for(;++r<=0;)for(;n(t,-1),!e(t););else for(;--r>=0;)for(;n(t,1),!e(t););})},e&&(i.count=function(n,r){return ad.setTime(+n),ud.setTime(+r),t(ad),t(ud),Math.floor(e(ad,ud))},i.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?function(n){return r(n)%t==0}:function(n){return i.count(0,n)%t==0}):i:null}),i}var fd=cd(function(){},function(t,n){t.setTime(+t+n)},function(t,n){return n-t});fd.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?cd(function(n){n.setTime(Math.floor(n/t)*t)},function(n,e){n.setTime(+n+e*t)},function(n,e){return(e-n)/t}):fd:null};var sd=fd.range,ld=6e4,hd=6048e5,dd=cd(function(t){t.setTime(t-t.getMilliseconds())},function(t,n){t.setTime(+t+1e3*n)},function(t,n){return(n-t)/1e3},function(t){return t.getUTCSeconds()}),pd=dd.range,vd=cd(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds())},function(t,n){t.setTime(+t+n*ld)},function(t,n){return(n-t)/ld},function(t){return t.getMinutes()}),gd=vd.range,yd=cd(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()-t.getMinutes()*ld)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getHours()}),_d=yd.range,bd=cd(function(t){t.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*ld)/864e5},function(t){return t.getDate()-1}),md=bd.range;function xd(t){return cd(function(n){n.setDate(n.getDate()-(n.getDay()+7-t)%7),n.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+7*n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*ld)/hd})}var wd=xd(0),Md=xd(1),Nd=xd(2),Ad=xd(3),Td=xd(4),Sd=xd(5),kd=xd(6),Ed=wd.range,Cd=Md.range,Pd=Nd.range,zd=Ad.range,Rd=Td.range,Dd=Sd.range,qd=kd.range,Ld=cd(function(t){t.setDate(1),t.setHours(0,0,0,0)},function(t,n){t.setMonth(t.getMonth()+n)},function(t,n){return n.getMonth()-t.getMonth()+12*(n.getFullYear()-t.getFullYear())},function(t){return t.getMonth()}),Ud=Ld.range,Od=cd(function(t){t.setMonth(0,1),t.setHours(0,0,0,0)},function(t,n){t.setFullYear(t.getFullYear()+n)},function(t,n){return n.getFullYear()-t.getFullYear()},function(t){return t.getFullYear()});Od.every=function(t){return isFinite(t=Math.floor(t))&&t>0?cd(function(n){n.setFullYear(Math.floor(n.getFullYear()/t)*t),n.setMonth(0,1),n.setHours(0,0,0,0)},function(n,e){n.setFullYear(n.getFullYear()+e*t)}):null};var Bd=Od.range,Yd=cd(function(t){t.setUTCSeconds(0,0)},function(t,n){t.setTime(+t+n*ld)},function(t,n){return(n-t)/ld},function(t){return t.getUTCMinutes()}),Fd=Yd.range,Id=cd(function(t){t.setUTCMinutes(0,0,0)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getUTCHours()}),Hd=Id.range,jd=cd(function(t){t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+n)},function(t,n){return(n-t)/864e5},function(t){return t.getUTCDate()-1}),Xd=jd.range;function Gd(t){return cd(function(n){n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+7-t)%7),n.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+7*n)},function(t,n){return(n-t)/hd})}var Vd=Gd(0),$d=Gd(1),Wd=Gd(2),Zd=Gd(3),Qd=Gd(4),Kd=Gd(5),Jd=Gd(6),tp=Vd.range,np=$d.range,ep=Wd.range,rp=Zd.range,ip=Qd.range,op=Kd.range,ap=Jd.range,up=cd(function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCMonth(t.getUTCMonth()+n)},function(t,n){return n.getUTCMonth()-t.getUTCMonth()+12*(n.getUTCFullYear()-t.getUTCFullYear())},function(t){return t.getUTCMonth()}),cp=up.range,fp=cd(function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n)},function(t,n){return n.getUTCFullYear()-t.getUTCFullYear()},function(t){return t.getUTCFullYear()});fp.every=function(t){return isFinite(t=Math.floor(t))&&t>0?cd(function(n){n.setUTCFullYear(Math.floor(n.getUTCFullYear()/t)*t),n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},function(n,e){n.setUTCFullYear(n.getUTCFullYear()+e*t)}):null};var sp=fp.range;function lp(t){if(0<=t.y&&t.y<100){var n=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return n.setFullYear(t.y),n}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function hp(t){if(0<=t.y&&t.y<100){var n=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return n.setUTCFullYear(t.y),n}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function dp(t){return{y:t,m:0,d:1,H:0,M:0,S:0,L:0}}function pp(t){var n=t.dateTime,e=t.date,r=t.time,i=t.periods,o=t.days,a=t.shortDays,u=t.months,c=t.shortMonths,f=wp(i),s=Mp(i),l=wp(o),h=Mp(o),d=wp(a),p=Mp(a),v=wp(u),g=Mp(u),y=wp(c),_=Mp(c),b={a:function(t){return a[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return u[t.getMonth()]},c:null,d:Hp,e:Hp,f:$p,H:jp,I:Xp,j:Gp,L:Vp,m:Wp,M:Zp,p:function(t){return i[+(t.getHours()>=12)]},Q:Nv,s:Av,S:Qp,u:Kp,U:Jp,V:tv,w:nv,W:ev,x:null,X:null,y:rv,Y:iv,Z:ov,"%":Mv},m={a:function(t){return a[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return c[t.getUTCMonth()]},B:function(t){return u[t.getUTCMonth()]},c:null,d:av,e:av,f:lv,H:uv,I:cv,j:fv,L:sv,m:hv,M:dv,p:function(t){return i[+(t.getUTCHours()>=12)]},Q:Nv,s:Av,S:pv,u:vv,U:gv,V:yv,w:_v,W:bv,x:null,X:null,y:mv,Y:xv,Z:wv,"%":Mv},x={a:function(t,n,e){var r=d.exec(n.slice(e));return r?(t.w=p[r[0].toLowerCase()],e+r[0].length):-1},A:function(t,n,e){var r=l.exec(n.slice(e));return r?(t.w=h[r[0].toLowerCase()],e+r[0].length):-1},b:function(t,n,e){var r=y.exec(n.slice(e));return r?(t.m=_[r[0].toLowerCase()],e+r[0].length):-1},B:function(t,n,e){var r=v.exec(n.slice(e));return r?(t.m=g[r[0].toLowerCase()],e+r[0].length):-1},c:function(t,e,r){return N(t,n,e,r)},d:Rp,e:Rp,f:Bp,H:qp,I:qp,j:Dp,L:Op,m:zp,M:Lp,p:function(t,n,e){var r=f.exec(n.slice(e));return r?(t.p=s[r[0].toLowerCase()],e+r[0].length):-1},Q:Fp,s:Ip,S:Up,u:Ap,U:Tp,V:Sp,w:Np,W:kp,x:function(t,n,r){return N(t,e,n,r)},X:function(t,n,e){return N(t,r,n,e)},y:Cp,Y:Ep,Z:Pp,"%":Yp};function w(t,n){return function(e){var r,i,o,a=[],u=-1,c=0,f=t.length;for(e instanceof Date||(e=new Date(+e));++u<f;)37===t.charCodeAt(u)&&(a.push(t.slice(c,u)),null!=(i=gp[r=t.charAt(++u)])?r=t.charAt(++u):i="e"===r?" ":"0",(o=n[r])&&(r=o(e,i)),a.push(r),c=u+1);return a.push(t.slice(c,u)),a.join("")}}function M(t,n){return function(e){var r,i,o=dp(1900);if(N(o,t,e+="",0)!=e.length)return null;if("Q"in o)return new Date(o.Q);if("p"in o&&(o.H=o.H%12+12*o.p),"V"in o){if(o.V<1||o.V>53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=hp(dp(o.y))).getUTCDay(),r=i>4||0===i?$d.ceil(r):$d(r),r=jd.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=n(dp(o.y))).getDay(),r=i>4||0===i?Md.ceil(r):Md(r),r=bd.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?hp(dp(o.y)).getUTCDay():n(dp(o.y)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,hp(o)):n(o)}}function N(t,n,e,r){for(var i,o,a=0,u=n.length,c=e.length;a<u;){if(r>=c)return-1;if(37===(i=n.charCodeAt(a++))){if(i=n.charAt(a++),!(o=x[i in gp?n.charAt(a++):i])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}return b.x=w(e,b),b.X=w(r,b),b.c=w(n,b),m.x=w(e,m),m.X=w(r,m),m.c=w(n,m),{format:function(t){var n=w(t+="",b);return n.toString=function(){return t},n},parse:function(t){var n=M(t+="",lp);return n.toString=function(){return t},n},utcFormat:function(t){var n=w(t+="",m);return n.toString=function(){return t},n},utcParse:function(t){var n=M(t,hp);return n.toString=function(){return t},n}}}var vp,gp={"-":"",_:" ",0:"0"},yp=/^\s*\d+/,_p=/^%/,bp=/[\\^$*+?|[\]().{}]/g;function mp(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o<e?new Array(e-o+1).join(n)+i:i)}function xp(t){return t.replace(bp,"\\$&")}function wp(t){return new RegExp("^(?:"+t.map(xp).join("|")+")","i")}function Mp(t){for(var n={},e=-1,r=t.length;++e<r;)n[t[e].toLowerCase()]=e;return n}function Np(t,n,e){var r=yp.exec(n.slice(e,e+1));return r?(t.w=+r[0],e+r[0].length):-1}function Ap(t,n,e){var r=yp.exec(n.slice(e,e+1));return r?(t.u=+r[0],e+r[0].length):-1}function Tp(t,n,e){var r=yp.exec(n.slice(e,e+2));return r?(t.U=+r[0],e+r[0].length):-1}function Sp(t,n,e){var r=yp.exec(n.slice(e,e+2));return r?(t.V=+r[0],e+r[0].length):-1}function kp(t,n,e){var r=yp.exec(n.slice(e,e+2));return r?(t.W=+r[0],e+r[0].length):-1}function Ep(t,n,e){var r=yp.exec(n.slice(e,e+4));return r?(t.y=+r[0],e+r[0].length):-1}function Cp(t,n,e){var r=yp.exec(n.slice(e,e+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),e+r[0].length):-1}function Pp(t,n,e){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(n.slice(e,e+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),e+r[0].length):-1}function zp(t,n,e){var r=yp.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function Rp(t,n,e){var r=yp.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function Dp(t,n,e){var r=yp.exec(n.slice(e,e+3));return r?(t.m=0,t.d=+r[0],e+r[0].length):-1}function qp(t,n,e){var r=yp.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function Lp(t,n,e){var r=yp.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function Up(t,n,e){var r=yp.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function Op(t,n,e){var r=yp.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function Bp(t,n,e){var r=yp.exec(n.slice(e,e+6));return r?(t.L=Math.floor(r[0]/1e3),e+r[0].length):-1}function Yp(t,n,e){var r=_p.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function Fp(t,n,e){var r=yp.exec(n.slice(e));return r?(t.Q=+r[0],e+r[0].length):-1}function Ip(t,n,e){var r=yp.exec(n.slice(e));return r?(t.Q=1e3*+r[0],e+r[0].length):-1}function Hp(t,n){return mp(t.getDate(),n,2)}function jp(t,n){return mp(t.getHours(),n,2)}function Xp(t,n){return mp(t.getHours()%12||12,n,2)}function Gp(t,n){return mp(1+bd.count(Od(t),t),n,3)}function Vp(t,n){return mp(t.getMilliseconds(),n,3)}function $p(t,n){return Vp(t,n)+"000"}function Wp(t,n){return mp(t.getMonth()+1,n,2)}function Zp(t,n){return mp(t.getMinutes(),n,2)}function Qp(t,n){return mp(t.getSeconds(),n,2)}function Kp(t){var n=t.getDay();return 0===n?7:n}function Jp(t,n){return mp(wd.count(Od(t),t),n,2)}function tv(t,n){var e=t.getDay();return t=e>=4||0===e?Td(t):Td.ceil(t),mp(Td.count(Od(t),t)+(4===Od(t).getDay()),n,2)}function nv(t){return t.getDay()}function ev(t,n){return mp(Md.count(Od(t),t),n,2)}function rv(t,n){return mp(t.getFullYear()%100,n,2)}function iv(t,n){return mp(t.getFullYear()%1e4,n,4)}function ov(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+mp(n/60|0,"0",2)+mp(n%60,"0",2)}function av(t,n){return mp(t.getUTCDate(),n,2)}function uv(t,n){return mp(t.getUTCHours(),n,2)}function cv(t,n){return mp(t.getUTCHours()%12||12,n,2)}function fv(t,n){return mp(1+jd.count(fp(t),t),n,3)}function sv(t,n){return mp(t.getUTCMilliseconds(),n,3)}function lv(t,n){return sv(t,n)+"000"}function hv(t,n){return mp(t.getUTCMonth()+1,n,2)}function dv(t,n){return mp(t.getUTCMinutes(),n,2)}function pv(t,n){return mp(t.getUTCSeconds(),n,2)}function vv(t){var n=t.getUTCDay();return 0===n?7:n}function gv(t,n){return mp(Vd.count(fp(t),t),n,2)}function yv(t,n){var e=t.getUTCDay();return t=e>=4||0===e?Qd(t):Qd.ceil(t),mp(Qd.count(fp(t),t)+(4===fp(t).getUTCDay()),n,2)}function _v(t){return t.getUTCDay()}function bv(t,n){return mp($d.count(fp(t),t),n,2)}function mv(t,n){return mp(t.getUTCFullYear()%100,n,2)}function xv(t,n){return mp(t.getUTCFullYear()%1e4,n,4)}function wv(){return"+0000"}function Mv(){return"%"}function Nv(t){return+t}function Av(t){return Math.floor(+t/1e3)}function Tv(n){return vp=pp(n),t.timeFormat=vp.format,t.timeParse=vp.parse,t.utcFormat=vp.utcFormat,t.utcParse=vp.utcParse,vp}Tv({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var Sv=Date.prototype.toISOString?function(t){return t.toISOString()}:t.utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");var kv=+new Date("2000-01-01T00:00:00.000Z")?function(t){var n=new Date(t);return isNaN(n)?null:n}:t.utcParse("%Y-%m-%dT%H:%M:%S.%LZ"),Ev=1e3,Cv=60*Ev,Pv=60*Cv,zv=24*Pv,Rv=7*zv,Dv=30*zv,qv=365*zv;function Lv(t){return new Date(t)}function Uv(t){return t instanceof Date?+t:+new Date(+t)}function Ov(t,n,r,i,o,a,u,c,f){var s=Fh(Dh,Dh),l=s.invert,h=s.domain,d=f(".%L"),p=f(":%S"),v=f("%I:%M"),g=f("%I %p"),y=f("%a %d"),_=f("%b %d"),b=f("%B"),m=f("%Y"),x=[[u,1,Ev],[u,5,5*Ev],[u,15,15*Ev],[u,30,30*Ev],[a,1,Cv],[a,5,5*Cv],[a,15,15*Cv],[a,30,30*Cv],[o,1,Pv],[o,3,3*Pv],[o,6,6*Pv],[o,12,12*Pv],[i,1,zv],[i,2,2*zv],[r,1,Rv],[n,1,Dv],[n,3,3*Dv],[t,1,qv]];function M(e){return(u(e)<e?d:a(e)<e?p:o(e)<e?v:i(e)<e?g:n(e)<e?r(e)<e?y:_:t(e)<e?b:m)(e)}function N(n,r,i,o){if(null==n&&(n=10),"number"==typeof n){var a=Math.abs(i-r)/n,u=e(function(t){return t[2]}).right(x,a);u===x.length?(o=w(r/qv,i/qv,n),n=t):u?(o=(u=x[a/x[u-1][2]<x[u][2]/a?u-1:u])[1],n=u[0]):(o=Math.max(w(r,i,n),1),n=c)}return null==o?n:n.every(o)}return s.invert=function(t){return new Date(l(t))},s.domain=function(t){return arguments.length?h(Sh.call(t,Uv)):h().map(Lv)},s.ticks=function(t,n){var e,r=h(),i=r[0],o=r[r.length-1],a=o<i;return a&&(e=i,i=o,o=e),e=(e=N(t,i,o,n))?e.range(i,o+1):[],a?e.reverse():e},s.tickFormat=function(t,n){return null==n?M:f(n)},s.nice=function(t,n){var e=h();return(t=N(t,e[0],e[e.length-1],n))?h(jh(e,t)):s},s.copy=function(){return Bh(s,Ov(t,n,r,i,o,a,u,c,f))},s}function Bv(){var t,n,e,r,i,o=0,a=1,u=Dh,c=!1;function f(n){return isNaN(n=+n)?i:u(0===e?.5:(n=(r(n)-t)*e,c?Math.max(0,Math.min(1,n)):n))}return f.domain=function(i){return arguments.length?(t=r(o=+i[0]),n=r(a=+i[1]),e=t===n?0:1/(n-t),f):[o,a]},f.clamp=function(t){return arguments.length?(c=!!t,f):c},f.interpolator=function(t){return arguments.length?(u=t,f):u},f.unknown=function(t){return arguments.length?(i=t,f):i},function(i){return r=i,t=i(o),n=i(a),e=t===n?0:1/(n-t),f}}function Yv(t,n){return n.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function Fv(){var t=id(Bv());return t.copy=function(){return Yv(t,Fv()).exponent(t.exponent())},Ah.apply(t,arguments)}function Iv(){var t,n,e,r,i,o,a,u=0,c=.5,f=1,s=Dh,l=!1;function h(t){return isNaN(t=+t)?a:(t=.5+((t=+o(t))-n)*(t<n?r:i),s(l?Math.max(0,Math.min(1,t)):t))}return h.domain=function(a){return arguments.length?(t=o(u=+a[0]),n=o(c=+a[1]),e=o(f=+a[2]),r=t===n?0:.5/(n-t),i=n===e?0:.5/(e-n),h):[u,c,f]},h.clamp=function(t){return arguments.length?(l=!!t,h):l},h.interpolator=function(t){return arguments.length?(s=t,h):s},h.unknown=function(t){return arguments.length?(a=t,h):a},function(a){return o=a,t=a(u),n=a(c),e=a(f),r=t===n?0:.5/(n-t),i=n===e?0:.5/(e-n),h}}function Hv(){var t=id(Iv());return t.copy=function(){return Yv(t,Hv()).exponent(t.exponent())},Ah.apply(t,arguments)}function jv(t){for(var n=t.length/6|0,e=new Array(n),r=0;r<n;)e[r]="#"+t.slice(6*r,6*++r);return e}var Xv=jv("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),Gv=jv("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"),Vv=jv("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"),$v=jv("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),Wv=jv("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"),Zv=jv("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"),Qv=jv("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"),Kv=jv("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"),Jv=jv("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"),tg=jv("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");function ng(t){return ve(t[t.length-1])}var eg=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(jv),rg=ng(eg),ig=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(jv),og=ng(ig),ag=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(jv),ug=ng(ag),cg=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(jv),fg=ng(cg),sg=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(jv),lg=ng(sg),hg=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(jv),dg=ng(hg),pg=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(jv),vg=ng(pg),gg=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(jv),yg=ng(gg),_g=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(jv),bg=ng(_g),mg=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(jv),xg=ng(mg),wg=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(jv),Mg=ng(wg),Ng=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(jv),Ag=ng(Ng),Tg=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(jv),Sg=ng(Tg),kg=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(jv),Eg=ng(kg),Cg=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(jv),Pg=ng(Cg),zg=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(jv),Rg=ng(zg),Dg=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(jv),qg=ng(Dg),Lg=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(jv),Ug=ng(Lg),Og=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(jv),Bg=ng(Og),Yg=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(jv),Fg=ng(Yg),Ig=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(jv),Hg=ng(Ig),jg=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(jv),Xg=ng(jg),Gg=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(jv),Vg=ng(Gg),$g=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(jv),Wg=ng($g),Zg=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(jv),Qg=ng(Zg),Kg=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(jv),Jg=ng(Kg),ty=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(jv),ny=ng(ty);var ey=Ze(re(300,.5,0),re(-240,.5,1)),ry=Ze(re(-100,.75,.35),re(80,1.5,.8)),iy=Ze(re(260,.75,.35),re(80,1.5,.8)),oy=re();var ay=bn(),uy=Math.PI/3,cy=2*Math.PI/3;function fy(t){var n=t.length;return function(e){return t[Math.max(0,Math.min(n-1,Math.floor(e*n)))]}}var sy=fy(jv("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),ly=fy(jv("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),hy=fy(jv("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),dy=fy(jv("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function py(t){return function(){return t}}var vy=Math.abs,gy=Math.atan2,yy=Math.cos,_y=Math.max,by=Math.min,my=Math.sin,xy=Math.sqrt,wy=1e-12,My=Math.PI,Ny=My/2,Ay=2*My;function Ty(t){return t>=1?Ny:t<=-1?-Ny:Math.asin(t)}function Sy(t){return t.innerRadius}function ky(t){return t.outerRadius}function Ey(t){return t.startAngle}function Cy(t){return t.endAngle}function Py(t){return t&&t.padAngle}function zy(t,n,e,r,i,o,a){var u=t-e,c=n-r,f=(a?o:-o)/xy(u*u+c*c),s=f*c,l=-f*u,h=t+s,d=n+l,p=e+s,v=r+l,g=(h+p)/2,y=(d+v)/2,_=p-h,b=v-d,m=_*_+b*b,x=i-o,w=h*v-p*d,M=(b<0?-1:1)*xy(_y(0,x*x*m-w*w)),N=(w*b-_*M)/m,A=(-w*_-b*M)/m,T=(w*b+_*M)/m,S=(-w*_+b*M)/m,k=N-g,E=A-y,C=T-g,P=S-y;return k*k+E*E>C*C+P*P&&(N=T,A=S),{cx:N,cy:A,x01:-s,y01:-l,x11:N*(i/x-1),y11:A*(i/x-1)}}function Ry(t){this._context=t}function Dy(t){return new Ry(t)}function qy(t){return t[0]}function Ly(t){return t[1]}function Uy(){var t=qy,n=Ly,e=py(!0),r=null,i=Dy,o=null;function a(a){var u,c,f,s=a.length,l=!1;for(null==r&&(o=i(f=to())),u=0;u<=s;++u)!(u<s&&e(c=a[u],u,a))===l&&((l=!l)?o.lineStart():o.lineEnd()),l&&o.point(+t(c,u,a),+n(c,u,a));if(f)return o=null,f+""||null}return a.x=function(n){return arguments.length?(t="function"==typeof n?n:py(+n),a):t},a.y=function(t){return arguments.length?(n="function"==typeof t?t:py(+t),a):n},a.defined=function(t){return arguments.length?(e="function"==typeof t?t:py(!!t),a):e},a.curve=function(t){return arguments.length?(i=t,null!=r&&(o=i(r)),a):i},a.context=function(t){return arguments.length?(null==t?r=o=null:o=i(r=t),a):r},a}function Oy(){var t=qy,n=null,e=py(0),r=Ly,i=py(!0),o=null,a=Dy,u=null;function c(c){var f,s,l,h,d,p=c.length,v=!1,g=new Array(p),y=new Array(p);for(null==o&&(u=a(d=to())),f=0;f<=p;++f){if(!(f<p&&i(h=c[f],f,c))===v)if(v=!v)s=f,u.areaStart(),u.lineStart();else{for(u.lineEnd(),u.lineStart(),l=f-1;l>=s;--l)u.point(g[l],y[l]);u.lineEnd(),u.areaEnd()}v&&(g[f]=+t(h,f,c),y[f]=+e(h,f,c),u.point(n?+n(h,f,c):g[f],r?+r(h,f,c):y[f]))}if(d)return u=null,d+""||null}function f(){return Uy().defined(i).curve(a).context(o)}return c.x=function(e){return arguments.length?(t="function"==typeof e?e:py(+e),n=null,c):t},c.x0=function(n){return arguments.length?(t="function"==typeof n?n:py(+n),c):t},c.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:py(+t),c):n},c.y=function(t){return arguments.length?(e="function"==typeof t?t:py(+t),r=null,c):e},c.y0=function(t){return arguments.length?(e="function"==typeof t?t:py(+t),c):e},c.y1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:py(+t),c):r},c.lineX0=c.lineY0=function(){return f().x(t).y(e)},c.lineY1=function(){return f().x(t).y(r)},c.lineX1=function(){return f().x(n).y(e)},c.defined=function(t){return arguments.length?(i="function"==typeof t?t:py(!!t),c):i},c.curve=function(t){return arguments.length?(a=t,null!=o&&(u=a(o)),c):a},c.context=function(t){return arguments.length?(null==t?o=u=null:u=a(o=t),c):o},c}function By(t,n){return n<t?-1:n>t?1:n>=t?0:NaN}function Yy(t){return t}Ry.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._context.lineTo(t,n)}}};var Fy=Hy(Dy);function Iy(t){this._curve=t}function Hy(t){function n(n){return new Iy(t(n))}return n._curve=t,n}function jy(t){var n=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(t){return arguments.length?n(Hy(t)):n()._curve},t}function Xy(){return jy(Uy().curve(Fy))}function Gy(){var t=Oy().curve(Fy),n=t.curve,e=t.lineX0,r=t.lineX1,i=t.lineY0,o=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return jy(e())},delete t.lineX0,t.lineEndAngle=function(){return jy(r())},delete t.lineX1,t.lineInnerRadius=function(){return jy(i())},delete t.lineY0,t.lineOuterRadius=function(){return jy(o())},delete t.lineY1,t.curve=function(t){return arguments.length?n(Hy(t)):n()._curve},t}function Vy(t,n){return[(n=+n)*Math.cos(t-=Math.PI/2),n*Math.sin(t)]}Iy.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(t,n){this._curve.point(n*Math.sin(t),n*-Math.cos(t))}};var $y=Array.prototype.slice;function Wy(t){return t.source}function Zy(t){return t.target}function Qy(t){var n=Wy,e=Zy,r=qy,i=Ly,o=null;function a(){var a,u=$y.call(arguments),c=n.apply(this,u),f=e.apply(this,u);if(o||(o=a=to()),t(o,+r.apply(this,(u[0]=c,u)),+i.apply(this,u),+r.apply(this,(u[0]=f,u)),+i.apply(this,u)),a)return o=null,a+""||null}return a.source=function(t){return arguments.length?(n=t,a):n},a.target=function(t){return arguments.length?(e=t,a):e},a.x=function(t){return arguments.length?(r="function"==typeof t?t:py(+t),a):r},a.y=function(t){return arguments.length?(i="function"==typeof t?t:py(+t),a):i},a.context=function(t){return arguments.length?(o=null==t?null:t,a):o},a}function Ky(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n=(n+r)/2,e,n,i,r,i)}function Jy(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n,e=(e+i)/2,r,e,r,i)}function t_(t,n,e,r,i){var o=Vy(n,e),a=Vy(n,e=(e+i)/2),u=Vy(r,e),c=Vy(r,i);t.moveTo(o[0],o[1]),t.bezierCurveTo(a[0],a[1],u[0],u[1],c[0],c[1])}var n_={draw:function(t,n){var e=Math.sqrt(n/My);t.moveTo(e,0),t.arc(0,0,e,0,Ay)}},e_={draw:function(t,n){var e=Math.sqrt(n/5)/2;t.moveTo(-3*e,-e),t.lineTo(-e,-e),t.lineTo(-e,-3*e),t.lineTo(e,-3*e),t.lineTo(e,-e),t.lineTo(3*e,-e),t.lineTo(3*e,e),t.lineTo(e,e),t.lineTo(e,3*e),t.lineTo(-e,3*e),t.lineTo(-e,e),t.lineTo(-3*e,e),t.closePath()}},r_=Math.sqrt(1/3),i_=2*r_,o_={draw:function(t,n){var e=Math.sqrt(n/i_),r=e*r_;t.moveTo(0,-e),t.lineTo(r,0),t.lineTo(0,e),t.lineTo(-r,0),t.closePath()}},a_=Math.sin(My/10)/Math.sin(7*My/10),u_=Math.sin(Ay/10)*a_,c_=-Math.cos(Ay/10)*a_,f_={draw:function(t,n){var e=Math.sqrt(.8908130915292852*n),r=u_*e,i=c_*e;t.moveTo(0,-e),t.lineTo(r,i);for(var o=1;o<5;++o){var a=Ay*o/5,u=Math.cos(a),c=Math.sin(a);t.lineTo(c*e,-u*e),t.lineTo(u*r-c*i,c*r+u*i)}t.closePath()}},s_={draw:function(t,n){var e=Math.sqrt(n),r=-e/2;t.rect(r,r,e,e)}},l_=Math.sqrt(3),h_={draw:function(t,n){var e=-Math.sqrt(n/(3*l_));t.moveTo(0,2*e),t.lineTo(-l_*e,-e),t.lineTo(l_*e,-e),t.closePath()}},d_=Math.sqrt(3)/2,p_=1/Math.sqrt(12),v_=3*(p_/2+1),g_={draw:function(t,n){var e=Math.sqrt(n/v_),r=e/2,i=e*p_,o=r,a=e*p_+e,u=-o,c=a;t.moveTo(r,i),t.lineTo(o,a),t.lineTo(u,c),t.lineTo(-.5*r-d_*i,d_*r+-.5*i),t.lineTo(-.5*o-d_*a,d_*o+-.5*a),t.lineTo(-.5*u-d_*c,d_*u+-.5*c),t.lineTo(-.5*r+d_*i,-.5*i-d_*r),t.lineTo(-.5*o+d_*a,-.5*a-d_*o),t.lineTo(-.5*u+d_*c,-.5*c-d_*u),t.closePath()}},y_=[n_,e_,o_,s_,f_,h_,g_];function __(){}function b_(t,n,e){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+n)/6,(t._y0+4*t._y1+e)/6)}function m_(t){this._context=t}function x_(t){this._context=t}function w_(t){this._context=t}function M_(t,n){this._basis=new m_(t),this._beta=n}m_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:b_(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:b_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},x_.prototype={areaStart:__,areaEnd:__,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x2=t,this._y2=n;break;case 1:this._point=2,this._x3=t,this._y3=n;break;case 2:this._point=3,this._x4=t,this._y4=n,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+n)/6);break;default:b_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},w_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var e=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+n)/6;this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break;case 3:this._point=4;default:b_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},M_.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,n=this._y,e=t.length-1;if(e>0)for(var r,i=t[0],o=n[0],a=t[e]-i,u=n[e]-o,c=-1;++c<=e;)r=c/e,this._basis.point(this._beta*t[c]+(1-this._beta)*(i+r*a),this._beta*n[c]+(1-this._beta)*(o+r*u));this._x=this._y=null,this._basis.lineEnd()},point:function(t,n){this._x.push(+t),this._y.push(+n)}};var N_=function t(n){function e(t){return 1===n?new m_(t):new M_(t,n)}return e.beta=function(n){return t(+n)},e}(.85);function A_(t,n,e){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-n),t._y2+t._k*(t._y1-e),t._x2,t._y2)}function T_(t,n){this._context=t,this._k=(1-n)/6}T_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:A_(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2,this._x1=t,this._y1=n;break;case 2:this._point=3;default:A_(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var S_=function t(n){function e(t){return new T_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function k_(t,n){this._context=t,this._k=(1-n)/6}k_.prototype={areaStart:__,areaEnd:__,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:A_(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var E_=function t(n){function e(t){return new k_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function C_(t,n){this._context=t,this._k=(1-n)/6}C_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:A_(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var P_=function t(n){function e(t){return new C_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function z_(t,n,e){var r=t._x1,i=t._y1,o=t._x2,a=t._y2;if(t._l01_a>wy){var u=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,c=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*u-t._x0*t._l12_2a+t._x2*t._l01_2a)/c,i=(i*u-t._y0*t._l12_2a+t._y2*t._l01_2a)/c}if(t._l23_a>wy){var f=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,s=3*t._l23_a*(t._l23_a+t._l12_a);o=(o*f+t._x1*t._l23_2a-n*t._l12_2a)/s,a=(a*f+t._y1*t._l23_2a-e*t._l12_2a)/s}t._context.bezierCurveTo(r,i,o,a,t._x2,t._y2)}function R_(t,n){this._context=t,this._alpha=n}R_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3;default:z_(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var D_=function t(n){function e(t){return n?new R_(t,n):new T_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function q_(t,n){this._context=t,this._alpha=n}q_.prototype={areaStart:__,areaEnd:__,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:z_(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var L_=function t(n){function e(t){return n?new q_(t,n):new k_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function U_(t,n){this._context=t,this._alpha=n}U_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:z_(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var O_=function t(n){function e(t){return n?new U_(t,n):new C_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function B_(t){this._context=t}function Y_(t){return t<0?-1:1}function F_(t,n,e){var r=t._x1-t._x0,i=n-t._x1,o=(t._y1-t._y0)/(r||i<0&&-0),a=(e-t._y1)/(i||r<0&&-0),u=(o*i+a*r)/(r+i);return(Y_(o)+Y_(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(u))||0}function I_(t,n){var e=t._x1-t._x0;return e?(3*(t._y1-t._y0)/e-n)/2:n}function H_(t,n,e){var r=t._x0,i=t._y0,o=t._x1,a=t._y1,u=(o-r)/3;t._context.bezierCurveTo(r+u,i+u*n,o-u,a-u*e,o,a)}function j_(t){this._context=t}function X_(t){this._context=new G_(t)}function G_(t){this._context=t}function V_(t){this._context=t}function $_(t){var n,e,r=t.length-1,i=new Array(r),o=new Array(r),a=new Array(r);for(i[0]=0,o[0]=2,a[0]=t[0]+2*t[1],n=1;n<r-1;++n)i[n]=1,o[n]=4,a[n]=4*t[n]+2*t[n+1];for(i[r-1]=2,o[r-1]=7,a[r-1]=8*t[r-1]+t[r],n=1;n<r;++n)e=i[n]/o[n-1],o[n]-=e,a[n]-=e*a[n-1];for(i[r-1]=a[r-1]/o[r-1],n=r-2;n>=0;--n)i[n]=(a[n]-i[n+1])/o[n];for(o[r-1]=(t[r]+i[r-1])/2,n=0;n<r-1;++n)o[n]=2*t[n+1]-i[n+1];return[i,o]}function W_(t,n){this._context=t,this._t=n}function Z_(t,n){if((i=t.length)>1)for(var e,r,i,o=1,a=t[n[0]],u=a.length;o<i;++o)for(r=a,a=t[n[o]],e=0;e<u;++e)a[e][1]+=a[e][0]=isNaN(r[e][1])?r[e][0]:r[e][1]}function Q_(t){for(var n=t.length,e=new Array(n);--n>=0;)e[n]=n;return e}function K_(t,n){return t[n]}function J_(t){var n=t.map(tb);return Q_(t).sort(function(t,e){return n[t]-n[e]})}function tb(t){for(var n,e=-1,r=0,i=t.length,o=-1/0;++e<i;)(n=+t[e][1])>o&&(o=n,r=e);return r}function nb(t){var n=t.map(eb);return Q_(t).sort(function(t,e){return n[t]-n[e]})}function eb(t){for(var n,e=0,r=-1,i=t.length;++r<i;)(n=+t[r][1])&&(e+=n);return e}function rb(t){return function(){return t}}function ib(t){return t[0]}function ob(t){return t[1]}function ab(){this._=null}function ub(t){t.U=t.C=t.L=t.R=t.P=t.N=null}function cb(t,n){var e=n,r=n.R,i=e.U;i?i.L===e?i.L=r:i.R=r:t._=r,r.U=i,e.U=r,e.R=r.L,e.R&&(e.R.U=e),r.L=e}function fb(t,n){var e=n,r=n.L,i=e.U;i?i.L===e?i.L=r:i.R=r:t._=r,r.U=i,e.U=r,e.L=r.R,e.L&&(e.L.U=e),r.R=e}function sb(t){for(;t.L;)t=t.L;return t}function lb(t,n,e,r){var i=[null,null],o=qb.push(i)-1;return i.left=t,i.right=n,e&&db(i,t,n,e),r&&db(i,n,t,r),Rb[t.index].halfedges.push(o),Rb[n.index].halfedges.push(o),i}function hb(t,n,e){var r=[n,e];return r.left=t,r}function db(t,n,e,r){t[0]||t[1]?t.left===e?t[1]=r:t[0]=r:(t[0]=r,t.left=n,t.right=e)}function pb(t,n,e,r,i){var o,a=t[0],u=t[1],c=a[0],f=a[1],s=0,l=1,h=u[0]-c,d=u[1]-f;if(o=n-c,h||!(o>0)){if(o/=h,h<0){if(o<s)return;o<l&&(l=o)}else if(h>0){if(o>l)return;o>s&&(s=o)}if(o=r-c,h||!(o<0)){if(o/=h,h<0){if(o>l)return;o>s&&(s=o)}else if(h>0){if(o<s)return;o<l&&(l=o)}if(o=e-f,d||!(o>0)){if(o/=d,d<0){if(o<s)return;o<l&&(l=o)}else if(d>0){if(o>l)return;o>s&&(s=o)}if(o=i-f,d||!(o<0)){if(o/=d,d<0){if(o>l)return;o>s&&(s=o)}else if(d>0){if(o<s)return;o<l&&(l=o)}return!(s>0||l<1)||(s>0&&(t[0]=[c+s*h,f+s*d]),l<1&&(t[1]=[c+l*h,f+l*d]),!0)}}}}}function vb(t,n,e,r,i){var o=t[1];if(o)return!0;var a,u,c=t[0],f=t.left,s=t.right,l=f[0],h=f[1],d=s[0],p=s[1],v=(l+d)/2,g=(h+p)/2;if(p===h){if(v<n||v>=r)return;if(l>d){if(c){if(c[1]>=i)return}else c=[v,e];o=[v,i]}else{if(c){if(c[1]<e)return}else c=[v,i];o=[v,e]}}else if(u=g-(a=(l-d)/(p-h))*v,a<-1||a>1)if(l>d){if(c){if(c[1]>=i)return}else c=[(e-u)/a,e];o=[(i-u)/a,i]}else{if(c){if(c[1]<e)return}else c=[(i-u)/a,i];o=[(e-u)/a,e]}else if(h<p){if(c){if(c[0]>=r)return}else c=[n,a*n+u];o=[r,a*r+u]}else{if(c){if(c[0]<n)return}else c=[r,a*r+u];o=[n,a*n+u]}return t[0]=c,t[1]=o,!0}function gb(t,n){var e=t.site,r=n.left,i=n.right;return e===i&&(i=r,r=e),i?Math.atan2(i[1]-r[1],i[0]-r[0]):(e===r?(r=n[1],i=n[0]):(r=n[0],i=n[1]),Math.atan2(r[0]-i[0],i[1]-r[1]))}function yb(t,n){return n[+(n.left!==t.site)]}function _b(t,n){return n[+(n.left===t.site)]}B_.prototype={areaStart:__,areaEnd:__,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,n){t=+t,n=+n,this._point?this._context.lineTo(t,n):(this._point=1,this._context.moveTo(t,n))}},j_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:H_(this,this._t0,I_(this,this._t0))}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){var e=NaN;if(n=+n,(t=+t)!==this._x1||n!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3,H_(this,I_(this,e=F_(this,t,n)),e);break;default:H_(this,this._t0,e=F_(this,t,n))}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n,this._t0=e}}},(X_.prototype=Object.create(j_.prototype)).point=function(t,n){j_.prototype.point.call(this,n,t)},G_.prototype={moveTo:function(t,n){this._context.moveTo(n,t)},closePath:function(){this._context.closePath()},lineTo:function(t,n){this._context.lineTo(n,t)},bezierCurveTo:function(t,n,e,r,i,o){this._context.bezierCurveTo(n,t,r,e,o,i)}},V_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,n=this._y,e=t.length;if(e)if(this._line?this._context.lineTo(t[0],n[0]):this._context.moveTo(t[0],n[0]),2===e)this._context.lineTo(t[1],n[1]);else for(var r=$_(t),i=$_(n),o=0,a=1;a<e;++o,++a)this._context.bezierCurveTo(r[0][o],i[0][o],r[1][o],i[1][o],t[a],n[a]);(this._line||0!==this._line&&1===e)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,n){this._x.push(+t),this._y.push(+n)}},W_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,n),this._context.lineTo(t,n);else{var e=this._x*(1-this._t)+t*this._t;this._context.lineTo(e,this._y),this._context.lineTo(e,n)}}this._x=t,this._y=n}},ab.prototype={constructor:ab,insert:function(t,n){var e,r,i;if(t){if(n.P=t,n.N=t.N,t.N&&(t.N.P=n),t.N=n,t.R){for(t=t.R;t.L;)t=t.L;t.L=n}else t.R=n;e=t}else this._?(t=sb(this._),n.P=null,n.N=t,t.P=t.L=n,e=t):(n.P=n.N=null,this._=n,e=null);for(n.L=n.R=null,n.U=e,n.C=!0,t=n;e&&e.C;)e===(r=e.U).L?(i=r.R)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.R&&(cb(this,e),e=(t=e).U),e.C=!1,r.C=!0,fb(this,r)):(i=r.L)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.L&&(fb(this,e),e=(t=e).U),e.C=!1,r.C=!0,cb(this,r)),e=t.U;this._.C=!1},remove:function(t){t.N&&(t.N.P=t.P),t.P&&(t.P.N=t.N),t.N=t.P=null;var n,e,r,i=t.U,o=t.L,a=t.R;if(e=o?a?sb(a):o:a,i?i.L===t?i.L=e:i.R=e:this._=e,o&&a?(r=e.C,e.C=t.C,e.L=o,o.U=e,e!==a?(i=e.U,e.U=t.U,t=e.R,i.L=t,e.R=a,a.U=e):(e.U=i,i=e,t=e.R)):(r=t.C,t=e),t&&(t.U=i),!r)if(t&&t.C)t.C=!1;else{do{if(t===this._)break;if(t===i.L){if((n=i.R).C&&(n.C=!1,i.C=!0,cb(this,i),n=i.R),n.L&&n.L.C||n.R&&n.R.C){n.R&&n.R.C||(n.L.C=!1,n.C=!0,fb(this,n),n=i.R),n.C=i.C,i.C=n.R.C=!1,cb(this,i),t=this._;break}}else if((n=i.L).C&&(n.C=!1,i.C=!0,fb(this,i),n=i.L),n.L&&n.L.C||n.R&&n.R.C){n.L&&n.L.C||(n.R.C=!1,n.C=!0,cb(this,n),n=i.L),n.C=i.C,i.C=n.L.C=!1,fb(this,i),t=this._;break}n.C=!0,t=i,i=i.U}while(!t.C);t&&(t.C=!1)}}};var bb,mb=[];function xb(){ub(this),this.x=this.y=this.arc=this.site=this.cy=null}function wb(t){var n=t.P,e=t.N;if(n&&e){var r=n.site,i=t.site,o=e.site;if(r!==o){var a=i[0],u=i[1],c=r[0]-a,f=r[1]-u,s=o[0]-a,l=o[1]-u,h=2*(c*l-f*s);if(!(h>=-Ub)){var d=c*c+f*f,p=s*s+l*l,v=(l*d-f*p)/h,g=(c*p-s*d)/h,y=mb.pop()||new xb;y.arc=t,y.site=i,y.x=v+a,y.y=(y.cy=g+u)+Math.sqrt(v*v+g*g),t.circle=y;for(var _=null,b=Db._;b;)if(y.y<b.y||y.y===b.y&&y.x<=b.x){if(!b.L){_=b.P;break}b=b.L}else{if(!b.R){_=b;break}b=b.R}Db.insert(_,y),_||(bb=y)}}}}function Mb(t){var n=t.circle;n&&(n.P||(bb=n.N),Db.remove(n),mb.push(n),ub(n),t.circle=null)}var Nb=[];function Ab(){ub(this),this.edge=this.site=this.circle=null}function Tb(t){var n=Nb.pop()||new Ab;return n.site=t,n}function Sb(t){Mb(t),zb.remove(t),Nb.push(t),ub(t)}function kb(t){var n=t.circle,e=n.x,r=n.cy,i=[e,r],o=t.P,a=t.N,u=[t];Sb(t);for(var c=o;c.circle&&Math.abs(e-c.circle.x)<Lb&&Math.abs(r-c.circle.cy)<Lb;)o=c.P,u.unshift(c),Sb(c),c=o;u.unshift(c),Mb(c);for(var f=a;f.circle&&Math.abs(e-f.circle.x)<Lb&&Math.abs(r-f.circle.cy)<Lb;)a=f.N,u.push(f),Sb(f),f=a;u.push(f),Mb(f);var s,l=u.length;for(s=1;s<l;++s)f=u[s],c=u[s-1],db(f.edge,c.site,f.site,i);c=u[0],(f=u[l-1]).edge=lb(c.site,f.site,null,i),wb(c),wb(f)}function Eb(t){for(var n,e,r,i,o=t[0],a=t[1],u=zb._;u;)if((r=Cb(u,a)-o)>Lb)u=u.L;else{if(!((i=o-Pb(u,a))>Lb)){r>-Lb?(n=u.P,e=u):i>-Lb?(n=u,e=u.N):n=e=u;break}if(!u.R){n=u;break}u=u.R}!function(t){Rb[t.index]={site:t,halfedges:[]}}(t);var c=Tb(t);if(zb.insert(n,c),n||e){if(n===e)return Mb(n),e=Tb(n.site),zb.insert(c,e),c.edge=e.edge=lb(n.site,c.site),wb(n),void wb(e);if(e){Mb(n),Mb(e);var f=n.site,s=f[0],l=f[1],h=t[0]-s,d=t[1]-l,p=e.site,v=p[0]-s,g=p[1]-l,y=2*(h*g-d*v),_=h*h+d*d,b=v*v+g*g,m=[(g*_-d*b)/y+s,(h*b-v*_)/y+l];db(e.edge,f,p,m),c.edge=lb(f,t,null,m),e.edge=lb(t,p,null,m),wb(n),wb(e)}else c.edge=lb(n.site,c.site)}}function Cb(t,n){var e=t.site,r=e[0],i=e[1],o=i-n;if(!o)return r;var a=t.P;if(!a)return-1/0;var u=(e=a.site)[0],c=e[1],f=c-n;if(!f)return u;var s=u-r,l=1/o-1/f,h=s/f;return l?(-h+Math.sqrt(h*h-2*l*(s*s/(-2*f)-c+f/2+i-o/2)))/l+r:(r+u)/2}function Pb(t,n){var e=t.N;if(e)return Cb(e,n);var r=t.site;return r[1]===n?r[0]:1/0}var zb,Rb,Db,qb,Lb=1e-6,Ub=1e-12;function Ob(t,n,e){return(t[0]-e[0])*(n[1]-t[1])-(t[0]-n[0])*(e[1]-t[1])}function Bb(t,n){return n[1]-t[1]||n[0]-t[0]}function Yb(t,n){var e,r,i,o=t.sort(Bb).pop();for(qb=[],Rb=new Array(t.length),zb=new ab,Db=new ab;;)if(i=bb,o&&(!i||o[1]<i.y||o[1]===i.y&&o[0]<i.x))o[0]===e&&o[1]===r||(Eb(o),e=o[0],r=o[1]),o=t.pop();else{if(!i)break;kb(i.arc)}if(function(){for(var t,n,e,r,i=0,o=Rb.length;i<o;++i)if((t=Rb[i])&&(r=(n=t.halfedges).length)){var a=new Array(r),u=new Array(r);for(e=0;e<r;++e)a[e]=e,u[e]=gb(t,qb[n[e]]);for(a.sort(function(t,n){return u[n]-u[t]}),e=0;e<r;++e)u[e]=n[a[e]];for(e=0;e<r;++e)n[e]=u[e]}}(),n){var a=+n[0][0],u=+n[0][1],c=+n[1][0],f=+n[1][1];!function(t,n,e,r){for(var i,o=qb.length;o--;)vb(i=qb[o],t,n,e,r)&&pb(i,t,n,e,r)&&(Math.abs(i[0][0]-i[1][0])>Lb||Math.abs(i[0][1]-i[1][1])>Lb)||delete qb[o]}(a,u,c,f),function(t,n,e,r){var i,o,a,u,c,f,s,l,h,d,p,v,g=Rb.length,y=!0;for(i=0;i<g;++i)if(o=Rb[i]){for(a=o.site,u=(c=o.halfedges).length;u--;)qb[c[u]]||c.splice(u,1);for(u=0,f=c.length;u<f;)p=(d=_b(o,qb[c[u]]))[0],v=d[1],l=(s=yb(o,qb[c[++u%f]]))[0],h=s[1],(Math.abs(p-l)>Lb||Math.abs(v-h)>Lb)&&(c.splice(u,0,qb.push(hb(a,d,Math.abs(p-t)<Lb&&r-v>Lb?[t,Math.abs(l-t)<Lb?h:r]:Math.abs(v-r)<Lb&&e-p>Lb?[Math.abs(h-r)<Lb?l:e,r]:Math.abs(p-e)<Lb&&v-n>Lb?[e,Math.abs(l-e)<Lb?h:n]:Math.abs(v-n)<Lb&&p-t>Lb?[Math.abs(h-n)<Lb?l:t,n]:null))-1),++f);f&&(y=!1)}if(y){var _,b,m,x=1/0;for(i=0,y=null;i<g;++i)(o=Rb[i])&&(m=(_=(a=o.site)[0]-t)*_+(b=a[1]-n)*b)<x&&(x=m,y=o);if(y){var w=[t,n],M=[t,r],N=[e,r],A=[e,n];y.halfedges.push(qb.push(hb(a=y.site,w,M))-1,qb.push(hb(a,M,N))-1,qb.push(hb(a,N,A))-1,qb.push(hb(a,A,w))-1)}}for(i=0;i<g;++i)(o=Rb[i])&&(o.halfedges.length||delete Rb[i])}(a,u,c,f)}this.edges=qb,this.cells=Rb,zb=Db=qb=Rb=null}function Fb(t){return function(){return t}}function Ib(t,n,e){this.target=t,this.type=n,this.transform=e}function Hb(t,n,e){this.k=t,this.x=n,this.y=e}Yb.prototype={constructor:Yb,polygons:function(){var t=this.edges;return this.cells.map(function(n){var e=n.halfedges.map(function(e){return yb(n,t[e])});return e.data=n.site.data,e})},triangles:function(){var t=[],n=this.edges;return this.cells.forEach(function(e,r){if(o=(i=e.halfedges).length)for(var i,o,a,u=e.site,c=-1,f=n[i[o-1]],s=f.left===u?f.right:f.left;++c<o;)a=s,s=(f=n[i[c]]).left===u?f.right:f.left,a&&s&&r<a.index&&r<s.index&&Ob(u,a,s)<0&&t.push([u.data,a.data,s.data])}),t},links:function(){return this.edges.filter(function(t){return t.right}).map(function(t){return{source:t.left.data,target:t.right.data}})},find:function(t,n,e){for(var r,i,o=this,a=o._found||0,u=o.cells.length;!(i=o.cells[a]);)if(++a>=u)return null;var c=t-i.site[0],f=n-i.site[1],s=c*c+f*f;do{i=o.cells[r=a],a=null,i.halfedges.forEach(function(e){var r=o.edges[e],u=r.left;if(u!==i.site&&u||(u=r.right)){var c=t-u[0],f=n-u[1],l=c*c+f*f;l<s&&(s=l,a=u.index)}})}while(null!==a);return o._found=r,null==e||s<=e*e?i.site:null}},Hb.prototype={constructor:Hb,scale:function(t){return 1===t?this:new Hb(this.k*t,this.x,this.y)},translate:function(t,n){return 0===t&0===n?this:new Hb(this.k,this.x+this.k*t,this.y+this.k*n)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var jb=new Hb(1,0,0);function Xb(t){for(;!t.__zoom;)if(!(t=t.parentNode))return jb;return t.__zoom}function Gb(){t.event.stopImmediatePropagation()}function Vb(){t.event.preventDefault(),t.event.stopImmediatePropagation()}function $b(){return!t.event.ctrlKey&&!t.event.button}function Wb(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function Zb(){return this.__zoom||jb}function Qb(){return-t.event.deltaY*(1===t.event.deltaMode?.05:t.event.deltaMode?1:.002)}function Kb(){return navigator.maxTouchPoints||"ontouchstart"in this}function Jb(t,n,e){var r=t.invertX(n[0][0])-e[0][0],i=t.invertX(n[1][0])-e[1][0],o=t.invertY(n[0][1])-e[0][1],a=t.invertY(n[1][1])-e[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}Xb.prototype=Hb.prototype,t.FormatSpecifier=Ra,t.active=function(t,n){var e,r,i=t.__transition;if(i)for(r in n=null==n?null:n+"",i)if((e=i[r]).state>mr&&e.name===n)return new Lr([[t]],gi,n,+r);return null},t.arc=function(){var t=Sy,n=ky,e=py(0),r=null,i=Ey,o=Cy,a=Py,u=null;function c(){var c,f,s=+t.apply(this,arguments),l=+n.apply(this,arguments),h=i.apply(this,arguments)-Ny,d=o.apply(this,arguments)-Ny,p=vy(d-h),v=d>h;if(u||(u=c=to()),l<s&&(f=l,l=s,s=f),l>wy)if(p>Ay-wy)u.moveTo(l*yy(h),l*my(h)),u.arc(0,0,l,h,d,!v),s>wy&&(u.moveTo(s*yy(d),s*my(d)),u.arc(0,0,s,d,h,v));else{var g,y,_=h,b=d,m=h,x=d,w=p,M=p,N=a.apply(this,arguments)/2,A=N>wy&&(r?+r.apply(this,arguments):xy(s*s+l*l)),T=by(vy(l-s)/2,+e.apply(this,arguments)),S=T,k=T;if(A>wy){var E=Ty(A/s*my(N)),C=Ty(A/l*my(N));(w-=2*E)>wy?(m+=E*=v?1:-1,x-=E):(w=0,m=x=(h+d)/2),(M-=2*C)>wy?(_+=C*=v?1:-1,b-=C):(M=0,_=b=(h+d)/2)}var P=l*yy(_),z=l*my(_),R=s*yy(x),D=s*my(x);if(T>wy){var q,L=l*yy(b),U=l*my(b),O=s*yy(m),B=s*my(m);if(p<My&&(q=function(t,n,e,r,i,o,a,u){var c=e-t,f=r-n,s=a-i,l=u-o,h=l*c-s*f;if(!(h*h<wy))return[t+(h=(s*(n-o)-l*(t-i))/h)*c,n+h*f]}(P,z,O,B,L,U,R,D))){var Y=P-q[0],F=z-q[1],I=L-q[0],H=U-q[1],j=1/my(function(t){return t>1?0:t<-1?My:Math.acos(t)}((Y*I+F*H)/(xy(Y*Y+F*F)*xy(I*I+H*H)))/2),X=xy(q[0]*q[0]+q[1]*q[1]);S=by(T,(s-X)/(j-1)),k=by(T,(l-X)/(j+1))}}M>wy?k>wy?(g=zy(O,B,P,z,l,k,v),y=zy(L,U,R,D,l,k,v),u.moveTo(g.cx+g.x01,g.cy+g.y01),k<T?u.arc(g.cx,g.cy,k,gy(g.y01,g.x01),gy(y.y01,y.x01),!v):(u.arc(g.cx,g.cy,k,gy(g.y01,g.x01),gy(g.y11,g.x11),!v),u.arc(0,0,l,gy(g.cy+g.y11,g.cx+g.x11),gy(y.cy+y.y11,y.cx+y.x11),!v),u.arc(y.cx,y.cy,k,gy(y.y11,y.x11),gy(y.y01,y.x01),!v))):(u.moveTo(P,z),u.arc(0,0,l,_,b,!v)):u.moveTo(P,z),s>wy&&w>wy?S>wy?(g=zy(R,D,L,U,s,-S,v),y=zy(P,z,O,B,s,-S,v),u.lineTo(g.cx+g.x01,g.cy+g.y01),S<T?u.arc(g.cx,g.cy,S,gy(g.y01,g.x01),gy(y.y01,y.x01),!v):(u.arc(g.cx,g.cy,S,gy(g.y01,g.x01),gy(g.y11,g.x11),!v),u.arc(0,0,s,gy(g.cy+g.y11,g.cx+g.x11),gy(y.cy+y.y11,y.cx+y.x11),v),u.arc(y.cx,y.cy,S,gy(y.y11,y.x11),gy(y.y01,y.x01),!v))):u.arc(0,0,s,x,m,v):u.lineTo(R,D)}else u.moveTo(0,0);if(u.closePath(),c)return u=null,c+""||null}return c.centroid=function(){var e=(+t.apply(this,arguments)+ +n.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +o.apply(this,arguments))/2-My/2;return[yy(r)*e,my(r)*e]},c.innerRadius=function(n){return arguments.length?(t="function"==typeof n?n:py(+n),c):t},c.outerRadius=function(t){return arguments.length?(n="function"==typeof t?t:py(+t),c):n},c.cornerRadius=function(t){return arguments.length?(e="function"==typeof t?t:py(+t),c):e},c.padRadius=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:py(+t),c):r},c.startAngle=function(t){return arguments.length?(i="function"==typeof t?t:py(+t),c):i},c.endAngle=function(t){return arguments.length?(o="function"==typeof t?t:py(+t),c):o},c.padAngle=function(t){return arguments.length?(a="function"==typeof t?t:py(+t),c):a},c.context=function(t){return arguments.length?(u=null==t?null:t,c):u},c},t.area=Oy,t.areaRadial=Gy,t.ascending=n,t.autoType=function(t){for(var n in t){var e,r=t[n].trim();if(r)if("true"===r)r=!0;else if("false"===r)r=!1;else if("NaN"===r)r=NaN;else if(isNaN(e=+r)){if(!/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/.test(r))continue;r=new Date(r)}else r=e;else r=null;t[n]=r}return t},t.axisBottom=function(t){return Y(D,t)},t.axisLeft=function(t){return Y(q,t)},t.axisRight=function(t){return Y(R,t)},t.axisTop=function(t){return Y(z,t)},t.bisect=i,t.bisectLeft=o,t.bisectRight=i,t.bisector=e,t.blob=function(t,n){return fetch(t,n).then(Ko)},t.brush=function(){return Yi(Ei)},t.brushSelection=function(t){var n=t.__brush;return n?n.dim.output(n.selection):null},t.brushX=function(){return Yi(Si)},t.brushY=function(){return Yi(ki)},t.buffer=function(t,n){return fetch(t,n).then(Jo)},t.chord=function(){var t=0,n=null,e=null,r=null;function i(i){var o,a,u,c,f,s,l=i.length,h=[],d=g(l),p=[],v=[],y=v.groups=new Array(l),_=new Array(l*l);for(o=0,f=-1;++f<l;){for(a=0,s=-1;++s<l;)a+=i[f][s];h.push(a),p.push(g(l)),o+=a}for(n&&d.sort(function(t,e){return n(h[t],h[e])}),e&&p.forEach(function(t,n){t.sort(function(t,r){return e(i[n][t],i[n][r])})}),c=(o=Gi(0,Xi-t*l)/o)?t:Xi/l,a=0,f=-1;++f<l;){for(u=a,s=-1;++s<l;){var b=d[f],m=p[b][s],x=i[b][m],w=a,M=a+=x*o;_[m*l+b]={index:b,subindex:m,startAngle:w,endAngle:M,value:x}}y[b]={index:b,startAngle:u,endAngle:a,value:h[b]},a+=c}for(f=-1;++f<l;)for(s=f-1;++s<l;){var N=_[s*l+f],A=_[f*l+s];(N.value||A.value)&&v.push(N.value<A.value?{source:A,target:N}:{source:N,target:A})}return r?v.sort(r):v}return i.padAngle=function(n){return arguments.length?(t=Gi(0,n),i):t},i.sortGroups=function(t){return arguments.length?(n=t,i):n},i.sortSubgroups=function(t){return arguments.length?(e=t,i):e},i.sortChords=function(t){return arguments.length?(null==t?r=null:(r=Vi(t))._=t,i):r&&r._},i},t.clientPoint=Ot,t.cluster=function(){var t=bl,n=1,e=1,r=!1;function i(i){var o,a=0;i.eachAfter(function(n){var e=n.children;e?(n.x=function(t){return t.reduce(ml,0)/t.length}(e),n.y=function(t){return 1+t.reduce(xl,0)}(e)):(n.x=o?a+=t(n,o):0,n.y=0,o=n)});var u=function(t){for(var n;n=t.children;)t=n[0];return t}(i),c=function(t){for(var n;n=t.children;)t=n[n.length-1];return t}(i),f=u.x-t(u,c)/2,s=c.x+t(c,u)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*n,t.y=(i.y-t.y)*e}:function(t){t.x=(t.x-f)/(s-f)*n,t.y=(1-(i.y?t.y/i.y:1))*e})}return i.separation=function(n){return arguments.length?(t=n,i):t},i.size=function(t){return arguments.length?(r=!1,n=+t[0],e=+t[1],i):r?null:[n,e]},i.nodeSize=function(t){return arguments.length?(r=!0,n=+t[0],e=+t[1],i):r?[n,e]:null},i},t.color=vn,t.contourDensity=function(){var t=So,n=ko,e=Eo,r=960,i=500,o=20,a=2,u=3*o,c=r+2*u>>a,f=i+2*u>>a,s=_o(20);function l(r){var i=new Float32Array(c*f),l=new Float32Array(c*f);r.forEach(function(r,o,s){var l=+t(r,o,s)+u>>a,h=+n(r,o,s)+u>>a,d=+e(r,o,s);l>=0&&l<c&&h>=0&&h<f&&(i[l+h*c]+=d)}),Ao({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),To({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),Ao({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),To({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),Ao({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),To({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a);var d=s(i);if(!Array.isArray(d)){var p=A(i);d=w(0,p,d),(d=g(0,Math.floor(p/d)*d,d)).shift()}return No().thresholds(d).size([c,f])(i).map(h)}function h(t){return t.value*=Math.pow(2,-2*a),t.coordinates.forEach(d),t}function d(t){t.forEach(p)}function p(t){t.forEach(v)}function v(t){t[0]=t[0]*Math.pow(2,a)-u,t[1]=t[1]*Math.pow(2,a)-u}function y(){return c=r+2*(u=3*o)>>a,f=i+2*u>>a,l}return l.x=function(n){return arguments.length?(t="function"==typeof n?n:_o(+n),l):t},l.y=function(t){return arguments.length?(n="function"==typeof t?t:_o(+t),l):n},l.weight=function(t){return arguments.length?(e="function"==typeof t?t:_o(+t),l):e},l.size=function(t){if(!arguments.length)return[r,i];var n=Math.ceil(t[0]),e=Math.ceil(t[1]);if(!(n>=0||n>=0))throw new Error("invalid size");return r=n,i=e,y()},l.cellSize=function(t){if(!arguments.length)return 1<<a;if(!((t=+t)>=1))throw new Error("invalid cell size");return a=Math.floor(Math.log(t)/Math.LN2),y()},l.thresholds=function(t){return arguments.length?(s="function"==typeof t?t:Array.isArray(t)?_o(go.call(t)):_o(t),l):s},l.bandwidth=function(t){if(!arguments.length)return Math.sqrt(o*(o+1));if(!((t=+t)>=0))throw new Error("invalid bandwidth");return o=Math.round((Math.sqrt(4*t*t+1)-1)/2),y()},l},t.contours=No,t.create=function(t){return Rt(Z(t).call(document.documentElement))},t.creator=Z,t.cross=function(t,n,e){var r,i,o,u,c=t.length,f=n.length,s=new Array(c*f);for(null==e&&(e=a),r=o=0;r<c;++r)for(u=t[r],i=0;i<f;++i,++o)s[o]=e(u,n[i]);return s},t.csv=ra,t.csvFormat=Ho,t.csvFormatBody=jo,t.csvFormatRows=Xo,t.csvParse=Fo,t.csvParseRows=Io,t.cubehelix=re,t.curveBasis=function(t){return new m_(t)},t.curveBasisClosed=function(t){return new x_(t)},t.curveBasisOpen=function(t){return new w_(t)},t.curveBundle=N_,t.curveCardinal=S_,t.curveCardinalClosed=E_,t.curveCardinalOpen=P_,t.curveCatmullRom=D_,t.curveCatmullRomClosed=L_,t.curveCatmullRomOpen=O_,t.curveLinear=Dy,t.curveLinearClosed=function(t){return new B_(t)},t.curveMonotoneX=function(t){return new j_(t)},t.curveMonotoneY=function(t){return new X_(t)},t.curveNatural=function(t){return new V_(t)},t.curveStep=function(t){return new W_(t,.5)},t.curveStepAfter=function(t){return new W_(t,1)},t.curveStepBefore=function(t){return new W_(t,0)},t.customEvent=kt,t.descending=function(t,n){return n<t?-1:n>t?1:n>=t?0:NaN},t.deviation=f,t.dispatch=I,t.drag=function(){var n,e,r,i,o=Vt,a=$t,u=Wt,c=Zt,f={},s=I("start","drag","end"),l=0,h=0;function d(t){t.on("mousedown.drag",p).filter(c).on("touchstart.drag",y).on("touchmove.drag",_).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(){if(!i&&o.apply(this,arguments)){var u=m("mouse",a.apply(this,arguments),Bt,this,arguments);u&&(Rt(t.event.view).on("mousemove.drag",v,!0).on("mouseup.drag",g,!0),Ht(t.event.view),Ft(),r=!1,n=t.event.clientX,e=t.event.clientY,u("start"))}}function v(){if(It(),!r){var i=t.event.clientX-n,o=t.event.clientY-e;r=i*i+o*o>h}f.mouse("drag")}function g(){Rt(t.event.view).on("mousemove.drag mouseup.drag",null),jt(t.event.view,r),It(),f.mouse("end")}function y(){if(o.apply(this,arguments)){var n,e,r=t.event.changedTouches,i=a.apply(this,arguments),u=r.length;for(n=0;n<u;++n)(e=m(r[n].identifier,i,Yt,this,arguments))&&(Ft(),e("start"))}}function _(){var n,e,r=t.event.changedTouches,i=r.length;for(n=0;n<i;++n)(e=f[r[n].identifier])&&(It(),e("drag"))}function b(){var n,e,r=t.event.changedTouches,o=r.length;for(i&&clearTimeout(i),i=setTimeout(function(){i=null},500),n=0;n<o;++n)(e=f[r[n].identifier])&&(Ft(),e("end"))}function m(n,e,r,i,o){var a,c,h,p=r(e,n),v=s.copy();if(kt(new Gt(d,"beforestart",a,n,l,p[0],p[1],0,0,v),function(){return null!=(t.event.subject=a=u.apply(i,o))&&(c=a.x-p[0]||0,h=a.y-p[1]||0,!0)}))return function t(u){var s,g=p;switch(u){case"start":f[n]=t,s=l++;break;case"end":delete f[n],--l;case"drag":p=r(e,n),s=l}kt(new Gt(d,u,a,n,s,p[0]+c,p[1]+h,p[0]-g[0],p[1]-g[1],v),v.apply,v,[u,i,o])}}return d.filter=function(t){return arguments.length?(o="function"==typeof t?t:Xt(!!t),d):o},d.container=function(t){return arguments.length?(a="function"==typeof t?t:Xt(t),d):a},d.subject=function(t){return arguments.length?(u="function"==typeof t?t:Xt(t),d):u},d.touchable=function(t){return arguments.length?(c="function"==typeof t?t:Xt(!!t),d):c},d.on=function(){var t=s.on.apply(s,arguments);return t===s?d:t},d.clickDistance=function(t){return arguments.length?(h=(t=+t)*t,d):Math.sqrt(h)},d},t.dragDisable=Ht,t.dragEnable=jt,t.dsv=function(t,n,e,r){3===arguments.length&&"function"==typeof e&&(r=e,e=void 0);var i=Bo(t);return na(n,e).then(function(t){return i.parse(t,r)})},t.dsvFormat=Bo,t.easeBack=fi,t.easeBackIn=ui,t.easeBackInOut=fi,t.easeBackOut=ci,t.easeBounce=ai,t.easeBounceIn=function(t){return 1-ai(1-t)},t.easeBounceInOut=function(t){return((t*=2)<=1?1-ai(1-t):ai(t-1)+1)/2},t.easeBounceOut=ai,t.easeCircle=Wr,t.easeCircleIn=function(t){return 1-Math.sqrt(1-t*t)},t.easeCircleInOut=Wr,t.easeCircleOut=function(t){return Math.sqrt(1- --t*t)},t.easeCubic=Fr,t.easeCubicIn=function(t){return t*t*t},t.easeCubicInOut=Fr,t.easeCubicOut=function(t){return--t*t*t+1},t.easeElastic=hi,t.easeElasticIn=li,t.easeElasticInOut=di,t.easeElasticOut=hi,t.easeExp=$r,t.easeExpIn=function(t){return Math.pow(2,10*t-10)},t.easeExpInOut=$r,t.easeExpOut=function(t){return 1-Math.pow(2,-10*t)},t.easeLinear=function(t){return+t},t.easePoly=jr,t.easePolyIn=Ir,t.easePolyInOut=jr,t.easePolyOut=Hr,t.easeQuad=Yr,t.easeQuadIn=function(t){return t*t},t.easeQuadInOut=Yr,t.easeQuadOut=function(t){return t*(2-t)},t.easeSin=Vr,t.easeSinIn=function(t){return 1-Math.cos(t*Gr)},t.easeSinInOut=Vr,t.easeSinOut=function(t){return Math.sin(t*Gr)},t.entries=function(t){var n=[];for(var e in t)n.push({key:e,value:t[e]});return n},t.extent=s,t.forceCenter=function(t,n){var e;function r(){var r,i,o=e.length,a=0,u=0;for(r=0;r<o;++r)a+=(i=e[r]).x,u+=i.y;for(a=a/o-t,u=u/o-n,r=0;r<o;++r)(i=e[r]).x-=a,i.y-=u}return null==t&&(t=0),null==n&&(n=0),r.initialize=function(t){e=t},r.x=function(n){return arguments.length?(t=+n,r):t},r.y=function(t){return arguments.length?(n=+t,r):n},r},t.forceCollide=function(t){var n,e,r=1,i=1;function o(){for(var t,o,u,c,f,s,l,h=n.length,d=0;d<i;++d)for(o=ga(n,ma,xa).visitAfter(a),t=0;t<h;++t)u=n[t],s=e[u.index],l=s*s,c=u.x+u.vx,f=u.y+u.vy,o.visit(p);function p(t,n,e,i,o){var a=t.data,h=t.r,d=s+h;if(!a)return n>c+d||i<c-d||e>f+d||o<f-d;if(a.index>u.index){var p=c-a.x-a.vx,v=f-a.y-a.vy,g=p*p+v*v;g<d*d&&(0===p&&(g+=(p=la())*p),0===v&&(g+=(v=la())*v),g=(d-(g=Math.sqrt(g)))/g*r,u.vx+=(p*=g)*(d=(h*=h)/(l+h)),u.vy+=(v*=g)*d,a.vx-=p*(d=1-d),a.vy-=v*d)}}}function a(t){if(t.data)return t.r=e[t.data.index];for(var n=t.r=0;n<4;++n)t[n]&&t[n].r>t.r&&(t.r=t[n].r)}function u(){if(n){var r,i,o=n.length;for(e=new Array(o),r=0;r<o;++r)i=n[r],e[i.index]=+t(i,r,n)}}return"function"!=typeof t&&(t=sa(null==t?1:+t)),o.initialize=function(t){n=t,u()},o.iterations=function(t){return arguments.length?(i=+t,o):i},o.strength=function(t){return arguments.length?(r=+t,o):r},o.radius=function(n){return arguments.length?(t="function"==typeof n?n:sa(+n),u(),o):t},o},t.forceLink=function(t){var n,e,r,i,o,a=wa,u=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=sa(30),f=1;function s(r){for(var i=0,a=t.length;i<f;++i)for(var u,c,s,l,h,d,p,v=0;v<a;++v)c=(u=t[v]).source,l=(s=u.target).x+s.vx-c.x-c.vx||la(),h=s.y+s.vy-c.y-c.vy||la(),l*=d=((d=Math.sqrt(l*l+h*h))-e[v])/d*r*n[v],h*=d,s.vx-=l*(p=o[v]),s.vy-=h*p,c.vx+=l*(p=1-p),c.vy+=h*p}function l(){if(r){var u,c,f=r.length,s=t.length,l=uo(r,a);for(u=0,i=new Array(f);u<s;++u)(c=t[u]).index=u,"object"!=typeof c.source&&(c.source=Ma(l,c.source)),"object"!=typeof c.target&&(c.target=Ma(l,c.target)),i[c.source.index]=(i[c.source.index]||0)+1,i[c.target.index]=(i[c.target.index]||0)+1;for(u=0,o=new Array(s);u<s;++u)c=t[u],o[u]=i[c.source.index]/(i[c.source.index]+i[c.target.index]);n=new Array(s),h(),e=new Array(s),d()}}function h(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+u(t[e],e,t)}function d(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+c(t[n],n,t)}return null==t&&(t=[]),s.initialize=function(t){r=t,l()},s.links=function(n){return arguments.length?(t=n,l(),s):t},s.id=function(t){return arguments.length?(a=t,s):a},s.iterations=function(t){return arguments.length?(f=+t,s):f},s.strength=function(t){return arguments.length?(u="function"==typeof t?t:sa(+t),h(),s):u},s.distance=function(t){return arguments.length?(c="function"==typeof t?t:sa(+t),d(),s):c},s},t.forceManyBody=function(){var t,n,e,r,i=sa(-30),o=1,a=1/0,u=.81;function c(r){var i,o=t.length,a=ga(t,Na,Aa).visitAfter(s);for(e=r,i=0;i<o;++i)n=t[i],a.visit(l)}function f(){if(t){var n,e,o=t.length;for(r=new Array(o),n=0;n<o;++n)e=t[n],r[e.index]=+i(e,n,t)}}function s(t){var n,e,i,o,a,u=0,c=0;if(t.length){for(i=o=a=0;a<4;++a)(n=t[a])&&(e=Math.abs(n.value))&&(u+=n.value,c+=e,i+=e*n.x,o+=e*n.y);t.x=i/c,t.y=o/c}else{(n=t).x=n.data.x,n.y=n.data.y;do{u+=r[n.data.index]}while(n=n.next)}t.value=u}function l(t,i,c,f){if(!t.value)return!0;var s=t.x-n.x,l=t.y-n.y,h=f-i,d=s*s+l*l;if(h*h/u<d)return d<a&&(0===s&&(d+=(s=la())*s),0===l&&(d+=(l=la())*l),d<o&&(d=Math.sqrt(o*d)),n.vx+=s*t.value*e/d,n.vy+=l*t.value*e/d),!0;if(!(t.length||d>=a)){(t.data!==n||t.next)&&(0===s&&(d+=(s=la())*s),0===l&&(d+=(l=la())*l),d<o&&(d=Math.sqrt(o*d)));do{t.data!==n&&(h=r[t.data.index]*e/d,n.vx+=s*h,n.vy+=l*h)}while(t=t.next)}}return c.initialize=function(n){t=n,f()},c.strength=function(t){return arguments.length?(i="function"==typeof t?t:sa(+t),f(),c):i},c.distanceMin=function(t){return arguments.length?(o=t*t,c):Math.sqrt(o)},c.distanceMax=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.theta=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u)},c},t.forceRadial=function(t,n,e){var r,i,o,a=sa(.1);function u(t){for(var a=0,u=r.length;a<u;++a){var c=r[a],f=c.x-n||1e-6,s=c.y-e||1e-6,l=Math.sqrt(f*f+s*s),h=(o[a]-l)*i[a]*t/l;c.vx+=f*h,c.vy+=s*h}}function c(){if(r){var n,e=r.length;for(i=new Array(e),o=new Array(e),n=0;n<e;++n)o[n]=+t(r[n],n,r),i[n]=isNaN(o[n])?0:+a(r[n],n,r)}}return"function"!=typeof t&&(t=sa(+t)),null==n&&(n=0),null==e&&(e=0),u.initialize=function(t){r=t,c()},u.strength=function(t){return arguments.length?(a="function"==typeof t?t:sa(+t),c(),u):a},u.radius=function(n){return arguments.length?(t="function"==typeof n?n:sa(+n),c(),u):t},u.x=function(t){return arguments.length?(n=+t,u):n},u.y=function(t){return arguments.length?(e=+t,u):e},u},t.forceSimulation=function(t){var n,e=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,u=uo(),c=lr(s),f=I("tick","end");function s(){l(),f.call("tick",n),e<r&&(c.stop(),f.call("end",n))}function l(r){var c,f,s=t.length;void 0===r&&(r=1);for(var l=0;l<r;++l)for(e+=(o-e)*i,u.each(function(t){t(e)}),c=0;c<s;++c)null==(f=t[c]).fx?f.x+=f.vx*=a:(f.x=f.fx,f.vx=0),null==f.fy?f.y+=f.vy*=a:(f.y=f.fy,f.vy=0);return n}function h(){for(var n,e=0,r=t.length;e<r;++e){if((n=t[e]).index=e,null!=n.fx&&(n.x=n.fx),null!=n.fy&&(n.y=n.fy),isNaN(n.x)||isNaN(n.y)){var i=Ta*Math.sqrt(e),o=e*Sa;n.x=i*Math.cos(o),n.y=i*Math.sin(o)}(isNaN(n.vx)||isNaN(n.vy))&&(n.vx=n.vy=0)}}function d(n){return n.initialize&&n.initialize(t),n}return null==t&&(t=[]),h(),n={tick:l,restart:function(){return c.restart(s),n},stop:function(){return c.stop(),n},nodes:function(e){return arguments.length?(t=e,h(),u.each(d),n):t},alpha:function(t){return arguments.length?(e=+t,n):e},alphaMin:function(t){return arguments.length?(r=+t,n):r},alphaDecay:function(t){return arguments.length?(i=+t,n):+i},alphaTarget:function(t){return arguments.length?(o=+t,n):o},velocityDecay:function(t){return arguments.length?(a=1-t,n):1-a},force:function(t,e){return arguments.length>1?(null==e?u.remove(t):u.set(t,d(e)),n):u.get(t)},find:function(n,e,r){var i,o,a,u,c,f=0,s=t.length;for(null==r?r=1/0:r*=r,f=0;f<s;++f)(a=(i=n-(u=t[f]).x)*i+(o=e-u.y)*o)<r&&(c=u,r=a);return c},on:function(t,e){return arguments.length>1?(f.on(t,e),n):f.on(t)}}},t.forceX=function(t){var n,e,r,i=sa(.1);function o(t){for(var i,o=0,a=n.length;o<a;++o)(i=n[o]).vx+=(r[o]-i.x)*e[o]*t}function a(){if(n){var o,a=n.length;for(e=new Array(a),r=new Array(a),o=0;o<a;++o)e[o]=isNaN(r[o]=+t(n[o],o,n))?0:+i(n[o],o,n)}}return"function"!=typeof t&&(t=sa(null==t?0:+t)),o.initialize=function(t){n=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:sa(+t),a(),o):i},o.x=function(n){return arguments.length?(t="function"==typeof n?n:sa(+n),a(),o):t},o},t.forceY=function(t){var n,e,r,i=sa(.1);function o(t){for(var i,o=0,a=n.length;o<a;++o)(i=n[o]).vy+=(r[o]-i.y)*e[o]*t}function a(){if(n){var o,a=n.length;for(e=new Array(a),r=new Array(a),o=0;o<a;++o)e[o]=isNaN(r[o]=+t(n[o],o,n))?0:+i(n[o],o,n)}}return"function"!=typeof t&&(t=sa(null==t?0:+t)),o.initialize=function(t){n=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:sa(+t),a(),o):i},o.y=function(n){return arguments.length?(t="function"==typeof n?n:sa(+n),a(),o):t},o},t.formatDefaultLocale=Fa,t.formatLocale=Ya,t.formatSpecifier=za,t.geoAlbers=Zs,t.geoAlbersUsa=function(){var t,n,e,r,i,o,a=Zs(),u=Ws().rotate([154,0]).center([-2,58.5]).parallels([55,65]),c=Ws().rotate([157,0]).center([-3,19.9]).parallels([8,18]),f={point:function(t,n){o=[t,n]}};function s(t){var n=t[0],a=t[1];return o=null,e.point(n,a),o||(r.point(n,a),o)||(i.point(n,a),o)}function l(){return t=n=null,s}return s.invert=function(t){var n=a.scale(),e=a.translate(),r=(t[0]-e[0])/n,i=(t[1]-e[1])/n;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?u:i>=.166&&i<.234&&r>=-.214&&r<-.115?c:a).invert(t)},s.stream=function(e){return t&&n===e?t:(r=[a.stream(n=e),u.stream(e),c.stream(e)],i=r.length,t={point:function(t,n){for(var e=-1;++e<i;)r[e].point(t,n)},sphere:function(){for(var t=-1;++t<i;)r[t].sphere()},lineStart:function(){for(var t=-1;++t<i;)r[t].lineStart()},lineEnd:function(){for(var t=-1;++t<i;)r[t].lineEnd()},polygonStart:function(){for(var t=-1;++t<i;)r[t].polygonStart()},polygonEnd:function(){for(var t=-1;++t<i;)r[t].polygonEnd()}});var r,i},s.precision=function(t){return arguments.length?(a.precision(t),u.precision(t),c.precision(t),l()):a.precision()},s.scale=function(t){return arguments.length?(a.scale(t),u.scale(.35*t),c.scale(t),s.translate(a.translate())):a.scale()},s.translate=function(t){if(!arguments.length)return a.translate();var n=a.scale(),o=+t[0],s=+t[1];return e=a.translate(t).clipExtent([[o-.455*n,s-.238*n],[o+.455*n,s+.238*n]]).stream(f),r=u.translate([o-.307*n,s+.201*n]).clipExtent([[o-.425*n+Wa,s+.12*n+Wa],[o-.214*n-Wa,s+.234*n-Wa]]).stream(f),i=c.translate([o-.205*n,s+.212*n]).clipExtent([[o-.214*n+Wa,s+.166*n+Wa],[o-.115*n-Wa,s+.234*n-Wa]]).stream(f),l()},s.fitExtent=function(t,n){return Ls(s,t,n)},s.fitSize=function(t,n){return Us(s,t,n)},s.fitWidth=function(t,n){return Os(s,t,n)},s.fitHeight=function(t,n){return Bs(s,t,n)},s.scale(1070)},t.geoArea=function(t){return Pu.reset(),Nu(t,zu),2*Pu},t.geoAzimuthalEqualArea=function(){return Xs(Js).scale(124.75).clipAngle(179.999)},t.geoAzimuthalEqualAreaRaw=Js,t.geoAzimuthalEquidistant=function(){return Xs(tl).scale(79.4188).clipAngle(179.999)},t.geoAzimuthalEquidistantRaw=tl,t.geoBounds=function(t){var n,e,r,i,o,a,u;if(Vu=Gu=-(ju=Xu=1/0),Ku=[],Nu(t,yc),e=Ku.length){for(Ku.sort(Tc),n=1,o=[r=Ku[0]];n<e;++n)Sc(r,(i=Ku[n])[0])||Sc(r,i[1])?(Ac(r[0],i[1])>Ac(r[0],r[1])&&(r[1]=i[1]),Ac(i[0],r[1])>Ac(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(a=-1/0,n=0,r=o[e=o.length-1];n<=e;r=i,++n)i=o[n],(u=Ac(r[1],i[0]))>a&&(a=u,ju=i[0],Gu=r[1])}return Ku=Ju=null,ju===1/0||Xu===1/0?[[NaN,NaN],[NaN,NaN]]:[[ju,Xu],[Gu,Vu]]},t.geoCentroid=function(t){tc=nc=ec=rc=ic=oc=ac=uc=cc=fc=sc=0,Nu(t,kc);var n=cc,e=fc,r=sc,i=n*n+e*e+r*r;return i<Za&&(n=oc,e=ac,r=uc,nc<Wa&&(n=ec,e=rc,r=ic),(i=n*n+e*e+r*r)<Za)?[NaN,NaN]:[ou(e,n)*nu,gu(r/du(i))*nu]},t.geoCircle=function(){var t,n,e=Bc([0,0]),r=Bc(90),i=Bc(6),o={point:function(e,r){t.push(e=n(e,r)),e[0]*=nu,e[1]*=nu}};function a(){var a=e.apply(this,arguments),u=r.apply(this,arguments)*eu,c=i.apply(this,arguments)*eu;return t=[],n=Ic(-a[0]*eu,-a[1]*eu,0).invert,Vc(o,u,c,1),a={type:"Polygon",coordinates:[t]},t=n=null,a}return a.center=function(t){return arguments.length?(e="function"==typeof t?t:Bc([+t[0],+t[1]]),a):e},a.radius=function(t){return arguments.length?(r="function"==typeof t?t:Bc(+t),a):r},a.precision=function(t){return arguments.length?(i="function"==typeof t?t:Bc(+t),a):i},a},t.geoClipAntimeridian=uf,t.geoClipCircle=cf,t.geoClipExtent=function(){var t,n,e,r=0,i=0,o=960,a=500;return e={stream:function(e){return t&&n===e?t:t=lf(r,i,o,a)(n=e)},extent:function(u){return arguments.length?(r=+u[0][0],i=+u[0][1],o=+u[1][0],a=+u[1][1],t=n=null,e):[[r,i],[o,a]]}}},t.geoClipRectangle=lf,t.geoConicConformal=function(){return Vs(il).scale(109.5).parallels([30,30])},t.geoConicConformalRaw=il,t.geoConicEqualArea=Ws,t.geoConicEqualAreaRaw=$s,t.geoConicEquidistant=function(){return Vs(al).scale(131.154).center([0,13.9389])},t.geoConicEquidistantRaw=al,t.geoContains=function(t,n){return(t&&Nf.hasOwnProperty(t.type)?Nf[t.type]:Tf)(t,n)},t.geoDistance=Mf,t.geoEqualEarth=function(){return Xs(hl).scale(177.158)},t.geoEqualEarthRaw=hl,t.geoEquirectangular=function(){return Xs(ol).scale(152.63)},t.geoEquirectangularRaw=ol,t.geoGnomonic=function(){return Xs(dl).scale(144.049).clipAngle(60)},t.geoGnomonicRaw=dl,t.geoGraticule=Df,t.geoGraticule10=function(){return Df()()},t.geoIdentity=function(){var t,n,e,r,i,o,a=1,u=0,c=0,f=1,s=1,l=qf,h=null,d=qf;function p(){return r=i=null,o}return o={stream:function(t){return r&&i===t?r:r=l(d(i=t))},postclip:function(r){return arguments.length?(d=r,h=t=n=e=null,p()):d},clipExtent:function(r){return arguments.length?(d=null==r?(h=t=n=e=null,qf):lf(h=+r[0][0],t=+r[0][1],n=+r[1][0],e=+r[1][1]),p()):null==h?null:[[h,t],[n,e]]},scale:function(t){return arguments.length?(l=pl((a=+t)*f,a*s,u,c),p()):a},translate:function(t){return arguments.length?(l=pl(a*f,a*s,u=+t[0],c=+t[1]),p()):[u,c]},reflectX:function(t){return arguments.length?(l=pl(a*(f=t?-1:1),a*s,u,c),p()):f<0},reflectY:function(t){return arguments.length?(l=pl(a*f,a*(s=t?-1:1),u,c),p()):s<0},fitExtent:function(t,n){return Ls(o,t,n)},fitSize:function(t,n){return Us(o,t,n)},fitWidth:function(t,n){return Os(o,t,n)},fitHeight:function(t,n){return Bs(o,t,n)}}},t.geoInterpolate=function(t,n){var e=t[0]*eu,r=t[1]*eu,i=n[0]*eu,o=n[1]*eu,a=au(r),u=lu(r),c=au(o),f=lu(o),s=a*au(e),l=a*lu(e),h=c*au(i),d=c*lu(i),p=2*gu(du(yu(o-r)+a*c*yu(i-e))),v=lu(p),g=p?function(t){var n=lu(t*=p)/v,e=lu(p-t)/v,r=e*s+n*h,i=e*l+n*d,o=e*u+n*f;return[ou(i,r)*nu,ou(o,du(r*r+i*i))*nu]}:function(){return[e*nu,r*nu]};return g.distance=p,g},t.geoLength=mf,t.geoMercator=function(){return el(nl).scale(961/tu)},t.geoMercatorRaw=nl,t.geoNaturalEarth1=function(){return Xs(vl).scale(175.295)},t.geoNaturalEarth1Raw=vl,t.geoOrthographic=function(){return Xs(gl).scale(249.5).clipAngle(90+Wa)},t.geoOrthographicRaw=gl,t.geoPath=function(t,n){var e,r,i=4.5;function o(t){return t&&("function"==typeof i&&r.pointRadius(+i.apply(this,arguments)),Nu(t,e(r))),r.result()}return o.area=function(t){return Nu(t,e(If)),If.result()},o.measure=function(t){return Nu(t,e(ks)),ks.result()},o.bounds=function(t){return Nu(t,e(Qf)),Qf.result()},o.centroid=function(t){return Nu(t,e(ls)),ls.result()},o.projection=function(n){return arguments.length?(e=null==n?(t=null,qf):(t=n).stream,o):t},o.context=function(t){return arguments.length?(r=null==t?(n=null,new Ps):new xs(n=t),"function"!=typeof i&&r.pointRadius(i),o):n},o.pointRadius=function(t){return arguments.length?(i="function"==typeof t?t:(r.pointRadius(+t),+t),o):i},o.projection(t).context(n)},t.geoProjection=Xs,t.geoProjectionMutator=Gs,t.geoRotation=Gc,t.geoStereographic=function(){return Xs(yl).scale(250).clipAngle(142)},t.geoStereographicRaw=yl,t.geoStream=Nu,t.geoTransform=function(t){return{stream:Rs(t)}},t.geoTransverseMercator=function(){var t=el(_l),n=t.center,e=t.rotate;return t.center=function(t){return arguments.length?n([-t[1],t[0]]):[(t=n())[1],-t[0]]},t.rotate=function(t){return arguments.length?e([t[0],t[1],t.length>2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90]).scale(159.155)},t.geoTransverseMercatorRaw=_l,t.gray=function(t,n){return new Yn(t,0,0,null==n?1:n)},t.hcl=Gn,t.hierarchy=Ml,t.histogram=function(){var t=v,n=s,e=M;function r(r){var o,a,u=r.length,c=new Array(u);for(o=0;o<u;++o)c[o]=t(r[o],o,r);var f=n(c),s=f[0],l=f[1],h=e(c,s,l);Array.isArray(h)||(h=w(s,l,h),h=g(Math.ceil(s/h)*h,l,h));for(var d=h.length;h[0]<=s;)h.shift(),--d;for(;h[d-1]>l;)h.pop(),--d;var p,v=new Array(d+1);for(o=0;o<=d;++o)(p=v[o]=[]).x0=o>0?h[o-1]:s,p.x1=o<d?h[o]:l;for(o=0;o<u;++o)s<=(a=c[o])&&a<=l&&v[i(h,a,0,d)].push(r[o]);return v}return r.value=function(n){return arguments.length?(t="function"==typeof n?n:p(n),r):t},r.domain=function(t){return arguments.length?(n="function"==typeof t?t:p([t[0],t[1]]),r):n},r.thresholds=function(t){return arguments.length?(e="function"==typeof t?t:Array.isArray(t)?p(h.call(t)):p(t),r):e},r},t.hsl=Tn,t.html=ca,t.image=function(t,n){return new Promise(function(e,r){var i=new Image;for(var o in n)i[o]=n[o];i.onerror=r,i.onload=function(){e(i)},i.src=t})},t.interpolate=Ne,t.interpolateArray=ye,t.interpolateBasis=ae,t.interpolateBasisClosed=ue,t.interpolateBlues=Xg,t.interpolateBrBG=rg,t.interpolateBuGn=xg,t.interpolateBuPu=Mg,t.interpolateCividis=function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-t*(35.34-t*(2381.73-t*(6402.7-t*(7024.72-2710.57*t)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+t*(170.73+t*(52.82-t*(131.46-t*(176.58-67.37*t)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+t*(442.36-t*(2482.43-t*(6167.24-t*(6614.94-2475.67*t)))))))+")"},t.interpolateCool=iy,t.interpolateCubehelix=We,t.interpolateCubehelixDefault=ey,t.interpolateCubehelixLong=Ze,t.interpolateDate=_e,t.interpolateDiscrete=function(t){var n=t.length;return function(e){return t[Math.max(0,Math.min(n-1,Math.floor(e*n)))]}},t.interpolateGnBu=Ag,t.interpolateGreens=Vg,t.interpolateGreys=Wg,t.interpolateHcl=Ge,t.interpolateHclLong=Ve,t.interpolateHsl=He,t.interpolateHslLong=je,t.interpolateHue=function(t,n){var e=se(+t,+n);return function(t){var n=e(t);return n-360*Math.floor(n/360)}},t.interpolateInferno=hy,t.interpolateLab=function(t,n){var e=he((t=Bn(t)).l,(n=Bn(n)).l),r=he(t.a,n.a),i=he(t.b,n.b),o=he(t.opacity,n.opacity);return function(n){return t.l=e(n),t.a=r(n),t.b=i(n),t.opacity=o(n),t+""}},t.interpolateMagma=ly,t.interpolateNumber=be,t.interpolateObject=me,t.interpolateOrRd=Sg,t.interpolateOranges=ny,t.interpolatePRGn=og,t.interpolatePiYG=ug,t.interpolatePlasma=dy,t.interpolatePuBu=Pg,t.interpolatePuBuGn=Eg,t.interpolatePuOr=fg,t.interpolatePuRd=Rg,t.interpolatePurples=Qg,t.interpolateRainbow=function(t){(t<0||t>1)&&(t-=Math.floor(t));var n=Math.abs(t-.5);return oy.h=360*t-100,oy.s=1.5-1.5*n,oy.l=.8-.9*n,oy+""},t.interpolateRdBu=lg,t.interpolateRdGy=dg,t.interpolateRdPu=qg,t.interpolateRdYlBu=vg,t.interpolateRdYlGn=yg,t.interpolateReds=Jg,t.interpolateRgb=de,t.interpolateRgbBasis=ve,t.interpolateRgbBasisClosed=ge,t.interpolateRound=Ae,t.interpolateSinebow=function(t){var n;return t=(.5-t)*Math.PI,ay.r=255*(n=Math.sin(t))*n,ay.g=255*(n=Math.sin(t+uy))*n,ay.b=255*(n=Math.sin(t+cy))*n,ay+""},t.interpolateSpectral=bg,t.interpolateString=Me,t.interpolateTransformCss=De,t.interpolateTransformSvg=qe,t.interpolateTurbo=function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))))+")"},t.interpolateViridis=sy,t.interpolateWarm=ry,t.interpolateYlGn=Bg,t.interpolateYlGnBu=Ug,t.interpolateYlOrBr=Fg,t.interpolateYlOrRd=Hg,t.interpolateZoom=Fe,t.interrupt=Cr,t.interval=function(t,n,e){var r=new sr,i=n;return null==n?(r.restart(t,n,e),r):(n=+n,e=null==e?cr():+e,r.restart(function o(a){a+=i,r.restart(o,i+=n,e),t(a)},n,e),r)},t.isoFormat=Sv,t.isoParse=kv,t.json=function(t,n){return fetch(t,n).then(oa)},t.keys=function(t){var n=[];for(var e in t)n.push(e);return n},t.lab=Bn,t.lch=function(t,n,e,r){return 1===arguments.length?Xn(t):new Vn(e,n,t,null==r?1:r)},t.line=Uy,t.lineRadial=Xy,t.linkHorizontal=function(){return Qy(Ky)},t.linkRadial=function(){var t=Qy(t_);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t},t.linkVertical=function(){return Qy(Jy)},t.local=qt,t.map=uo,t.matcher=nt,t.max=A,t.mean=function(t,n){var e,r=t.length,i=r,o=-1,a=0;if(null==n)for(;++o<r;)isNaN(e=u(t[o]))?--i:a+=e;else for(;++o<r;)isNaN(e=u(n(t[o],o,t)))?--i:a+=e;if(i)return a/i},t.median=function(t,e){var r,i=t.length,o=-1,a=[];if(null==e)for(;++o<i;)isNaN(r=u(t[o]))||a.push(r);else for(;++o<i;)isNaN(r=u(e(t[o],o,t)))||a.push(r);return N(a.sort(n),.5)},t.merge=T,t.min=S,t.mouse=Bt,t.namespace=W,t.namespaces=$,t.nest=function(){var t,n,e,r=[],i=[];function o(e,i,a,u){if(i>=r.length)return null!=t&&e.sort(t),null!=n?n(e):e;for(var c,f,s,l=-1,h=e.length,d=r[i++],p=uo(),v=a();++l<h;)(s=p.get(c=d(f=e[l])+""))?s.push(f):p.set(c,[f]);return p.each(function(t,n){u(v,n,o(t,i,a,u))}),v}return e={object:function(t){return o(t,0,co,fo)},map:function(t){return o(t,0,so,lo)},entries:function(t){return function t(e,o){if(++o>r.length)return e;var a,u=i[o-1];return null!=n&&o>=r.length?a=e.entries():(a=[],e.each(function(n,e){a.push({key:e,values:t(n,o)})})),null!=u?a.sort(function(t,n){return u(t.key,n.key)}):a}(o(t,0,so,lo),0)},key:function(t){return r.push(t),e},sortKeys:function(t){return i[r.length-1]=t,e},sortValues:function(n){return t=n,e},rollup:function(t){return n=t,e}}},t.now=cr,t.pack=function(){var t=null,n=1,e=1,r=jl;function i(i){return i.x=n/2,i.y=e/2,t?i.eachBefore(Vl(t)).eachAfter($l(r,.5)).eachBefore(Wl(1)):i.eachBefore(Vl(Gl)).eachAfter($l(jl,1)).eachAfter($l(r,i.r/Math.min(n,e))).eachBefore(Wl(Math.min(n,e)/(2*i.r))),i}return i.radius=function(n){return arguments.length?(t=Il(n),i):t},i.size=function(t){return arguments.length?(n=+t[0],e=+t[1],i):[n,e]},i.padding=function(t){return arguments.length?(r="function"==typeof t?t:Xl(+t),i):r},i},t.packEnclose=El,t.packSiblings=function(t){return Fl(t),t},t.pairs=function(t,n){null==n&&(n=a);for(var e=0,r=t.length-1,i=t[0],o=new Array(r<0?0:r);e<r;)o[e]=n(i,i=t[++e]);return o},t.partition=function(){var t=1,n=1,e=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=e,i.x1=t,i.y1=n/o,i.eachBefore(function(t,n){return function(r){r.children&&Ql(r,r.x0,t*(r.depth+1)/n,r.x1,t*(r.depth+2)/n);var i=r.x0,o=r.y0,a=r.x1-e,u=r.y1-e;a<i&&(i=a=(i+a)/2),u<o&&(o=u=(o+u)/2),r.x0=i,r.y0=o,r.x1=a,r.y1=u}}(n,o)),r&&i.eachBefore(Zl),i}return i.round=function(t){return arguments.length?(r=!!t,i):r},i.size=function(e){return arguments.length?(t=+e[0],n=+e[1],i):[t,n]},i.padding=function(t){return arguments.length?(e=+t,i):e},i},t.path=to,t.permute=function(t,n){for(var e=n.length,r=new Array(e);e--;)r[e]=t[n[e]];return r},t.pie=function(){var t=Yy,n=By,e=null,r=py(0),i=py(Ay),o=py(0);function a(a){var u,c,f,s,l,h=a.length,d=0,p=new Array(h),v=new Array(h),g=+r.apply(this,arguments),y=Math.min(Ay,Math.max(-Ay,i.apply(this,arguments)-g)),_=Math.min(Math.abs(y)/h,o.apply(this,arguments)),b=_*(y<0?-1:1);for(u=0;u<h;++u)(l=v[p[u]=u]=+t(a[u],u,a))>0&&(d+=l);for(null!=n?p.sort(function(t,e){return n(v[t],v[e])}):null!=e&&p.sort(function(t,n){return e(a[t],a[n])}),u=0,f=d?(y-h*b)/d:0;u<h;++u,g=s)c=p[u],s=g+((l=v[c])>0?l*f:0)+b,v[c]={data:a[c],index:u,value:l,startAngle:g,endAngle:s,padAngle:_};return v}return a.value=function(n){return arguments.length?(t="function"==typeof n?n:py(+n),a):t},a.sortValues=function(t){return arguments.length?(n=t,e=null,a):n},a.sort=function(t){return arguments.length?(e=t,n=null,a):e},a.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:py(+t),a):r},a.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:py(+t),a):i},a.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:py(+t),a):o},a},t.piecewise=function(t,n){for(var e=0,r=n.length-1,i=n[0],o=new Array(r<0?0:r);e<r;)o[e]=t(i,i=n[++e]);return function(t){var n=Math.max(0,Math.min(r-1,Math.floor(t*=r)));return o[n](t-n)}},t.pointRadial=Vy,t.polygonArea=function(t){for(var n,e=-1,r=t.length,i=t[r-1],o=0;++e<r;)n=i,i=t[e],o+=n[1]*i[0]-n[0]*i[1];return o/2},t.polygonCentroid=function(t){for(var n,e,r=-1,i=t.length,o=0,a=0,u=t[i-1],c=0;++r<i;)n=u,u=t[r],c+=e=n[0]*u[1]-u[0]*n[1],o+=(n[0]+u[0])*e,a+=(n[1]+u[1])*e;return[o/(c*=3),a/c]},t.polygonContains=function(t,n){for(var e,r,i=t.length,o=t[i-1],a=n[0],u=n[1],c=o[0],f=o[1],s=!1,l=0;l<i;++l)e=(o=t[l])[0],(r=o[1])>u!=f>u&&a<(c-e)*(u-r)/(f-r)+e&&(s=!s),c=e,f=r;return s},t.polygonHull=function(t){if((e=t.length)<3)return null;var n,e,r=new Array(e),i=new Array(e);for(n=0;n<e;++n)r[n]=[+t[n][0],+t[n][1],n];for(r.sort(vh),n=0;n<e;++n)i[n]=[r[n][0],-r[n][1]];var o=gh(r),a=gh(i),u=a[0]===o[0],c=a[a.length-1]===o[o.length-1],f=[];for(n=o.length-1;n>=0;--n)f.push(t[r[o[n]][2]]);for(n=+u;n<a.length-c;++n)f.push(t[r[a[n]][2]]);return f},t.polygonLength=function(t){for(var n,e,r=-1,i=t.length,o=t[i-1],a=o[0],u=o[1],c=0;++r<i;)n=a,e=u,n-=a=(o=t[r])[0],e-=u=o[1],c+=Math.sqrt(n*n+e*e);return c},t.precisionFixed=Ia,t.precisionPrefix=Ha,t.precisionRound=ja,t.quadtree=ga,t.quantile=N,t.quantize=function(t,n){for(var e=new Array(n),r=0;r<n;++r)e[r]=t(r/(n-1));return e},t.radialArea=Gy,t.radialLine=Xy,t.randomBates=wh,t.randomExponential=Mh,t.randomIrwinHall=xh,t.randomLogNormal=mh,t.randomNormal=bh,t.randomUniform=_h,t.range=g,t.rgb=bn,t.ribbon=function(){var t=no,n=eo,e=ro,r=io,i=oo,o=null;function a(){var a,u=$i.call(arguments),c=t.apply(this,u),f=n.apply(this,u),s=+e.apply(this,(u[0]=c,u)),l=r.apply(this,u)-ji,h=i.apply(this,u)-ji,d=s*Fi(l),p=s*Ii(l),v=+e.apply(this,(u[0]=f,u)),g=r.apply(this,u)-ji,y=i.apply(this,u)-ji;if(o||(o=a=to()),o.moveTo(d,p),o.arc(0,0,s,l,h),l===g&&h===y||(o.quadraticCurveTo(0,0,v*Fi(g),v*Ii(g)),o.arc(0,0,v,g,y)),o.quadraticCurveTo(0,0,d,p),o.closePath(),a)return o=null,a+""||null}return a.radius=function(t){return arguments.length?(e="function"==typeof t?t:Wi(+t),a):e},a.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:Wi(+t),a):r},a.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:Wi(+t),a):i},a.source=function(n){return arguments.length?(t=n,a):t},a.target=function(t){return arguments.length?(n=t,a):n},a.context=function(t){return arguments.length?(o=null==t?null:t,a):o},a},t.scaleBand=Ph,t.scaleDiverging=function t(){var n=Hh(Iv()(Dh));return n.copy=function(){return Yv(n,t())},Ah.apply(n,arguments)},t.scaleDivergingLog=function t(){var n=Qh(Iv()).domain([.1,1,10]);return n.copy=function(){return Yv(n,t()).base(n.base())},Ah.apply(n,arguments)},t.scaleDivergingPow=Hv,t.scaleDivergingSqrt=function(){return Hv.apply(null,arguments).exponent(.5)},t.scaleDivergingSymlog=function t(){var n=td(Iv());return n.copy=function(){return Yv(n,t()).constant(n.constant())},Ah.apply(n,arguments)},t.scaleIdentity=function t(n){var e;function r(t){return isNaN(t=+t)?e:t}return r.invert=r,r.domain=r.range=function(t){return arguments.length?(n=Sh.call(t,zh),r):n.slice()},r.unknown=function(t){return arguments.length?(e=t,r):e},r.copy=function(){return t(n).unknown(e)},n=arguments.length?Sh.call(n,zh):[0,1],Hh(r)},t.scaleImplicit=Eh,t.scaleLinear=function t(){var n=Fh(Dh,Dh);return n.copy=function(){return Bh(n,t())},Nh.apply(n,arguments),Hh(n)},t.scaleLog=function t(){var n=Qh(Yh()).domain([1,10]);return n.copy=function(){return Bh(n,t()).base(n.base())},Nh.apply(n,arguments),n},t.scaleOrdinal=Ch,t.scalePoint=function(){return function t(n){var e=n.copy;return n.padding=n.paddingOuter,delete n.paddingInner,delete n.paddingOuter,n.copy=function(){return t(e())},n}(Ph.apply(null,arguments).paddingInner(1))},t.scalePow=od,t.scaleQuantile=function t(){var e,r=[],o=[],a=[];function u(){var t=0,n=Math.max(1,o.length);for(a=new Array(n-1);++t<n;)a[t-1]=N(r,t/n);return c}function c(t){return isNaN(t=+t)?e:o[i(a,t)]}return c.invertExtent=function(t){var n=o.indexOf(t);return n<0?[NaN,NaN]:[n>0?a[n-1]:r[0],n<a.length?a[n]:r[r.length-1]]},c.domain=function(t){if(!arguments.length)return r.slice();r=[];for(var e,i=0,o=t.length;i<o;++i)null==(e=t[i])||isNaN(e=+e)||r.push(e);return r.sort(n),u()},c.range=function(t){return arguments.length?(o=kh.call(t),u()):o.slice()},c.unknown=function(t){return arguments.length?(e=t,c):e},c.quantiles=function(){return a.slice()},c.copy=function(){return t().domain(r).range(o).unknown(e)},Nh.apply(c,arguments)},t.scaleQuantize=function t(){var n,e=0,r=1,o=1,a=[.5],u=[0,1];function c(t){return t<=t?u[i(a,t,0,o)]:n}function f(){var t=-1;for(a=new Array(o);++t<o;)a[t]=((t+1)*r-(t-o)*e)/(o+1);return c}return c.domain=function(t){return arguments.length?(e=+t[0],r=+t[1],f()):[e,r]},c.range=function(t){return arguments.length?(o=(u=kh.call(t)).length-1,f()):u.slice()},c.invertExtent=function(t){var n=u.indexOf(t);return n<0?[NaN,NaN]:n<1?[e,a[0]]:n>=o?[a[o-1],r]:[a[n-1],a[n]]},c.unknown=function(t){return arguments.length?(n=t,c):c},c.thresholds=function(){return a.slice()},c.copy=function(){return t().domain([e,r]).range(u).unknown(n)},Nh.apply(Hh(c),arguments)},t.scaleSequential=function t(){var n=Hh(Bv()(Dh));return n.copy=function(){return Yv(n,t())},Ah.apply(n,arguments)},t.scaleSequentialLog=function t(){var n=Qh(Bv()).domain([1,10]);return n.copy=function(){return Yv(n,t()).base(n.base())},Ah.apply(n,arguments)},t.scaleSequentialPow=Fv,t.scaleSequentialQuantile=function t(){var e=[],r=Dh;function o(t){if(!isNaN(t=+t))return r((i(e,t)-1)/(e.length-1))}return o.domain=function(t){if(!arguments.length)return e.slice();e=[];for(var r,i=0,a=t.length;i<a;++i)null==(r=t[i])||isNaN(r=+r)||e.push(r);return e.sort(n),o},o.interpolator=function(t){return arguments.length?(r=t,o):r},o.copy=function(){return t(r).domain(e)},Ah.apply(o,arguments)},t.scaleSequentialSqrt=function(){return Fv.apply(null,arguments).exponent(.5)},t.scaleSequentialSymlog=function t(){var n=td(Bv());return n.copy=function(){return Yv(n,t()).constant(n.constant())},Ah.apply(n,arguments)},t.scaleSqrt=function(){return od.apply(null,arguments).exponent(.5)},t.scaleSymlog=function t(){var n=td(Yh());return n.copy=function(){return Bh(n,t()).constant(n.constant())},Nh.apply(n,arguments)},t.scaleThreshold=function t(){var n,e=[.5],r=[0,1],o=1;function a(t){return t<=t?r[i(e,t,0,o)]:n}return a.domain=function(t){return arguments.length?(e=kh.call(t),o=Math.min(e.length,r.length-1),a):e.slice()},a.range=function(t){return arguments.length?(r=kh.call(t),o=Math.min(e.length,r.length-1),a):r.slice()},a.invertExtent=function(t){var n=r.indexOf(t);return[e[n-1],e[n]]},a.unknown=function(t){return arguments.length?(n=t,a):n},a.copy=function(){return t().domain(e).range(r).unknown(n)},Nh.apply(a,arguments)},t.scaleTime=function(){return Nh.apply(Ov(Od,Ld,wd,bd,yd,vd,dd,fd,t.timeFormat).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)},t.scaleUtc=function(){return Nh.apply(Ov(fp,up,Vd,jd,Id,Yd,dd,fd,t.utcFormat).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},t.scan=function(t,e){if(r=t.length){var r,i,o=0,a=0,u=t[a];for(null==e&&(e=n);++o<r;)(e(i=t[o],u)<0||0!==e(u,u))&&(u=i,a=o);return 0===e(u,u)?a:void 0}},t.schemeAccent=Gv,t.schemeBlues=jg,t.schemeBrBG=eg,t.schemeBuGn=mg,t.schemeBuPu=wg,t.schemeCategory10=Xv,t.schemeDark2=Vv,t.schemeGnBu=Ng,t.schemeGreens=Gg,t.schemeGreys=$g,t.schemeOrRd=Tg,t.schemeOranges=ty,t.schemePRGn=ig,t.schemePaired=$v,t.schemePastel1=Wv,t.schemePastel2=Zv,t.schemePiYG=ag,t.schemePuBu=Cg,t.schemePuBuGn=kg,t.schemePuOr=cg,t.schemePuRd=zg,t.schemePurples=Zg,t.schemeRdBu=sg,t.schemeRdGy=hg,t.schemeRdPu=Dg,t.schemeRdYlBu=pg,t.schemeRdYlGn=gg,t.schemeReds=Kg,t.schemeSet1=Qv,t.schemeSet2=Kv,t.schemeSet3=Jv,t.schemeSpectral=_g,t.schemeTableau10=tg,t.schemeYlGn=Og,t.schemeYlGnBu=Lg,t.schemeYlOrBr=Yg,t.schemeYlOrRd=Ig,t.select=Rt,t.selectAll=function(t){return"string"==typeof t?new Pt([document.querySelectorAll(t)],[document.documentElement]):new Pt([null==t?[]:t],Ct)},t.selection=zt,t.selector=K,t.selectorAll=tt,t.set=vo,t.shuffle=function(t,n,e){for(var r,i,o=(null==e?t.length:e)-(n=null==n?0:+n);o;)i=Math.random()*o--|0,r=t[o+n],t[o+n]=t[i+n],t[i+n]=r;return t},t.stack=function(){var t=py([]),n=Q_,e=Z_,r=K_;function i(i){var o,a,u=t.apply(this,arguments),c=i.length,f=u.length,s=new Array(f);for(o=0;o<f;++o){for(var l,h=u[o],d=s[o]=new Array(c),p=0;p<c;++p)d[p]=l=[0,+r(i[p],h,p,i)],l.data=i[p];d.key=h}for(o=0,a=n(s);o<f;++o)s[a[o]].index=o;return e(s,a),s}return i.keys=function(n){return arguments.length?(t="function"==typeof n?n:py($y.call(n)),i):t},i.value=function(t){return arguments.length?(r="function"==typeof t?t:py(+t),i):r},i.order=function(t){return arguments.length?(n=null==t?Q_:"function"==typeof t?t:py($y.call(t)),i):n},i.offset=function(t){return arguments.length?(e=null==t?Z_:t,i):e},i},t.stackOffsetDiverging=function(t,n){if((u=t.length)>0)for(var e,r,i,o,a,u,c=0,f=t[n[0]].length;c<f;++c)for(o=a=0,e=0;e<u;++e)(i=(r=t[n[e]][c])[1]-r[0])>=0?(r[0]=o,r[1]=o+=i):i<0?(r[1]=a,r[0]=a+=i):r[0]=o},t.stackOffsetExpand=function(t,n){if((r=t.length)>0){for(var e,r,i,o=0,a=t[0].length;o<a;++o){for(i=e=0;e<r;++e)i+=t[e][o][1]||0;if(i)for(e=0;e<r;++e)t[e][o][1]/=i}Z_(t,n)}},t.stackOffsetNone=Z_,t.stackOffsetSilhouette=function(t,n){if((e=t.length)>0){for(var e,r=0,i=t[n[0]],o=i.length;r<o;++r){for(var a=0,u=0;a<e;++a)u+=t[a][r][1]||0;i[r][1]+=i[r][0]=-u/2}Z_(t,n)}},t.stackOffsetWiggle=function(t,n){if((i=t.length)>0&&(r=(e=t[n[0]]).length)>0){for(var e,r,i,o=0,a=1;a<r;++a){for(var u=0,c=0,f=0;u<i;++u){for(var s=t[n[u]],l=s[a][1]||0,h=(l-(s[a-1][1]||0))/2,d=0;d<u;++d){var p=t[n[d]];h+=(p[a][1]||0)-(p[a-1][1]||0)}c+=l,f+=h*l}e[a-1][1]+=e[a-1][0]=o,c&&(o-=f/c)}e[a-1][1]+=e[a-1][0]=o,Z_(t,n)}},t.stackOrderAppearance=J_,t.stackOrderAscending=nb,t.stackOrderDescending=function(t){return nb(t).reverse()},t.stackOrderInsideOut=function(t){var n,e,r=t.length,i=t.map(eb),o=J_(t),a=0,u=0,c=[],f=[];for(n=0;n<r;++n)e=o[n],a<u?(a+=i[e],c.push(e)):(u+=i[e],f.push(e));return f.reverse().concat(c)},t.stackOrderNone=Q_,t.stackOrderReverse=function(t){return Q_(t).reverse()},t.stratify=function(){var t=nh,n=eh;function e(e){var r,i,o,a,u,c,f,s=e.length,l=new Array(s),h={};for(i=0;i<s;++i)r=e[i],u=l[i]=new Sl(r),null!=(c=t(r,i,e))&&(c+="")&&(h[f=Kl+(u.id=c)]=f in h?th:u);for(i=0;i<s;++i)if(u=l[i],null!=(c=n(e[i],i,e))&&(c+="")){if(!(a=h[Kl+c]))throw new Error("missing: "+c);if(a===th)throw new Error("ambiguous: "+c);a.children?a.children.push(u):a.children=[u],u.parent=a}else{if(o)throw new Error("multiple roots");o=u}if(!o)throw new Error("no root");if(o.parent=Jl,o.eachBefore(function(t){t.depth=t.parent.depth+1,--s}).eachBefore(Tl),o.parent=null,s>0)throw new Error("cycle");return o}return e.id=function(n){return arguments.length?(t=Hl(n),e):t},e.parentId=function(t){return arguments.length?(n=Hl(t),e):n},e},t.style=ft,t.sum=function(t,n){var e,r=t.length,i=-1,o=0;if(null==n)for(;++i<r;)(e=+t[i])&&(o+=e);else for(;++i<r;)(e=+n(t[i],i,t))&&(o+=e);return o},t.svg=fa,t.symbol=function(){var t=py(n_),n=py(64),e=null;function r(){var r;if(e||(e=r=to()),t.apply(this,arguments).draw(e,+n.apply(this,arguments)),r)return e=null,r+""||null}return r.type=function(n){return arguments.length?(t="function"==typeof n?n:py(n),r):t},r.size=function(t){return arguments.length?(n="function"==typeof t?t:py(+t),r):n},r.context=function(t){return arguments.length?(e=null==t?null:t,r):e},r},t.symbolCircle=n_,t.symbolCross=e_,t.symbolDiamond=o_,t.symbolSquare=s_,t.symbolStar=f_,t.symbolTriangle=h_,t.symbolWye=g_,t.symbols=y_,t.text=na,t.thresholdFreedmanDiaconis=function(t,e,r){return t=d.call(t,u).sort(n),Math.ceil((r-e)/(2*(N(t,.75)-N(t,.25))*Math.pow(t.length,-1/3)))},t.thresholdScott=function(t,n,e){return Math.ceil((e-n)/(3.5*f(t)*Math.pow(t.length,-1/3)))},t.thresholdSturges=M,t.tickFormat=Ih,t.tickIncrement=x,t.tickStep=w,t.ticks=m,t.timeDay=bd,t.timeDays=md,t.timeFormatDefaultLocale=Tv,t.timeFormatLocale=pp,t.timeFriday=Sd,t.timeFridays=Dd,t.timeHour=yd,t.timeHours=_d,t.timeInterval=cd,t.timeMillisecond=fd,t.timeMilliseconds=sd,t.timeMinute=vd,t.timeMinutes=gd,t.timeMonday=Md,t.timeMondays=Cd,t.timeMonth=Ld,t.timeMonths=Ud,t.timeSaturday=kd,t.timeSaturdays=qd,t.timeSecond=dd,t.timeSeconds=pd,t.timeSunday=wd,t.timeSundays=Ed,t.timeThursday=Td,t.timeThursdays=Rd,t.timeTuesday=Nd,t.timeTuesdays=Pd,t.timeWednesday=Ad,t.timeWednesdays=zd,t.timeWeek=wd,t.timeWeeks=Ed,t.timeYear=Od,t.timeYears=Bd,t.timeout=gr,t.timer=lr,t.timerFlush=hr,t.touch=Yt,t.touches=function(t,n){null==n&&(n=Ut().touches);for(var e=0,r=n?n.length:0,i=new Array(r);e<r;++e)i[e]=Ot(t,n[e]);return i},t.transition=Ur,t.transpose=k,t.tree=function(){var t=rh,n=1,e=1,r=null;function i(i){var c=function(t){for(var n,e,r,i,o,a=new ch(t,0),u=[a];n=u.pop();)if(r=n._.children)for(n.children=new Array(o=r.length),i=o-1;i>=0;--i)u.push(e=n.children[i]=new ch(r[i],i)),e.parent=n;return(a.parent=new ch(null,0)).children=[a],a}(i);if(c.eachAfter(o),c.parent.m=-c.z,c.eachBefore(a),r)i.eachBefore(u);else{var f=i,s=i,l=i;i.eachBefore(function(t){t.x<f.x&&(f=t),t.x>s.x&&(s=t),t.depth>l.depth&&(l=t)});var h=f===s?1:t(f,s)/2,d=h-f.x,p=n/(s.x+h+d),v=e/(l.depth||1);i.eachBefore(function(t){t.x=(t.x+d)*p,t.y=t.depth*v})}return i}function o(n){var e=n.children,r=n.parent.children,i=n.i?r[n.i-1]:null;if(e){!function(t){for(var n,e=0,r=0,i=t.children,o=i.length;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(n);var o=(e[0].z+e[e.length-1].z)/2;i?(n.z=i.z+t(n._,i._),n.m=n.z-o):n.z=o}else i&&(n.z=i.z+t(n._,i._));n.parent.A=function(n,e,r){if(e){for(var i,o=n,a=n,u=e,c=o.parent.children[0],f=o.m,s=a.m,l=u.m,h=c.m;u=oh(u),o=ih(o),u&&o;)c=ih(c),(a=oh(a)).a=n,(i=u.z+l-o.z-f+t(u._,o._))>0&&(ah(uh(u,n,r),n,i),f+=i,s+=i),l+=u.m,f+=o.m,h+=c.m,s+=a.m;u&&!oh(a)&&(a.t=u,a.m+=l-s),o&&!ih(c)&&(c.t=o,c.m+=f-h,r=n)}return r}(n,i,n.parent.A||r[0])}function a(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function u(t){t.x*=n,t.y=t.depth*e}return i.separation=function(n){return arguments.length?(t=n,i):t},i.size=function(t){return arguments.length?(r=!1,n=+t[0],e=+t[1],i):r?null:[n,e]},i.nodeSize=function(t){return arguments.length?(r=!0,n=+t[0],e=+t[1],i):r?[n,e]:null},i},t.treemap=function(){var t=hh,n=!1,e=1,r=1,i=[0],o=jl,a=jl,u=jl,c=jl,f=jl;function s(t){return t.x0=t.y0=0,t.x1=e,t.y1=r,t.eachBefore(l),i=[0],n&&t.eachBefore(Zl),t}function l(n){var e=i[n.depth],r=n.x0+e,s=n.y0+e,l=n.x1-e,h=n.y1-e;l<r&&(r=l=(r+l)/2),h<s&&(s=h=(s+h)/2),n.x0=r,n.y0=s,n.x1=l,n.y1=h,n.children&&(e=i[n.depth+1]=o(n)/2,r+=f(n)-e,s+=a(n)-e,(l-=u(n)-e)<r&&(r=l=(r+l)/2),(h-=c(n)-e)<s&&(s=h=(s+h)/2),t(n,r,s,l,h))}return s.round=function(t){return arguments.length?(n=!!t,s):n},s.size=function(t){return arguments.length?(e=+t[0],r=+t[1],s):[e,r]},s.tile=function(n){return arguments.length?(t=Hl(n),s):t},s.padding=function(t){return arguments.length?s.paddingInner(t).paddingOuter(t):s.paddingInner()},s.paddingInner=function(t){return arguments.length?(o="function"==typeof t?t:Xl(+t),s):o},s.paddingOuter=function(t){return arguments.length?s.paddingTop(t).paddingRight(t).paddingBottom(t).paddingLeft(t):s.paddingTop()},s.paddingTop=function(t){return arguments.length?(a="function"==typeof t?t:Xl(+t),s):a},s.paddingRight=function(t){return arguments.length?(u="function"==typeof t?t:Xl(+t),s):u},s.paddingBottom=function(t){return arguments.length?(c="function"==typeof t?t:Xl(+t),s):c},s.paddingLeft=function(t){return arguments.length?(f="function"==typeof t?t:Xl(+t),s):f},s},t.treemapBinary=function(t,n,e,r,i){var o,a,u=t.children,c=u.length,f=new Array(c+1);for(f[0]=a=o=0;o<c;++o)f[o+1]=a+=u[o].value;!function t(n,e,r,i,o,a,c){if(n>=e-1){var s=u[n];return s.x0=i,s.y0=o,s.x1=a,void(s.y1=c)}for(var l=f[n],h=r/2+l,d=n+1,p=e-1;d<p;){var v=d+p>>>1;f[v]<h?d=v+1:p=v}h-f[d-1]<f[d]-h&&n+1<d&&--d;var g=f[d]-l,y=r-g;if(a-i>c-o){var _=(i*y+a*g)/r;t(n,d,g,i,o,_,c),t(d,e,y,_,o,a,c)}else{var b=(o*y+c*g)/r;t(n,d,g,i,o,a,b),t(d,e,y,i,b,a,c)}}(0,c,t.value,n,e,r,i)},t.treemapDice=Ql,t.treemapResquarify=dh,t.treemapSlice=fh,t.treemapSliceDice=function(t,n,e,r,i){(1&t.depth?fh:Ql)(t,n,e,r,i)},t.treemapSquarify=hh,t.tsv=ia,t.tsvFormat=Wo,t.tsvFormatBody=Zo,t.tsvFormatRows=Qo,t.tsvParse=Vo,t.tsvParseRows=$o,t.utcDay=jd,t.utcDays=Xd,t.utcFriday=Kd,t.utcFridays=op,t.utcHour=Id,t.utcHours=Hd,t.utcMillisecond=fd,t.utcMilliseconds=sd,t.utcMinute=Yd,t.utcMinutes=Fd,t.utcMonday=$d,t.utcMondays=np,t.utcMonth=up,t.utcMonths=cp,t.utcSaturday=Jd,t.utcSaturdays=ap,t.utcSecond=dd,t.utcSeconds=pd,t.utcSunday=Vd,t.utcSundays=tp,t.utcThursday=Qd,t.utcThursdays=ip,t.utcTuesday=Wd,t.utcTuesdays=ep,t.utcWednesday=Zd,t.utcWednesdays=rp,t.utcWeek=Vd,t.utcWeeks=tp,t.utcYear=fp,t.utcYears=sp,t.values=function(t){var n=[];for(var e in t)n.push(t[e]);return n},t.variance=c,t.version="5.12.0",t.voronoi=function(){var t=ib,n=ob,e=null;function r(r){return new Yb(r.map(function(e,i){var o=[Math.round(t(e,i,r)/Lb)*Lb,Math.round(n(e,i,r)/Lb)*Lb];return o.index=i,o.data=e,o}),e)}return r.polygons=function(t){return r(t).polygons()},r.links=function(t){return r(t).links()},r.triangles=function(t){return r(t).triangles()},r.x=function(n){return arguments.length?(t="function"==typeof n?n:rb(+n),r):t},r.y=function(t){return arguments.length?(n="function"==typeof t?t:rb(+t),r):n},r.extent=function(t){return arguments.length?(e=null==t?null:[[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]],r):e&&[[e[0][0],e[0][1]],[e[1][0],e[1][1]]]},r.size=function(t){return arguments.length?(e=null==t?null:[[0,0],[+t[0],+t[1]]],r):e&&[e[1][0]-e[0][0],e[1][1]-e[0][1]]},r},t.window=ct,t.xml=ua,t.zip=function(){return k(arguments)},t.zoom=function(){var n,e,r=$b,i=Wb,o=Jb,a=Qb,u=Kb,c=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],s=250,l=Fe,h=I("start","zoom","end"),d=500,p=150,v=0;function g(t){t.property("__zoom",Zb).on("wheel.zoom",M).on("mousedown.zoom",N).on("dblclick.zoom",A).filter(u).on("touchstart.zoom",T).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(t,n){return(n=Math.max(c[0],Math.min(c[1],n)))===t.k?t:new Hb(n,t.x,t.y)}function _(t,n,e){var r=n[0]-e[0]*t.k,i=n[1]-e[1]*t.k;return r===t.x&&i===t.y?t:new Hb(t.k,r,i)}function b(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function m(t,n,e){t.on("start.zoom",function(){x(this,arguments).start()}).on("interrupt.zoom end.zoom",function(){x(this,arguments).end()}).tween("zoom",function(){var t=this,r=arguments,o=x(t,r),a=i.apply(t,r),u=null==e?b(a):"function"==typeof e?e.apply(t,r):e,c=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),f=t.__zoom,s="function"==typeof n?n.apply(t,r):n,h=l(f.invert(u).concat(c/f.k),s.invert(u).concat(c/s.k));return function(t){if(1===t)t=s;else{var n=h(t),e=c/n[2];t=new Hb(e,u[0]-n[0]*e,u[1]-n[1]*e)}o.zoom(null,t)}})}function x(t,n,e){return!e&&t.__zooming||new w(t,n)}function w(t,n){this.that=t,this.args=n,this.active=0,this.extent=i.apply(t,n),this.taps=0}function M(){if(r.apply(this,arguments)){var t=x(this,arguments),n=this.__zoom,e=Math.max(c[0],Math.min(c[1],n.k*Math.pow(2,a.apply(this,arguments)))),i=Bt(this);if(t.wheel)t.mouse[0][0]===i[0]&&t.mouse[0][1]===i[1]||(t.mouse[1]=n.invert(t.mouse[0]=i)),clearTimeout(t.wheel);else{if(n.k===e)return;t.mouse=[i,n.invert(i)],Cr(this),t.start()}Vb(),t.wheel=setTimeout(function(){t.wheel=null,t.end()},p),t.zoom("mouse",o(_(y(n,e),t.mouse[0],t.mouse[1]),t.extent,f))}}function N(){if(!e&&r.apply(this,arguments)){var n=x(this,arguments,!0),i=Rt(t.event.view).on("mousemove.zoom",function(){if(Vb(),!n.moved){var e=t.event.clientX-u,r=t.event.clientY-c;n.moved=e*e+r*r>v}n.zoom("mouse",o(_(n.that.__zoom,n.mouse[0]=Bt(n.that),n.mouse[1]),n.extent,f))},!0).on("mouseup.zoom",function(){i.on("mousemove.zoom mouseup.zoom",null),jt(t.event.view,n.moved),Vb(),n.end()},!0),a=Bt(this),u=t.event.clientX,c=t.event.clientY;Ht(t.event.view),Gb(),n.mouse=[a,this.__zoom.invert(a)],Cr(this),n.start()}}function A(){if(r.apply(this,arguments)){var n=this.__zoom,e=Bt(this),a=n.invert(e),u=n.k*(t.event.shiftKey?.5:2),c=o(_(y(n,u),e,a),i.apply(this,arguments),f);Vb(),s>0?Rt(this).transition().duration(s).call(m,c,e):Rt(this).call(g.transform,c)}}function T(){if(r.apply(this,arguments)){var e,i,o,a,u=t.event.touches,c=u.length,f=x(this,arguments,t.event.changedTouches.length===c);for(Gb(),i=0;i<c;++i)a=[a=Yt(this,u,(o=u[i]).identifier),this.__zoom.invert(a),o.identifier],f.touch0?f.touch1||f.touch0[2]===a[2]||(f.touch1=a,f.taps=0):(f.touch0=a,e=!0,f.taps=1+!!n);n&&(n=clearTimeout(n)),e&&(f.taps<2&&(n=setTimeout(function(){n=null},d)),Cr(this),f.start())}}function S(){if(this.__zooming){var e,r,i,a,u=x(this,arguments),c=t.event.changedTouches,s=c.length;for(Vb(),n&&(n=clearTimeout(n)),u.taps=0,e=0;e<s;++e)i=Yt(this,c,(r=c[e]).identifier),u.touch0&&u.touch0[2]===r.identifier?u.touch0[0]=i:u.touch1&&u.touch1[2]===r.identifier&&(u.touch1[0]=i);if(r=u.that.__zoom,u.touch1){var l=u.touch0[0],h=u.touch0[1],d=u.touch1[0],p=u.touch1[1],v=(v=d[0]-l[0])*v+(v=d[1]-l[1])*v,g=(g=p[0]-h[0])*g+(g=p[1]-h[1])*g;r=y(r,Math.sqrt(v/g)),i=[(l[0]+d[0])/2,(l[1]+d[1])/2],a=[(h[0]+p[0])/2,(h[1]+p[1])/2]}else{if(!u.touch0)return;i=u.touch0[0],a=u.touch0[1]}u.zoom("touch",o(_(r,i,a),u.extent,f))}}function k(){if(this.__zooming){var n,r,i=x(this,arguments),o=t.event.changedTouches,a=o.length;for(Gb(),e&&clearTimeout(e),e=setTimeout(function(){e=null},d),n=0;n<a;++n)r=o[n],i.touch0&&i.touch0[2]===r.identifier?delete i.touch0:i.touch1&&i.touch1[2]===r.identifier&&delete i.touch1;if(i.touch1&&!i.touch0&&(i.touch0=i.touch1,delete i.touch1),i.touch0)i.touch0[1]=this.__zoom.invert(i.touch0[0]);else if(i.end(),2===i.taps){var u=Rt(this).on("dblclick.zoom");u&&u.apply(this,arguments)}}}return g.transform=function(t,n,e){var r=t.selection?t.selection():t;r.property("__zoom",Zb),t!==r?m(t,n,e):r.interrupt().each(function(){x(this,arguments).start().zoom(null,"function"==typeof n?n.apply(this,arguments):n).end()})},g.scaleBy=function(t,n,e){g.scaleTo(t,function(){var t=this.__zoom.k,e="function"==typeof n?n.apply(this,arguments):n;return t*e},e)},g.scaleTo=function(t,n,e){g.transform(t,function(){var t=i.apply(this,arguments),r=this.__zoom,a=null==e?b(t):"function"==typeof e?e.apply(this,arguments):e,u=r.invert(a),c="function"==typeof n?n.apply(this,arguments):n;return o(_(y(r,c),a,u),t,f)},e)},g.translateBy=function(t,n,e){g.transform(t,function(){return o(this.__zoom.translate("function"==typeof n?n.apply(this,arguments):n,"function"==typeof e?e.apply(this,arguments):e),i.apply(this,arguments),f)})},g.translateTo=function(t,n,e,r){g.transform(t,function(){var t=i.apply(this,arguments),a=this.__zoom,u=null==r?b(t):"function"==typeof r?r.apply(this,arguments):r;return o(jb.translate(u[0],u[1]).scale(a.k).translate("function"==typeof n?-n.apply(this,arguments):-n,"function"==typeof e?-e.apply(this,arguments):-e),t,f)},r)},w.prototype={start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,n){return this.mouse&&"mouse"!==t&&(this.mouse[1]=n.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=n.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=n.invert(this.touch1[0])),this.that.__zoom=n,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){kt(new Ib(g,t,this.that.__zoom),h.apply,h,[t,this.that,this.args])}},g.wheelDelta=function(t){return arguments.length?(a="function"==typeof t?t:Fb(+t),g):a},g.filter=function(t){return arguments.length?(r="function"==typeof t?t:Fb(!!t),g):r},g.touchable=function(t){return arguments.length?(u="function"==typeof t?t:Fb(!!t),g):u},g.extent=function(t){return arguments.length?(i="function"==typeof t?t:Fb([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),g):i},g.scaleExtent=function(t){return arguments.length?(c[0]=+t[0],c[1]=+t[1],g):[c[0],c[1]]},g.translateExtent=function(t){return arguments.length?(f[0][0]=+t[0][0],f[1][0]=+t[1][0],f[0][1]=+t[0][1],f[1][1]=+t[1][1],g):[[f[0][0],f[0][1]],[f[1][0],f[1][1]]]},g.constrain=function(t){return arguments.length?(o=t,g):o},g.duration=function(t){return arguments.length?(s=+t,g):s},g.interpolate=function(t){return arguments.length?(l=t,g):l},g.on=function(){var t=h.on.apply(h,arguments);return t===h?g:t},g.clickDistance=function(t){return arguments.length?(v=(t=+t)*t,g):Math.sqrt(v)},g},t.zoomIdentity=jb,t.zoomTransform=Xb,Object.defineProperty(t,"__esModule",{value:!0})}); diff --git a/ldb/expr.js b/ldb/expr.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d4247089befd2cbbf9f1f07e6c0afc60629e51 --- /dev/null +++ b/ldb/expr.js @@ -0,0 +1,816 @@ +// https://github.com/soney/jsep/blob/master/test/tests.js +// JavaScript Expression Parser (JSEP) <%= version %> +// JSEP may be freely distributed under the MIT License +// http://jsep.from.so/ + +/*global module: true, exports: true, console: true */ +(function (root) { + 'use strict'; + // Node Types + // ---------- + + // This is the full set of types that any JSEP node can be. + // Store them here to save space when minified + var COMPOUND = 'Compound', + IDENTIFIER = 'Identifier', + MEMBER_EXP = 'MemberExpression', + LITERAL = 'Literal', + THIS_EXP = 'ThisExpression', + CALL_EXP = 'CallExpression', + UNARY_EXP = 'UnaryExpression', + BINARY_EXP = 'BinaryExpression', + LOGICAL_EXP = 'LogicalExpression', + CONDITIONAL_EXP = 'ConditionalExpression', + ARRAY_EXP = 'ArrayExpression', + + PERIOD_CODE = 46, // '.' + COMMA_CODE = 44, // ',' + SQUOTE_CODE = 39, // single quote + DQUOTE_CODE = 34, // double quotes + OPAREN_CODE = 40, // ( + CPAREN_CODE = 41, // ) + OBRACK_CODE = 91, // [ + CBRACK_CODE = 93, // ] + QUMARK_CODE = 63, // ? + SEMCOL_CODE = 59, // ; + COLON_CODE = 58, // : + + throwError = function(message, index) { + var error = new Error(message + ' at character ' + index); + error.index = index; + error.description = message; + throw error; + }, + + // Operations + // ---------- + + // Set `t` to `true` to save space (when minified, not gzipped) + t = true, + // Use a quickly-accessible map to store all of the unary operators + // Values are set to `true` (it really doesn't matter) + unary_ops = {'-': t, '!': t, '~': t, '+': t}, + // Also use a map for the binary operations but set their values to their + // binary precedence for quick reference: + // see [Order of operations](http://en.wikipedia.org/wiki/Order_of_operations#Programming_language) + binary_ops = { + '||': 1, '&&': 2, '|': 3, '^': 4, '&': 5, + '==': 6, '!=': 6, '===': 6, '!==': 6, + '<': 7, '>': 7, '<=': 7, '>=': 7, + '<<':8, '>>': 8, '>>>': 8, + '+': 9, '-': 9, + '*': 10, '/': 10, '%': 10 + }, + // Get return the longest key length of any object + getMaxKeyLen = function(obj) { + var max_len = 0, len; + for(var key in obj) { + if((len = key.length) > max_len && obj.hasOwnProperty(key)) { + max_len = len; + } + } + return max_len; + }, + max_unop_len = getMaxKeyLen(unary_ops), + max_binop_len = getMaxKeyLen(binary_ops), + // Literals + // ---------- + // Store the values to return for the various literals we may encounter + literals = { + 'true': true, + 'false': false, + 'null': null + }, + // Except for `this`, which is special. This could be changed to something like `'self'` as well + this_str = 'this', + // Returns the precedence of a binary operator or `0` if it isn't a binary operator + binaryPrecedence = function(op_val) { + return binary_ops[op_val] || 0; + }, + // Utility function (gets called from multiple places) + // Also note that `a && b` and `a || b` are *logical* expressions, not binary expressions + createBinaryExpression = function (operator, left, right) { + var type = (operator === '||' || operator === '&&') ? LOGICAL_EXP : BINARY_EXP; + return { + type: type, + operator: operator, + left: left, + right: right + }; + }, + // `ch` is a character code in the next three functions + isDecimalDigit = function(ch) { + return (ch >= 48 && ch <= 57); // 0...9 + }, + isIdentifierStart = function(ch) { + return (ch === 36) || (ch === 95) || // `$` and `_` + (ch >= 65 && ch <= 90) || // A...Z + (ch >= 97 && ch <= 122) || // a...z + (ch >= 128 && !binary_ops[String.fromCharCode(ch)]); // any non-ASCII that is not an operator + }, + isIdentifierPart = function(ch) { + return (ch === 36) || (ch === 95) || // `$` and `_` + (ch >= 65 && ch <= 90) || // A...Z + (ch >= 97 && ch <= 122) || // a...z + (ch >= 48 && ch <= 57) || // 0...9 + (ch >= 128 && !binary_ops[String.fromCharCode(ch)]); // any non-ASCII that is not an operator + }, + + // Parsing + // ------- + // `expr` is a string with the passed in expression + jsep = function(expr) { + // `index` stores the character number we are currently at while `length` is a constant + // All of the gobbles below will modify `index` as we move along + var index = 0, + charAtFunc = expr.charAt, + charCodeAtFunc = expr.charCodeAt, + exprI = function(i) { return charAtFunc.call(expr, i); }, + exprICode = function(i) { return charCodeAtFunc.call(expr, i); }, + length = expr.length, + + // Push `index` up to the next non-space character + gobbleSpaces = function() { + var ch = exprICode(index); + // space or tab + while(ch === 32 || ch === 9 || ch === 10 || ch === 13) { + ch = exprICode(++index); + } + }, + + // The main parsing function. Much of this code is dedicated to ternary expressions + gobbleExpression = function() { + var test = gobbleBinaryExpression(), + consequent, alternate; + gobbleSpaces(); + if(exprICode(index) === QUMARK_CODE) { + // Ternary expression: test ? consequent : alternate + index++; + consequent = gobbleExpression(); + if(!consequent) { + throwError('Expected expression', index); + } + gobbleSpaces(); + if(exprICode(index) === COLON_CODE) { + index++; + alternate = gobbleExpression(); + if(!alternate) { + throwError('Expected expression', index); + } + return { + type: CONDITIONAL_EXP, + test: test, + consequent: consequent, + alternate: alternate + }; + } else { + throwError('Expected :', index); + } + } else { + return test; + } + }, + + // Search for the operation portion of the string (e.g. `+`, `===`) + // Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`) + // and move down from 3 to 2 to 1 character until a matching binary operation is found + // then, return that binary operation + gobbleBinaryOp = function() { + gobbleSpaces(); + var biop, to_check = expr.substr(index, max_binop_len), tc_len = to_check.length; + while(tc_len > 0) { + // Don't accept a binary op when it is an identifier. + // Binary ops that start with a identifier-valid character must be followed + // by a non identifier-part valid character + if(binary_ops.hasOwnProperty(to_check) && ( + !isIdentifierStart(exprICode(index)) || + (index+to_check.length< expr.length && !isIdentifierPart(exprICode(index+to_check.length))) + )) { + index += tc_len; + return to_check; + } + to_check = to_check.substr(0, --tc_len); + } + return false; + }, + + // This function is responsible for gobbling an individual expression, + // e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)` + gobbleBinaryExpression = function() { + var ch_i, node, biop, prec, stack, biop_info, left, right, i, cur_biop; + + // First, try to get the leftmost thing + // Then, check to see if there's a binary operator operating on that leftmost thing + left = gobbleToken(); + biop = gobbleBinaryOp(); + + // If there wasn't a binary operator, just return the leftmost node + if(!biop) { + return left; + } + + // Otherwise, we need to start a stack to properly place the binary operations in their + // precedence structure + biop_info = { value: biop, prec: binaryPrecedence(biop)}; + + right = gobbleToken(); + if(!right) { + throwError("Expected expression after " + biop, index); + } + stack = [left, biop_info, right]; + + // Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm) + while((biop = gobbleBinaryOp())) { + prec = binaryPrecedence(biop); + + if(prec === 0) { + break; + } + biop_info = { value: biop, prec: prec }; + + cur_biop = biop; + // Reduce: make a binary expression from the three topmost entries. + while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { + right = stack.pop(); + biop = stack.pop().value; + left = stack.pop(); + node = createBinaryExpression(biop, left, right); + stack.push(node); + } + + node = gobbleToken(); + if(!node) { + throwError("Expected expression after " + cur_biop, index); + } + stack.push(biop_info, node); + } + + i = stack.length - 1; + node = stack[i]; + while(i > 1) { + node = createBinaryExpression(stack[i - 1].value, stack[i - 2], node); + i -= 2; + } + return node; + }, + + // An individual part of a binary expression: + // e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis) + gobbleToken = function() { + var ch, to_check, tc_len; + + gobbleSpaces(); + ch = exprICode(index); + + if(isDecimalDigit(ch) || ch === PERIOD_CODE) { + // Char code 46 is a dot `.` which can start off a numeric literal + return gobbleNumericLiteral(); + } else if(ch === SQUOTE_CODE || ch === DQUOTE_CODE) { + // Single or double quotes + return gobbleStringLiteral(); + } else if (ch === OBRACK_CODE) { + return gobbleArray(); + } else { + to_check = expr.substr(index, max_unop_len); + tc_len = to_check.length; + while(tc_len > 0) { + // Don't accept an unary op when it is an identifier. + // Unary ops that start with a identifier-valid character must be followed + // by a non identifier-part valid character + if(unary_ops.hasOwnProperty(to_check) && ( + !isIdentifierStart(exprICode(index)) || + (index+to_check.length < expr.length && !isIdentifierPart(exprICode(index+to_check.length))) + )) { + index += tc_len; + return { + type: UNARY_EXP, + operator: to_check, + argument: gobbleToken(), + prefix: true + }; + } + to_check = to_check.substr(0, --tc_len); + } + + if (isIdentifierStart(ch) || ch === OPAREN_CODE) { // open parenthesis + // `foo`, `bar.baz` + return gobbleVariable(); + } + } + + return false; + }, + // Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to + // keep track of everything in the numeric literal and then calling `parseFloat` on that string + gobbleNumericLiteral = function() { + var number = '', ch, chCode; + while(isDecimalDigit(exprICode(index))) { + number += exprI(index++); + } + + if(exprICode(index) === PERIOD_CODE) { // can start with a decimal marker + number += exprI(index++); + + while(isDecimalDigit(exprICode(index))) { + number += exprI(index++); + } + } + + ch = exprI(index); + if(ch === 'e' || ch === 'E') { // exponent marker + number += exprI(index++); + ch = exprI(index); + if(ch === '+' || ch === '-') { // exponent sign + number += exprI(index++); + } + while(isDecimalDigit(exprICode(index))) { //exponent itself + number += exprI(index++); + } + if(!isDecimalDigit(exprICode(index-1)) ) { + throwError('Expected exponent (' + number + exprI(index) + ')', index); + } + } + + + chCode = exprICode(index); + // Check to make sure this isn't a variable name that start with a number (123abc) + if(isIdentifierStart(chCode)) { + throwError('Variable names cannot start with a number (' + + number + exprI(index) + ')', index); + } else if(chCode === PERIOD_CODE) { + throwError('Unexpected period', index); + } + + return { + type: LITERAL, + value: parseFloat(number), + raw: number + }; + }, + + // Parses a string literal, staring with single or double quotes with basic support for escape codes + // e.g. `"hello world"`, `'this is\nJSEP'` + gobbleStringLiteral = function() { + var str = '', quote = exprI(index++), closed = false, ch; + + while(index < length) { + ch = exprI(index++); + if(ch === quote) { + closed = true; + break; + } else if(ch === '\\') { + // Check for all of the common escape codes + ch = exprI(index++); + switch(ch) { + case 'n': str += '\n'; break; + case 'r': str += '\r'; break; + case 't': str += '\t'; break; + case 'b': str += '\b'; break; + case 'f': str += '\f'; break; + case 'v': str += '\x0B'; break; + default : str += ch; + } + } else { + str += ch; + } + } + + if(!closed) { + throwError('Unclosed quote after "'+str+'"', index); + } + + return { + type: LITERAL, + value: str, + raw: quote + str + quote + }; + }, + + // Gobbles only identifiers + // e.g.: `foo`, `_value`, `$x1` + // Also, this function checks if that identifier is a literal: + // (e.g. `true`, `false`, `null`) or `this` + gobbleIdentifier = function() { + var ch = exprICode(index), start = index, identifier; + + if(isIdentifierStart(ch)) { + index++; + } else { + throwError('Unexpected ' + exprI(index), index); + } + + while(index < length) { + ch = exprICode(index); + if(isIdentifierPart(ch)) { + index++; + } else { + break; + } + } + identifier = expr.slice(start, index); + + if(literals.hasOwnProperty(identifier)) { + return { + type: LITERAL, + value: literals[identifier], + raw: identifier + }; + } else if(identifier === this_str) { + return { type: THIS_EXP }; + } else { + return { + type: IDENTIFIER, + name: identifier + }; + } + }, + + // Gobbles a list of arguments within the context of a function call + // or array literal. This function also assumes that the opening character + // `(` or `[` has already been gobbled, and gobbles expressions and commas + // until the terminator character `)` or `]` is encountered. + // e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]` + gobbleArguments = function(termination) { + var ch_i, args = [], node, closed = false; + var separator_count = 0; + while(index < length) { + gobbleSpaces(); + ch_i = exprICode(index); + if(ch_i === termination) { // done parsing + closed = true; + index++; + if(termination === CPAREN_CODE && separator_count && separator_count >= args.length){ + throwError('Unexpected token ' + String.fromCharCode(termination), index); + } + break; + } else if (ch_i === COMMA_CODE) { // between expressions + index++; + separator_count++; + if(separator_count !== args.length) { // missing argument + if(termination === CPAREN_CODE) { + throwError('Unexpected token ,', index); + } + else if(termination === CBRACK_CODE) { + for(var arg = args.length; arg< separator_count; arg++) { + args.push(null); + } + } + } + } else { + node = gobbleExpression(); + if(!node || node.type === COMPOUND) { + throwError('Expected comma', index); + } + args.push(node); + } + } + if (!closed) { + throwError('Expected ' + String.fromCharCode(termination), index); + } + return args; + }, + + // Gobble a non-literal variable name. This variable name may include properties + // e.g. `foo`, `bar.baz`, `foo['bar'].baz` + // It also gobbles function calls: + // e.g. `Math.acos(obj.angle)` + gobbleVariable = function() { + var ch_i, node; + ch_i = exprICode(index); + + if(ch_i === OPAREN_CODE) { + node = gobbleGroup(); + } else { + node = gobbleIdentifier(); + } + gobbleSpaces(); + ch_i = exprICode(index); + while(ch_i === PERIOD_CODE || ch_i === OBRACK_CODE || ch_i === OPAREN_CODE) { + index++; + if(ch_i === PERIOD_CODE) { + gobbleSpaces(); + node = { + type: MEMBER_EXP, + computed: false, + object: node, + property: gobbleIdentifier() + }; + } else if(ch_i === OBRACK_CODE) { + node = { + type: MEMBER_EXP, + computed: true, + object: node, + property: gobbleExpression() + }; + gobbleSpaces(); + ch_i = exprICode(index); + if(ch_i !== CBRACK_CODE) { + throwError('Unclosed [', index); + } + index++; + } else if(ch_i === OPAREN_CODE) { + // A function call is being made; gobble all the arguments + node = { + type: CALL_EXP, + 'arguments': gobbleArguments(CPAREN_CODE), + callee: node + }; + } + gobbleSpaces(); + ch_i = exprICode(index); + } + return node; + }, + + // Responsible for parsing a group of things within parentheses `()` + // This function assumes that it needs to gobble the opening parenthesis + // and then tries to gobble everything within that parenthesis, assuming + // that the next thing it should see is the close parenthesis. If not, + // then the expression probably doesn't have a `)` + gobbleGroup = function() { + index++; + var node = gobbleExpression(); + gobbleSpaces(); + if(exprICode(index) === CPAREN_CODE) { + index++; + return node; + } else { + throwError('Unclosed (', index); + } + }, + + // Responsible for parsing Array literals `[1, 2, 3]` + // This function assumes that it needs to gobble the opening bracket + // and then tries to gobble the expressions as arguments. + gobbleArray = function() { + index++; + return { + type: ARRAY_EXP, + elements: gobbleArguments(CBRACK_CODE) + }; + }, + + nodes = [], ch_i, node; + + while(index < length) { + ch_i = exprICode(index); + + // Expressions can be separated by semicolons, commas, or just inferred without any + // separators + if(ch_i === SEMCOL_CODE || ch_i === COMMA_CODE) { + index++; // ignore separators + } else { + // Try to gobble each expression individually + if((node = gobbleExpression())) { + nodes.push(node); + // If we weren't able to find a binary expression and are out of room, then + // the expression passed in probably has too much + } else if(index < length) { + throwError('Unexpected "' + exprI(index) + '"', index); + } + } + } + + // If there's only one expression just try returning the expression + if(nodes.length === 1) { + return nodes[0]; + } else { + return { + type: COMPOUND, + body: nodes + }; + } + }; + + // To be filled in by the template + jsep.version = '<%= version %>'; + jsep.toString = function() { return 'JavaScript Expression Parser (JSEP) v' + jsep.version; }; + + /** + * @method jsep.addUnaryOp + * @param {string} op_name The name of the unary op to add + * @return jsep + */ + jsep.addUnaryOp = function(op_name) { + max_unop_len = Math.max(op_name.length, max_unop_len); + unary_ops[op_name] = t; return this; + }; + + /** + * @method jsep.addBinaryOp + * @param {string} op_name The name of the binary op to add + * @param {number} precedence The precedence of the binary op (can be a float) + * @return jsep + */ + jsep.addBinaryOp = function(op_name, precedence) { + max_binop_len = Math.max(op_name.length, max_binop_len); + binary_ops[op_name] = precedence; + return this; + }; + + /** + * @method jsep.addLiteral + * @param {string} literal_name The name of the literal to add + * @param {*} literal_value The value of the literal + * @return jsep + */ + jsep.addLiteral = function(literal_name, literal_value) { + literals[literal_name] = literal_value; + return this; + }; + + /** + * @method jsep.removeUnaryOp + * @param {string} op_name The name of the unary op to remove + * @return jsep + */ + jsep.removeUnaryOp = function(op_name) { + delete unary_ops[op_name]; + if(op_name.length === max_unop_len) { + max_unop_len = getMaxKeyLen(unary_ops); + } + return this; + }; + + /** + * @method jsep.removeAllUnaryOps + * @return jsep + */ + jsep.removeAllUnaryOps = function() { + unary_ops = {}; + max_unop_len = 0; + + return this; + }; + + /** + * @method jsep.removeBinaryOp + * @param {string} op_name The name of the binary op to remove + * @return jsep + */ + jsep.removeBinaryOp = function(op_name) { + delete binary_ops[op_name]; + if(op_name.length === max_binop_len) { + max_binop_len = getMaxKeyLen(binary_ops); + } + return this; + }; + + /** + * @method jsep.removeAllBinaryOps + * @return jsep + */ + jsep.removeAllBinaryOps = function() { + binary_ops = {}; + max_binop_len = 0; + + return this; + }; + + /** + * @method jsep.removeLiteral + * @param {string} literal_name The name of the literal to remove + * @return jsep + */ + jsep.removeLiteral = function(literal_name) { + delete literals[literal_name]; + return this; + }; + + /** + * @method jsep.removeAllLiterals + * @return jsep + */ + jsep.removeAllLiterals = function() { + literals = {}; + + return this; + }; + + // In desktop environments, have a way to restore the old value for `jsep` + if (typeof exports === 'undefined') { + var old_jsep = root.jsep; + // The star of the show! It's a function! + root.jsep = jsep; + // And a courteous function willing to move out of the way for other similarly-named objects! + jsep.noConflict = function() { + if(root.jsep === jsep) { + root.jsep = old_jsep; + } + return jsep; + }; + } else { + // In Node.JS environments + if (typeof module !== 'undefined' && module.exports) { + exports = module.exports = jsep; + } else { + exports.parse = jsep; + } + } +}(this)); + +var binops = { + "+" : function(a, b) { return a + b; }, + "-" : function(a, b) { return a - b; }, + "*" : function(a, b) { return a * b; }, + "/" : function(a, b) { return a / b; }, + "%" : function(a, b) { return a % b; }, + "==" : function(a, b) { return a == b; }, + "!=" : function(a, b) { return a != b; }, + "<=" : function(a, b) { return a <= b; }, + ">=" : function(a, b) { return a >= b; }, + "<" : function(a, b) { return a < b; }, + ">" : function(a, b) { return a > b; }, +}; +var unops = { + "-" : function(a) { return -a; }, + "+" : function(a) { return +a; } +}; + +function is_id(node, id){ + if (node.type === "Identifier"){ + return (node.name === id); + } + return false; +} + +function unsupported_node(node){ + console.log("Unsupported node : "); + console.log(node); + return NaN; +} + +function do_eval(node, env) { + if(node.type === "BinaryExpression") { + return binops[node.operator](do_eval(node.left, env), do_eval(node.right, env)); + } else if(node.type === "UnaryExpression") { + return unops[node.operator](do_eval(node.argument, env)); + } else if(node.type === "Literal") { + return node.value; + } else if(node.type === "Identifier") { + return env.env[node.name]; + } else if (node.type === "ArrayExpression") { + let vals = node.elements.map(e => do_eval(e, env)); + return vals; + } else if (node.type === "CallExpression") { + if(is_id(node.callee,"mem")){ + let sz = do_eval(node.arguments[0], env); + let addr = do_eval(node.arguments[1], env); + let a = Array.from(Array(sz)).map((e,i) => env.mem(addr + i)); + let v = a.reduce(function(acc, b, i) { return acc + b * (1 << (8*i)); }, 0); + env.memrecord(ast_to_string(node),addr, sz, v); + return v; + } else if(is_id(node.callee,"str")){ + let addr = do_eval(node.arguments[0], env); + let str = env.str(addr); + return str; + } else if(is_id(node.callee,"hex")){ + let s = do_eval(node.arguments[0],env); + return word_to_string(s); + } else if(is_id(node.callee,"log")){ + let s = node.arguments.map(e => ast_to_string(e) + "="+ do_eval(e,env)); + env.log("step="+ env.env.step + ", ip=" + env.env.ip + ": "+s+"\n"); + return s; + } else if(is_id(node.callee,"if")){ + let cond = do_eval(node.arguments[0], env); + if(cond){ + return do_eval(node.arguments[1], env); + } + return undefined; + } else if(is_id(node.callee,"in")){ + let elt = do_eval(node.arguments[0], env); + let list = do_eval(node.arguments[1], env); + return list.includes(elt); + } else { + return unsupported_node(node); + } + } else if (node.type === "Compound") { + let vals = node.body.map(e => do_eval(e, env)); + return vals; + } + return unsupported_node(node); +} + + +function ast_to_string(node) { + if(node.type === "BinaryExpression") { + return ast_to_string(node.left) + node.operator + ast_to_string(node.right); + } else if(node.type === "UnaryExpression") { + return node.operator + ast_to_string(node.argument); + } else if(node.type === "Literal") { + return String(node.value); + } else if(node.type === "Identifier") { + return node.name; + } else if (node.type === "ArrayExpression") { + let vals = node.elements.map(e => ast_to_string(e)); + return vals.toString(); + } else if (node.type === "CallExpression") { + return ast_to_string(node.callee) + "(" + + node.arguments.map(e => ast_to_string(e)).toString() + + ")"; + } else if (node.type === "Compound") { + let vals = node.body.map(e => ast_to_string(e)); + return vals.toString(); + } + return "??"; +} diff --git a/ldb/ldb.html b/ldb/ldb.html new file mode 100644 index 0000000000000000000000000000000000000000..efcdd8ee2bdf96ca51cd686745a0371b478831ba --- /dev/null +++ b/ldb/ldb.html @@ -0,0 +1,76 @@ +<!DOCTYPE html> +<html> +<meta charset="utf-8"> + +<head> + <link rel="stylesheet" type="text/css" href="style.css"> +</head> + +<body> + <div class="title"> + <h2>LTL Trace Explorer : <span id="traceName"></span> </h2> + </div> + <div id="step_navigator"> + Parameters : <input type="text" id="init_params" /> + <input type="button" value="Init" id="btn_init" /> + <input type="button" id="quit_btn" value="Quit" /> + <input type="button" id="graph_btn" value="Draw graph" /> + <input type="button" id="prev_bp" value="↞" /> + + <input type="button" id="prev_step" value="←" /> + + <span id="curstep"></span> of <span id="total_num_steps"></span> + + <input type="button" id="next_step" value=" →" /> + + <input type="button" id="next_bp" value="↠" /> + <input type="button" id="play" value="Play" /> + + <input type="button" id="pause" value="Pause" /> + </div> + + <div id="body"> + + <!-- <div id="left"> --> + + <div id="code"></div> + <div id="cfg"><h1>CFG</h1><div id="cfg_cont"></div> </div> + <!-- </div> --> + <div id="output"></div> + <div id="log"></div> + <!-- <div id="right-panel"> --> + <div id="state"> + <div id="regstate"></div> + <div id="memstate"></div> + </div> + <div id="expr"> + <input type="text" id="expr_input" size="20" /><br> + Result: <span id="expr_res"></span><hr> + <div id="subexprs"></div> + </div> + <div id="legend"> + <!-- <h3>Legend</h3> + <h4>State</h4> + <span class="touched">Address written to</span><br> + <span class="read">Address read from</span><br> + <h4>Instructions</h4> + <span class="break">Instruction with breakpoint</span><br> + <span class="current">Instruction to be executed next</span><br> + <span class="break current">Next instruction has a breakpoint</span><br> --> + <h4>Vars</h4> + <div id="vars"></div> + <h4>CFG</h4> + <div id="cfg_legend"></div> + <h4>Status</h4> + <div id="status"></div> + </div> + <!-- </div> --> + </div> + <script src="d3.v5.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js"></script> + <script src="expr.js"></script> + <script src="ldb.js"></script> + +</body> + +</html> diff --git a/ldb/ldb.js b/ldb/ldb.js new file mode 100644 index 0000000000000000000000000000000000000000..a1320381695f964ed4ea0cef96816545749e3082 --- /dev/null +++ b/ldb/ldb.js @@ -0,0 +1,794 @@ +// Get trace file and source file from GET parameters +let url = new URL(window.location.href); +var debug = url.searchParams.has("debug"); + +// 'trace' will hold objects { ip, regs, memwrite, memread } +// ip : instruction pointer +// regs : register values, e.g. { s0: 12, sp: 9888, a0: 1, ... } +// memwrite : memory bytes written at this step [ { addr: 9809, v: 0x00-0xff }, ... ] +// memread : list of memory addresses read at this step +// output : output at that step +var trace = {}; + +// current_step : index in `trace` array +var current_step = 0; + +// current_label : funname_instrindex +var current_label = undefined; + +// set of addresses to display -- populated by get_interesting_addresses() based +// on addresses accessed in the trace +var interesting_addresses = []; + +// set of breakpoints (funname_instrindex) +var breaks = []; + +// for each function, its start and end addresses in the code +var funboundaries = {}; + +// Expressions are evaluated in the current state. Memory subexpressions are +// identified and assigned a CSS class taken from the `available_css_classes` +// set. `expr_css_classes` records the relationship between classes and +// expressions. +let available_css_classes = ["expr1", "expr2", "expr3", "expr4"]; +var expr_css_classes = {}; + +// List of all registers. Used for showing the state of the registers, in that +// order in a 8-col x 4-row table. +let all_regs = [ "zero" , "ra" , "sp" , "gp" , "s0", "s1" , "s2" , "s3" , + "s4" , "s5" , "s6" , "s7" , "s8" , "s9" , "s10" , "s11" , + "a0" , "a1" , "a2" , "a3" , "a4" , "a5" , "a6" , "a7" , + "t0" , "t1" , "t2" , "t3" , "t4" , "t5" , "t6", "tp" ]; + + +// Table which holds the value of any memory address at each step. Populated +// lazily by the membyte function. +var memo_table = {}; + +var cfgNodes; +var cfgEdges; +var cfgNetwork; +var curCfgNode; +var nodeId = {}; + +// Variable for websocket -- initialized later, once all data has been loaded +var ws; + +var log = {}; + +// Have we received data for step 'step'? +function trace_for_step(step){ + return Object.keys(trace).includes(String(step)); +} + +// Send a json object to the debugger +function send_to_debugger(json){ + console.log("Sending "+ JSON.stringify(json)); + ws.send(JSON.stringify(json)+"\n"); +} + +// Conversion to hex +// One byte +function byte_to_string(i){ + return ("00" + i.toString(16)).substr(-2); +} +// One word +function word_to_string(i){ + return ("0".repeat(8) + i.toString(16)).substr(-8); +} +// A bitvector of sz hex digits (hexvector?) +function bv_to_string(sz, i){ + return ("0".repeat(sz) + i.toString(16)).substr(-sz); +} + +// Get ASCII character corresponding to code i if printable, '.' otherwise +function byte_to_char(i){ + let v = String.fromCharCode(i); + return v.replace(/[^\x20-\x7E]/g, '.');; +} + +var isPlaying = false; +var playSpeed = 0.6; +var isFinished = false; +var timer = undefined; + + +function toggle(elt, icon) { + var isHidden = elt.style('display') == 'none'; + if(isHidden){ + icon.html("-"); + return elt.style('display', 'inherit'); + } else { + icon.html("+"); + return elt.style('display', 'none'); + } +} + +// Given a list of highlighted ranges of addresses 'highlight', determine wheter +// 'addr' is in one of these ranges. A range is a JS object r with r.addr giving +// the range start address and r.sz its size +// Returns an array a where a[0] is a boolean saying whether or not it should be +// highlighted, and a[1] is the CSS class that should be applied +function is_highlighted(addr, highlight){ + return highlight.reduce(function (acc,e) { + if (acc[0]) return acc; + if (e.addr <= addr && addr < e.addr + e.sz){ + return [true, e.expr]; + } + return acc; + }, [false, ""]); +} + +// Display the memory at a given step, from memory address 'start' and +// 'numbytes' bytes on. Highlight those addresses that are in highlight. +function show_mem(step, start, numbytes, highlight){ + var s = ""; + var line = []; // holds the bytes in the line currently under construction, + // used for printing chars on the right of each line + for(var j = 0; j < numbytes; j++){ + let addr = start + j; + if(addr % 16 == 0) { + s+="\n" + word_to_string(addr) + ":"; + } + if(addr %8 == 0) s+=" "; + let v = membyte(step, addr); + line.push(v); + let touched = (Object.keys(trace[step].memwrite).includes(addr.toString())) ? "touched" : "untouched"; + let read = (trace[step].memread.includes(addr)) ? "read" : "unread"; + + let hi = is_highlighted(addr, highlight); + var col = ""; + if(hi[0]){ + col = expr_css_classes[hi[1]] ; + } + s+= "<span class=\""+ touched + " "+ read + " " + col +"\">" + byte_to_string(v) + "</span> "; + if((addr + 1) % 16 == 0) { + line.forEach(function(i){ + s+= byte_to_char(i); + }); + line = []; + } + } + return s; +} + +// Show the state at step 'step'. 'highlight' is the set of addresses that +// should be highlighted, i.e. those that appears in expressions that we watch. +// Shows registers, memory at "interesting addresses" (computed in +// get_interesting_addresses). +function show_state(step, highlight){ + let numcols = 4; + var s = "<h1>Registers</h1><table>"; + let regs = trace[step]["regs"]; + all_regs.forEach(function (k, i){ + if (i % numcols == 0) s+= "<tr>"; + s += "<td class=\"regname\">" + k + + "</td><td class=\"regval\" title=\"" + regs[k] + "\">0x"+ word_to_string(regs[k]) +"</td>"; + i++; + if (i % numcols == 0) s+= "</tr>"; + }); + s += "</table>"; + document.querySelector('#regstate').innerHTML = s; + // s = "<h1>Stack</h1><pre>"; + // let sp = regs["sp"]; + // let s0 = regs["s0"]; + // for(var addr = sp; addr <= 10000; addr+=8){ + // let a = Array.from(Array(8)).map((e,i) => membyte(step, addr + i)); + // let v = a.reduce(function(acc, b, i) { return acc + b * (1 << (8*i)); }, 0); + // s += word_to_string(addr) + ": " + word_to_string(v) + "<br>"; + // } + s = "<h1>Memory</h1><pre>"; + get_interesting_addresses(); + interesting_addresses.forEach(function (ad){ + s += "<hr>"; + s += show_mem(step, ad[0], ad[1], highlight); + }); + + document.querySelector('#memstate').innerHTML = s + "</pre>"; +} + +// Set current label to 'label' in the code view and make it visible +function set_current_label(label){ + if(current_label !== undefined){ + d3.select('#code_'+current_label).classed("current", false); + } + d3.select('#code_'+label).classed("current", true); + var elt = document.getElementById('code_'+label); + elt.scrollIntoView({block: "nearest"}); + current_label = label; +} + + +// Sets the state to be at step 'step'. +function state(step){ + // Number in navigator bar + document.querySelector('#curstep').innerHTML = step; + let t = trace[step]; + let label = t["ip"]; + let highlight = compute_expr(step); + if(label in nodeId){ + if (curCfgNode !== undefined){ + cfgNodes.update([{id: nodeId[curCfgNode], group: ip_to_fun(curCfgNode)}]); + } + cfgNodes.update([{ id: nodeId[label], group: 'current'}]); + curCfgNode = label; + } + + display_exprs_and_logs(step); + show_state(step, highlight); + + // Compute expressions + let show_exprs = d3.select('#subexprs'); + show_exprs.html(""); + highlight.forEach(function (hi){ + show_exprs.insert("p") + .html(hi.expr + " -> " + hi.val) + .attr("title", bv_to_string(hi.sz, hi.val)) + .classed(expr_css_classes[hi.expr], true); + }); + + // Show output + d3.select('#output').html("<h1>Output</h1><pre>" + get_output(step) +"</pre>"); + // Set current label and step + set_current_label(label); + current_step = step; +} + +// Add a breakpoint at a given label (+ communicates with debugger) +function add_breakpoint(label){ + label = parseInt(label); + var i = breaks.indexOf(label); + if(i > -1){ + breaks.splice(i, 1); + send_to_debugger({'cmd': 'rmbreak', 'ip': label}); + d3.select('#code_'+label).classed("break", false); + } else { + breaks.push(label); + send_to_debugger({'cmd': 'break', 'ip': label}); + d3.select('#code_'+label).classed("break", true); + } +} + +// Determines whethere a step is a breakpoint or not. +function is_step_breakpoint(step){ + return breaks.includes(trace[step]["ip"]); +} + +// Shows a memdiff -- used during debug. +function string_of_memdiff(t){ + var s = "{"; + Object.keys(t).forEach(function (k){ + s+= " " + k + " -> " + t[k] + ","; + }); + return s + "}"; +} + +// Gets the byte value at memory address 'addr' for step 'step'. If lucky, this +// is alread memoized in 'memo_table'. Otherwise, walk back the trace to find +// out, and saves the result in the 'memo_table'. +function membyte(step, addr){ + if (step in memo_table){ + if (addr in memo_table[step]){ + return memo_table[step][addr]; + } + } else { + memo_table[step] = {}; + } + let t = trace[step].memwrite; + if (Object.keys(t).includes(addr.toString())){ + memo_table[step][addr] = t[addr]; + return t[addr]; + } else { + if (step == 0) { return "XX"; } + else { + let v = membyte(step-1, addr); + memo_table[step][addr] = v; + return v; + } + } +} + + +var out_table = {}; +// Gets the output for step 'step'. +function get_output(step){ + if (step in out_table){ + return out_table[step]; + } + let t = trace[step].output; + if (step == 0) { + out_table[step] = t; + return t; + } + else { + let prev_output = get_output(step-1); + let o = prev_output + t; + out_table[step] = o; + return o; + } +} + + +// Initializes the debugger with parameter values. +function init(){ + var params = d3.select('#init_params').property('value'); + let p = params.split(" ").map((val) => parseInt(val)); + trace = []; + breaks = []; + memo_table = {}; + log = {}; + send_to_debugger({'cmd': 'init', memsize:10000, params: p}); + isFinished = false; +} + +// Quits the debugger +function quit(){ + send_to_debugger({'cmd': 'quit'}); +} + +// Walk back one step, if possible +function prev_step(){ + if(current_step <= 0) return; + current_step--; + state(current_step); +} + +// Go to next step, call debugger if necessary. Note: if the debugger is called, +// the current_step will be updated with the response from the debugger, not +// before. +function next_step(){ + if(!trace_for_step(current_step + 1)){ + if ( !isFinished) + send_to_debugger({"cmd": "next"}); + else + pause(); + } else { + current_step++; + state(current_step); + } +} + +// Go to next breakpoint, call debugger if necessary. Note: if the debugger is called, +// the current_step will be updated with the response from the debugger, not +// before. +function next_bp(){ + current_step++; + if(trace_for_step(current_step)){ + if (is_step_breakpoint(current_step)){ + state(current_step); + return; + } else { + next_bp(); + } + } else if (! isFinished ){ + send_to_debugger({"cmd": "next_bp"}); + } +} + +// Go to previous breakpoint, if possible. If step is unavailable, something has +// gone wrong (shouldn't happen). +function prev_bp(){ + if(current_step <= 0) { + state(0); + return; + } + current_step--; + if(trace_for_step(current_step)){ + if(is_step_breakpoint(current_step)){ + state(current_step); + return; + } else { + prev_bp(); + } + } else { + console.log('Lost intermediate states...'); + return; + } +} + +function ip_to_fun(ip){ + for (let [fname, bounds] of Object.entries(funboundaries)){ + if(bounds.start <= ip && ip < bounds.end){ + return fname; + } + } + return "unknown"; +} + +function get_jumps(){ + var s = new Set(); + var curip = undefined; + var states = []; + trace.forEach(function (t){ + let first = curip === undefined; + let next_label = first || (t.ip === curip+1); + if(!next_label){ + states.push(curip); + } + curip = t.ip; + if(first || !next_label) + states.push(curip); + }); + var states2 = []; + trace.forEach(function (t){ + if(states.includes(t.ip)){ states2.push(t.ip); } + }); + states = states2; + nodeId = {}; + var nextId = 0; + var nodes = []; + states.forEach(function (s){ + if (!(s in nodeId)){ + nodes.push({ 'id': nextId, 'label' : String(s), group: ip_to_fun(s) }); + nodeId[s] = nextId; + nextId++; + } + }); + var edges = []; + var curs = undefined; + states.forEach(function (s){ + if(curs !== undefined){ + let from = nodeId[curs]; + let to = nodeId[s]; + let f = edges.findIndex(e => e.from == from && e.to == to); + var c = 1; + if (f > -1){ + c = 1 + Number(edges[f].label); + edges.splice(f,1); + } + edges.push({'from': from, 'to': to, 'arrows': 'to', + 'physics': false, 'smooth': {'type': 'cubicBezier'}, 'label': String(c)}); + } + curs = s; + }); + let container = document.querySelector('#cfg_cont'); + var options = { + layout: { + randomSeed: 1, + }, + edges:{ + color:{ + inherit:false + } + }, + physics: { + forceAtlas2Based: { + gravitationalConstant: -26, + centralGravity: 0.005, + springLength: 230, + springConstant: 0.18 + }, + maxVelocity: 146, + solver: "forceAtlas2Based", + timestep: 0.35, + stabilization: { iterations: 150 } + }, + manipulation: false, + }; + cfgNodes = new vis.DataSet(nodes); + cfgEdges = new vis.DataSet(edges); + let data = { + nodes: cfgNodes, + edges: cfgEdges + }; + cfgNetwork = new vis.Network(container, data, options); + d3.select('#cfg_legend').html(""); + for(let [g,info] of Object.entries(cfgNetwork.groups.groups)){ + d3.select('#cfg_legend') + .insert("span") + .style("background", info.color.background) + .html(g) + .insert("br"); + } +} + +// Computes a set of memory addresses that are either read from or written to in +// the current trace. Outputs a list of memory regions that contain interesting +// addresses. Several distinct regions are output if no interesting addresses +// appear in allowable_skip*16 bytes. +function get_interesting_addresses(){ + var s = new Set(); + for (let [step, t] of Object.entries(trace)){ + Object.keys(t.memwrite).forEach((x) => s.add(Math.floor(x / 16))); + t.memread.forEach((x) =>s.add(Math.floor(x / 16))); + } + var a = Array.from(s); + a.sort((x,y)=>x-y); // to sort as numbers... WTF... + var b = []; + var curlo = undefined; + var curhi = undefined; + var allowable_skip = 4; + a.forEach(function(x){ + if(curhi === undefined){ + curlo = x; curhi = x; + } else { + if (x - curhi <= allowable_skip){ + curhi = x; + } else { + b.push([curlo, curhi]); + curlo = x; curhi = x; + } + } + }); + if(curlo !== undefined) b.push([curlo, curhi]); + interesting_addresses = b.map(x => [x[0]*16,(x[1]-x[0]+1)*16]); +} + +function memstr(step, addr){ + var s = ""; + var c = membyte(step, addr); + while(c !== 0){ + s += byte_to_char(c); + addr++; + c = membyte(step, addr); + } + return s; +} + + +function safeDictGet(dict, key, deft){ + key = key.toString(); + if(Object.keys(dict).includes(key)) + return dict[key]; + return deft; +} + +function log2string(step){ + var s = ""; + for(var i = 0; i <= step; i++){ + s += safeDictGet(log, i, ""); + } + d3.select('#log').html("<pre>"+s+"</pre>"); +} + +var expr_result = ""; + +function compute_expr (step){ + let newValue = d3.select('#expr_input').property("value"); + let ast = jsep(newValue); + var hi = []; + let env = { + "env": {...trace[step].regs, "ip": trace[step].ip, "step": step}, + "mem": function(addr) { return membyte(step, addr); }, + "str": function(addr) { return memstr(step, addr); }, + "log": function(str) { + if (!(Object.keys(log)).includes(step)){ + log[step] = ""; + } + log[step] += str; + }, + "memrecord": function(str, addr, sz, v) { + if(!(str in expr_css_classes)){ + expr_css_classes[str] = available_css_classes[Object.keys(expr_css_classes).length % available_css_classes.length]; + } + hi.push( + { + 'addr': addr, + 'sz': sz, + 'expr': str, + 'val' : v + } + ); + } + }; + expr_result = do_eval(ast, env); + return hi; +} + +function display_exprs_and_logs(step){ + log2string(step); + d3.select('#expr_res').html(expr_result); +} + + +function play_next(){ + next_step(); + if (is_step_breakpoint(current_step)) { + pause(); + } +} + +function play(){ + isPlaying = true; + d3.select('#play').style("font-weight", "bold"); + d3.select('#pause').style("font-weight", "normal"); + timer = setInterval(play_next, playSpeed); +} +function pause(){ + clearInterval(timer); + isPlaying = false; + d3.select('#pause').style("font-weight", "bold"); + d3.select('#play').style("font-weight", "normal"); + +} + +function play_pause_toggle(){ + if(isPlaying) pause(); + else play(); +} + + + +function ab2str(buf) { + return String.fromCharCode.apply(null, new Uint8Array(buf)); +} + +function handle_command(d){ + + if(debug){ + console.log("Handling "+ JSON.stringify(d)); + } + if (Array.isArray(d)){ + d.forEach(d => handle_command(d)); + return; + } + + if(d['step'] !== undefined){ // This is a trace for a given step index + let ip = parseInt(d['ip']); + let step = parseInt(d['step']); + d3.select('#status').html("Handling step="+step); + let out = (Object.keys(d).includes('output')) ? d['output'] : ""; + trace[step] = { + "ip": ip, + "regs": d['regs'], + "memwrite": d['memwrite'], + "memread": d['memread'], + "output" : out + }; + compute_expr(step); + + } else if (d['currentstep'] !== undefined){ + current_step = parseInt(d['currentstep']); + d3.select('#status').html("Handling currentstep="+current_step); + updateNumSteps(); + state(current_step); + } else if (d['code'] !== undefined){ + d3.select('#code').html(""); + var p; + var curf; + for (let [ip, instr] of Object.entries(d['code'])) { + if(ip_to_fun(ip) != curf){ + p = d3.select('#code').insert("p"); + curf = ip_to_fun(ip); + } + p.insert("a") + .attr("id", "code_"+ip) + .on("click", function(){ add_breakpoint(ip); } ) + .html(ip + ": " + instr) + .append("br"); + } + } else if (d['progname'] !== undefined){ + d3.select('#traceName').html(d['progname'] + " with params [" + + d['params'].join(", ") + "]" + ); + } else if (d['funboundaries'] !== undefined){ + let vars_html = d3.select('#vars'); + vars_html.html(""); + d['funboundaries'].forEach(function(fb){ + let icon = vars_html.insert("span").html("-"); + let span = vars_html.insert("span").html(" Function "+fb['fname']); + vars_html.insert("br"); + let p = vars_html.insert("p"); + span.on('click', function(){ + toggle(p, icon); + }); + icon.on('click', function(){ + toggle(p, icon); + }); + + for(let [evar,loc] of Object.entries(fb['vars'])){ + if(Object.keys(loc).includes("reg")){ + p.insert("span").html("Var "+evar+": Reg "+loc["reg"]) + .insert("br"); + } else { + p.insert("span").html("Var "+evar+": Stk "+loc["stk"]) + .insert("br"); + } + } + funboundaries[fb['fname']] = {start : fb['start'], + end: fb['end'],}; + } + ); + } else if (d['error'] !== undefined){ + d3.select('#status').html("Error="+d['error']); + } else if (d['finished'] !== undefined){ + isFinished = true; + pause(); + } + + +} + +function updateNumSteps(){ + var ks = Object.keys(trace); + ks = ks.map(e => parseInt(e)); + ks = ks.filter(e => !isNaN(e)); + var max = ks.reduce((a,b)=>Math.max(a,b), 0); + document.querySelector('#total_num_steps').innerHTML = max; +} + +var __buf = ""; + +d3.select('#code').insert("h3").html("Code"); + + +document.querySelector('#curstep').innerHTML = 0; +updateNumSteps(); +document.querySelector('#prev_bp').onclick = prev_bp; + +document.querySelector('#prev_step').onclick = prev_step; +document.querySelector('#next_step').onclick = next_step; +document.querySelector('#next_bp').onclick = next_bp; + +document.querySelector('#play').onclick = next_bp; +document.querySelector('#pause').onclick = next_bp; + +d3.select("body") + .on("keydown", function(){ + if(["expr_input", "init_params"].includes(d3.event.target.id) ) return; + switch(d3.event.key){ + + case "ArrowRight": + next_step(); + break; + case "ArrowLeft": + prev_step(); + break; + case "ArrowDown": + next_bp(); + break; + case "ArrowUp": + prev_bp(); + break; + case "Home": + init(); + break; + case "g": + get_jumps(); + break; + case " ": + play_pause_toggle(); + // Space key would scroll if not prevented... + d3.event.preventDefault(); + break; + default: + break; + } + + }); + +d3.select('#expr_input').on("change", function (){ state(current_step); }); +d3.select('#btn_init').on("click", init); +d3.select('#quit_btn').on("click", quit); +d3.select('#graph_btn').on("click", get_jumps); + +ws = new WebSocket("ws://127.0.0.1:8080"); +// ws.binaryType = "arraybuffer"; +var recv = []; +ws.onmessage = function(event) { + let dr = // ab2str + (event.data); + recv.push(dr); + __buf += dr; + var todo = []; + var d = undefined; + try { + var s = __buf.split("@"); + for(var i = 0; i < s.length - 1; i++){ + todo.push(JSON.parse(s[i])); + } + __buf = s[s.length - 1]; + } catch (e) { + if (e instanceof SyntaxError){ + // console.log("JSON parse KO." , __buf, e); + } + } + todo.forEach (d => handle_command(d)); +}; +ws.onopen = function(event){ + init(); +}; + + + + diff --git a/ldb/style.css b/ldb/style.css new file mode 100644 index 0000000000000000000000000000000000000000..036b6c9856d48022239e634c21d7925bdd9e9b86 --- /dev/null +++ b/ldb/style.css @@ -0,0 +1,189 @@ +:root { + --bgcolor: white; + --textcolor: black; + --bordercolor: black; + --regbgcolor: #99ccff; + --regtextcolor: black; + --breakbg: #ff6666; + --currentbg: #99ccff; + --breakcurrentbg: purple; + --touchedbg: green; + --touchedfg: white; + --readbg: pink; + --readfg: red; + --highlightedbg: #999900; + --expr1bg: #a2b9bc; + --expr1fg: black; + --expr2bg: #b2ad7f; + --expr2fg: black; + --expr3bg: #878f99; + --expr3fg: white; + --expr4bg: #6b5b95; + --expr4fg: white; +} + + +/* :root { */ +/* --bgcolor: black; */ +/* --textcolor: white; */ +/* --bordercolor: white; */ +/* --regbgcolor: #99ccff; */ +/* --regtextcolor: purple; */ +/* --breakbg: #ff6666; */ +/* --currentbg: #99ccff; */ +/* --breakcurrentbg: purple; */ +/* --touchedbg: green; */ +/* --touchedfg: white; */ +/* --readbg: pink; */ +/* --readfg: red; */ +/* --highlightedbg: #999900; */ +/* --expr1bg: #a2b9bc; */ +/* --expr1fg: white; */ +/* --expr2bg: #b2ad7f; */ +/* --expr2fg: white; */ +/* --expr3bg: #878f99; */ +/* --expr3fg: gray; */ +/* --expr4bg: #6b5b95; */ +/* --expr4fg: gray; */ +/* --codecolor: white; */ +/* } */ + +html { + background: var(--bgcolor); + color: var(--textcolor); +} +#body{ + display: grid; + grid-template-columns: [ctrl] 250px [code] 400px [outcfg] 500px [state] 700px; + grid-template-rows: [row1] 200px [row2] 200px [row3] 400px [row4]; +} +#code { + grid-column-start: code; + grid-column-end: code; + grid-row-start: row1; + grid-row-end: row4; + border: 1px solid var(--bordercolor); + overflow-y: auto; + color: var(--codecolor); +} +#output { + grid-column-start: outcfg; + grid-column-end: outcfg; + grid-row-start: row1; + grid-row-end: row2; + border: 1px solid var(--bordercolor); + overflow-y: auto; +} +#log { + grid-column-start: outcfg; + grid-column-end: outcfg; + grid-row-start: row2; + grid-row-end: row3; + border: 1px solid var(--bordercolor); + overflow-y: auto; +} +#state { + grid-column-start: state; + grid-column-end: state; + grid-row-start: row1; + grid-row-end: row4; + border: 1px solid var(--bordercolor); + overflow-y: auto; +} +#expr { + grid-column-start: ctrl; + grid-column-end: ctrl; + grid-row-start: row1; + grid-row-end: row1; + border: 1px solid var(--bordercolor); +} +#legend{ + grid-column-start: ctrl; + grid-column-end: ctrl; + grid-row-start: row2; + grid-row-end: row4; + border: 1px solid var(--bordercolor); +} +#status{ + font-size: 11pt; +} +#step_navigator{ + /* grid-column-start: ctrl; */ + /* grid-column-end: ctrl; */ + /* grid-row-start: row1; */ + /* grid-row-end: row1; */ + /* font-size: 20pt; */ +} +#cfg{ + grid-column-start: outcfg; + grid-column-end: outcfg; + grid-row-start: row3; + grid-row-end: row4; + border: 1px solid var(--bordercolor); +} +#cfg_cont{ + width: 100%; + height: 80%; + background: #dddddd; +} + +td { + width: 40px; + text-align: center; +} + +.regname { + background: var(--regbgcolor); + color: var(--regtextcolor); +} + + +.break { + background: var(--breakbg); +} + + +.current { + background: var(--currentbg); +} + + +.break.current { + background: var(--breakcurrentbg); +} +pre{ + font-size: 10pt; + font-family: courier; +} + +.touched { + background: var(--touchedbg); + color: var(--touchedfg); +} + +.read { + background: var(--readbg); + color: var(--readfg); +} +.highlighted { + background: var(--highlightedbg); + } + + +.expr1 { + background: var(--expr1bg); + color: var(--expr1fg); +} +.expr2 { + background: var(--expr2bg); + color: var(--expr2fg); +} +.expr3 +{ + background: var(--expr3bg); + color: var(--expr3fg); +} +.expr4 { + background: var(--expr4bg); + color: var(--expr4fg); +} diff --git a/ldb/vis.min.js b/ldb/vis.min.js new file mode 100644 index 0000000000000000000000000000000000000000..aa3715bdb865ebc4ec69ed585864f5ba15dd41f9 --- /dev/null +++ b/ldb/vis.min.js @@ -0,0 +1,47 @@ +/** + * vis.js + * https://github.com/almende/vis + * + * A dynamic, browser-based visualization library. + * + * @version 4.20.1-SNAPSHOT + * @date 2017-10-12 + * + * @license + * Copyright (C) 2011-2017 Almende B.V, http://almende.com + * + * Vis.js is dual licensed under both + * + * * The Apache 2.0 License + * http://www.apache.org/licenses/LICENSE-2.0 + * + * and + * + * * The MIT License + * http://opensource.org/licenses/MIT + * + * Vis.js may be distributed under either license. + */ +"use strict";!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.vis=e():t.vis=e()}(this,function(){return function(t){function e(o){if(i[o])return i[o].exports;var n=i[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,o){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=123)}([function(t,e,i){e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,i){e.__esModule=!0;var o=i(169),n=function(t){return t&&t.__esModule?t:{default:t}}(o);e.default=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),(0,n.default)(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}()},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e,i,o){var n=!1;!0===o&&(n=null===e[i]&&void 0!==t[i]),n?delete t[i]:t[i]=e[i]}var s=i(77),r=o(s),a=i(29),h=o(a),d=i(8),l=o(d),u=i(6),c=o(u),p=i(9),f=i(157);e.isNumber=function(t){return t instanceof Number||"number"==typeof t},e.recursiveDOMDelete=function(t){if(t)for(;!0===t.hasChildNodes();)e.recursiveDOMDelete(t.firstChild),t.removeChild(t.firstChild)},e.giveRange=function(t,e,i,o){if(e==t)return.5;var n=1/(e-t);return Math.max(0,(o-t)*n)},e.isString=function(t){return t instanceof String||"string"==typeof t},e.isDate=function(t){if(t instanceof Date)return!0;if(e.isString(t)){if(m.exec(t))return!0;if(!isNaN(Date.parse(t)))return!0}return!1},e.randomUUID=function(){return f.v4()},e.assignAllKeys=function(t,e){for(var i in t)t.hasOwnProperty(i)&&"object"!==(0,c.default)(t[i])&&(t[i]=e)},e.fillIfDefined=function(t,i){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];for(var s in t)void 0!==i[s]&&(null===i[s]||"object"!==(0,c.default)(i[s])?n(t,i,s,o):"object"===(0,c.default)(t[s])&&e.fillIfDefined(t[s],i[s],o))},e.extend=function(t,e){for(var i=1;i<arguments.length;i++){var o=arguments[i];for(var n in o)o.hasOwnProperty(n)&&(t[n]=o[n])}return t},e.selectiveExtend=function(t,e,i){if(!Array.isArray(t))throw new Error("Array with property names expected as first argument");for(var o=2;o<arguments.length;o++)for(var n=arguments[o],s=0;s<t.length;s++){var r=t[s];n&&n.hasOwnProperty(r)&&(e[r]=n[r])}return e},e.selectiveDeepExtend=function(t,i,o){var s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Array.isArray(o))throw new TypeError("Arrays are not supported by deepExtend");for(var r=0;r<t.length;r++){var a=t[r];if(o.hasOwnProperty(a))if(o[a]&&o[a].constructor===Object)void 0===i[a]&&(i[a]={}),i[a].constructor===Object?e.deepExtend(i[a],o[a],!1,s):n(i,o,a,s);else{if(Array.isArray(o[a]))throw new TypeError("Arrays are not supported by deepExtend");n(i,o,a,s)}}return i},e.selectiveNotDeepExtend=function(t,i,o){var s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Array.isArray(o))throw new TypeError("Arrays are not supported by deepExtend");for(var r in o)if(o.hasOwnProperty(r)&&-1===t.indexOf(r))if(o[r]&&o[r].constructor===Object)void 0===i[r]&&(i[r]={}),i[r].constructor===Object?e.deepExtend(i[r],o[r]):n(i,o,r,s);else if(Array.isArray(o[r])){i[r]=[];for(var a=0;a<o[r].length;a++)i[r].push(o[r][a])}else n(i,o,r,s);return i},e.deepExtend=function(t,i){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];for(var r in i)if(i.hasOwnProperty(r)||!0===o)if(i[r]&&i[r].constructor===Object)void 0===t[r]&&(t[r]={}),t[r].constructor===Object?e.deepExtend(t[r],i[r],o):n(t,i,r,s);else if(Array.isArray(i[r])){t[r]=[];for(var a=0;a<i[r].length;a++)t[r].push(i[r][a])}else n(t,i,r,s);return t},e.equalArray=function(t,e){if(t.length!=e.length)return!1;for(var i=0,o=t.length;i<o;i++)if(t[i]!=e[i])return!1;return!0},e.convert=function(t,i){var o;if(void 0!==t){if(null===t)return null;if(!i)return t;if("string"!=typeof i&&!(i instanceof String))throw new Error("Type must be a string");switch(i){case"boolean":case"Boolean":return Boolean(t);case"number":case"Number":return e.isString(t)&&!isNaN(Date.parse(t))?p(t).valueOf():Number(t.valueOf());case"string":case"String":return String(t);case"Date":if(e.isNumber(t))return new Date(t);if(t instanceof Date)return new Date(t.valueOf());if(p.isMoment(t))return new Date(t.valueOf());if(e.isString(t))return o=m.exec(t),o?new Date(Number(o[1])):p(new Date(t)).toDate();throw new Error("Cannot convert object of type "+e.getType(t)+" to type Date");case"Moment":if(e.isNumber(t))return p(t);if(t instanceof Date)return p(t.valueOf());if(p.isMoment(t))return p(t);if(e.isString(t))return o=m.exec(t),p(o?Number(o[1]):t);throw new Error("Cannot convert object of type "+e.getType(t)+" to type Date");case"ISODate":if(e.isNumber(t))return new Date(t);if(t instanceof Date)return t.toISOString();if(p.isMoment(t))return t.toDate().toISOString();if(e.isString(t))return o=m.exec(t),o?new Date(Number(o[1])).toISOString():p(t).format();throw new Error("Cannot convert object of type "+e.getType(t)+" to type ISODate");case"ASPDate":if(e.isNumber(t))return"/Date("+t+")/";if(t instanceof Date)return"/Date("+t.valueOf()+")/";if(e.isString(t)){o=m.exec(t);return"/Date("+(o?new Date(Number(o[1])).valueOf():new Date(t).valueOf())+")/"}throw new Error("Cannot convert object of type "+e.getType(t)+" to type ASPDate");default:throw new Error('Unknown type "'+i+'"')}}};var m=/^\/?Date\((\-?\d+)/i;e.getType=function(t){var e=void 0===t?"undefined":(0,c.default)(t);return"object"==e?null===t?"null":t instanceof Boolean?"Boolean":t instanceof Number?"Number":t instanceof String?"String":Array.isArray(t)?"Array":t instanceof Date?"Date":"Object":"number"==e?"Number":"boolean"==e?"Boolean":"string"==e?"String":void 0===e?"undefined":e},e.copyAndExtendArray=function(t,e){for(var i=[],o=0;o<t.length;o++)i.push(t[o]);return i.push(e),i},e.copyArray=function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i]);return e},e.getAbsoluteLeft=function(t){return t.getBoundingClientRect().left},e.getAbsoluteRight=function(t){return t.getBoundingClientRect().right},e.getAbsoluteTop=function(t){return t.getBoundingClientRect().top},e.addClassName=function(t,e){var i=t.className.split(" "),o=e.split(" ");i=i.concat(o.filter(function(t){return i.indexOf(t)<0})),t.className=i.join(" ")},e.removeClassName=function(t,e){var i=t.className.split(" "),o=e.split(" ");i=i.filter(function(t){return o.indexOf(t)<0}),t.className=i.join(" ")},e.forEach=function(t,e){var i,o;if(Array.isArray(t))for(i=0,o=t.length;i<o;i++)e(t[i],i,t);else for(i in t)t.hasOwnProperty(i)&&e(t[i],i,t)},e.toArray=function(t){var e=[];for(var i in t)t.hasOwnProperty(i)&&e.push(t[i]);return e},e.updateProperty=function(t,e,i){return t[e]!==i&&(t[e]=i,!0)},e.throttle=function(t){var e=!1;return function(){e||(e=!0,requestAnimationFrame(function(){e=!1,t()}))}},e.addEventListener=function(t,e,i,o){t.addEventListener?(void 0===o&&(o=!1),"mousewheel"===e&&navigator.userAgent.indexOf("Firefox")>=0&&(e="DOMMouseScroll"),t.addEventListener(e,i,o)):t.attachEvent("on"+e,i)},e.removeEventListener=function(t,e,i,o){t.removeEventListener?(void 0===o&&(o=!1),"mousewheel"===e&&navigator.userAgent.indexOf("Firefox")>=0&&(e="DOMMouseScroll"),t.removeEventListener(e,i,o)):t.detachEvent("on"+e,i)},e.preventDefault=function(t){t||(t=window.event),t.preventDefault?t.preventDefault():t.returnValue=!1},e.getTarget=function(t){t||(t=window.event);var e;return t.target?e=t.target:t.srcElement&&(e=t.srcElement),void 0!=e.nodeType&&3==e.nodeType&&(e=e.parentNode),e},e.hasParent=function(t,e){for(var i=t;i;){if(i===e)return!0;i=i.parentNode}return!1},e.option={},e.option.asBoolean=function(t,e){return"function"==typeof t&&(t=t()),null!=t?0!=t:e||null},e.option.asNumber=function(t,e){return"function"==typeof t&&(t=t()),null!=t?Number(t)||e||null:e||null},e.option.asString=function(t,e){return"function"==typeof t&&(t=t()),null!=t?String(t):e||null},e.option.asSize=function(t,i){return"function"==typeof t&&(t=t()),e.isString(t)?t:e.isNumber(t)?t+"px":i||null},e.option.asElement=function(t,e){return"function"==typeof t&&(t=t()),t||e||null},e.hexToRGB=function(t){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(e,function(t,e,i,o){return e+e+i+i+o+o});var i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return i?{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16)}:null},e.overrideOpacity=function(t,i){var o;return-1!=t.indexOf("rgba")?t:-1!=t.indexOf("rgb")?(o=t.substr(t.indexOf("(")+1).replace(")","").split(","),"rgba("+o[0]+","+o[1]+","+o[2]+","+i+")"):(o=e.hexToRGB(t),null==o?t:"rgba("+o.r+","+o.g+","+o.b+","+i+")")},e.RGBToHex=function(t,e,i){return"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)},e.parseColor=function(t){var i;if(!0===e.isString(t)){if(!0===e.isValidRGB(t)){var o=t.substr(4).substr(0,t.length-5).split(",").map(function(t){return parseInt(t)});t=e.RGBToHex(o[0],o[1],o[2])}if(!0===e.isValidHex(t)){var n=e.hexToHSV(t),s={h:n.h,s:.8*n.s,v:Math.min(1,1.02*n.v)},r={h:n.h,s:Math.min(1,1.25*n.s),v:.8*n.v},a=e.HSVToHex(r.h,r.s,r.v),h=e.HSVToHex(s.h,s.s,s.v);i={background:t,border:a,highlight:{background:h,border:a},hover:{background:h,border:a}}}else i={background:t,border:t,highlight:{background:t,border:t},hover:{background:t,border:t}}}else i={},i.background=t.background||void 0,i.border=t.border||void 0,e.isString(t.highlight)?i.highlight={border:t.highlight,background:t.highlight}:(i.highlight={},i.highlight.background=t.highlight&&t.highlight.background||void 0,i.highlight.border=t.highlight&&t.highlight.border||void 0),e.isString(t.hover)?i.hover={border:t.hover,background:t.hover}:(i.hover={},i.hover.background=t.hover&&t.hover.background||void 0,i.hover.border=t.hover&&t.hover.border||void 0);return i},e.RGBToHSV=function(t,e,i){t/=255,e/=255,i/=255;var o=Math.min(t,Math.min(e,i)),n=Math.max(t,Math.max(e,i));if(o==n)return{h:0,s:0,v:o};var s=t==o?e-i:i==o?t-e:i-t;return{h:60*((t==o?3:i==o?1:5)-s/(n-o))/360,s:(n-o)/n,v:n}};var v={split:function(t){var e={};return t.split(";").forEach(function(t){if(""!=t.trim()){var i=t.split(":"),o=i[0].trim(),n=i[1].trim();e[o]=n}}),e},join:function(t){return(0,l.default)(t).map(function(e){return e+": "+t[e]}).join("; ")}};e.addCssText=function(t,i){var o=v.split(t.style.cssText),n=v.split(i),s=e.extend(o,n);t.style.cssText=v.join(s)},e.removeCssText=function(t,e){var i=v.split(t.style.cssText),o=v.split(e);for(var n in o)o.hasOwnProperty(n)&&delete i[n];t.style.cssText=v.join(i)},e.HSVToRGB=function(t,e,i){var o,n,s,r=Math.floor(6*t),a=6*t-r,h=i*(1-e),d=i*(1-a*e),l=i*(1-(1-a)*e);switch(r%6){case 0:o=i,n=l,s=h;break;case 1:o=d,n=i,s=h;break;case 2:o=h,n=i,s=l;break;case 3:o=h,n=d,s=i;break;case 4:o=l,n=h,s=i;break;case 5:o=i,n=h,s=d}return{r:Math.floor(255*o),g:Math.floor(255*n),b:Math.floor(255*s)}},e.HSVToHex=function(t,i,o){var n=e.HSVToRGB(t,i,o);return e.RGBToHex(n.r,n.g,n.b)},e.hexToHSV=function(t){var i=e.hexToRGB(t);return e.RGBToHSV(i.r,i.g,i.b)},e.isValidHex=function(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)},e.isValidRGB=function(t){return t=t.replace(" ",""),/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i.test(t)},e.isValidRGBA=function(t){return t=t.replace(" ",""),/rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(.{1,3})\)/i.test(t)},e.selectiveBridgeObject=function(t,i){if(null!==i&&"object"===(void 0===i?"undefined":(0,c.default)(i))){for(var o=(0,h.default)(i),n=0;n<t.length;n++)i.hasOwnProperty(t[n])&&"object"==(0,c.default)(i[t[n]])&&(o[t[n]]=e.bridgeObject(i[t[n]]));return o}return null},e.bridgeObject=function(t){if(null!==t&&"object"===(void 0===t?"undefined":(0,c.default)(t))){var i=(0,h.default)(t);if(t instanceof Element)i=t;else{i=(0,h.default)(t);for(var o in t)t.hasOwnProperty(o)&&"object"==(0,c.default)(t[o])&&(i[o]=e.bridgeObject(t[o]))}return i}return null},e.insertSort=function(t,e){for(var i=0;i<t.length;i++){for(var o=t[i],n=i;n>0&&e(o,t[n-1])<0;n--)t[n]=t[n-1];t[n]=o}return t},e.mergeOptions=function(t,e,i){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=function(t){return null!==t&&void 0!==t},s=function(t){return null!==t&&"object"===(void 0===t?"undefined":(0,c.default)(t))};if(!s(t))throw new Error("Parameter mergeTarget must be an object");if(!s(e))throw new Error("Parameter options must be an object");if(!n(i))throw new Error("Parameter option must have a value");if(!s(o))throw new Error("Parameter globalOptions must be an object");var r=e[i],a=s(o)&&!function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}(o),d=a?o[i]:void 0,l=d?d.enabled:void 0;if(void 0!==r){if("boolean"==typeof r)return s(t[i])||(t[i]={}),void(t[i].enabled=r);if(null===r&&!s(t[i])){if(!n(d))return;t[i]=(0,h.default)(d)}if(s(r)){var u=!0;void 0!==r.enabled?u=r.enabled:void 0!==l&&(u=d.enabled),function(t,e,i){s(t[i])||(t[i]={});var o=e[i],n=t[i];for(var r in o)o.hasOwnProperty(r)&&(n[r]=o[r])}(t,e,i),t[i].enabled=u}}},e.binarySearchCustom=function(t,e,i,o){for(var n=0,s=0,r=t.length-1;s<=r&&n<1e4;){var a=Math.floor((s+r)/2),h=t[a],d=void 0===o?h[i]:h[i][o],l=e(d);if(0==l)return a;-1==l?s=a+1:r=a-1,n++}return-1},e.binarySearchValue=function(t,e,i,o,n){var s,r,a,h,d=0,l=0,u=t.length-1;for(n=void 0!=n?n:function(t,e){return t==e?0:t<e?-1:1};l<=u&&d<1e4;){if(h=Math.floor(.5*(u+l)),s=t[Math.max(0,h-1)][i],r=t[h][i],a=t[Math.min(t.length-1,h+1)][i],0==n(r,e))return h;if(n(s,e)<0&&n(r,e)>0)return"before"==o?Math.max(0,h-1):h;if(n(r,e)<0&&n(a,e)>0)return"before"==o?h:Math.min(t.length-1,h+1);n(r,e)<0?l=h+1:u=h-1,d++}return-1},e.easingFunctions={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return t<.5?2*t*t:(4-2*t)*t-1},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t}},e.getScrollBarWidth=function(){var t=document.createElement("p");t.style.width="100%",t.style.height="200px";var e=document.createElement("div");e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.appendChild(t),document.body.appendChild(e);var i=t.offsetWidth;e.style.overflow="scroll";var o=t.offsetWidth;return i==o&&(o=e.clientWidth),document.body.removeChild(e),i-o},e.topMost=function(t,e){var i=void 0;Array.isArray(e)||(e=[e]);var o=!0,n=!1,s=void 0;try{for(var a,h=(0,r.default)(t);!(o=(a=h.next()).done);o=!0){var d=a.value;if(d){i=d[e[0]];for(var l=1;l<e.length;l++)i&&(i=i[e[l]]);if(void 0!==i)break}}}catch(t){n=!0,s=t}finally{try{!o&&h.return&&h.return()}finally{if(n)throw s}}return i}},function(t,e,i){t.exports={default:i(194),__esModule:!0}},function(t,e,i){e.__esModule=!0;var o=i(6),n=function(t){return t&&t.__esModule?t:{default:t}}(o);e.default=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==(void 0===e?"undefined":(0,n.default)(e))&&"function"!=typeof e?t:e}},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var n=i(196),s=o(n),r=i(29),a=o(r),h=i(6),d=o(h);e.default=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+(void 0===e?"undefined":(0,d.default)(e)));t.prototype=(0,a.default)(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(s.default?(0,s.default)(t,e):t.__proto__=e)}},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var n=i(142),s=o(n),r=i(144),a=o(r),h="function"==typeof a.default&&"symbol"==typeof s.default?function(t){return typeof t}:function(t){return t&&"function"==typeof a.default&&t.constructor===a.default&&t!==a.default.prototype?"symbol":typeof t};e.default="function"==typeof a.default&&"symbol"===h(s.default)?function(t){return void 0===t?"undefined":h(t)}:function(t){return t&&"function"==typeof a.default&&t.constructor===a.default&&t!==a.default.prototype?"symbol":void 0===t?"undefined":h(t)}},function(t,e){var i=t.exports={version:"2.5.1"};"number"==typeof __e&&(__e=i)},function(t,e,i){t.exports={default:i(140),__esModule:!0}},function(t,e,i){t.exports="undefined"!=typeof window&&window.moment||i(154)},function(t,e,i){function o(){var t=function(){};return{on:t,off:t,destroy:t,emit:t,get:function(e){return{set:t}}}}if("undefined"!=typeof window){var n=i(175),s=window.Hammer||i(176);t.exports=n(s,{preventDefault:"mouse"})}else t.exports=function(){return o()}},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(t&&!Array.isArray(t)&&(e=t,t=null),this._options=e||{},this._data={},this.length=0,this._fieldId=this._options.fieldId||"id",this._type={},this._options.type)for(var i=(0,l.default)(this._options.type),o=0,n=i.length;o<n;o++){var s=i[o],r=this._options.type[s];this._type[s]="Date"==r||"ISODate"==r||"ASPDate"==r?"Date":r}this._subscribers={},t&&this.add(t),this.setOptions(e)}var s=i(19),r=o(s),a=i(6),h=o(a),d=i(8),l=o(d),u=i(2),c=i(43);n.prototype.setOptions=function(t){t&&void 0!==t.queue&&(!1===t.queue?this._queue&&(this._queue.destroy(),delete this._queue):(this._queue||(this._queue=c.extend(this,{replace:["add","update","remove"]})),"object"===(0,h.default)(t.queue)&&this._queue.setOptions(t.queue)))},n.prototype.on=function(t,e){var i=this._subscribers[t];i||(i=[],this._subscribers[t]=i),i.push({callback:e})},n.prototype.off=function(t,e){var i=this._subscribers[t];i&&(this._subscribers[t]=i.filter(function(t){return t.callback!=e}))},n.prototype._trigger=function(t,e,i){if("*"==t)throw new Error("Cannot trigger event *");var o=[];t in this._subscribers&&(o=o.concat(this._subscribers[t])),"*"in this._subscribers&&(o=o.concat(this._subscribers["*"]));for(var n=0,s=o.length;n<s;n++){var r=o[n];r.callback&&r.callback(t,e,i||null)}},n.prototype.add=function(t,e){var i,o=[],n=this;if(Array.isArray(t))for(var s=0,r=t.length;s<r;s++)i=n._addItem(t[s]),o.push(i);else{if(!t||"object"!==(void 0===t?"undefined":(0,h.default)(t)))throw new Error("Unknown dataType");i=n._addItem(t),o.push(i)}return o.length&&this._trigger("add",{items:o},e),o},n.prototype.update=function(t,e){var i=[],o=[],n=[],s=[],r=this,a=r._fieldId,d=function(t){var e=t[a];if(r._data[e]){var h=u.extend({},r._data[e]);e=r._updateItem(t),o.push(e),s.push(t),n.push(h)}else e=r._addItem(t),i.push(e)};if(Array.isArray(t))for(var l=0,c=t.length;l<c;l++)t[l]&&"object"===(0,h.default)(t[l])?d(t[l]):console.warn("Ignoring input item, which is not an object at index "+l);else{if(!t||"object"!==(void 0===t?"undefined":(0,h.default)(t)))throw new Error("Unknown dataType");d(t)}if(i.length&&this._trigger("add",{items:i},e),o.length){var p={items:o,oldData:n,data:s};this._trigger("update",p,e)}return i.concat(o)},n.prototype.get=function(t){var e,i,o,n=this,s=u.getType(arguments[0]);"String"==s||"Number"==s?(e=arguments[0],o=arguments[1]):"Array"==s?(i=arguments[0],o=arguments[1]):o=arguments[0];var r;if(o&&o.returnType){r=-1==["Array","Object"].indexOf(o.returnType)?"Array":o.returnType}else r="Array";var a,h,d,c,p,f=o&&o.type||this._options.type,m=o&&o.filter,v=[];if(void 0!=e)(a=n._getItem(e,f))&&m&&!m(a)&&(a=null);else if(void 0!=i)for(c=0,p=i.length;c<p;c++)a=n._getItem(i[c],f),m&&!m(a)||v.push(a);else for(h=(0,l.default)(this._data),c=0,p=h.length;c<p;c++)d=h[c],a=n._getItem(d,f),m&&!m(a)||v.push(a);if(o&&o.order&&void 0==e&&this._sort(v,o.order),o&&o.fields){var g=o.fields;if(void 0!=e)a=this._filterFields(a,g);else for(c=0,p=v.length;c<p;c++)v[c]=this._filterFields(v[c],g)}if("Object"==r){var y,b={};for(c=0,p=v.length;c<p;c++)y=v[c],b[y.id]=y;return b}return void 0!=e?a:v},n.prototype.getIds=function(t){var e,i,o,n,s,r=this._data,a=t&&t.filter,h=t&&t.order,d=t&&t.type||this._options.type,u=(0,l.default)(r),c=[];if(a)if(h){for(s=[],e=0,i=u.length;e<i;e++)o=u[e],n=this._getItem(o,d),a(n)&&s.push(n);for(this._sort(s,h),e=0,i=s.length;e<i;e++)c.push(s[e][this._fieldId])}else for(e=0,i=u.length;e<i;e++)o=u[e],n=this._getItem(o,d),a(n)&&c.push(n[this._fieldId]);else if(h){for(s=[],e=0,i=u.length;e<i;e++)o=u[e],s.push(r[o]);for(this._sort(s,h),e=0,i=s.length;e<i;e++)c.push(s[e][this._fieldId])}else for(e=0,i=u.length;e<i;e++)o=u[e],n=r[o],c.push(n[this._fieldId]);return c},n.prototype.getDataSet=function(){return this},n.prototype.forEach=function(t,e){var i,o,n,s,r=e&&e.filter,a=e&&e.type||this._options.type,h=this._data,d=(0,l.default)(h);if(e&&e.order){var u=this.get(e);for(i=0,o=u.length;i<o;i++)n=u[i],s=n[this._fieldId],t(n,s)}else for(i=0,o=d.length;i<o;i++)s=d[i],n=this._getItem(s,a),r&&!r(n)||t(n,s)},n.prototype.map=function(t,e){var i,o,n,s,r=e&&e.filter,a=e&&e.type||this._options.type,h=[],d=this._data,u=(0,l.default)(d);for(i=0,o=u.length;i<o;i++)n=u[i],s=this._getItem(n,a),r&&!r(s)||h.push(t(s,n));return e&&e.order&&this._sort(h,e.order),h},n.prototype._filterFields=function(t,e){if(!t)return t;var i,o,n={},s=(0,l.default)(t),r=s.length;if(Array.isArray(e))for(i=0;i<r;i++)o=s[i],-1!=e.indexOf(o)&&(n[o]=t[o]);else for(i=0;i<r;i++)o=s[i],e.hasOwnProperty(o)&&(n[e[o]]=t[o]);return n},n.prototype._sort=function(t,e){if(u.isString(e)){var i=e;t.sort(function(t,e){var o=t[i],n=e[i];return o>n?1:o<n?-1:0})}else{if("function"!=typeof e)throw new TypeError("Order must be a function or a string");t.sort(e)}},n.prototype.remove=function(t,e){var i,o,n,s,r=[],a=[],h=[];for(h=Array.isArray(t)?t:[t],i=0,o=h.length;i<o;i++)(s=this._remove(h[i]))&&void 0!=(n=s[this._fieldId])&&(r.push(n),a.push(s));return r.length&&this._trigger("remove",{items:r,oldData:a},e),r},n.prototype._remove=function(t){var e,i;return u.isNumber(t)||u.isString(t)?i=t:t&&"object"===(void 0===t?"undefined":(0,h.default)(t))&&(i=t[this._fieldId]),void 0!==i&&this._data[i]?(e=this._data[i],delete this._data[i],this.length--,e):null},n.prototype.clear=function(t){var e,i,o=(0,l.default)(this._data),n=[];for(e=0,i=o.length;e<i;e++)n.push(this._data[o[e]]);return this._data={},this.length=0,this._trigger("remove",{items:o,oldData:n},t),o},n.prototype.max=function(t){var e,i,o=this._data,n=(0,l.default)(o),s=null,r=null;for(e=0,i=n.length;e<i;e++){var a=n[e],h=o[a],d=h[t];null!=d&&(!s||d>r)&&(s=h,r=d)}return s},n.prototype.min=function(t){var e,i,o=this._data,n=(0,l.default)(o),s=null,r=null;for(e=0,i=n.length;e<i;e++){var a=n[e],h=o[a],d=h[t];null!=d&&(!s||d<r)&&(s=h,r=d)}return s},n.prototype.distinct=function(t){var e,i,o,n=this._data,s=(0,l.default)(n),r=[],a=this._options.type&&this._options.type[t]||null,h=0;for(e=0,o=s.length;e<o;e++){var d=s[e],c=n[d],p=c[t],f=!1;for(i=0;i<h;i++)if(r[i]==p){f=!0;break}f||void 0===p||(r[h]=p,h++)}if(a)for(e=0,o=r.length;e<o;e++)r[e]=u.convert(r[e],a);return r},n.prototype._addItem=function(t){var e=t[this._fieldId];if(void 0!=e){if(this._data[e])throw new Error("Cannot add item: item with id "+e+" already exists")}else e=u.randomUUID(),t[this._fieldId]=e;var i,o,n={},s=(0,l.default)(t);for(i=0,o=s.length;i<o;i++){var r=s[i],a=this._type[r];n[r]=u.convert(t[r],a)}return this._data[e]=n,this.length++,e},n.prototype._getItem=function(t,e){var i,o,n,s,r=this._data[t];if(!r)return null;var a={},h=(0,l.default)(r);if(e)for(n=0,s=h.length;n<s;n++)i=h[n],o=r[i],a[i]=u.convert(o,e[i]);else for(n=0,s=h.length;n<s;n++)i=h[n],o=r[i],a[i]=o;return a[this._fieldId]||(a[this._fieldId]=r.id),a},n.prototype._updateItem=function(t){var e=t[this._fieldId];if(void 0==e)throw new Error("Cannot update item: item has no id (item: "+(0,r.default)(t)+")");var i=this._data[e];if(!i)throw new Error("Cannot update item: no item with id "+e+" found");for(var o=(0,l.default)(t),n=0,s=o.length;n<s;n++){var a=o[n],h=this._type[a];i[a]=u.convert(t[a],h)}return e},t.exports=n},function(t,e,i){function o(t,e){this._data=null,this._ids={},this.length=0,this._options=e||{},this._fieldId="id",this._subscribers={};var i=this;this.listener=function(){i._onEvent.apply(i,arguments)},this.setData(t)}var n=i(8),s=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(2),a=i(11);o.prototype.setData=function(t){var e,i,o,n,s;if(this._data){for(this._data.off&&this._data.off("*",this.listener),e=this._data.getIds({filter:this._options&&this._options.filter}),s=[],o=0,n=e.length;o<n;o++)s.push(this._data._data[e[o]]);this._ids={},this.length=0,this._trigger("remove",{items:e,oldData:s})}if(this._data=t,this._data){for(this._fieldId=this._options.fieldId||this._data&&this._data.options&&this._data.options.fieldId||"id",e=this._data.getIds({filter:this._options&&this._options.filter}),o=0,n=e.length;o<n;o++)i=e[o],this._ids[i]=!0;this.length=e.length,this._trigger("add",{items:e}),this._data.on&&this._data.on("*",this.listener)}},o.prototype.refresh=function(){var t,e,i,o=this._data.getIds({filter:this._options&&this._options.filter}),n=(0,s.default)(this._ids),r={},a=[],h=[],d=[];for(e=0,i=o.length;e<i;e++)t=o[e],r[t]=!0,this._ids[t]||(a.push(t),this._ids[t]=!0);for(e=0,i=n.length;e<i;e++)t=n[e],r[t]||(h.push(t),d.push(this._data._data[t]),delete this._ids[t]);this.length+=a.length-h.length,a.length&&this._trigger("add",{items:a}),h.length&&this._trigger("remove",{items:h,oldData:d})},o.prototype.get=function(t){var e,i,o,n=this,s=r.getType(arguments[0]);"String"==s||"Number"==s||"Array"==s?(e=arguments[0],i=arguments[1],o=arguments[2]):(i=arguments[0],o=arguments[1]);var a=r.extend({},this._options,i);this._options.filter&&i&&i.filter&&(a.filter=function(t){return n._options.filter(t)&&i.filter(t)});var h=[];return void 0!=e&&h.push(e),h.push(a),h.push(o),this._data&&this._data.get.apply(this._data,h)},o.prototype.getIds=function(t){var e;if(this._data){var i,o=this._options.filter;i=t&&t.filter?o?function(e){return o(e)&&t.filter(e)}:t.filter:o,e=this._data.getIds({filter:i,order:t&&t.order})}else e=[];return e},o.prototype.map=function(t,e){var i=[];if(this._data){var o,n=this._options.filter;o=e&&e.filter?n?function(t){return n(t)&&e.filter(t)}:e.filter:n,i=this._data.map(t,{filter:o,order:e&&e.order})}else i=[];return i},o.prototype.getDataSet=function(){for(var t=this;t instanceof o;)t=t._data;return t||null},o.prototype._onEvent=function(t,e,i){var o,n,s,r,a=e&&e.items,h=[],d=[],l=[],u=[],c=[],p=[];if(a&&this._data){switch(t){case"add":for(o=0,n=a.length;o<n;o++)s=a[o],(r=this.get(s))&&(this._ids[s]=!0,h.push(s));break;case"update":for(o=0,n=a.length;o<n;o++)s=a[o],r=this.get(s),r?this._ids[s]?(d.push(s),c.push(e.data[o]),u.push(e.oldData[o])):(this._ids[s]=!0,h.push(s)):this._ids[s]&&(delete this._ids[s],l.push(s),p.push(e.oldData[o]));break;case"remove":for(o=0,n=a.length;o<n;o++)s=a[o],this._ids[s]&&(delete this._ids[s],l.push(s),p.push(e.oldData[o]))}this.length+=h.length-l.length,h.length&&this._trigger("add",{items:h},i),d.length&&this._trigger("update",{items:d,oldData:u,data:c},i),l.length&&this._trigger("remove",{items:l,oldData:p},i)}},o.prototype.on=a.prototype.on,o.prototype.off=a.prototype.off,o.prototype._trigger=a.prototype._trigger,o.prototype.subscribe=o.prototype.on,o.prototype.unsubscribe=o.prototype.off,t.exports=o},function(t,e,i){var o=i(57)("wks"),n=i(40),s=i(18).Symbol,r="function"==typeof s;(t.exports=function(t){return o[t]||(o[t]=r&&s[t]||(r?s:n)("Symbol."+t))}).store=o},function(t,e,i){e.prepareElements=function(t){for(var e in t)t.hasOwnProperty(e)&&(t[e].redundant=t[e].used,t[e].used=[])},e.cleanupElements=function(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e].redundant){for(var i=0;i<t[e].redundant.length;i++)t[e].redundant[i].parentNode.removeChild(t[e].redundant[i]);t[e].redundant=[]}},e.resetElements=function(t){e.prepareElements(t),e.cleanupElements(t),e.prepareElements(t)},e.getSVGElement=function(t,e,i){var o;return e.hasOwnProperty(t)?e[t].redundant.length>0?(o=e[t].redundant[0],e[t].redundant.shift()):(o=document.createElementNS("http://www.w3.org/2000/svg",t),i.appendChild(o)):(o=document.createElementNS("http://www.w3.org/2000/svg",t),e[t]={used:[],redundant:[]},i.appendChild(o)),e[t].used.push(o),o},e.getDOMElement=function(t,e,i,o){var n;return e.hasOwnProperty(t)?e[t].redundant.length>0?(n=e[t].redundant[0],e[t].redundant.shift()):(n=document.createElement(t),void 0!==o?i.insertBefore(n,o):i.appendChild(n)):(n=document.createElement(t),e[t]={used:[],redundant:[]},void 0!==o?i.insertBefore(n,o):i.appendChild(n)),e[t].used.push(n),n},e.drawPoint=function(t,i,o,n,s,r){var a;if("circle"==o.style?(a=e.getSVGElement("circle",n,s),a.setAttributeNS(null,"cx",t),a.setAttributeNS(null,"cy",i),a.setAttributeNS(null,"r",.5*o.size)):(a=e.getSVGElement("rect",n,s),a.setAttributeNS(null,"x",t-.5*o.size),a.setAttributeNS(null,"y",i-.5*o.size),a.setAttributeNS(null,"width",o.size),a.setAttributeNS(null,"height",o.size)),void 0!==o.styles&&a.setAttributeNS(null,"style",o.styles),a.setAttributeNS(null,"class",o.className+" vis-point"),r){var h=e.getSVGElement("text",n,s);r.xOffset&&(t+=r.xOffset),r.yOffset&&(i+=r.yOffset),r.content&&(h.textContent=r.content),r.className&&h.setAttributeNS(null,"class",r.className+" vis-label"),h.setAttributeNS(null,"x",t),h.setAttributeNS(null,"y",i)}return a},e.drawBar=function(t,i,o,n,s,r,a,h){if(0!=n){n<0&&(n*=-1,i-=n);var d=e.getSVGElement("rect",r,a);d.setAttributeNS(null,"x",t-.5*o),d.setAttributeNS(null,"y",i),d.setAttributeNS(null,"width",o),d.setAttributeNS(null,"height",n),d.setAttributeNS(null,"class",s),h&&d.setAttributeNS(null,"style",h)}}},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.printStyle=void 0;var n=i(19),s=o(n),r=i(6),a=o(r),h=i(8),d=o(h),l=i(0),u=o(l),c=i(1),p=o(c),f=i(2),m=!1,v=void 0,g="background: #FFeeee; color: #dd0000",y=function(){function t(){(0,u.default)(this,t)}return(0,p.default)(t,null,[{key:"validate",value:function(e,i,o){m=!1,v=i;var n=i;return void 0!==o&&(n=i[o]),t.parse(e,n,[]),m}},{key:"parse",value:function(e,i,o){for(var n in e)e.hasOwnProperty(n)&&t.check(n,e,i,o)}},{key:"check",value:function(e,i,o,n){if(void 0===o[e]&&void 0===o.__any__)return void t.getSuggestion(e,o,n);var s=e,r=!0;void 0===o[e]&&void 0!==o.__any__&&(s="__any__",r="object"===t.getType(i[e]));var a=o[s];r&&void 0!==a.__type__&&(a=a.__type__),t.checkFields(e,i,o,s,a,n)}},{key:"checkFields",value:function(e,i,o,n,s,r){var a=function(i){console.log("%c"+i+t.printLocation(r,e),g)},h=t.getType(i[e]),l=s[h];void 0!==l?"array"===t.getType(l)&&-1===l.indexOf(i[e])?(a('Invalid option detected in "'+e+'". Allowed values are:'+t.print(l)+' not "'+i[e]+'". '),m=!0):"object"===h&&"__any__"!==n&&(r=f.copyAndExtendArray(r,e),t.parse(i[e],o[n],r)):void 0===s.any&&(a('Invalid type received for "'+e+'". Expected: '+t.print((0,d.default)(s))+". Received ["+h+'] "'+i[e]+'"'),m=!0)}},{key:"getType",value:function(t){var e=void 0===t?"undefined":(0,a.default)(t);return"object"===e?null===t?"null":t instanceof Boolean?"boolean":t instanceof Number?"number":t instanceof String?"string":Array.isArray(t)?"array":t instanceof Date?"date":void 0!==t.nodeType?"dom":!0===t._isAMomentObject?"moment":"object":"number"===e?"number":"boolean"===e?"boolean":"string"===e?"string":void 0===e?"undefined":e}},{key:"getSuggestion",value:function(e,i,o){var n=t.findInOptions(e,i,o,!1),s=t.findInOptions(e,v,[],!0),r=void 0 +;r=void 0!==n.indexMatch?" in "+t.printLocation(n.path,e,"")+'Perhaps it was incomplete? Did you mean: "'+n.indexMatch+'"?\n\n':s.distance<=4&&n.distance>s.distance?" in "+t.printLocation(n.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+t.printLocation(s.path,s.closestMatch,""):n.distance<=8?'. Did you mean "'+n.closestMatch+'"?'+t.printLocation(n.path,e):". Did you mean one of these: "+t.print((0,d.default)(i))+t.printLocation(o,e),console.log('%cUnknown option detected: "'+e+'"'+r,g),m=!0}},{key:"findInOptions",value:function(e,i,o){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=1e9,r="",a=[],h=e.toLowerCase(),d=void 0;for(var l in i){var u=void 0;if(void 0!==i[l].__type__&&!0===n){var c=t.findInOptions(e,i[l],f.copyAndExtendArray(o,l));s>c.distance&&(r=c.closestMatch,a=c.path,s=c.distance,d=c.indexMatch)}else-1!==l.toLowerCase().indexOf(h)&&(d=l),u=t.levenshteinDistance(e,l),s>u&&(r=l,a=f.copyArray(o),s=u)}return{closestMatch:r,path:a,distance:s,indexMatch:d}}},{key:"printLocation",value:function(t,e){for(var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Problem value found at: \n",o="\n\n"+i+"options = {\n",n=0;n<t.length;n++){for(var s=0;s<n+1;s++)o+=" ";o+=t[n]+": {\n"}for(var r=0;r<t.length+1;r++)o+=" ";o+=e+"\n";for(var a=0;a<t.length+1;a++){for(var h=0;h<t.length-a;h++)o+=" ";o+="}\n"}return o+"\n\n"}},{key:"print",value:function(t){return(0,s.default)(t).replace(/(\")|(\[)|(\])|(,"__type__")/g,"").replace(/(\,)/g,", ")}},{key:"levenshteinDistance",value:function(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;var i,o=[];for(i=0;i<=e.length;i++)o[i]=[i];var n;for(n=0;n<=t.length;n++)o[0][n]=n;for(i=1;i<=e.length;i++)for(n=1;n<=t.length;n++)e.charAt(i-1)==t.charAt(n-1)?o[i][n]=o[i-1][n-1]:o[i][n]=Math.min(o[i-1][n-1]+1,Math.min(o[i][n-1]+1,o[i-1][n]+1));return o[e.length][t.length]}}]),t}();e.default=y,e.printStyle=g},function(t,e,i){function o(t,e){this.options=null,this.props=null}var n=i(2);o.prototype.setOptions=function(t){t&&n.extend(this.options,t)},o.prototype.redraw=function(){return!1},o.prototype.destroy=function(){},o.prototype._isResized=function(){var t=this.props._previousWidth!==this.props.width||this.props._previousHeight!==this.props.height;return this.props._previousWidth=this.props.width,this.props._previousHeight=this.props.height,t},t.exports=o},function(t,e,i){var o=i(18),n=i(7),s=i(80),r=i(26),a=function(t,e,i){var h,d,l,u=t&a.F,c=t&a.G,p=t&a.S,f=t&a.P,m=t&a.B,v=t&a.W,g=c?n:n[e]||(n[e]={}),y=g.prototype,b=c?o:p?o[e]:(o[e]||{}).prototype;c&&(i=e);for(h in i)(d=!u&&b&&void 0!==b[h])&&h in g||(l=d?b[h]:i[h],g[h]=c&&"function"!=typeof b[h]?i[h]:m&&d?s(l,o):v&&b[h]==l?function(t){var e=function(e,i,o){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,i)}return new t(e,i,o)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(l):f&&"function"==typeof l?s(Function.call,l):l,f&&((g.virtual||(g.virtual={}))[h]=l,t&a.R&&y&&!y[h]&&r(y,h,l)))};a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},function(t,e){var i=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=i)},function(t,e,i){t.exports={default:i(160),__esModule:!0}},function(t,e,i){var o=i(27),n=i(81),s=i(53),r=Object.defineProperty;e.f=i(21)?Object.defineProperty:function(t,e,i){if(o(t),e=s(e,!0),o(i),n)try{return r(t,e,i)}catch(t){}if("get"in i||"set"in i)throw TypeError("Accessors not supported!");return"value"in i&&(t[e]=i.value),t}},function(t,e,i){t.exports=!i(28)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){var i={}.hasOwnProperty;t.exports=function(t,e){return i.call(t,e)}},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(6),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=function(){function t(e,i,o){(0,a.default)(this,t),this.body=i,this.labelModule=o,this.setOptions(e),this.top=void 0,this.left=void 0,this.height=void 0,this.width=void 0,this.radius=void 0,this.margin=void 0,this.refreshNeeded=!0,this.boundingBox={top:0,left:0,right:0,bottom:0}}return(0,d.default)(t,[{key:"setOptions",value:function(t){this.options=t}},{key:"_setMargins",value:function(t){this.margin={},this.options.margin&&("object"==(0,s.default)(this.options.margin)?(this.margin.top=this.options.margin.top,this.margin.right=this.options.margin.right,this.margin.bottom=this.options.margin.bottom,this.margin.left=this.options.margin.left):(this.margin.top=this.options.margin,this.margin.right=this.options.margin,this.margin.bottom=this.options.margin,this.margin.left=this.options.margin)),t.adjustSizes(this.margin)}},{key:"_distanceToBorder",value:function(t,e){var i=this.options.borderWidth;return this.resize(t),Math.min(Math.abs(this.width/2/Math.cos(e)),Math.abs(this.height/2/Math.sin(e)))+i}},{key:"enableShadow",value:function(t,e){e.shadow&&(t.shadowColor=e.shadowColor,t.shadowBlur=e.shadowSize,t.shadowOffsetX=e.shadowX,t.shadowOffsetY=e.shadowY)}},{key:"disableShadow",value:function(t,e){e.shadow&&(t.shadowColor="rgba(0,0,0,0)",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0)}},{key:"enableBorderDashes",value:function(t,e){if(!1!==e.borderDashes)if(void 0!==t.setLineDash){var i=e.borderDashes;!0===i&&(i=[5,15]),t.setLineDash(i)}else console.warn("setLineDash is not supported in this browser. The dashed borders cannot be used."),this.options.shapeProperties.borderDashes=!1,e.borderDashes=!1}},{key:"disableBorderDashes",value:function(t,e){!1!==e.borderDashes&&(void 0!==t.setLineDash?t.setLineDash([0]):(console.warn("setLineDash is not supported in this browser. The dashed borders cannot be used."),this.options.shapeProperties.borderDashes=!1,e.borderDashes=!1))}},{key:"needsRefresh",value:function(t,e){return!0===this.refreshNeeded?(this.refreshNeeded=!1,!0):void 0===this.width||this.labelModule.differentState(t,e)}},{key:"initContextForDraw",value:function(t,e){var i=e.borderWidth/this.body.view.scale;t.lineWidth=Math.min(this.width,i),t.strokeStyle=e.borderColor,t.fillStyle=e.color}},{key:"performStroke",value:function(t,e){var i=e.borderWidth/this.body.view.scale;t.save(),i>0&&(this.enableBorderDashes(t,e),t.stroke(),this.disableBorderDashes(t,e)),t.restore()}},{key:"performFill",value:function(t,e){this.enableShadow(t,e),t.fill(),this.disableShadow(t,e),this.performStroke(t,e)}},{key:"_addBoundingBoxMargin",value:function(t){this.boundingBox.left-=t,this.boundingBox.top-=t,this.boundingBox.bottom+=t,this.boundingBox.right+=t}},{key:"_updateBoundingBox",value:function(t,e,i,o,n){void 0!==i&&this.resize(i,o,n),this.left=t-this.width/2,this.top=e-this.height/2,this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width}},{key:"updateBoundingBox",value:function(t,e,i,o,n){this._updateBoundingBox(t,e,i,o,n)}},{key:"getDimensionsFromLabel",value:function(t,e,i){this.textSize=this.labelModule.getTextSize(t,e,i);var o=this.textSize.width,n=this.textSize.height;return 0===o&&(o=14,n=14),{width:o,height:n}}}]),t}();e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(23),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"resize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{size:this.options.size};if(this.needsRefresh(e,i)){this.labelModule.getTextSize(t,e,i);var n=2*o.size;this.width=n,this.height=n,this.radius=.5*this.width}}},{key:"_drawShape",value:function(t,e,i,o,n,s,r,a){if(this.resize(t,s,r,a),this.left=o-this.width/2,this.top=n-this.height/2,this.initContextForDraw(t,a),t[e](o,n,a.size),this.performFill(t,a),void 0!==this.options.label){this.labelModule.calculateLabelSize(t,s,r,o,n,"hanging");var h=n+.5*this.height+.5*this.labelModule.size.height;this.labelModule.draw(t,o,h,s,r,"hanging")}this.updateBoundingBox(o,n)}},{key:"updateBoundingBox",value:function(t,e){this.boundingBox.top=e-this.options.size,this.boundingBox.left=t-this.options.size,this.boundingBox.right=t+this.options.size,this.boundingBox.bottom=e+this.options.size,void 0!==this.options.label&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height))}}]),e}(m.default);e.default=v},function(t,e,i){var o=i(78),n=i(51);t.exports=function(t){return o(n(t))}},function(t,e,i){var o=i(20),n=i(39);t.exports=i(21)?function(t,e,i){return o.f(t,e,n(1,i))}:function(t,e,i){return t[e]=i,t}},function(t,e,i){var o=i(32);t.exports=function(t){if(!o(t))throw TypeError(t+" is not an object!");return t}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e,i){t.exports={default:i(138),__esModule:!0}},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var n=i(188),s=o(n),r=i(77),a=o(r);e.default=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,h=(0,a.default)(t);!(o=(r=h.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(t){n=!0,s=t}finally{try{!o&&h.return&&h.return()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if((0,s.default)(Object(e)))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}()},function(t,e){t.exports={}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,i){var o=i(84),n=i(58);t.exports=Object.keys||function(t){return o(t,n)}},function(t,e,i){function o(t,e,i){this.x=void 0!==t?t:0,this.y=void 0!==e?e:0,this.z=void 0!==i?i:0}o.subtract=function(t,e){var i=new o;return i.x=t.x-e.x,i.y=t.y-e.y,i.z=t.z-e.z,i},o.add=function(t,e){var i=new o;return i.x=t.x+e.x,i.y=t.y+e.y,i.z=t.z+e.z,i},o.avg=function(t,e){return new o((t.x+e.x)/2,(t.y+e.y)/2,(t.z+e.z)/2)},o.crossProduct=function(t,e){var i=new o;return i.x=t.y*e.z-t.z*e.y,i.y=t.z*e.x-t.x*e.z,i.z=t.x*e.y-t.y*e.x,i},o.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},t.exports=o},function(t,e,i){var o,n,s;!function(i,r){n=[],o=r,void 0!==(s="function"==typeof o?o.apply(e,n):o)&&(t.exports=s)}(0,function(){function t(t){var e,i=t&&t.preventDefault||!1,o=t&&t.container||window,n={},s={keydown:{},keyup:{}},r={};for(e=97;e<=122;e++)r[String.fromCharCode(e)]={code:e-97+65,shift:!1};for(e=65;e<=90;e++)r[String.fromCharCode(e)]={code:e,shift:!0};for(e=0;e<=9;e++)r[""+e]={code:48+e,shift:!1};for(e=1;e<=12;e++)r["F"+e]={code:111+e,shift:!1};for(e=0;e<=9;e++)r["num"+e]={code:96+e,shift:!1};r["num*"]={code:106,shift:!1},r["num+"]={code:107,shift:!1},r["num-"]={code:109,shift:!1},r["num/"]={code:111,shift:!1},r["num."]={code:110,shift:!1},r.left={code:37,shift:!1},r.up={code:38,shift:!1},r.right={code:39,shift:!1},r.down={code:40,shift:!1},r.space={code:32,shift:!1},r.enter={code:13,shift:!1},r.shift={code:16,shift:void 0},r.esc={code:27,shift:!1},r.backspace={code:8,shift:!1},r.tab={code:9,shift:!1},r.ctrl={code:17,shift:!1},r.alt={code:18,shift:!1},r.delete={code:46,shift:!1},r.pageup={code:33,shift:!1},r.pagedown={code:34,shift:!1},r["="]={code:187,shift:!1},r["-"]={code:189,shift:!1},r["]"]={code:221,shift:!1},r["["]={code:219,shift:!1};var a=function(t){d(t,"keydown")},h=function(t){d(t,"keyup")},d=function(t,e){if(void 0!==s[e][t.keyCode]){for(var o=s[e][t.keyCode],n=0;n<o.length;n++)void 0===o[n].shift?o[n].fn(t):1==o[n].shift&&1==t.shiftKey?o[n].fn(t):0==o[n].shift&&0==t.shiftKey&&o[n].fn(t);1==i&&t.preventDefault()}};return n.bind=function(t,e,i){if(void 0===i&&(i="keydown"),void 0===r[t])throw new Error("unsupported key: "+t);void 0===s[i][r[t].code]&&(s[i][r[t].code]=[]),s[i][r[t].code].push({fn:e,shift:r[t].shift})},n.bindAll=function(t,e){void 0===e&&(e="keydown");for(var i in r)r.hasOwnProperty(i)&&n.bind(i,t,e)},n.getKey=function(t){for(var e in r)if(r.hasOwnProperty(e)){if(1==t.shiftKey&&1==r[e].shift&&t.keyCode==r[e].code)return e;if(0==t.shiftKey&&0==r[e].shift&&t.keyCode==r[e].code)return e;if(t.keyCode==r[e].code&&"shift"==e)return e}return"unknown key, currently not supported"},n.unbind=function(t,e,i){if(void 0===i&&(i="keydown"),void 0===r[t])throw new Error("unsupported key: "+t);if(void 0!==e){var o=[],n=s[i][r[t].code];if(void 0!==n)for(var a=0;a<n.length;a++)n[a].fn==e&&n[a].shift==r[t].shift||o.push(s[i][r[t].code][a]);s[i][r[t].code]=o}else s[i][r[t].code]=[]},n.reset=function(){s={keydown:{},keyup:{}}},n.destroy=function(){s={keydown:{},keyup:{}},o.removeEventListener("keydown",a,!0),o.removeEventListener("keyup",h,!0)},o.addEventListener("keydown",a,!0),o.addEventListener("keyup",h,!0),n}return t})},function(t,e,i){e.convertHiddenOptions=function(t,i,o){if(o&&!Array.isArray(o))return e.convertHiddenOptions(t,i,[o]);if(i.hiddenDates=[],o&&1==Array.isArray(o)){for(var n=0;n<o.length;n++)if(void 0===o[n].repeat){var s={};s.start=t(o[n].start).toDate().valueOf(),s.end=t(o[n].end).toDate().valueOf(),i.hiddenDates.push(s)}i.hiddenDates.sort(function(t,e){return t.start-e.start})}},e.updateHiddenDates=function(t,i,o){if(o&&!Array.isArray(o))return e.updateHiddenDates(t,i,[o]);if(o&&void 0!==i.domProps.centerContainer.width){e.convertHiddenOptions(t,i,o);for(var n=t(i.range.start),s=t(i.range.end),r=i.range.end-i.range.start,a=r/i.domProps.centerContainer.width,h=0;h<o.length;h++)if(void 0!==o[h].repeat){var d=t(o[h].start),l=t(o[h].end);if("Invalid Date"==d._d)throw new Error("Supplied start date is not valid: "+o[h].start);if("Invalid Date"==l._d)throw new Error("Supplied end date is not valid: "+o[h].end);var u=l-d;if(u>=4*a){var c=0,p=s.clone();switch(o[h].repeat){case"daily":d.day()!=l.day()&&(c=1),d.dayOfYear(n.dayOfYear()),d.year(n.year()),d.subtract(7,"days"),l.dayOfYear(n.dayOfYear()),l.year(n.year()),l.subtract(7-c,"days"),p.add(1,"weeks");break;case"weekly":var f=l.diff(d,"days"),m=d.day();d.date(n.date()),d.month(n.month()),d.year(n.year()),l=d.clone(),d.day(m),l.day(m),l.add(f,"days"),d.subtract(1,"weeks"),l.subtract(1,"weeks"),p.add(1,"weeks");break;case"monthly":d.month()!=l.month()&&(c=1),d.month(n.month()),d.year(n.year()),d.subtract(1,"months"),l.month(n.month()),l.year(n.year()),l.subtract(1,"months"),l.add(c,"months"),p.add(1,"months");break;case"yearly":d.year()!=l.year()&&(c=1),d.year(n.year()),d.subtract(1,"years"),l.year(n.year()),l.subtract(1,"years"),l.add(c,"years"),p.add(1,"years");break;default:return void console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:",o[h].repeat)}for(;d<p;)switch(i.hiddenDates.push({start:d.valueOf(),end:l.valueOf()}),o[h].repeat){case"daily":d.add(1,"days"),l.add(1,"days");break;case"weekly":d.add(1,"weeks"),l.add(1,"weeks");break;case"monthly":d.add(1,"months"),l.add(1,"months");break;case"yearly":d.add(1,"y"),l.add(1,"y");break;default:return void console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:",o[h].repeat)}i.hiddenDates.push({start:d.valueOf(),end:l.valueOf()})}}e.removeDuplicates(i);var v=e.isHidden(i.range.start,i.hiddenDates),g=e.isHidden(i.range.end,i.hiddenDates),y=i.range.start,b=i.range.end;1==v.hidden&&(y=1==i.range.startToFront?v.startDate-1:v.endDate+1),1==g.hidden&&(b=1==i.range.endToFront?g.startDate-1:g.endDate+1),1!=v.hidden&&1!=g.hidden||i.range._applyRange(y,b)}},e.removeDuplicates=function(t){for(var e=t.hiddenDates,i=[],o=0;o<e.length;o++)for(var n=0;n<e.length;n++)o!=n&&1!=e[n].remove&&1!=e[o].remove&&(e[n].start>=e[o].start&&e[n].end<=e[o].end?e[n].remove=!0:e[n].start>=e[o].start&&e[n].start<=e[o].end?(e[o].end=e[n].end,e[n].remove=!0):e[n].end>=e[o].start&&e[n].end<=e[o].end&&(e[o].start=e[n].start,e[n].remove=!0));for(o=0;o<e.length;o++)!0!==e[o].remove&&i.push(e[o]);t.hiddenDates=i,t.hiddenDates.sort(function(t,e){return t.start-e.start})},e.printDates=function(t){for(var e=0;e<t.length;e++)console.log(e,new Date(t[e].start),new Date(t[e].end),t[e].start,t[e].end,t[e].remove)},e.stepOverHiddenDates=function(t,e,i){for(var o=!1,n=e.current.valueOf(),s=0;s<e.hiddenDates.length;s++){var r=e.hiddenDates[s].start,a=e.hiddenDates[s].end;if(n>=r&&n<a){o=!0;break}}if(1==o&&n<e._end.valueOf()&&n!=i){var h=t(i),d=t(a);h.year()!=d.year()?e.switchedYear=!0:h.month()!=d.month()?e.switchedMonth=!0:h.dayOfYear()!=d.dayOfYear()&&(e.switchedDay=!0),e.current=d}},e.toScreen=function(t,i,o){var n;if(0==t.body.hiddenDates.length)return n=t.range.conversion(o),(i.valueOf()-n.offset)*n.scale;var s=e.isHidden(i,t.body.hiddenDates);1==s.hidden&&(i=s.startDate);var r=e.getHiddenDurationBetween(t.body.hiddenDates,t.range.start,t.range.end);if(i<t.range.start){n=t.range.conversion(o,r);var a=e.getHiddenDurationBeforeStart(t.body.hiddenDates,i,n.offset);return i=t.options.moment(i).toDate().valueOf(),i+=a,-(n.offset-i.valueOf())*n.scale}if(i>t.range.end){var h={start:t.range.start,end:i};return i=e.correctTimeForHidden(t.options.moment,t.body.hiddenDates,h,i),n=t.range.conversion(o,r),(i.valueOf()-n.offset)*n.scale}return i=e.correctTimeForHidden(t.options.moment,t.body.hiddenDates,t.range,i),n=t.range.conversion(o,r),(i.valueOf()-n.offset)*n.scale},e.toTime=function(t,i,o){if(0==t.body.hiddenDates.length){var n=t.range.conversion(o);return new Date(i/n.scale+n.offset)}var s=e.getHiddenDurationBetween(t.body.hiddenDates,t.range.start,t.range.end),r=t.range.end-t.range.start-s,a=r*i/o,h=e.getAccumulatedHiddenDuration(t.body.hiddenDates,t.range,a);return new Date(h+a+t.range.start)},e.getHiddenDurationBetween=function(t,e,i){for(var o=0,n=0;n<t.length;n++){var s=t[n].start,r=t[n].end;s>=e&&r<i&&(o+=r-s)}return o},e.getHiddenDurationBeforeStart=function(t,e,i){for(var o=0,n=0;n<t.length;n++){var s=t[n].start,r=t[n].end;s>=e&&r<=i&&(o+=r-s)}return o},e.correctTimeForHidden=function(t,i,o,n){return n=t(n).toDate().valueOf(),n-=e.getHiddenDurationBefore(t,i,o,n)},e.getHiddenDurationBefore=function(t,e,i,o){var n=0;o=t(o).toDate().valueOf();for(var s=0;s<e.length;s++){var r=e[s].start,a=e[s].end;r>=i.start&&a<i.end&&o>=a&&(n+=a-r)}return n},e.getAccumulatedHiddenDuration=function(t,e,i){for(var o=0,n=0,s=e.start,r=0;r<t.length;r++){var a=t[r].start,h=t[r].end;if(a>=e.start&&h<e.end){if(n+=a-s,s=h,n>=i)break;o+=h-a}}return o},e.snapAwayFromHidden=function(t,i,o,n){var s=e.isHidden(i,t);return 1==s.hidden?o<0?1==n?s.startDate-(s.endDate-i)-1:s.startDate-1:1==n?s.endDate+(i-s.startDate)+1:s.endDate+1:i},e.isHidden=function(t,e){for(var i=0;i<e.length;i++){var o=e[i].start,n=e[i].end;if(t>=o&&t<n)return{hidden:!0,startDate:o,endDate:n}}return{hidden:!1,startDate:o,endDate:n}}},function(t,e,i){e.onTouch=function(t,e){e.inputHandler=function(t){t.isFirst&&e(t)},t.on("hammer.input",e.inputHandler)},e.onRelease=function(t,e){return e.inputHandler=function(t){t.isFinal&&e(t)},t.on("hammer.input",e.inputHandler)},e.offTouch=function(t,e){t.off("hammer.input",e.inputHandler)},e.offRelease=e.offTouch,e.disablePreventDefaultVertically=function(t){return t.getTouchAction=function(){return["pan-y"]},t}},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e,i){this.id=null,this.parent=null,this.data=t,this.dom=null,this.conversion=e||{},this.options=i||{},this.selected=!1,this.displayed=!1,this.groupShowing=!0,this.dirty=!0,this.top=null,this.right=null,this.left=null,this.width=null,this.height=null,this.editable=null,this._updateEditStatus()}var s=i(6),r=o(s),a=i(8),h=o(a),d=i(10),l=i(2),u=i(9);n.prototype.stack=!0,n.prototype.select=function(){this.selected=!0,this.dirty=!0,this.displayed&&this.redraw()},n.prototype.unselect=function(){this.selected=!1,this.dirty=!0,this.displayed&&this.redraw()},n.prototype.setData=function(t){void 0!=t.group&&this.data.group!=t.group&&null!=this.parent&&this.parent.itemSet._moveToGroup(this,t.group),this.parent&&(this.parent.stackDirty=!0),void 0!=t.subgroup&&this.data.subgroup!=t.subgroup&&null!=this.parent&&this.parent.changeSubgroup(this,this.data.subgroup,t.subgroup),this.data=t,this._updateEditStatus(),this.dirty=!0,this.displayed&&this.redraw()},n.prototype.setParent=function(t){this.displayed?(this.hide(),this.parent=t,this.parent&&this.show()):this.parent=t},n.prototype.isVisible=function(t){return!1},n.prototype.show=function(){return!1},n.prototype.hide=function(){return!1},n.prototype.redraw=function(){},n.prototype.repositionX=function(){},n.prototype.repositionY=function(){},n.prototype._repaintDragCenter=function(){if(this.selected&&this.options.editable.updateTime&&!this.dom.dragCenter){var t=this,e=document.createElement("div");e.className="vis-drag-center",e.dragCenterItem=this;var i=new d(e);i.on("tap",function(e){t.parent.itemSet.body.emitter.emit("click",{event:e,item:t.id})}),i.on("doubletap",function(e){e.stopPropagation(),t.parent.itemSet._onUpdateItem(t),t.parent.itemSet.body.emitter.emit("doubleClick",{event:e,item:t.id})}),this.dom.box?this.dom.dragLeft?this.dom.box.insertBefore(e,this.dom.dragLeft):this.dom.box.appendChild(e):this.dom.point&&this.dom.point.appendChild(e),this.dom.dragCenter=e}else!this.selected&&this.dom.dragCenter&&(this.dom.dragCenter.parentNode&&this.dom.dragCenter.parentNode.removeChild(this.dom.dragCenter),this.dom.dragCenter=null)},n.prototype._repaintDeleteButton=function(t){var e=(this.options.editable.overrideItems||null==this.editable)&&this.options.editable.remove||!this.options.editable.overrideItems&&null!=this.editable&&this.editable.remove;if(this.selected&&e&&!this.dom.deleteButton){var i=this,o=document.createElement("div");this.options.rtl?o.className="vis-delete-rtl":o.className="vis-delete",o.title="Delete this item",new d(o).on("tap",function(t){t.stopPropagation(),i.parent.removeFromDataSet(i)}),t.appendChild(o),this.dom.deleteButton=o}else!this.selected&&this.dom.deleteButton&&(this.dom.deleteButton.parentNode&&this.dom.deleteButton.parentNode.removeChild(this.dom.deleteButton),this.dom.deleteButton=null)},n.prototype._repaintOnItemUpdateTimeTooltip=function(t){if(this.options.tooltipOnItemUpdateTime){var e=(this.options.editable.updateTime||!0===this.data.editable)&&!1!==this.data.editable;if(this.selected&&e&&!this.dom.onItemUpdateTimeTooltip){var i=document.createElement("div");i.className="vis-onUpdateTime-tooltip",t.appendChild(i),this.dom.onItemUpdateTimeTooltip=i}else!this.selected&&this.dom.onItemUpdateTimeTooltip&&(this.dom.onItemUpdateTimeTooltip.parentNode&&this.dom.onItemUpdateTimeTooltip.parentNode.removeChild(this.dom.onItemUpdateTimeTooltip),this.dom.onItemUpdateTimeTooltip=null);if(this.dom.onItemUpdateTimeTooltip){this.dom.onItemUpdateTimeTooltip.style.visibility=this.parent.itemSet.touchParams.itemIsDragging?"visible":"hidden",this.options.rtl?this.dom.onItemUpdateTimeTooltip.style.right=this.dom.content.style.right:this.dom.onItemUpdateTimeTooltip.style.left=this.dom.content.style.left;var o,n=this.parent.itemSet.body.domProps.scrollTop;o="top"==this.options.orientation.item?this.top:this.parent.height-this.top-this.height;o+this.parent.top-50<-n?(this.dom.onItemUpdateTimeTooltip.style.bottom="",this.dom.onItemUpdateTimeTooltip.style.top=this.height+2+"px"):(this.dom.onItemUpdateTimeTooltip.style.top="",this.dom.onItemUpdateTimeTooltip.style.bottom=this.height+2+"px");var s,r;this.options.tooltipOnItemUpdateTime&&this.options.tooltipOnItemUpdateTime.template?(r=this.options.tooltipOnItemUpdateTime.template.bind(this),s=r(this.data)):(s="start: "+u(this.data.start).format("MM/DD/YYYY hh:mm"),this.data.end&&(s+="<br> end: "+u(this.data.end).format("MM/DD/YYYY hh:mm"))),this.dom.onItemUpdateTimeTooltip.innerHTML=s}}},n.prototype._updateContents=function(t){var e,i,o,n,s=this.parent.itemSet.itemsData.get(this.id),r=this.dom.box||this.dom.point,a=r.getElementsByClassName("vis-item-visible-frame")[0];if(this.options.visibleFrameTemplate?(n=this.options.visibleFrameTemplate.bind(this),o=n(s,r)):o="",a)if(o instanceof Object&&!(o instanceof Element))n(s,a);else if(this._contentToString(this.itemVisibleFrameContent)!==this._contentToString(o)){if(o instanceof Element)a.innerHTML="",a.appendChild(o);else if(void 0!=o)a.innerHTML=o;else if("background"!=this.data.type||void 0!==this.data.content)throw new Error('Property "content" missing in item '+this.id);this.itemVisibleFrameContent=o}if(this.options.template?(i=this.options.template.bind(this),e=i(s,t,this.data)):e=this.data.content,e instanceof Object&&!(e instanceof Element))i(s,t);else if(this._contentToString(this.content)!==this._contentToString(e)){if(e instanceof Element)t.innerHTML="",t.appendChild(e);else if(void 0!=e)t.innerHTML=e;else if("background"!=this.data.type||void 0!==this.data.content)throw new Error('Property "content" missing in item '+this.id);this.content=e}},n.prototype._updateDataAttributes=function(t){if(this.options.dataAttributes&&this.options.dataAttributes.length>0){var e=[];if(Array.isArray(this.options.dataAttributes))e=this.options.dataAttributes;else{if("all"!=this.options.dataAttributes)return;e=(0,h.default)(this.data)}for(var i=0;i<e.length;i++){var o=e[i],n=this.data[o];null!=n?t.setAttribute("data-"+o,n):t.removeAttribute("data-"+o)}}},n.prototype._updateStyle=function(t){this.style&&(l.removeCssText(t,this.style),this.style=null),this.data.style&&(l.addCssText(t,this.data.style),this.style=this.data.style)},n.prototype._contentToString=function(t){return"string"==typeof t?t:t&&"outerHTML"in t?t.outerHTML:t},n.prototype._updateEditStatus=function(){this.options&&("boolean"==typeof this.options.editable?this.editable={updateTime:this.options.editable,updateGroup:this.options.editable,remove:this.options.editable}:"object"===(0,r.default)(this.options.editable)&&(this.editable={},l.selectiveExtend(["updateTime","updateGroup","remove"],this.editable,this.options.editable))),this.options&&this.options.editable&&!0===this.options.editable.overrideItems||this.data&&("boolean"==typeof this.data.editable?this.editable={updateTime:this.data.editable,updateGroup:this.data.editable,remove:this.data.editable}:"object"===(0,r.default)(this.data.editable)&&(this.editable={},l.selectiveExtend(["updateTime","updateGroup","remove"],this.editable,this.data.editable)))},n.prototype.getWidthLeft=function(){return 0},n.prototype.getWidthRight=function(){return 0},n.prototype.getTitle=function(){return this.data.title},t.exports=n},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e){var i=0,o=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++i+o).toString(36))}},function(t,e,i){var o=i(51);t.exports=function(t){return Object(o(t))}},function(t,e){e.f={}.propertyIsEnumerable},function(t,e,i){function o(t){this.delay=null,this.max=1/0,this._queue=[],this._timeout=null,this._extended=null,this.setOptions(t)}o.prototype.setOptions=function(t){t&&void 0!==t.delay&&(this.delay=t.delay),t&&void 0!==t.max&&(this.max=t.max),this._flushIfNeeded()},o.extend=function(t,e){var i=new o(e);if(void 0!==t.flush)throw new Error("Target object already has a property flush");t.flush=function(){i.flush()};var n=[{name:"flush",original:void 0}];if(e&&e.replace)for(var s=0;s<e.replace.length;s++){var r=e.replace[s];n.push({name:r,original:t[r]}),i.replace(t,r)}return i._extended={object:t,methods:n},i},o.prototype.destroy=function(){if(this.flush(),this._extended){for(var t=this._extended.object,e=this._extended.methods,i=0;i<e.length;i++){var o=e[i];o.original?t[o.name]=o.original:delete t[o.name]}this._extended=null}},o.prototype.replace=function(t,e){var i=this,o=t[e];if(!o)throw new Error("Method "+e+" undefined");t[e]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];i.queue({args:t,fn:o,context:this})}},o.prototype.queue=function(t){"function"==typeof t?this._queue.push({fn:t}):this._queue.push(t),this._flushIfNeeded()},o.prototype._flushIfNeeded=function(){if(this._queue.length>this.max&&this.flush(),clearTimeout(this._timeout),this.queue.length>0&&"number"==typeof this.delay){var t=this;this._timeout=setTimeout(function(){t.flush()},this.delay)}},o.prototype.flush=function(){for(;this._queue.length>0;){var t=this._queue.shift();t.fn.apply(t.context||t.fn,t.args||[])}},t.exports=o},function(t,e){function i(t){if(t)return o(t)}function o(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}t.exports=i,i.prototype.on=i.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},i.prototype.once=function(t,e){function i(){o.off(t,i),e.apply(this,arguments)}var o=this;return this._callbacks=this._callbacks||{},i.fn=e,this.on(t,i),this},i.prototype.off=i.prototype.removeListener=i.prototype.removeAllListeners=i.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i=this._callbacks[t];if(!i)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var o,n=0;n<i.length;n++)if((o=i[n])===e||o.fn===e){i.splice(n,1);break}return this},i.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),i=this._callbacks[t];if(i){i=i.slice(0);for(var o=0,n=i.length;o<n;++o)i[o].apply(this,e)}return this},i.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},i.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,i){function o(t,e){this.dom={foreground:null,lines:[],majorTexts:[],minorTexts:[],redundant:{lines:[],majorTexts:[],minorTexts:[]}},this.props={range:{start:0,end:0,minimumStep:0},lineTop:0},this.defaultOptions={orientation:{axis:"bottom"},showMinorLabels:!0,showMajorLabels:!0,maxMinorChars:7,format:h.FORMAT,moment:l,timeAxis:null},this.options=r.extend({},this.defaultOptions),this.body=t,this._create(),this.setOptions(e)}var n=i(6),s=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(2),a=i(16),h=i(66),d=i(36),l=i(9);o.prototype=new a,o.prototype.setOptions=function(t){t&&(r.selectiveExtend(["showMinorLabels","showMajorLabels","maxMinorChars","hiddenDates","timeAxis","moment","rtl"],this.options,t),r.selectiveDeepExtend(["format"],this.options,t),"orientation"in t&&("string"==typeof t.orientation?this.options.orientation.axis=t.orientation:"object"===(0,s.default)(t.orientation)&&"axis"in t.orientation&&(this.options.orientation.axis=t.orientation.axis)),"locale"in t&&("function"==typeof l.locale?l.locale(t.locale):l.lang(t.locale)))},o.prototype._create=function(){this.dom.foreground=document.createElement("div"),this.dom.background=document.createElement("div"),this.dom.foreground.className="vis-time-axis vis-foreground",this.dom.background.className="vis-time-axis vis-background"},o.prototype.destroy=function(){this.dom.foreground.parentNode&&this.dom.foreground.parentNode.removeChild(this.dom.foreground),this.dom.background.parentNode&&this.dom.background.parentNode.removeChild(this.dom.background),this.body=null},o.prototype.redraw=function(){var t=this.props,e=this.dom.foreground,i=this.dom.background,o="top"==this.options.orientation.axis?this.body.dom.top:this.body.dom.bottom,n=e.parentNode!==o;this._calculateCharSize() +;var s=this.options.showMinorLabels&&"none"!==this.options.orientation.axis,r=this.options.showMajorLabels&&"none"!==this.options.orientation.axis;t.minorLabelHeight=s?t.minorCharHeight:0,t.majorLabelHeight=r?t.majorCharHeight:0,t.height=t.minorLabelHeight+t.majorLabelHeight,t.width=e.offsetWidth,t.minorLineHeight=this.body.domProps.root.height-t.majorLabelHeight-("top"==this.options.orientation.axis?this.body.domProps.bottom.height:this.body.domProps.top.height),t.minorLineWidth=1,t.majorLineHeight=t.minorLineHeight+t.majorLabelHeight,t.majorLineWidth=1;var a=e.nextSibling,h=i.nextSibling;return e.parentNode&&e.parentNode.removeChild(e),i.parentNode&&i.parentNode.removeChild(i),e.style.height=this.props.height+"px",this._repaintLabels(),a?o.insertBefore(e,a):o.appendChild(e),h?this.body.dom.backgroundVertical.insertBefore(i,h):this.body.dom.backgroundVertical.appendChild(i),this._isResized()||n},o.prototype._repaintLabels=function(){var t=this.options.orientation.axis,e=r.convert(this.body.range.start,"Number"),i=r.convert(this.body.range.end,"Number"),o=this.body.util.toTime((this.props.minorCharWidth||10)*this.options.maxMinorChars).valueOf(),n=o-d.getHiddenDurationBefore(this.options.moment,this.body.hiddenDates,this.body.range,o);n-=this.body.util.toTime(0).valueOf();var s=new h(new Date(e),new Date(i),n,this.body.hiddenDates,this.options);s.setMoment(this.options.moment),this.options.format&&s.setFormat(this.options.format),this.options.timeAxis&&s.setScale(this.options.timeAxis),this.step=s;var a=this.dom;a.redundant.lines=a.lines,a.redundant.majorTexts=a.majorTexts,a.redundant.minorTexts=a.minorTexts,a.lines=[],a.majorTexts=[],a.minorTexts=[];var l,c,p,f,m,v,g,y,b,_=0,w=void 0,x=0;for(s.start(),l=s.getCurrent(),p=this.body.util.toScreen(l);s.hasNext()&&x<1e3;){switch(x++,f=s.isMajor(),b=s.getClassName(),y=s.getLabelMinor(),l,c=p,s.next(),l=s.getCurrent(),s.isMajor(),p=this.body.util.toScreen(l),v=_,_=p-c,s.scale){case"week":m=!0;break;default:m=_>=.4*v}if(this.options.showMinorLabels&&m){var k=this._repaintMinorText(c,y,t,b);k.style.width=_+"px"}f&&this.options.showMajorLabels?(c>0&&(void 0==w&&(w=c),k=this._repaintMajorText(c,s.getLabelMajor(),t,b)),g=this._repaintMajorLine(c,_,t,b)):m?g=this._repaintMinorLine(c,_,t,b):g&&(g.style.width=parseInt(g.style.width)+_+"px")}if(1e3!==x||u||(console.warn("Something is wrong with the Timeline scale. Limited drawing of grid lines to 1000 lines."),u=!0),this.options.showMajorLabels){var S=this.body.util.toTime(0),D=s.getLabelMajor(S),M=D.length*(this.props.majorCharWidth||10)+10;(void 0==w||M<w)&&this._repaintMajorText(0,D,t,b)}r.forEach(this.dom.redundant,function(t){for(;t.length;){var e=t.pop();e&&e.parentNode&&e.parentNode.removeChild(e)}})},o.prototype._repaintMinorText=function(t,e,i,o){var n=this.dom.redundant.minorTexts.shift();if(!n){var s=document.createTextNode("");n=document.createElement("div"),n.appendChild(s),this.dom.foreground.appendChild(n)}return this.dom.minorTexts.push(n),n.innerHTML=e,n.style.top="top"==i?this.props.majorLabelHeight+"px":"0",this.options.rtl?(n.style.left="",n.style.right=t+"px"):n.style.left=t+"px",n.className="vis-text vis-minor "+o,n},o.prototype._repaintMajorText=function(t,e,i,o){var n=this.dom.redundant.majorTexts.shift();if(!n){var s=document.createElement("div");n=document.createElement("div"),n.appendChild(s),this.dom.foreground.appendChild(n)}return n.childNodes[0].innerHTML=e,n.className="vis-text vis-major "+o,n.style.top="top"==i?"0":this.props.minorLabelHeight+"px",this.options.rtl?(n.style.left="",n.style.right=t+"px"):n.style.left=t+"px",this.dom.majorTexts.push(n),n},o.prototype._repaintMinorLine=function(t,e,i,o){var n=this.dom.redundant.lines.shift();n||(n=document.createElement("div"),this.dom.background.appendChild(n)),this.dom.lines.push(n);var s=this.props;return n.style.top="top"==i?s.majorLabelHeight+"px":this.body.domProps.top.height+"px",n.style.height=s.minorLineHeight+"px",this.options.rtl?(n.style.left="",n.style.right=t-s.minorLineWidth/2+"px",n.className="vis-grid vis-vertical-rtl vis-minor "+o):(n.style.left=t-s.minorLineWidth/2+"px",n.className="vis-grid vis-vertical vis-minor "+o),n.style.width=e+"px",n},o.prototype._repaintMajorLine=function(t,e,i,o){var n=this.dom.redundant.lines.shift();n||(n=document.createElement("div"),this.dom.background.appendChild(n)),this.dom.lines.push(n);var s=this.props;return n.style.top="top"==i?"0":this.body.domProps.top.height+"px",this.options.rtl?(n.style.left="",n.style.right=t-s.majorLineWidth/2+"px",n.className="vis-grid vis-vertical-rtl vis-major "+o):(n.style.left=t-s.majorLineWidth/2+"px",n.className="vis-grid vis-vertical vis-major "+o),n.style.height=s.majorLineHeight+"px",n.style.width=e+"px",n},o.prototype._calculateCharSize=function(){this.dom.measureCharMinor||(this.dom.measureCharMinor=document.createElement("DIV"),this.dom.measureCharMinor.className="vis-text vis-minor vis-measure",this.dom.measureCharMinor.style.position="absolute",this.dom.measureCharMinor.appendChild(document.createTextNode("0")),this.dom.foreground.appendChild(this.dom.measureCharMinor)),this.props.minorCharHeight=this.dom.measureCharMinor.clientHeight,this.props.minorCharWidth=this.dom.measureCharMinor.clientWidth,this.dom.measureCharMajor||(this.dom.measureCharMajor=document.createElement("DIV"),this.dom.measureCharMajor.className="vis-text vis-major vis-measure",this.dom.measureCharMajor.style.position="absolute",this.dom.measureCharMajor.appendChild(document.createTextNode("0")),this.dom.foreground.appendChild(this.dom.measureCharMajor)),this.props.majorCharHeight=this.dom.measureCharMajor.clientHeight,this.props.majorCharWidth=this.dom.measureCharMajor.clientWidth};var u=!1;t.exports=o},function(t,e,i){function o(t,e){this.body=t,this.defaultOptions={moment:a,locales:h,locale:"en",id:void 0,title:void 0},this.options=s.extend({},this.defaultOptions),e&&e.time?this.customTime=e.time:this.customTime=new Date,this.eventParams={},this.setOptions(e),this._create()}var n=i(10),s=i(2),r=i(16),a=i(9),h=i(98);o.prototype=new r,o.prototype.setOptions=function(t){t&&s.selectiveExtend(["moment","locale","locales","id"],this.options,t)},o.prototype._create=function(){function t(t){this.body.range._onMouseWheel(t)}var e=document.createElement("div");e["custom-time"]=this,e.className="vis-custom-time "+(this.options.id||""),e.style.position="absolute",e.style.top="0px",e.style.height="100%",this.bar=e;var i=document.createElement("div");i.style.position="relative",i.style.top="0px",i.style.left="-10px",i.style.height="100%",i.style.width="20px",i.addEventListener?(i.addEventListener("mousewheel",t.bind(this),!1),i.addEventListener("DOMMouseScroll",t.bind(this),!1)):i.attachEvent("onmousewheel",t.bind(this)),e.appendChild(i),this.hammer=new n(i),this.hammer.on("panstart",this._onDragStart.bind(this)),this.hammer.on("panmove",this._onDrag.bind(this)),this.hammer.on("panend",this._onDragEnd.bind(this)),this.hammer.get("pan").set({threshold:5,direction:n.DIRECTION_HORIZONTAL})},o.prototype.destroy=function(){this.hide(),this.hammer.destroy(),this.hammer=null,this.body=null},o.prototype.redraw=function(){var t=this.body.dom.backgroundVertical;this.bar.parentNode!=t&&(this.bar.parentNode&&this.bar.parentNode.removeChild(this.bar),t.appendChild(this.bar));var e=this.body.util.toScreen(this.customTime),i=this.options.locales[this.options.locale];i||(this.warned||(console.log("WARNING: options.locales['"+this.options.locale+"'] not found. See http://visjs.org/docs/timeline/#Localization"),this.warned=!0),i=this.options.locales.en);var o=this.options.title;return void 0===o?(o=i.time+": "+this.options.moment(this.customTime).format("dddd, MMMM Do YYYY, H:mm:ss"),o=o.charAt(0).toUpperCase()+o.substring(1)):"function"==typeof o&&(o=o.call(this.customTime)),this.bar.style.left=e+"px",this.bar.title=o,!1},o.prototype.hide=function(){this.bar.parentNode&&this.bar.parentNode.removeChild(this.bar)},o.prototype.setCustomTime=function(t){this.customTime=s.convert(t,"Date"),this.redraw()},o.prototype.getCustomTime=function(){return new Date(this.customTime.valueOf())},o.prototype.setCustomTitle=function(t){this.options.title=t},o.prototype._onDragStart=function(t){this.eventParams.dragging=!0,this.eventParams.customTime=this.customTime,t.stopPropagation()},o.prototype._onDrag=function(t){if(this.eventParams.dragging){var e=this.body.util.toScreen(this.eventParams.customTime)+t.deltaX,i=this.body.util.toTime(e);this.setCustomTime(i),this.body.emitter.emit("timechange",{id:this.options.id,time:new Date(this.customTime.valueOf()),event:t}),t.stopPropagation()}},o.prototype._onDragEnd=function(t){this.eventParams.dragging&&(this.body.emitter.emit("timechanged",{id:this.options.id,time:new Date(this.customTime.valueOf()),event:t}),t.stopPropagation())},o.customTimeFromTarget=function(t){for(var e=t.target;e;){if(e.hasOwnProperty("custom-time"))return e["custom-time"];e=e.parentNode}return null},t.exports=o},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(2),d=i(117).default,l=i(48).default,u=i(193).default,c=i(200).default,p=i(201).default,f=i(202).default,m=i(203).default,v=i(204).default,g=i(205).default,y=i(206).default,b=i(207).default,_=i(208).default,w=i(209).default,x=i(210).default,k=i(211).default,S=i(212).default,D=i(213).default,M=i(15),C=M.printStyle,O=function(){function t(e,i,o,n,r,a){(0,s.default)(this,t),this.options=h.bridgeObject(r),this.globalOptions=r,this.defaultOptions=a,this.body=i,this.edges=[],this.id=void 0,this.imagelist=o,this.grouplist=n,this.x=void 0,this.y=void 0,this.baseSize=this.options.size,this.baseFontSize=this.options.font.size,this.predefinedPosition=!1,this.selected=!1,this.hover=!1,this.labelModule=new d(this.body,this.options,!1),this.setOptions(e)}return(0,a.default)(t,[{key:"attachEdge",value:function(t){-1===this.edges.indexOf(t)&&this.edges.push(t)}},{key:"detachEdge",value:function(t){var e=this.edges.indexOf(t);-1!=e&&this.edges.splice(e,1)}},{key:"setOptions",value:function(e){var i=this.options.shape;if(e){if(void 0!==e.id&&(this.id=e.id),void 0===this.id)throw new Error("Node must have an id");t.checkMass(e,this.id),void 0!==e.x&&(null===e.x?(this.x=void 0,this.predefinedPosition=!1):(this.x=parseInt(e.x),this.predefinedPosition=!0)),void 0!==e.y&&(null===e.y?(this.y=void 0,this.predefinedPosition=!1):(this.y=parseInt(e.y),this.predefinedPosition=!0)),void 0!==e.size&&(this.baseSize=e.size),void 0!==e.value&&(e.value=parseFloat(e.value)),t.parseOptions(this.options,e,!0,this.globalOptions,this.grouplist);var o=[e,this.options,this.defaultOptions];return this.chooser=l.choosify("node",o),this._load_images(),this.updateLabelModule(e),this.updateShape(i),void 0!==e.hidden||void 0!==e.physics}}},{key:"_load_images",value:function(){if("circularImage"===this.options.shape||"image"===this.options.shape){if(void 0===this.options.image)throw new Error("Option image must be defined for node type '"+this.options.shape+"'");if(void 0===this.imagelist)throw new Error("Internal Error: No images provided");if("string"==typeof this.options.image)this.imageObj=this.imagelist.load(this.options.image,this.options.brokenImage,this.id);else{if(void 0===this.options.image.unselected)throw new Error("No unselected image provided");this.imageObj=this.imagelist.load(this.options.image.unselected,this.options.brokenImage,this.id),void 0!==this.options.image.selected?this.imageObjAlt=this.imagelist.load(this.options.image.selected,this.options.brokenImage,this.id):this.imageObjAlt=void 0}}}},{key:"getFormattingValues",value:function(){var t={color:this.options.color.background,borderWidth:this.options.borderWidth,borderColor:this.options.color.border,size:this.options.size,borderDashes:this.options.shapeProperties.borderDashes,borderRadius:this.options.shapeProperties.borderRadius,shadow:this.options.shadow.enabled,shadowColor:this.options.shadow.color,shadowSize:this.options.shadow.size,shadowX:this.options.shadow.x,shadowY:this.options.shadow.y};return this.selected||this.hover?!0===this.chooser?this.selected?(t.borderWidth*=2,t.color=this.options.color.highlight.background,t.borderColor=this.options.color.highlight.border,t.shadow=this.options.shadow.enabled):this.hover&&(t.color=this.options.color.hover.background,t.borderColor=this.options.color.hover.border,t.shadow=this.options.shadow.enabled):"function"==typeof this.chooser&&(this.chooser(t,this.options.id,this.selected,this.hover),!1===t.shadow&&(t.shadowColor===this.options.shadow.color&&t.shadowSize===this.options.shadow.size&&t.shadowX===this.options.shadow.x&&t.shadowY===this.options.shadow.y||(t.shadow=!0))):t.shadow=this.options.shadow.enabled,t}},{key:"updateLabelModule",value:function(e){void 0!==this.options.label&&null!==this.options.label||(this.options.label=""),t.updateGroupOptions(this.options,e,this.grouplist);var i=this.grouplist.get(this.options.group,!1),o=[e,this.options,i,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,o),void 0!==this.labelModule.baseSize&&(this.baseFontSize=this.labelModule.baseSize)}},{key:"updateShape",value:function(t){if(t===this.options.shape&&this.shape)this.shape.setOptions(this.options,this.imageObj,this.imageObjAlt);else switch(this.options.shape){case"box":this.shape=new u(this.options,this.body,this.labelModule);break;case"circle":this.shape=new c(this.options,this.body,this.labelModule);break;case"circularImage":this.shape=new p(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"database":this.shape=new f(this.options,this.body,this.labelModule);break;case"diamond":this.shape=new m(this.options,this.body,this.labelModule);break;case"dot":this.shape=new v(this.options,this.body,this.labelModule);break;case"ellipse":this.shape=new g(this.options,this.body,this.labelModule);break;case"icon":this.shape=new y(this.options,this.body,this.labelModule);break;case"image":this.shape=new b(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"square":this.shape=new _(this.options,this.body,this.labelModule);break;case"hexagon":this.shape=new w(this.options,this.body,this.labelModule);break;case"star":this.shape=new x(this.options,this.body,this.labelModule);break;case"text":this.shape=new k(this.options,this.body,this.labelModule);break;case"triangle":this.shape=new S(this.options,this.body,this.labelModule);break;case"triangleDown":this.shape=new D(this.options,this.body,this.labelModule);break;default:this.shape=new g(this.options,this.body,this.labelModule)}this.needsRefresh()}},{key:"select",value:function(){this.selected=!0,this.needsRefresh()}},{key:"unselect",value:function(){this.selected=!1,this.needsRefresh()}},{key:"needsRefresh",value:function(){this.shape.refreshNeeded=!0}},{key:"getTitle",value:function(){return this.options.title}},{key:"distanceToBorder",value:function(t,e){return this.shape.distanceToBorder(t,e)}},{key:"isFixed",value:function(){return this.options.fixed.x&&this.options.fixed.y}},{key:"isSelected",value:function(){return this.selected}},{key:"getValue",value:function(){return this.options.value}},{key:"getLabelSize",value:function(){return this.labelModule.size()}},{key:"setValueRange",value:function(t,e,i){if(void 0!==this.options.value){var o=this.options.scaling.customScalingFunction(t,e,i,this.options.value),n=this.options.scaling.max-this.options.scaling.min;if(!0===this.options.scaling.label.enabled){var s=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+o*s}this.options.size=this.options.scaling.min+o*n}else this.options.size=this.baseSize,this.options.font.size=this.baseFontSize;this.updateLabelModule()}},{key:"draw",value:function(t){var e=this.getFormattingValues();this.shape.draw(t,this.x,this.y,this.selected,this.hover,e)}},{key:"updateBoundingBox",value:function(t){this.shape.updateBoundingBox(this.x,this.y,t)}},{key:"resize",value:function(t){var e=this.getFormattingValues();this.shape.resize(t,this.selected,this.hover,e)}},{key:"getItemsOnPoint",value:function(t){var e=[];return this.labelModule.visible()&&l.pointInRect(this.labelModule.getSize(),t)&&e.push({nodeId:this.id,labelId:0}),l.pointInRect(this.shape.boundingBox,t)&&e.push({nodeId:this.id}),e}},{key:"isOverlappingWith",value:function(t){return this.shape.left<t.right&&this.shape.left+this.shape.width>t.left&&this.shape.top<t.bottom&&this.shape.top+this.shape.height>t.top}},{key:"isBoundingBoxOverlappingWith",value:function(t){return this.shape.boundingBox.left<t.right&&this.shape.boundingBox.right>t.left&&this.shape.boundingBox.top<t.bottom&&this.shape.boundingBox.bottom>t.top}}],[{key:"updateGroupOptions",value:function(t,e,i){if(void 0!==i){var o=t.group;if(void 0!==e&&void 0!==e.group&&o!==e.group)throw new Error("updateGroupOptions: group values in options don't match.");if("number"==typeof o||"string"==typeof o&&""!=o){var n=i.get(o);h.selectiveNotDeepExtend(["font"],t,n),t.color=h.parseColor(t.color)}}}},{key:"parseOptions",value:function(e,i){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=arguments[4],r=["color","fixed","shadow"];if(h.selectiveNotDeepExtend(r,e,i,o),t.checkMass(i),h.mergeOptions(e,i,"shadow",n),void 0!==i.color&&null!==i.color){var a=h.parseColor(i.color);h.fillIfDefined(e.color,a)}else!0===o&&null===i.color&&(e.color=h.bridgeObject(n.color));void 0!==i.fixed&&null!==i.fixed&&("boolean"==typeof i.fixed?(e.fixed.x=i.fixed,e.fixed.y=i.fixed):(void 0!==i.fixed.x&&"boolean"==typeof i.fixed.x&&(e.fixed.x=i.fixed.x),void 0!==i.fixed.y&&"boolean"==typeof i.fixed.y&&(e.fixed.y=i.fixed.y))),!0===o&&null===i.font&&(e.font=h.bridgeObject(n.font)),t.updateGroupOptions(e,i,s),void 0!==i.scaling&&h.mergeOptions(e.scaling,i.scaling,"label",n.scaling)}},{key:"checkMass",value:function(t,e){if(void 0!==t.mass&&t.mass<=0){var i="";void 0!==e&&(i=" in node id: "+e),console.log("%cNegative or zero mass disallowed"+i+", setting mass to 1.",C),t.mass=1}}}]),t}();e.default=O},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(6),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(2),u=function(){function t(){(0,a.default)(this,t)}return(0,d.default)(t,null,[{key:"choosify",value:function(t,e){var i=["node","edge","label"],o=!0,n=l.topMost(e,"chosen");if("boolean"==typeof n)o=n;else if("object"===(void 0===n?"undefined":(0,s.default)(n))){if(-1===i.indexOf(t))throw new Error("choosify: subOption '"+t+"' should be one of '"+i.join("', '")+"'");var r=l.topMost(e,["chosen",t]);"boolean"!=typeof r&&"function"!=typeof r||(o=r)}return o}},{key:"pointInRect",value:function(t,e,i){if(t.width<=0||t.height<=0)return!1;if(void 0!==i){var o={x:e.x-i.x,y:e.y-i.y};if(0!==i.angle){var n=-i.angle;e={x:Math.cos(n)*o.x-Math.sin(n)*o.y,y:Math.sin(n)*o.x+Math.cos(n)*o.y}}else e=o}var s=t.x+t.width,r=t.y+t.width;return t.left<e.x&&s>e.x&&t.top<e.y&&r>e.y}},{key:"isValidLabel",value:function(t){return"string"==typeof t&&""!==t}}]),t}();e.default=u},function(t,e,i){i(125);for(var o=i(18),n=i(26),s=i(31),r=i(13)("toStringTag"),a="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),h=0;h<a.length;h++){var d=a[h],l=o[d],u=l&&l.prototype;u&&!u[r]&&n(u,r,d),s[d]=s.Array}},function(t,e){var i={}.toString;t.exports=function(t){return i.call(t).slice(8,-1)}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e){t.exports=!0},function(t,e,i){var o=i(32);t.exports=function(t,e){if(!o(t))return t;var i,n;if(e&&"function"==typeof(i=t.toString)&&!o(n=i.call(t)))return n;if("function"==typeof(i=t.valueOf)&&!o(n=i.call(t)))return n;if(!e&&"function"==typeof(i=t.toString)&&!o(n=i.call(t)))return n;throw TypeError("Can't convert object to primitive value")}},function(t,e,i){var o=i(27),n=i(130),s=i(58),r=i(56)("IE_PROTO"),a=function(){},h=function(){var t,e=i(82)("iframe"),o=s.length;for(e.style.display="none",i(134).appendChild(e),e.src="javascript:",t=e.contentWindow.document,t.open(),t.write("<script>document.F=Object<\/script>"),t.close(),h=t.F;o--;)delete h.prototype[s[o]];return h()};t.exports=Object.create||function(t,e){var i;return null!==t?(a.prototype=o(t),i=new a,a.prototype=null,i[r]=t):i=h(),void 0===e?i:n(i,e)}},function(t,e){var i=Math.ceil,o=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?o:i)(t)}},function(t,e,i){var o=i(57)("keys"),n=i(40);t.exports=function(t){return o[t]||(o[t]=n(t))}},function(t,e,i){var o=i(18),n=o["__core-js_shared__"]||(o["__core-js_shared__"]={});t.exports=function(t){return n[t]||(n[t]={})}},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,e,i){var o=i(20).f,n=i(22),s=i(13)("toStringTag");t.exports=function(t,e,i){t&&!n(t=i?t:t.prototype,s)&&o(t,s,{configurable:!0,value:e})}},function(t,e,i){var o=i(135)(!0);i(79)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,i=this._i;return i>=e.length?{value:void 0,done:!0}:(t=o(e,i),this._i+=t.length,{value:t,done:!1})})},function(t,e,i){e.f=i(13)},function(t,e,i){var o=i(18),n=i(7),s=i(52),r=i(61),a=i(20).f;t.exports=function(t){var e=n.Symbol||(n.Symbol=s?{}:o.Symbol||{});"_"==t.charAt(0)||t in e||a(e,t,{value:r.f(t)})}},function(t,e){e.f=Object.getOwnPropertySymbols},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){var i=p().hours(0).minutes(0).seconds(0).milliseconds(0),o=i.clone().add(-3,"days").valueOf(),n=i.clone().add(3,"days").valueOf();this.millisecondsPerPixelCache=void 0,void 0===e?(this.start=o,this.end=n):(this.start=e.start||o,this.end=e.end||n),this.rolling=!1,this.body=t,this.deltaDifference=0,this.scaleOffset=0,this.startToFront=!1,this.endToFront=!0,this.defaultOptions={rtl:!1,start:null,end:null,moment:p,direction:"horizontal",moveable:!0,zoomable:!0,min:null,max:null,zoomMin:10,zoomMax:31536e10,rollingMode:{follow:!1,offset:.5}},this.options=c.extend({},this.defaultOptions),this.props={touch:{}},this.animationTimer=null,this.body.emitter.on("panstart",this._onDragStart.bind(this)),this.body.emitter.on("panmove",this._onDrag.bind(this)),this.body.emitter.on("panend",this._onDragEnd.bind(this)),this.body.emitter.on("mousewheel",this._onMouseWheel.bind(this)),this.body.emitter.on("touch",this._onTouch.bind(this)),this.body.emitter.on("pinch",this._onPinch.bind(this)),this.body.dom.rollingModeBtn.addEventListener("click",this.startRolling.bind(this)),this.setOptions(e)}function s(t){if("horizontal"!=t&&"vertical"!=t)throw new TypeError('Unknown direction "'+t+'". Choose "horizontal" or "vertical".')}var r=i(8),a=o(r),h=i(19),d=o(h),l=i(6),u=o(l),c=i(2),p=i(9),f=i(16),m=i(36);n.prototype=new f,n.prototype.setOptions=function(t){if(t){var e=["animation","direction","min","max","zoomMin","zoomMax","moveable","zoomable","moment","activate","hiddenDates","zoomKey","rtl","showCurrentTime","rollingMode","horizontalScroll"];c.selectiveExtend(e,this.options,t),t.rollingMode&&t.rollingMode.follow&&this.startRolling(),("start"in t||"end"in t)&&this.setRange(t.start,t.end)}},n.prototype.startRolling=function(){function t(){e.stopRolling(),e.rolling=!0;var i=e.end-e.start,o=c.convert(new Date,"Date").valueOf(),n=o-i*e.options.rollingMode.offset,s=o+i*(1-e.options.rollingMode.offset),r={animation:!1};e.setRange(n,s,r),i=1/e.conversion(e.body.domProps.center.width).scale/10,i<30&&(i=30),i>1e3&&(i=1e3),e.body.dom.rollingModeBtn.style.visibility="hidden",e.currentTimeTimer=setTimeout(t,i)}var e=this;t()},n.prototype.stopRolling=function(){void 0!==this.currentTimeTimer&&(clearTimeout(this.currentTimeTimer),this.rolling=!1,this.body.dom.rollingModeBtn.style.visibility="visible")},n.prototype.setRange=function(t,e,i,o,n){i||(i={}),!0!==i.byUser&&(i.byUser=!1);var s=this,r=void 0!=t?c.convert(t,"Date").valueOf():null,h=void 0!=e?c.convert(e,"Date").valueOf():null;if(this._cancelAnimation(),this.millisecondsPerPixelCache=void 0,i.animation){var l=this.start,p=this.end,f="object"===(0,u.default)(i.animation)&&"duration"in i.animation?i.animation.duration:500,v="object"===(0,u.default)(i.animation)&&"easingFunction"in i.animation?i.animation.easingFunction:"easeInOutQuad",g=c.easingFunctions[v];if(!g)throw new Error("Unknown easing function "+(0,d.default)(v)+". Choose from: "+(0,a.default)(c.easingFunctions).join(", "));var y=(new Date).valueOf(),b=!1;return function t(){if(!s.props.touch.dragging){var e=(new Date).valueOf(),a=e-y,d=g(a/f),u=a>f,c=u||null===r?r:l+(r-l)*d,v=u||null===h?h:p+(h-p)*d;_=s._applyRange(c,v),m.updateHiddenDates(s.options.moment,s.body,s.options.hiddenDates),b=b||_;var w={start:new Date(s.start),end:new Date(s.end),byUser:i.byUser,event:i.event};if(n&&n(d,_,u),_&&s.body.emitter.emit("rangechange",w),u){if(b&&(s.body.emitter.emit("rangechanged",w),o))return o()}else s.animationTimer=setTimeout(t,20)}}()}var _=this._applyRange(r,h);if(m.updateHiddenDates(this.options.moment,this.body,this.options.hiddenDates),_){var w={start:new Date(this.start),end:new Date(this.end),byUser:i.byUser,event:i.event};if(this.body.emitter.emit("rangechange",w),clearTimeout(s.timeoutID),s.timeoutID=setTimeout(function(){s.body.emitter.emit("rangechanged",w)},200),o)return o()}},n.prototype.getMillisecondsPerPixel=function(){return void 0===this.millisecondsPerPixelCache&&(this.millisecondsPerPixelCache=(this.end-this.start)/this.body.dom.center.clientWidth),this.millisecondsPerPixelCache},n.prototype._cancelAnimation=function(){this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=null)},n.prototype._applyRange=function(t,e){var i,o=null!=t?c.convert(t,"Date").valueOf():this.start,n=null!=e?c.convert(e,"Date").valueOf():this.end,s=null!=this.options.max?c.convert(this.options.max,"Date").valueOf():null,r=null!=this.options.min?c.convert(this.options.min,"Date").valueOf():null;if(isNaN(o)||null===o)throw new Error('Invalid start "'+t+'"');if(isNaN(n)||null===n)throw new Error('Invalid end "'+e+'"');if(n<o&&(n=o),null!==r&&o<r&&(i=r-o,o+=i,n+=i,null!=s&&n>s&&(n=s)),null!==s&&n>s&&(i=n-s,o-=i,n-=i,null!=r&&o<r&&(o=r)),null!==this.options.zoomMin){var a=parseFloat(this.options.zoomMin);if(a<0&&(a=0),n-o<a){this.end-this.start===a&&o>=this.start-.5&&n<=this.end?(o=this.start,n=this.end):(i=a-(n-o),o-=i/2,n+=i/2)}}if(null!==this.options.zoomMax){var h=parseFloat(this.options.zoomMax);h<0&&(h=0),n-o>h&&(this.end-this.start===h&&o<this.start&&n>this.end?(o=this.start,n=this.end):(i=n-o-h,o+=i/2,n-=i/2))}var d=this.start!=o||this.end!=n;return o>=this.start&&o<=this.end||n>=this.start&&n<=this.end||this.start>=o&&this.start<=n||this.end>=o&&this.end<=n||this.body.emitter.emit("checkRangedItems"),this.start=o,this.end=n,d},n.prototype.getRange=function(){return{start:this.start,end:this.end}},n.prototype.conversion=function(t,e){return n.conversion(this.start,this.end,t,e)},n.conversion=function(t,e,i,o){return void 0===o&&(o=0),0!=i&&e-t!=0?{offset:t,scale:i/(e-t-o)}:{offset:0,scale:1}},n.prototype._onDragStart=function(t){this.deltaDifference=0,this.previousDelta=0,this.options.moveable&&this._isInsideRange(t)&&this.props.touch.allowDragging&&(this.stopRolling(),this.props.touch.start=this.start,this.props.touch.end=this.end,this.props.touch.dragging=!0,this.body.dom.root&&(this.body.dom.root.style.cursor="move"))},n.prototype._onDrag=function(t){if(t&&this.props.touch.dragging&&this.options.moveable&&this.props.touch.allowDragging){var e=this.options.direction;s(e);var i="horizontal"==e?t.deltaX:t.deltaY;i-=this.deltaDifference;var o=this.props.touch.end-this.props.touch.start;o-=m.getHiddenDurationBetween(this.body.hiddenDates,this.start,this.end);var n,r="horizontal"==e?this.body.domProps.center.width:this.body.domProps.center.height;n=this.options.rtl?i/r*o:-i/r*o;var a=this.props.touch.start+n,h=this.props.touch.end+n,d=m.snapAwayFromHidden(this.body.hiddenDates,a,this.previousDelta-i,!0),l=m.snapAwayFromHidden(this.body.hiddenDates,h,this.previousDelta-i,!0);if(d!=a||l!=h)return this.deltaDifference+=i,this.props.touch.start=d,this.props.touch.end=l,void this._onDrag(t);this.previousDelta=i,this._applyRange(a,h);var u=new Date(this.start),c=new Date(this.end);this.body.emitter.emit("rangechange",{start:u,end:c,byUser:!0,event:t}),this.body.emitter.emit("panmove")}},n.prototype._onDragEnd=function(t){this.props.touch.dragging&&this.options.moveable&&this.props.touch.allowDragging&&(this.props.touch.dragging=!1,this.body.dom.root&&(this.body.dom.root.style.cursor="auto"),this.body.emitter.emit("rangechanged",{start:new Date(this.start),end:new Date(this.end),byUser:!0,event:t}))},n.prototype._onMouseWheel=function(t){var e=0;if(t.wheelDelta?e=t.wheelDelta/120:t.detail&&(e=-t.detail/3),!(this.options.zoomKey&&!t[this.options.zoomKey]&&this.options.zoomable||!this.options.zoomable&&this.options.moveable)&&this.options.zoomable&&this.options.moveable&&this._isInsideRange(t)&&e){var i;i=e<0?1-e/5:1/(1+e/5);var o;if(this.rolling)o=this.start+(this.end-this.start)*this.options.rollingMode.offset;else{var n=this.getPointer({x:t.clientX,y:t.clientY},this.body.dom.center);o=this._pointerToDate(n)}this.zoom(i,o,e,t),t.preventDefault()}},n.prototype._onTouch=function(t){this.props.touch.start=this.start,this.props.touch.end=this.end,this.props.touch.allowDragging=!0,this.props.touch.center=null,this.scaleOffset=0,this.deltaDifference=0,c.preventDefault(t)},n.prototype._onPinch=function(t){if(this.options.zoomable&&this.options.moveable){c.preventDefault(t),this.props.touch.allowDragging=!1,this.props.touch.center||(this.props.touch.center=this.getPointer(t.center,this.body.dom.center)),this.stopRolling();var e=1/(t.scale+this.scaleOffset),i=this._pointerToDate(this.props.touch.center),o=m.getHiddenDurationBetween(this.body.hiddenDates,this.start,this.end),n=m.getHiddenDurationBefore(this.options.moment,this.body.hiddenDates,this,i),s=o-n,r=i-n+(this.props.touch.start-(i-n))*e,a=i+s+(this.props.touch.end-(i+s))*e;this.startToFront=1-e<=0,this.endToFront=e-1<=0;var h=m.snapAwayFromHidden(this.body.hiddenDates,r,1-e,!0),d=m.snapAwayFromHidden(this.body.hiddenDates,a,e-1,!0);h==r&&d==a||(this.props.touch.start=h,this.props.touch.end=d,this.scaleOffset=1-t.scale,r=h,a=d);var l={animation:!1,byUser:!0,event:t};this.setRange(r,a,l),this.startToFront=!1,this.endToFront=!0}},n.prototype._isInsideRange=function(t){var e,i=t.center?t.center.x:t.clientX;e=this.options.rtl?i-c.getAbsoluteLeft(this.body.dom.centerContainer):c.getAbsoluteRight(this.body.dom.centerContainer)-i;var o=this.body.util.toTime(e);return o>=this.start&&o<=this.end},n.prototype._pointerToDate=function(t){var e,i=this.options.direction;if(s(i),"horizontal"==i)return this.body.util.toTime(t.x).valueOf();var o=this.body.domProps.center.height;return e=this.conversion(o),t.y/e.scale+e.offset},n.prototype.getPointer=function(t,e){return this.options.rtl?{x:c.getAbsoluteRight(e)-t.x,y:t.y-c.getAbsoluteTop(e)}:{x:t.x-c.getAbsoluteLeft(e),y:t.y-c.getAbsoluteTop(e)}},n.prototype.zoom=function(t,e,i,o){null==e&&(e=(this.start+this.end)/2);var n=m.getHiddenDurationBetween(this.body.hiddenDates,this.start,this.end),s=m.getHiddenDurationBefore(this.options.moment,this.body.hiddenDates,this,e),r=n-s,a=e-s+(this.start-(e-s))*t,h=e+r+(this.end-(e+r))*t;this.startToFront=!(i>0),this.endToFront=!(-i>0) +;var d=m.snapAwayFromHidden(this.body.hiddenDates,a,i,!0),l=m.snapAwayFromHidden(this.body.hiddenDates,h,-i,!0);d==a&&l==h||(a=d,h=l);var u={animation:!1,byUser:!0,event:o};this.setRange(a,h,u),this.startToFront=!1,this.endToFront=!0},n.prototype.move=function(t){var e=this.end-this.start,i=this.start+e*t,o=this.end+e*t;this.start=i,this.end=o},n.prototype.moveTo=function(t){var e=(this.start+this.end)/2,i=e-t,o=this.start-i,n=this.end-i,s={animation:!1,byUser:!0,event:null};this.setRange(o,n,s)},t.exports=n},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(){}var s=i(19),r=o(s),a=i(6),h=o(a),d=i(44),l=i(10),u=i(37),c=i(2),p=i(45),f=i(97),m=i(36),v=i(46);d(n.prototype),n.prototype._create=function(t){function e(t){this.isActive()&&this.emit("mousewheel",t);var e=0,i=0;if("detail"in t&&(i=-1*t.detail),"wheelDelta"in t&&(i=t.wheelDelta),"wheelDeltaY"in t&&(i=t.wheelDeltaY),"wheelDeltaX"in t&&(e=-1*t.wheelDeltaX),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(e=-1*i,i=0),"deltaY"in t&&(i=-1*t.deltaY),"deltaX"in t&&(e=t.deltaX),this.options.zoomKey&&!t[this.options.zoomKey])if(t.preventDefault(),this.options.verticalScroll&&Math.abs(i)>=Math.abs(e)){var o=this.props.scrollTop,n=o+i;this.isActive()&&(this._setScrollTop(n),this._redraw(),this.emit("scroll",t))}else if(this.options.horizontalScroll){var s=Math.abs(e)>=Math.abs(i)?e:i,r=s/120*(this.range.end-this.range.start)/20,a=this.range.start+r,h=this.range.end+r,d={animation:!1,byUser:!0,event:t};this.range.setRange(a,h,d)}}function i(t){if(s.options.verticalScroll&&(t.preventDefault(),s.isActive())){var e=-t.target.scrollTop;s._setScrollTop(e),s._redraw(),s.emit("scrollSide",t)}}function o(t){if(t.preventDefault&&t.preventDefault(),!(!t.target.className.indexOf("vis")>-1||a))return t.dataTransfer.dropEffect="move",a=!0,!1}function n(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation();try{var e=JSON.parse(t.dataTransfer.getData("text"));if(!e||!e.content)return}catch(t){return!1}return a=!1,t.center={x:t.clientX,y:t.clientY},"item"!==e.target?s.itemSet._onAddItem(t):s.itemSet._onDropObjectOnItem(t),s.emit("drop",s.getEventProperties(t)),!1}this.dom={},this.dom.container=t,this.dom.root=document.createElement("div"),this.dom.background=document.createElement("div"),this.dom.backgroundVertical=document.createElement("div"),this.dom.backgroundHorizontal=document.createElement("div"),this.dom.centerContainer=document.createElement("div"),this.dom.leftContainer=document.createElement("div"),this.dom.rightContainer=document.createElement("div"),this.dom.center=document.createElement("div"),this.dom.left=document.createElement("div"),this.dom.right=document.createElement("div"),this.dom.top=document.createElement("div"),this.dom.bottom=document.createElement("div"),this.dom.shadowTop=document.createElement("div"),this.dom.shadowBottom=document.createElement("div"),this.dom.shadowTopLeft=document.createElement("div"),this.dom.shadowBottomLeft=document.createElement("div"),this.dom.shadowTopRight=document.createElement("div"),this.dom.shadowBottomRight=document.createElement("div"),this.dom.rollingModeBtn=document.createElement("div"),this.dom.root.className="vis-timeline",this.dom.background.className="vis-panel vis-background",this.dom.backgroundVertical.className="vis-panel vis-background vis-vertical",this.dom.backgroundHorizontal.className="vis-panel vis-background vis-horizontal",this.dom.centerContainer.className="vis-panel vis-center",this.dom.leftContainer.className="vis-panel vis-left",this.dom.rightContainer.className="vis-panel vis-right",this.dom.top.className="vis-panel vis-top",this.dom.bottom.className="vis-panel vis-bottom",this.dom.left.className="vis-content",this.dom.center.className="vis-content",this.dom.right.className="vis-content",this.dom.shadowTop.className="vis-shadow vis-top",this.dom.shadowBottom.className="vis-shadow vis-bottom",this.dom.shadowTopLeft.className="vis-shadow vis-top",this.dom.shadowBottomLeft.className="vis-shadow vis-bottom",this.dom.shadowTopRight.className="vis-shadow vis-top",this.dom.shadowBottomRight.className="vis-shadow vis-bottom",this.dom.rollingModeBtn.className="vis-rolling-mode-btn",this.dom.root.appendChild(this.dom.background),this.dom.root.appendChild(this.dom.backgroundVertical),this.dom.root.appendChild(this.dom.backgroundHorizontal),this.dom.root.appendChild(this.dom.centerContainer),this.dom.root.appendChild(this.dom.leftContainer),this.dom.root.appendChild(this.dom.rightContainer),this.dom.root.appendChild(this.dom.top),this.dom.root.appendChild(this.dom.bottom),this.dom.root.appendChild(this.dom.bottom),this.dom.root.appendChild(this.dom.rollingModeBtn),this.dom.centerContainer.appendChild(this.dom.center),this.dom.leftContainer.appendChild(this.dom.left),this.dom.rightContainer.appendChild(this.dom.right),this.dom.centerContainer.appendChild(this.dom.shadowTop),this.dom.centerContainer.appendChild(this.dom.shadowBottom),this.dom.leftContainer.appendChild(this.dom.shadowTopLeft),this.dom.leftContainer.appendChild(this.dom.shadowBottomLeft),this.dom.rightContainer.appendChild(this.dom.shadowTopRight),this.dom.rightContainer.appendChild(this.dom.shadowBottomRight),this.props={root:{},background:{},centerContainer:{},leftContainer:{},rightContainer:{},center:{},left:{},right:{},top:{},bottom:{},border:{},scrollTop:0,scrollTopMin:0},this.on("rangechange",function(){!0===this.initialDrawDone&&this._redraw()}.bind(this)),this.on("rangechanged",function(){this.initialRangeChangeDone||(this.initialRangeChangeDone=!0)}.bind(this)),this.on("touch",this._onTouch.bind(this)),this.on("panmove",this._onDrag.bind(this));var s=this;this._origRedraw=this._redraw.bind(this),this._redraw=c.throttle(this._origRedraw),this.on("_change",function(t){s.itemSet&&s.itemSet.initialItemSetDrawn&&t&&1==t.queue?s._redraw():s._origRedraw()}),this.hammer=new l(this.dom.root);var r=this.hammer.get("pinch").set({enable:!0});u.disablePreventDefaultVertically(r),this.hammer.get("pan").set({threshold:5,direction:l.DIRECTION_HORIZONTAL}),this.listeners={},["tap","doubletap","press","pinch","pan","panstart","panmove","panend"].forEach(function(t){var e=function(e){s.isActive()&&s.emit(t,e)};s.hammer.on(t,e),s.listeners[t]=e}),u.onTouch(this.hammer,function(t){s.emit("touch",t)}.bind(this)),u.onRelease(this.hammer,function(t){s.emit("release",t)}.bind(this)),this.dom.centerContainer.addEventListener?(this.dom.centerContainer.addEventListener("mousewheel",e.bind(this),!1),this.dom.centerContainer.addEventListener("DOMMouseScroll",e.bind(this),!1)):this.dom.centerContainer.attachEvent("onmousewheel",e.bind(this)),this.dom.left.parentNode.addEventListener("scroll",i.bind(this)),this.dom.right.parentNode.addEventListener("scroll",i.bind(this));var a=!1;if(this.dom.center.addEventListener("dragover",o.bind(this),!1),this.dom.center.addEventListener("drop",n.bind(this),!1),this.customTimes=[],this.touch={},this.redrawCount=0,this.initialDrawDone=!1,this.initialRangeChangeDone=!1,!t)throw new Error("No container provided");t.appendChild(this.dom.root)},n.prototype.setOptions=function(t){if(t){var e=["width","height","minHeight","maxHeight","autoResize","start","end","clickToUse","dataAttributes","hiddenDates","locale","locales","moment","rtl","zoomKey","horizontalScroll","verticalScroll"];if(c.selectiveExtend(e,this.options,t),this.dom.rollingModeBtn.style.visibility="hidden",this.options.rtl&&(this.dom.container.style.direction="rtl",this.dom.backgroundVertical.className="vis-panel vis-background vis-vertical-rtl"),this.options.verticalScroll&&(this.options.rtl?this.dom.rightContainer.className="vis-panel vis-right vis-vertical-scroll":this.dom.leftContainer.className="vis-panel vis-left vis-vertical-scroll"),"object"!==(0,h.default)(this.options.orientation)&&(this.options.orientation={item:void 0,axis:void 0}),"orientation"in t&&("string"==typeof t.orientation?this.options.orientation={item:t.orientation,axis:t.orientation}:"object"===(0,h.default)(t.orientation)&&("item"in t.orientation&&(this.options.orientation.item=t.orientation.item),"axis"in t.orientation&&(this.options.orientation.axis=t.orientation.axis))),"both"===this.options.orientation.axis){if(!this.timeAxis2){var i=this.timeAxis2=new p(this.body);i.setOptions=function(t){var e=t?c.extend({},t):{};e.orientation="top",p.prototype.setOptions.call(i,e)},this.components.push(i)}}else if(this.timeAxis2){var o=this.components.indexOf(this.timeAxis2);-1!==o&&this.components.splice(o,1),this.timeAxis2.destroy(),this.timeAxis2=null}if("function"==typeof t.drawPoints&&(t.drawPoints={onRender:t.drawPoints}),"hiddenDates"in this.options&&m.convertHiddenOptions(this.options.moment,this.body,this.options.hiddenDates),"clickToUse"in t&&(t.clickToUse?this.activator||(this.activator=new f(this.dom.root)):this.activator&&(this.activator.destroy(),delete this.activator)),"showCustomTime"in t)throw new Error("Option `showCustomTime` is deprecated. Create a custom time bar via timeline.addCustomTime(time [, id])");this._initAutoResize()}if(this.components.forEach(function(e){return e.setOptions(t)}),"configure"in t){this.configurator||(this.configurator=this._createConfigurator()),this.configurator.setOptions(t.configure);var n=c.deepExtend({},this.options);this.components.forEach(function(t){c.deepExtend(n,t.options)}),this.configurator.setModuleOptions({global:n})}this._redraw()},n.prototype.isActive=function(){return!this.activator||this.activator.active},n.prototype.destroy=function(){this.setItems(null),this.setGroups(null),this.off(),this._stopAutoResize(),this.dom.root.parentNode&&this.dom.root.parentNode.removeChild(this.dom.root),this.dom=null,this.activator&&(this.activator.destroy(),delete this.activator);for(var t in this.listeners)this.listeners.hasOwnProperty(t)&&delete this.listeners[t];this.listeners=null,this.hammer=null,this.components.forEach(function(t){return t.destroy()}),this.body=null},n.prototype.setCustomTime=function(t,e){var i=this.customTimes.filter(function(t){return e===t.options.id});if(0===i.length)throw new Error("No custom time bar found with id "+(0,r.default)(e));i.length>0&&i[0].setCustomTime(t)},n.prototype.getCustomTime=function(t){var e=this.customTimes.filter(function(e){return e.options.id===t});if(0===e.length)throw new Error("No custom time bar found with id "+(0,r.default)(t));return e[0].getCustomTime()},n.prototype.setCustomTimeTitle=function(t,e){var i=this.customTimes.filter(function(t){return t.options.id===e});if(0===i.length)throw new Error("No custom time bar found with id "+(0,r.default)(e));if(i.length>0)return i[0].setCustomTitle(t)},n.prototype.getEventProperties=function(t){return{event:t}},n.prototype.addCustomTime=function(t,e){var i=void 0!==t?c.convert(t,"Date").valueOf():new Date;if(this.customTimes.some(function(t){return t.options.id===e}))throw new Error("A custom time with id "+(0,r.default)(e)+" already exists");var o=new v(this.body,c.extend({},this.options,{time:i,id:e}));return this.customTimes.push(o),this.components.push(o),this._redraw(),e},n.prototype.removeCustomTime=function(t){var e=this.customTimes.filter(function(e){return e.options.id===t});if(0===e.length)throw new Error("No custom time bar found with id "+(0,r.default)(t));e.forEach(function(t){this.customTimes.splice(this.customTimes.indexOf(t),1),this.components.splice(this.components.indexOf(t),1),t.destroy()}.bind(this))},n.prototype.getVisibleItems=function(){return this.itemSet&&this.itemSet.getVisibleItems()||[]},n.prototype.fit=function(t,e){var i=this.getDataRange();if(null!==i.min||null!==i.max){var o=i.max-i.min,n=new Date(i.min.valueOf()-.01*o),s=new Date(i.max.valueOf()+.01*o),r=!t||void 0===t.animation||t.animation;this.range.setRange(n,s,{animation:r},e)}},n.prototype.getDataRange=function(){throw new Error("Cannot invoke abstract method getDataRange")},n.prototype.setWindow=function(t,e,i,o){"function"==typeof arguments[2]&&(o=arguments[2],i={});var n,s;1==arguments.length?(s=arguments[0],n=void 0===s.animation||s.animation,this.range.setRange(s.start,s.end,{animation:n})):2==arguments.length&&"function"==typeof arguments[1]?(s=arguments[0],o=arguments[1],n=void 0===s.animation||s.animation,this.range.setRange(s.start,s.end,{animation:n},o)):(n=!i||void 0===i.animation||i.animation,this.range.setRange(t,e,{animation:n},o))},n.prototype.moveTo=function(t,e,i){"function"==typeof arguments[1]&&(i=arguments[1],e={});var o=this.range.end-this.range.start,n=c.convert(t,"Date").valueOf(),s=n-o/2,r=n+o/2,a=!e||void 0===e.animation||e.animation;this.range.setRange(s,r,{animation:a},i)},n.prototype.getWindow=function(){var t=this.range.getRange();return{start:new Date(t.start),end:new Date(t.end)}},n.prototype.zoomIn=function(t,e,i){if(!(!t||t<0||t>1)){"function"==typeof arguments[1]&&(i=arguments[1],e={});var o=this.getWindow(),n=o.start.valueOf(),s=o.end.valueOf(),r=s-n,a=r/(1+t),h=(r-a)/2,d=n+h,l=s-h;this.setWindow(d,l,e,i)}},n.prototype.zoomOut=function(t,e,i){if(!(!t||t<0||t>1)){"function"==typeof arguments[1]&&(i=arguments[1],e={});var o=this.getWindow(),n=o.start.valueOf(),s=o.end.valueOf(),r=s-n,a=n-r*t/2,h=s+r*t/2;this.setWindow(a,h,e,i)}},n.prototype.redraw=function(){this._redraw()},n.prototype._redraw=function(){this.redrawCount++;var t=!1,e=this.options,i=this.props,o=this.dom;if(o&&o.container&&0!=o.root.offsetWidth){m.updateHiddenDates(this.options.moment,this.body,this.options.hiddenDates),"top"==e.orientation?(c.addClassName(o.root,"vis-top"),c.removeClassName(o.root,"vis-bottom")):(c.removeClassName(o.root,"vis-top"),c.addClassName(o.root,"vis-bottom")),o.root.style.maxHeight=c.option.asSize(e.maxHeight,""),o.root.style.minHeight=c.option.asSize(e.minHeight,""),o.root.style.width=c.option.asSize(e.width,""),i.border.left=(o.centerContainer.offsetWidth-o.centerContainer.clientWidth)/2,i.border.right=i.border.left,i.border.top=(o.centerContainer.offsetHeight-o.centerContainer.clientHeight)/2,i.border.bottom=i.border.top,i.borderRootHeight=o.root.offsetHeight-o.root.clientHeight,i.borderRootWidth=o.root.offsetWidth-o.root.clientWidth,0===o.centerContainer.clientHeight&&(i.border.left=i.border.top,i.border.right=i.border.left),0===o.root.clientHeight&&(i.borderRootWidth=i.borderRootHeight),i.center.height=o.center.offsetHeight,i.left.height=o.left.offsetHeight,i.right.height=o.right.offsetHeight,i.top.height=o.top.clientHeight||-i.border.top,i.bottom.height=o.bottom.clientHeight||-i.border.bottom;var n=Math.max(i.left.height,i.center.height,i.right.height),s=i.top.height+n+i.bottom.height+i.borderRootHeight+i.border.top+i.border.bottom;o.root.style.height=c.option.asSize(e.height,s+"px"),i.root.height=o.root.offsetHeight,i.background.height=i.root.height-i.borderRootHeight;var r=i.root.height-i.top.height-i.bottom.height-i.borderRootHeight;i.centerContainer.height=r,i.leftContainer.height=r,i.rightContainer.height=i.leftContainer.height,i.root.width=o.root.offsetWidth,i.background.width=i.root.width-i.borderRootWidth,this.initialDrawDone||(i.scrollbarWidth=c.getScrollBarWidth()),e.verticalScroll?e.rtl?(i.left.width=o.leftContainer.clientWidth||-i.border.left,i.right.width=o.rightContainer.clientWidth+i.scrollbarWidth||-i.border.right):(i.left.width=o.leftContainer.clientWidth+i.scrollbarWidth||-i.border.left,i.right.width=o.rightContainer.clientWidth||-i.border.right):(i.left.width=o.leftContainer.clientWidth||-i.border.left,i.right.width=o.rightContainer.clientWidth||-i.border.right),this._setDOM();var a=this._updateScrollTop();"top"!=e.orientation.item&&(a+=Math.max(i.centerContainer.height-i.center.height-i.border.top-i.border.bottom,0)),o.center.style.top=a+"px";var h=0==i.scrollTop?"hidden":"",d=i.scrollTop==i.scrollTopMin?"hidden":"";o.shadowTop.style.visibility=h,o.shadowBottom.style.visibility=d,o.shadowTopLeft.style.visibility=h,o.shadowBottomLeft.style.visibility=d,o.shadowTopRight.style.visibility=h,o.shadowBottomRight.style.visibility=d,e.verticalScroll&&(o.rightContainer.className="vis-panel vis-right vis-vertical-scroll",o.leftContainer.className="vis-panel vis-left vis-vertical-scroll",o.shadowTopRight.style.visibility="hidden",o.shadowBottomRight.style.visibility="hidden",o.shadowTopLeft.style.visibility="hidden",o.shadowBottomLeft.style.visibility="hidden",o.left.style.top="0px",o.right.style.top="0px"),(!e.verticalScroll||i.center.height<i.centerContainer.height)&&(o.left.style.top=a+"px",o.right.style.top=a+"px",o.rightContainer.className=o.rightContainer.className.replace(new RegExp("(?:^|\\s)vis-vertical-scroll(?:\\s|$)")," "),o.leftContainer.className=o.leftContainer.className.replace(new RegExp("(?:^|\\s)vis-vertical-scroll(?:\\s|$)")," "),i.left.width=o.leftContainer.clientWidth||-i.border.left,i.right.width=o.rightContainer.clientWidth||-i.border.right,this._setDOM());var u=i.center.height>i.centerContainer.height;this.hammer.get("pan").set({direction:u?l.DIRECTION_ALL:l.DIRECTION_HORIZONTAL}),this.components.forEach(function(e){t=e.redraw()||t});if(t){if(this.redrawCount<5)return void this.body.emitter.emit("_change");console.log("WARNING: infinite loop in redraw?")}else this.redrawCount=0;this.body.emitter.emit("changed")}},n.prototype._setDOM=function(){var t=this.props,e=this.dom;t.leftContainer.width=t.left.width,t.rightContainer.width=t.right.width;var i=t.root.width-t.left.width-t.right.width-t.borderRootWidth;t.center.width=i,t.centerContainer.width=i,t.top.width=i,t.bottom.width=i,e.background.style.height=t.background.height+"px",e.backgroundVertical.style.height=t.background.height+"px",e.backgroundHorizontal.style.height=t.centerContainer.height+"px",e.centerContainer.style.height=t.centerContainer.height+"px",e.leftContainer.style.height=t.leftContainer.height+"px",e.rightContainer.style.height=t.rightContainer.height+"px",e.background.style.width=t.background.width+"px",e.backgroundVertical.style.width=t.centerContainer.width+"px",e.backgroundHorizontal.style.width=t.background.width+"px",e.centerContainer.style.width=t.center.width+"px",e.top.style.width=t.top.width+"px",e.bottom.style.width=t.bottom.width+"px",e.background.style.left="0",e.background.style.top="0",e.backgroundVertical.style.left=t.left.width+t.border.left+"px",e.backgroundVertical.style.top="0",e.backgroundHorizontal.style.left="0",e.backgroundHorizontal.style.top=t.top.height+"px",e.centerContainer.style.left=t.left.width+"px",e.centerContainer.style.top=t.top.height+"px",e.leftContainer.style.left="0",e.leftContainer.style.top=t.top.height+"px",e.rightContainer.style.left=t.left.width+t.center.width+"px",e.rightContainer.style.top=t.top.height+"px",e.top.style.left=t.left.width+"px",e.top.style.top="0",e.bottom.style.left=t.left.width+"px",e.bottom.style.top=t.top.height+t.centerContainer.height+"px",e.center.style.left="0",e.left.style.left="0",e.right.style.left="0"},n.prototype.repaint=function(){throw new Error("Function repaint is deprecated. Use redraw instead.")},n.prototype.setCurrentTime=function(t){if(!this.currentTime)throw new Error("Option showCurrentTime must be true");this.currentTime.setCurrentTime(t)},n.prototype.getCurrentTime=function(){if(!this.currentTime)throw new Error("Option showCurrentTime must be true");return this.currentTime.getCurrentTime()},n.prototype._toTime=function(t){return m.toTime(this,t,this.props.center.width)},n.prototype._toGlobalTime=function(t){return m.toTime(this,t,this.props.root.width)},n.prototype._toScreen=function(t){return m.toScreen(this,t,this.props.center.width)},n.prototype._toGlobalScreen=function(t){return m.toScreen(this,t,this.props.root.width)},n.prototype._initAutoResize=function(){1==this.options.autoResize?this._startAutoResize():this._stopAutoResize()},n.prototype._startAutoResize=function(){var t=this;this._stopAutoResize(),this._onResize=function(){if(1!=t.options.autoResize)return void t._stopAutoResize();t.dom.root&&(t.dom.root.offsetWidth==t.props.lastWidth&&t.dom.root.offsetHeight==t.props.lastHeight||(t.props.lastWidth=t.dom.root.offsetWidth,t.props.lastHeight=t.dom.root.offsetHeight,t.props.scrollbarWidth=c.getScrollBarWidth(),t.body.emitter.emit("_change")))},c.addEventListener(window,"resize",this._onResize),t.dom.root&&(t.props.lastWidth=t.dom.root.offsetWidth,t.props.lastHeight=t.dom.root.offsetHeight),this.watchTimer=setInterval(this._onResize,1e3)},n.prototype._stopAutoResize=function(){this.watchTimer&&(clearInterval(this.watchTimer),this.watchTimer=void 0),this._onResize&&(c.removeEventListener(window,"resize",this._onResize),this._onResize=null)},n.prototype._onTouch=function(t){this.touch.allowDragging=!0,this.touch.initialScrollTop=this.props.scrollTop},n.prototype._onPinch=function(t){this.touch.allowDragging=!1},n.prototype._onDrag=function(t){if(t&&this.touch.allowDragging){var e=t.deltaY,i=this._getScrollTop(),o=this._setScrollTop(this.touch.initialScrollTop+e);this.options.verticalScroll&&(this.dom.left.parentNode.scrollTop=-this.props.scrollTop,this.dom.right.parentNode.scrollTop=-this.props.scrollTop),o!=i&&this.emit("verticalDrag")}},n.prototype._setScrollTop=function(t){return this.props.scrollTop=t,this._updateScrollTop(),this.props.scrollTop},n.prototype._updateScrollTop=function(){var t=Math.min(this.props.centerContainer.height-this.props.center.height,0);return t!=this.props.scrollTopMin&&("top"!=this.options.orientation.item&&(this.props.scrollTop+=t-this.props.scrollTopMin),this.props.scrollTopMin=t),this.props.scrollTop>0&&(this.props.scrollTop=0),this.props.scrollTop<t&&(this.props.scrollTop=t),this.options.verticalScroll&&(this.dom.left.parentNode.scrollTop=-this.props.scrollTop,this.dom.right.parentNode.scrollTop=-this.props.scrollTop),this.props.scrollTop},n.prototype._getScrollTop=function(){return this.props.scrollTop},n.prototype._createConfigurator=function(){throw new Error("Cannot invoke abstract method _createConfigurator")},t.exports=n},function(t,e,i){function o(t,e,i,s,r){this.moment=n,this.current=this.moment(),this._start=this.moment(),this._end=this.moment(),this.autoScale=!0,this.scale="day",this.step=1,this.setRange(t,e,i),this.switchedDay=!1,this.switchedMonth=!1,this.switchedYear=!1,Array.isArray(s)?this.hiddenDates=s:this.hiddenDates=void 0!=s?[s]:[],this.format=o.FORMAT,this.options=r||{}}var n=i(9),s=i(36),r=i(2);o.FORMAT={minorLabels:{millisecond:"SSS",second:"s",minute:"HH:mm",hour:"HH:mm",weekday:"ddd D",day:"D",week:"w",month:"MMM",year:"YYYY"},majorLabels:{millisecond:"HH:mm:ss",second:"D MMMM HH:mm",minute:"ddd D MMMM",hour:"ddd D MMMM",weekday:"MMMM YYYY",day:"MMMM YYYY",week:"MMMM YYYY",month:"YYYY",year:""}},o.prototype.setMoment=function(t){this.moment=t,this.current=this.moment(this.current.valueOf()),this._start=this.moment(this._start.valueOf()),this._end=this.moment(this._end.valueOf())},o.prototype.setFormat=function(t){var e=r.deepExtend({},o.FORMAT);this.format=r.deepExtend(e,t)},o.prototype.setRange=function(t,e,i){if(!(t instanceof Date&&e instanceof Date))throw"No legal start or end date in method setRange";this._start=void 0!=t?this.moment(t.valueOf()):new Date,this._end=void 0!=e?this.moment(e.valueOf()):new Date,this.autoScale&&this.setMinimumStep(i)},o.prototype.start=function(){this.current=this._start.clone(),this.roundToMinor()},o.prototype.roundToMinor=function(){switch("week"==this.scale&&this.current.weekday(0),this.scale){case"year":this.current.year(this.step*Math.floor(this.current.year()/this.step)),this.current.month(0);case"month":this.current.date(1);case"week":case"day":case"weekday":this.current.hours(0);case"hour":this.current.minutes(0);case"minute":this.current.seconds(0);case"second":this.current.milliseconds(0)}if(1!=this.step)switch(this.scale){case"millisecond":this.current.subtract(this.current.milliseconds()%this.step,"milliseconds");break;case"second":this.current.subtract(this.current.seconds()%this.step,"seconds");break;case"minute":this.current.subtract(this.current.minutes()%this.step,"minutes");break;case"hour":this.current.subtract(this.current.hours()%this.step,"hours");break;case"weekday":case"day":this.current.subtract((this.current.date()-1)%this.step,"day");break;case"week":this.current.subtract(this.current.week()%this.step,"week");break;case"month":this.current.subtract(this.current.month()%this.step,"month");break;case"year":this.current.subtract(this.current.year()%this.step,"year")}},o.prototype.hasNext=function(){return this.current.valueOf()<=this._end.valueOf()},o.prototype.next=function(){var t=this.current.valueOf();switch(this.scale){case"millisecond":this.current.add(this.step,"millisecond");break;case"second":this.current.add(this.step,"second");break;case"minute":this.current.add(this.step,"minute");break;case"hour":this.current.add(this.step,"hour"),this.current.month()<6?this.current.subtract(this.current.hours()%this.step,"hour"):this.current.hours()%this.step!=0&&this.current.add(this.step-this.current.hours()%this.step,"hour");break;case"weekday":case"day":this.current.add(this.step,"day");break;case"week":if(0!==this.current.weekday())this.current.weekday(0),this.current.add(this.step,"week");else if(!1===this.options.showMajorLabels)this.current.add(this.step,"week");else{var e=this.current.clone();e.add(1,"week"),e.isSame(this.current,"month")?this.current.add(this.step,"week"):(this.current.add(this.step,"week"),this.current.date(1))}break;case"month":this.current.add(this.step,"month");break;case"year":this.current.add(this.step,"year")}if(1!=this.step)switch(this.scale){case"millisecond":this.current.milliseconds()>0&&this.current.milliseconds()<this.step&&this.current.milliseconds(0);break;case"second":this.current.seconds()>0&&this.current.seconds()<this.step&&this.current.seconds(0);break;case"minute":this.current.minutes()>0&&this.current.minutes()<this.step&&this.current.minutes(0);break;case"hour":this.current.hours()>0&&this.current.hours()<this.step&&this.current.hours(0);break;case"weekday":case"day":this.current.date()<this.step+1&&this.current.date(1);break;case"week":this.current.week()<this.step&&this.current.week(1);break;case"month":this.current.month()<this.step&&this.current.month(0)}this.current.valueOf()==t&&(this.current=this._end.clone()),this.switchedDay=!1,this.switchedMonth=!1,this.switchedYear=!1,s.stepOverHiddenDates(this.moment,this,t)},o.prototype.getCurrent=function(){return this.current},o.prototype.setScale=function(t){t&&"string"==typeof t.scale&&(this.scale=t.scale,this.step=t.step>0?t.step:1,this.autoScale=!1)},o.prototype.setAutoScale=function(t){this.autoScale=t},o.prototype.setMinimumStep=function(t){if(void 0!=t){31104e9>t&&(this.scale="year",this.step=1e3),15552e9>t&&(this.scale="year",this.step=500),31104e8>t&&(this.scale="year",this.step=100),15552e8>t&&(this.scale="year",this.step=50),31104e7>t&&(this.scale="year",this.step=10),15552e7>t&&(this.scale="year",this.step=5),31104e6>t&&(this.scale="year",this.step=1),7776e6>t&&(this.scale="month",this.step=3),2592e6>t&&(this.scale="month",this.step=1),432e6>t&&(this.scale="day",this.step=5),1728e5>t&&(this.scale="day",this.step=2),864e5>t&&(this.scale="day",this.step=1),432e5>t&&(this.scale="weekday",this.step=1),144e5>t&&(this.scale="hour",this.step=4),36e5>t&&(this.scale="hour",this.step=1),9e5>t&&(this.scale="minute",this.step=15),6e5>t&&(this.scale="minute",this.step=10),3e5>t&&(this.scale="minute",this.step=5),6e4>t&&(this.scale="minute",this.step=1),15e3>t&&(this.scale="second",this.step=15),1e4>t&&(this.scale="second",this.step=10),5e3>t&&(this.scale="second",this.step=5),1e3>t&&(this.scale="second",this.step=1),200>t&&(this.scale="millisecond",this.step=200),100>t&&(this.scale="millisecond",this.step=100),50>t&&(this.scale="millisecond",this.step=50),10>t&&(this.scale="millisecond",this.step=10),5>t&&(this.scale="millisecond",this.step=5),1>t&&(this.scale="millisecond",this.step=1)}},o.snap=function(t,e,i){var o=n(t);if("year"==e){var s=o.year()+Math.round(o.month()/12);o.year(Math.round(s/i)*i),o.month(0),o.date(0),o.hours(0),o.minutes(0),o.seconds(0),o.milliseconds(0)}else if("month"==e)o.date()>15?(o.date(1),o.add(1,"month")):o.date(1),o.hours(0),o.minutes(0),o.seconds(0),o.milliseconds(0);else if("week"==e)o.weekday()>2?(o.weekday(0),o.add(1,"week")):o.weekday(0),o.hours(0),o.minutes(0),o.seconds(0),o.milliseconds(0);else if("day"==e){switch(i){case 5:case 2:o.hours(24*Math.round(o.hours()/24));break;default:o.hours(12*Math.round(o.hours()/12))}o.minutes(0),o.seconds(0),o.milliseconds(0)}else if("weekday"==e){switch(i){case 5:case 2:o.hours(12*Math.round(o.hours()/12));break;default:o.hours(6*Math.round(o.hours()/6))}o.minutes(0),o.seconds(0),o.milliseconds(0)}else if("hour"==e){switch(i){case 4:o.minutes(60*Math.round(o.minutes()/60));break;default:o.minutes(30*Math.round(o.minutes()/30))}o.seconds(0),o.milliseconds(0)}else if("minute"==e){switch(i){case 15:case 10:o.minutes(5*Math.round(o.minutes()/5)),o.seconds(0);break;case 5:o.seconds(60*Math.round(o.seconds()/60));break;default:o.seconds(30*Math.round(o.seconds()/30))}o.milliseconds(0)}else if("second"==e)switch(i){case 15:case 10:o.seconds(5*Math.round(o.seconds()/5)),o.milliseconds(0);break;case 5:o.milliseconds(1e3*Math.round(o.milliseconds()/1e3));break;default:o.milliseconds(500*Math.round(o.milliseconds()/500))}else if("millisecond"==e){var r=i>5?i/2:1;o.milliseconds(Math.round(o.milliseconds()/r)*r)}return o},o.prototype.isMajor=function(){if(1==this.switchedYear)switch(this.scale){case"year":case"month":case"week":case"weekday":case"day":case"hour":case"minute":case"second":case"millisecond":return!0;default:return!1}else if(1==this.switchedMonth)switch(this.scale){case"week":case"weekday":case"day":case"hour":case"minute":case"second":case"millisecond":return!0;default:return!1}else if(1==this.switchedDay)switch(this.scale){case"millisecond":case"second":case"minute":case"hour":return!0;default:return!1}var t=this.moment(this.current);switch(this.scale){case"millisecond":return 0==t.milliseconds();case"second":return 0==t.seconds();case"minute":return 0==t.hours()&&0==t.minutes();case"hour":return 0==t.hours();case"weekday":case"day":case"week":return 1==t.date();case"month":return 0==t.month();case"year":default:return!1}},o.prototype.getLabelMinor=function(t){if(void 0==t&&(t=this.current),t instanceof Date&&(t=this.moment(t)),"function"==typeof this.format.minorLabels)return this.format.minorLabels(t,this.scale,this.step);var e=this.format.minorLabels[this.scale];switch(this.scale){case"week":if(this.isMajor()&&0!==t.weekday())return"";default:return e&&e.length>0?this.moment(t).format(e):""}},o.prototype.getLabelMajor=function(t){if(void 0==t&&(t=this.current),t instanceof Date&&(t=this.moment(t)),"function"==typeof this.format.majorLabels)return this.format.majorLabels(t,this.scale,this.step);var e=this.format.majorLabels[this.scale];return e&&e.length>0?this.moment(t).format(e):""},o.prototype.getClassName=function(){function t(t){return t/a%2==0?" vis-even":" vis-odd"}function e(t){return t.isSame(new Date,"day")?" vis-today":t.isSame(n().add(1,"day"),"day")?" vis-tomorrow":t.isSame(n().add(-1,"day"),"day")?" vis-yesterday":""}function i(t){return t.isSame(new Date,"week")?" vis-current-week":""}function o(t){return t.isSame(new Date,"month")?" vis-current-month":""}var n=this.moment,s=this.moment(this.current),r=s.locale?s.locale("en"):s.lang("en"),a=this.step,h=[];switch(this.scale){case"millisecond":h.push(e(r)),h.push(t(r.milliseconds()));break;case"second":h.push(e(r)),h.push(t(r.seconds()));break;case"minute":h.push(e(r)),h.push(t(r.minutes()));break;case"hour":h.push("vis-h"+r.hours()+(4==this.step?"-h"+(r.hours()+4):"")),h.push(e(r)),h.push(t(r.hours()));break;case"weekday":h.push("vis-"+r.format("dddd").toLowerCase()),h.push(e(r)),h.push(i(r)),h.push(t(r.date()));break;case"day":h.push("vis-day"+r.date()),h.push("vis-"+r.format("MMMM").toLowerCase()),h.push(e(r)),h.push(o(r)),h.push(this.step<=2?e(r):""),h.push(this.step<=2?"vis-"+r.format("dddd").toLowerCase():""), +h.push(t(r.date()-1));break;case"week":h.push("vis-week"+r.format("w")),h.push(i(r)),h.push(t(r.week()));break;case"month":h.push("vis-"+r.format("MMMM").toLowerCase()),h.push(o(r)),h.push(t(r.month()));break;case"year":h.push("vis-year"+r.year()),h.push(function(t){return t.isSame(new Date,"year")?" vis-current-year":""}(r)),h.push(t(r.year()))}return h.filter(String).join(" ")},t.exports=o},function(t,e,i){function o(t,e){this.body=t,this.defaultOptions={rtl:!1,showCurrentTime:!0,moment:r,locales:a,locale:"en"},this.options=n.extend({},this.defaultOptions),this.offset=0,this._create(),this.setOptions(e)}var n=i(2),s=i(16),r=i(9),a=i(98);o.prototype=new s,o.prototype._create=function(){var t=document.createElement("div");t.className="vis-current-time",t.style.position="absolute",t.style.top="0px",t.style.height="100%",this.bar=t},o.prototype.destroy=function(){this.options.showCurrentTime=!1,this.redraw(),this.body=null},o.prototype.setOptions=function(t){t&&n.selectiveExtend(["rtl","showCurrentTime","moment","locale","locales"],this.options,t)},o.prototype.redraw=function(){if(this.options.showCurrentTime){var t=this.body.dom.backgroundVertical;this.bar.parentNode!=t&&(this.bar.parentNode&&this.bar.parentNode.removeChild(this.bar),t.appendChild(this.bar),this.start());var e=this.options.moment((new Date).valueOf()+this.offset),i=this.body.util.toScreen(e),o=this.options.locales[this.options.locale];o||(this.warned||(console.log("WARNING: options.locales['"+this.options.locale+"'] not found. See http://visjs.org/docs/timeline/#Localization"),this.warned=!0),o=this.options.locales.en);var n=o.current+" "+o.time+": "+e.format("dddd, MMMM Do YYYY, H:mm:ss");n=n.charAt(0).toUpperCase()+n.substring(1),this.options.rtl?this.bar.style.right=i+"px":this.bar.style.left=i+"px",this.bar.title=n}else this.bar.parentNode&&this.bar.parentNode.removeChild(this.bar),this.stop();return!1},o.prototype.start=function(){function t(){e.stop();var i=e.body.range.conversion(e.body.domProps.center.width).scale,o=1/i/10;o<30&&(o=30),o>1e3&&(o=1e3),e.redraw(),e.body.emitter.emit("currentTimeTick"),e.currentTimeTimer=setTimeout(t,o)}var e=this;t()},o.prototype.stop=function(){void 0!==this.currentTimeTimer&&(clearTimeout(this.currentTimeTimer),delete this.currentTimeTimer)},o.prototype.setCurrentTime=function(t){var e=n.convert(t,"Date").valueOf(),i=(new Date).valueOf();this.offset=e-i,this.redraw()},o.prototype.getCurrentTime=function(){return new Date((new Date).valueOf()+this.offset)},t.exports=o},function(t,e,i){function o(t,e,i){if(this.groupId=t,this.subgroups={},this.subgroupStack={},this.subgroupStackAll=!1,this.doInnerStack=!1,this.subgroupIndex=0,this.subgroupOrderer=e&&e.subgroupOrder,this.itemSet=i,this.isVisible=null,this.stackDirty=!0,e&&e.nestedGroups&&(this.nestedGroups=e.nestedGroups,0==e.showNested?this.showNested=!1:this.showNested=!0),e&&e.subgroupStack)if("boolean"==typeof e.subgroupStack)this.doInnerStack=e.subgroupStack,this.subgroupStackAll=e.subgroupStack;else for(var o in e.subgroupStack)this.subgroupStack[o]=e.subgroupStack[o],this.doInnerStack=this.doInnerStack||e.subgroupStack[o];this.nestedInGroup=null,this.dom={},this.props={label:{width:0,height:0}},this.className=null,this.items={},this.visibleItems=[],this.itemsInRange=[],this.orderedItems={byStart:[],byEnd:[]},this.checkRangedItems=!1;var n=this;this.itemSet.body.emitter.on("checkRangedItems",function(){n.checkRangedItems=!0}),this._create(),this.setData(e)}var n=i(8),s=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(2),a=i(100);o.prototype._create=function(){var t=document.createElement("div");this.itemSet.options.groupEditable.order?t.className="vis-label draggable":t.className="vis-label",this.dom.label=t;var e=document.createElement("div");e.className="vis-inner",t.appendChild(e),this.dom.inner=e;var i=document.createElement("div");i.className="vis-group",i["timeline-group"]=this,this.dom.foreground=i,this.dom.background=document.createElement("div"),this.dom.background.className="vis-group",this.dom.axis=document.createElement("div"),this.dom.axis.className="vis-group",this.dom.marker=document.createElement("div"),this.dom.marker.style.visibility="hidden",this.dom.marker.style.position="absolute",this.dom.marker.innerHTML="",this.dom.background.appendChild(this.dom.marker)},o.prototype.setData=function(t){var e,i;if(this.itemSet.options&&this.itemSet.options.groupTemplate?(i=this.itemSet.options.groupTemplate.bind(this),e=i(t,this.dom.inner)):e=t&&t.content,e instanceof Element){for(this.dom.inner.appendChild(e);this.dom.inner.firstChild;)this.dom.inner.removeChild(this.dom.inner.firstChild);this.dom.inner.appendChild(e)}else e instanceof Object?i(t,this.dom.inner):this.dom.inner.innerHTML=void 0!==e&&null!==e?e:this.groupId||"";if(this.dom.label.title=t&&t.title||"",this.dom.inner.firstChild?r.removeClassName(this.dom.inner,"vis-hidden"):r.addClassName(this.dom.inner,"vis-hidden"),t&&t.nestedGroups){this.nestedGroups&&this.nestedGroups==t.nestedGroups||(this.nestedGroups=t.nestedGroups),void 0===t.showNested&&void 0!==this.showNested||(0==t.showNested?this.showNested=!1:this.showNested=!0),r.addClassName(this.dom.label,"vis-nesting-group");var o=this.itemSet.options.rtl?"collapsed-rtl":"collapsed";this.showNested?(r.removeClassName(this.dom.label,o),r.addClassName(this.dom.label,"expanded")):(r.removeClassName(this.dom.label,"expanded"),r.addClassName(this.dom.label,o))}else this.nestedGroups&&(this.nestedGroups=null,o=this.itemSet.options.rtl?"collapsed-rtl":"collapsed",r.removeClassName(this.dom.label,o),r.removeClassName(this.dom.label,"expanded"),r.removeClassName(this.dom.label,"vis-nesting-group"));t&&t.nestedInGroup&&(r.addClassName(this.dom.label,"vis-nested-group"),this.itemSet.options&&this.itemSet.options.rtl?this.dom.inner.style.paddingRight="30px":this.dom.inner.style.paddingLeft="30px");var n=t&&t.className||null;n!=this.className&&(this.className&&(r.removeClassName(this.dom.label,this.className),r.removeClassName(this.dom.foreground,this.className),r.removeClassName(this.dom.background,this.className),r.removeClassName(this.dom.axis,this.className)),r.addClassName(this.dom.label,n),r.addClassName(this.dom.foreground,n),r.addClassName(this.dom.background,n),r.addClassName(this.dom.axis,n),this.className=n),this.style&&(r.removeCssText(this.dom.label,this.style),this.style=null),t&&t.style&&(r.addCssText(this.dom.label,t.style),this.style=t.style)},o.prototype.getLabelWidth=function(){return this.props.label.width},o.prototype._didMarkerHeightChange=function(){var t=this.dom.marker.clientHeight;if(t!=this.lastMarkerHeight){this.lastMarkerHeight=t;var e={},i=0;r.forEach(this.items,function(t,o){if(t.dirty=!0,t.displayed){e[o]=t.redraw(!0),i=e[o].length}});if(i>0)for(var o=0;o<i;o++)r.forEach(e,function(t){t[o]()});return!0}},o.prototype._calculateGroupSizeAndPosition=function(){var t=this.dom.foreground.offsetTop,e=this.dom.foreground.offsetLeft,i=this.dom.foreground.offsetWidth;this.top=t,this.right=e,this.width=i},o.prototype._redrawItems=function(t,e,i,o){if(t||this.stackDirty||this.isVisible&&!e){var n={},s=null;if("function"==typeof this.itemSet.options.order){var h=this,d={},l=0;if(r.forEach(this.items,function(t,e){t.displayed||(d[e]=t.redraw(!0),l=d[e].length,h.visibleItems.push(t))}),l>0)for(var u=0;u<l;u++)r.forEach(d,function(t){t[u]()});if(r.forEach(this.items,function(t){t.repositionX(!1)}),this.doInnerStack&&this.itemSet.options.stackSubgroups){for(s in this.subgroups)n[s]=this.subgroups[s].items.slice().sort(function(t,e){return h.itemSet.options.order(t.data,e.data)});a.stackSubgroupsWithInnerStack(n,i,this.subgroups)}else{var c=this.orderedItems.byStart.slice().sort(function(t,e){return h.itemSet.options.order(t.data,e.data)});a.stack(c,i,!0)}this.visibleItems=this._updateItemsInRange(this.orderedItems,this.visibleItems,o)}else if(this.visibleItems=this._updateItemsInRange(this.orderedItems,this.visibleItems,o),this.itemSet.options.stack)if(this.doInnerStack&&this.itemSet.options.stackSubgroups){for(s in this.subgroups)n[s]=this.subgroups[s].items;a.stackSubgroupsWithInnerStack(n,i,this.subgroups)}else a.stack(this.visibleItems,i,!0);else a.nostack(this.visibleItems,i,this.subgroups,this.itemSet.options.stackSubgroups);this.stackDirty=!1}},o.prototype._didResize=function(t,e){t=r.updateProperty(this,"height",e)||t;var i=this.dom.inner.clientWidth,o=this.dom.inner.clientHeight;return t=r.updateProperty(this.props.label,"width",i)||t,t=r.updateProperty(this.props.label,"height",o)||t},o.prototype._applyGroupHeight=function(t){this.dom.background.style.height=t+"px",this.dom.foreground.style.height=t+"px",this.dom.label.style.height=t+"px"},o.prototype._updateItemsVerticalPosition=function(t){for(var e=0,i=this.visibleItems.length;e<i;e++){var o=this.visibleItems[e];o.repositionY(t),this.isVisible||"__background__"==this.groupId||o.displayed&&o.hide()}},o.prototype.redraw=function(t,e,i,o){var n,s=!1,r=this.isVisible,a=[function(){i=this._didMarkerHeightChange.bind(this)}.bind(this),this._updateSubGroupHeights.bind(this,e),this._calculateGroupSizeAndPosition.bind(this),function(){this.isVisible=this._isGroupVisible.bind(this)(t,e)}.bind(this),function(){this._redrawItems.bind(this)(i,r,e,t)}.bind(this),this._updateSubgroupsSizes.bind(this),function(){n=this._calculateHeight.bind(this)(e)}.bind(this),this._calculateGroupSizeAndPosition.bind(this),function(){s=this._didResize.bind(this)(s,n)}.bind(this),function(){this._applyGroupHeight.bind(this)(n)}.bind(this),function(){this._updateItemsVerticalPosition.bind(this)(e)}.bind(this),function(){return!this.isVisible&&this.height&&(s=!1),s}];if(o)return a;var h;return a.forEach(function(t){h=t()}),h},o.prototype._updateSubGroupHeights=function(t){if((0,s.default)(this.subgroups).length>0){var e=this;this.resetSubgroups(),r.forEach(this.visibleItems,function(i){void 0!==i.data.subgroup&&(e.subgroups[i.data.subgroup].height=Math.max(e.subgroups[i.data.subgroup].height,i.height+t.item.vertical),e.subgroups[i.data.subgroup].visible=!0)})}},o.prototype._isGroupVisible=function(t,e){return this.top<=t.body.domProps.centerContainer.height-t.body.domProps.scrollTop+e.axis&&this.top+this.height+e.axis>=-t.body.domProps.scrollTop},o.prototype._calculateHeight=function(t){var e,i=this.visibleItems;if(i.length>0){var o=i[0].top,n=i[0].top+i[0].height;if(r.forEach(i,function(t){o=Math.min(o,t.top),n=Math.max(n,t.top+t.height)}),o>t.axis){var s=o-t.axis;n-=s,r.forEach(i,function(t){t.top-=s})}e=n+t.item.vertical/2}else e=0;return e=Math.max(e,this.props.label.height)},o.prototype.show=function(){this.dom.label.parentNode||this.itemSet.dom.labelSet.appendChild(this.dom.label),this.dom.foreground.parentNode||this.itemSet.dom.foreground.appendChild(this.dom.foreground),this.dom.background.parentNode||this.itemSet.dom.background.appendChild(this.dom.background),this.dom.axis.parentNode||this.itemSet.dom.axis.appendChild(this.dom.axis)},o.prototype.hide=function(){var t=this.dom.label;t.parentNode&&t.parentNode.removeChild(t);var e=this.dom.foreground;e.parentNode&&e.parentNode.removeChild(e);var i=this.dom.background;i.parentNode&&i.parentNode.removeChild(i);var o=this.dom.axis;o.parentNode&&o.parentNode.removeChild(o)},o.prototype.add=function(t){if(this.items[t.id]=t,t.setParent(this),this.stackDirty=!0,void 0!==t.data.subgroup&&(this._addToSubgroup(t),this.orderSubgroups()),-1==this.visibleItems.indexOf(t)){var e=this.itemSet.body.range;this._checkIfVisible(t,this.visibleItems,e)}},o.prototype._addToSubgroup=function(t,e){e=e||t.data.subgroup,void 0!=e&&void 0===this.subgroups[e]&&(this.subgroups[e]={height:0,top:0,start:t.data.start,end:t.data.end||t.data.start,visible:!1,index:this.subgroupIndex,items:[],stack:this.subgroupStackAll||this.subgroupStack[e]||!1},this.subgroupIndex++),new Date(t.data.start)<new Date(this.subgroups[e].start)&&(this.subgroups[e].start=t.data.start);var i=t.data.end||t.data.start;new Date(i)>new Date(this.subgroups[e].end)&&(this.subgroups[e].end=i),this.subgroups[e].items.push(t)},o.prototype._updateSubgroupsSizes=function(){var t=this;if(t.subgroups)for(var e in t.subgroups){var i=t.subgroups[e].items[0].data.end||t.subgroups[e].items[0].data.start,o=t.subgroups[e].items[0].data.start,n=i-1;t.subgroups[e].items.forEach(function(t){new Date(t.data.start)<new Date(o)&&(o=t.data.start);var e=t.data.end||t.data.start;new Date(e)>new Date(n)&&(n=e)}),t.subgroups[e].start=o,t.subgroups[e].end=new Date(n-1)}},o.prototype.orderSubgroups=function(){if(void 0!==this.subgroupOrderer){var t,e=[];if("string"==typeof this.subgroupOrderer){for(t in this.subgroups)e.push({subgroup:t,sortField:this.subgroups[t].items[0].data[this.subgroupOrderer]});e.sort(function(t,e){return t.sortField-e.sortField})}else if("function"==typeof this.subgroupOrderer){for(t in this.subgroups)e.push(this.subgroups[t].items[0].data);e.sort(this.subgroupOrderer)}if(e.length>0)for(var i=0;i<e.length;i++)this.subgroups[e[i].subgroup].index=i}},o.prototype.resetSubgroups=function(){for(var t in this.subgroups)this.subgroups.hasOwnProperty(t)&&(this.subgroups[t].visible=!1,this.subgroups[t].height=0)},o.prototype.remove=function(t){delete this.items[t.id],t.setParent(null),this.stackDirty=!0;var e=this.visibleItems.indexOf(t);-1!=e&&this.visibleItems.splice(e,1),void 0!==t.data.subgroup&&(this._removeFromSubgroup(t),this.orderSubgroups())},o.prototype._removeFromSubgroup=function(t,e){if(void 0!=(e=e||t.data.subgroup)){var i=this.subgroups[e];if(i){var o=i.items.indexOf(t);o>=0&&(i.items.splice(o,1),i.items.length?this._updateSubgroupsSizes():delete this.subgroups[e])}}},o.prototype.removeFromDataSet=function(t){this.itemSet.removeItem(t.id)},o.prototype.order=function(){for(var t=r.toArray(this.items),e=[],i=[],o=0;o<t.length;o++)void 0!==t[o].data.end&&i.push(t[o]),e.push(t[o]);this.orderedItems={byStart:e,byEnd:i},a.orderByStart(this.orderedItems.byStart),a.orderByEnd(this.orderedItems.byEnd)},o.prototype._updateItemsInRange=function(t,e,i){var o=[],n={},s=(i.end-i.start)/4,a=i.start-s,h=i.end+s,d=function(t){return t<a?-1:t<=h?0:1};if(e.length>0)for(var l=0;l<e.length;l++)this._checkIfVisibleWithReference(e[l],o,n,i);var u=r.binarySearchCustom(t.byStart,d,"data","start");if(this._traceVisible(u,t.byStart,o,n,function(t){return t.data.start<a||t.data.start>h}),1==this.checkRangedItems)for(this.checkRangedItems=!1,l=0;l<t.byEnd.length;l++)this._checkIfVisibleWithReference(t.byEnd[l],o,n,i);else{var c=r.binarySearchCustom(t.byEnd,d,"data","end");this._traceVisible(c,t.byEnd,o,n,function(t){return t.data.end<a||t.data.end>h})}var p={},f=0;for(l=0;l<o.length;l++){var m=o[l];if(!m.displayed){p[l]=m.redraw(!0),f=p[l].length}}if(f>0)for(var v=0;v<f;v++)r.forEach(p,function(t){t[v]()});for(l=0;l<o.length;l++)o[l].repositionX();return o},o.prototype._traceVisible=function(t,e,i,o,n){if(-1!=t){var s,r;for(s=t;s>=0&&(r=e[s],!n(r));s--)void 0===o[r.id]&&(o[r.id]=!0,i.push(r));for(s=t+1;s<e.length&&(r=e[s],!n(r));s++)void 0===o[r.id]&&(o[r.id]=!0,i.push(r))}},o.prototype._checkIfVisible=function(t,e,i){t.isVisible(i)?(t.displayed||t.show(),t.repositionX(),e.push(t)):t.displayed&&t.hide()},o.prototype._checkIfVisibleWithReference=function(t,e,i,o){t.isVisible(o)?void 0===i[t.id]&&(i[t.id]=!0,e.push(t)):t.displayed&&t.hide()},o.prototype.changeSubgroup=function(t,e,i){this._removeFromSubgroup(t,e),this._addToSubgroup(t,i),this.orderSubgroups()},t.exports=o},function(t,e,i){function o(t,e,i){r.call(this,t,e,i),this.width=0,this.height=0,this.top=0,this.left=0}var n=i(29),s=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(68);o.prototype=(0,s.default)(r.prototype),o.prototype.redraw=function(t,e,i){this.visibleItems=this._updateItemsInRange(this.orderedItems,this.visibleItems,t),this.width=this.dom.background.offsetWidth,this.dom.background.style.height="0";for(var o=0,n=this.visibleItems.length;o<n;o++){this.visibleItems[o].repositionY(e)}return!1},o.prototype.show=function(){this.dom.background.parentNode||this.itemSet.dom.background.appendChild(this.dom.background)},t.exports=o},function(t,e,i){function o(t,e,i){if(this.props={content:{width:0}},this.overflow=!1,this.options=i,t){if(void 0==t.start)throw new Error('Property "start" missing in item '+t.id);if(void 0==t.end)throw new Error('Property "end" missing in item '+t.id)}n.call(this,t,e,i)}var n=i(38);o.prototype=new n(null,null,null),o.prototype.baseClassName="vis-item vis-range",o.prototype.isVisible=function(t){return this.data.start<t.end&&this.data.end>t.start},o.prototype._createDomElement=function(){this.dom||(this.dom={},this.dom.box=document.createElement("div"),this.dom.frame=document.createElement("div"),this.dom.frame.className="vis-item-overflow",this.dom.box.appendChild(this.dom.frame),this.dom.visibleFrame=document.createElement("div"),this.dom.visibleFrame.className="vis-item-visible-frame",this.dom.box.appendChild(this.dom.visibleFrame),this.dom.content=document.createElement("div"),this.dom.content.className="vis-item-content",this.dom.frame.appendChild(this.dom.content),this.dom.box["timeline-item"]=this,this.dirty=!0)},o.prototype._appendDomElement=function(){if(!this.parent)throw new Error("Cannot redraw item: no parent attached");if(!this.dom.box.parentNode){var t=this.parent.dom.foreground;if(!t)throw new Error("Cannot redraw item: parent has no foreground container element");t.appendChild(this.dom.box)}this.displayed=!0},o.prototype._updateDirtyDomComponents=function(){if(this.dirty){this._updateContents(this.dom.content),this._updateDataAttributes(this.dom.box),this._updateStyle(this.dom.box);var t=this.editable.updateTime||this.editable.updateGroup,e=(this.data.className?" "+this.data.className:"")+(this.selected?" vis-selected":"")+(t?" vis-editable":" vis-readonly");this.dom.box.className=this.baseClassName+e,this.dom.content.style.maxWidth="none"}},o.prototype._getDomComponentsSizes=function(){return this.overflow="hidden"!==window.getComputedStyle(this.dom.frame).overflow,{content:{width:this.dom.content.offsetWidth},box:{height:this.dom.box.offsetHeight}}},o.prototype._updateDomComponentsSizes=function(t){this.props.content.width=t.content.width,this.height=t.box.height,this.dom.content.style.maxWidth="",this.dirty=!1},o.prototype._repaintDomAdditionals=function(){this._repaintOnItemUpdateTimeTooltip(this.dom.box),this._repaintDeleteButton(this.dom.box),this._repaintDragCenter(),this._repaintDragLeft(),this._repaintDragRight()},o.prototype.redraw=function(t){var e,i=[this._createDomElement.bind(this),this._appendDomElement.bind(this),this._updateDirtyDomComponents.bind(this),function(){this.dirty&&(e=this._getDomComponentsSizes.bind(this)())}.bind(this),function(){this.dirty&&this._updateDomComponentsSizes.bind(this)(e)}.bind(this),this._repaintDomAdditionals.bind(this)];if(t)return i;var o;return i.forEach(function(t){o=t()}),o},o.prototype.show=function(){this.displayed||this.redraw()},o.prototype.hide=function(){if(this.displayed){var t=this.dom.box;t.parentNode&&t.parentNode.removeChild(t),this.displayed=!1}},o.prototype.repositionX=function(t){var e,i,o=this.parent.width,n=this.conversion.toScreen(this.data.start),s=this.conversion.toScreen(this.data.end),r=void 0===this.data.align?this.options.align:this.data.align;!1===this.data.limitSize||void 0!==t&&!0!==t||(n<-o&&(n=-o),s>2*o&&(s=2*o));var a=Math.max(s-n+.5,1);switch(this.overflow?(this.options.rtl?this.right=n:this.left=n,this.width=a+this.props.content.width,i=this.props.content.width):(this.options.rtl?this.right=n:this.left=n,this.width=a,i=Math.min(s-n,this.props.content.width)),this.options.rtl?this.dom.box.style.right=this.right+"px":this.dom.box.style.left=this.left+"px",this.dom.box.style.width=a+"px",r){case"left":this.options.rtl?this.dom.content.style.right="0":this.dom.content.style.left="0";break;case"right":this.options.rtl?this.dom.content.style.right=Math.max(a-i,0)+"px":this.dom.content.style.left=Math.max(a-i,0)+"px";break;case"center":this.options.rtl?this.dom.content.style.right=Math.max((a-i)/2,0)+"px":this.dom.content.style.left=Math.max((a-i)/2,0)+"px";break;default:e=this.overflow?s>0?Math.max(-n,0):-i:n<0?-n:0,this.options.rtl?this.dom.content.style.right=e+"px":(this.dom.content.style.left=e+"px",this.dom.content.style.width="calc(100% - "+e+"px)")}},o.prototype.repositionY=function(){var t=this.options.orientation.item,e=this.dom.box;e.style.top="top"==t?this.top+"px":this.parent.height-this.top-this.height+"px"},o.prototype._repaintDragLeft=function(){if((this.selected||this.options.itemsAlwaysDraggable.range)&&this.options.editable.updateTime&&!this.dom.dragLeft){var t=document.createElement("div");t.className="vis-drag-left",t.dragLeftItem=this,this.dom.box.appendChild(t),this.dom.dragLeft=t}else this.selected||this.options.itemsAlwaysDraggable.range||!this.dom.dragLeft||(this.dom.dragLeft.parentNode&&this.dom.dragLeft.parentNode.removeChild(this.dom.dragLeft),this.dom.dragLeft=null)},o.prototype._repaintDragRight=function(){if((this.selected||this.options.itemsAlwaysDraggable.range)&&this.options.editable.updateTime&&!this.dom.dragRight){var t=document.createElement("div");t.className="vis-drag-right",t.dragRightItem=this,this.dom.box.appendChild(t),this.dom.dragRight=t}else this.selected||this.options.itemsAlwaysDraggable.range||!this.dom.dragRight||(this.dom.dragRight.parentNode&&this.dom.dragRight.parentNode.removeChild(this.dom.dragRight),this.dom.dragRight=null)},t.exports=o},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(19),s=o(n),r=i(6),a=o(r),h=i(0),d=o(h),l=i(1),u=o(l),c=i(2),p=i(179).default,f=function(){function t(e,i,o){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;(0,d.default)(this,t),this.parent=e,this.changedOptions=[],this.container=i,this.allowCreation=!1,this.options={},this.initialized=!1,this.popupCounter=0,this.defaultOptions={enabled:!1,filter:!0,container:void 0,showButton:!0},c.extend(this.options,this.defaultOptions),this.configureOptions=o,this.moduleOptions={},this.domElements=[],this.popupDiv={},this.popupLimit=5,this.popupHistory={},this.colorPicker=new p(n),this.wrapper=void 0}return(0,u.default)(t,[{key:"setOptions",value:function(t){if(void 0!==t){this.popupHistory={},this._removePopup();var e=!0;"string"==typeof t?this.options.filter=t:t instanceof Array?this.options.filter=t.join():"object"===(void 0===t?"undefined":(0,a.default)(t))?(void 0!==t.container&&(this.options.container=t.container),void 0!==t.filter&&(this.options.filter=t.filter),void 0!==t.showButton&&(this.options.showButton=t.showButton),void 0!==t.enabled&&(e=t.enabled)):"boolean"==typeof t?(this.options.filter=!0,e=t):"function"==typeof t&&(this.options.filter=t,e=!0),!1===this.options.filter&&(e=!1),this.options.enabled=e}this._clean()}},{key:"setModuleOptions",value:function(t){this.moduleOptions=t,!0===this.options.enabled&&(this._clean(),void 0!==this.options.container&&(this.container=this.options.container),this._create())}},{key:"_create",value:function(){var t=this;this._clean(),this.changedOptions=[];var e=this.options.filter,i=0,o=!1;for(var n in this.configureOptions)this.configureOptions.hasOwnProperty(n)&&(this.allowCreation=!1,o=!1,"function"==typeof e?(o=e(n,[]),o=o||this._handleObject(this.configureOptions[n],[n],!0)):!0!==e&&-1===e.indexOf(n)||(o=!0),!1!==o&&(this.allowCreation=!0,i>0&&this._makeItem([]),this._makeHeader(n),this._handleObject(this.configureOptions[n],[n])),i++);if(!0===this.options.showButton){var s=document.createElement("div");s.className="vis-configuration vis-config-button",s.innerHTML="generate options",s.onclick=function(){t._printOptions()},s.onmouseover=function(){s.className="vis-configuration vis-config-button hover"},s.onmouseout=function(){s.className="vis-configuration vis-config-button"},this.optionsContainer=document.createElement("div"),this.optionsContainer.className="vis-configuration vis-config-option-container",this.domElements.push(this.optionsContainer),this.domElements.push(s)}this._push()}},{key:"_push",value:function(){this.wrapper=document.createElement("div"),this.wrapper.className="vis-configuration-wrapper",this.container.appendChild(this.wrapper);for(var t=0;t<this.domElements.length;t++)this.wrapper.appendChild(this.domElements[t]);this._showPopupIfNeeded()}},{key:"_clean",value:function(){for(var t=0;t<this.domElements.length;t++)this.wrapper.removeChild(this.domElements[t]);void 0!==this.wrapper&&(this.container.removeChild(this.wrapper),this.wrapper=void 0),this.domElements=[],this._removePopup()}},{key:"_getValue",value:function(t){for(var e=this.moduleOptions,i=0;i<t.length;i++){if(void 0===e[t[i]]){e=void 0;break}e=e[t[i]]}return e}},{key:"_makeItem",value:function(t){if(!0===this.allowCreation){var e=document.createElement("div");e.className="vis-configuration vis-config-item vis-config-s"+t.length;for(var i=arguments.length,o=Array(i>1?i-1:0),n=1;n<i;n++)o[n-1]=arguments[n];return o.forEach(function(t){e.appendChild(t)}),this.domElements.push(e),this.domElements.length}return 0}},{key:"_makeHeader",value:function(t){var e=document.createElement("div");e.className="vis-configuration vis-config-header",e.innerHTML=t,this._makeItem([],e)}},{key:"_makeLabel",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=document.createElement("div");return o.className="vis-configuration vis-config-label vis-config-s"+e.length,o.innerHTML=!0===i?"<i><b>"+t+":</b></i>":t+":",o}},{key:"_makeDropdown",value:function(t,e,i){var o=document.createElement("select");o.className="vis-configuration vis-config-select";var n=0;void 0!==e&&-1!==t.indexOf(e)&&(n=t.indexOf(e));for(var s=0;s<t.length;s++){var r=document.createElement("option");r.value=t[s],s===n&&(r.selected="selected"),r.innerHTML=t[s],o.appendChild(r)}var a=this;o.onchange=function(){a._update(this.value,i)};var h=this._makeLabel(i[i.length-1],i);this._makeItem(i,h,o)}},{key:"_makeRange",value:function(t,e,i){var o=t[0],n=t[1],s=t[2],r=t[3],a=document.createElement("input");a.className="vis-configuration vis-config-range";try{a.type="range",a.min=n,a.max=s}catch(t){}a.step=r;var h="",d=0;if(void 0!==e){e<0&&1.2*e<n?(a.min=Math.ceil(1.2*e),d=a.min,h="range increased"):e/1.2<n&&(a.min=Math.ceil(e/1.2),d=a.min,h="range increased"),1.2*e>s&&1!==s&&(a.max=Math.ceil(1.2*e),d=a.max,h="range increased"),a.value=e}else a.value=o;var l=document.createElement("input");l.className="vis-configuration vis-config-rangeinput",l.value=a.value;var u=this;a.onchange=function(){l.value=this.value,u._update(Number(this.value),i)},a.oninput=function(){l.value=this.value};var c=this._makeLabel(i[i.length-1],i),p=this._makeItem(i,c,a,l);""!==h&&this.popupHistory[p]!==d&&(this.popupHistory[p]=d,this._setupPopup(h,p))}},{key:"_setupPopup",value:function(t,e){var i=this;if(!0===this.initialized&&!0===this.allowCreation&&this.popupCounter<this.popupLimit){var o=document.createElement("div");o.id="vis-configuration-popup",o.className="vis-configuration-popup",o.innerHTML=t,o.onclick=function(){i._removePopup()},this.popupCounter+=1,this.popupDiv={html:o,index:e}}}},{key:"_removePopup",value:function(){void 0!==this.popupDiv.html&&(this.popupDiv.html.parentNode.removeChild(this.popupDiv.html),clearTimeout(this.popupDiv.hideTimeout),clearTimeout(this.popupDiv.deleteTimeout),this.popupDiv={})}},{key:"_showPopupIfNeeded",value:function(){var t=this;if(void 0!==this.popupDiv.html){var e=this.domElements[this.popupDiv.index],i=e.getBoundingClientRect();this.popupDiv.html.style.left=i.left+"px",this.popupDiv.html.style.top=i.top-30+"px",document.body.appendChild(this.popupDiv.html),this.popupDiv.hideTimeout=setTimeout(function(){t.popupDiv.html.style.opacity=0},1500),this.popupDiv.deleteTimeout=setTimeout(function(){t._removePopup()},1800)}}},{key:"_makeCheckbox",value:function(t,e,i){var o=document.createElement("input");o.type="checkbox",o.className="vis-configuration vis-config-checkbox",o.checked=t,void 0!==e&&(o.checked=e,e!==t&&("object"===(void 0===t?"undefined":(0,a.default)(t))?e!==t.enabled&&this.changedOptions.push({path:i,value:e}):this.changedOptions.push({path:i,value:e})));var n=this;o.onchange=function(){n._update(this.checked,i)};var s=this._makeLabel(i[i.length-1],i);this._makeItem(i,s,o)}},{key:"_makeTextInput",value:function(t,e,i){var o=document.createElement("input");o.type="text",o.className="vis-configuration vis-config-text",o.value=e,e!==t&&this.changedOptions.push({path:i,value:e});var n=this;o.onchange=function(){n._update(this.value,i)};var s=this._makeLabel(i[i.length-1],i);this._makeItem(i,s,o)}},{key:"_makeColorField",value:function(t,e,i){var o=this,n=t[1],s=document.createElement("div");e=void 0===e?n:e,"none"!==e?(s.className="vis-configuration vis-config-colorBlock",s.style.backgroundColor=e):s.className="vis-configuration vis-config-colorBlock none",e=void 0===e?n:e,s.onclick=function(){o._showColorPicker(e,s,i)};var r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,s)}},{key:"_showColorPicker",value:function(t,e,i){var o=this;e.onclick=function(){},this.colorPicker.insertTo(e),this.colorPicker.show(),this.colorPicker.setColor(t),this.colorPicker.setUpdateCallback(function(t){var n="rgba("+t.r+","+t.g+","+t.b+","+t.a+")";e.style.backgroundColor=n,o._update(n,i)}),this.colorPicker.setCloseCallback(function(){e.onclick=function(){o._showColorPicker(t,e,i)}})}},{key:"_handleObject",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=!1,n=this.options.filter,s=!1;for(var r in t)if(t.hasOwnProperty(r)){o=!0;var a=t[r],h=c.copyAndExtendArray(e,r);if("function"==typeof n&&!1===(o=n(r,e))&&!(a instanceof Array)&&"string"!=typeof a&&"boolean"!=typeof a&&a instanceof Object&&(this.allowCreation=!1,o=this._handleObject(a,h,!0),this.allowCreation=!1===i),!1!==o){s=!0;var d=this._getValue(h);if(a instanceof Array)this._handleArray(a,d,h);else if("string"==typeof a)this._makeTextInput(a,d,h);else if("boolean"==typeof a)this._makeCheckbox(a,d,h);else if(a instanceof Object){var l=!0;if(-1!==e.indexOf("physics")&&this.moduleOptions.physics.solver!==r&&(l=!1),!0===l)if(void 0!==a.enabled){var u=c.copyAndExtendArray(h,"enabled"),p=this._getValue(u);if(!0===p){var f=this._makeLabel(r,h,!0);this._makeItem(h,f),s=this._handleObject(a,h)||s}else this._makeCheckbox(a,p,h)}else{var m=this._makeLabel(r,h,!0);this._makeItem(h,m),s=this._handleObject(a,h)||s}}else console.error("dont know how to handle",a,r,h)}}return s}},{key:"_handleArray",value:function(t,e,i){"string"==typeof t[0]&&"color"===t[0]?(this._makeColorField(t,e,i),t[1]!==e&&this.changedOptions.push({path:i,value:e})):"string"==typeof t[0]?(this._makeDropdown(t,e,i),t[0]!==e&&this.changedOptions.push({path:i,value:e})):"number"==typeof t[0]&&(this._makeRange(t,e,i),t[0]!==e&&this.changedOptions.push({path:i,value:Number(e)}))}},{key:"_update",value:function(t,e){var i=this._constructOptions(t,e);this.parent.body&&this.parent.body.emitter&&this.parent.body.emitter.emit&&this.parent.body.emitter.emit("configChange",i),this.initialized=!0,this.parent.setOptions(i)}},{key:"_constructOptions",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i;t="true"===t||t,t="false"!==t&&t;for(var n=0;n<e.length;n++)"global"!==e[n]&&(void 0===o[e[n]]&&(o[e[n]]={}),n!==e.length-1?o=o[e[n]]:o[e[n]]=t);return i}},{key:"_printOptions",value:function(){var t=this.getOptions();this.optionsContainer.innerHTML="<pre>var options = "+(0,s.default)(t,null,2)+"</pre>"}},{key:"getOptions",value:function(){for(var t={},e=0;e<this.changedOptions.length;e++)this._constructOptions(this.changedOptions[e].value,this.changedOptions[e].path,t);return t}}]),t}();e.default=f},function(t,e,i){function o(t,e){}function n(t,e){return e=void 0===e?{}:e,{style:e.style||t.options.drawPoints.style, +styles:e.styles||t.options.drawPoints.styles,size:e.size||t.options.drawPoints.size,className:e.className||t.className}}function s(t,e){var i=void 0;return t.options&&t.options.drawPoints&&t.options.drawPoints.onRender&&"function"==typeof t.options.drawPoints.onRender&&(i=t.options.drawPoints.onRender),e.group.options&&e.group.options.drawPoints&&e.group.options.drawPoints.onRender&&"function"==typeof e.group.options.drawPoints.onRender&&(i=e.group.options.drawPoints.onRender),i}var r=i(6),a=function(t){return t&&t.__esModule?t:{default:t}}(r),h=i(14);o.draw=function(t,e,i,o){o=o||0;for(var r=s(i,e),d=0;d<t.length;d++)if(r){var l=r(t[d],e);!0!==l&&"object"!==(void 0===l?"undefined":(0,a.default)(l))||h.drawPoint(t[d].screen_x+o,t[d].screen_y,n(e,l),i.svgElements,i.svg,t[d].label)}else h.drawPoint(t[d].screen_x+o,t[d].screen_y,n(e),i.svgElements,i.svg,t[d].label)},o.drawIcon=function(t,e,i,o,s,r){var a=.5*s,d=h.getSVGElement("rect",r.svgElements,r.svg);d.setAttributeNS(null,"x",e),d.setAttributeNS(null,"y",i-a),d.setAttributeNS(null,"width",o),d.setAttributeNS(null,"height",2*a),d.setAttributeNS(null,"class","vis-outline"),h.drawPoint(e+.5*o,i,n(t),r.svgElements,r.svg)},t.exports=o},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(23),m=o(f),v=function(t){function e(t,i,o){(0,a.default)(this,e);var n=(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o));return n.labelOffset=0,n.selected=!1,n}return(0,p.default)(e,t),(0,d.default)(e,[{key:"setOptions",value:function(t,e,i){this.options=t,void 0===e&&void 0===i||this.setImages(e,i)}},{key:"setImages",value:function(t,e){e&&this.selected?(this.imageObj=e,this.imageObjAlt=t):(this.imageObj=t,this.imageObjAlt=e)}},{key:"switchImages",value:function(t){var e=t&&!this.selected||!t&&this.selected;if(this.selected=t,void 0!==this.imageObjAlt&&e){var i=this.imageObj;this.imageObj=this.imageObjAlt,this.imageObjAlt=i}}},{key:"_resizeImage",value:function(){var t,e;if(!1===this.options.shapeProperties.useImageSize){var i=1,o=1;this.imageObj.width&&this.imageObj.height&&(this.imageObj.width>this.imageObj.height?i=this.imageObj.width/this.imageObj.height:o=this.imageObj.height/this.imageObj.width),t=2*this.options.size*i,e=2*this.options.size*o}else t=this.imageObj.width,e=this.imageObj.height;this.width=t,this.height=e,this.radius=.5*this.width}},{key:"_drawRawCircle",value:function(t,e,i,o){this.initContextForDraw(t,o),t.circle(e,i,o.size),this.performFill(t,o)}},{key:"_drawImageAtPosition",value:function(t,e){if(0!=this.imageObj.width){t.globalAlpha=1,this.enableShadow(t,e);var i=1;!0===this.options.shapeProperties.interpolation&&(i=this.imageObj.width/this.width/this.body.view.scale),this.imageObj.drawImageAtPosition(t,i,this.left,this.top,this.width,this.height),this.disableShadow(t,e)}}},{key:"_drawImageLabel",value:function(t,e,i,o,n){var s,r=0;if(void 0!==this.height){r=.5*this.height;var a=this.labelModule.getTextSize(t,o,n);a.lineCount>=1&&(r+=a.height/2)}s=i+r,this.options.label&&(this.labelOffset=r),this.labelModule.draw(t,e,s,o,n,"hanging")}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(19),s=o(n),r=i(6),a=o(r),h=i(29),d=o(h),l=i(0),u=o(l),c=i(1),p=o(c),f=i(2),m=i(117).default,v=i(48).default,g=i(215).default,y=i(217).default,b=i(218).default,_=i(219).default,w=function(){function t(e,i,o,n){if((0,u.default)(this,t),void 0===i)throw new Error("No body provided");this.options=f.bridgeObject(o),this.globalOptions=o,this.defaultOptions=n,this.body=i,this.id=void 0,this.fromId=void 0,this.toId=void 0,this.selected=!1,this.hover=!1,this.labelDirty=!0,this.baseWidth=this.options.width,this.baseFontSize=this.options.font.size,this.from=void 0,this.to=void 0,this.edgeType=void 0,this.connected=!1,this.labelModule=new m(this.body,this.options,!0),this.setOptions(e)}return(0,p.default)(t,[{key:"setOptions",value:function(e){if(e){t.parseOptions(this.options,e,!0,this.globalOptions),void 0!==e.id&&(this.id=e.id),void 0!==e.from&&(this.fromId=e.from),void 0!==e.to&&(this.toId=e.to),void 0!==e.title&&(this.title=e.title),void 0!==e.value&&(e.value=parseFloat(e.value));var i=[e,this.options,this.defaultOptions];this.chooser=v.choosify("edge",i),this.updateLabelModule(e);var o=this.updateEdgeType();return this._setInteractionWidths(),this.connect(),void 0===e.hidden&&void 0===e.physics||(o=!0),o}}},{key:"getFormattingValues",value:function(){var t=!0===this.options.arrows.to||!0===this.options.arrows.to.enabled,e=!0===this.options.arrows.from||!0===this.options.arrows.from.enabled,i=!0===this.options.arrows.middle||!0===this.options.arrows.middle.enabled,o=this.options.color.inherit,n={toArrow:t,toArrowScale:this.options.arrows.to.scaleFactor,toArrowType:this.options.arrows.to.type,middleArrow:i,middleArrowScale:this.options.arrows.middle.scaleFactor,middleArrowType:this.options.arrows.middle.type,fromArrow:e,fromArrowScale:this.options.arrows.from.scaleFactor,fromArrowType:this.options.arrows.from.type,arrowStrikethrough:this.options.arrowStrikethrough,color:o?void 0:this.options.color.color,inheritsColor:o,opacity:this.options.color.opacity,hidden:this.options.hidden,length:this.options.length,shadow:this.options.shadow.enabled,shadowColor:this.options.shadow.color,shadowSize:this.options.shadow.size,shadowX:this.options.shadow.x,shadowY:this.options.shadow.y,dashes:this.options.dashes,width:this.options.width};if(this.selected||this.hover)if(!0===this.chooser){if(this.selected){var s=this.options.selectionWidth;"function"==typeof s?n.width=s(n.width):"number"==typeof s&&(n.width+=s),n.width=Math.max(n.width,.3/this.body.view.scale),n.color=this.options.color.highlight,n.shadow=this.options.shadow.enabled}else if(this.hover){var r=this.options.hoverWidth;"function"==typeof r?n.width=r(n.width):"number"==typeof r&&(n.width+=r),n.width=Math.max(n.width,.3/this.body.view.scale),n.color=this.options.color.hover,n.shadow=this.options.shadow.enabled}}else"function"==typeof this.chooser&&(this.chooser(n,this.options.id,this.selected,this.hover),void 0!==n.color&&(n.inheritsColor=!1),!1===n.shadow&&(n.shadowColor===this.options.shadow.color&&n.shadowSize===this.options.shadow.size&&n.shadowX===this.options.shadow.x&&n.shadowY===this.options.shadow.y||(n.shadow=!0)));else n.shadow=this.options.shadow.enabled,n.width=Math.max(n.width,.3/this.body.view.scale);return n}},{key:"updateLabelModule",value:function(t){var e=[t,this.options,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,e),void 0!==this.labelModule.baseSize&&(this.baseFontSize=this.labelModule.baseSize)}},{key:"updateEdgeType",value:function(){var t=this.options.smooth,e=!1,i=!0;return void 0!==this.edgeType&&((this.edgeType instanceof y&&!0===t.enabled&&"dynamic"===t.type||this.edgeType instanceof g&&!0===t.enabled&&"cubicBezier"===t.type||this.edgeType instanceof b&&!0===t.enabled&&"dynamic"!==t.type&&"cubicBezier"!==t.type||this.edgeType instanceof _&&!1===t.type.enabled)&&(i=!1),!0===i&&(e=this.cleanup())),!0===i?!0===t.enabled?"dynamic"===t.type?(e=!0,this.edgeType=new y(this.options,this.body,this.labelModule)):"cubicBezier"===t.type?this.edgeType=new g(this.options,this.body,this.labelModule):this.edgeType=new b(this.options,this.body,this.labelModule):this.edgeType=new _(this.options,this.body,this.labelModule):this.edgeType.setOptions(this.options),e}},{key:"connect",value:function(){this.disconnect(),this.from=this.body.nodes[this.fromId]||void 0,this.to=this.body.nodes[this.toId]||void 0,this.connected=void 0!==this.from&&void 0!==this.to,!0===this.connected?(this.from.attachEdge(this),this.to.attachEdge(this)):(this.from&&this.from.detachEdge(this),this.to&&this.to.detachEdge(this)),this.edgeType.connect()}},{key:"disconnect",value:function(){this.from&&(this.from.detachEdge(this),this.from=void 0),this.to&&(this.to.detachEdge(this),this.to=void 0),this.connected=!1}},{key:"getTitle",value:function(){return this.title}},{key:"isSelected",value:function(){return this.selected}},{key:"getValue",value:function(){return this.options.value}},{key:"setValueRange",value:function(t,e,i){if(void 0!==this.options.value){var o=this.options.scaling.customScalingFunction(t,e,i,this.options.value),n=this.options.scaling.max-this.options.scaling.min;if(!0===this.options.scaling.label.enabled){var s=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+o*s}this.options.width=this.options.scaling.min+o*n}else this.options.width=this.baseWidth,this.options.font.size=this.baseFontSize;this._setInteractionWidths(),this.updateLabelModule()}},{key:"_setInteractionWidths",value:function(){"function"==typeof this.options.hoverWidth?this.edgeType.hoverWidth=this.options.hoverWidth(this.options.width):this.edgeType.hoverWidth=this.options.hoverWidth+this.options.width,"function"==typeof this.options.selectionWidth?this.edgeType.selectionWidth=this.options.selectionWidth(this.options.width):this.edgeType.selectionWidth=this.options.selectionWidth+this.options.width}},{key:"draw",value:function(t){var e=this.getFormattingValues();if(!e.hidden){var i=this.edgeType.getViaNode(),o={};this.edgeType.fromPoint=this.edgeType.from,this.edgeType.toPoint=this.edgeType.to,e.fromArrow&&(o.from=this.edgeType.getArrowData(t,"from",i,this.selected,this.hover,e),!1===e.arrowStrikethrough&&(this.edgeType.fromPoint=o.from.core)),e.toArrow&&(o.to=this.edgeType.getArrowData(t,"to",i,this.selected,this.hover,e),!1===e.arrowStrikethrough&&(this.edgeType.toPoint=o.to.core)),e.middleArrow&&(o.middle=this.edgeType.getArrowData(t,"middle",i,this.selected,this.hover,e)),this.edgeType.drawLine(t,e,this.selected,this.hover,i),this.drawArrows(t,o,e),this.drawLabel(t,i)}}},{key:"drawArrows",value:function(t,e,i){i.fromArrow&&this.edgeType.drawArrowHead(t,i,this.selected,this.hover,e.from),i.middleArrow&&this.edgeType.drawArrowHead(t,i,this.selected,this.hover,e.middle),i.toArrow&&this.edgeType.drawArrowHead(t,i,this.selected,this.hover,e.to)}},{key:"drawLabel",value:function(t,e){if(void 0!==this.options.label){var i=this.from,o=this.to;if(this.labelModule.differentState(this.selected,this.hover)&&this.labelModule.getTextSize(t,this.selected,this.hover),i.id!=o.id){this.labelModule.pointToSelf=!1;var n=this.edgeType.getPoint(.5,e);t.save();var s=this._getRotation(t);0!=s.angle&&(t.translate(s.x,s.y),t.rotate(s.angle)),this.labelModule.draw(t,n.x,n.y,this.selected,this.hover),t.restore()}else{this.labelModule.pointToSelf=!0;var r,a,h=this.options.selfReferenceSize;i.shape.width>i.shape.height?(r=i.x+.5*i.shape.width,a=i.y-h):(r=i.x+h,a=i.y-.5*i.shape.height),n=this._pointOnCircle(r,a,h,.125),this.labelModule.draw(t,n.x,n.y,this.selected,this.hover)}}}},{key:"getItemsOnPoint",value:function(t){var e=[];if(this.labelModule.visible()){var i=this._getRotation();v.pointInRect(this.labelModule.getSize(),t,i)&&e.push({edgeId:this.id,labelId:0})}var o={left:t.x,top:t.y};return this.isOverlappingWith(o)&&e.push({edgeId:this.id}),e}},{key:"isOverlappingWith",value:function(t){if(this.connected){var e=this.from.x,i=this.from.y,o=this.to.x,n=this.to.y,s=t.left,r=t.top;return this.edgeType.getDistanceToEdge(e,i,o,n,s,r)<10}return!1}},{key:"_getRotation",value:function(t){var e=this.edgeType.getViaNode(),i=this.edgeType.getPoint(.5,e);void 0!==t&&this.labelModule.calculateLabelSize(t,this.selected,this.hover,i.x,i.y);var o={x:i.x,y:this.labelModule.size.yLine,angle:0};if(!this.labelModule.visible())return o;if("horizontal"===this.options.font.align)return o;var n=this.from.y-this.to.y,s=this.from.x-this.to.x,r=Math.atan2(n,s);return(r<-1&&s<0||r>0&&s<0)&&(r+=Math.PI),o.angle=r,o}},{key:"_pointOnCircle",value:function(t,e,i,o){var n=2*o*Math.PI;return{x:t+i*Math.cos(n),y:e-i*Math.sin(n)}}},{key:"select",value:function(){this.selected=!0}},{key:"unselect",value:function(){this.selected=!1}},{key:"cleanup",value:function(){return this.edgeType.cleanup()}},{key:"remove",value:function(){this.cleanup(),this.disconnect(),delete this.body.edges[this.id]}},{key:"endPointsValid",value:function(){return void 0!==this.body.nodes[this.fromId]&&void 0!==this.body.nodes[this.toId]}}],[{key:"parseOptions",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=["arrowStrikethrough","id","from","hidden","hoverWidth","labelHighlightBold","length","line","opacity","physics","scaling","selectionWidth","selfReferenceSize","to","title","value","width","font","chosen","widthConstraint"];if(f.selectiveDeepExtend(r,t,e,i),v.isValidLabel(e.label)?t.label=e.label:t.label=void 0,f.mergeOptions(t,e,"smooth",o),f.mergeOptions(t,e,"shadow",o),void 0!==e.dashes&&null!==e.dashes?t.dashes=e.dashes:!0===i&&null===e.dashes&&(t.dashes=(0,d.default)(o.dashes)),void 0!==e.scaling&&null!==e.scaling?(void 0!==e.scaling.min&&(t.scaling.min=e.scaling.min),void 0!==e.scaling.max&&(t.scaling.max=e.scaling.max),f.mergeOptions(t.scaling,e.scaling,"label",o.scaling)):!0===i&&null===e.scaling&&(t.scaling=(0,d.default)(o.scaling)),void 0!==e.arrows&&null!==e.arrows)if("string"==typeof e.arrows){var h=e.arrows.toLowerCase();t.arrows.to.enabled=-1!=h.indexOf("to"),t.arrows.middle.enabled=-1!=h.indexOf("middle"),t.arrows.from.enabled=-1!=h.indexOf("from")}else{if("object"!==(0,a.default)(e.arrows))throw new Error("The arrow newOptions can only be an object or a string. Refer to the documentation. You used:"+(0,s.default)(e.arrows));f.mergeOptions(t.arrows,e.arrows,"to",o.arrows),f.mergeOptions(t.arrows,e.arrows,"middle",o.arrows),f.mergeOptions(t.arrows,e.arrows,"from",o.arrows)}else!0===i&&null===e.arrows&&(t.arrows=(0,d.default)(o.arrows));if(void 0!==e.color&&null!==e.color){var l=e.color,u=t.color;if(n)f.deepExtend(u,o.color,!1,i);else for(var c in u)u.hasOwnProperty(c)&&delete u[c];if(f.isString(u))u.color=u,u.highlight=u,u.hover=u,u.inherit=!1,void 0===l.opacity&&(u.opacity=1);else{var p=!1;void 0!==l.color&&(u.color=l.color,p=!0),void 0!==l.highlight&&(u.highlight=l.highlight,p=!0),void 0!==l.hover&&(u.hover=l.hover,p=!0),void 0!==l.inherit&&(u.inherit=l.inherit),void 0!==l.opacity&&(u.opacity=Math.min(1,Math.max(0,l.opacity))),!0===p?u.inherit=!1:void 0===u.inherit&&(u.inherit="from")}}else!0===i&&null===e.color&&(t.color=f.bridgeObject(o.color));!0===i&&null===e.font&&(t.font=f.bridgeObject(o.font))}}]),t}();e.default=w},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(118),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"_findBorderPositionBezier",value:function(t,e){var i,o,n,s,r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this._getViaCoordinates(),h=0,d=0,l=1,u=this.to,c=!1;for(t.id===this.from.id&&(u=this.from,c=!0);d<=l&&h<10;){var p=.5*(d+l);if(i=this.getPoint(p,a),o=Math.atan2(u.y-i.y,u.x-i.x),n=u.distanceToBorder(e,o),s=Math.sqrt(Math.pow(i.x-u.x,2)+Math.pow(i.y-u.y,2)),r=n-s,Math.abs(r)<.2)break;r<0?!1===c?d=p:l=p:!1===c?l=p:d=p,h++}return i.t=p,i}},{key:"_getDistanceToBezierEdge",value:function(t,e,i,o,n,s,r){var a=1e9,h=void 0,d=void 0,l=void 0,u=void 0,c=void 0,p=t,f=e;for(d=1;d<10;d++)l=.1*d,u=Math.pow(1-l,2)*t+2*l*(1-l)*r.x+Math.pow(l,2)*i,c=Math.pow(1-l,2)*e+2*l*(1-l)*r.y+Math.pow(l,2)*o,d>0&&(h=this._getDistanceToLine(p,f,u,c,n,s),a=h<a?h:a),p=u,f=c;return a}},{key:"_bezierCurve",value:function(t,e,i,o){var n=void 0!==i&&void 0!==i.x,s=void 0!==o&&void 0!==o.x;t.beginPath(),t.moveTo(this.fromPoint.x,this.fromPoint.y),n&&s?t.bezierCurveTo(i.x,i.y,o.x,o.y,this.toPoint.x,this.toPoint.y):n?t.quadraticCurveTo(i.x,i.y,this.toPoint.x,this.toPoint.y):t.lineTo(this.toPoint.x,this.toPoint.y),this.enableShadow(t,e),t.stroke(),this.disableShadow(t,e)}},{key:"getViaNode",value:function(){return this._getViaCoordinates()}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(2),d=function(){function t(){(0,s.default)(this,t)}return(0,a.default)(t,null,[{key:"getRange",value:function(t){var e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=1e9,n=-1e9,s=1e9,r=-1e9;if(i.length>0)for(var a=0;a<i.length;a++)e=t[i[a]],s>e.shape.boundingBox.left&&(s=e.shape.boundingBox.left),r<e.shape.boundingBox.right&&(r=e.shape.boundingBox.right),o>e.shape.boundingBox.top&&(o=e.shape.boundingBox.top),n<e.shape.boundingBox.bottom&&(n=e.shape.boundingBox.bottom);return 1e9===s&&-1e9===r&&1e9===o&&-1e9===n&&(o=0,n=0,s=0,r=0),{minX:s,maxX:r,minY:o,maxY:n}}},{key:"getRangeCore",value:function(t){var e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=1e9,n=-1e9,s=1e9,r=-1e9;if(i.length>0)for(var a=0;a<i.length;a++)e=t[i[a]],s>e.x&&(s=e.x),r<e.x&&(r=e.x),o>e.y&&(o=e.y),n<e.y&&(n=e.y);return 1e9===s&&-1e9===r&&1e9===o&&-1e9===n&&(o=0,n=0,s=0,r=0),{minX:s,maxX:r,minY:o,maxY:n}}},{key:"findCenter",value:function(t){return{x:.5*(t.maxX+t.minX),y:.5*(t.maxY+t.minY)}}},{key:"cloneOptions",value:function(t,e){var i={};return void 0===e||"node"===e?(h.deepExtend(i,t.options,!0),i.x=t.x,i.y=t.y,i.amountOfConnections=t.edges.length):h.deepExtend(i,t.options,!0),i}}]),t}();e.default=d},function(t,e,i){t.exports={default:i(124),__esModule:!0}},function(t,e,i){var o=i(50);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==o(t)?t.split(""):Object(t)}},function(t,e,i){var o=i(52),n=i(17),s=i(83),r=i(26),a=i(22),h=i(31),d=i(129),l=i(59),u=i(85),c=i(13)("iterator"),p=!([].keys&&"next"in[].keys()),f=function(){return this};t.exports=function(t,e,i,m,v,g,y){d(i,e,m);var b,_,w,x=function(t){if(!p&&t in M)return M[t];switch(t){case"keys":case"values":return function(){return new i(this,t)}}return function(){return new i(this,t)}},k=e+" Iterator",S="values"==v,D=!1,M=t.prototype,C=M[c]||M["@@iterator"]||v&&M[v],O=C||x(v),E=v?S?x("entries"):O:void 0,T="Array"==e?M.entries||C:C;if(T&&(w=u(T.call(new t)))!==Object.prototype&&w.next&&(l(w,k,!0),o||a(w,c)||r(w,c,f)),S&&C&&"values"!==C.name&&(D=!0,O=function(){return C.call(this)}),o&&!y||!p&&!D&&M[c]||r(M,c,O),h[e]=O,h[k]=f,v)if(b={values:S?O:x("values"),keys:g?O:x("keys"),entries:E},y)for(_ in b)_ in M||s(M,_,b[_]);else n(n.P+n.F*(p||D),e,b);return b}},function(t,e,i){var o=i(128);t.exports=function(t,e,i){if(o(t),void 0===e)return t;switch(i){case 1:return function(i){return t.call(e,i)};case 2:return function(i,o){return t.call(e,i,o)};case 3:return function(i,o,n){return t.call(e,i,o,n)}}return function(){return t.apply(e,arguments)}}},function(t,e,i){t.exports=!i(21)&&!i(28)(function(){return 7!=Object.defineProperty(i(82)("div"),"a",{get:function(){return 7}}).a})},function(t,e,i){var o=i(32),n=i(18).document,s=o(n)&&o(n.createElement);t.exports=function(t){return s?n.createElement(t):{}}},function(t,e,i){t.exports=i(26)},function(t,e,i){var o=i(22),n=i(25),s=i(131)(!1),r=i(56)("IE_PROTO");t.exports=function(t,e){var i,a=n(t),h=0,d=[];for(i in a)i!=r&&o(a,i)&&d.push(i);for(;e.length>h;)o(a,i=e[h++])&&(~s(d,i)||d.push(i));return d}},function(t,e,i){var o=i(22),n=i(41),s=i(56)("IE_PROTO"),r=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=n(t),o(t,s)?t[s]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?r:null}},function(t,e,i){var o=i(50),n=i(13)("toStringTag"),s="Arguments"==o(function(){return arguments}()),r=function(t,e){try{return t[e]}catch(t){}};t.exports=function(t){var e,i,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=r(e=Object(t),n))?i:s?o(e):"Object"==(a=o(e))&&"function"==typeof e.callee?"Arguments":a}},function(t,e,i){var o=i(17),n=i(7),s=i(28);t.exports=function(t,e){var i=(n.Object||{})[t]||Object[t],r={};r[t]=e(i),o(o.S+o.F*s(function(){i(1)}),"Object",r)}},function(t,e,i){var o=i(84),n=i(58).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return o(t,n)}},function(t,e,i){var o=i(42),n=i(39),s=i(25),r=i(53),a=i(22),h=i(81),d=Object.getOwnPropertyDescriptor;e.f=i(21)?d:function(t,e){if(t=s(t),e=r(e,!0),h)try{return d(t,e)}catch(t){}if(a(t,e))return n(!o.f.call(t,e),t[e])}},function(t,e,i){t.exports={default:i(162),__esModule:!0}},function(t,e,i){function o(t,e){this.x=void 0!==t?t:0,this.y=void 0!==e?e:0}t.exports=o},function(t,e,i){function o(t,e){if(void 0===t)throw new Error("No container element defined");if(this.container=t,this.visible=!e||void 0==e.visible||e.visible,this.visible){this.frame=document.createElement("DIV"),this.frame.style.width="100%",this.frame.style.position="relative",this.container.appendChild(this.frame),this.frame.prev=document.createElement("INPUT"),this.frame.prev.type="BUTTON",this.frame.prev.value="Prev",this.frame.appendChild(this.frame.prev),this.frame.play=document.createElement("INPUT"),this.frame.play.type="BUTTON",this.frame.play.value="Play",this.frame.appendChild(this.frame.play),this.frame.next=document.createElement("INPUT"),this.frame.next.type="BUTTON",this.frame.next.value="Next",this.frame.appendChild(this.frame.next),this.frame.bar=document.createElement("INPUT"),this.frame.bar.type="BUTTON",this.frame.bar.style.position="absolute",this.frame.bar.style.border="1px solid red",this.frame.bar.style.width="100px",this.frame.bar.style.height="6px",this.frame.bar.style.borderRadius="2px",this.frame.bar.style.MozBorderRadius="2px",this.frame.bar.style.border="1px solid #7F7F7F",this.frame.bar.style.backgroundColor="#E5E5E5",this.frame.appendChild(this.frame.bar),this.frame.slide=document.createElement("INPUT"),this.frame.slide.type="BUTTON",this.frame.slide.style.margin="0px",this.frame.slide.value=" ",this.frame.slide.style.position="relative",this.frame.slide.style.left="-100px",this.frame.appendChild(this.frame.slide);var i=this;this.frame.slide.onmousedown=function(t){i._onMouseDown(t)},this.frame.prev.onclick=function(t){i.prev(t)},this.frame.play.onclick=function(t){i.togglePlay(t)},this.frame.next.onclick=function(t){i.next(t)}}this.onChangeCallback=void 0,this.values=[],this.index=void 0,this.playTimeout=void 0,this.playInterval=1e3,this.playLoop=!0}var n=i(2);o.prototype.prev=function(){var t=this.getIndex();t>0&&(t--,this.setIndex(t))},o.prototype.next=function(){var t=this.getIndex();t<this.values.length-1&&(t++,this.setIndex(t))},o.prototype.playNext=function(){var t=new Date,e=this.getIndex();e<this.values.length-1?(e++,this.setIndex(e)):this.playLoop&&(e=0,this.setIndex(e));var i=new Date,o=i-t,n=Math.max(this.playInterval-o,0),s=this;this.playTimeout=setTimeout(function(){s.playNext()},n)},o.prototype.togglePlay=function(){void 0===this.playTimeout?this.play():this.stop()},o.prototype.play=function(){this.playTimeout||(this.playNext(),this.frame&&(this.frame.play.value="Stop"))},o.prototype.stop=function(){clearInterval(this.playTimeout),this.playTimeout=void 0,this.frame&&(this.frame.play.value="Play")},o.prototype.setOnChangeCallback=function(t){this.onChangeCallback=t},o.prototype.setPlayInterval=function(t){this.playInterval=t},o.prototype.getPlayInterval=function(){return this.playInterval},o.prototype.setPlayLoop=function(t){this.playLoop=t},o.prototype.onChange=function(){void 0!==this.onChangeCallback&&this.onChangeCallback()},o.prototype.redraw=function(){if(this.frame){this.frame.bar.style.top=this.frame.clientHeight/2-this.frame.bar.offsetHeight/2+"px",this.frame.bar.style.width=this.frame.clientWidth-this.frame.prev.clientWidth-this.frame.play.clientWidth-this.frame.next.clientWidth-30+"px";var t=this.indexToLeft(this.index);this.frame.slide.style.left=t+"px"}},o.prototype.setValues=function(t){this.values=t,this.values.length>0?this.setIndex(0):this.index=void 0},o.prototype.setIndex=function(t){if(!(t<this.values.length))throw new Error("Index out of range");this.index=t,this.redraw(),this.onChange()},o.prototype.getIndex=function(){return this.index},o.prototype.get=function(){return this.values[this.index]},o.prototype._onMouseDown=function(t){if(t.which?1===t.which:1===t.button){this.startClientX=t.clientX,this.startSlideX=parseFloat(this.frame.slide.style.left),this.frame.style.cursor="move";var e=this;this.onmousemove=function(t){e._onMouseMove(t)},this.onmouseup=function(t){e._onMouseUp(t)},n.addEventListener(document,"mousemove",this.onmousemove),n.addEventListener(document,"mouseup",this.onmouseup),n.preventDefault(t)}},o.prototype.leftToIndex=function(t){var e=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10,i=t-3,o=Math.round(i/e*(this.values.length-1));return o<0&&(o=0),o>this.values.length-1&&(o=this.values.length-1),o},o.prototype.indexToLeft=function(t){var e=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10;return t/(this.values.length-1)*e+3},o.prototype._onMouseMove=function(t){var e=t.clientX-this.startClientX,i=this.startSlideX+e,o=this.leftToIndex(i);this.setIndex(o),n.preventDefault()},o.prototype._onMouseUp=function(t){this.frame.style.cursor="auto",n.removeEventListener(document,"mousemove",this.onmousemove),n.removeEventListener(document,"mouseup",this.onmouseup),n.preventDefault()},t.exports=o},function(t,e,i){function o(t,e,i,o){this._start=0,this._end=0,this._step=1,this.prettyStep=!0,this.precision=5,this._current=0,this.setRange(t,e,i,o)}o.prototype.isNumeric=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},o.prototype.setRange=function(t,e,i,o){if(!this.isNumeric(t))throw new Error("Parameter 'start' is not numeric; value: "+t);if(!this.isNumeric(e))throw new Error("Parameter 'end' is not numeric; value: "+t);if(!this.isNumeric(i))throw new Error("Parameter 'step' is not numeric; value: "+t);this._start=t||0,this._end=e||0,this.setStep(i,o)},o.prototype.setStep=function(t,e){void 0===t||t<=0||(void 0!==e&&(this.prettyStep=e),!0===this.prettyStep?this._step=o.calculatePrettyStep(t):this._step=t)},o.calculatePrettyStep=function(t){var e=function(t){return Math.log(t)/Math.LN10},i=Math.pow(10,Math.round(e(t))),o=2*Math.pow(10,Math.round(e(t/2))),n=5*Math.pow(10,Math.round(e(t/5))),s=i;return Math.abs(o-t)<=Math.abs(s-t)&&(s=o),Math.abs(n-t)<=Math.abs(s-t)&&(s=n),s<=0&&(s=1),s},o.prototype.getCurrent=function(){return parseFloat(this._current.toPrecision(this.precision))},o.prototype.getStep=function(){return this._step},o.prototype.start=function(t){void 0===t&&(t=!1),this._current=this._start-this._start%this._step,t&&this.getCurrent()<this._start&&this.next()},o.prototype.next=function(){this._current+=this._step},o.prototype.end=function(){return this._current>this._end},t.exports=o},function(t,e,i){function o(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}function n(t){return void 0===t||""===t||"string"!=typeof t?t:t.charAt(0).toUpperCase()+t.slice(1)}function s(t,e){return void 0===t||""===t?e:t+n(e)}function r(t,e,i,o){for(var n,r,a=0;a<i.length;++a)n=i[a],r=s(o,n),e[r]=t[n]}function a(t,e,i,o){for(var n,r,a=0;a<i.length;++a)n=i[a],void 0!==t[n]&&(r=s(o,n),e[r]=t[n])}function h(t,e){if(void 0===t||o(t))throw new Error("No DEFAULTS passed");if(void 0===e)throw new Error("No dst passed");C=t,r(t,e,D),r(t,e,M,"default"),l(t,e),e.margin=10,e.showGrayBottom=!1,e.showTooltip=!1,e.onclick_callback=null,e.eye=new x(0,0,-1)}function d(t,e){if(void 0!==t){if(void 0===e)throw new Error("No dst passed");if(void 0===C||o(C))throw new Error("DEFAULTS not set for module Settings");a(t,e,D),a(t,e,M,"default"),l(t,e)}}function l(t,e){void 0!==t.backgroundColor&&m(t.backgroundColor,e),v(t.dataColor,e),f(t.style,e),u(t.showLegend,e),g(t.cameraPosition,e),void 0!==t.tooltip&&(e.showTooltip=t.tooltip),void 0!=t.onclick&&(e.onclick_callback=t.onclick),void 0!==t.tooltipStyle&&_.selectiveDeepExtend(["tooltipStyle"],e,t)}function u(t,e){if(void 0===t){if(void 0===C.showLegend){var i=e.style===k.DOTCOLOR||e.style===k.DOTSIZE;e.showLegend=i}}else e.showLegend=t}function c(t){var e=S[t];return void 0===e?-1:e}function p(t){var e=!1;for(var i in k)if(k[i]===t){e=!0;break}return e}function f(t,e){if(void 0!==t){var i;if("string"==typeof t){if(-1===(i=c(t)))throw new Error("Style '"+t+"' is invalid")}else{if(!p(t))throw new Error("Style '"+t+"' is invalid");i=t}e.style=i}}function m(t,e){var i="white",o="gray",n=1;if("string"==typeof t)i=t,o="none",n=0;else{if("object"!==(void 0===t?"undefined":(0,b.default)(t)))throw new Error("Unsupported type of backgroundColor");void 0!==t.fill&&(i=t.fill),void 0!==t.stroke&&(o=t.stroke),void 0!==t.strokeWidth&&(n=t.strokeWidth)}e.frame.style.backgroundColor=i,e.frame.style.borderColor=o,e.frame.style.borderWidth=n+"px",e.frame.style.borderStyle="solid"}function v(t,e){void 0!==t&&(void 0===e.dataColor&&(e.dataColor={}),"string"==typeof t?(e.dataColor.fill=t,e.dataColor.stroke=t):(t.fill&&(e.dataColor.fill=t.fill),t.stroke&&(e.dataColor.stroke=t.stroke),void 0!==t.strokeWidth&&(e.dataColor.strokeWidth=t.strokeWidth)))}function g(t,e){var i=t;void 0!==i&&(void 0===e.camera&&(e.camera=new w),e.camera.setArmRotation(i.horizontal,i.vertical),e.camera.setArmLength(i.distance))}var y=i(6),b=function(t){return t&&t.__esModule?t:{default:t}}(y),_=i(2),w=i(95),x=i(34),k={BAR:0,BARCOLOR:1,BARSIZE:2,DOT:3,DOTLINE:4,DOTCOLOR:5,DOTSIZE:6,GRID:7,LINE:8,SURFACE:9},S={dot:k.DOT,"dot-line":k.DOTLINE,"dot-color":k.DOTCOLOR,"dot-size":k.DOTSIZE,line:k.LINE,grid:k.GRID,surface:k.SURFACE,bar:k.BAR,"bar-color":k.BARCOLOR,"bar-size":k.BARSIZE},D=["width","height","filterLabel","legendLabel","xLabel","yLabel","zLabel","xValueLabel","yValueLabel","zValueLabel","showXAxis","showYAxis","showZAxis","showGrid","showPerspective","showShadow","keepAspectRatio","verticalRatio","dotSizeRatio","dotSizeMinFraction","dotSizeMaxFraction","showAnimationControls","animationInterval","animationPreload","animationAutoStart","axisColor","gridColor","xCenter","yCenter"],M=["xBarWidth","yBarWidth","valueMin","valueMax","xMin","xMax","xStep","yMin","yMax","yStep","zMin","zMax","zStep"],C=void 0;t.exports.STYLE=k,t.exports.setDefaults=h,t.exports.setOptions=d,t.exports.setCameraPosition=g},function(t,e,i){function o(){this.armLocation=new r,this.armRotation={},this.armRotation.horizontal=0,this.armRotation.vertical=0,this.armLength=1.7,this.cameraOffset=new r,this.offsetMultiplier=.6,this.cameraLocation=new r,this.cameraRotation=new r(.5*Math.PI,0,0),this.calculateCameraOrientation()}var n=i(165),s=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(34);o.prototype.setOffset=function(t,e){var i=Math.abs,o=s.default,n=this.offsetMultiplier,r=this.armLength*n;i(t)>r&&(t=o(t)*r),i(e)>r&&(e=o(e)*r),this.cameraOffset.x=t,this.cameraOffset.y=e,this.calculateCameraOrientation()},o.prototype.getOffset=function(){return this.cameraOffset},o.prototype.setArmLocation=function(t,e,i){this.armLocation.x=t,this.armLocation.y=e,this.armLocation.z=i,this.calculateCameraOrientation()},o.prototype.setArmRotation=function(t,e){void 0!==t&&(this.armRotation.horizontal=t),void 0!==e&&(this.armRotation.vertical=e,this.armRotation.vertical<0&&(this.armRotation.vertical=0),this.armRotation.vertical>.5*Math.PI&&(this.armRotation.vertical=.5*Math.PI)),void 0===t&&void 0===e||this.calculateCameraOrientation()},o.prototype.getArmRotation=function(){var t={};return t.horizontal=this.armRotation.horizontal,t.vertical=this.armRotation.vertical,t},o.prototype.setArmLength=function(t){void 0!==t&&(this.armLength=t,this.armLength<.71&&(this.armLength=.71),this.armLength>5&&(this.armLength=5),this.setOffset(this.cameraOffset.x,this.cameraOffset.y),this.calculateCameraOrientation())}, +o.prototype.getArmLength=function(){return this.armLength},o.prototype.getCameraLocation=function(){return this.cameraLocation},o.prototype.getCameraRotation=function(){return this.cameraRotation},o.prototype.calculateCameraOrientation=function(){this.cameraLocation.x=this.armLocation.x-this.armLength*Math.sin(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical),this.cameraLocation.y=this.armLocation.y-this.armLength*Math.cos(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical),this.cameraLocation.z=this.armLocation.z+this.armLength*Math.sin(this.armRotation.vertical),this.cameraRotation.x=Math.PI/2-this.armRotation.vertical,this.cameraRotation.y=0,this.cameraRotation.z=-this.armRotation.horizontal;var t=this.cameraRotation.x,e=this.cameraRotation.z,i=this.cameraOffset.x,o=this.cameraOffset.y,n=Math.sin,s=Math.cos;this.cameraLocation.x=this.cameraLocation.x+i*s(e)+o*-n(e)*s(t),this.cameraLocation.y=this.cameraLocation.y+i*n(e)+o*s(e)*s(t),this.cameraLocation.z=this.cameraLocation.z+o*n(t)},t.exports=o},function(t,e,i){function o(t,e,i){this.dataGroup=t,this.column=e,this.graph=i,this.index=void 0,this.value=void 0,this.values=t.getDistinctValues(this.column),this.values.length>0&&this.selectValue(0),this.dataPoints=[],this.loaded=!1,this.onLoadCallback=void 0,i.animationPreload?(this.loaded=!1,this.loadInBackground()):this.loaded=!0}var n=i(12);o.prototype.isLoaded=function(){return this.loaded},o.prototype.getLoadedProgress=function(){for(var t=this.values.length,e=0;this.dataPoints[e];)e++;return Math.round(e/t*100)},o.prototype.getLabel=function(){return this.graph.filterLabel},o.prototype.getColumn=function(){return this.column},o.prototype.getSelectedValue=function(){if(void 0!==this.index)return this.values[this.index]},o.prototype.getValues=function(){return this.values},o.prototype.getValue=function(t){if(t>=this.values.length)throw new Error("Index out of range");return this.values[t]},o.prototype._getDataPoints=function(t){if(void 0===t&&(t=this.index),void 0===t)return[];var e;if(this.dataPoints[t])e=this.dataPoints[t];else{var i={};i.column=this.column,i.value=this.values[t];var o=new n(this.dataGroup.getDataSet(),{filter:function(t){return t[i.column]==i.value}}).get();e=this.dataGroup._getDataPoints(o),this.dataPoints[t]=e}return e},o.prototype.setOnLoadCallback=function(t){this.onLoadCallback=t},o.prototype.selectValue=function(t){if(t>=this.values.length)throw new Error("Index out of range");this.index=t,this.value=this.values[t]},o.prototype.loadInBackground=function(t){void 0===t&&(t=0);var e=this.graph.frame;if(t<this.values.length){void 0===e.progress&&(e.progress=document.createElement("DIV"),e.progress.style.position="absolute",e.progress.style.color="gray",e.appendChild(e.progress));var i=this.getLoadedProgress();e.progress.innerHTML="Loading animation... "+i+"%",e.progress.style.bottom="60px",e.progress.style.left="10px";var o=this;setTimeout(function(){o.loadInBackground(t+1)},10),this.loaded=!1}else this.loaded=!0,void 0!==e.progress&&(e.removeChild(e.progress),e.progress=void 0),this.onLoadCallback&&this.onLoadCallback()},t.exports=o},function(t,e,i){function o(t){this.active=!1,this.dom={container:t},this.dom.overlay=document.createElement("div"),this.dom.overlay.className="vis-overlay",this.dom.container.appendChild(this.dom.overlay),this.hammer=a(this.dom.overlay),this.hammer.on("tap",this._onTapOverlay.bind(this));var e=this;["tap","doubletap","press","pinch","pan","panstart","panmove","panend"].forEach(function(t){e.hammer.on(t,function(t){t.stopPropagation()})}),document&&document.body&&(this.onClick=function(i){n(i.target,t)||e.deactivate()},document.body.addEventListener("click",this.onClick)),void 0!==this.keycharm&&this.keycharm.destroy(),this.keycharm=s(),this.escListener=this.deactivate.bind(this)}function n(t,e){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}var s=i(35),r=i(44),a=i(10),h=i(2);r(o.prototype),o.current=null,o.prototype.destroy=function(){this.deactivate(),this.dom.overlay.parentNode.removeChild(this.dom.overlay),this.onClick&&document.body.removeEventListener("click",this.onClick),this.hammer.destroy(),this.hammer=null},o.prototype.activate=function(){o.current&&o.current.deactivate(),o.current=this,this.active=!0,this.dom.overlay.style.display="none",h.addClassName(this.dom.container,"vis-active"),this.emit("change"),this.emit("activate"),this.keycharm.bind("esc",this.escListener)},o.prototype.deactivate=function(){this.active=!1,this.dom.overlay.style.display="",h.removeClassName(this.dom.container,"vis-active"),this.keycharm.unbind("esc",this.escListener),this.emit("change"),this.emit("deactivate")},o.prototype._onTapOverlay=function(t){this.activate(),t.stopPropagation()},t.exports=o},function(t,e,i){e.en={current:"current",time:"time"},e.en_EN=e.en,e.en_US=e.en,e.it={current:"attuale",time:"tempo"},e.it_IT=e.it,e.it_CH=e.it,e.nl={current:"huidige",time:"tijd"},e.nl_NL=e.nl,e.nl_BE=e.nl,e.de={current:"Aktuelle",time:"Zeit"},e.de_DE=e.de,e.fr={current:"actuel",time:"heure"},e.fr_FR=e.fr,e.fr_CA=e.fr,e.fr_BE=e.fr,e.es={current:"corriente",time:"hora"},e.es_ES=e.es},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){this.body=t,this.defaultOptions={type:null,orientation:{item:"bottom"},align:"auto",stack:!0,stackSubgroups:!0,groupOrderSwap:function(t,e,i){var o=e.order;e.order=t.order,t.order=o},groupOrder:"order",selectable:!0,multiselect:!1,itemsAlwaysDraggable:{item:!1,range:!1},editable:{updateTime:!1,updateGroup:!1,add:!1,remove:!1,overrideItems:!1},groupEditable:{order:!1,add:!1,remove:!1},snap:p.snap,onDropObjectOnItem:function(t,e,i){i(e)},onAdd:function(t,e){e(t)},onUpdate:function(t,e){e(t)},onMove:function(t,e){e(t)},onRemove:function(t,e){e(t)},onMoving:function(t,e){e(t)},onAddGroup:function(t,e){e(t)},onMoveGroup:function(t,e){e(t)},onRemoveGroup:function(t,e){e(t)},margin:{item:{horizontal:10,vertical:10},axis:20},showTooltips:!0,tooltip:{followMouse:!1,overflowMethod:"flip"},tooltipOnItemUpdateTime:!1},this.options=l.extend({},this.defaultOptions),this.options.rtl=e.rtl,this.itemOptions={type:{start:"Date",end:"Date"}},this.conversion={toScreen:t.util.toScreen,toTime:t.util.toTime},this.dom={},this.props={},this.hammer=null;var i=this;this.itemsData=null,this.groupsData=null,this.itemListeners={add:function(t,e,o){i._onAdd(e.items)},update:function(t,e,o){i._onUpdate(e.items)},remove:function(t,e,o){i._onRemove(e.items)}},this.groupListeners={add:function(t,e,o){if(i._onAddGroups(e.items),i.groupsData&&i.groupsData.length>0){var n=i.groupsData.getDataSet();n.get().forEach(function(t){if(t.nestedGroups){0!=t.showNested&&(t.showNested=!0);var e=[];t.nestedGroups.forEach(function(i){var o=n.get(i);o&&(o.nestedInGroup=t.id,0==t.showNested&&(o.visible=!1),e=e.concat(o))}),n.update(e,o)}})}},update:function(t,e,o){i._onUpdateGroups(e.items)},remove:function(t,e,o){i._onRemoveGroups(e.items)}},this.items={},this.groups={},this.groupIds=[],this.selection=[],this.popup=null,this.touchParams={},this.groupTouchParams={},this._create(),this.setOptions(e)}var s=i(29),r=o(s),a=i(6),h=o(a),d=i(10),l=i(2),u=i(11),c=i(12),p=i(66),f=i(16),m=i(68),v=i(69),g=i(101),y=i(102),b=i(70),_=i(103),w=i(104).default,x="__ungrouped__",k="__background__";n.prototype=new f,n.types={background:_,box:g,range:b,point:y},n.prototype._create=function(){var t=document.createElement("div");t.className="vis-itemset",t["timeline-itemset"]=this,this.dom.frame=t;var e=document.createElement("div");e.className="vis-background",t.appendChild(e),this.dom.background=e;var i=document.createElement("div");i.className="vis-foreground",t.appendChild(i),this.dom.foreground=i;var o=document.createElement("div");o.className="vis-axis",this.dom.axis=o;var n=document.createElement("div");n.className="vis-labelset",this.dom.labelSet=n,this._updateUngrouped();var s=new v(k,null,this);s.show(),this.groups[k]=s,this.hammer=new d(this.body.dom.centerContainer),this.hammer.on("hammer.input",function(t){t.isFirst&&this._onTouch(t)}.bind(this)),this.hammer.on("panstart",this._onDragStart.bind(this)),this.hammer.on("panmove",this._onDrag.bind(this)),this.hammer.on("panend",this._onDragEnd.bind(this)),this.hammer.get("pan").set({threshold:5,direction:d.DIRECTION_HORIZONTAL}),this.hammer.on("tap",this._onSelectItem.bind(this)),this.hammer.on("press",this._onMultiSelectItem.bind(this)),this.hammer.on("doubletap",this._onAddItem.bind(this)),this.options.rtl?this.groupHammer=new d(this.body.dom.rightContainer):this.groupHammer=new d(this.body.dom.leftContainer),this.groupHammer.on("tap",this._onGroupClick.bind(this)),this.groupHammer.on("panstart",this._onGroupDragStart.bind(this)),this.groupHammer.on("panmove",this._onGroupDrag.bind(this)),this.groupHammer.on("panend",this._onGroupDragEnd.bind(this)),this.groupHammer.get("pan").set({threshold:5,direction:d.DIRECTION_VERTICAL}),this.body.dom.centerContainer.addEventListener("mouseover",this._onMouseOver.bind(this)),this.body.dom.centerContainer.addEventListener("mouseout",this._onMouseOut.bind(this)),this.body.dom.centerContainer.addEventListener("mousemove",this._onMouseMove.bind(this)),this.body.dom.centerContainer.addEventListener("contextmenu",this._onDragEnd.bind(this)),this.body.dom.centerContainer.addEventListener("mousewheel",this._onMouseWheel.bind(this)),this.show()},n.prototype.setOptions=function(t){if(t){var e=["type","rtl","align","order","stack","stackSubgroups","selectable","multiselect","multiselectPerGroup","groupOrder","dataAttributes","template","groupTemplate","visibleFrameTemplate","hide","snap","groupOrderSwap","showTooltips","tooltip","tooltipOnItemUpdateTime"];l.selectiveExtend(e,this.options,t),"itemsAlwaysDraggable"in t&&("boolean"==typeof t.itemsAlwaysDraggable?(this.options.itemsAlwaysDraggable.item=t.itemsAlwaysDraggable,this.options.itemsAlwaysDraggable.range=!1):"object"===(0,h.default)(t.itemsAlwaysDraggable)&&(l.selectiveExtend(["item","range"],this.options.itemsAlwaysDraggable,t.itemsAlwaysDraggable),this.options.itemsAlwaysDraggable.item||(this.options.itemsAlwaysDraggable.range=!1))),"orientation"in t&&("string"==typeof t.orientation?this.options.orientation.item="top"===t.orientation?"top":"bottom":"object"===(0,h.default)(t.orientation)&&"item"in t.orientation&&(this.options.orientation.item=t.orientation.item)),"margin"in t&&("number"==typeof t.margin?(this.options.margin.axis=t.margin,this.options.margin.item.horizontal=t.margin,this.options.margin.item.vertical=t.margin):"object"===(0,h.default)(t.margin)&&(l.selectiveExtend(["axis"],this.options.margin,t.margin),"item"in t.margin&&("number"==typeof t.margin.item?(this.options.margin.item.horizontal=t.margin.item,this.options.margin.item.vertical=t.margin.item):"object"===(0,h.default)(t.margin.item)&&l.selectiveExtend(["horizontal","vertical"],this.options.margin.item,t.margin.item)))),"editable"in t&&("boolean"==typeof t.editable?(this.options.editable.updateTime=t.editable,this.options.editable.updateGroup=t.editable,this.options.editable.add=t.editable,this.options.editable.remove=t.editable,this.options.editable.overrideItems=!1):"object"===(0,h.default)(t.editable)&&l.selectiveExtend(["updateTime","updateGroup","add","remove","overrideItems"],this.options.editable,t.editable)),"groupEditable"in t&&("boolean"==typeof t.groupEditable?(this.options.groupEditable.order=t.groupEditable,this.options.groupEditable.add=t.groupEditable,this.options.groupEditable.remove=t.groupEditable):"object"===(0,h.default)(t.groupEditable)&&l.selectiveExtend(["order","add","remove"],this.options.groupEditable,t.groupEditable));["onDropObjectOnItem","onAdd","onUpdate","onRemove","onMove","onMoving","onAddGroup","onMoveGroup","onRemoveGroup"].forEach(function(e){var i=t[e];if(i){if(!(i instanceof Function))throw new Error("option "+e+" must be a function "+e+"(item, callback)");this.options[e]=i}}.bind(this)),this.markDirty()}},n.prototype.markDirty=function(t){this.groupIds=[],t&&t.refreshItems&&l.forEach(this.items,function(t){t.dirty=!0,t.displayed&&t.redraw()})},n.prototype.destroy=function(){this.hide(),this.setItems(null),this.setGroups(null),this.hammer=null,this.body=null,this.conversion=null},n.prototype.hide=function(){this.dom.frame.parentNode&&this.dom.frame.parentNode.removeChild(this.dom.frame),this.dom.axis.parentNode&&this.dom.axis.parentNode.removeChild(this.dom.axis),this.dom.labelSet.parentNode&&this.dom.labelSet.parentNode.removeChild(this.dom.labelSet)},n.prototype.show=function(){this.dom.frame.parentNode||this.body.dom.center.appendChild(this.dom.frame),this.dom.axis.parentNode||this.body.dom.backgroundVertical.appendChild(this.dom.axis),this.dom.labelSet.parentNode||(this.options.rtl?this.body.dom.right.appendChild(this.dom.labelSet):this.body.dom.left.appendChild(this.dom.labelSet))},n.prototype.setSelection=function(t){var e,i,o,n;for(void 0==t&&(t=[]),Array.isArray(t)||(t=[t]),e=0,i=this.selection.length;e<i;e++)o=this.selection[e],(n=this.items[o])&&n.unselect();for(this.selection=[],e=0,i=t.length;e<i;e++)o=t[e],(n=this.items[o])&&(this.selection.push(o),n.select())},n.prototype.getSelection=function(){return this.selection.concat([])},n.prototype.getVisibleItems=function(){var t,e,i=this.body.range.getRange();this.options.rtl?(t=this.body.util.toScreen(i.start),e=this.body.util.toScreen(i.end)):(e=this.body.util.toScreen(i.start),t=this.body.util.toScreen(i.end));var o=[];for(var n in this.groups)if(this.groups.hasOwnProperty(n))for(var s=this.groups[n],r=s.isVisible?s.visibleItems:[],a=0;a<r.length;a++){var h=r[a];this.options.rtl?h.right<e&&h.right+h.width>t&&o.push(h.id):h.left<t&&h.left+h.width>e&&o.push(h.id)}return o},n.prototype._deselect=function(t){for(var e=this.selection,i=0,o=e.length;i<o;i++)if(e[i]==t){e.splice(i,1);break}},n.prototype.redraw=function(){var t=this.options.margin,e=this.body.range,i=l.option.asSize,o=this.options,n=o.orientation.item,s=!1,r=this.dom.frame;this.props.top=this.body.domProps.top.height+this.body.domProps.border.top,this.options.rtl?this.props.right=this.body.domProps.right.width+this.body.domProps.border.right:this.props.left=this.body.domProps.left.width+this.body.domProps.border.left,r.className="vis-itemset",s=this._orderGroups()||s;var a=e.end-e.start,h=a!=this.lastVisibleInterval||this.props.width!=this.props.lastWidth,d=e.start!=this.lastRangeStart,u=o.stack!=this.lastStack,c=o.stackSubgroups!=this.lastStackSubgroups,p=h||d||u||c;this.lastVisibleInterval=a,this.lastRangeStart=e.start,this.lastStack=o.stack,this.lastStackSubgroups=o.stackSubgroups,this.props.lastWidth=this.props.width;var f=this._firstGroup(),m={item:t.item,axis:t.axis},v={item:t.item,axis:t.item.vertical/2},g=0,y=t.axis+t.item.vertical;this.groups[k].redraw(e,v,p);var b={},_=0;if(l.forEach(this.groups,function(t,i){if(i!==k){var o=t==f?m:v;b[i]=t.redraw(e,o,p,!0),_=b[i].length}}),_>0){for(var w={},x=0;x<_;x++)l.forEach(b,function(t,e){w[e]=t[x]()});l.forEach(this.groups,function(t,e){if(e!==k){var i=w[e];s=i||s,g+=t.height}}),g=Math.max(g,y)}return g=Math.max(g,y),r.style.height=i(g),this.props.width=r.offsetWidth,this.props.height=g,this.dom.axis.style.top=i("top"==n?this.body.domProps.top.height+this.body.domProps.border.top:this.body.domProps.top.height+this.body.domProps.centerContainer.height),this.options.rtl?this.dom.axis.style.right="0":this.dom.axis.style.left="0",this.initialItemSetDrawn=!0,s=this._isResized()||s},n.prototype._firstGroup=function(){var t="top"==this.options.orientation.item?0:this.groupIds.length-1,e=this.groupIds[t];return this.groups[e]||this.groups[x]||null},n.prototype._updateUngrouped=function(){var t,e,i=this.groups[x];if(this.groupsData){if(i){i.hide(),delete this.groups[x];for(e in this.items)if(this.items.hasOwnProperty(e)){t=this.items[e],t.parent&&t.parent.remove(t);var o=this._getGroupId(t.data),n=this.groups[o];n&&n.add(t)||t.hide()}}}else if(!i){i=new m(null,null,this),this.groups[x]=i;for(e in this.items)this.items.hasOwnProperty(e)&&(t=this.items[e],i.add(t));i.show()}},n.prototype.getLabelSet=function(){return this.dom.labelSet},n.prototype.setItems=function(t){var e,i=this,o=this.itemsData;if(t){if(!(t instanceof u||t instanceof c))throw new TypeError("Data must be an instance of DataSet or DataView");this.itemsData=t}else this.itemsData=null;if(o&&(l.forEach(this.itemListeners,function(t,e){o.off(e,t)}),e=o.getIds(),this._onRemove(e)),this.itemsData){var n=this.id;l.forEach(this.itemListeners,function(t,e){i.itemsData.on(e,t,n)}),e=this.itemsData.getIds(),this._onAdd(e),this._updateUngrouped()}this.body.emitter.emit("_change",{queue:!0})},n.prototype.getItems=function(){return this.itemsData},n.prototype.setGroups=function(t){var e,i=this;if(this.groupsData&&(l.forEach(this.groupListeners,function(t,e){i.groupsData.off(e,t)}),e=this.groupsData.getIds(),this.groupsData=null,this._onRemoveGroups(e)),t){if(!(t instanceof u||t instanceof c))throw new TypeError("Data must be an instance of DataSet or DataView");this.groupsData=t}else this.groupsData=null;if(this.groupsData){var o=this.groupsData;this.groupsData instanceof c&&(o=this.groupsData.getDataSet()),o.get().forEach(function(t){t.nestedGroups&&t.nestedGroups.forEach(function(e){var i=o.get(e);i.nestedInGroup=t.id,0==t.showNested&&(i.visible=!1),o.update(i)})});var n=this.id;l.forEach(this.groupListeners,function(t,e){i.groupsData.on(e,t,n)}),e=this.groupsData.getIds(),this._onAddGroups(e)}this._updateUngrouped(),this._order(),this.body.emitter.emit("_change",{queue:!0})},n.prototype.getGroups=function(){return this.groupsData},n.prototype.removeItem=function(t){var e=this.itemsData.get(t),i=this.itemsData.getDataSet();e&&this.options.onRemove(e,function(e){e&&i.remove(t)})},n.prototype._getType=function(t){return t.type||this.options.type||(t.end?"range":"box")},n.prototype._getGroupId=function(t){return"background"==this._getType(t)&&void 0==t.group?k:this.groupsData?t.group:x},n.prototype._onUpdate=function(t){var e=this;t.forEach(function(t){var i,o=e.itemsData.get(t,e.itemOptions),s=e.items[t],r=o?e._getType(o):null,a=n.types[r];if(s&&(a&&s instanceof a?e._updateItem(s,o):(i=s.selected,e._removeItem(s),s=null)),!s&&o){if(!a)throw"rangeoverflow"==r?new TypeError('Item type "rangeoverflow" is deprecated. Use css styling instead: .vis-item.vis-range .vis-item-content {overflow: visible;}'):new TypeError('Unknown item type "'+r+'"');s=new a(o,e.conversion,e.options),s.id=t,e._addItem(s),i&&(this.selection.push(t),s.select())}}.bind(this)),this._order(),this.body.emitter.emit("_change",{queue:!0})},n.prototype._onAdd=n.prototype._onUpdate,n.prototype._onRemove=function(t){var e=0,i=this;t.forEach(function(t){var o=i.items[t];o&&(e++,i._removeItem(o))}),e&&(this._order(),this.body.emitter.emit("_change",{queue:!0}))},n.prototype._order=function(){l.forEach(this.groups,function(t){t.order()})},n.prototype._onUpdateGroups=function(t){this._onAddGroups(t)},n.prototype._onAddGroups=function(t){var e=this;t.forEach(function(t){var i=e.groupsData.get(t),o=e.groups[t];if(o)o.setData(i);else{if(t==x||t==k)throw new Error("Illegal group id. "+t+" is a reserved id.");var n=(0,r.default)(e.options);l.extend(n,{height:null}),o=new m(t,i,e),e.groups[t]=o;for(var s in e.items)if(e.items.hasOwnProperty(s)){var a=e.items[s];a.data.group==t&&o.add(a)}o.order(),o.show()}}),this.body.emitter.emit("_change",{queue:!0})},n.prototype._onRemoveGroups=function(t){var e=this.groups;t.forEach(function(t){var i=e[t];i&&(i.hide(),delete e[t])}),this.markDirty(),this.body.emitter.emit("_change",{queue:!0})},n.prototype._orderGroups=function(){if(this.groupsData){var t=this.groupsData.getIds({order:this.options.groupOrder});t=this._orderNestedGroups(t);var e=!l.equalArray(t,this.groupIds);if(e){var i=this.groups;t.forEach(function(t){i[t].hide()}),t.forEach(function(t){i[t].show()}),this.groupIds=t}return e}return!1},n.prototype._orderNestedGroups=function(t){var e=[];return t.forEach(function(t){var i=this.groupsData.get(t);if(i.nestedInGroup||e.push(t),i.nestedGroups){var o=this.groupsData.get({filter:function(e){return e.nestedInGroup==t},order:this.options.groupOrder}),n=o.map(function(t){return t.id});e=e.concat(n)}},this),e},n.prototype._addItem=function(t){this.items[t.id]=t;var e=this._getGroupId(t.data),i=this.groups[e];i?i&&i.data&&i.data.showNested&&(t.groupShowing=!0):t.groupShowing=!1,i&&i.add(t)},n.prototype._updateItem=function(t,e){t.setData(e);var i=this._getGroupId(t.data),o=this.groups[i];o?o&&o.data&&o.data.showNested&&(t.groupShowing=!0):t.groupShowing=!1},n.prototype._removeItem=function(t){t.hide(),delete this.items[t.id];var e=this.selection.indexOf(t.id);-1!=e&&this.selection.splice(e,1),t.parent&&t.parent.remove(t)},n.prototype._constructByEndArray=function(t){for(var e=[],i=0;i<t.length;i++)t[i]instanceof b&&e.push(t[i]);return e},n.prototype._onTouch=function(t){this.touchParams.item=this.itemFromTarget(t),this.touchParams.dragLeftItem=t.target.dragLeftItem||!1,this.touchParams.dragRightItem=t.target.dragRightItem||!1,this.touchParams.itemProps=null},n.prototype._getGroupIndex=function(t){for(var e=0;e<this.groupIds.length;e++)if(t==this.groupIds[e])return e},n.prototype._onDragStart=function(t){if(!this.touchParams.itemIsDragging){var e,i=this.touchParams.item||null,o=this;if(i&&(i.selected||this.options.itemsAlwaysDraggable.item)){if(this.options.editable.overrideItems&&!this.options.editable.updateTime&&!this.options.editable.updateGroup)return;if(null!=i.editable&&!i.editable.updateTime&&!i.editable.updateGroup&&!this.options.editable.overrideItems)return;var n=this.touchParams.dragLeftItem,s=this.touchParams.dragRightItem;if(this.touchParams.itemIsDragging=!0,this.touchParams.selectedItem=i,n)e={item:n,initialX:t.center.x,dragLeft:!0,data:this._cloneItemData(i.data)},this.touchParams.itemProps=[e];else if(s)e={item:s,initialX:t.center.x,dragRight:!0,data:this._cloneItemData(i.data)},this.touchParams.itemProps=[e];else if(this.options.editable.add&&(t.srcEvent.ctrlKey||t.srcEvent.metaKey))this._onDragStartAddItem(t);else{this.groupIds.length<1&&this.redraw();var r=this._getGroupIndex(i.data.group),a=this.options.itemsAlwaysDraggable.item&&!i.selected?[i.id]:this.getSelection();this.touchParams.itemProps=a.map(function(e){var i=o.items[e],n=o._getGroupIndex(i.data.group);return{item:i,initialX:t.center.x,groupOffset:r-n,data:this._cloneItemData(i.data)}}.bind(this))}t.stopPropagation()}else this.options.editable.add&&(t.srcEvent.ctrlKey||t.srcEvent.metaKey)&&this._onDragStartAddItem(t)}},n.prototype._onDragStartAddItem=function(t){var e,i,o=this.options.snap||null;this.options.rtl?(e=l.getAbsoluteRight(this.dom.frame),i=e-t.center.x+10):(e=l.getAbsoluteLeft(this.dom.frame),i=t.center.x-e-10);var n=this.body.util.toTime(i),s=this.body.util.getScale(),r=this.body.util.getStep(),a=o?o(n,s,r):n,h=a,d={type:"range",start:a,end:h,content:"new item"},u=l.randomUUID();d[this.itemsData._fieldId]=u;var c=this.groupFromTarget(t);c&&(d.group=c.groupId);var p=new b(d,this.conversion,this.options);p.id=u,p.data=this._cloneItemData(d),this._addItem(p),this.touchParams.selectedItem=p;var f={item:p,initialX:t.center.x,data:p.data};this.options.rtl?f.dragLeft=!0:f.dragRight=!0,this.touchParams.itemProps=[f],t.stopPropagation()},n.prototype._onDrag=function(t){if(this.touchParams.itemProps){t.stopPropagation();var e,i=this,o=this.options.snap||null;e=this.options.rtl?this.body.dom.root.offsetLeft+this.body.domProps.right.width:this.body.dom.root.offsetLeft+this.body.domProps.left.width;var n=this.body.util.getScale(),s=this.body.util.getStep(),r=this.touchParams.selectedItem,a=(this.options.editable.overrideItems||null==r.editable)&&this.options.editable.updateGroup||!this.options.editable.overrideItems&&null!=r.editable&&r.editable.updateGroup,h=null;if(a&&r&&void 0!=r.data.group){var d=i.groupFromTarget(t);d&&(h=this._getGroupIndex(d.groupId))}this.touchParams.itemProps.forEach(function(d){var u,c,p,f,m,v=i.body.util.toTime(t.center.x-e),g=i.body.util.toTime(d.initialX-e);u=this.options.rtl?-(v-g):v-g;var y=this._cloneItemData(d.item.data);if(null==d.item.editable||d.item.editable.updateTime||d.item.editable.updateGroup||i.options.editable.overrideItems){if((this.options.editable.overrideItems||null==r.editable)&&this.options.editable.updateTime||!this.options.editable.overrideItems&&null!=r.editable&&r.editable.updateTime)if(d.dragLeft)this.options.rtl?void 0!=y.end&&(p=l.convert(d.data.end,"Date"),m=new Date(p.valueOf()+u),y.end=o?o(m,n,s):m):void 0!=y.start&&(c=l.convert(d.data.start,"Date"),f=new Date(c.valueOf()+u),y.start=o?o(f,n,s):f);else if(d.dragRight)this.options.rtl?void 0!=y.start&&(c=l.convert(d.data.start,"Date"),f=new Date(c.valueOf()+u),y.start=o?o(f,n,s):f):void 0!=y.end&&(p=l.convert(d.data.end,"Date"),m=new Date(p.valueOf()+u),y.end=o?o(m,n,s):m);else if(void 0!=y.start)if(c=l.convert(d.data.start,"Date").valueOf(),f=new Date(c+u),void 0!=y.end){p=l.convert(d.data.end,"Date");var b=p.valueOf()-c.valueOf();y.start=o?o(f,n,s):f,y.end=new Date(y.start.valueOf()+b)}else y.start=o?o(f,n,s):f;if(a&&!d.dragLeft&&!d.dragRight&&null!=h&&void 0!=y.group){var _=h-d.groupOffset;_=Math.max(0,_),_=Math.min(i.groupIds.length-1,_),y.group=i.groupIds[_]}y=this._cloneItemData(y),i.options.onMoving(y,function(t){t&&d.item.setData(this._cloneItemData(t,"Date"))}.bind(this))}}.bind(this)),this.body.emitter.emit("_change")}},n.prototype._moveToGroup=function(t,e){var i=this.groups[e];if(i&&i.groupId!=t.data.group){var o=t.parent;o.remove(t),o.order(),t.data.group=i.groupId,i.add(t),i.order()}},n.prototype._onDragEnd=function(t){if(this.touchParams.itemIsDragging=!1,this.touchParams.itemProps){t.stopPropagation();var e=this,i=this.itemsData.getDataSet(),o=this.touchParams.itemProps;this.touchParams.itemProps=null,o.forEach(function(t){var o=t.item.id;if(null!=e.itemsData.get(o,e.itemOptions)){var n=this._cloneItemData(t.item.data);e.options.onMove(n,function(n){n?(n[i._fieldId]=o,i.update(n)):(t.item.setData(t.data),e.body.emitter.emit("_change"))})}else e.options.onAdd(t.item.data,function(i){e._removeItem(t.item),i&&e.itemsData.getDataSet().add(i),e.body.emitter.emit("_change")})}.bind(this))}},n.prototype._onGroupClick=function(t){var e=this.groupFromTarget(t);if(e&&e.nestedGroups){var i=this.groupsData.getDataSet(),o=i.get(e.groupId);void 0==o.showNested&&(o.showNested=!0),o.showNested=!o.showNested;var n=i.get(e.nestedGroups).map(function(t){return t.visible=o.showNested,t});if(i.update(n.concat(o)),o.showNested)l.removeClassName(e.dom.label,"collapsed"),l.addClassName(e.dom.label,"expanded");else{l.removeClassName(e.dom.label,"expanded");var s=this.options.rtl?"collapsed-rtl":"collapsed";l.addClassName(e.dom.label,s)}}},n.prototype._onGroupDragStart=function(t){this.options.groupEditable.order&&(this.groupTouchParams.group=this.groupFromTarget(t),this.groupTouchParams.group&&(t.stopPropagation(),this.groupTouchParams.originalOrder=this.groupsData.getIds({order:this.options.groupOrder})))},n.prototype._onGroupDrag=function(t){if(this.options.groupEditable.order&&this.groupTouchParams.group){t.stopPropagation();var e=this.groupsData;this.groupsData instanceof c&&(e=this.groupsData.getDataSet());var i=this.groupFromTarget(t);if(i&&i.height!=this.groupTouchParams.group.height){var o=i.top<this.groupTouchParams.group.top,n=t.center?t.center.y:t.clientY,s=l.getAbsoluteTop(i.dom.foreground),r=this.groupTouchParams.group.height;if(o){if(s+r<n)return}else{if(s+i.height-r>n)return}}if(i&&i!=this.groupTouchParams.group){var a=e.get(i.groupId),h=e.get(this.groupTouchParams.group.groupId);h&&a&&(this.options.groupOrderSwap(h,a,e),e.update(h),e.update(a));var d=e.getIds({order:this.options.groupOrder});if(!l.equalArray(d,this.groupTouchParams.originalOrder))for(var u=this.groupTouchParams.originalOrder,p=this.groupTouchParams.group.groupId,f=Math.min(u.length,d.length),m=0,v=0,g=0;m<f;){for(;m+v<f&&m+g<f&&d[m+v]==u[m+g];)m++;if(m+v>=f)break;if(d[m+v]==p)v=1;else if(u[m+g]==p)g=1;else{var y=d.indexOf(u[m+g]),b=e.get(d[m+v]),_=e.get(u[m+g]);this.options.groupOrderSwap(b,_,e),e.update(b),e.update(_);var w=d[m+v];d[m+v]=u[m+g],d[y]=w,m++}}}}},n.prototype._onGroupDragEnd=function(t){if(this.options.groupEditable.order&&this.groupTouchParams.group){t.stopPropagation();var e=this,i=e.groupTouchParams.group.groupId,o=e.groupsData.getDataSet(),n=l.extend({},o.get(i));e.options.onMoveGroup(n,function(t){if(t)t[o._fieldId]=i,o.update(t);else{var n=o.getIds({order:e.options.groupOrder});if(!l.equalArray(n,e.groupTouchParams.originalOrder))for(var s=e.groupTouchParams.originalOrder,r=Math.min(s.length,n.length),a=0;a<r;){for(;a<r&&n[a]==s[a];)a++;if(a>=r)break;var h=n.indexOf(s[a]),d=o.get(n[a]),u=o.get(s[a]);e.options.groupOrderSwap(d,u,o),o.update(d),o.update(u);var c=n[a];n[a]=s[a],n[h]=c,a++}}}),e.body.emitter.emit("groupDragged",{groupId:i})}},n.prototype._onSelectItem=function(t){if(this.options.selectable){var e=t.srcEvent&&(t.srcEvent.ctrlKey||t.srcEvent.metaKey),i=t.srcEvent&&t.srcEvent.shiftKey;if(e||i)return void this._onMultiSelectItem(t);var o=this.getSelection(),n=this.itemFromTarget(t),s=n?[n.id]:[];this.setSelection(s);var r=this.getSelection();(r.length>0||o.length>0)&&this.body.emitter.emit("select",{items:r,event:t})}},n.prototype._onMouseOver=function(t){var e=this.itemFromTarget(t);if(e){if(e!==this.itemFromRelatedTarget(t)){var i=e.getTitle();if(this.options.showTooltips&&i){null==this.popup&&(this.popup=new w(this.body.dom.root,this.options.tooltip.overflowMethod||"flip")),this.popup.setText(i);var o=this.body.dom.centerContainer;this.popup.setPosition(t.clientX-l.getAbsoluteLeft(o)+o.offsetLeft,t.clientY-l.getAbsoluteTop(o)+o.offsetTop),this.popup.show()}else null!=this.popup&&this.popup.hide();this.body.emitter.emit("itemover",{item:e.id,event:t})}}},n.prototype._onMouseOut=function(t){var e=this.itemFromTarget(t);if(e){e!==this.itemFromRelatedTarget(t)&&(null!=this.popup&&this.popup.hide(),this.body.emitter.emit("itemout",{item:e.id,event:t}))}},n.prototype._onMouseMove=function(t){if(this.itemFromTarget(t)&&this.options.showTooltips&&this.options.tooltip.followMouse&&this.popup&&!this.popup.hidden){var e=this.body.dom.centerContainer;this.popup.setPosition(t.clientX-l.getAbsoluteLeft(e)+e.offsetLeft,t.clientY-l.getAbsoluteTop(e)+e.offsetTop),this.popup.show()}},n.prototype._onMouseWheel=function(t){this.touchParams.itemIsDragging&&this._onDragEnd(t)},n.prototype._onUpdateItem=function(t){if(this.options.selectable&&this.options.editable.add){var e=this;if(t){var i=e.itemsData.get(t.id);this.options.onUpdate(i,function(t){t&&e.itemsData.getDataSet().update(t)})}}},n.prototype._onDropObjectOnItem=function(t){var e=this.itemFromTarget(t),i=JSON.parse(t.dataTransfer.getData("text"));this.options.onDropObjectOnItem(i,e)},n.prototype._onAddItem=function(t){if(this.options.selectable&&this.options.editable.add){var e,i,o=this,n=this.options.snap||null;this.options.rtl?(e=l.getAbsoluteRight(this.dom.frame),i=e-t.center.x):(e=l.getAbsoluteLeft(this.dom.frame),i=t.center.x-e);var s,r,a=this.body.util.toTime(i),h=this.body.util.getScale(),d=this.body.util.getStep();"drop"==t.type?(r=JSON.parse(t.dataTransfer.getData("text")),r.content=r.content?r.content:"new item",r.start=r.start?r.start:n?n(a,h,d):a,r.type=r.type||"box",r[this.itemsData._fieldId]=r.id||l.randomUUID(),"range"!=r.type||r.end||(s=this.body.util.toTime(i+this.props.width/5),r.end=n?n(s,h,d):s)):(r={start:n?n(a,h,d):a,content:"new item"},r[this.itemsData._fieldId]=l.randomUUID(),"range"===this.options.type&&(s=this.body.util.toTime(i+this.props.width/5),r.end=n?n(s,h,d):s));var u=this.groupFromTarget(t);u&&(r.group=u.groupId),r=this._cloneItemData(r),this.options.onAdd(r,function(e){e&&(o.itemsData.getDataSet().add(e),"drop"==t.type&&o.setSelection([e.id]))})}},n.prototype._onMultiSelectItem=function(t){if(this.options.selectable){var e=this.itemFromTarget(t);if(e){ +var i=this.options.multiselect?this.getSelection():[];if((t.srcEvent&&t.srcEvent.shiftKey||!1)&&this.options.multiselect){var o=this.itemsData.get(e.id).group,s=void 0;this.options.multiselectPerGroup&&i.length>0&&(s=this.itemsData.get(i[0]).group),this.options.multiselectPerGroup&&void 0!=s&&s!=o||i.push(e.id);var r=n._getItemRange(this.itemsData.get(i,this.itemOptions));if(!this.options.multiselectPerGroup||s==o){i=[];for(var a in this.items)if(this.items.hasOwnProperty(a)){var h=this.items[a],d=h.data.start,l=void 0!==h.data.end?h.data.end:d;!(d>=r.min&&l<=r.max)||this.options.multiselectPerGroup&&s!=this.itemsData.get(h.id).group||h instanceof _||i.push(h.id)}}}else{var u=i.indexOf(e.id);-1==u?i.push(e.id):i.splice(u,1)}this.setSelection(i),this.body.emitter.emit("select",{items:this.getSelection(),event:t})}}},n._getItemRange=function(t){var e=null,i=null;return t.forEach(function(t){(null==i||t.start<i)&&(i=t.start),void 0!=t.end?(null==e||t.end>e)&&(e=t.end):(null==e||t.start>e)&&(e=t.start)}),{min:i,max:e}},n.prototype.itemFromElement=function(t){for(var e=t;e;){if(e.hasOwnProperty("timeline-item"))return e["timeline-item"];e=e.parentNode}return null},n.prototype.itemFromTarget=function(t){return this.itemFromElement(t.target)},n.prototype.itemFromRelatedTarget=function(t){return this.itemFromElement(t.relatedTarget)},n.prototype.groupFromTarget=function(t){var e=t.center?t.center.y:t.clientY,i=this.groupIds;i.length<=0&&this.groupsData&&(i=this.groupsData.getIds({order:this.options.groupOrder}));for(var o=0;o<i.length;o++){var n=i[o],s=this.groups[n],r=s.dom.foreground,a=l.getAbsoluteTop(r);if(e>a&&e<a+r.offsetHeight)return s;if("top"===this.options.orientation.item){if(o===this.groupIds.length-1&&e>a)return s}else if(0===o&&e<a+r.offset)return s}return null},n.itemSetFromTarget=function(t){for(var e=t.target;e;){if(e.hasOwnProperty("timeline-itemset"))return e["timeline-itemset"];e=e.parentNode}return null},n.prototype._cloneItemData=function(t,e){var i=l.extend({},t);return e||(e=this.itemsData.getDataSet()._options.type),void 0!=i.start&&(i.start=l.convert(i.start,e&&e.start||"Date")),void 0!=i.end&&(i.end=l.convert(i.end,e&&e.end||"Date")),i},t.exports=n},function(t,e,i){e.orderByStart=function(t){t.sort(function(t,e){return t.data.start-e.data.start})},e.orderByEnd=function(t){t.sort(function(t,e){return("end"in t.data?t.data.end:t.data.start)-("end"in e.data?e.data.end:e.data.start)})},e.stack=function(t,i,o){if(o)for(var n=0;n<t.length;n++)t[n].top=null;for(var n=0;n<t.length;n++){var s=t[n];if(s.stack&&null===s.top){s.top=i.axis;do{for(var r=null,a=0,h=t.length;a<h;a++){var d=t[a];if(null!==d.top&&d!==s&&d.stack&&e.collision(s,d,i.item,d.options.rtl)){r=d;break}}null!=r&&(s.top=r.top+r.height+i.item.vertical)}while(r)}}},e.substack=function(t,i,o){for(var n=0;n<t.length;n++)t[n].top=null;var s=o.height;for(n=0;n<t.length;n++){var r=t[n];if(r.stack&&null===r.top){r.top=r.baseTop;do{for(var a=null,h=0,d=t.length;h<d;h++){var l=t[h];if(null!==l.top&&l!==r&&e.collision(r,l,i.item,l.options.rtl)){a=l;break}}null!=a&&(r.top=a.top+a.height+i.item.vertical),r.top+r.height>s&&(s=r.top+r.height)}while(a)}}o.height=s-o.top+.5*i.item.vertical},e.nostack=function(t,i,o,n){for(var s=0;s<t.length;s++)if(void 0==t[s].data.subgroup)t[s].top=i.item.vertical;else if(void 0!==t[s].data.subgroup&&n){var r=0;for(var a in o)o.hasOwnProperty(a)&&1==o[a].visible&&o[a].index<o[t[s].data.subgroup].index&&(r+=o[a].height,o[t[s].data.subgroup].top=r);t[s].top=r+.5*i.item.vertical}n||e.stackSubgroups(t,i,o)},e.stackSubgroups=function(t,i,o){for(var n in o)if(o.hasOwnProperty(n)){o[n].top=0;do{var s=null;for(var r in o)if(null!==o[r].top&&r!==n&&o[n].index>o[r].index&&e.collisionByTimes(o[n],o[r])){s=o[r];break}null!=s&&(o[n].top=s.top+s.height)}while(s)}for(var a=0;a<t.length;a++)void 0!==t[a].data.subgroup&&(t[a].top=o[t[a].data.subgroup].top+.5*i.item.vertical)},e.stackSubgroupsWithInnerStack=function(t,i,o){var n=!1,s=[];for(var r in o)o[r].hasOwnProperty("index")?s[o[r].index]=r:s.push(r);for(var a=0;a<s.length;a++)if(r=s[a],o.hasOwnProperty(r)){n=n||o[r].stack,o[r].top=0;for(var h in o)o[h].visible&&o[r].index>o[h].index&&(o[r].top+=o[h].height);for(var d=t[r],l=0;l<d.length;l++)void 0!==d[l].data.subgroup&&(d[l].top=o[d[l].data.subgroup].top+.5*i.item.vertical,o[r].stack&&(d[l].baseTop=d[l].top));n&&o[r].stack&&e.substack(t[r],i,o[r])}},e.collision=function(t,e,i,o){return o?t.right-i.horizontal+.001<e.right+e.width&&t.right+t.width+i.horizontal-.001>e.right&&t.top-i.vertical+.001<e.top+e.height&&t.top+t.height+i.vertical-.001>e.top:t.left-i.horizontal+.001<e.left+e.width&&t.left+t.width+i.horizontal-.001>e.left&&t.top-i.vertical+.001<e.top+e.height&&t.top+t.height+i.vertical-.001>e.top},e.collisionByTimes=function(t,e){return t.start<=e.start&&t.end>=e.start&&t.top<e.top+e.height&&t.top+t.height>e.top||e.start<=t.start&&e.end>=t.start&&e.top<t.top+t.height&&e.top+e.height>t.top}},function(t,e,i){function o(t,e,i){if(this.props={dot:{width:0,height:0},line:{width:0,height:0}},this.options=i,t&&void 0==t.start)throw new Error('Property "start" missing in item '+t);n.call(this,t,e,i)}var n=i(38);o.prototype=new n(null,null,null),o.prototype.isVisible=function(t){var e=this.options.align,i=this.width*t.getMillisecondsPerPixel();return"right"==e?this.data.start.getTime()>t.start&&this.data.start.getTime()-i<t.end:"left"==e?this.data.start.getTime()+i>t.start&&this.data.start.getTime()<t.end:this.data.start.getTime()+i/2>t.start&&this.data.start.getTime()-i/2<t.end},o.prototype._createDomElement=function(){this.dom||(this.dom={},this.dom.box=document.createElement("DIV"),this.dom.content=document.createElement("DIV"),this.dom.content.className="vis-item-content",this.dom.box.appendChild(this.dom.content),this.dom.line=document.createElement("DIV"),this.dom.line.className="vis-line",this.dom.dot=document.createElement("DIV"),this.dom.dot.className="vis-dot",this.dom.box["timeline-item"]=this,this.dirty=!0)},o.prototype._appendDomElement=function(){if(!this.parent)throw new Error("Cannot redraw item: no parent attached");if(!this.dom.box.parentNode){var t=this.parent.dom.foreground;if(!t)throw new Error("Cannot redraw item: parent has no foreground container element");t.appendChild(this.dom.box)}if(!this.dom.line.parentNode){var e=this.parent.dom.background;if(!e)throw new Error("Cannot redraw item: parent has no background container element");e.appendChild(this.dom.line)}if(!this.dom.dot.parentNode){var i=this.parent.dom.axis;if(!e)throw new Error("Cannot redraw item: parent has no axis container element");i.appendChild(this.dom.dot)}this.displayed=!0},o.prototype._updateDirtyDomComponents=function(){if(this.dirty){this._updateContents(this.dom.content),this._updateDataAttributes(this.dom.box),this._updateStyle(this.dom.box);var t=this.editable.updateTime||this.editable.updateGroup,e=(this.data.className?" "+this.data.className:"")+(this.selected?" vis-selected":"")+(t?" vis-editable":" vis-readonly");this.dom.box.className="vis-item vis-box"+e,this.dom.line.className="vis-item vis-line"+e,this.dom.dot.className="vis-item vis-dot"+e}},o.prototype._getDomComponentsSizes=function(){return{previous:{right:this.dom.box.style.right,left:this.dom.box.style.left},dot:{height:this.dom.dot.offsetHeight,width:this.dom.dot.offsetWidth},line:{width:this.dom.line.offsetWidth},box:{width:this.dom.box.offsetWidth,height:this.dom.box.offsetHeight}}},o.prototype._updateDomComponentsSizes=function(t){this.options.rtl?this.dom.box.style.right="0px":this.dom.box.style.left="0px",this.props.dot.height=t.dot.height,this.props.dot.width=t.dot.width,this.props.line.width=t.line.width,this.width=t.box.width,this.height=t.box.height,this.options.rtl?this.dom.box.style.right=t.previous.right:this.dom.box.style.left=t.previous.left,this.dirty=!1},o.prototype._repaintDomAdditionals=function(){this._repaintOnItemUpdateTimeTooltip(this.dom.box),this._repaintDragCenter(),this._repaintDeleteButton(this.dom.box)},o.prototype.redraw=function(t){var e,i=[this._createDomElement.bind(this),this._appendDomElement.bind(this),this._updateDirtyDomComponents.bind(this),function(){this.dirty&&(e=this._getDomComponentsSizes())}.bind(this),function(){this.dirty&&this._updateDomComponentsSizes.bind(this)(e)}.bind(this),this._repaintDomAdditionals.bind(this)];if(t)return i;var o;return i.forEach(function(t){o=t()}),o},o.prototype.show=function(){this.displayed||this.redraw()},o.prototype.hide=function(){if(this.displayed){var t=this.dom;t.box.parentNode&&t.box.parentNode.removeChild(t.box),t.line.parentNode&&t.line.parentNode.removeChild(t.line),t.dot.parentNode&&t.dot.parentNode.removeChild(t.dot),this.displayed=!1}},o.prototype.repositionX=function(){var t=this.conversion.toScreen(this.data.start),e=this.options.align;"right"==e?this.options.rtl?(this.right=t-this.width,this.dom.box.style.right=this.right+"px",this.dom.line.style.right=t-this.props.line.width+"px",this.dom.dot.style.right=t-this.props.line.width/2-this.props.dot.width/2+"px"):(this.left=t-this.width,this.dom.box.style.left=this.left+"px",this.dom.line.style.left=t-this.props.line.width+"px",this.dom.dot.style.left=t-this.props.line.width/2-this.props.dot.width/2+"px"):"left"==e?this.options.rtl?(this.right=t,this.dom.box.style.right=this.right+"px",this.dom.line.style.right=t+"px",this.dom.dot.style.right=t+this.props.line.width/2-this.props.dot.width/2+"px"):(this.left=t,this.dom.box.style.left=this.left+"px",this.dom.line.style.left=t+"px",this.dom.dot.style.left=t+this.props.line.width/2-this.props.dot.width/2+"px"):this.options.rtl?(this.right=t-this.width/2,this.dom.box.style.right=this.right+"px",this.dom.line.style.right=t-this.props.line.width+"px",this.dom.dot.style.right=t-this.props.dot.width/2+"px"):(this.left=t-this.width/2,this.dom.box.style.left=this.left+"px",this.dom.line.style.left=t-this.props.line.width/2+"px",this.dom.dot.style.left=t-this.props.dot.width/2+"px")},o.prototype.repositionY=function(){var t=this.options.orientation.item,e=this.dom.box,i=this.dom.line,o=this.dom.dot;if("top"==t)e.style.top=(this.top||0)+"px",i.style.top="0",i.style.height=this.parent.top+this.top+1+"px",i.style.bottom="";else{var n=this.parent.itemSet.props.height,s=n-this.parent.top-this.parent.height+this.top;e.style.top=(this.parent.height-this.top-this.height||0)+"px",i.style.top=n-s+"px",i.style.bottom="0"}o.style.top=-this.props.dot.height/2+"px"},o.prototype.getWidthLeft=function(){return this.width/2},o.prototype.getWidthRight=function(){return this.width/2},t.exports=o},function(t,e,i){function o(t,e,i){if(this.props={dot:{top:0,width:0,height:0},content:{height:0,marginLeft:0,marginRight:0}},this.options=i,t&&void 0==t.start)throw new Error('Property "start" missing in item '+t);n.call(this,t,e,i)}var n=i(38);o.prototype=new n(null,null,null),o.prototype.isVisible=function(t){var e=this.width*t.getMillisecondsPerPixel();return this.data.start.getTime()+e>t.start&&this.data.start<t.end},o.prototype._createDomElement=function(){this.dom||(this.dom={},this.dom.point=document.createElement("div"),this.dom.content=document.createElement("div"),this.dom.content.className="vis-item-content",this.dom.point.appendChild(this.dom.content),this.dom.dot=document.createElement("div"),this.dom.point.appendChild(this.dom.dot),this.dom.point["timeline-item"]=this,this.dirty=!0)},o.prototype._appendDomElement=function(){if(!this.parent)throw new Error("Cannot redraw item: no parent attached");if(!this.dom.point.parentNode){var t=this.parent.dom.foreground;if(!t)throw new Error("Cannot redraw item: parent has no foreground container element");t.appendChild(this.dom.point)}this.displayed=!0},o.prototype._updateDirtyDomComponents=function(){if(this.dirty){this._updateContents(this.dom.content),this._updateDataAttributes(this.dom.point),this._updateStyle(this.dom.point);var t=this.editable.updateTime||this.editable.updateGroup,e=(this.data.className?" "+this.data.className:"")+(this.selected?" vis-selected":"")+(t?" vis-editable":" vis-readonly");this.dom.point.className="vis-item vis-point"+e,this.dom.dot.className="vis-item vis-dot"+e}},o.prototype._getDomComponentsSizes=function(){return{dot:{width:this.dom.dot.offsetWidth,height:this.dom.dot.offsetHeight},content:{width:this.dom.content.offsetWidth,height:this.dom.content.offsetHeight},point:{width:this.dom.point.offsetWidth,height:this.dom.point.offsetHeight}}},o.prototype._updateDomComponentsSizes=function(t){this.props.dot.width=t.dot.width,this.props.dot.height=t.dot.height,this.props.content.height=t.content.height,this.options.rtl?this.dom.content.style.marginRight=2*this.props.dot.width+"px":this.dom.content.style.marginLeft=2*this.props.dot.width+"px",this.width=t.point.width,this.height=t.point.height,this.dom.dot.style.top=(this.height-this.props.dot.height)/2+"px",this.options.rtl?this.dom.dot.style.right=this.props.dot.width/2+"px":this.dom.dot.style.left=this.props.dot.width/2+"px",this.dirty=!1},o.prototype._repaintDomAdditionals=function(){this._repaintOnItemUpdateTimeTooltip(this.dom.point),this._repaintDragCenter(),this._repaintDeleteButton(this.dom.point)},o.prototype.redraw=function(t){var e,i=[this._createDomElement.bind(this),this._appendDomElement.bind(this),this._updateDirtyDomComponents.bind(this),function(){this.dirty&&(e=this._getDomComponentsSizes())}.bind(this),function(){this.dirty&&this._updateDomComponentsSizes.bind(this)(e)}.bind(this),this._repaintDomAdditionals.bind(this)];if(t)return i;var o;return i.forEach(function(t){o=t()}),o},o.prototype.show=function(){this.displayed||this.redraw()},o.prototype.hide=function(){this.displayed&&(this.dom.point.parentNode&&this.dom.point.parentNode.removeChild(this.dom.point),this.displayed=!1)},o.prototype.repositionX=function(){var t=this.conversion.toScreen(this.data.start);this.options.rtl?(this.right=t-this.props.dot.width,this.dom.point.style.right=this.right+"px"):(this.left=t-this.props.dot.width,this.dom.point.style.left=this.left+"px")},o.prototype.repositionY=function(){var t=this.options.orientation.item,e=this.dom.point;e.style.top="top"==t?this.top+"px":this.parent.height-this.top-this.height+"px"},o.prototype.getWidthLeft=function(){return this.props.dot.width},o.prototype.getWidthRight=function(){return this.props.dot.width},t.exports=o},function(t,e,i){function o(t,e,i){if(this.props={content:{width:0}},this.overflow=!1,t){if(void 0==t.start)throw new Error('Property "start" missing in item '+t.id);if(void 0==t.end)throw new Error('Property "end" missing in item '+t.id)}n.call(this,t,e,i)}var n=i(38),s=i(69),r=i(70);o.prototype=new n(null,null,null),o.prototype.baseClassName="vis-item vis-background",o.prototype.stack=!1,o.prototype.isVisible=function(t){return this.data.start<t.end&&this.data.end>t.start},o.prototype._createDomElement=function(){this.dom||(this.dom={},this.dom.box=document.createElement("div"),this.dom.frame=document.createElement("div"),this.dom.frame.className="vis-item-overflow",this.dom.box.appendChild(this.dom.frame),this.dom.content=document.createElement("div"),this.dom.content.className="vis-item-content",this.dom.frame.appendChild(this.dom.content),this.dirty=!0)},o.prototype._appendDomElement=function(){if(!this.parent)throw new Error("Cannot redraw item: no parent attached");if(!this.dom.box.parentNode){var t=this.parent.dom.background;if(!t)throw new Error("Cannot redraw item: parent has no background container element");t.appendChild(this.dom.box)}this.displayed=!0},o.prototype._updateDirtyDomComponents=function(){if(this.dirty){this._updateContents(this.dom.content),this._updateDataAttributes(this.dom.content),this._updateStyle(this.dom.box);var t=(this.data.className?" "+this.data.className:"")+(this.selected?" vis-selected":"");this.dom.box.className=this.baseClassName+t}},o.prototype._getDomComponentsSizes=function(){return this.overflow="hidden"!==window.getComputedStyle(this.dom.content).overflow,{content:{width:this.dom.content.offsetWidth}}},o.prototype._updateDomComponentsSizes=function(t){this.props.content.width=t.content.width,this.height=0,this.dirty=!1},o.prototype._repaintDomAdditionals=function(){},o.prototype.redraw=function(t){var e,i=[this._createDomElement.bind(this),this._appendDomElement.bind(this),this._updateDirtyDomComponents.bind(this),function(){this.dirty&&(e=this._getDomComponentsSizes.bind(this)())}.bind(this),function(){this.dirty&&this._updateDomComponentsSizes.bind(this)(e)}.bind(this),this._repaintDomAdditionals.bind(this)];if(t)return i;var o;return i.forEach(function(t){o=t()}),o},o.prototype.show=r.prototype.show,o.prototype.hide=r.prototype.hide,o.prototype.repositionX=r.prototype.repositionX,o.prototype.repositionY=function(t){var e,i=this.options.orientation.item;if(void 0!==this.data.subgroup){var o=this.data.subgroup;this.dom.box.style.height=this.parent.subgroups[o].height+"px",this.dom.box.style.top="top"==i?this.parent.top+this.parent.subgroups[o].top+"px":this.parent.top+this.parent.height-this.parent.subgroups[o].top-this.parent.subgroups[o].height+"px",this.dom.box.style.bottom=""}else this.parent instanceof s?(e=Math.max(this.parent.height,this.parent.itemSet.body.domProps.center.height,this.parent.itemSet.body.domProps.centerContainer.height),this.dom.box.style.bottom="bottom"==i?"0":"",this.dom.box.style.top="top"==i?"0":""):(e=this.parent.height,this.dom.box.style.top=this.parent.top+"px",this.dom.box.style.bottom="");this.dom.box.style.height=e+"px"},t.exports=o},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=function(){function t(e,i){(0,s.default)(this,t),this.container=e,this.overflowMethod=i||"cap",this.x=0,this.y=0,this.padding=5,this.hidden=!1,this.frame=document.createElement("div"),this.frame.className="vis-tooltip",this.container.appendChild(this.frame)}return(0,a.default)(t,[{key:"setPosition",value:function(t,e){this.x=parseInt(t),this.y=parseInt(e)}},{key:"setText",value:function(t){t instanceof Element?(this.frame.innerHTML="",this.frame.appendChild(t)):this.frame.innerHTML=t}},{key:"show",value:function(t){if(void 0===t&&(t=!0),!0===t){var e=this.frame.clientHeight,i=this.frame.clientWidth,o=this.frame.parentNode.clientHeight,n=this.frame.parentNode.clientWidth,s=0,r=0;if("flip"==this.overflowMethod){var a=!1,h=!0;this.y-e<this.padding&&(h=!1),this.x+i>n-this.padding&&(a=!0),s=a?this.x-i:this.x,r=h?this.y-e:this.y}else r=this.y-e,r+e+this.padding>o&&(r=o-e-this.padding),r<this.padding&&(r=this.padding),s=this.x,s+i+this.padding>n&&(s=n-i-this.padding),s<this.padding&&(s=this.padding);this.frame.style.left=s+"px",this.frame.style.top=r+"px",this.frame.style.visibility="visible",this.hidden=!1}else this.hide()}},{key:"hide",value:function(){this.hidden=!0,this.frame.style.left="0",this.frame.style.top="0",this.frame.style.visibility="hidden"}},{key:"destroy",value:function(){this.frame.parentNode.removeChild(this.frame)}}]),t}();e.default=h},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var o="string",n="boolean",s="number",r="object",a={configure:{enabled:{boolean:n},filter:{boolean:n,function:"function"},container:{dom:"dom"},__type__:{object:r,boolean:n,function:"function"}},align:{string:o},rtl:{boolean:n,undefined:"undefined"},rollingMode:{follow:{boolean:n},offset:{number:s,undefined:"undefined"},__type__:{object:r}},verticalScroll:{boolean:n,undefined:"undefined"},horizontalScroll:{boolean:n,undefined:"undefined"},autoResize:{boolean:n},throttleRedraw:{number:s},clickToUse:{boolean:n},dataAttributes:{string:o,array:"array"},editable:{add:{boolean:n,undefined:"undefined"},remove:{boolean:n,undefined:"undefined"},updateGroup:{boolean:n,undefined:"undefined"},updateTime:{boolean:n,undefined:"undefined"},overrideItems:{boolean:n,undefined:"undefined"},__type__:{boolean:n,object:r}},end:{number:s,date:"date",string:o,moment:"moment"},format:{minorLabels:{millisecond:{string:o,undefined:"undefined"},second:{string:o,undefined:"undefined"},minute:{string:o,undefined:"undefined"},hour:{string:o,undefined:"undefined"},weekday:{string:o,undefined:"undefined"},day:{string:o,undefined:"undefined"},week:{string:o,undefined:"undefined"},month:{string:o,undefined:"undefined"},year:{string:o,undefined:"undefined"},__type__:{object:r,function:"function"}},majorLabels:{millisecond:{string:o,undefined:"undefined"},second:{string:o,undefined:"undefined"},minute:{string:o,undefined:"undefined"},hour:{string:o,undefined:"undefined"},weekday:{string:o,undefined:"undefined"},day:{string:o,undefined:"undefined"},week:{string:o,undefined:"undefined"},month:{string:o,undefined:"undefined"},year:{string:o,undefined:"undefined"},__type__:{object:r,function:"function"}},__type__:{object:r}},moment:{function:"function"},groupOrder:{string:o,function:"function"},groupEditable:{add:{boolean:n,undefined:"undefined"},remove:{boolean:n,undefined:"undefined"},order:{boolean:n,undefined:"undefined"},__type__:{boolean:n,object:r}},groupOrderSwap:{function:"function"},height:{string:o,number:s},hiddenDates:{start:{date:"date",number:s,string:o,moment:"moment"},end:{date:"date",number:s,string:o,moment:"moment"},repeat:{string:o},__type__:{object:r,array:"array"}},itemsAlwaysDraggable:{item:{boolean:n,undefined:"undefined"},range:{boolean:n,undefined:"undefined"},__type__:{boolean:n,object:r}},limitSize:{boolean:n},locale:{string:o},locales:{__any__:{any:"any"},__type__:{object:r}},margin:{axis:{number:s},item:{horizontal:{number:s,undefined:"undefined"},vertical:{number:s,undefined:"undefined"},__type__:{object:r,number:s}},__type__:{object:r,number:s}},max:{date:"date",number:s,string:o,moment:"moment"},maxHeight:{number:s,string:o},maxMinorChars:{number:s},min:{date:"date",number:s,string:o,moment:"moment"},minHeight:{number:s,string:o},moveable:{boolean:n},multiselect:{boolean:n},multiselectPerGroup:{boolean:n},onAdd:{function:"function"},onDropObjectOnItem:{function:"function"},onUpdate:{function:"function"},onMove:{function:"function"},onMoving:{function:"function"},onRemove:{function:"function"},onAddGroup:{function:"function"},onMoveGroup:{function:"function"},onRemoveGroup:{function:"function"},onInitialDrawComplete:{function:"function"},order:{function:"function"},orientation:{axis:{string:o,undefined:"undefined"},item:{string:o,undefined:"undefined"},__type__:{string:o,object:r}},selectable:{boolean:n},showCurrentTime:{boolean:n},showMajorLabels:{boolean:n},showMinorLabels:{boolean:n},stack:{boolean:n},stackSubgroups:{boolean:n},snap:{function:"function",null:"null"},start:{date:"date",number:s,string:o,moment:"moment"},template:{function:"function"},groupTemplate:{function:"function"},visibleFrameTemplate:{string:o,function:"function"},showTooltips:{boolean:n},tooltip:{followMouse:{boolean:n},overflowMethod:{string:["cap","flip"]},__type__:{object:r}},tooltipOnItemUpdateTime:{template:{function:"function"},__type__:{boolean:n,object:r}},timeAxis:{scale:{string:o,undefined:"undefined"},step:{number:s,undefined:"undefined"},__type__:{object:r}},type:{string:o},width:{string:o,number:s},zoomable:{boolean:n},zoomKey:{string:["ctrlKey","altKey","metaKey",""]},zoomMax:{number:s},zoomMin:{number:s},__type__:{object:r}},h={global:{align:["center","left","right"],direction:!1,autoResize:!0,clickToUse:!1,editable:{add:!1,remove:!1,updateGroup:!1,updateTime:!1},end:"",format:{minorLabels:{millisecond:"SSS",second:"s",minute:"HH:mm",hour:"HH:mm",weekday:"ddd D",day:"D",week:"w",month:"MMM",year:"YYYY"},majorLabels:{millisecond:"HH:mm:ss",second:"D MMMM HH:mm",minute:"ddd D MMMM",hour:"ddd D MMMM",weekday:"MMMM YYYY",day:"MMMM YYYY",week:"MMMM YYYY",month:"YYYY",year:""}},groupsDraggable:!1,height:"",locale:"",margin:{axis:[20,0,100,1],item:{horizontal:[10,0,100,1],vertical:[10,0,100,1]}},max:"",maxHeight:"",maxMinorChars:[7,0,20,1],min:"",minHeight:"",moveable:!1,multiselect:!1,multiselectPerGroup:!1,orientation:{axis:["both","bottom","top"],item:["bottom","top"]},selectable:!0,showCurrentTime:!1,showMajorLabels:!0,showMinorLabels:!0,stack:!0,stackSubgroups:!0,start:"",showTooltips:!0,tooltip:{followMouse:!1,overflowMethod:"flip"},tooltipOnItemUpdateTime:!1,type:["box","point","range","background"],width:"100%",zoomable:!0,zoomKey:["ctrlKey","altKey","metaKey",""],zoomMax:[31536e10,10,31536e10,1],zoomMin:[10,10,31536e10,1]}};e.allOptions=a,e.configureOptions=h},function(t,e,i){function o(t,e){this.id=r.randomUUID(),this.body=t,this.defaultOptions={yAxisOrientation:"left",defaultGroup:"default",sort:!0,sampling:!0,stack:!1,graphHeight:"400px",shaded:{enabled:!1,orientation:"bottom"},style:"line",barChart:{width:50,sideBySide:!1,align:"center"},interpolation:{enabled:!0,parametrization:"centripetal",alpha:.5},drawPoints:{enabled:!0,size:6,style:"square"},dataAxis:{},legend:{},groups:{visibility:{}}},this.options=r.extend({},this.defaultOptions),this.dom={},this.props={},this.hammer=null,this.groups={},this.abortedGraphUpdate=!1,this.updateSVGheight=!1,this.updateSVGheightOnResize=!1,this.forceGraphUpdate=!0;var i=this;this.itemsData=null,this.groupsData=null,this.itemListeners={add:function(t,e,o){i._onAdd(e.items)},update:function(t,e,o){i._onUpdate(e.items)},remove:function(t,e,o){i._onRemove(e.items)}},this.groupListeners={add:function(t,e,o){i._onAddGroups(e.items)},update:function(t,e,o){i._onUpdateGroups(e.items)},remove:function(t,e,o){i._onRemoveGroups(e.items)}},this.items={},this.selection=[],this.lastStart=this.body.range.start,this.touchParams={},this.svgElements={},this.setOptions(e),this.groupsUsingDefaultStyles=[0],this.body.emitter.on("rangechanged",function(){i.lastStart=i.body.range.start,i.svg.style.left=r.option.asSize(-i.props.width),i.forceGraphUpdate=!0,i.redraw.call(i)}),this._create(),this.framework={svg:this.svg,svgElements:this.svgElements,options:this.options,groups:this.groups}}var n=i(6),s=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(2),a=i(14),h=i(11),d=i(12),l=i(16),u=i(107),c=i(109),p=i(112),f=i(110),m=i(111),v=i(72);o.prototype=new l,o.prototype._create=function(){var t=document.createElement("div");t.className="vis-line-graph",this.dom.frame=t,this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.position="relative",this.svg.style.height=(""+this.options.graphHeight).replace("px","")+"px",this.svg.style.display="block",t.appendChild(this.svg),this.options.dataAxis.orientation="left",this.yAxisLeft=new u(this.body,this.options.dataAxis,this.svg,this.options.groups),this.options.dataAxis.orientation="right",this.yAxisRight=new u(this.body,this.options.dataAxis,this.svg,this.options.groups),delete this.options.dataAxis.orientation,this.legendLeft=new p(this.body,this.options.legend,"left",this.options.groups),this.legendRight=new p(this.body,this.options.legend,"right",this.options.groups),this.show()},o.prototype.setOptions=function(t){if(t){var e=["sampling","defaultGroup","stack","height","graphHeight","yAxisOrientation","style","barChart","dataAxis","sort","groups"];void 0===t.graphHeight&&void 0!==t.height?(this.updateSVGheight=!0,this.updateSVGheightOnResize=!0):void 0!==this.body.domProps.centerContainer.height&&void 0!==t.graphHeight&&parseInt((t.graphHeight+"").replace("px",""))<this.body.domProps.centerContainer.height&&(this.updateSVGheight=!0),r.selectiveDeepExtend(e,this.options,t),r.mergeOptions(this.options,t,"interpolation"),r.mergeOptions(this.options,t,"drawPoints"),r.mergeOptions(this.options,t,"shaded"),r.mergeOptions(this.options,t,"legend"),t.interpolation&&"object"==(0,s.default)(t.interpolation)&&t.interpolation.parametrization&&("uniform"==t.interpolation.parametrization?this.options.interpolation.alpha=0:"chordal"==t.interpolation.parametrization?this.options.interpolation.alpha=1:(this.options.interpolation.parametrization="centripetal",this.options.interpolation.alpha=.5)),this.yAxisLeft&&void 0!==t.dataAxis&&(this.yAxisLeft.setOptions(this.options.dataAxis),this.yAxisRight.setOptions(this.options.dataAxis)),this.legendLeft&&void 0!==t.legend&&(this.legendLeft.setOptions(this.options.legend),this.legendRight.setOptions(this.options.legend)),this.groups.hasOwnProperty("__ungrouped__")&&this.groups.__ungrouped__.setOptions(t)}this.dom.frame&&(this.forceGraphUpdate=!0,this.body.emitter.emit("_change",{queue:!0}))},o.prototype.hide=function(){this.dom.frame.parentNode&&this.dom.frame.parentNode.removeChild(this.dom.frame)},o.prototype.show=function(){this.dom.frame.parentNode||this.body.dom.center.appendChild(this.dom.frame)},o.prototype.setItems=function(t){var e,i=this,o=this.itemsData;if(t){if(!(t instanceof h||t instanceof d))throw new TypeError("Data must be an instance of DataSet or DataView");this.itemsData=t}else this.itemsData=null;if(o&&(r.forEach(this.itemListeners,function(t,e){o.off(e,t)}),e=o.getIds(),this._onRemove(e)),this.itemsData){var n=this.id;r.forEach(this.itemListeners,function(t,e){i.itemsData.on(e,t,n)}),e=this.itemsData.getIds(),this._onAdd(e)}},o.prototype.setGroups=function(t){var e,i=this;if(this.groupsData){r.forEach(this.groupListeners,function(t,e){i.groupsData.off(e,t)}),e=this.groupsData.getIds(),this.groupsData=null;for(var o=0;o<e.length;o++)this._removeGroup(e[o])}if(t){if(!(t instanceof h||t instanceof d))throw new TypeError("Data must be an instance of DataSet or DataView");this.groupsData=t}else this.groupsData=null;if(this.groupsData){var n=this.id;r.forEach(this.groupListeners,function(t,e){i.groupsData.on(e,t,n)}),e=this.groupsData.getIds(),this._onAddGroups(e)}},o.prototype._onUpdate=function(t){this._updateAllGroupData(t)},o.prototype._onAdd=function(t){this._onUpdate(t)},o.prototype._onRemove=function(t){this._onUpdate(t)},o.prototype._onUpdateGroups=function(t){this._updateAllGroupData(null,t)},o.prototype._onAddGroups=function(t){this._onUpdateGroups(t)},o.prototype._onRemoveGroups=function(t){for(var e=0;e<t.length;e++)this._removeGroup(t[e]);this.forceGraphUpdate=!0,this.body.emitter.emit("_change",{queue:!0})},o.prototype._removeGroup=function(t){this.groups.hasOwnProperty(t)&&("right"==this.groups[t].options.yAxisOrientation?(this.yAxisRight.removeGroup(t),this.legendRight.removeGroup(t),this.legendRight.redraw()):(this.yAxisLeft.removeGroup(t),this.legendLeft.removeGroup(t),this.legendLeft.redraw()),delete this.groups[t])},o.prototype._updateGroup=function(t,e){this.groups.hasOwnProperty(e)?(this.groups[e].update(t),"right"==this.groups[e].options.yAxisOrientation?(this.yAxisRight.updateGroup(e,this.groups[e]),this.legendRight.updateGroup(e,this.groups[e]),this.yAxisLeft.removeGroup(e),this.legendLeft.removeGroup(e)):(this.yAxisLeft.updateGroup(e,this.groups[e]),this.legendLeft.updateGroup(e,this.groups[e]),this.yAxisRight.removeGroup(e),this.legendRight.removeGroup(e))):(this.groups[e]=new c(t,e,this.options,this.groupsUsingDefaultStyles),"right"==this.groups[e].options.yAxisOrientation?(this.yAxisRight.addGroup(e,this.groups[e]),this.legendRight.addGroup(e,this.groups[e])):(this.yAxisLeft.addGroup(e,this.groups[e]),this.legendLeft.addGroup(e,this.groups[e]))),this.legendLeft.redraw(),this.legendRight.redraw()},o.prototype._updateAllGroupData=function(t,e){if(null!=this.itemsData){var i={},o=this.itemsData.get(),n=this.itemsData._fieldId,s={};t&&t.map(function(t){s[t]=t});for(var a={},h=0;h<o.length;h++){var d=o[h],l=d.group;null!==l&&void 0!==l||(l="__ungrouped__"),a.hasOwnProperty(l)?a[l]++:a[l]=1}var u={};if(!e&&t)for(l in this.groups)if(this.groups.hasOwnProperty(l)){v=this.groups[l];var c=v.getItems();i[l]=c.filter(function(t){return u[t[n]]=t[n],t[n]!==s[t[n]]});var p=a[l];a[l]-=i[l].length,i[l].length<p&&(i[l][p-1]={})}for(h=0;h<o.length;h++)if(d=o[h],l=d.group,null!==l&&void 0!==l||(l="__ungrouped__"),e||!t||d[n]===s[d[n]]||!u.hasOwnProperty(d[n])){i.hasOwnProperty(l)||(i[l]=new Array(a[l]));var f=r.bridgeObject(d);f.x=r.convert(d.x,"Date"),f.end=r.convert(d.end,"Date"),f.orginalY=d.y,f.y=Number(d.y), +f[n]=d[n];var m=i[l].length-a[l]--;i[l][m]=f}for(l in this.groups)this.groups.hasOwnProperty(l)&&(i.hasOwnProperty(l)||(i[l]=new Array(0)));for(l in i)if(i.hasOwnProperty(l))if(0==i[l].length)this.groups.hasOwnProperty(l)&&this._removeGroup(l);else{var v=void 0;void 0!=this.groupsData&&(v=this.groupsData.get(l)),void 0==v&&(v={id:l,content:this.options.defaultGroup+l}),this._updateGroup(v,l),this.groups[l].setItems(i[l])}this.forceGraphUpdate=!0,this.body.emitter.emit("_change",{queue:!0})}},o.prototype.redraw=function(){var t=!1;this.props.width=this.dom.frame.offsetWidth,this.props.height=this.body.domProps.centerContainer.height-this.body.domProps.border.top-this.body.domProps.border.bottom,t=this._isResized()||t;var e=this.body.range.end-this.body.range.start,i=e!=this.lastVisibleInterval;if(this.lastVisibleInterval=e,1==t&&(this.svg.style.width=r.option.asSize(3*this.props.width),this.svg.style.left=r.option.asSize(-this.props.width),-1==(this.options.height+"").indexOf("%")&&1!=this.updateSVGheightOnResize||(this.updateSVGheight=!0)),1==this.updateSVGheight?(this.options.graphHeight!=this.props.height+"px"&&(this.options.graphHeight=this.props.height+"px",this.svg.style.height=this.props.height+"px"),this.updateSVGheight=!1):this.svg.style.height=(""+this.options.graphHeight).replace("px","")+"px",1==t||1==i||1==this.abortedGraphUpdate||1==this.forceGraphUpdate)t=this._updateGraph()||t,this.forceGraphUpdate=!1;else if(0!=this.lastStart){var o=this.body.range.start-this.lastStart,n=this.body.range.end-this.body.range.start;if(0!=this.props.width){var s=this.props.width/n,a=o*s;this.svg.style.left=-this.props.width-a+"px"}}return this.legendLeft.redraw(),this.legendRight.redraw(),t},o.prototype._getSortedGroupIds=function(){var t=[];for(var e in this.groups)if(this.groups.hasOwnProperty(e)){var i=this.groups[e];1!=i.visible||void 0!==this.options.groups.visibility[e]&&1!=this.options.groups.visibility[e]||t.push({id:e,zIndex:i.options.zIndex})}r.insertSort(t,function(t,e){var i=t.zIndex,o=e.zIndex;return void 0===i&&(i=0),void 0===o&&(o=0),i==o?0:i<o?-1:1});for(var o=new Array(t.length),n=0;n<t.length;n++)o[n]=t[n].id;return o},o.prototype._updateGraph=function(){if(a.prepareElements(this.svgElements),0!=this.props.width&&null!=this.itemsData){var t,e,i={},o=this.body.util.toGlobalTime(-this.body.domProps.root.width),n=this.body.util.toGlobalTime(2*this.body.domProps.root.width),s=this._getSortedGroupIds();if(s.length>0){var r={};for(this._getRelevantData(s,r,o,n),this._applySampling(s,r),e=0;e<s.length;e++)this._convertXcoordinates(r[s[e]]);if(this._getYRanges(s,r,i),1==this._updateYAxis(s,i))return a.cleanupElements(this.svgElements),this.abortedGraphUpdate=!0,!0;this.abortedGraphUpdate=!1;var h=void 0;for(e=0;e<s.length;e++)t=this.groups[s[e]],!0===this.options.stack&&"line"===this.options.style&&(void 0!=t.options.excludeFromStacking&&t.options.excludeFromStacking||(void 0!=h&&(this._stack(r[t.id],r[h.id]),1==t.options.shaded.enabled&&"group"!==t.options.shaded.orientation&&("top"==t.options.shaded.orientation&&"group"!==h.options.shaded.orientation?(h.options.shaded.orientation="group",h.options.shaded.groupId=t.id):(t.options.shaded.orientation="group",t.options.shaded.groupId=h.id))),h=t)),this._convertYcoordinates(r[s[e]],t);var d={};for(e=0;e<s.length;e++)if(t=this.groups[s[e]],"line"===t.options.style&&1==t.options.shaded.enabled){var l=r[s[e]];if(null==l||0==l.length)continue;if(d.hasOwnProperty(s[e])||(d[s[e]]=m.calcPath(l,t)),"group"===t.options.shaded.orientation){var u=t.options.shaded.groupId;if(-1===s.indexOf(u)){console.log(t.id+": Unknown shading group target given:"+u);continue}d.hasOwnProperty(u)||(d[u]=m.calcPath(r[u],this.groups[u])),m.drawShading(d[s[e]],t,d[u],this.framework)}else m.drawShading(d[s[e]],t,void 0,this.framework)}for(f.draw(s,r,this.framework),e=0;e<s.length;e++)if(t=this.groups[s[e]],r[s[e]].length>0)switch(t.options.style){case"line":d.hasOwnProperty(s[e])||(d[s[e]]=m.calcPath(r[s[e]],t)),m.draw(d[s[e]],t,this.framework);case"point":case"points":"point"!=t.options.style&&"points"!=t.options.style&&1!=t.options.drawPoints.enabled||v.draw(r[s[e]],t,this.framework)}}}return a.cleanupElements(this.svgElements),!1},o.prototype._stack=function(t,e){var i,o,n,s,r;i=0;for(var a=0;a<t.length;a++){s=void 0,r=void 0;for(var h=i;h<e.length;h++){if(e[h].x===t[a].x){s=e[h],r=e[h],i=h;break}if(e[h].x>t[a].x){r=e[h],s=0==h?r:e[h-1],i=h;break}}void 0===r&&(s=e[e.length-1],r=e[e.length-1]),o=r.x-s.x,n=r.y-s.y,t[a].y=0==o?t[a].orginalY+r.y:t[a].orginalY+n/o*(t[a].x-s.x)+s.y}},o.prototype._getRelevantData=function(t,e,i,o){var n,s,a,h;if(t.length>0)for(s=0;s<t.length;s++){n=this.groups[t[s]];var d=n.getItems();if(1==n.options.sort){var l=function(t,e){return t.getTime()==e.getTime()?0:t<e?-1:1},u=Math.max(0,r.binarySearchValue(d,i,"x","before",l)),c=Math.min(d.length,r.binarySearchValue(d,o,"x","after",l)+1);c<=0&&(c=d.length);var p=new Array(c-u);for(a=u;a<c;a++)h=n.itemsData[a],p[a-u]=h;e[t[s]]=p}else e[t[s]]=n.itemsData}},o.prototype._applySampling=function(t,e){var i;if(t.length>0)for(var o=0;o<t.length;o++)if(i=this.groups[t[o]],1==i.options.sampling){var n=e[t[o]];if(n.length>0){var s=1,r=n.length,a=this.body.util.toGlobalScreen(n[n.length-1].x)-this.body.util.toGlobalScreen(n[0].x),h=r/a;s=Math.min(Math.ceil(.2*r),Math.max(1,Math.round(h)));for(var d=new Array(r),l=0;l<r;l+=s){var u=Math.round(l/s);d[u]=n[l]}e[t[o]]=d.splice(0,Math.round(r/s))}}},o.prototype._getYRanges=function(t,e,i){var o,n,s,r,a=[],h=[];if(t.length>0){for(s=0;s<t.length;s++)o=e[t[s]],r=this.groups[t[s]].options,o.length>0&&(n=this.groups[t[s]],!0===r.stack&&"bar"===r.style?"left"===r.yAxisOrientation?a=a.concat(o):h=h.concat(o):i[t[s]]=n.getYRange(o,t[s]));f.getStackedYRange(a,i,t,"__barStackLeft","left"),f.getStackedYRange(h,i,t,"__barStackRight","right")}},o.prototype._updateYAxis=function(t,e){var i,o,n=!1,s=!1,r=!1,a=1e9,h=1e9,d=-1e9,l=-1e9;if(t.length>0){for(var u=0;u<t.length;u++){var c=this.groups[t[u]];c&&"right"!=c.options.yAxisOrientation?(s=!0,a=1e9,d=-1e9):c&&c.options.yAxisOrientation&&(r=!0,h=1e9,l=-1e9)}for(u=0;u<t.length;u++)e.hasOwnProperty(t[u])&&!0!==e[t[u]].ignore&&(i=e[t[u]].min,o=e[t[u]].max,"right"!=e[t[u]].yAxisOrientation?(s=!0,a=a>i?i:a,d=d<o?o:d):(r=!0,h=h>i?i:h,l=l<o?o:l));1==s&&this.yAxisLeft.setRange(a,d),1==r&&this.yAxisRight.setRange(h,l)}n=this._toggleAxisVisiblity(s,this.yAxisLeft)||n,n=this._toggleAxisVisiblity(r,this.yAxisRight)||n,1==r&&1==s?(this.yAxisLeft.drawIcons=!0,this.yAxisRight.drawIcons=!0):(this.yAxisLeft.drawIcons=!1,this.yAxisRight.drawIcons=!1),this.yAxisRight.master=!s,this.yAxisRight.masterAxis=this.yAxisLeft,0==this.yAxisRight.master?(this.yAxisLeft.lineOffset=1==r?this.yAxisRight.width:0,n=this.yAxisLeft.redraw()||n,n=this.yAxisRight.redraw()||n):n=this.yAxisRight.redraw()||n;var p=["__barStackLeft","__barStackRight","__lineStackLeft","__lineStackRight"];for(u=0;u<p.length;u++)-1!=t.indexOf(p[u])&&t.splice(t.indexOf(p[u]),1);return n},o.prototype._toggleAxisVisiblity=function(t,e){var i=!1;return 0==t?e.dom.frame.parentNode&&0==e.hidden&&(e.hide(),i=!0):e.dom.frame.parentNode||1!=e.hidden||(e.show(),i=!0),i},o.prototype._convertXcoordinates=function(t){for(var e=this.body.util.toScreen,i=0;i<t.length;i++)t[i].screen_x=e(t[i].x)+this.props.width,t[i].screen_y=t[i].y,void 0!=t[i].end?t[i].screen_end=e(t[i].end)+this.props.width:t[i].screen_end=void 0},o.prototype._convertYcoordinates=function(t,e){var i=this.yAxisLeft,o=Number(this.svg.style.height.replace("px",""));"right"==e.options.yAxisOrientation&&(i=this.yAxisRight);for(var n=0;n<t.length;n++)t[n].screen_y=Math.round(i.convertValue(t[n].y));e.setZeroPosition(Math.min(o,i.convertValue(0)))},t.exports=o},function(t,e,i){function o(t,e,i,o){this.id=r.randomUUID(),this.body=t,this.defaultOptions={orientation:"left",showMinorLabels:!0,showMajorLabels:!0,icons:!1,majorLinesOffset:7,minorLinesOffset:4,labelOffsetX:10,labelOffsetY:2,iconWidth:20,width:"40px",visible:!0,alignZeros:!0,left:{range:{min:void 0,max:void 0},format:function(t){return""+parseFloat(t.toPrecision(3))},title:{text:void 0,style:void 0}},right:{range:{min:void 0,max:void 0},format:function(t){return""+parseFloat(t.toPrecision(3))},title:{text:void 0,style:void 0}}},this.linegraphOptions=o,this.linegraphSVG=i,this.props={},this.DOMelements={lines:{},labels:{},title:{}},this.dom={},this.scale=void 0,this.range={start:0,end:0},this.options=r.extend({},this.defaultOptions),this.conversionFactor=1,this.setOptions(e),this.width=Number((""+this.options.width).replace("px","")),this.minWidth=this.width,this.height=this.linegraphSVG.getBoundingClientRect().height,this.hidden=!1,this.stepPixels=25,this.zeroCrossing=-1,this.amountOfSteps=-1,this.lineOffset=0,this.master=!0,this.masterAxis=null,this.svgElements={},this.iconsRemoved=!1,this.groups={},this.amountOfGroups=0,this._create(),this.framework={svg:this.svg,svgElements:this.svgElements,options:this.options,groups:this.groups};var n=this;this.body.emitter.on("verticalDrag",function(){n.dom.lineContainer.style.top=n.body.domProps.scrollTop+"px"})}var n=i(8),s=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(2),a=i(14),h=i(16),d=i(108);o.prototype=new h,o.prototype.addGroup=function(t,e){this.groups.hasOwnProperty(t)||(this.groups[t]=e),this.amountOfGroups+=1},o.prototype.updateGroup=function(t,e){this.groups.hasOwnProperty(t)||(this.amountOfGroups+=1),this.groups[t]=e},o.prototype.removeGroup=function(t){this.groups.hasOwnProperty(t)&&(delete this.groups[t],this.amountOfGroups-=1)},o.prototype.setOptions=function(t){if(t){var e=!1;this.options.orientation!=t.orientation&&void 0!==t.orientation&&(e=!0);var i=["orientation","showMinorLabels","showMajorLabels","icons","majorLinesOffset","minorLinesOffset","labelOffsetX","labelOffsetY","iconWidth","width","visible","left","right","alignZeros"];r.selectiveDeepExtend(i,this.options,t),this.minWidth=Number((""+this.options.width).replace("px","")),!0===e&&this.dom.frame&&(this.hide(),this.show())}},o.prototype._create=function(){this.dom.frame=document.createElement("div"),this.dom.frame.style.width=this.options.width,this.dom.frame.style.height=this.height,this.dom.lineContainer=document.createElement("div"),this.dom.lineContainer.style.width="100%",this.dom.lineContainer.style.height=this.height,this.dom.lineContainer.style.position="relative",this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.position="absolute",this.svg.style.top="0px",this.svg.style.height="100%",this.svg.style.width="100%",this.svg.style.display="block",this.dom.frame.appendChild(this.svg)},o.prototype._redrawGroupIcons=function(){a.prepareElements(this.svgElements);var t,e=this.options.iconWidth,i=11.5;t="left"===this.options.orientation?4:this.width-e-4;var o=(0,s.default)(this.groups);o.sort(function(t,e){return t<e?-1:1});for(var n=0;n<o.length;n++){var r=o[n];!0!==this.groups[r].visible||void 0!==this.linegraphOptions.visibility[r]&&!0!==this.linegraphOptions.visibility[r]||(this.groups[r].getLegend(e,15,this.framework,t,i),i+=19)}a.cleanupElements(this.svgElements),this.iconsRemoved=!1},o.prototype._cleanupIcons=function(){!1===this.iconsRemoved&&(a.prepareElements(this.svgElements),a.cleanupElements(this.svgElements),this.iconsRemoved=!0)},o.prototype.show=function(){this.hidden=!1,this.dom.frame.parentNode||("left"===this.options.orientation?this.body.dom.left.appendChild(this.dom.frame):this.body.dom.right.appendChild(this.dom.frame)),this.dom.lineContainer.parentNode||this.body.dom.backgroundHorizontal.appendChild(this.dom.lineContainer)},o.prototype.hide=function(){this.hidden=!0,this.dom.frame.parentNode&&this.dom.frame.parentNode.removeChild(this.dom.frame),this.dom.lineContainer.parentNode&&this.dom.lineContainer.parentNode.removeChild(this.dom.lineContainer)},o.prototype.setRange=function(t,e){this.range.start=t,this.range.end=e},o.prototype.redraw=function(){var t=!1,e=0;this.dom.lineContainer.style.top=this.body.domProps.scrollTop+"px";for(var i in this.groups)this.groups.hasOwnProperty(i)&&(!0!==this.groups[i].visible||void 0!==this.linegraphOptions.visibility[i]&&!0!==this.linegraphOptions.visibility[i]||e++);if(0===this.amountOfGroups||0===e)this.hide();else{this.show(),this.height=Number(this.linegraphSVG.style.height.replace("px","")),this.dom.lineContainer.style.height=this.height+"px",this.width=!0===this.options.visible?Number((""+this.options.width).replace("px","")):0;var o=this.props,n=this.dom.frame;n.className="vis-data-axis",this._calculateCharSize();var s=this.options.orientation,r=this.options.showMinorLabels,a=this.options.showMajorLabels;o.minorLabelHeight=r?o.minorCharHeight:0,o.majorLabelHeight=a?o.majorCharHeight:0,o.minorLineWidth=this.body.dom.backgroundHorizontal.offsetWidth-this.lineOffset-this.width+2*this.options.minorLinesOffset,o.minorLineHeight=1,o.majorLineWidth=this.body.dom.backgroundHorizontal.offsetWidth-this.lineOffset-this.width+2*this.options.majorLinesOffset,o.majorLineHeight=1,"left"===s?(n.style.top="0",n.style.left="0",n.style.bottom="",n.style.width=this.width+"px",n.style.height=this.height+"px",this.props.width=this.body.domProps.left.width,this.props.height=this.body.domProps.left.height):(n.style.top="",n.style.bottom="0",n.style.left="0",n.style.width=this.width+"px",n.style.height=this.height+"px",this.props.width=this.body.domProps.right.width,this.props.height=this.body.domProps.right.height),t=this._redrawLabels(),t=this._isResized()||t,!0===this.options.icons?this._redrawGroupIcons():this._cleanupIcons(),this._redrawTitle(s)}return t},o.prototype._redrawLabels=function(){var t=this,e=!1;a.prepareElements(this.DOMelements.lines),a.prepareElements(this.DOMelements.labels);var i=this.options.orientation,o=void 0!=this.options[i].range?this.options[i].range:{},n=!0;void 0!=o.max&&(this.range.end=o.max,n=!1);var s=!0;void 0!=o.min&&(this.range.start=o.min,s=!1),this.scale=new d(this.range.start,this.range.end,s,n,this.dom.frame.offsetHeight,this.props.majorCharHeight,this.options.alignZeros,this.options[i].format),!1===this.master&&void 0!=this.masterAxis&&this.scale.followScale(this.masterAxis.scale),this.maxLabelSize=0,this.scale.getLines().forEach(function(e){var o=e.y,n=e.major;t.options.showMinorLabels&&!1===n&&t._redrawLabel(o-2,e.val,i,"vis-y-axis vis-minor",t.props.minorCharHeight),n&&o>=0&&t._redrawLabel(o-2,e.val,i,"vis-y-axis vis-major",t.props.majorCharHeight),!0===t.master&&(n?t._redrawLine(o,i,"vis-grid vis-horizontal vis-major",t.options.majorLinesOffset,t.props.majorLineWidth):t._redrawLine(o,i,"vis-grid vis-horizontal vis-minor",t.options.minorLinesOffset,t.props.minorLineWidth))});var r=0;void 0!==this.options[i].title&&void 0!==this.options[i].title.text&&(r=this.props.titleCharHeight);var h=!0===this.options.icons?Math.max(this.options.iconWidth,r)+this.options.labelOffsetX+15:r+this.options.labelOffsetX+15;return this.maxLabelSize>this.width-h&&!0===this.options.visible?(this.width=this.maxLabelSize+h,this.options.width=this.width+"px",a.cleanupElements(this.DOMelements.lines),a.cleanupElements(this.DOMelements.labels),this.redraw(),e=!0):this.maxLabelSize<this.width-h&&!0===this.options.visible&&this.width>this.minWidth?(this.width=Math.max(this.minWidth,this.maxLabelSize+h),this.options.width=this.width+"px",a.cleanupElements(this.DOMelements.lines),a.cleanupElements(this.DOMelements.labels),this.redraw(),e=!0):(a.cleanupElements(this.DOMelements.lines),a.cleanupElements(this.DOMelements.labels),e=!1),e},o.prototype.convertValue=function(t){return this.scale.convertValue(t)},o.prototype.screenToValue=function(t){return this.scale.screenToValue(t)},o.prototype._redrawLabel=function(t,e,i,o,n){var s=a.getDOMElement("div",this.DOMelements.labels,this.dom.frame);s.className=o,s.innerHTML=e,"left"===i?(s.style.left="-"+this.options.labelOffsetX+"px",s.style.textAlign="right"):(s.style.right="-"+this.options.labelOffsetX+"px",s.style.textAlign="left"),s.style.top=t-.5*n+this.options.labelOffsetY+"px",e+="";var r=Math.max(this.props.majorCharWidth,this.props.minorCharWidth);this.maxLabelSize<e.length*r&&(this.maxLabelSize=e.length*r)},o.prototype._redrawLine=function(t,e,i,o,n){if(!0===this.master){var s=a.getDOMElement("div",this.DOMelements.lines,this.dom.lineContainer);s.className=i,s.innerHTML="","left"===e?s.style.left=this.width-o+"px":s.style.right=this.width-o+"px",s.style.width=n+"px",s.style.top=t+"px"}},o.prototype._redrawTitle=function(t){if(a.prepareElements(this.DOMelements.title),void 0!==this.options[t].title&&void 0!==this.options[t].title.text){var e=a.getDOMElement("div",this.DOMelements.title,this.dom.frame);e.className="vis-y-axis vis-title vis-"+t,e.innerHTML=this.options[t].title.text,void 0!==this.options[t].title.style&&r.addCssText(e,this.options[t].title.style),"left"===t?e.style.left=this.props.titleCharHeight+"px":e.style.right=this.props.titleCharHeight+"px",e.style.width=this.height+"px"}a.cleanupElements(this.DOMelements.title)},o.prototype._calculateCharSize=function(){if(!("minorCharHeight"in this.props)){var t=document.createTextNode("0"),e=document.createElement("div");e.className="vis-y-axis vis-minor vis-measure",e.appendChild(t),this.dom.frame.appendChild(e),this.props.minorCharHeight=e.clientHeight,this.props.minorCharWidth=e.clientWidth,this.dom.frame.removeChild(e)}if(!("majorCharHeight"in this.props)){var i=document.createTextNode("0"),o=document.createElement("div");o.className="vis-y-axis vis-major vis-measure",o.appendChild(i),this.dom.frame.appendChild(o),this.props.majorCharHeight=o.clientHeight,this.props.majorCharWidth=o.clientWidth,this.dom.frame.removeChild(o)}if(!("titleCharHeight"in this.props)){var n=document.createTextNode("0"),s=document.createElement("div");s.className="vis-y-axis vis-title vis-measure",s.appendChild(n),this.dom.frame.appendChild(s),this.props.titleCharHeight=s.clientHeight,this.props.titleCharWidth=s.clientWidth,this.dom.frame.removeChild(s)}},t.exports=o},function(t,e,i){function o(t,e,i,o,n,s){var r=arguments.length>6&&void 0!==arguments[6]&&arguments[6],a=arguments.length>7&&void 0!==arguments[7]&&arguments[7];if(this.majorSteps=[1,2,5,10],this.minorSteps=[.25,.5,1,2],this.customLines=null,this.containerHeight=n,this.majorCharHeight=s,this._start=t,this._end=e,this.scale=1,this.minorStepIdx=-1,this.magnitudefactor=1,this.determineScale(),this.zeroAlign=r,this.autoScaleStart=i,this.autoScaleEnd=o,this.formattingFunction=a,i||o){var h=this,d=function(t){var e=t-t%(h.magnitudefactor*h.minorSteps[h.minorStepIdx]);return t%(h.magnitudefactor*h.minorSteps[h.minorStepIdx])>h.magnitudefactor*h.minorSteps[h.minorStepIdx]*.5?e+h.magnitudefactor*h.minorSteps[h.minorStepIdx]:e};i&&(this._start-=2*this.magnitudefactor*this.minorSteps[this.minorStepIdx],this._start=d(this._start)),o&&(this._end+=this.magnitudefactor*this.minorSteps[this.minorStepIdx],this._end=d(this._end)),this.determineScale()}}o.prototype.setCharHeight=function(t){this.majorCharHeight=t},o.prototype.setHeight=function(t){this.containerHeight=t},o.prototype.determineScale=function(){var t=this._end-this._start;this.scale=this.containerHeight/t;var e=this.majorCharHeight/this.scale,i=t>0?Math.round(Math.log(t)/Math.LN10):0;this.minorStepIdx=-1,this.magnitudefactor=Math.pow(10,i);var o=0;i<0&&(o=i);for(var n=!1,s=o;Math.abs(s)<=Math.abs(i);s++){this.magnitudefactor=Math.pow(10,s);for(var r=0;r<this.minorSteps.length;r++){if(this.magnitudefactor*this.minorSteps[r]>=e){n=!0,this.minorStepIdx=r;break}}if(!0===n)break}},o.prototype.is_major=function(t){return t%(this.magnitudefactor*this.majorSteps[this.minorStepIdx])==0},o.prototype.getStep=function(){return this.magnitudefactor*this.minorSteps[this.minorStepIdx]},o.prototype.getFirstMajor=function(){var t=this.magnitudefactor*this.majorSteps[this.minorStepIdx];return this.convertValue(this._start+(t-this._start%t)%t)},o.prototype.formatValue=function(t){var e=t.toPrecision(5);return"function"==typeof this.formattingFunction&&(e=this.formattingFunction(t)),"number"==typeof e?""+e:"string"==typeof e?e:t.toPrecision(5)},o.prototype.getLines=function(){for(var t=[],e=this.getStep(),i=(e-this._start%e)%e,o=this._start+i;this._end-o>1e-5;o+=e)o!=this._start&&t.push({major:this.is_major(o),y:this.convertValue(o),val:this.formatValue(o)});return t},o.prototype.followScale=function(t){var e=this.minorStepIdx,i=this._start,o=this._end,n=this,s=function(){n.magnitudefactor*=2},r=function(){n.magnitudefactor/=2};t.minorStepIdx<=1&&this.minorStepIdx<=1||t.minorStepIdx>1&&this.minorStepIdx>1||(t.minorStepIdx<this.minorStepIdx?(this.minorStepIdx=1,2==e?s():(s(),s())):(this.minorStepIdx=2,1==e?r():(r(),r())));for(var a=t.convertValue(0),h=t.getStep()*t.scale,d=!1,l=0;!d&&l++<5;){this.scale=h/(this.minorSteps[this.minorStepIdx]*this.magnitudefactor);var u=this.containerHeight/this.scale;this._start=i,this._end=this._start+u;var c=this._end*this.scale,p=this.magnitudefactor*this.majorSteps[this.minorStepIdx],f=this.getFirstMajor()-t.getFirstMajor();if(this.zeroAlign){var m=a-c;this._end+=m/this.scale,this._start=this._end-u}else this.autoScaleStart?(this._start-=f/this.scale,this._end=this._start+u):(this._start+=p-f/this.scale,this._end=this._start+u);if(!this.autoScaleEnd&&this._end>o+1e-5)r(),d=!1;else{if(!this.autoScaleStart&&this._start<i-1e-5){if(!(this.zeroAlign&&i>=0)){r(),d=!1;continue}console.warn("Can't adhere to given 'min' range, due to zeroalign")}this.autoScaleStart&&this.autoScaleEnd&&u<o-i?(s(),d=!1):d=!0}}},o.prototype.convertValue=function(t){return this.containerHeight-(t-this._start)*this.scale},o.prototype.screenToValue=function(t){return(this.containerHeight-t)/this.scale+this._start},t.exports=o},function(t,e,i){function o(t,e,i,o){this.id=e;var n=["sampling","style","sort","yAxisOrientation","barChart","drawPoints","shaded","interpolation","zIndex","excludeFromStacking","excludeFromLegend"];this.options=r.selectiveBridgeObject(n,i),this.usingDefaultStyle=void 0===t.className,this.groupsUsingDefaultStyles=o,this.zeroPosition=0,this.update(t),1==this.usingDefaultStyle&&(this.groupsUsingDefaultStyles[0]+=1),this.itemsData=[],this.visible=void 0===t.visible||t.visible}var n=i(6),s=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(2),a=i(110),h=i(111),d=i(72);o.prototype.setItems=function(t){null!=t?(this.itemsData=t,1==this.options.sort&&r.insertSort(this.itemsData,function(t,e){return t.x>e.x?1:-1})):this.itemsData=[]},o.prototype.getItems=function(){return this.itemsData},o.prototype.setZeroPosition=function(t){this.zeroPosition=t},o.prototype.setOptions=function(t){if(void 0!==t){var e=["sampling","style","sort","yAxisOrientation","barChart","zIndex","excludeFromStacking","excludeFromLegend"];r.selectiveDeepExtend(e,this.options,t),"function"==typeof t.drawPoints&&(t.drawPoints={onRender:t.drawPoints}),r.mergeOptions(this.options,t,"interpolation"),r.mergeOptions(this.options,t,"drawPoints"),r.mergeOptions(this.options,t,"shaded"),t.interpolation&&"object"==(0,s.default)(t.interpolation)&&t.interpolation.parametrization&&("uniform"==t.interpolation.parametrization?this.options.interpolation.alpha=0:"chordal"==t.interpolation.parametrization?this.options.interpolation.alpha=1:(this.options.interpolation.parametrization="centripetal",this.options.interpolation.alpha=.5))}},o.prototype.update=function(t){this.group=t,this.content=t.content||"graph",this.className=t.className||this.className||"vis-graph-group"+this.groupsUsingDefaultStyles[0]%10,this.visible=void 0===t.visible||t.visible,this.style=t.style,this.setOptions(t.options)},o.prototype.getLegend=function(t,e,i,o,n){if(void 0==i||null==i){i={svg:document.createElementNS("http://www.w3.org/2000/svg","svg"),svgElements:{},options:this.options,groups:[this]}}switch(void 0!=o&&null!=o||(o=0),void 0!=n&&null!=n||(n=.5*e),this.options.style){case"line":h.drawIcon(this,o,n,t,e,i);break;case"points":case"point":d.drawIcon(this,o,n,t,e,i);break;case"bar":a.drawIcon(this,o,n,t,e,i)}return{icon:i.svg,label:this.content,orientation:this.options.yAxisOrientation}},o.prototype.getYRange=function(t){for(var e=t[0].y,i=t[0].y,o=0;o<t.length;o++)e=e>t[o].y?t[o].y:e,i=i<t[o].y?t[o].y:i;return{min:e,max:i,yAxisOrientation:this.options.yAxisOrientation}},t.exports=o},function(t,e,i){function o(t,e){}var n=i(14),s=i(72);o.drawIcon=function(t,e,i,o,s,r){var a=.5*s,h=n.getSVGElement("rect",r.svgElements,r.svg);h.setAttributeNS(null,"x",e),h.setAttributeNS(null,"y",i-a),h.setAttributeNS(null,"width",o),h.setAttributeNS(null,"height",2*a),h.setAttributeNS(null,"class","vis-outline");var d=Math.round(.3*o),l=t.options.barChart.width,u=l/d,c=Math.round(.4*s),p=Math.round(.75*s),f=Math.round((o-2*d)/3);if(n.drawBar(e+.5*d+f,i+a-c-1,d,c,t.className+" vis-bar",r.svgElements,r.svg,t.style),n.drawBar(e+1.5*d+f+2,i+a-p-1,d,p,t.className+" vis-bar",r.svgElements,r.svg,t.style),1==t.options.drawPoints.enabled){var m={style:t.options.drawPoints.style,styles:t.options.drawPoints.styles,size:t.options.drawPoints.size/u,className:t.className};n.drawPoint(e+.5*d+f,i+a-c-1,m,r.svgElements,r.svg),n.drawPoint(e+1.5*d+f+2,i+a-p-1,m,r.svgElements,r.svg)}},o.draw=function(t,e,i){var r,a,h,d,l,u,c=[],p={},f=0;for(l=0;l<t.length;l++)if(d=i.groups[t[l]],"bar"===d.options.style&&!0===d.visible&&(void 0===i.options.groups.visibility[t[l]]||!0===i.options.groups.visibility[t[l]]))for(u=0;u<e[t[l]].length;u++)c.push({screen_x:e[t[l]][u].screen_x,screen_end:e[t[l]][u].screen_end,screen_y:e[t[l]][u].screen_y,x:e[t[l]][u].x,end:e[t[l]][u].end,y:e[t[l]][u].y,groupId:t[l],label:e[t[l]][u].label}),f+=1;if(0!==f)for(c.sort(function(t,e){return t.screen_x===e.screen_x?t.groupId<e.groupId?-1:1:t.screen_x-e.screen_x}),o._getDataIntersections(p,c),l=0;l<c.length;l++){d=i.groups[c[l].groupId];var m=void 0!=d.options.barChart.minWidth?d.options.barChart.minWidth:.1*d.options.barChart.width;a=c[l].screen_x;var v=0;if(void 0===p[a])l+1<c.length&&(r=Math.abs(c[l+1].screen_x-a)),h=o._getSafeDrawData(r,d,m);else{var g=l+(p[a].amount-p[a].resolved);g<c.length&&(r=Math.abs(c[g].screen_x-a)),h=o._getSafeDrawData(r,d,m),p[a].resolved+=1,!0===d.options.stack&&!0!==d.options.excludeFromStacking?c[l].screen_y<d.zeroPosition?(v=p[a].accumulatedNegative,p[a].accumulatedNegative+=d.zeroPosition-c[l].screen_y):(v=p[a].accumulatedPositive,p[a].accumulatedPositive+=d.zeroPosition-c[l].screen_y):!0===d.options.barChart.sideBySide&&(h.width=h.width/p[a].amount,h.offset+=p[a].resolved*h.width-.5*h.width*(p[a].amount+1))}var y=h.width,b=c[l].screen_x;if(void 0!=c[l].screen_end?(y=c[l].screen_end-c[l].screen_x,b+=.5*y):b+=h.offset,n.drawBar(b,c[l].screen_y-v,y,d.zeroPosition-c[l].screen_y,d.className+" vis-bar",i.svgElements,i.svg,d.style),!0===d.options.drawPoints.enabled){var _={screen_x:c[l].screen_x,screen_y:c[l].screen_y-v,x:c[l].x,y:c[l].y,groupId:c[l].groupId,label:c[l].label};s.draw([_],d,i,h.offset)}}},o._getDataIntersections=function(t,e){for(var i,o=0;o<e.length;o++)o+1<e.length&&(i=Math.abs(e[o+1].screen_x-e[o].screen_x)),o>0&&(i=Math.min(i,Math.abs(e[o-1].screen_x-e[o].screen_x))),0===i&&(void 0===t[e[o].screen_x]&&(t[e[o].screen_x]={amount:0,resolved:0,accumulatedPositive:0,accumulatedNegative:0}),t[e[o].screen_x].amount+=1)},o._getSafeDrawData=function(t,e,i){var o,n;return t<e.options.barChart.width&&t>0?(o=t<i?i:t,n=0,"left"===e.options.barChart.align?n-=.5*t:"right"===e.options.barChart.align&&(n+=.5*t)):(o=e.options.barChart.width,n=0,"left"===e.options.barChart.align?n-=.5*e.options.barChart.width:"right"===e.options.barChart.align&&(n+=.5*e.options.barChart.width)),{width:o,offset:n}},o.getStackedYRange=function(t,e,i,n,s){if(t.length>0){t.sort(function(t,e){return t.screen_x===e.screen_x?t.groupId<e.groupId?-1:1:t.screen_x-e.screen_x});var r={};o._getDataIntersections(r,t),e[n]=o._getStackedYRange(r,t),e[n].yAxisOrientation=s,i.push(n)}},o._getStackedYRange=function(t,e){for(var i,o=e[0].screen_y,n=e[0].screen_y,s=0;s<e.length;s++)i=e[s].screen_x,void 0===t[i]?(o=o>e[s].screen_y?e[s].screen_y:o,n=n<e[s].screen_y?e[s].screen_y:n):e[s].screen_y<0?t[i].accumulatedNegative+=e[s].screen_y:t[i].accumulatedPositive+=e[s].screen_y;for(var r in t)t.hasOwnProperty(r)&&(o=o>t[r].accumulatedNegative?t[r].accumulatedNegative:o,o=o>t[r].accumulatedPositive?t[r].accumulatedPositive:o,n=n<t[r].accumulatedNegative?t[r].accumulatedNegative:n,n=n<t[r].accumulatedPositive?t[r].accumulatedPositive:n);return{min:o,max:n}},t.exports=o},function(t,e,i){function o(t,e){}var n=i(14);o.calcPath=function(t,e){if(null!=t&&t.length>0){return 1==e.options.interpolation.enabled?o._catmullRom(t,e):o._linear(t)}},o.drawIcon=function(t,e,i,o,s,r){var a,h,d=.5*s,l=n.getSVGElement("rect",r.svgElements,r.svg);if(l.setAttributeNS(null,"x",e),l.setAttributeNS(null,"y",i-d),l.setAttributeNS(null,"width",o),l.setAttributeNS(null,"height",2*d),l.setAttributeNS(null,"class","vis-outline"),a=n.getSVGElement("path",r.svgElements,r.svg),a.setAttributeNS(null,"class",t.className),void 0!==t.style&&a.setAttributeNS(null,"style",t.style),a.setAttributeNS(null,"d","M"+e+","+i+" L"+(e+o)+","+i),1==t.options.shaded.enabled&&(h=n.getSVGElement("path",r.svgElements,r.svg),"top"==t.options.shaded.orientation?h.setAttributeNS(null,"d","M"+e+", "+(i-d)+"L"+e+","+i+" L"+(e+o)+","+i+" L"+(e+o)+","+(i-d)):h.setAttributeNS(null,"d","M"+e+","+i+" L"+e+","+(i+d)+" L"+(e+o)+","+(i+d)+"L"+(e+o)+","+i),h.setAttributeNS(null,"class",t.className+" vis-icon-fill"),void 0!==t.options.shaded.style&&""!==t.options.shaded.style&&h.setAttributeNS(null,"style",t.options.shaded.style)),1==t.options.drawPoints.enabled){var u={style:t.options.drawPoints.style,styles:t.options.drawPoints.styles,size:t.options.drawPoints.size,className:t.className};n.drawPoint(e+.5*o,i,u,r.svgElements,r.svg)}},o.drawShading=function(t,e,i,o){if(1==e.options.shaded.enabled){var s=Number(o.svg.style.height.replace("px","")),r=n.getSVGElement("path",o.svgElements,o.svg),a="L";1==e.options.interpolation.enabled&&(a="C");var h,d=0;d="top"==e.options.shaded.orientation?0:"bottom"==e.options.shaded.orientation?s:Math.min(Math.max(0,e.zeroPosition),s),h="group"==e.options.shaded.orientation&&null!=i&&void 0!=i?"M"+t[0][0]+","+t[0][1]+" "+this.serializePath(t,a,!1)+" L"+i[i.length-1][0]+","+i[i.length-1][1]+" "+this.serializePath(i,a,!0)+i[0][0]+","+i[0][1]+" Z":"M"+t[0][0]+","+t[0][1]+" "+this.serializePath(t,a,!1)+" V"+d+" H"+t[0][0]+" Z",r.setAttributeNS(null,"class",e.className+" vis-fill"),void 0!==e.options.shaded.style&&r.setAttributeNS(null,"style",e.options.shaded.style),r.setAttributeNS(null,"d",h)}},o.draw=function(t,e,i){if(null!=t&&void 0!=t){var o=n.getSVGElement("path",i.svgElements,i.svg);o.setAttributeNS(null,"class",e.className),void 0!==e.style&&o.setAttributeNS(null,"style",e.style);var s="L";1==e.options.interpolation.enabled&&(s="C"),o.setAttributeNS(null,"d","M"+t[0][0]+","+t[0][1]+" "+this.serializePath(t,s,!1))}},o.serializePath=function(t,e,i){if(t.length<2)return"";var o,n=e;if(i)for(o=t.length-2;o>0;o--)n+=t[o][0]+","+t[o][1]+" ";else for(o=1;o<t.length;o++)n+=t[o][0]+","+t[o][1]+" ";return n},o._catmullRomUniform=function(t){var e,i,o,n,s,r,a=[];a.push([Math.round(t[0].screen_x),Math.round(t[0].screen_y)]);for(var h=t.length,d=0;d<h-1;d++)e=0==d?t[0]:t[d-1],i=t[d],o=t[d+1],n=d+2<h?t[d+2]:o,s={screen_x:(-e.screen_x+6*i.screen_x+o.screen_x)*(1/6),screen_y:(-e.screen_y+6*i.screen_y+o.screen_y)*(1/6)},r={screen_x:(i.screen_x+6*o.screen_x-n.screen_x)*(1/6),screen_y:(i.screen_y+6*o.screen_y-n.screen_y)*(1/6)},a.push([s.screen_x,s.screen_y]),a.push([r.screen_x,r.screen_y]),a.push([o.screen_x,o.screen_y]);return a},o._catmullRom=function(t,e){var i=e.options.interpolation.alpha;if(0==i||void 0===i)return this._catmullRomUniform(t);var o,n,s,r,a,h,d,l,u,c,p,f,m,v,g,y,b,_,w,x=[];x.push([Math.round(t[0].screen_x),Math.round(t[0].screen_y)]);for(var k=t.length,S=0;S<k-1;S++)o=0==S?t[0]:t[S-1],n=t[S],s=t[S+1],r=S+2<k?t[S+2]:s, +d=Math.sqrt(Math.pow(o.screen_x-n.screen_x,2)+Math.pow(o.screen_y-n.screen_y,2)),l=Math.sqrt(Math.pow(n.screen_x-s.screen_x,2)+Math.pow(n.screen_y-s.screen_y,2)),u=Math.sqrt(Math.pow(s.screen_x-r.screen_x,2)+Math.pow(s.screen_y-r.screen_y,2)),v=Math.pow(u,i),y=Math.pow(u,2*i),g=Math.pow(l,i),b=Math.pow(l,2*i),w=Math.pow(d,i),_=Math.pow(d,2*i),c=2*_+3*w*g+b,p=2*y+3*v*g+b,f=3*w*(w+g),f>0&&(f=1/f),m=3*v*(v+g),m>0&&(m=1/m),a={screen_x:(-b*o.screen_x+c*n.screen_x+_*s.screen_x)*f,screen_y:(-b*o.screen_y+c*n.screen_y+_*s.screen_y)*f},h={screen_x:(y*n.screen_x+p*s.screen_x-b*r.screen_x)*m,screen_y:(y*n.screen_y+p*s.screen_y-b*r.screen_y)*m},0==a.screen_x&&0==a.screen_y&&(a=n),0==h.screen_x&&0==h.screen_y&&(h=s),x.push([a.screen_x,a.screen_y]),x.push([h.screen_x,h.screen_y]),x.push([s.screen_x,s.screen_y]);return x},o._linear=function(t){for(var e=[],i=0;i<t.length;i++)e.push([t[i].screen_x,t[i].screen_y]);return e},t.exports=o},function(t,e,i){function o(t,e,i,o){this.body=t,this.defaultOptions={enabled:!1,icons:!0,iconSize:20,iconSpacing:6,left:{visible:!0,position:"top-left"},right:{visible:!0,position:"top-right"}},this.side=i,this.options=r.extend({},this.defaultOptions),this.linegraphOptions=o,this.svgElements={},this.dom={},this.groups={},this.amountOfGroups=0,this._create(),this.framework={svg:this.svg,svgElements:this.svgElements,options:this.options,groups:this.groups},this.setOptions(e)}var n=i(8),s=function(t){return t&&t.__esModule?t:{default:t}}(n),r=i(2),a=i(14),h=i(16);o.prototype=new h,o.prototype.clear=function(){this.groups={},this.amountOfGroups=0},o.prototype.addGroup=function(t,e){1!=e.options.excludeFromLegend&&(this.groups.hasOwnProperty(t)||(this.groups[t]=e),this.amountOfGroups+=1)},o.prototype.updateGroup=function(t,e){this.groups[t]=e},o.prototype.removeGroup=function(t){this.groups.hasOwnProperty(t)&&(delete this.groups[t],this.amountOfGroups-=1)},o.prototype._create=function(){this.dom.frame=document.createElement("div"),this.dom.frame.className="vis-legend",this.dom.frame.style.position="absolute",this.dom.frame.style.top="10px",this.dom.frame.style.display="block",this.dom.textArea=document.createElement("div"),this.dom.textArea.className="vis-legend-text",this.dom.textArea.style.position="relative",this.dom.textArea.style.top="0px",this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.position="absolute",this.svg.style.top="0px",this.svg.style.width=this.options.iconSize+5+"px",this.svg.style.height="100%",this.dom.frame.appendChild(this.svg),this.dom.frame.appendChild(this.dom.textArea)},o.prototype.hide=function(){this.dom.frame.parentNode&&this.dom.frame.parentNode.removeChild(this.dom.frame)},o.prototype.show=function(){this.dom.frame.parentNode||this.body.dom.center.appendChild(this.dom.frame)},o.prototype.setOptions=function(t){var e=["enabled","orientation","icons","left","right"];r.selectiveDeepExtend(e,this.options,t)},o.prototype.redraw=function(){var t=0,e=(0,s.default)(this.groups);e.sort(function(t,e){return t<e?-1:1});for(var i=0;i<e.length;i++){var o=e[i];1!=this.groups[o].visible||void 0!==this.linegraphOptions.visibility[o]&&1!=this.linegraphOptions.visibility[o]||t++}if(0==this.options[this.side].visible||0==this.amountOfGroups||0==this.options.enabled||0==t)this.hide();else{if(this.show(),"top-left"==this.options[this.side].position||"bottom-left"==this.options[this.side].position?(this.dom.frame.style.left="4px",this.dom.frame.style.textAlign="left",this.dom.textArea.style.textAlign="left",this.dom.textArea.style.left=this.options.iconSize+15+"px",this.dom.textArea.style.right="",this.svg.style.left="0px",this.svg.style.right=""):(this.dom.frame.style.right="4px",this.dom.frame.style.textAlign="right",this.dom.textArea.style.textAlign="right",this.dom.textArea.style.right=this.options.iconSize+15+"px",this.dom.textArea.style.left="",this.svg.style.right="0px",this.svg.style.left=""),"top-left"==this.options[this.side].position||"top-right"==this.options[this.side].position)this.dom.frame.style.top=4-Number(this.body.dom.center.style.top.replace("px",""))+"px",this.dom.frame.style.bottom="";else{var n=this.body.domProps.center.height-this.body.domProps.centerContainer.height;this.dom.frame.style.bottom=4+n+Number(this.body.dom.center.style.top.replace("px",""))+"px",this.dom.frame.style.top=""}0==this.options.icons?(this.dom.frame.style.width=this.dom.textArea.offsetWidth+10+"px",this.dom.textArea.style.right="",this.dom.textArea.style.left="",this.svg.style.width="0px"):(this.dom.frame.style.width=this.options.iconSize+15+this.dom.textArea.offsetWidth+10+"px",this.drawLegendIcons());var r="";for(i=0;i<e.length;i++)o=e[i],1!=this.groups[o].visible||void 0!==this.linegraphOptions.visibility[o]&&1!=this.linegraphOptions.visibility[o]||(r+=this.groups[o].content+"<br />");this.dom.textArea.innerHTML=r,this.dom.textArea.style.lineHeight=.75*this.options.iconSize+this.options.iconSpacing+"px"}},o.prototype.drawLegendIcons=function(){if(this.dom.frame.parentNode){var t=(0,s.default)(this.groups);t.sort(function(t,e){return t<e?-1:1}),a.resetElements(this.svgElements);var e=window.getComputedStyle(this.dom.frame).paddingTop,i=Number(e.replace("px","")),o=i,n=this.options.iconSize,r=.75*this.options.iconSize,h=i+.5*r+3;this.svg.style.width=n+5+i+"px";for(var d=0;d<t.length;d++){var l=t[d];1!=this.groups[l].visible||void 0!==this.linegraphOptions.visibility[l]&&1!=this.linegraphOptions.visibility[l]||(this.groups[l].getLegend(n,r,this.framework,o,h),h+=r+this.options.iconSpacing)}}},t.exports=o},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var o="string",n="boolean",s="number",r="object",a={configure:{enabled:{boolean:n},filter:{boolean:n,function:"function"},container:{dom:"dom"},__type__:{object:r,boolean:n,function:"function"}},yAxisOrientation:{string:["left","right"]},defaultGroup:{string:o},sort:{boolean:n},sampling:{boolean:n},stack:{boolean:n},graphHeight:{string:o,number:s},shaded:{enabled:{boolean:n},orientation:{string:["bottom","top","zero","group"]},groupId:{object:r},__type__:{boolean:n,object:r}},style:{string:["line","bar","points"]},barChart:{width:{number:s},minWidth:{number:s},sideBySide:{boolean:n},align:{string:["left","center","right"]},__type__:{object:r}},interpolation:{enabled:{boolean:n},parametrization:{string:["centripetal","chordal","uniform"]},alpha:{number:s},__type__:{object:r,boolean:n}},drawPoints:{enabled:{boolean:n},onRender:{function:"function"},size:{number:s},style:{string:["square","circle"]},__type__:{object:r,boolean:n,function:"function"}},dataAxis:{showMinorLabels:{boolean:n},showMajorLabels:{boolean:n},icons:{boolean:n},width:{string:o,number:s},visible:{boolean:n},alignZeros:{boolean:n},left:{range:{min:{number:s,undefined:"undefined"},max:{number:s,undefined:"undefined"},__type__:{object:r}},format:{function:"function"},title:{text:{string:o,number:s,undefined:"undefined"},style:{string:o,undefined:"undefined"},__type__:{object:r}},__type__:{object:r}},right:{range:{min:{number:s,undefined:"undefined"},max:{number:s,undefined:"undefined"},__type__:{object:r}},format:{function:"function"},title:{text:{string:o,number:s,undefined:"undefined"},style:{string:o,undefined:"undefined"},__type__:{object:r}},__type__:{object:r}},__type__:{object:r}},legend:{enabled:{boolean:n},icons:{boolean:n},left:{visible:{boolean:n},position:{string:["top-right","bottom-right","top-left","bottom-left"]},__type__:{object:r}},right:{visible:{boolean:n},position:{string:["top-right","bottom-right","top-left","bottom-left"]},__type__:{object:r}},__type__:{object:r,boolean:n}},groups:{visibility:{any:"any"},__type__:{object:r}},autoResize:{boolean:n},throttleRedraw:{number:s},clickToUse:{boolean:n},end:{number:s,date:"date",string:o,moment:"moment"},format:{minorLabels:{millisecond:{string:o,undefined:"undefined"},second:{string:o,undefined:"undefined"},minute:{string:o,undefined:"undefined"},hour:{string:o,undefined:"undefined"},weekday:{string:o,undefined:"undefined"},day:{string:o,undefined:"undefined"},month:{string:o,undefined:"undefined"},year:{string:o,undefined:"undefined"},__type__:{object:r}},majorLabels:{millisecond:{string:o,undefined:"undefined"},second:{string:o,undefined:"undefined"},minute:{string:o,undefined:"undefined"},hour:{string:o,undefined:"undefined"},weekday:{string:o,undefined:"undefined"},day:{string:o,undefined:"undefined"},month:{string:o,undefined:"undefined"},year:{string:o,undefined:"undefined"},__type__:{object:r}},__type__:{object:r}},moment:{function:"function"},height:{string:o,number:s},hiddenDates:{start:{date:"date",number:s,string:o,moment:"moment"},end:{date:"date",number:s,string:o,moment:"moment"},repeat:{string:o},__type__:{object:r,array:"array"}},locale:{string:o},locales:{__any__:{any:"any"},__type__:{object:r}},max:{date:"date",number:s,string:o,moment:"moment"},maxHeight:{number:s,string:o},maxMinorChars:{number:s},min:{date:"date",number:s,string:o,moment:"moment"},minHeight:{number:s,string:o},moveable:{boolean:n},multiselect:{boolean:n},orientation:{string:o},showCurrentTime:{boolean:n},showMajorLabels:{boolean:n},showMinorLabels:{boolean:n},start:{date:"date",number:s,string:o,moment:"moment"},timeAxis:{scale:{string:o,undefined:"undefined"},step:{number:s,undefined:"undefined"},__type__:{object:r}},width:{string:o,number:s},zoomable:{boolean:n},zoomKey:{string:["ctrlKey","altKey","metaKey",""]},zoomMax:{number:s},zoomMin:{number:s},zIndex:{number:s},__type__:{object:r}},h={global:{sort:!0,sampling:!0,stack:!1,shaded:{enabled:!1,orientation:["zero","top","bottom","group"]},style:["line","bar","points"],barChart:{width:[50,5,100,5],minWidth:[50,5,100,5],sideBySide:!1,align:["left","center","right"]},interpolation:{enabled:!0,parametrization:["centripetal","chordal","uniform"]},drawPoints:{enabled:!0,size:[6,2,30,1],style:["square","circle"]},dataAxis:{showMinorLabels:!0,showMajorLabels:!0,icons:!1,width:[40,0,200,1],visible:!0,alignZeros:!0,left:{title:{text:"",style:""}},right:{title:{text:"",style:""}}},legend:{enabled:!1,icons:!0,left:{visible:!0,position:["top-right","bottom-right","top-left","bottom-left"]},right:{visible:!0,position:["top-right","bottom-right","top-left","bottom-left"]}},autoResize:!0,clickToUse:!1,end:"",format:{minorLabels:{millisecond:"SSS",second:"s",minute:"HH:mm",hour:"HH:mm",weekday:"ddd D",day:"D",month:"MMM",year:"YYYY"},majorLabels:{millisecond:"HH:mm:ss",second:"D MMMM HH:mm",minute:"ddd D MMMM",hour:"ddd D MMMM",weekday:"MMMM YYYY",day:"MMMM YYYY",month:"YYYY",year:""}},height:"",locale:"",max:"",maxHeight:"",maxMinorChars:[7,0,20,1],min:"",minHeight:"",moveable:!0,orientation:["both","bottom","top"],showCurrentTime:!1,showMajorLabels:!0,showMinorLabels:!0,start:"",width:"100%",zoomable:!0,zoomKey:["ctrlKey","altKey","metaKey",""],zoomMax:[31536e10,10,31536e10,1],zoomMin:[10,10,31536e10,1],zIndex:0}};e.allOptions=a,e.configureOptions=h},function(t,e,i){function o(t){return R=t,f()}function n(){A=0,z=R.charAt(0)}function s(){A++,z=R.charAt(A)}function r(){return R.charAt(A+1)}function a(t){return B.test(t)}function h(t,e){if(t||(t={}),e)for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function d(t,e,i){for(var o=e.split("."),n=t;o.length;){var s=o.shift();o.length?(n[s]||(n[s]={}),n=n[s]):n[s]=i}}function l(t,e){for(var i,o,n=null,s=[t],r=t;r.parent;)s.push(r.parent),r=r.parent;if(r.nodes)for(i=0,o=r.nodes.length;i<o;i++)if(e.id===r.nodes[i].id){n=r.nodes[i];break}for(n||(n={id:e.id},t.node&&(n.attr=h(n.attr,t.node))),i=s.length-1;i>=0;i--){var a=s[i];a.nodes||(a.nodes=[]),-1===a.nodes.indexOf(n)&&a.nodes.push(n)}e.attr&&(n.attr=h(n.attr,e.attr))}function u(t,e){if(t.edges||(t.edges=[]),t.edges.push(e),t.edge){var i=h({},t.edge);e.attr=h(i,e.attr)}}function c(t,e,i,o,n){var s={from:e,to:i,type:o};return t.edge&&(s.attr=h({},t.edge)),s.attr=h(s.attr||{},n),s}function p(){for(F=I.NULL,L="";" "===z||"\t"===z||"\n"===z||"\r"===z;)s();do{var t=!1;if("#"===z){for(var e=A-1;" "===R.charAt(e)||"\t"===R.charAt(e);)e--;if("\n"===R.charAt(e)||""===R.charAt(e)){for(;""!=z&&"\n"!=z;)s();t=!0}}if("/"===z&&"/"===r()){for(;""!=z&&"\n"!=z;)s();t=!0}if("/"===z&&"*"===r()){for(;""!=z;){if("*"===z&&"/"===r()){s(),s();break}s()}t=!0}for(;" "===z||"\t"===z||"\n"===z||"\r"===z;)s()}while(t);if(""===z)return void(F=I.DELIMITER);var i=z+r();if(N[i])return F=I.DELIMITER,L=i,s(),void s();if(N[z])return F=I.DELIMITER,L=z,void s();if(a(z)||"-"===z){for(L+=z,s();a(z);)L+=z,s();return"false"===L?L=!1:"true"===L?L=!0:isNaN(Number(L))||(L=Number(L)),void(F=I.IDENTIFIER)}if('"'===z){for(s();""!=z&&('"'!=z||'"'===z&&'"'===r());)'"'===z?(L+=z,s()):"\\"===z&&"n"===r()?(L+="\n",s()):L+=z,s();if('"'!=z)throw x('End of string " expected');return s(),void(F=I.IDENTIFIER)}for(F=I.UNKNOWN;""!=z;)L+=z,s();throw new SyntaxError('Syntax error in part "'+k(L,30)+'"')}function f(){var t={};if(n(),p(),"strict"===L&&(t.strict=!0,p()),"graph"!==L&&"digraph"!==L||(t.type=L,p()),F===I.IDENTIFIER&&(t.id=L,p()),"{"!=L)throw x("Angle bracket { expected");if(p(),m(t),"}"!=L)throw x("Angle bracket } expected");if(p(),""!==L)throw x("End of file expected");return p(),delete t.node,delete t.edge,delete t.graph,t}function m(t){for(;""!==L&&"}"!=L;)v(t),";"===L&&p()}function v(t){var e=g(t);if(e)return void _(t,e);if(!y(t)){if(F!=I.IDENTIFIER)throw x("Identifier expected");var i=L;if(p(),"="===L){if(p(),F!=I.IDENTIFIER)throw x("Identifier expected");t[i]=L,p()}else b(t,i)}}function g(t){var e=null;if("subgraph"===L&&(e={},e.type="subgraph",p(),F===I.IDENTIFIER&&(e.id=L,p())),"{"===L){if(p(),e||(e={}),e.parent=t,e.node=t.node,e.edge=t.edge,e.graph=t.graph,m(e),"}"!=L)throw x("Angle bracket } expected");p(),delete e.node,delete e.edge,delete e.graph,delete e.parent,t.subgraphs||(t.subgraphs=[]),t.subgraphs.push(e)}return e}function y(t){return"node"===L?(p(),t.node=w(),"node"):"edge"===L?(p(),t.edge=w(),"edge"):"graph"===L?(p(),t.graph=w(),"graph"):null}function b(t,e){var i={id:e},o=w();o&&(i.attr=o),l(t,i),_(t,e)}function _(t,e){for(;"->"===L||"--"===L;){var i,o=L;p();var n=g(t);if(n)i=n;else{if(F!=I.IDENTIFIER)throw x("Identifier or subgraph expected");i=L,l(t,{id:i}),p()}u(t,c(t,e,i,o,w())),e=i}}function w(){for(var t=null,e={dashed:!0,solid:!1,dotted:[1,5]};"["===L;){for(p(),t={};""!==L&&"]"!=L;){if(F!=I.IDENTIFIER)throw x("Attribute name expected");var i=L;if(p(),"="!=L)throw x("Equal sign = expected");if(p(),F!=I.IDENTIFIER)throw x("Attribute value expected");var o=L;"style"===i&&(o=e[o]),d(t,i,o),p(),","==L&&p()}if("]"!=L)throw x("Bracket ] expected");p()}return t}function x(t){return new SyntaxError(t+', got "'+k(L,30)+'" (char '+A+")")}function k(t,e){return t.length<=e?t:t.substr(0,27)+"..."}function S(t,e,i){Array.isArray(t)?t.forEach(function(t){Array.isArray(e)?e.forEach(function(e){i(t,e)}):i(t,e)}):Array.isArray(e)?e.forEach(function(e){i(t,e)}):i(t,e)}function D(t,e,i){for(var o=e.split("."),n=o.pop(),s=t,r=0;r<o.length;r++){var a=o[r];a in s||(s[a]={}),s=s[a]}return s[n]=i,t}function M(t,e){var i={};for(var o in t)if(t.hasOwnProperty(o)){var n=e[o];Array.isArray(n)?n.forEach(function(e){D(i,e,t[o])}):"string"==typeof n?D(i,n,t[o]):D(i,o,t[o])}return i}function C(t){var e=o(t),i={nodes:[],edges:[],options:{}};if(e.nodes&&e.nodes.forEach(function(t){var e={id:t.id,label:String(t.label||t.id)};h(e,M(t.attr,T)),e.image&&(e.shape="image"),i.nodes.push(e)}),e.edges){var n=function(t){var e={from:t.from,to:t.to};return h(e,M(t.attr,P)),e.arrows="->"===t.type?"to":void 0,e};e.edges.forEach(function(t){var e,o;e=t.from instanceof Object?t.from.nodes:{id:t.from},o=t.to instanceof Object?t.to.nodes:{id:t.to},t.from instanceof Object&&t.from.edges&&t.from.edges.forEach(function(t){var e=n(t);i.edges.push(e)}),S(e,o,function(e,o){var s=c(i,e.id,o.id,t.type,t.attr),r=n(s);i.edges.push(r)}),t.to instanceof Object&&t.to.edges&&t.to.edges.forEach(function(t){var e=n(t);i.edges.push(e)})})}return e.attr&&(i.options=e.attr),i}var O=i(29),E=function(t){return t&&t.__esModule?t:{default:t}}(O),T={fontsize:"font.size",fontcolor:"font.color",labelfontcolor:"font.color",fontname:"font.face",color:["color.border","color.background"],fillcolor:"color.background",tooltip:"title",labeltooltip:"title"},P=(0,E.default)(T);P.color="color.color",P.style="dashes";var I={NULL:0,DELIMITER:1,IDENTIFIER:2,UNKNOWN:3},N={"{":!0,"}":!0,"[":!0,"]":!0,";":!0,"=":!0,",":!0,"->":!0,"--":!0},R="",A=0,z="",L="",F=I.NULL,B=/[a-zA-Z_0-9.:#]/;e.parseDOT=o,e.DOTToGraph=C},function(t,e,i){function o(t,e){var i=[],o=[],n={edges:{inheritColor:!1},nodes:{fixed:!1,parseColor:!1}};void 0!==e&&(void 0!==e.fixed&&(n.nodes.fixed=e.fixed),void 0!==e.parseColor&&(n.nodes.parseColor=e.parseColor),void 0!==e.inheritColor&&(n.edges.inheritColor=e.inheritColor));for(var s=t.edges,r=t.nodes,a=0;a<s.length;a++){var h={},d=s[a];h.id=d.id,h.from=d.source,h.to=d.target,h.attributes=d.attributes,h.label=d.label,h.title=void 0!==d.attributes?d.attributes.title:void 0,"Directed"===d.type&&(h.arrows="to"),d.color&&!1===n.inheritColor&&(h.color=d.color),i.push(h)}for(var l=0;l<r.length;l++){var u={},c=r[l];u.id=c.id,u.attributes=c.attributes,u.x=c.x,u.y=c.y,u.label=c.label,u.title=void 0!==c.attributes?c.attributes.title:c.title,!0===n.nodes.parseColor?u.color=c.color:u.color=void 0!==c.color?{background:c.color,border:c.color,highlight:{background:c.color,border:c.color},hover:{background:c.color,border:c.color}}:void 0,u.size=c.size,u.fixed=n.nodes.fixed&&void 0!==c.x&&void 0!==c.y,o.push(u)}return{nodes:o,edges:i}}e.parseGephi=o},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(185),d=o(h),l=function(){function t(e){(0,s.default)(this,t),this.images={},this.imageBroken={},this.callback=e}return(0,a.default)(t,[{key:"_tryloadBrokenUrl",value:function(t,e,i){if(void 0!==t&&void 0!==i){if(void 0===e)return void console.warn("No broken url image defined");i.onerror=function(){console.error("Could not load brokenImage:",e)},i.image.src=e}}},{key:"_redrawWithImage",value:function(t){this.callback&&this.callback(t)}},{key:"load",value:function(t,e){var i=this,o=this.images[t];if(o)return o;var n=new d.default;return this.images[t]=n,n.image.onload=function(){i._fixImageCoordinates(n.image),n.init(),i._redrawWithImage(n)},n.image.onerror=function(){console.error("Could not load image:",t),i._tryloadBrokenUrl(t,e,n)},n.image.src=t,n}},{key:"_fixImageCoordinates",value:function(t){0===t.width&&(document.body.appendChild(t),t.width=t.offsetWidth,t.height=t.offsetHeight,document.body.removeChild(t))}}]),t}();e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(30),s=o(n),r=i(6),a=o(r),h=i(0),d=o(h),l=i(1),u=o(l),c=i(2),p=i(48).default,f=i(191).default,m=["bold","ital","boldital","mono"],v=function(){function t(e,i){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(0,d.default)(this,t),this.body=e,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(i),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=o}return(0,u.default)(t,[{key:"setOptions",value:function(t){if(this.elementOptions=t,this.initFontOptions(t.font),p.isValidLabel(t.label)?this.labelDirty=!0:t.label="",void 0!==t.font&&null!==t.font)if("string"==typeof t.font)this.baseSize=this.fontOptions.size;else if("object"===(0,a.default)(t.font)){var e=t.font.size;void 0!==e&&(this.baseSize=e)}}},{key:"initFontOptions",value:function(e){var i=this;if(c.forEach(m,function(t){i.fontOptions[t]={}}),t.parseFontString(this.fontOptions,e))return void(this.fontOptions.vadjust=0);c.forEach(e,function(t,e){void 0!==t&&null!==t&&"object"!==(void 0===t?"undefined":(0,a.default)(t))&&(i.fontOptions[e]=t)})}},{key:"constrain",value:function(t){var e={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},i=c.topMost(t,"widthConstraint");if("number"==typeof i)e.maxWdt=Number(i),e.minWdt=Number(i);else if("object"===(void 0===i?"undefined":(0,a.default)(i))){var o=c.topMost(t,["widthConstraint","maximum"]);"number"==typeof o&&(e.maxWdt=Number(o));var n=c.topMost(t,["widthConstraint","minimum"]);"number"==typeof n&&(e.minWdt=Number(n))}var s=c.topMost(t,"heightConstraint");if("number"==typeof s)e.minHgt=Number(s);else if("object"===(void 0===s?"undefined":(0,a.default)(s))){var r=c.topMost(t,["heightConstraint","minimum"]);"number"==typeof r&&(e.minHgt=Number(r));var h=c.topMost(t,["heightConstraint","valign"]);"string"==typeof h&&("top"!==h&&"bottom"!==h||(e.valign=h))}return e}},{key:"update",value:function(t,e){this.setOptions(t,!0),this.propagateFonts(e),c.deepExtend(this.fontOptions,this.constrain(e)),this.fontOptions.chooser=p.choosify("label",e)}},{key:"adjustSizes",value:function(t){var e=t?t.right+t.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=e,this.fontOptions.minWdt-=e);var i=t?t.top+t.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=i)}},{key:"addFontOptionsToPile",value:function(t,e){for(var i=0;i<e.length;++i)this.addFontToPile(t,e[i])}},{key:"addFontToPile",value:function(t,e){if(void 0!==e&&void 0!==e.font&&null!==e.font){var i=e.font;t.push(i)}}},{key:"getBasicOptions",value:function(e){for(var i={},o=0;o<e.length;++o){var n=e[o],s={};t.parseFontString(s,n)&&(n=s),c.forEach(n,function(t,e){void 0!==t&&(i.hasOwnProperty(e)||(-1!==m.indexOf(e)?i[e]={}:i[e]=t))})}return i}},{key:"getFontOption",value:function(e,i,o){for(var n=void 0,s=0;s<e.length;++s){var r=e[s];if(r.hasOwnProperty(i)){if(void 0===(n=r[i])||null===n)continue;var a={};if(t.parseFontString(a,n)&&(n=a),n.hasOwnProperty(o))return n[o]}}if(this.fontOptions.hasOwnProperty(o))return this.fontOptions[o];throw new Error("Did not find value for multi-font for property: '"+o+"'")}},{key:"getFontOptions",value:function(t,e){for(var i={},o=["color","size","face","mod","vadjust"],n=0;n<o.length;++n){var s=o[n];i[s]=this.getFontOption(t,e,s)}return i}},{key:"propagateFonts",value:function(t){var e=this,i=[];this.addFontOptionsToPile(i,t),this.fontOptions=this.getBasicOptions(i);for(var o=0;o<m.length;++o)!function(t){var o=m[t],n=e.fontOptions[o],s=e.getFontOptions(i,o);c.forEach(s,function(t,e){n[e]=t}),n.size=Number(n.size),n.vadjust=Number(n.vadjust)}(o)}},{key:"draw",value:function(t,e,i,o,n){var s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"middle";if(void 0!==this.elementOptions.label){var r=this.fontOptions.size*this.body.view.scale;this.elementOptions.label&&r<this.elementOptions.scaling.label.drawThreshold-1||(r>=this.elementOptions.scaling.label.maxVisible&&(r=Number(this.elementOptions.scaling.label.maxVisible)/this.body.view.scale),this.calculateLabelSize(t,o,n,e,i,s),this._drawBackground(t),this._drawText(t,e,this.size.yLine,s,r))}}},{key:"_drawBackground",value:function(t){if(void 0!==this.fontOptions.background&&"none"!==this.fontOptions.background){t.fillStyle=this.fontOptions.background;var e=this.getSize();t.fillRect(e.left,e.top,e.width,e.height)}}},{key:"_drawText",value:function(t,e,i){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"middle",n=arguments[4],r=this._setAlignment(t,e,i,o),a=(0,s.default)(r,2);e=a[0],i=a[1],t.textAlign="left",e-=this.size.width/2,this.fontOptions.valign&&this.size.height>this.size.labelHeight&&("top"===this.fontOptions.valign&&(i-=(this.size.height-this.size.labelHeight)/2),"bottom"===this.fontOptions.valign&&(i+=(this.size.height-this.size.labelHeight)/2));for(var h=0;h<this.lineCount;h++){var d=this.lines[h];if(d&&d.blocks){var l=0;this.isEdgeLabel||"center"===this.fontOptions.align?l+=(this.size.width-d.width)/2:"right"===this.fontOptions.align&&(l+=this.size.width-d.width);for(var u=0;u<d.blocks.length;u++){var c=d.blocks[u];t.font=c.font;var p=this._getColor(c.color,n,c.strokeColor),f=(0,s.default)(p,2),m=f[0],v=f[1];c.strokeWidth>0&&(t.lineWidth=c.strokeWidth,t.strokeStyle=v,t.lineJoin="round"),t.fillStyle=m,c.strokeWidth>0&&t.strokeText(c.text,e+l,i+c.vadjust),t.fillText(c.text,e+l,i+c.vadjust),l+=c.width}i+=d.height}}}},{key:"_setAlignment",value:function(t,e,i,o){if(this.isEdgeLabel&&"horizontal"!==this.fontOptions.align&&!1===this.pointToSelf){e=0,i=0;"top"===this.fontOptions.align?(t.textBaseline="alphabetic",i-=4):"bottom"===this.fontOptions.align?(t.textBaseline="hanging",i+=4):t.textBaseline="middle"}else t.textBaseline=o;return[e,i]}},{key:"_getColor",value:function(t,e,i){var o=t||"#000000",n=i||"#ffffff";if(e<=this.elementOptions.scaling.label.drawThreshold){var s=Math.max(0,Math.min(1,1-(this.elementOptions.scaling.label.drawThreshold-e)));o=c.overrideOpacity(o,s),n=c.overrideOpacity(n,s)}return[o,n]}},{key:"getTextSize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this._processLabel(t,e,i),{width:this.size.width,height:this.size.height,lineCount:this.lineCount}}},{key:"getSize",value:function(){var t=this.size.left,e=this.size.top-1;if(this.isEdgeLabel){var i=.5*-this.size.width;switch(this.fontOptions.align){case"middle":t=i,e=.5*-this.size.height;break;case"top":t=i,e=-(this.size.height+2);break;case"bottom":t=i,e=2}}return{left:t,top:e,width:this.size.width,height:this.size.height}}},{key:"calculateLabelSize",value:function(t,e,i){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"middle";this._processLabel(t,e,i),this.size.left=o-.5*this.size.width,this.size.top=n-.5*this.size.height,this.size.yLine=n+.5*(1-this.lineCount)*this.fontOptions.size,"hanging"===s&&(this.size.top+=.5*this.fontOptions.size,this.size.top+=4,this.size.yLine+=4)}},{key:"getFormattingValues",value:function(t,e,i,o){var n=function(t,e,i){return"normal"===e?"mod"===i?"":t[i]:void 0!==t[e][i]?t[e][i]:t[i]},s={color:n(this.fontOptions,o,"color"),size:n(this.fontOptions,o,"size"),face:n(this.fontOptions,o,"face"),mod:n(this.fontOptions,o,"mod"),vadjust:n(this.fontOptions,o,"vadjust"),strokeWidth:this.fontOptions.strokeWidth,strokeColor:this.fontOptions.strokeColor};(e||i)&&("normal"===o&&!0===this.fontOptions.chooser&&this.elementOptions.labelHighlightBold?s.mod="bold":"function"==typeof this.fontOptions.chooser&&this.fontOptions.chooser(s,this.elementOptions.id,e,i));var r="";return void 0!==s.mod&&""!==s.mod&&(r+=s.mod+" "),r+=s.size+"px "+s.face,t.font=r.replace(/"/g,""),s.font=t.font,s.height=s.size,s}},{key:"differentState",value:function(t,e){return t!==this.selectedState||e!==this.hoverState}},{key:"_processLabelText",value:function(t,e,i,o){return new f(t,this,e,i).process(o)}},{key:"_processLabel",value:function(t,e,i){if(!1!==this.labelDirty||this.differentState(e,i)){var o=this._processLabelText(t,e,i,this.elementOptions.label);this.fontOptions.minWdt>0&&o.width<this.fontOptions.minWdt&&(o.width=this.fontOptions.minWdt),this.size.labelHeight=o.height,this.fontOptions.minHgt>0&&o.height<this.fontOptions.minHgt&&(o.height=this.fontOptions.minHgt),this.lines=o.lines,this.lineCount=o.lines.length,this.size.width=o.width,this.size.height=o.height,this.selectedState=e,this.hoverState=i,this.labelDirty=!1}}},{key:"visible",value:function(){return 0!==this.size.width&&0!==this.size.height&&void 0!==this.elementOptions.label&&!(this.fontOptions.size*this.body.view.scale<this.elementOptions.scaling.label.drawThreshold-1)}}],[{key:"parseFontString",value:function(t,e){if(!e||"string"!=typeof e)return!1;var i=e.split(" ");return t.size=i[0].replace("px",""),t.face=i[1],t.color=i[2],!0}}]),t}();e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(30),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(2),u=i(119).default,c=function(){function t(e,i,o){(0,a.default)(this,t),this.body=i,this.labelModule=o,this.options={},this.setOptions(e),this.colorDirty=!0,this.color={},this.selectionWidth=2,this.hoverWidth=1.5,this.fromPoint=this.from,this.toPoint=this.to}return(0,d.default)(t,[{key:"connect",value:function(){this.from=this.body.nodes[this.options.from],this.to=this.body.nodes[this.options.to]}},{key:"cleanup",value:function(){return!1}},{key:"setOptions",value:function(t){this.options=t,this.from=this.body.nodes[this.options.from],this.to=this.body.nodes[this.options.to],this.id=this.options.id}},{key:"drawLine",value:function(t,e,i,o,n){t.strokeStyle=this.getColor(t,e,i,o),t.lineWidth=e.width,!1!==e.dashes?this._drawDashedLine(t,e,n):this._drawLine(t,e,n)}},{key:"_drawLine",value:function(t,e,i,o,n){if(this.from!=this.to)this._line(t,e,i,o,n);else{var r=this._getCircleData(t),a=(0,s.default)(r,3),h=a[0],d=a[1],l=a[2];this._circle(t,e,h,d,l)}}},{key:"_drawDashedLine",value:function(t,e,i,o,n){t.lineCap="round";var r=[5,5];if(!0===Array.isArray(e.dashes)&&(r=e.dashes),void 0!==t.setLineDash){if(t.save(),t.setLineDash(r),t.lineDashOffset=0,this.from!=this.to)this._line(t,e,i);else{var a=this._getCircleData(t),h=(0,s.default)(a,3),d=h[0],l=h[1],u=h[2];this._circle(t,e,d,l,u)}t.setLineDash([0]),t.lineDashOffset=0,t.restore()}else{if(this.from!=this.to)t.dashedLine(this.from.x,this.from.y,this.to.x,this.to.y,r);else{var c=this._getCircleData(t),p=(0,s.default)(c,3),f=p[0],m=p[1],v=p[2];this._circle(t,e,f,m,v)}this.enableShadow(t,e),t.stroke(),this.disableShadow(t,e)}}},{key:"findBorderPosition",value:function(t,e,i){return this.from!=this.to?this._findBorderPosition(t,e,i):this._findBorderPositionCircle(t,e,i)}},{key:"findBorderPositions",value:function(t){var e={},i={};if(this.from!=this.to)e=this._findBorderPosition(this.from,t),i=this._findBorderPosition(this.to,t);else{var o=this._getCircleData(t).slice(0,2),n=(0,s.default)(o,2),r=n[0],a=n[1];e=this._findBorderPositionCircle(this.from,t,{x:r,y:a,low:.25,high:.6,direction:-1}),i=this._findBorderPositionCircle(this.from,t,{x:r,y:a,low:.6,high:.8,direction:1})}return{from:e,to:i}}},{key:"_getCircleData",value:function(t){var e=void 0,i=void 0,o=this.from,n=this.options.selfReferenceSize;return void 0!==t&&void 0===o.shape.width&&o.shape.resize(t),o.shape.width>o.shape.height?(e=o.x+.5*o.shape.width,i=o.y-n):(e=o.x+n,i=o.y-.5*o.shape.height),[e,i,n]}},{key:"_pointOnCircle",value:function(t,e,i,o){var n=2*o*Math.PI;return{x:t+i*Math.cos(n),y:e-i*Math.sin(n)}}},{key:"_findBorderPositionCircle",value:function(t,e,i){for(var o=i.x,n=i.y,s=i.low,r=i.high,a=i.direction,h=0,d=this.options.selfReferenceSize,l=void 0,u=void 0,c=void 0,p=void 0,f=void 0,m=.5*(s+r);s<=r&&h<10&&(m=.5*(s+r),l=this._pointOnCircle(o,n,d,m),u=Math.atan2(t.y-l.y,t.x-l.x),c=t.distanceToBorder(e,u),p=Math.sqrt(Math.pow(l.x-t.x,2)+Math.pow(l.y-t.y,2)),f=c-p,!(Math.abs(f)<.05));)f>0?a>0?s=m:r=m:a>0?r=m:s=m,h++;return l.t=m,l}},{key:"getLineWidth",value:function(t,e){return!0===t?Math.max(this.selectionWidth,.3/this.body.view.scale):!0===e?Math.max(this.hoverWidth,.3/this.body.view.scale):Math.max(this.options.width,.3/this.body.view.scale)}},{key:"getColor",value:function(t,e,i,o){if(!1!==e.inheritsColor){if("both"===e.inheritsColor&&this.from.id!==this.to.id){var n=t.createLinearGradient(this.from.x,this.from.y,this.to.x,this.to.y),s=void 0,r=void 0;return s=this.from.options.color.highlight.border,r=this.to.options.color.highlight.border,!1===this.from.selected&&!1===this.to.selected?(s=l.overrideOpacity(this.from.options.color.border,e.opacity),r=l.overrideOpacity(this.to.options.color.border,e.opacity)):!0===this.from.selected&&!1===this.to.selected?r=this.to.options.color.border:!1===this.from.selected&&!0===this.to.selected&&(s=this.from.options.color.border),n.addColorStop(0,s),n.addColorStop(1,r),n}return"to"===e.inheritsColor?l.overrideOpacity(this.to.options.color.border,e.opacity):l.overrideOpacity(this.from.options.color.border,e.opacity)}return l.overrideOpacity(e.color,e.opacity)}},{key:"_circle", +value:function(t,e,i,o,n){this.enableShadow(t,e),t.beginPath(),t.arc(i,o,n,0,2*Math.PI,!1),t.stroke(),this.disableShadow(t,e)}},{key:"getDistanceToEdge",value:function(t,e,i,o,n,r,a,h){var d=0;if(this.from!=this.to)d=this._getDistanceToEdge(t,e,i,o,n,r,a);else{var l=this._getCircleData(void 0),u=(0,s.default)(l,3),c=u[0],p=u[1],f=u[2],m=c-n,v=p-r;d=Math.abs(Math.sqrt(m*m+v*v)-f)}return d}},{key:"_getDistanceToLine",value:function(t,e,i,o,n,s){var r=i-t,a=o-e,h=r*r+a*a,d=((n-t)*r+(s-e)*a)/h;d>1?d=1:d<0&&(d=0);var l=t+d*r,u=e+d*a,c=l-n,p=u-s;return Math.sqrt(c*c+p*p)}},{key:"getArrowData",value:function(t,e,i,o,n,r){var a=void 0,h=void 0,d=void 0,l=void 0,u=void 0,c=void 0,p=void 0,f=r.width;if("from"===e?(d=this.from,l=this.to,u=.1,c=r.fromArrowScale,p=r.fromArrowType):"to"===e?(d=this.to,l=this.from,u=-.1,c=r.toArrowScale,p=r.toArrowType):(d=this.to,l=this.from,c=r.middleArrowScale,p=r.middleArrowType),d!=l)if("middle"!==e)if(!0===this.options.smooth.enabled){h=this.findBorderPosition(d,t,{via:i});var m=this.getPoint(Math.max(0,Math.min(1,h.t+u)),i);a=Math.atan2(h.y-m.y,h.x-m.x)}else a=Math.atan2(d.y-l.y,d.x-l.x),h=this.findBorderPosition(d,t);else a=Math.atan2(d.y-l.y,d.x-l.x),h=this.getPoint(.5,i);else{var v=this._getCircleData(t),g=(0,s.default)(v,3),y=g[0],b=g[1],_=g[2];"from"===e?(h=this.findBorderPosition(this.from,t,{x:y,y:b,low:.25,high:.6,direction:-1}),a=-2*h.t*Math.PI+1.5*Math.PI+.1*Math.PI):"to"===e?(h=this.findBorderPosition(this.from,t,{x:y,y:b,low:.6,high:1,direction:1}),a=-2*h.t*Math.PI+1.5*Math.PI-1.1*Math.PI):(h=this._pointOnCircle(y,b,_,.175),a=3.9269908169872414)}"middle"===e&&c<0&&(f*=-1);var w=15*c+3*f;return{point:h,core:{x:h.x-.9*w*Math.cos(a),y:h.y-.9*w*Math.sin(a)},angle:a,length:w,type:p}}},{key:"drawArrowHead",value:function(t,e,i,o,n){t.strokeStyle=this.getColor(t,e,i,o),t.fillStyle=t.strokeStyle,t.lineWidth=e.width,u.draw(t,n),this.enableShadow(t,e),t.fill(),this.disableShadow(t,e)}},{key:"enableShadow",value:function(t,e){!0===e.shadow&&(t.shadowColor=e.shadowColor,t.shadowBlur=e.shadowSize,t.shadowOffsetX=e.shadowX,t.shadowOffsetY=e.shadowY)}},{key:"disableShadow",value:function(t,e){!0===e.shadow&&(t.shadowColor="rgba(0,0,0,0)",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0)}}]),t}();e.default=c},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(4),a=o(r),h=i(5),d=o(h),l=i(0),u=o(l),c=i(1),p=o(c),f=function(){function t(){(0,u.default)(this,t)}return(0,p.default)(t,null,[{key:"transform",value:function(t,e){t instanceof Array||(t=[t]);for(var i=e.point.x,o=e.point.y,n=e.angle,s=e.length,r=0;r<t.length;++r){var a=t[r],h=a.x*Math.cos(n)-a.y*Math.sin(n),d=a.x*Math.sin(n)+a.y*Math.cos(n);a.x=i+s*h,a.y=o+s*d}}},{key:"drawPath",value:function(t,e){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(var i=1;i<e.length;++i)t.lineTo(e[i].x,e[i].y);t.closePath()}}]),t}(),m=function(t){function e(){return(0,u.default)(this,e),(0,a.default)(this,(e.__proto__||(0,s.default)(e)).apply(this,arguments))}return(0,d.default)(e,t),(0,p.default)(e,null,[{key:"draw",value:function(t,e){var i=[{x:0,y:0},{x:-1,y:.3},{x:-.9,y:0},{x:-1,y:-.3}];f.transform(i,e),f.drawPath(t,i)}}]),e}(f),v=function(){function t(){(0,u.default)(this,t)}return(0,p.default)(t,null,[{key:"draw",value:function(t,e){var i={x:-.4,y:0};f.transform(i,e),t.circle(i.x,i.y,.4*e.length)}}]),t}(),g=function(){function t(){(0,u.default)(this,t)}return(0,p.default)(t,null,[{key:"draw",value:function(t,e){var i=[{x:0,y:.5},{x:0,y:-.5},{x:-.15,y:-.5},{x:-.15,y:.5}];f.transform(i,e),f.drawPath(t,i)}}]),t}(),y=function(){function t(){(0,u.default)(this,t)}return(0,p.default)(t,null,[{key:"draw",value:function(t,e){var i;switch(e.type&&(i=e.type.toLowerCase()),i){case"circle":v.draw(t,e);break;case"bar":g.draw(t,e);break;case"arrow":default:m.draw(t,e)}}}]),t}();e.default=y},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=function(){function t(e,i,o){(0,s.default)(this,t),this.body=e,this.physicsBody=i,this.barnesHutTree,this.setOptions(o),this.randomSeed=5}return(0,a.default)(t,[{key:"setOptions",value:function(t){this.options=t,this.thetaInversed=1/this.options.theta,this.overlapAvoidanceFactor=1-Math.max(0,Math.min(1,this.options.avoidOverlap))}},{key:"seededRandom",value:function(){var t=1e4*Math.sin(this.randomSeed++);return t-Math.floor(t)}},{key:"solve",value:function(){if(0!==this.options.gravitationalConstant&&this.physicsBody.physicsNodeIndices.length>0){var t=void 0,e=this.body.nodes,i=this.physicsBody.physicsNodeIndices,o=i.length,n=this._formBarnesHutTree(e,i);this.barnesHutTree=n;for(var s=0;s<o;s++)t=e[i[s]],t.options.mass>0&&this._getForceContributions(n.root,t)}}},{key:"_getForceContributions",value:function(t,e){this._getForceContribution(t.children.NW,e),this._getForceContribution(t.children.NE,e),this._getForceContribution(t.children.SW,e),this._getForceContribution(t.children.SE,e)}},{key:"_getForceContribution",value:function(t,e){if(t.childrenCount>0){var i=void 0,o=void 0,n=void 0;i=t.centerOfMass.x-e.x,o=t.centerOfMass.y-e.y,n=Math.sqrt(i*i+o*o),n*t.calcSize>this.thetaInversed?this._calculateForces(n,i,o,e,t):4===t.childrenCount?this._getForceContributions(t,e):t.children.data.id!=e.id&&this._calculateForces(n,i,o,e,t)}}},{key:"_calculateForces",value:function(t,e,i,o,n){0===t&&(t=.1,e=t),this.overlapAvoidanceFactor<1&&o.shape.radius&&(t=Math.max(.1+this.overlapAvoidanceFactor*o.shape.radius,t-o.shape.radius));var s=this.options.gravitationalConstant*n.mass*o.options.mass/Math.pow(t,3),r=e*s,a=i*s;this.physicsBody.forces[o.id].x+=r,this.physicsBody.forces[o.id].y+=a}},{key:"_formBarnesHutTree",value:function(t,e){for(var i=void 0,o=e.length,n=t[e[0]].x,s=t[e[0]].y,r=t[e[0]].x,a=t[e[0]].y,h=1;h<o;h++){var d=t[e[h]],l=d.x,u=d.y;d.options.mass>0&&(l<n&&(n=l),l>r&&(r=l),u<s&&(s=u),u>a&&(a=u))}var c=Math.abs(r-n)-Math.abs(a-s);c>0?(s-=.5*c,a+=.5*c):(n+=.5*c,r-=.5*c);var p=Math.max(1e-5,Math.abs(r-n)),f=.5*p,m=.5*(n+r),v=.5*(s+a),g={root:{centerOfMass:{x:0,y:0},mass:0,range:{minX:m-f,maxX:m+f,minY:v-f,maxY:v+f},size:p,calcSize:1/p,children:{data:null},maxWidth:0,level:0,childrenCount:4}};this._splitBranch(g.root);for(var y=0;y<o;y++)i=t[e[y]],i.options.mass>0&&this._placeInTree(g.root,i);return g}},{key:"_updateBranchMass",value:function(t,e){var i=t.centerOfMass,o=t.mass+e.options.mass,n=1/o;i.x=i.x*t.mass+e.x*e.options.mass,i.x*=n,i.y=i.y*t.mass+e.y*e.options.mass,i.y*=n,t.mass=o;var s=Math.max(Math.max(e.height,e.radius),e.width);t.maxWidth=t.maxWidth<s?s:t.maxWidth}},{key:"_placeInTree",value:function(t,e,i){1==i&&void 0!==i||this._updateBranchMass(t,e);var o=t.children.NW.range,n=void 0;n=o.maxX>e.x?o.maxY>e.y?"NW":"SW":o.maxY>e.y?"NE":"SE",this._placeInRegion(t,e,n)}},{key:"_placeInRegion",value:function(t,e,i){var o=t.children[i];switch(o.childrenCount){case 0:o.children.data=e,o.childrenCount=1,this._updateBranchMass(o,e);break;case 1:o.children.data.x===e.x&&o.children.data.y===e.y?(e.x+=this.seededRandom(),e.y+=this.seededRandom()):(this._splitBranch(o),this._placeInTree(o,e));break;case 4:this._placeInTree(o,e)}}},{key:"_splitBranch",value:function(t){var e=null;1===t.childrenCount&&(e=t.children.data,t.mass=0,t.centerOfMass.x=0,t.centerOfMass.y=0),t.childrenCount=4,t.children.data=null,this._insertRegion(t,"NW"),this._insertRegion(t,"NE"),this._insertRegion(t,"SW"),this._insertRegion(t,"SE"),null!=e&&this._placeInTree(t,e)}},{key:"_insertRegion",value:function(t,e){var i=void 0,o=void 0,n=void 0,s=void 0,r=.5*t.size;switch(e){case"NW":i=t.range.minX,o=t.range.minX+r,n=t.range.minY,s=t.range.minY+r;break;case"NE":i=t.range.minX+r,o=t.range.maxX,n=t.range.minY,s=t.range.minY+r;break;case"SW":i=t.range.minX,o=t.range.minX+r,n=t.range.minY+r,s=t.range.maxY;break;case"SE":i=t.range.minX+r,o=t.range.maxX,n=t.range.minY+r,s=t.range.maxY}t.children[e]={centerOfMass:{x:0,y:0},mass:0,range:{minX:i,maxX:o,minY:n,maxY:s},size:.5*t.size,calcSize:2*t.calcSize,children:{data:null},maxWidth:0,level:t.level+1,childrenCount:0}}},{key:"_debug",value:function(t,e){void 0!==this.barnesHutTree&&(t.lineWidth=1,this._drawBranch(this.barnesHutTree.root,t,e))}},{key:"_drawBranch",value:function(t,e,i){void 0===i&&(i="#FF0000"),4===t.childrenCount&&(this._drawBranch(t.children.NW,e),this._drawBranch(t.children.NE,e),this._drawBranch(t.children.SE,e),this._drawBranch(t.children.SW,e)),e.strokeStyle=i,e.beginPath(),e.moveTo(t.range.minX,t.range.minY),e.lineTo(t.range.maxX,t.range.minY),e.stroke(),e.beginPath(),e.moveTo(t.range.maxX,t.range.minY),e.lineTo(t.range.maxX,t.range.maxY),e.stroke(),e.beginPath(),e.moveTo(t.range.maxX,t.range.maxY),e.lineTo(t.range.minX,t.range.maxY),e.stroke(),e.beginPath(),e.moveTo(t.range.minX,t.range.maxY),e.lineTo(t.range.minX,t.range.minY),e.stroke()}}]),t}();e.default=h},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=function(){function t(e,i,o){(0,s.default)(this,t),this.body=e,this.physicsBody=i,this.setOptions(o)}return(0,a.default)(t,[{key:"setOptions",value:function(t){this.options=t}},{key:"solve",value:function(){for(var t=void 0,e=void 0,i=void 0,o=void 0,n=this.body.nodes,s=this.physicsBody.physicsNodeIndices,r=this.physicsBody.forces,a=0;a<s.length;a++){o=n[s[a]],t=-o.x,e=-o.y,i=Math.sqrt(t*t+e*e),this._calculateForces(i,t,e,r,o)}}},{key:"_calculateForces",value:function(t,e,i,o,n){var s=0===t?0:this.options.centralGravity/t;o[n.id].x=e*s,o[n.id].y=i*s}}]),t}();e.default=h},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var o="string",n="boolean",s="number",r="object",a=["arrow","circle","bar"],h={configure:{enabled:{boolean:n},filter:{boolean:n,string:o,array:"array",function:"function"},container:{dom:"dom"},showButton:{boolean:n},__type__:{object:r,boolean:n,string:o,array:"array",function:"function"}},edges:{arrows:{to:{enabled:{boolean:n},scaleFactor:{number:s},type:{string:a},__type__:{object:r,boolean:n}},middle:{enabled:{boolean:n},scaleFactor:{number:s},type:{string:a},__type__:{object:r,boolean:n}},from:{enabled:{boolean:n},scaleFactor:{number:s},type:{string:a},__type__:{object:r,boolean:n}},__type__:{string:["from","to","middle"],object:r}},arrowStrikethrough:{boolean:n},chosen:{label:{boolean:n,function:"function"},edge:{boolean:n,function:"function"},__type__:{object:r,boolean:n}},color:{color:{string:o},highlight:{string:o},hover:{string:o},inherit:{string:["from","to","both"],boolean:n},opacity:{number:s},__type__:{object:r,string:o}},dashes:{boolean:n,array:"array"},font:{color:{string:o},size:{number:s},face:{string:o},background:{string:o},strokeWidth:{number:s},strokeColor:{string:o},align:{string:["horizontal","top","middle","bottom"]},vadjust:{number:s},multi:{boolean:n,string:o},bold:{color:{string:o},size:{number:s},face:{string:o},mod:{string:o},vadjust:{number:s},__type__:{object:r,string:o}},boldital:{color:{string:o},size:{number:s},face:{string:o},mod:{string:o},vadjust:{number:s},__type__:{object:r,string:o}},ital:{color:{string:o},size:{number:s},face:{string:o},mod:{string:o},vadjust:{number:s},__type__:{object:r,string:o}},mono:{color:{string:o},size:{number:s},face:{string:o},mod:{string:o},vadjust:{number:s},__type__:{object:r,string:o}},__type__:{object:r,string:o}},hidden:{boolean:n},hoverWidth:{function:"function",number:s},label:{string:o,undefined:"undefined"},labelHighlightBold:{boolean:n},length:{number:s,undefined:"undefined"},physics:{boolean:n},scaling:{min:{number:s},max:{number:s},label:{enabled:{boolean:n},min:{number:s},max:{number:s},maxVisible:{number:s},drawThreshold:{number:s},__type__:{object:r,boolean:n}},customScalingFunction:{function:"function"},__type__:{object:r}},selectionWidth:{function:"function",number:s},selfReferenceSize:{number:s},shadow:{enabled:{boolean:n},color:{string:o},size:{number:s},x:{number:s},y:{number:s},__type__:{object:r,boolean:n}},smooth:{enabled:{boolean:n},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:s},forceDirection:{string:["horizontal","vertical","none"],boolean:n},__type__:{object:r,boolean:n}},title:{string:o,undefined:"undefined"},width:{number:s},widthConstraint:{maximum:{number:s},__type__:{object:r,boolean:n,number:s}},value:{number:s,undefined:"undefined"},__type__:{object:r}},groups:{useDefaultGroups:{boolean:n},__any__:"get from nodes, will be overwritten below",__type__:{object:r}},interaction:{dragNodes:{boolean:n},dragView:{boolean:n},hideEdgesOnDrag:{boolean:n},hideNodesOnDrag:{boolean:n},hover:{boolean:n},keyboard:{enabled:{boolean:n},speed:{x:{number:s},y:{number:s},zoom:{number:s},__type__:{object:r}},bindToWindow:{boolean:n},__type__:{object:r,boolean:n}},multiselect:{boolean:n},navigationButtons:{boolean:n},selectable:{boolean:n},selectConnectedEdges:{boolean:n},hoverConnectedEdges:{boolean:n},tooltipDelay:{number:s},zoomView:{boolean:n},__type__:{object:r}},layout:{randomSeed:{undefined:"undefined",number:s},improvedLayout:{boolean:n},hierarchical:{enabled:{boolean:n},levelSeparation:{number:s},nodeSpacing:{number:s},treeSpacing:{number:s},blockShifting:{boolean:n},edgeMinimization:{boolean:n},parentCentralization:{boolean:n},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},__type__:{object:r,boolean:n}},__type__:{object:r}},manipulation:{enabled:{boolean:n},initiallyActive:{boolean:n},addNode:{boolean:n,function:"function"},addEdge:{boolean:n,function:"function"},editNode:{function:"function"},editEdge:{editWithoutDrag:{function:"function"},__type__:{object:r,boolean:n,function:"function"}},deleteNode:{boolean:n,function:"function"},deleteEdge:{boolean:n,function:"function"},controlNodeStyle:"get from nodes, will be overwritten below",__type__:{object:r,boolean:n}},nodes:{borderWidth:{number:s},borderWidthSelected:{number:s,undefined:"undefined"},brokenImage:{string:o,undefined:"undefined"},chosen:{label:{boolean:n,function:"function"},node:{boolean:n,function:"function"},__type__:{object:r,boolean:n}},color:{border:{string:o},background:{string:o},highlight:{border:{string:o},background:{string:o},__type__:{object:r,string:o}},hover:{border:{string:o},background:{string:o},__type__:{object:r,string:o}},__type__:{object:r,string:o}},fixed:{x:{boolean:n},y:{boolean:n},__type__:{object:r,boolean:n}},font:{align:{string:o},color:{string:o},size:{number:s},face:{string:o},background:{string:o},strokeWidth:{number:s},strokeColor:{string:o},vadjust:{number:s},multi:{boolean:n,string:o},bold:{color:{string:o},size:{number:s},face:{string:o},mod:{string:o},vadjust:{number:s},__type__:{object:r,string:o}},boldital:{color:{string:o},size:{number:s},face:{string:o},mod:{string:o},vadjust:{number:s},__type__:{object:r,string:o}},ital:{color:{string:o},size:{number:s},face:{string:o},mod:{string:o},vadjust:{number:s},__type__:{object:r,string:o}},mono:{color:{string:o},size:{number:s},face:{string:o},mod:{string:o},vadjust:{number:s},__type__:{object:r,string:o}},__type__:{object:r,string:o}},group:{string:o,number:s,undefined:"undefined"},heightConstraint:{minimum:{number:s},valign:{string:o},__type__:{object:r,boolean:n,number:s}},hidden:{boolean:n},icon:{face:{string:o},code:{string:o},size:{number:s},color:{string:o},__type__:{object:r}},id:{string:o,number:s},image:{selected:{string:o,undefined:"undefined"},unselected:{string:o,undefined:"undefined"},__type__:{object:r,string:o}},label:{string:o,undefined:"undefined"},labelHighlightBold:{boolean:n},level:{number:s,undefined:"undefined"},margin:{top:{number:s},right:{number:s},bottom:{number:s},left:{number:s},__type__:{object:r,number:s}},mass:{number:s},physics:{boolean:n},scaling:{min:{number:s},max:{number:s},label:{enabled:{boolean:n},min:{number:s},max:{number:s},maxVisible:{number:s},drawThreshold:{number:s},__type__:{object:r,boolean:n}},customScalingFunction:{function:"function"},__type__:{object:r}},shadow:{enabled:{boolean:n},color:{string:o},size:{number:s},x:{number:s},y:{number:s},__type__:{object:r,boolean:n}},shape:{string:["ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon","hexagon"]},shapeProperties:{borderDashes:{boolean:n,array:"array"},borderRadius:{number:s},interpolation:{boolean:n},useImageSize:{boolean:n},useBorderWithImage:{boolean:n},__type__:{object:r}},size:{number:s},title:{string:o,dom:"dom",undefined:"undefined"},value:{number:s,undefined:"undefined"},widthConstraint:{minimum:{number:s},maximum:{number:s},__type__:{object:r,boolean:n,number:s}},x:{number:s},y:{number:s},__type__:{object:r}},physics:{enabled:{boolean:n},barnesHut:{gravitationalConstant:{number:s},centralGravity:{number:s},springLength:{number:s},springConstant:{number:s},damping:{number:s},avoidOverlap:{number:s},__type__:{object:r}},forceAtlas2Based:{gravitationalConstant:{number:s},centralGravity:{number:s},springLength:{number:s},springConstant:{number:s},damping:{number:s},avoidOverlap:{number:s},__type__:{object:r}},repulsion:{centralGravity:{number:s},springLength:{number:s},springConstant:{number:s},nodeDistance:{number:s},damping:{number:s},__type__:{object:r}},hierarchicalRepulsion:{centralGravity:{number:s},springLength:{number:s},springConstant:{number:s},nodeDistance:{number:s},damping:{number:s},__type__:{object:r}},maxVelocity:{number:s},minVelocity:{number:s},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{boolean:n},iterations:{number:s},updateInterval:{number:s},onlyDynamicEdges:{boolean:n},fit:{boolean:n},__type__:{object:r,boolean:n}},timestep:{number:s},adaptiveTimestep:{boolean:n},__type__:{object:r,boolean:n}},autoResize:{boolean:n},clickToUse:{boolean:n},locale:{string:o},locales:{__any__:{any:"any"},__type__:{object:r}},height:{string:o},width:{string:o},__type__:{object:r}};h.groups.__any__=h.nodes,h.manipulation.controlNodeStyle=h.nodes;var d={nodes:{borderWidth:[1,0,10,1],borderWidthSelected:[2,0,10,1],color:{border:["color","#2B7CE9"],background:["color","#97C2FC"],highlight:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]},hover:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]}},fixed:{x:!1,y:!1},font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[0,0,50,1],strokeColor:["color","#ffffff"]},hidden:!1,labelHighlightBold:!0,physics:!0,scaling:{min:[10,0,200,1],max:[30,0,200,1],label:{enabled:!1,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},shape:["ellipse","box","circle","database","diamond","dot","square","star","text","triangle","triangleDown","hexagon"],shapeProperties:{borderDashes:!1,borderRadius:[6,0,20,1],interpolation:!0,useImageSize:!1},size:[25,0,200,1]},edges:{arrows:{to:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},middle:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},from:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"}},arrowStrikethrough:!0,color:{color:["color","#848484"],highlight:["color","#848484"],hover:["color","#848484"],inherit:["from","to","both",!0,!1],opacity:[1,0,1,.05]},dashes:!1,font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[2,0,50,1],strokeColor:["color","#ffffff"],align:["horizontal","top","middle","bottom"]},hidden:!1,hoverWidth:[1.5,0,5,.1],labelHighlightBold:!0,physics:!0,scaling:{min:[1,0,100,1],max:[15,0,100,1],label:{enabled:!0,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},selectionWidth:[1.5,0,5,.1],selfReferenceSize:[20,0,200,1],shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},smooth:{enabled:!0,type:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"],forceDirection:["horizontal","vertical","none"],roundness:[.5,0,1,.05]},width:[1,0,30,1]},layout:{hierarchical:{enabled:!1,levelSeparation:[150,20,500,5],nodeSpacing:[100,20,500,5],treeSpacing:[200,20,500,5],blockShifting:!0,edgeMinimization:!0,parentCentralization:!0,direction:["UD","DU","LR","RL"],sortMethod:["hubsize","directed"]}},interaction:{dragNodes:!0,dragView:!0,hideEdgesOnDrag:!1,hideNodesOnDrag:!1,hover:!1,keyboard:{enabled:!1,speed:{x:[10,0,40,1],y:[10,0,40,1],zoom:[.02,0,.1,.005]},bindToWindow:!0},multiselect:!1,navigationButtons:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0,tooltipDelay:[300,0,1e3,25],zoomView:!0},manipulation:{enabled:!1,initiallyActive:!1},physics:{enabled:!0,barnesHut:{gravitationalConstant:[-2e3,-3e4,0,50],centralGravity:[.3,0,10,.05],springLength:[95,0,500,5],springConstant:[.04,0,1.2,.005],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},forceAtlas2Based:{gravitationalConstant:[-50,-500,0,1],centralGravity:[.01,0,1,.005],springLength:[95,0,500,5],springConstant:[.08,0,1.2,.005],damping:[.4,0,1,.01],avoidOverlap:[0,0,1,.01]},repulsion:{centralGravity:[.2,0,10,.05],springLength:[200,0,500,5],springConstant:[.05,0,1.2,.005],nodeDistance:[100,0,500,5],damping:[.09,0,1,.01]},hierarchicalRepulsion:{centralGravity:[.2,0,10,.05],springLength:[100,0,500,5],springConstant:[.01,0,1.2,.005],nodeDistance:[120,0,500,5],damping:[.09,0,1,.01]},maxVelocity:[50,0,150,1],minVelocity:[.1,.01,.5,.01],solver:["barnesHut","forceAtlas2Based","repulsion","hierarchicalRepulsion"],timestep:[.5,.01,1,.01]}};e.allOptions=h,e.configureOptions=d},function(t,e,i){var o=i(2);o.extend(e,i(159)),o.extend(e,i(177)),o.extend(e,i(181))},function(t,e,i){i(49),i(60),t.exports=i(136)},function(t,e,i){var o=i(126),n=i(127),s=i(31),r=i(25);t.exports=i(79)(Array,"Array",function(t,e){this._t=r(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,i=this._i++;return!t||i>=t.length?(this._t=void 0,n(1)):"keys"==e?n(0,i):"values"==e?n(0,t[i]):n(0,[i,t[i]])},"values"),s.Arguments=s.Array,o("keys"),o("values"),o("entries")},function(t,e){t.exports=function(){}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,i){var o=i(54),n=i(39),s=i(59),r={};i(26)(r,i(13)("iterator"),function(){return this}),t.exports=function(t,e,i){t.prototype=o(r,{next:n(1,i)}),s(t,e+" Iterator")}},function(t,e,i){var o=i(20),n=i(27),s=i(33);t.exports=i(21)?Object.defineProperties:function(t,e){n(t);for(var i,r=s(e),a=r.length,h=0;a>h;)o.f(t,i=r[h++],e[i]);return t}},function(t,e,i){var o=i(25),n=i(132),s=i(133);t.exports=function(t){return function(e,i,r){var a,h=o(e),d=n(h.length),l=s(r,d);if(t&&i!=i){for(;d>l;)if((a=h[l++])!=a)return!0}else for(;d>l;l++)if((t||l in h)&&h[l]===i)return t||l||0;return!t&&-1}}},function(t,e,i){var o=i(55),n=Math.min;t.exports=function(t){return t>0?n(o(t),9007199254740991):0}},function(t,e,i){var o=i(55),n=Math.max,s=Math.min;t.exports=function(t,e){return t=o(t),t<0?n(t+e,0):s(t,e)}},function(t,e,i){var o=i(18).document;t.exports=o&&o.documentElement},function(t,e,i){var o=i(55),n=i(51);t.exports=function(t){return function(e,i){var s,r,a=String(n(e)),h=o(i),d=a.length;return h<0||h>=d?t?"":void 0:(s=a.charCodeAt(h),s<55296||s>56319||h+1===d||(r=a.charCodeAt(h+1))<56320||r>57343?t?a.charAt(h):s:t?a.slice(h,h+2):r-56320+(s-55296<<10)+65536)}}},function(t,e,i){var o=i(27),n=i(137);t.exports=i(7).getIterator=function(t){var e=n(t);if("function"!=typeof e)throw TypeError(t+" is not iterable!");return o(e.call(t))}},function(t,e,i){var o=i(86),n=i(13)("iterator"),s=i(31);t.exports=i(7).getIteratorMethod=function(t){if(void 0!=t)return t[n]||t["@@iterator"]||s[o(t)]}},function(t,e,i){i(139);var o=i(7).Object;t.exports=function(t,e){return o.create(t,e)}},function(t,e,i){var o=i(17);o(o.S,"Object",{create:i(54)})},function(t,e,i){i(141),t.exports=i(7).Object.keys},function(t,e,i){var o=i(41),n=i(33);i(87)("keys",function(){return function(t){return n(o(t))}})},function(t,e,i){t.exports={default:i(143),__esModule:!0}},function(t,e,i){i(60),i(49),t.exports=i(61).f("iterator")},function(t,e,i){t.exports={default:i(145),__esModule:!0}},function(t,e,i){i(146),i(151),i(152),i(153),t.exports=i(7).Symbol},function(t,e,i){var o=i(18),n=i(22),s=i(21),r=i(17),a=i(83),h=i(147).KEY,d=i(28),l=i(57),u=i(59),c=i(40),p=i(13),f=i(61),m=i(62),v=i(148),g=i(149),y=i(27),b=i(25),_=i(53),w=i(39),x=i(54),k=i(150),S=i(89),D=i(20),M=i(33),C=S.f,O=D.f,E=k.f,T=o.Symbol,P=o.JSON,I=P&&P.stringify,N=p("_hidden"),R=p("toPrimitive"),A={}.propertyIsEnumerable,z=l("symbol-registry"),L=l("symbols"),F=l("op-symbols"),B=Object.prototype,j="function"==typeof T,H=o.QObject,W=!H||!H.prototype||!H.prototype.findChild,Y=s&&d(function(){return 7!=x(O({},"a",{get:function(){return O(this,"a",{value:7}).a}})).a})?function(t,e,i){var o=C(B,e);o&&delete B[e],O(t,e,i),o&&t!==B&&O(B,e,o)}:O,G=function(t){var e=L[t]=x(T.prototype);return e._k=t,e},V=j&&"symbol"==typeof T.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof T},U=function(t,e,i){return t===B&&U(F,e,i),y(t),e=_(e,!0),y(i),n(L,e)?(i.enumerable?(n(t,N)&&t[N][e]&&(t[N][e]=!1),i=x(i,{enumerable:w(0,!1)})):(n(t,N)||O(t,N,w(1,{})),t[N][e]=!0),Y(t,e,i)):O(t,e,i)},q=function(t,e){y(t);for(var i,o=v(e=b(e)),n=0,s=o.length;s>n;)U(t,i=o[n++],e[i]);return t},X=function(t,e){return void 0===e?x(t):q(x(t),e)},Z=function(t){var e=A.call(this,t=_(t,!0));return!(this===B&&n(L,t)&&!n(F,t))&&(!(e||!n(this,t)||!n(L,t)||n(this,N)&&this[N][t])||e)},K=function(t,e){if(t=b(t),e=_(e,!0),t!==B||!n(L,e)||n(F,e)){var i=C(t,e);return!i||!n(L,e)||n(t,N)&&t[N][e]||(i.enumerable=!0),i}},J=function(t){for(var e,i=E(b(t)),o=[],s=0;i.length>s;)n(L,e=i[s++])||e==N||e==h||o.push(e);return o},$=function(t){for(var e,i=t===B,o=E(i?F:b(t)),s=[],r=0;o.length>r;)!n(L,e=o[r++])||i&&!n(B,e)||s.push(L[e]);return s};j||(T=function(){if(this instanceof T)throw TypeError("Symbol is not a constructor!");var t=c(arguments.length>0?arguments[0]:void 0),e=function(i){this===B&&e.call(F,i),n(this,N)&&n(this[N],t)&&(this[N][t]=!1),Y(this,t,w(1,i))};return s&&W&&Y(B,t,{configurable:!0,set:e}),G(t)},a(T.prototype,"toString",function(){return this._k}),S.f=K,D.f=U,i(88).f=k.f=J,i(42).f=Z,i(63).f=$,s&&!i(52)&&a(B,"propertyIsEnumerable",Z,!0),f.f=function(t){return G(p(t))}),r(r.G+r.W+r.F*!j,{Symbol:T});for(var Q="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),tt=0;Q.length>tt;)p(Q[tt++]);for(var et=M(p.store),it=0;et.length>it;)m(et[it++]);r(r.S+r.F*!j,"Symbol",{for:function(t){return n(z,t+="")?z[t]:z[t]=T(t)},keyFor:function(t){if(!V(t))throw TypeError(t+" is not a symbol!");for(var e in z)if(z[e]===t)return e},useSetter:function(){W=!0},useSimple:function(){W=!1}}),r(r.S+r.F*!j,"Object",{create:X,defineProperty:U,defineProperties:q,getOwnPropertyDescriptor:K,getOwnPropertyNames:J,getOwnPropertySymbols:$}),P&&r(r.S+r.F*(!j||d(function(){var t=T();return"[null]"!=I([t])||"{}"!=I({a:t})||"{}"!=I(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!V(t)){for(var e,i,o=[t],n=1;arguments.length>n;)o.push(arguments[n++]);return e=o[1],"function"==typeof e&&(i=e),!i&&g(e)||(e=function(t,e){if(i&&(e=i.call(this,t,e)),!V(e))return e}),o[1]=e,I.apply(P,o)}}}),T.prototype[R]||i(26)(T.prototype,R,T.prototype.valueOf),u(T,"Symbol"),u(Math,"Math",!0),u(o.JSON,"JSON",!0)},function(t,e,i){var o=i(40)("meta"),n=i(32),s=i(22),r=i(20).f,a=0,h=Object.isExtensible||function(){return!0},d=!i(28)(function(){return h(Object.preventExtensions({}))}),l=function(t){r(t,o,{value:{i:"O"+ ++a,w:{}}})},u=function(t,e){if(!n(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!s(t,o)){if(!h(t))return"F";if(!e)return"E";l(t)}return t[o].i},c=function(t,e){if(!s(t,o)){if(!h(t))return!0;if(!e)return!1;l(t)}return t[o].w},p=function(t){return d&&f.NEED&&h(t)&&!s(t,o)&&l(t),t},f=t.exports={KEY:o,NEED:!1,fastKey:u,getWeak:c,onFreeze:p}},function(t,e,i){var o=i(33),n=i(63),s=i(42);t.exports=function(t){var e=o(t),i=n.f;if(i)for(var r,a=i(t),h=s.f,d=0;a.length>d;)h.call(t,r=a[d++])&&e.push(r);return e}},function(t,e,i){var o=i(50);t.exports=Array.isArray||function(t){return"Array"==o(t)}},function(t,e,i){var o=i(25),n=i(88).f,s={}.toString,r="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],a=function(t){try{return n(t)}catch(t){return r.slice()}};t.exports.f=function(t){return r&&"[object Window]"==s.call(t)?a(t):n(o(t))}},function(t,e){},function(t,e,i){i(62)("asyncIterator")},function(t,e,i){i(62)("observable")},function(t,e,i){(function(t){!function(e,i){t.exports=i()}(0,function(){function e(){return Co.apply(null,arguments)}function i(t){return t instanceof Array||"[object Array]"===Object.prototype.toString.call(t)}function o(t){return null!=t&&"[object Object]"===Object.prototype.toString.call(t)}function n(t){if(Object.getOwnPropertyNames)return 0===Object.getOwnPropertyNames(t).length;var e;for(e in t)if(t.hasOwnProperty(e))return!1;return!0}function s(t){return void 0===t}function r(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)}function a(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function h(t,e){var i,o=[];for(i=0;i<t.length;++i)o.push(e(t[i],i));return o}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function l(t,e){for(var i in e)d(e,i)&&(t[i]=e[i]);return d(e,"toString")&&(t.toString=e.toString),d(e,"valueOf")&&(t.valueOf=e.valueOf),t}function u(t,e,i,o){return Se(t,e,i,o,!0).utc()}function c(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function p(t){return null==t._pf&&(t._pf=c()),t._pf}function f(t){if(null==t._isValid){var e=p(t),i=Oo.call(e.parsedDateParts,function(t){return null!=t}),o=!isNaN(t._d.getTime())&&e.overflow<0&&!e.empty&&!e.invalidMonth&&!e.invalidWeekday&&!e.weekdayMismatch&&!e.nullInput&&!e.invalidFormat&&!e.userInvalidated&&(!e.meridiem||e.meridiem&&i);if(t._strict&&(o=o&&0===e.charsLeftOver&&0===e.unusedTokens.length&&void 0===e.bigHour),null!=Object.isFrozen&&Object.isFrozen(t))return o;t._isValid=o}return t._isValid}function m(t){var e=u(NaN);return null!=t?l(p(e),t):p(e).userInvalidated=!0,e}function v(t,e){var i,o,n;if(s(e._isAMomentObject)||(t._isAMomentObject=e._isAMomentObject),s(e._i)||(t._i=e._i),s(e._f)||(t._f=e._f),s(e._l)||(t._l=e._l),s(e._strict)||(t._strict=e._strict),s(e._tzm)||(t._tzm=e._tzm),s(e._isUTC)||(t._isUTC=e._isUTC),s(e._offset)||(t._offset=e._offset),s(e._pf)||(t._pf=p(e)),s(e._locale)||(t._locale=e._locale),Eo.length>0)for(i=0;i<Eo.length;i++)o=Eo[i],n=e[o],s(n)||(t[o]=n);return t}function g(t){v(this,t),this._d=new Date(null!=t._d?t._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),!1===To&&(To=!0,e.updateOffset(this),To=!1)}function y(t){return t instanceof g||null!=t&&null!=t._isAMomentObject}function b(t){return t<0?Math.ceil(t)||0:Math.floor(t)}function _(t){var e=+t,i=0;return 0!==e&&isFinite(e)&&(i=b(e)),i}function w(t,e,i){var o,n=Math.min(t.length,e.length),s=Math.abs(t.length-e.length),r=0;for(o=0;o<n;o++)(i&&t[o]!==e[o]||!i&&_(t[o])!==_(e[o]))&&r++;return r+s}function x(t){!1===e.suppressDeprecationWarnings&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function k(t,i){var o=!0;return l(function(){if(null!=e.deprecationHandler&&e.deprecationHandler(null,t),o){for(var n,s=[],r=0;r<arguments.length;r++){if(n="","object"==typeof arguments[r]){n+="\n["+r+"] " +;for(var a in arguments[0])n+=a+": "+arguments[0][a]+", ";n=n.slice(0,-2)}else n=arguments[r];s.push(n)}x(t+"\nArguments: "+Array.prototype.slice.call(s).join("")+"\n"+(new Error).stack),o=!1}return i.apply(this,arguments)},i)}function S(t,i){null!=e.deprecationHandler&&e.deprecationHandler(t,i),Po[t]||(x(i),Po[t]=!0)}function D(t){return t instanceof Function||"[object Function]"===Object.prototype.toString.call(t)}function M(t){var e,i;for(i in t)e=t[i],D(e)?this[i]=e:this["_"+i]=e;this._config=t,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function C(t,e){var i,n=l({},t);for(i in e)d(e,i)&&(o(t[i])&&o(e[i])?(n[i]={},l(n[i],t[i]),l(n[i],e[i])):null!=e[i]?n[i]=e[i]:delete n[i]);for(i in t)d(t,i)&&!d(e,i)&&o(t[i])&&(n[i]=l({},n[i]));return n}function O(t){null!=t&&this.set(t)}function E(t,e,i){var o=this._calendar[t]||this._calendar.sameElse;return D(o)?o.call(e,i):o}function T(t){var e=this._longDateFormat[t],i=this._longDateFormat[t.toUpperCase()];return e||!i?e:(this._longDateFormat[t]=i.replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t])}function P(){return this._invalidDate}function I(t){return this._ordinal.replace("%d",t)}function N(t,e,i,o){var n=this._relativeTime[i];return D(n)?n(t,e,i,o):n.replace(/%d/i,t)}function R(t,e){var i=this._relativeTime[t>0?"future":"past"];return D(i)?i(e):i.replace(/%s/i,e)}function A(t,e){var i=t.toLowerCase();Lo[i]=Lo[i+"s"]=Lo[e]=t}function z(t){return"string"==typeof t?Lo[t]||Lo[t.toLowerCase()]:void 0}function L(t){var e,i,o={};for(i in t)d(t,i)&&(e=z(i))&&(o[e]=t[i]);return o}function F(t,e){Fo[t]=e}function B(t){var e=[];for(var i in t)e.push({unit:i,priority:Fo[i]});return e.sort(function(t,e){return t.priority-e.priority}),e}function j(t,e,i){var o=""+Math.abs(t),n=e-o.length;return(t>=0?i?"+":"":"-")+Math.pow(10,Math.max(0,n)).toString().substr(1)+o}function H(t,e,i,o){var n=o;"string"==typeof o&&(n=function(){return this[o]()}),t&&(Wo[t]=n),e&&(Wo[e[0]]=function(){return j(n.apply(this,arguments),e[1],e[2])}),i&&(Wo[i]=function(){return this.localeData().ordinal(n.apply(this,arguments),t)})}function W(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function Y(t){var e,i,o=t.match(Bo);for(e=0,i=o.length;e<i;e++)Wo[o[e]]?o[e]=Wo[o[e]]:o[e]=W(o[e]);return function(e){var n,s="";for(n=0;n<i;n++)s+=D(o[n])?o[n].call(e,t):o[n];return s}}function G(t,e){return t.isValid()?(e=V(e,t.localeData()),Ho[e]=Ho[e]||Y(e),Ho[e](t)):t.localeData().invalidDate()}function V(t,e){function i(t){return e.longDateFormat(t)||t}var o=5;for(jo.lastIndex=0;o>=0&&jo.test(t);)t=t.replace(jo,i),jo.lastIndex=0,o-=1;return t}function U(t,e,i){an[t]=D(e)?e:function(t,o){return t&&i?i:e}}function q(t,e){return d(an,t)?an[t](e._strict,e._locale):new RegExp(X(t))}function X(t){return Z(t.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,i,o,n){return e||i||o||n}))}function Z(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function K(t,e){var i,o=e;for("string"==typeof t&&(t=[t]),r(e)&&(o=function(t,i){i[e]=_(t)}),i=0;i<t.length;i++)hn[t[i]]=o}function J(t,e){K(t,function(t,i,o,n){o._w=o._w||{},e(t,o._w,o,n)})}function $(t,e,i){null!=e&&d(hn,t)&&hn[t](e,i._a,i,t)}function Q(t){return tt(t)?366:365}function tt(t){return t%4==0&&t%100!=0||t%400==0}function et(){return tt(this.year())}function it(t,i){return function(o){return null!=o?(nt(this,t,o),e.updateOffset(this,i),this):ot(this,t)}}function ot(t,e){return t.isValid()?t._d["get"+(t._isUTC?"UTC":"")+e]():NaN}function nt(t,e,i){t.isValid()&&!isNaN(i)&&("FullYear"===e&&tt(t.year())?t._d["set"+(t._isUTC?"UTC":"")+e](i,t.month(),ht(i,t.month())):t._d["set"+(t._isUTC?"UTC":"")+e](i))}function st(t){return t=z(t),D(this[t])?this[t]():this}function rt(t,e){if("object"==typeof t){t=L(t);for(var i=B(t),o=0;o<i.length;o++)this[i[o].unit](t[i[o].unit])}else if(t=z(t),D(this[t]))return this[t](e);return this}function at(t,e){return(t%e+e)%e}function ht(t,e){if(isNaN(t)||isNaN(e))return NaN;var i=at(e,12);return t+=(e-i)/12,1===i?tt(t)?29:28:31-i%7%2}function dt(t,e){return t?i(this._months)?this._months[t.month()]:this._months[(this._months.isFormat||_n).test(e)?"format":"standalone"][t.month()]:i(this._months)?this._months:this._months.standalone}function lt(t,e){return t?i(this._monthsShort)?this._monthsShort[t.month()]:this._monthsShort[_n.test(e)?"format":"standalone"][t.month()]:i(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function ut(t,e,i){var o,n,s,r=t.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],o=0;o<12;++o)s=u([2e3,o]),this._shortMonthsParse[o]=this.monthsShort(s,"").toLocaleLowerCase(),this._longMonthsParse[o]=this.months(s,"").toLocaleLowerCase();return i?"MMM"===e?(n=yn.call(this._shortMonthsParse,r),-1!==n?n:null):(n=yn.call(this._longMonthsParse,r),-1!==n?n:null):"MMM"===e?-1!==(n=yn.call(this._shortMonthsParse,r))?n:(n=yn.call(this._longMonthsParse,r),-1!==n?n:null):-1!==(n=yn.call(this._longMonthsParse,r))?n:(n=yn.call(this._shortMonthsParse,r),-1!==n?n:null)}function ct(t,e,i){var o,n,s;if(this._monthsParseExact)return ut.call(this,t,e,i);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),o=0;o<12;o++){if(n=u([2e3,o]),i&&!this._longMonthsParse[o]&&(this._longMonthsParse[o]=new RegExp("^"+this.months(n,"").replace(".","")+"$","i"),this._shortMonthsParse[o]=new RegExp("^"+this.monthsShort(n,"").replace(".","")+"$","i")),i||this._monthsParse[o]||(s="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[o]=new RegExp(s.replace(".",""),"i")),i&&"MMMM"===e&&this._longMonthsParse[o].test(t))return o;if(i&&"MMM"===e&&this._shortMonthsParse[o].test(t))return o;if(!i&&this._monthsParse[o].test(t))return o}}function pt(t,e){var i;if(!t.isValid())return t;if("string"==typeof e)if(/^\d+$/.test(e))e=_(e);else if(e=t.localeData().monthsParse(e),!r(e))return t;return i=Math.min(t.date(),ht(t.year(),e)),t._d["set"+(t._isUTC?"UTC":"")+"Month"](e,i),t}function ft(t){return null!=t?(pt(this,t),e.updateOffset(this,!0),this):ot(this,"Month")}function mt(){return ht(this.year(),this.month())}function vt(t){return this._monthsParseExact?(d(this,"_monthsRegex")||yt.call(this),t?this._monthsShortStrictRegex:this._monthsShortRegex):(d(this,"_monthsShortRegex")||(this._monthsShortRegex=kn),this._monthsShortStrictRegex&&t?this._monthsShortStrictRegex:this._monthsShortRegex)}function gt(t){return this._monthsParseExact?(d(this,"_monthsRegex")||yt.call(this),t?this._monthsStrictRegex:this._monthsRegex):(d(this,"_monthsRegex")||(this._monthsRegex=Sn),this._monthsStrictRegex&&t?this._monthsStrictRegex:this._monthsRegex)}function yt(){function t(t,e){return e.length-t.length}var e,i,o=[],n=[],s=[];for(e=0;e<12;e++)i=u([2e3,e]),o.push(this.monthsShort(i,"")),n.push(this.months(i,"")),s.push(this.months(i,"")),s.push(this.monthsShort(i,""));for(o.sort(t),n.sort(t),s.sort(t),e=0;e<12;e++)o[e]=Z(o[e]),n[e]=Z(n[e]);for(e=0;e<24;e++)s[e]=Z(s[e]);this._monthsRegex=new RegExp("^("+s.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+o.join("|")+")","i")}function bt(t,e,i,o,n,s,r){var a=new Date(t,e,i,o,n,s,r);return t<100&&t>=0&&isFinite(a.getFullYear())&&a.setFullYear(t),a}function _t(t){var e=new Date(Date.UTC.apply(null,arguments));return t<100&&t>=0&&isFinite(e.getUTCFullYear())&&e.setUTCFullYear(t),e}function wt(t,e,i){var o=7+e-i;return-(7+_t(t,0,o).getUTCDay()-e)%7+o-1}function xt(t,e,i,o,n){var s,r,a=(7+i-o)%7,h=wt(t,o,n),d=1+7*(e-1)+a+h;return d<=0?(s=t-1,r=Q(s)+d):d>Q(t)?(s=t+1,r=d-Q(t)):(s=t,r=d),{year:s,dayOfYear:r}}function kt(t,e,i){var o,n,s=wt(t.year(),e,i),r=Math.floor((t.dayOfYear()-s-1)/7)+1;return r<1?(n=t.year()-1,o=r+St(n,e,i)):r>St(t.year(),e,i)?(o=r-St(t.year(),e,i),n=t.year()+1):(n=t.year(),o=r),{week:o,year:n}}function St(t,e,i){var o=wt(t,e,i),n=wt(t+1,e,i);return(Q(t)-o+n)/7}function Dt(t){return kt(t,this._week.dow,this._week.doy).week}function Mt(){return this._week.dow}function Ct(){return this._week.doy}function Ot(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")}function Et(t){var e=kt(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")}function Tt(t,e){return"string"!=typeof t?t:isNaN(t)?(t=e.weekdaysParse(t),"number"==typeof t?t:null):parseInt(t,10)}function Pt(t,e){return"string"==typeof t?e.weekdaysParse(t)%7||7:isNaN(t)?null:t}function It(t,e){return t?i(this._weekdays)?this._weekdays[t.day()]:this._weekdays[this._weekdays.isFormat.test(e)?"format":"standalone"][t.day()]:i(this._weekdays)?this._weekdays:this._weekdays.standalone}function Nt(t){return t?this._weekdaysShort[t.day()]:this._weekdaysShort}function Rt(t){return t?this._weekdaysMin[t.day()]:this._weekdaysMin}function At(t,e,i){var o,n,s,r=t.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],o=0;o<7;++o)s=u([2e3,1]).day(o),this._minWeekdaysParse[o]=this.weekdaysMin(s,"").toLocaleLowerCase(),this._shortWeekdaysParse[o]=this.weekdaysShort(s,"").toLocaleLowerCase(),this._weekdaysParse[o]=this.weekdays(s,"").toLocaleLowerCase();return i?"dddd"===e?(n=yn.call(this._weekdaysParse,r),-1!==n?n:null):"ddd"===e?(n=yn.call(this._shortWeekdaysParse,r),-1!==n?n:null):(n=yn.call(this._minWeekdaysParse,r),-1!==n?n:null):"dddd"===e?-1!==(n=yn.call(this._weekdaysParse,r))?n:-1!==(n=yn.call(this._shortWeekdaysParse,r))?n:(n=yn.call(this._minWeekdaysParse,r),-1!==n?n:null):"ddd"===e?-1!==(n=yn.call(this._shortWeekdaysParse,r))?n:-1!==(n=yn.call(this._weekdaysParse,r))?n:(n=yn.call(this._minWeekdaysParse,r),-1!==n?n:null):-1!==(n=yn.call(this._minWeekdaysParse,r))?n:-1!==(n=yn.call(this._weekdaysParse,r))?n:(n=yn.call(this._shortWeekdaysParse,r),-1!==n?n:null)}function zt(t,e,i){var o,n,s;if(this._weekdaysParseExact)return At.call(this,t,e,i);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),o=0;o<7;o++){if(n=u([2e3,1]).day(o),i&&!this._fullWeekdaysParse[o]&&(this._fullWeekdaysParse[o]=new RegExp("^"+this.weekdays(n,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[o]=new RegExp("^"+this.weekdaysShort(n,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[o]=new RegExp("^"+this.weekdaysMin(n,"").replace(".",".?")+"$","i")),this._weekdaysParse[o]||(s="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[o]=new RegExp(s.replace(".",""),"i")),i&&"dddd"===e&&this._fullWeekdaysParse[o].test(t))return o;if(i&&"ddd"===e&&this._shortWeekdaysParse[o].test(t))return o;if(i&&"dd"===e&&this._minWeekdaysParse[o].test(t))return o;if(!i&&this._weekdaysParse[o].test(t))return o}}function Lt(t){if(!this.isValid())return null!=t?this:NaN;var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?(t=Tt(t,this.localeData()),this.add(t-e,"d")):e}function Ft(t){if(!this.isValid())return null!=t?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")}function Bt(t){if(!this.isValid())return null!=t?this:NaN;if(null!=t){var e=Pt(t,this.localeData());return this.day(this.day()%7?e:e-7)}return this.day()||7}function jt(t){return this._weekdaysParseExact?(d(this,"_weekdaysRegex")||Yt.call(this),t?this._weekdaysStrictRegex:this._weekdaysRegex):(d(this,"_weekdaysRegex")||(this._weekdaysRegex=En),this._weekdaysStrictRegex&&t?this._weekdaysStrictRegex:this._weekdaysRegex)}function Ht(t){return this._weekdaysParseExact?(d(this,"_weekdaysRegex")||Yt.call(this),t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(d(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=Tn),this._weekdaysShortStrictRegex&&t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Wt(t){return this._weekdaysParseExact?(d(this,"_weekdaysRegex")||Yt.call(this),t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(d(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=Pn),this._weekdaysMinStrictRegex&&t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function Yt(){function t(t,e){return e.length-t.length}var e,i,o,n,s,r=[],a=[],h=[],d=[];for(e=0;e<7;e++)i=u([2e3,1]).day(e),o=this.weekdaysMin(i,""),n=this.weekdaysShort(i,""),s=this.weekdays(i,""),r.push(o),a.push(n),h.push(s),d.push(o),d.push(n),d.push(s);for(r.sort(t),a.sort(t),h.sort(t),d.sort(t),e=0;e<7;e++)a[e]=Z(a[e]),h[e]=Z(h[e]),d[e]=Z(d[e]);this._weekdaysRegex=new RegExp("^("+d.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+h.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+r.join("|")+")","i")}function Gt(){return this.hours()%12||12}function Vt(){return this.hours()||24}function Ut(t,e){H(t,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)})}function qt(t,e){return e._meridiemParse}function Xt(t){return"p"===(t+"").toLowerCase().charAt(0)}function Zt(t,e,i){return t>11?i?"pm":"PM":i?"am":"AM"}function Kt(t){return t?t.toLowerCase().replace("_","-"):t}function Jt(t){for(var e,i,o,n,s=0;s<t.length;){for(n=Kt(t[s]).split("-"),e=n.length,i=Kt(t[s+1]),i=i?i.split("-"):null;e>0;){if(o=$t(n.slice(0,e).join("-")))return o;if(i&&i.length>=e&&w(n,i,!0)>=e-1)break;e--}s++}return null}function $t(e){var i=null;if(!zn[e]&&void 0!==t&&t&&t.exports)try{i=In._abbr;!function(){var t=new Error('Cannot find module "./locale"');throw t.code="MODULE_NOT_FOUND",t}(),Qt(i)}catch(t){}return zn[e]}function Qt(t,e){var i;return t&&(i=s(e)?ie(t):te(t,e))&&(In=i),In._abbr}function te(t,e){if(null!==e){var i=An;if(e.abbr=t,null!=zn[t])S("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),i=zn[t]._config;else if(null!=e.parentLocale){if(null==zn[e.parentLocale])return Ln[e.parentLocale]||(Ln[e.parentLocale]=[]),Ln[e.parentLocale].push({name:t,config:e}),null;i=zn[e.parentLocale]._config}return zn[t]=new O(C(i,e)),Ln[t]&&Ln[t].forEach(function(t){te(t.name,t.config)}),Qt(t),zn[t]}return delete zn[t],null}function ee(t,e){if(null!=e){var i,o=An;null!=zn[t]&&(o=zn[t]._config),e=C(o,e),i=new O(e),i.parentLocale=zn[t],zn[t]=i,Qt(t)}else null!=zn[t]&&(null!=zn[t].parentLocale?zn[t]=zn[t].parentLocale:null!=zn[t]&&delete zn[t]);return zn[t]}function ie(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return In;if(!i(t)){if(e=$t(t))return e;t=[t]}return Jt(t)}function oe(){return Io(zn)}function ne(t){var e,i=t._a;return i&&-2===p(t).overflow&&(e=i[ln]<0||i[ln]>11?ln:i[un]<1||i[un]>ht(i[dn],i[ln])?un:i[cn]<0||i[cn]>24||24===i[cn]&&(0!==i[pn]||0!==i[fn]||0!==i[mn])?cn:i[pn]<0||i[pn]>59?pn:i[fn]<0||i[fn]>59?fn:i[mn]<0||i[mn]>999?mn:-1,p(t)._overflowDayOfYear&&(e<dn||e>un)&&(e=un),p(t)._overflowWeeks&&-1===e&&(e=vn),p(t)._overflowWeekday&&-1===e&&(e=gn),p(t).overflow=e),t}function se(t,e,i){return null!=t?t:null!=e?e:i}function re(t){var i=new Date(e.now());return t._useUTC?[i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()]:[i.getFullYear(),i.getMonth(),i.getDate()]}function ae(t){var e,i,o,n,s=[];if(!t._d){for(o=re(t),t._w&&null==t._a[un]&&null==t._a[ln]&&he(t),null!=t._dayOfYear&&(n=se(t._a[dn],o[dn]),(t._dayOfYear>Q(n)||0===t._dayOfYear)&&(p(t)._overflowDayOfYear=!0),i=_t(n,0,t._dayOfYear),t._a[ln]=i.getUTCMonth(),t._a[un]=i.getUTCDate()),e=0;e<3&&null==t._a[e];++e)t._a[e]=s[e]=o[e];for(;e<7;e++)t._a[e]=s[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[cn]&&0===t._a[pn]&&0===t._a[fn]&&0===t._a[mn]&&(t._nextDay=!0,t._a[cn]=0),t._d=(t._useUTC?_t:bt).apply(null,s),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[cn]=24),t._w&&void 0!==t._w.d&&t._w.d!==t._d.getDay()&&(p(t).weekdayMismatch=!0)}}function he(t){var e,i,o,n,s,r,a,h;if(e=t._w,null!=e.GG||null!=e.W||null!=e.E)s=1,r=4,i=se(e.GG,t._a[dn],kt(De(),1,4).year),o=se(e.W,1),((n=se(e.E,1))<1||n>7)&&(h=!0);else{s=t._locale._week.dow,r=t._locale._week.doy;var d=kt(De(),s,r);i=se(e.gg,t._a[dn],d.year),o=se(e.w,d.week),null!=e.d?((n=e.d)<0||n>6)&&(h=!0):null!=e.e?(n=e.e+s,(e.e<0||e.e>6)&&(h=!0)):n=s}o<1||o>St(i,s,r)?p(t)._overflowWeeks=!0:null!=h?p(t)._overflowWeekday=!0:(a=xt(i,o,n,s,r),t._a[dn]=a.year,t._dayOfYear=a.dayOfYear)}function de(t){var e,i,o,n,s,r,a=t._i,h=Fn.exec(a)||Bn.exec(a);if(h){for(p(t).iso=!0,e=0,i=Hn.length;e<i;e++)if(Hn[e][1].exec(h[1])){n=Hn[e][0],o=!1!==Hn[e][2];break}if(null==n)return void(t._isValid=!1);if(h[3]){for(e=0,i=Wn.length;e<i;e++)if(Wn[e][1].exec(h[3])){s=(h[2]||" ")+Wn[e][0];break}if(null==s)return void(t._isValid=!1)}if(!o&&null!=s)return void(t._isValid=!1);if(h[4]){if(!jn.exec(h[4]))return void(t._isValid=!1);r="Z"}t._f=n+(s||"")+(r||""),ge(t)}else t._isValid=!1}function le(t,e,i,o,n,s){var r=[ue(t),xn.indexOf(e),parseInt(i,10),parseInt(o,10),parseInt(n,10)];return s&&r.push(parseInt(s,10)),r}function ue(t){var e=parseInt(t,10);return e<=49?2e3+e:e<=999?1900+e:e}function ce(t){return t.replace(/\([^)]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}function pe(t,e,i){if(t){if(Cn.indexOf(t)!==new Date(e[0],e[1],e[2]).getDay())return p(i).weekdayMismatch=!0,i._isValid=!1,!1}return!0}function fe(t,e,i){if(t)return Vn[t];if(e)return 0;var o=parseInt(i,10),n=o%100;return(o-n)/100*60+n}function me(t){var e=Gn.exec(ce(t._i));if(e){var i=le(e[4],e[3],e[2],e[5],e[6],e[7]);if(!pe(e[1],i,t))return;t._a=i,t._tzm=fe(e[8],e[9],e[10]),t._d=_t.apply(null,t._a),t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),p(t).rfc2822=!0}else t._isValid=!1}function ve(t){var i=Yn.exec(t._i);if(null!==i)return void(t._d=new Date(+i[1]));de(t),!1===t._isValid&&(delete t._isValid,me(t),!1===t._isValid&&(delete t._isValid,e.createFromInputFallback(t)))}function ge(t){if(t._f===e.ISO_8601)return void de(t);if(t._f===e.RFC_2822)return void me(t);t._a=[],p(t).empty=!0;var i,o,n,s,r,a=""+t._i,h=a.length,d=0;for(n=V(t._f,t._locale).match(Bo)||[],i=0;i<n.length;i++)s=n[i],o=(a.match(q(s,t))||[])[0],o&&(r=a.substr(0,a.indexOf(o)),r.length>0&&p(t).unusedInput.push(r),a=a.slice(a.indexOf(o)+o.length),d+=o.length),Wo[s]?(o?p(t).empty=!1:p(t).unusedTokens.push(s),$(s,o,t)):t._strict&&!o&&p(t).unusedTokens.push(s);p(t).charsLeftOver=h-d,a.length>0&&p(t).unusedInput.push(a),t._a[cn]<=12&&!0===p(t).bigHour&&t._a[cn]>0&&(p(t).bigHour=void 0),p(t).parsedDateParts=t._a.slice(0),p(t).meridiem=t._meridiem,t._a[cn]=ye(t._locale,t._a[cn],t._meridiem),ae(t),ne(t)}function ye(t,e,i){var o;return null==i?e:null!=t.meridiemHour?t.meridiemHour(e,i):null!=t.isPM?(o=t.isPM(i),o&&e<12&&(e+=12),o||12!==e||(e=0),e):e}function be(t){var e,i,o,n,s;if(0===t._f.length)return p(t).invalidFormat=!0,void(t._d=new Date(NaN));for(n=0;n<t._f.length;n++)s=0,e=v({},t),null!=t._useUTC&&(e._useUTC=t._useUTC),e._f=t._f[n],ge(e),f(e)&&(s+=p(e).charsLeftOver,s+=10*p(e).unusedTokens.length,p(e).score=s,(null==o||s<o)&&(o=s,i=e));l(t,i||e)}function _e(t){if(!t._d){var e=L(t._i);t._a=h([e.year,e.month,e.day||e.date,e.hour,e.minute,e.second,e.millisecond],function(t){return t&&parseInt(t,10)}),ae(t)}}function we(t){var e=new g(ne(xe(t)));return e._nextDay&&(e.add(1,"d"),e._nextDay=void 0),e}function xe(t){var e=t._i,o=t._f;return t._locale=t._locale||ie(t._l),null===e||void 0===o&&""===e?m({nullInput:!0}):("string"==typeof e&&(t._i=e=t._locale.preparse(e)),y(e)?new g(ne(e)):(a(e)?t._d=e:i(o)?be(t):o?ge(t):ke(t),f(t)||(t._d=null),t))}function ke(t){var n=t._i;s(n)?t._d=new Date(e.now()):a(n)?t._d=new Date(n.valueOf()):"string"==typeof n?ve(t):i(n)?(t._a=h(n.slice(0),function(t){return parseInt(t,10)}),ae(t)):o(n)?_e(t):r(n)?t._d=new Date(n):e.createFromInputFallback(t)}function Se(t,e,s,r,a){var h={};return!0!==s&&!1!==s||(r=s,s=void 0),(o(t)&&n(t)||i(t)&&0===t.length)&&(t=void 0),h._isAMomentObject=!0,h._useUTC=h._isUTC=a,h._l=s,h._i=t,h._f=e,h._strict=r,we(h)}function De(t,e,i,o){return Se(t,e,i,o,!1)}function Me(t,e){var o,n;if(1===e.length&&i(e[0])&&(e=e[0]),!e.length)return De();for(o=e[0],n=1;n<e.length;++n)e[n].isValid()&&!e[n][t](o)||(o=e[n]);return o}function Ce(){return Me("isBefore",[].slice.call(arguments,0))}function Oe(){return Me("isAfter",[].slice.call(arguments,0))}function Ee(t){for(var e in t)if(-1===yn.call(Zn,e)||null!=t[e]&&isNaN(t[e]))return!1;for(var i=!1,o=0;o<Zn.length;++o)if(t[Zn[o]]){if(i)return!1;parseFloat(t[Zn[o]])!==_(t[Zn[o]])&&(i=!0)}return!0}function Te(){return this._isValid}function Pe(){return Ke(NaN)}function Ie(t){var e=L(t),i=e.year||0,o=e.quarter||0,n=e.month||0,s=e.week||0,r=e.day||0,a=e.hour||0,h=e.minute||0,d=e.second||0,l=e.millisecond||0;this._isValid=Ee(e),this._milliseconds=+l+1e3*d+6e4*h+1e3*a*60*60,this._days=+r+7*s,this._months=+n+3*o+12*i,this._data={},this._locale=ie(),this._bubble()}function Ne(t){return t instanceof Ie}function Re(t){return t<0?-1*Math.round(-1*t):Math.round(t)}function Ae(t,e){H(t,0,0,function(){var t=this.utcOffset(),i="+";return t<0&&(t=-t,i="-"),i+j(~~(t/60),2)+e+j(~~t%60,2)})}function ze(t,e){var i=(e||"").match(t);if(null===i)return null;var o=i[i.length-1]||[],n=(o+"").match(Kn)||["-",0,0],s=60*n[1]+_(n[2]);return 0===s?0:"+"===n[0]?s:-s}function Le(t,i){var o,n;return i._isUTC?(o=i.clone(),n=(y(t)||a(t)?t.valueOf():De(t).valueOf())-o.valueOf(),o._d.setTime(o._d.valueOf()+n),e.updateOffset(o,!1),o):De(t).local()}function Fe(t){return 15*-Math.round(t._d.getTimezoneOffset()/15)}function Be(t,i,o){var n,s=this._offset||0;if(!this.isValid())return null!=t?this:NaN;if(null!=t){if("string"==typeof t){if(null===(t=ze(nn,t)))return this}else Math.abs(t)<16&&!o&&(t*=60);return!this._isUTC&&i&&(n=Fe(this)),this._offset=t,this._isUTC=!0,null!=n&&this.add(n,"m"),s!==t&&(!i||this._changeInProgress?ei(this,Ke(t-s,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,e.updateOffset(this,!0),this._changeInProgress=null)),this}return this._isUTC?s:Fe(this)}function je(t,e){return null!=t?("string"!=typeof t&&(t=-t),this.utcOffset(t,e),this):-this.utcOffset()}function He(t){return this.utcOffset(0,t)}function We(t){return this._isUTC&&(this.utcOffset(0,t),this._isUTC=!1,t&&this.subtract(Fe(this),"m")),this}function Ye(){if(null!=this._tzm)this.utcOffset(this._tzm,!1,!0);else if("string"==typeof this._i){var t=ze(on,this._i);null!=t?this.utcOffset(t):this.utcOffset(0,!0)}return this}function Ge(t){return!!this.isValid()&&(t=t?De(t).utcOffset():0,(this.utcOffset()-t)%60==0)}function Ve(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Ue(){if(!s(this._isDSTShifted))return this._isDSTShifted;var t={};if(v(t,this),t=xe(t),t._a){var e=t._isUTC?u(t._a):De(t._a);this._isDSTShifted=this.isValid()&&w(t._a,e.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted}function qe(){return!!this.isValid()&&!this._isUTC}function Xe(){return!!this.isValid()&&this._isUTC}function Ze(){return!!this.isValid()&&(this._isUTC&&0===this._offset)}function Ke(t,e){var i,o,n,s=t,a=null;return Ne(t)?s={ms:t._milliseconds,d:t._days,M:t._months}:r(t)?(s={},e?s[e]=t:s.milliseconds=t):(a=Jn.exec(t))?(i="-"===a[1]?-1:1,s={y:0,d:_(a[un])*i,h:_(a[cn])*i,m:_(a[pn])*i,s:_(a[fn])*i,ms:_(Re(1e3*a[mn]))*i}):(a=$n.exec(t))?(i="-"===a[1]?-1:(a[1],1),s={y:Je(a[2],i),M:Je(a[3],i),w:Je(a[4],i),d:Je(a[5],i),h:Je(a[6],i),m:Je(a[7],i),s:Je(a[8],i)}):null==s?s={}:"object"==typeof s&&("from"in s||"to"in s)&&(n=Qe(De(s.from),De(s.to)),s={},s.ms=n.milliseconds,s.M=n.months),o=new Ie(s),Ne(t)&&d(t,"_locale")&&(o._locale=t._locale),o}function Je(t,e){var i=t&&parseFloat(t.replace(",","."));return(isNaN(i)?0:i)*e}function $e(t,e){var i={milliseconds:0,months:0};return i.months=e.month()-t.month()+12*(e.year()-t.year()),t.clone().add(i.months,"M").isAfter(e)&&--i.months,i.milliseconds=+e-+t.clone().add(i.months,"M"),i}function Qe(t,e){var i;return t.isValid()&&e.isValid()?(e=Le(e,t),t.isBefore(e)?i=$e(t,e):(i=$e(e,t),i.milliseconds=-i.milliseconds,i.months=-i.months),i):{milliseconds:0,months:0}}function ti(t,e){return function(i,o){var n,s;return null===o||isNaN(+o)||(S(e,"moment()."+e+"(period, number) is deprecated. Please use moment()."+e+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),s=i,i=o,o=s),i="string"==typeof i?+i:i,n=Ke(i,o),ei(this,n,t),this}}function ei(t,i,o,n){var s=i._milliseconds,r=Re(i._days),a=Re(i._months);t.isValid()&&(n=null==n||n,a&&pt(t,ot(t,"Month")+a*o),r&&nt(t,"Date",ot(t,"Date")+r*o),s&&t._d.setTime(t._d.valueOf()+s*o),n&&e.updateOffset(t,r||a))}function ii(t,e){var i=t.diff(e,"days",!0);return i<-6?"sameElse":i<-1?"lastWeek":i<0?"lastDay":i<1?"sameDay":i<2?"nextDay":i<7?"nextWeek":"sameElse"}function oi(t,i){var o=t||De(),n=Le(o,this).startOf("day"),s=e.calendarFormat(this,n)||"sameElse",r=i&&(D(i[s])?i[s].call(this,o):i[s]);return this.format(r||this.localeData().calendar(s,this,De(o)))}function ni(){return new g(this)}function si(t,e){var i=y(t)?t:De(t);return!(!this.isValid()||!i.isValid())&&(e=z(s(e)?"millisecond":e),"millisecond"===e?this.valueOf()>i.valueOf():i.valueOf()<this.clone().startOf(e).valueOf())}function ri(t,e){var i=y(t)?t:De(t);return!(!this.isValid()||!i.isValid())&&(e=z(s(e)?"millisecond":e),"millisecond"===e?this.valueOf()<i.valueOf():this.clone().endOf(e).valueOf()<i.valueOf())}function ai(t,e,i,o){return o=o||"()",("("===o[0]?this.isAfter(t,i):!this.isBefore(t,i))&&(")"===o[1]?this.isBefore(e,i):!this.isAfter(e,i))}function hi(t,e){var i,o=y(t)?t:De(t);return!(!this.isValid()||!o.isValid())&&(e=z(e||"millisecond"),"millisecond"===e?this.valueOf()===o.valueOf():(i=o.valueOf(),this.clone().startOf(e).valueOf()<=i&&i<=this.clone().endOf(e).valueOf()))}function di(t,e){return this.isSame(t,e)||this.isAfter(t,e)}function li(t,e){return this.isSame(t,e)||this.isBefore(t,e)}function ui(t,e,i){var o,n,s;if(!this.isValid())return NaN;if(o=Le(t,this),!o.isValid())return NaN;switch(n=6e4*(o.utcOffset()-this.utcOffset()),e=z(e)){case"year":s=ci(this,o)/12;break;case"month":s=ci(this,o);break;case"quarter":s=ci(this,o)/3;break;case"second":s=(this-o)/1e3;break;case"minute":s=(this-o)/6e4;break;case"hour":s=(this-o)/36e5;break;case"day":s=(this-o-n)/864e5;break;case"week":s=(this-o-n)/6048e5;break;default:s=this-o}return i?s:b(s)}function ci(t,e){var i,o,n=12*(e.year()-t.year())+(e.month()-t.month()),s=t.clone().add(n,"months");return e-s<0?(i=t.clone().add(n-1,"months"),o=(e-s)/(s-i)):(i=t.clone().add(n+1,"months"),o=(e-s)/(i-s)),-(n+o)||0}function pi(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function fi(){if(!this.isValid())return null;var t=this.clone().utc();return t.year()<0||t.year()>9999?G(t,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):D(Date.prototype.toISOString)?this.toDate().toISOString():G(t,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")}function mi(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var t="moment",e="";this.isLocal()||(t=0===this.utcOffset()?"moment.utc":"moment.parseZone",e="Z");var i="["+t+'("]',o=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",n=e+'[")]';return this.format(i+o+"-MM-DD[T]HH:mm:ss.SSS"+n)}function vi(t){t||(t=this.isUtc()?e.defaultFormatUtc:e.defaultFormat);var i=G(this,t);return this.localeData().postformat(i)}function gi(t,e){return this.isValid()&&(y(t)&&t.isValid()||De(t).isValid())?Ke({to:this,from:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function yi(t){return this.from(De(),t)}function bi(t,e){return this.isValid()&&(y(t)&&t.isValid()||De(t).isValid())?Ke({from:this,to:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function _i(t){return this.to(De(),t)}function wi(t){var e;return void 0===t?this._locale._abbr:(e=ie(t),null!=e&&(this._locale=e),this)}function xi(){return this._locale}function ki(t){switch(t=z(t)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":case"date":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===t&&this.weekday(0),"isoWeek"===t&&this.isoWeekday(1),"quarter"===t&&this.month(3*Math.floor(this.month()/3)),this}function Si(t){return void 0===(t=z(t))||"millisecond"===t?this:("date"===t&&(t="day"),this.startOf(t).add(1,"isoWeek"===t?"week":t).subtract(1,"ms"))}function Di(){return this._d.valueOf()-6e4*(this._offset||0)}function Mi(){return Math.floor(this.valueOf()/1e3)}function Ci(){return new Date(this.valueOf())}function Oi(){var t=this;return[t.year(),t.month(),t.date(),t.hour(),t.minute(),t.second(),t.millisecond()]}function Ei(){var t=this;return{years:t.year(),months:t.month(),date:t.date(),hours:t.hours(),minutes:t.minutes(),seconds:t.seconds(),milliseconds:t.milliseconds()}}function Ti(){return this.isValid()?this.toISOString():null}function Pi(){return f(this)}function Ii(){return l({},p(this))}function Ni(){return p(this).overflow}function Ri(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}function Ai(t,e){H(0,[t,t.length],0,e)}function zi(t){return ji.call(this,t,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)}function Li(t){return ji.call(this,t,this.isoWeek(),this.isoWeekday(),1,4)}function Fi(){return St(this.year(),1,4)}function Bi(){var t=this.localeData()._week;return St(this.year(),t.dow,t.doy)}function ji(t,e,i,o,n){var s;return null==t?kt(this,o,n).year:(s=St(t,o,n),e>s&&(e=s),Hi.call(this,t,e,i,o,n))}function Hi(t,e,i,o,n){var s=xt(t,e,i,o,n),r=_t(s.year,0,s.dayOfYear);return this.year(r.getUTCFullYear()),this.month(r.getUTCMonth()),this.date(r.getUTCDate()),this}function Wi(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)}function Yi(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")}function Gi(t,e){e[mn]=_(1e3*("0."+t))}function Vi(){return this._isUTC?"UTC":""}function Ui(){return this._isUTC?"Coordinated Universal Time":""}function qi(t){return De(1e3*t)}function Xi(){return De.apply(null,arguments).parseZone()}function Zi(t){return t}function Ki(t,e,i,o){var n=ie(),s=u().set(o,e);return n[i](s,t)}function Ji(t,e,i){if(r(t)&&(e=t,t=void 0),t=t||"",null!=e)return Ki(t,e,i,"month");var o,n=[];for(o=0;o<12;o++)n[o]=Ki(t,o,i,"month");return n}function $i(t,e,i,o){"boolean"==typeof t?(r(e)&&(i=e,e=void 0),e=e||""):(e=t,i=e,t=!1,r(e)&&(i=e,e=void 0),e=e||"");var n=ie(),s=t?n._week.dow:0;if(null!=i)return Ki(e,(i+s)%7,o,"day");var a,h=[];for(a=0;a<7;a++)h[a]=Ki(e,(a+s)%7,o,"day");return h}function Qi(t,e){return Ji(t,e,"months")}function to(t,e){return Ji(t,e,"monthsShort")}function eo(t,e,i){return $i(t,e,i,"weekdays")}function io(t,e,i){return $i(t,e,i,"weekdaysShort")}function oo(t,e,i){return $i(t,e,i,"weekdaysMin")}function no(){var t=this._data;return this._milliseconds=ds(this._milliseconds),this._days=ds(this._days),this._months=ds(this._months),t.milliseconds=ds(t.milliseconds),t.seconds=ds(t.seconds),t.minutes=ds(t.minutes),t.hours=ds(t.hours),t.months=ds(t.months),t.years=ds(t.years),this}function so(t,e,i,o){var n=Ke(e,i);return t._milliseconds+=o*n._milliseconds,t._days+=o*n._days,t._months+=o*n._months,t._bubble()}function ro(t,e){return so(this,t,e,1)}function ao(t,e){return so(this,t,e,-1)}function ho(t){return t<0?Math.floor(t):Math.ceil(t)}function lo(){var t,e,i,o,n,s=this._milliseconds,r=this._days,a=this._months,h=this._data;return s>=0&&r>=0&&a>=0||s<=0&&r<=0&&a<=0||(s+=864e5*ho(co(a)+r),r=0,a=0),h.milliseconds=s%1e3,t=b(s/1e3),h.seconds=t%60,e=b(t/60),h.minutes=e%60,i=b(e/60),h.hours=i%24,r+=b(i/24),n=b(uo(r)),a+=n, +r-=ho(co(n)),o=b(a/12),a%=12,h.days=r,h.months=a,h.years=o,this}function uo(t){return 4800*t/146097}function co(t){return 146097*t/4800}function po(t){if(!this.isValid())return NaN;var e,i,o=this._milliseconds;if("month"===(t=z(t))||"year"===t)return e=this._days+o/864e5,i=this._months+uo(e),"month"===t?i:i/12;switch(e=this._days+Math.round(co(this._months)),t){case"week":return e/7+o/6048e5;case"day":return e+o/864e5;case"hour":return 24*e+o/36e5;case"minute":return 1440*e+o/6e4;case"second":return 86400*e+o/1e3;case"millisecond":return Math.floor(864e5*e)+o;default:throw new Error("Unknown unit "+t)}}function fo(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*_(this._months/12):NaN}function mo(t){return function(){return this.as(t)}}function vo(){return Ke(this)}function go(t){return t=z(t),this.isValid()?this[t+"s"]():NaN}function yo(t){return function(){return this.isValid()?this._data[t]:NaN}}function bo(){return b(this.days()/7)}function _o(t,e,i,o,n){return n.relativeTime(e||1,!!i,t,o)}function wo(t,e,i){var o=Ke(t).abs(),n=Ds(o.as("s")),s=Ds(o.as("m")),r=Ds(o.as("h")),a=Ds(o.as("d")),h=Ds(o.as("M")),d=Ds(o.as("y")),l=n<=Ms.ss&&["s",n]||n<Ms.s&&["ss",n]||s<=1&&["m"]||s<Ms.m&&["mm",s]||r<=1&&["h"]||r<Ms.h&&["hh",r]||a<=1&&["d"]||a<Ms.d&&["dd",a]||h<=1&&["M"]||h<Ms.M&&["MM",h]||d<=1&&["y"]||["yy",d];return l[2]=e,l[3]=+t>0,l[4]=i,_o.apply(null,l)}function xo(t){return void 0===t?Ds:"function"==typeof t&&(Ds=t,!0)}function ko(t,e){return void 0!==Ms[t]&&(void 0===e?Ms[t]:(Ms[t]=e,"s"===t&&(Ms.ss=e-1),!0))}function So(t){if(!this.isValid())return this.localeData().invalidDate();var e=this.localeData(),i=wo(this,!t,e);return t&&(i=e.pastFuture(+this,i)),e.postformat(i)}function Do(t){return(t>0)-(t<0)||+t}function Mo(){if(!this.isValid())return this.localeData().invalidDate();var t,e,i,o=Cs(this._milliseconds)/1e3,n=Cs(this._days),s=Cs(this._months);t=b(o/60),e=b(t/60),o%=60,t%=60,i=b(s/12),s%=12;var r=i,a=s,h=n,d=e,l=t,u=o?o.toFixed(3).replace(/\.?0+$/,""):"",c=this.asSeconds();if(!c)return"P0D";var p=c<0?"-":"",f=Do(this._months)!==Do(c)?"-":"",m=Do(this._days)!==Do(c)?"-":"",v=Do(this._milliseconds)!==Do(c)?"-":"";return p+"P"+(r?f+r+"Y":"")+(a?f+a+"M":"")+(h?m+h+"D":"")+(d||l||u?"T":"")+(d?v+d+"H":"")+(l?v+l+"M":"")+(u?v+u+"S":"")}var Co,Oo;Oo=Array.prototype.some?Array.prototype.some:function(t){for(var e=Object(this),i=e.length>>>0,o=0;o<i;o++)if(o in e&&t.call(this,e[o],o,e))return!0;return!1};var Eo=e.momentProperties=[],To=!1,Po={};e.suppressDeprecationWarnings=!1,e.deprecationHandler=null;var Io;Io=Object.keys?Object.keys:function(t){var e,i=[];for(e in t)d(t,e)&&i.push(e);return i};var No={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},Ro={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},Ao=/\d{1,2}/,zo={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},Lo={},Fo={},Bo=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,jo=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,Ho={},Wo={},Yo=/\d/,Go=/\d\d/,Vo=/\d{3}/,Uo=/\d{4}/,qo=/[+-]?\d{6}/,Xo=/\d\d?/,Zo=/\d\d\d\d?/,Ko=/\d\d\d\d\d\d?/,Jo=/\d{1,3}/,$o=/\d{1,4}/,Qo=/[+-]?\d{1,6}/,tn=/\d+/,en=/[+-]?\d+/,on=/Z|[+-]\d\d:?\d\d/gi,nn=/Z|[+-]\d\d(?::?\d\d)?/gi,sn=/[+-]?\d+(\.\d{1,3})?/,rn=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,an={},hn={},dn=0,ln=1,un=2,cn=3,pn=4,fn=5,mn=6,vn=7,gn=8;H("Y",0,0,function(){var t=this.year();return t<=9999?""+t:"+"+t}),H(0,["YY",2],0,function(){return this.year()%100}),H(0,["YYYY",4],0,"year"),H(0,["YYYYY",5],0,"year"),H(0,["YYYYYY",6,!0],0,"year"),A("year","y"),F("year",1),U("Y",en),U("YY",Xo,Go),U("YYYY",$o,Uo),U("YYYYY",Qo,qo),U("YYYYYY",Qo,qo),K(["YYYYY","YYYYYY"],dn),K("YYYY",function(t,i){i[dn]=2===t.length?e.parseTwoDigitYear(t):_(t)}),K("YY",function(t,i){i[dn]=e.parseTwoDigitYear(t)}),K("Y",function(t,e){e[dn]=parseInt(t,10)}),e.parseTwoDigitYear=function(t){return _(t)+(_(t)>68?1900:2e3)};var yn,bn=it("FullYear",!0);yn=Array.prototype.indexOf?Array.prototype.indexOf:function(t){var e;for(e=0;e<this.length;++e)if(this[e]===t)return e;return-1},H("M",["MM",2],"Mo",function(){return this.month()+1}),H("MMM",0,0,function(t){return this.localeData().monthsShort(this,t)}),H("MMMM",0,0,function(t){return this.localeData().months(this,t)}),A("month","M"),F("month",8),U("M",Xo),U("MM",Xo,Go),U("MMM",function(t,e){return e.monthsShortRegex(t)}),U("MMMM",function(t,e){return e.monthsRegex(t)}),K(["M","MM"],function(t,e){e[ln]=_(t)-1}),K(["MMM","MMMM"],function(t,e,i,o){var n=i._locale.monthsParse(t,o,i._strict);null!=n?e[ln]=n:p(i).invalidMonth=t});var _n=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,wn="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),xn="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),kn=rn,Sn=rn;H("w",["ww",2],"wo","week"),H("W",["WW",2],"Wo","isoWeek"),A("week","w"),A("isoWeek","W"),F("week",5),F("isoWeek",5),U("w",Xo),U("ww",Xo,Go),U("W",Xo),U("WW",Xo,Go),J(["w","ww","W","WW"],function(t,e,i,o){e[o.substr(0,1)]=_(t)});var Dn={dow:0,doy:6};H("d",0,"do","day"),H("dd",0,0,function(t){return this.localeData().weekdaysMin(this,t)}),H("ddd",0,0,function(t){return this.localeData().weekdaysShort(this,t)}),H("dddd",0,0,function(t){return this.localeData().weekdays(this,t)}),H("e",0,0,"weekday"),H("E",0,0,"isoWeekday"),A("day","d"),A("weekday","e"),A("isoWeekday","E"),F("day",11),F("weekday",11),F("isoWeekday",11),U("d",Xo),U("e",Xo),U("E",Xo),U("dd",function(t,e){return e.weekdaysMinRegex(t)}),U("ddd",function(t,e){return e.weekdaysShortRegex(t)}),U("dddd",function(t,e){return e.weekdaysRegex(t)}),J(["dd","ddd","dddd"],function(t,e,i,o){var n=i._locale.weekdaysParse(t,o,i._strict);null!=n?e.d=n:p(i).invalidWeekday=t}),J(["d","e","E"],function(t,e,i,o){e[o]=_(t)});var Mn="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Cn="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),On="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),En=rn,Tn=rn,Pn=rn;H("H",["HH",2],0,"hour"),H("h",["hh",2],0,Gt),H("k",["kk",2],0,Vt),H("hmm",0,0,function(){return""+Gt.apply(this)+j(this.minutes(),2)}),H("hmmss",0,0,function(){return""+Gt.apply(this)+j(this.minutes(),2)+j(this.seconds(),2)}),H("Hmm",0,0,function(){return""+this.hours()+j(this.minutes(),2)}),H("Hmmss",0,0,function(){return""+this.hours()+j(this.minutes(),2)+j(this.seconds(),2)}),Ut("a",!0),Ut("A",!1),A("hour","h"),F("hour",13),U("a",qt),U("A",qt),U("H",Xo),U("h",Xo),U("k",Xo),U("HH",Xo,Go),U("hh",Xo,Go),U("kk",Xo,Go),U("hmm",Zo),U("hmmss",Ko),U("Hmm",Zo),U("Hmmss",Ko),K(["H","HH"],cn),K(["k","kk"],function(t,e,i){var o=_(t);e[cn]=24===o?0:o}),K(["a","A"],function(t,e,i){i._isPm=i._locale.isPM(t),i._meridiem=t}),K(["h","hh"],function(t,e,i){e[cn]=_(t),p(i).bigHour=!0}),K("hmm",function(t,e,i){var o=t.length-2;e[cn]=_(t.substr(0,o)),e[pn]=_(t.substr(o)),p(i).bigHour=!0}),K("hmmss",function(t,e,i){var o=t.length-4,n=t.length-2;e[cn]=_(t.substr(0,o)),e[pn]=_(t.substr(o,2)),e[fn]=_(t.substr(n)),p(i).bigHour=!0}),K("Hmm",function(t,e,i){var o=t.length-2;e[cn]=_(t.substr(0,o)),e[pn]=_(t.substr(o))}),K("Hmmss",function(t,e,i){var o=t.length-4,n=t.length-2;e[cn]=_(t.substr(0,o)),e[pn]=_(t.substr(o,2)),e[fn]=_(t.substr(n))});var In,Nn=/[ap]\.?m?\.?/i,Rn=it("Hours",!0),An={calendar:No,longDateFormat:Ro,invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:Ao,relativeTime:zo,months:wn,monthsShort:xn,week:Dn,weekdays:Mn,weekdaysMin:On,weekdaysShort:Cn,meridiemParse:Nn},zn={},Ln={},Fn=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Bn=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,jn=/Z|[+-]\d\d(?::?\d\d)?/,Hn=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],Wn=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Yn=/^\/?Date\((\-?\d+)/i,Gn=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,Vn={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};e.createFromInputFallback=k("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(t){t._d=new Date(t._i+(t._useUTC?" UTC":""))}),e.ISO_8601=function(){},e.RFC_2822=function(){};var Un=k("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var t=De.apply(null,arguments);return this.isValid()&&t.isValid()?t<this?this:t:m()}),qn=k("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var t=De.apply(null,arguments);return this.isValid()&&t.isValid()?t>this?this:t:m()}),Xn=function(){return Date.now?Date.now():+new Date},Zn=["year","quarter","month","week","day","hour","minute","second","millisecond"];Ae("Z",":"),Ae("ZZ",""),U("Z",nn),U("ZZ",nn),K(["Z","ZZ"],function(t,e,i){i._useUTC=!0,i._tzm=ze(nn,t)});var Kn=/([\+\-]|\d\d)/gi;e.updateOffset=function(){};var Jn=/^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,$n=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;Ke.fn=Ie.prototype,Ke.invalid=Pe;var Qn=ti(1,"add"),ts=ti(-1,"subtract");e.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",e.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var es=k("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(t){return void 0===t?this.localeData():this.locale(t)});H(0,["gg",2],0,function(){return this.weekYear()%100}),H(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Ai("gggg","weekYear"),Ai("ggggg","weekYear"),Ai("GGGG","isoWeekYear"),Ai("GGGGG","isoWeekYear"),A("weekYear","gg"),A("isoWeekYear","GG"),F("weekYear",1),F("isoWeekYear",1),U("G",en),U("g",en),U("GG",Xo,Go),U("gg",Xo,Go),U("GGGG",$o,Uo),U("gggg",$o,Uo),U("GGGGG",Qo,qo),U("ggggg",Qo,qo),J(["gggg","ggggg","GGGG","GGGGG"],function(t,e,i,o){e[o.substr(0,2)]=_(t)}),J(["gg","GG"],function(t,i,o,n){i[n]=e.parseTwoDigitYear(t)}),H("Q",0,"Qo","quarter"),A("quarter","Q"),F("quarter",7),U("Q",Yo),K("Q",function(t,e){e[ln]=3*(_(t)-1)}),H("D",["DD",2],"Do","date"),A("date","D"),F("date",9),U("D",Xo),U("DD",Xo,Go),U("Do",function(t,e){return t?e._dayOfMonthOrdinalParse||e._ordinalParse:e._dayOfMonthOrdinalParseLenient}),K(["D","DD"],un),K("Do",function(t,e){e[un]=_(t.match(Xo)[0],10)});var is=it("Date",!0);H("DDD",["DDDD",3],"DDDo","dayOfYear"),A("dayOfYear","DDD"),F("dayOfYear",4),U("DDD",Jo),U("DDDD",Vo),K(["DDD","DDDD"],function(t,e,i){i._dayOfYear=_(t)}),H("m",["mm",2],0,"minute"),A("minute","m"),F("minute",14),U("m",Xo),U("mm",Xo,Go),K(["m","mm"],pn);var os=it("Minutes",!1);H("s",["ss",2],0,"second"),A("second","s"),F("second",15),U("s",Xo),U("ss",Xo,Go),K(["s","ss"],fn);var ns=it("Seconds",!1);H("S",0,0,function(){return~~(this.millisecond()/100)}),H(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),H(0,["SSS",3],0,"millisecond"),H(0,["SSSS",4],0,function(){return 10*this.millisecond()}),H(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),H(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),H(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),H(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),H(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),A("millisecond","ms"),F("millisecond",16),U("S",Jo,Yo),U("SS",Jo,Go),U("SSS",Jo,Vo);var ss;for(ss="SSSS";ss.length<=9;ss+="S")U(ss,tn);for(ss="S";ss.length<=9;ss+="S")K(ss,Gi);var rs=it("Milliseconds",!1);H("z",0,0,"zoneAbbr"),H("zz",0,0,"zoneName");var as=g.prototype;as.add=Qn,as.calendar=oi,as.clone=ni,as.diff=ui,as.endOf=Si,as.format=vi,as.from=gi,as.fromNow=yi,as.to=bi,as.toNow=_i,as.get=st,as.invalidAt=Ni,as.isAfter=si,as.isBefore=ri,as.isBetween=ai,as.isSame=hi,as.isSameOrAfter=di,as.isSameOrBefore=li,as.isValid=Pi,as.lang=es,as.locale=wi,as.localeData=xi,as.max=qn,as.min=Un,as.parsingFlags=Ii,as.set=rt,as.startOf=ki,as.subtract=ts,as.toArray=Oi,as.toObject=Ei,as.toDate=Ci,as.toISOString=fi,as.inspect=mi,as.toJSON=Ti,as.toString=pi,as.unix=Mi,as.valueOf=Di,as.creationData=Ri,as.year=bn,as.isLeapYear=et,as.weekYear=zi,as.isoWeekYear=Li,as.quarter=as.quarters=Wi,as.month=ft,as.daysInMonth=mt,as.week=as.weeks=Ot,as.isoWeek=as.isoWeeks=Et,as.weeksInYear=Bi,as.isoWeeksInYear=Fi,as.date=is,as.day=as.days=Lt,as.weekday=Ft,as.isoWeekday=Bt,as.dayOfYear=Yi,as.hour=as.hours=Rn,as.minute=as.minutes=os,as.second=as.seconds=ns,as.millisecond=as.milliseconds=rs,as.utcOffset=Be,as.utc=He,as.local=We,as.parseZone=Ye,as.hasAlignedHourOffset=Ge,as.isDST=Ve,as.isLocal=qe,as.isUtcOffset=Xe,as.isUtc=Ze,as.isUTC=Ze,as.zoneAbbr=Vi,as.zoneName=Ui,as.dates=k("dates accessor is deprecated. Use date instead.",is),as.months=k("months accessor is deprecated. Use month instead",ft),as.years=k("years accessor is deprecated. Use year instead",bn),as.zone=k("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",je),as.isDSTShifted=k("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",Ue);var hs=O.prototype;hs.calendar=E,hs.longDateFormat=T,hs.invalidDate=P,hs.ordinal=I,hs.preparse=Zi,hs.postformat=Zi,hs.relativeTime=N,hs.pastFuture=R,hs.set=M,hs.months=dt,hs.monthsShort=lt,hs.monthsParse=ct,hs.monthsRegex=gt,hs.monthsShortRegex=vt,hs.week=Dt,hs.firstDayOfYear=Ct,hs.firstDayOfWeek=Mt,hs.weekdays=It,hs.weekdaysMin=Rt,hs.weekdaysShort=Nt,hs.weekdaysParse=zt,hs.weekdaysRegex=jt,hs.weekdaysShortRegex=Ht,hs.weekdaysMinRegex=Wt,hs.isPM=Xt,hs.meridiem=Zt,Qt("en",{dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(t){var e=t%10;return t+(1===_(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th")}}),e.lang=k("moment.lang is deprecated. Use moment.locale instead.",Qt),e.langData=k("moment.langData is deprecated. Use moment.localeData instead.",ie);var ds=Math.abs,ls=mo("ms"),us=mo("s"),cs=mo("m"),ps=mo("h"),fs=mo("d"),ms=mo("w"),vs=mo("M"),gs=mo("y"),ys=yo("milliseconds"),bs=yo("seconds"),_s=yo("minutes"),ws=yo("hours"),xs=yo("days"),ks=yo("months"),Ss=yo("years"),Ds=Math.round,Ms={ss:44,s:45,m:45,h:22,d:26,M:11},Cs=Math.abs,Os=Ie.prototype;return Os.isValid=Te,Os.abs=no,Os.add=ro,Os.subtract=ao,Os.as=po,Os.asMilliseconds=ls,Os.asSeconds=us,Os.asMinutes=cs,Os.asHours=ps,Os.asDays=fs,Os.asWeeks=ms,Os.asMonths=vs,Os.asYears=gs,Os.valueOf=fo,Os._bubble=lo,Os.clone=vo,Os.get=go,Os.milliseconds=ys,Os.seconds=bs,Os.minutes=_s,Os.hours=ws,Os.days=xs,Os.weeks=bo,Os.months=ks,Os.years=Ss,Os.humanize=So,Os.toISOString=Mo,Os.toString=Mo,Os.toJSON=Mo,Os.locale=wi,Os.localeData=xi,Os.toIsoString=k("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",Mo),Os.lang=es,H("X",0,0,"unix"),H("x",0,0,"valueOf"),U("x",en),U("X",sn),K("X",function(t,e,i){i._d=new Date(1e3*parseFloat(t,10))}),K("x",function(t,e,i){i._d=new Date(_(t))}),e.version="2.19.1",function(t){Co=t}(De),e.fn=as,e.min=Ce,e.max=Oe,e.now=Xn,e.utc=u,e.unix=qi,e.months=Qi,e.isDate=a,e.locale=Qt,e.invalid=m,e.duration=Ke,e.isMoment=y,e.weekdays=eo,e.parseZone=Xi,e.localeData=ie,e.isDuration=Ne,e.monthsShort=to,e.weekdaysMin=oo,e.defineLocale=te,e.updateLocale=ee,e.locales=oe,e.weekdaysShort=io,e.normalizeUnits=z,e.relativeTimeRounding=xo,e.relativeTimeThreshold=ko,e.calendarFormat=ii,e.prototype=as,e})}).call(e,i(155)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e){function i(t){throw new Error("Cannot find module '"+t+"'.")}i.keys=function(){return[]},i.resolve=i,t.exports=i,i.id=156},function(t,e,i){(function(e){function i(t,e,i){var o=e&&i||0,n=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){n<16&&(e[o+n++]=u[t])});n<16;)e[o+n++]=0;return e}function o(t,e){var i=e||0,o=l;return o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]}function n(t,e,i){var n=e&&i||0,s=e||[];t=t||{};var r=void 0!==t.clockseq?t.clockseq:m,a=void 0!==t.msecs?t.msecs:(new Date).getTime(),h=void 0!==t.nsecs?t.nsecs:g+1,d=a-v+(h-g)/1e4;if(d<0&&void 0===t.clockseq&&(r=r+1&16383),(d<0||a>v)&&void 0===t.nsecs&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=a,g=h,m=r,a+=122192928e5;var l=(1e4*(268435455&a)+h)%4294967296;s[n++]=l>>>24&255,s[n++]=l>>>16&255,s[n++]=l>>>8&255,s[n++]=255&l;var u=a/4294967296*1e4&268435455;s[n++]=u>>>8&255,s[n++]=255&u,s[n++]=u>>>24&15|16,s[n++]=u>>>16&255,s[n++]=r>>>8|128,s[n++]=255&r;for(var c=t.node||f,p=0;p<6;p++)s[n+p]=c[p];return e||o(s)}function s(t,e,i){var n=e&&i||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null),t=t||{};var s=t.random||(t.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e)for(var a=0;a<16;a++)e[n+a]=s[a];return e||o(s)}var r,a="undefined"!=typeof window?window:void 0!==e?e:null;if(a&&a.crypto&&crypto.getRandomValues){var h=new Uint8Array(16);r=function(){return crypto.getRandomValues(h),h}}if(!r){var d=new Array(16);r=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),d[e]=t>>>((3&e)<<3)&255;return d}}for(var l=[],u={},c=0;c<256;c++)l[c]=(c+256).toString(16).substr(1),u[l[c]]=c;var p=r(),f=[1|p[0],p[1],p[2],p[3],p[4],p[5]],m=16383&(p[6]<<8|p[7]),v=0,g=0,y=s;y.v1=n,y.v4=s,y.parse=i,y.unparse=o,t.exports=y}).call(e,i(158))},function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){e.util=i(2),e.DOMutil=i(14),e.DataSet=i(11),e.DataView=i(12),e.Queue=i(43),e.Graph3d=i(161),e.graph3d={Camera:i(95),Filter:i(96),Point2d:i(91),Point3d:i(34),Slider:i(92),StepNumber:i(93)},e.moment=i(9),e.Hammer=i(10),e.keycharm=i(35)},function(t,e,i){var o=i(7),n=o.JSON||(o.JSON={stringify:JSON.stringify});t.exports=function(t){return n.stringify.apply(n,arguments)}},function(t,e,i){function o(t,e,i){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");this.containerElement=t,this.dataGroup=new _,this.dataPoints=null,this.create(),f.setDefaults(o.DEFAULTS,this),this.colX=void 0,this.colY=void 0,this.colZ=void 0,this.colValue=void 0,this.setOptions(i),this.setData(e)}function n(t){return"clientX"in t?t.clientX:t.targetTouches[0]&&t.targetTouches[0].clientX||0}function s(t){return"clientY"in t?t.clientY:t.targetTouches[0]&&t.targetTouches[0].clientY||0}var r=i(90),a=function(t){return t&&t.__esModule?t:{default:t}}(r),h=i(44),d=i(2),l=i(34),u=i(91),c=i(92),p=i(93),f=i(94),m=i(15).default,v=i(15),g=v.printStyle,y=i(172),b=y.allOptions,_=i(173);o.STYLE=f.STYLE;o.DEFAULTS={width:"400px",height:"400px",filterLabel:"time",legendLabel:"value",xLabel:"x",yLabel:"y",zLabel:"z",xValueLabel:function(t){return t},yValueLabel:function(t){return t},zValueLabel:function(t){return t},showXAxis:!0,showYAxis:!0,showZAxis:!0,showGrid:!0,showPerspective:!0,showShadow:!1,keepAspectRatio:!0,verticalRatio:.5,dotSizeRatio:.02,dotSizeMinFraction:.5,dotSizeMaxFraction:2.5,showAnimationControls:void 0,animationInterval:1e3,animationPreload:!1,animationAutoStart:void 0,axisColor:"#4D4D4D",gridColor:"#D3D3D3",xCenter:"55%",yCenter:"50%",style:o.STYLE.DOT,tooltip:!1,tooltipStyle:{content:{padding:"10px",border:"1px solid #4d4d4d",color:"#1a1a1a",background:"rgba(255,255,255,0.7)",borderRadius:"2px",boxShadow:"5px 5px 10px rgba(128,128,128,0.5)"},line:{height:"40px",width:"0",borderLeft:"1px solid #4d4d4d"},dot:{height:"0",width:"0",border:"5px solid #4d4d4d",borderRadius:"5px"}},dataColor:{fill:"#7DC1FF",stroke:"#3267D2",strokeWidth:1},cameraPosition:{horizontal:1,vertical:.5,distance:1.7},showLegend:void 0,backgroundColor:void 0,xBarWidth:void 0,yBarWidth:void 0,valueMin:void 0,valueMax:void 0,xMin:void 0,xMax:void 0,xStep:void 0,yMin:void 0,yMax:void 0,yStep:void 0,zMin:void 0,zMax:void 0,zStep:void 0},h(o.prototype),o.prototype._setScale=function(){this.scale=new l(1/this.xRange.range(),1/this.yRange.range(),1/this.zRange.range()),this.keepAspectRatio&&(this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y),this.scale.z*=this.verticalRatio,void 0!==this.valueRange&&(this.scale.value=1/this.valueRange.range());var t=this.xRange.center()*this.scale.x,e=this.yRange.center()*this.scale.y,i=this.zRange.center()*this.scale.z;this.camera.setArmLocation(t,e,i)},o.prototype._convert3Dto2D=function(t){var e=this._convertPointToTranslation(t);return this._convertTranslationToScreen(e)},o.prototype._convertPointToTranslation=function(t){var e=this.camera.getCameraLocation(),i=this.camera.getCameraRotation(),o=t.x*this.scale.x,n=t.y*this.scale.y,s=t.z*this.scale.z,r=e.x,a=e.y,h=e.z,d=Math.sin(i.x),u=Math.cos(i.x),c=Math.sin(i.y),p=Math.cos(i.y),f=Math.sin(i.z),m=Math.cos(i.z);return new l(p*(f*(n-a)+m*(o-r))-c*(s-h),d*(p*(s-h)+c*(f*(n-a)+m*(o-r)))+u*(m*(n-a)-f*(o-r)),u*(p*(s-h)+c*(f*(n-a)+m*(o-r)))-d*(m*(n-a)-f*(o-r)))},o.prototype._convertTranslationToScreen=function(t){var e,i,o=this.eye.x,n=this.eye.y,s=this.eye.z,r=t.x,a=t.y,h=t.z;return this.showPerspective?(e=s/h*(r-o),i=s/h*(a-n)):(e=r*(-s/this.camera.getArmLength()),i=a*(-s/this.camera.getArmLength())),new u(this.currentXCenter+e*this.frame.canvas.clientWidth,this.currentYCenter-i*this.frame.canvas.clientWidth)},o.prototype._calcTranslations=function(t){for(var e=0;e<t.length;e++){var i=t[e];i.trans=this._convertPointToTranslation(i.point),i.screen=this._convertTranslationToScreen(i.trans);var o=this._convertPointToTranslation(i.bottom);i.dist=this.showPerspective?o.length():-o.z}var n=function(t,e){return e.dist-t.dist};t.sort(n)},o.prototype._initializeRanges=function(){var t=this.dataGroup;this.xRange=t.xRange,this.yRange=t.yRange,this.zRange=t.zRange,this.valueRange=t.valueRange,this.xStep=t.xStep,this.yStep=t.yStep,this.zStep=t.zStep,this.xBarWidth=t.xBarWidth,this.yBarWidth=t.yBarWidth,this.colX=t.colX,this.colY=t.colY,this.colZ=t.colZ,this.colValue=t.colValue,this._setScale()},o.prototype.getDataPoints=function(t){for(var e=[],i=0;i<t.length;i++){var o=new l;o.x=t[i][this.colX]||0,o.y=t[i][this.colY]||0,o.z=t[i][this.colZ]||0,o.data=t[i],void 0!==this.colValue&&(o.value=t[i][this.colValue]||0);var n={};n.point=o,n.bottom=new l(o.x,o.y,this.zRange.min),n.trans=void 0,n.screen=void 0,e.push(n)}return e},o.prototype._getDataPoints=function(t){var e,i,n,s,r=[];if(this.style===o.STYLE.GRID||this.style===o.STYLE.SURFACE){var a=this.dataGroup.getDistinctValues(this.colX,t),h=this.dataGroup.getDistinctValues(this.colY,t);r=this.getDataPoints(t);var d=[];for(n=0;n<r.length;n++){s=r[n];var l=a.indexOf(s.point.x),u=h.indexOf(s.point.y);void 0===d[l]&&(d[l]=[]),d[l][u]=s}for(e=0;e<d.length;e++)for(i=0;i<d[e].length;i++)d[e][i]&&(d[e][i].pointRight=e<d.length-1?d[e+1][i]:void 0,d[e][i].pointTop=i<d[e].length-1?d[e][i+1]:void 0,d[e][i].pointCross=e<d.length-1&&i<d[e].length-1?d[e+1][i+1]:void 0)}else if(this._checkValueField(t),r=this.getDataPoints(t),this.style===o.STYLE.LINE)for(n=0;n<r.length;n++)n>0&&(r[n-1].pointNext=r[n]);return r},o.prototype.create=function(){for(;this.containerElement.hasChildNodes();)this.containerElement.removeChild(this.containerElement.firstChild);this.frame=document.createElement("div"),this.frame.style.position="relative",this.frame.style.overflow="hidden",this.frame.canvas=document.createElement("canvas"),this.frame.canvas.style.position="relative",this.frame.appendChild(this.frame.canvas);var t=document.createElement("DIV");t.style.color="red",t.style.fontWeight="bold",t.style.padding="10px",t.innerHTML="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(t),this.frame.filter=document.createElement("div"),this.frame.filter.style.position="absolute",this.frame.filter.style.bottom="0px",this.frame.filter.style.left="0px",this.frame.filter.style.width="100%",this.frame.appendChild(this.frame.filter);var e=this,i=function(t){e._onMouseDown(t)},o=function(t){e._onTouchStart(t)},n=function(t){e._onWheel(t)},s=function(t){e._onTooltip(t)},r=function(t){e._onClick(t)};d.addEventListener(this.frame.canvas,"mousedown",i),d.addEventListener(this.frame.canvas,"touchstart",o),d.addEventListener(this.frame.canvas,"mousewheel",n),d.addEventListener(this.frame.canvas,"mousemove",s),d.addEventListener(this.frame.canvas,"click",r),this.containerElement.appendChild(this.frame)},o.prototype._setSize=function(t,e){this.frame.style.width=t,this.frame.style.height=e,this._resizeCanvas()},o.prototype._resizeCanvas=function(){this.frame.canvas.style.width="100%",this.frame.canvas.style.height="100%",this.frame.canvas.width=this.frame.canvas.clientWidth,this.frame.canvas.height=this.frame.canvas.clientHeight,this.frame.filter.style.width=this.frame.canvas.clientWidth-20+"px"},o.prototype.animationStart=function(){if(this.animationAutoStart&&this.dataGroup.dataFilter){if(!this.frame.filter||!this.frame.filter.slider)throw new Error("No animation available");this.frame.filter.slider.play()}},o.prototype.animationStop=function(){this.frame.filter&&this.frame.filter.slider&&this.frame.filter.slider.stop()},o.prototype._resizeCenter=function(){"%"===this.xCenter.charAt(this.xCenter.length-1)?this.currentXCenter=parseFloat(this.xCenter)/100*this.frame.canvas.clientWidth:this.currentXCenter=parseFloat(this.xCenter),"%"===this.yCenter.charAt(this.yCenter.length-1)?this.currentYCenter=parseFloat(this.yCenter)/100*(this.frame.canvas.clientHeight-this.frame.filter.clientHeight):this.currentYCenter=parseFloat(this.yCenter)},o.prototype.getCameraPosition=function(){var t=this.camera.getArmRotation();return t.distance=this.camera.getArmLength(),t},o.prototype._readData=function(t){this.dataPoints=this.dataGroup.initializeData(this,t,this.style),this._initializeRanges(),this._redrawFilter()},o.prototype.setData=function(t){void 0!==t&&null!==t&&(this._readData(t),this.redraw(),this.animationStart())},o.prototype.setOptions=function(t){if(void 0!==t){!0===m.validate(t,b)&&console.log("%cErrors have been found in the supplied options object.",g),this.animationStop(),f.setOptions(t,this),this.setPointDrawingMethod(),this._setSize(this.width,this.height),this.setData(this.dataGroup.getDataTable()),this.animationStart()}},o.prototype.setPointDrawingMethod=function(){var t=void 0;switch(this.style){case o.STYLE.BAR:t=o.prototype._redrawBarGraphPoint;break;case o.STYLE.BARCOLOR:t=o.prototype._redrawBarColorGraphPoint;break;case o.STYLE.BARSIZE:t=o.prototype._redrawBarSizeGraphPoint;break;case o.STYLE.DOT:t=o.prototype._redrawDotGraphPoint;break;case o.STYLE.DOTLINE:t=o.prototype._redrawDotLineGraphPoint;break;case o.STYLE.DOTCOLOR:t=o.prototype._redrawDotColorGraphPoint;break;case o.STYLE.DOTSIZE:t=o.prototype._redrawDotSizeGraphPoint;break;case o.STYLE.SURFACE:t=o.prototype._redrawSurfaceGraphPoint;break;case o.STYLE.GRID:t=o.prototype._redrawGridGraphPoint;break;case o.STYLE.LINE:t=o.prototype._redrawLineGraphPoint;break;default:throw new Error("Can not determine point drawing method for graph style '"+this.style+"'")}this._pointDrawingMethod=t},o.prototype.redraw=function(){if(void 0===this.dataPoints)throw new Error("Graph data not initialized");this._resizeCanvas(),this._resizeCenter(),this._redrawSlider(),this._redrawClear(),this._redrawAxis(),this._redrawDataGraph(),this._redrawInfo(),this._redrawLegend()},o.prototype._getContext=function(){var t=this.frame.canvas,e=t.getContext("2d");return e.lineJoin="round",e.lineCap="round",e},o.prototype._redrawClear=function(){var t=this.frame.canvas;t.getContext("2d").clearRect(0,0,t.width,t.height)},o.prototype._dotSize=function(){return this.frame.clientWidth*this.dotSizeRatio},o.prototype._getLegendWidth=function(){var t;if(this.style===o.STYLE.DOTSIZE){t=this._dotSize()*this.dotSizeMaxFraction}else t=this.style===o.STYLE.BARSIZE?this.xBarWidth:20;return t},o.prototype._redrawLegend=function(){if(!0===this.showLegend&&this.style!==o.STYLE.LINE&&this.style!==o.STYLE.BARSIZE){var t=this.style===o.STYLE.BARSIZE||this.style===o.STYLE.DOTSIZE,e=this.style===o.STYLE.DOTSIZE||this.style===o.STYLE.DOTCOLOR||this.style===o.STYLE.BARCOLOR,i=Math.max(.25*this.frame.clientHeight,100),n=this.margin,s=this._getLegendWidth(),r=this.frame.clientWidth-this.margin,a=r-s,h=n+i,d=this._getContext();if(d.lineWidth=1,d.font="14px arial",!1===t){var l,c=i;for(l=0;l<c;l++){var f=(l-0)/(c-0),m=240*f,v=this._hsv2rgb(m,1,1);d.strokeStyle=v,d.beginPath(),d.moveTo(a,n+l),d.lineTo(r,n+l),d.stroke()}d.strokeStyle=this.axisColor,d.strokeRect(a,n,s,i)}else{var g;this.style===o.STYLE.DOTSIZE?g=s*(this.dotSizeMinFraction/this.dotSizeMaxFraction):(this.style,o.STYLE.BARSIZE),d.strokeStyle=this.axisColor,d.fillStyle=this.dataColor.fill,d.beginPath(),d.moveTo(a,n),d.lineTo(r,n),d.lineTo(a+g,h),d.lineTo(a,h),d.closePath(),d.fill(),d.stroke()}var y=e?this.valueRange.min:this.zRange.min,b=e?this.valueRange.max:this.zRange.max,_=new p(y,b,(b-y)/5,!0);_.start(!0);for(var w,x;!_.end();)l=h-(_.getCurrent()-y)/(b-y)*i,w=new u(a-5,l),x=new u(a,l),this._line(d,w,x),d.textAlign="right",d.textBaseline="middle",d.fillStyle=this.axisColor,d.fillText(_.getCurrent(),a-10,l),_.next();d.textAlign="right",d.textBaseline="top";var k=this.legendLabel;d.fillText(k,r,h+this.margin)}},o.prototype._redrawFilter=function(){var t=this.dataGroup.dataFilter,e=this.frame.filter;if(e.innerHTML="",!t)return void(e.slider=void 0);var i={visible:this.showAnimationControls},o=new c(e,i);e.slider=o,e.style.padding="10px",o.setValues(t.values),o.setPlayInterval(this.animationInterval);var n=this,s=function(){var t=n.dataGroup.dataFilter,e=o.getIndex();t.selectValue(e),n.dataPoints=t._getDataPoints(),n.redraw()};o.setOnChangeCallback(s)},o.prototype._redrawSlider=function(){void 0!==this.frame.filter.slider&&this.frame.filter.slider.redraw()},o.prototype._redrawInfo=function(){var t=this.dataGroup.getInfo();if(void 0!==t){var e=this._getContext();e.font="14px arial",e.lineStyle="gray",e.fillStyle="gray",e.textAlign="left",e.textBaseline="top";var i=this.margin,o=this.margin;e.fillText(t,i,o)}},o.prototype._line=function(t,e,i,o){void 0!==o&&(t.strokeStyle=o),t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(i.x,i.y),t.stroke()},o.prototype.drawAxisLabelX=function(t,e,i,o,n){void 0===n&&(n=0);var s=this._convert3Dto2D(e) +;Math.cos(2*o)>0?(t.textAlign="center",t.textBaseline="top",s.y+=n):Math.sin(2*o)<0?(t.textAlign="right",t.textBaseline="middle"):(t.textAlign="left",t.textBaseline="middle"),t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y)},o.prototype.drawAxisLabelY=function(t,e,i,o,n){void 0===n&&(n=0);var s=this._convert3Dto2D(e);Math.cos(2*o)<0?(t.textAlign="center",t.textBaseline="top",s.y+=n):Math.sin(2*o)>0?(t.textAlign="right",t.textBaseline="middle"):(t.textAlign="left",t.textBaseline="middle"),t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y)},o.prototype.drawAxisLabelZ=function(t,e,i,o){void 0===o&&(o=0);var n=this._convert3Dto2D(e);t.textAlign="right",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,n.x-o,n.y)},o.prototype._line3d=function(t,e,i,o){var n=this._convert3Dto2D(e),s=this._convert3Dto2D(i);this._line(t,n,s,o)},o.prototype._redrawAxis=function(){var t,e,i,o,n,s,r,a,h,d,c,f=this._getContext();f.font=24/this.camera.getArmLength()+"px arial";var m,v=.025/this.scale.x,g=.025/this.scale.y,y=5/this.camera.getArmLength(),b=this.camera.getArmRotation().horizontal,_=new u(Math.cos(b),Math.sin(b)),w=this.xRange,x=this.yRange,k=this.zRange;for(f.lineWidth=1,o=void 0===this.defaultXStep,i=new p(w.min,w.max,this.xStep,o),i.start(!0);!i.end();){var S=i.getCurrent();if(this.showGrid?(t=new l(S,x.min,k.min),e=new l(S,x.max,k.min),this._line3d(f,t,e,this.gridColor)):this.showXAxis&&(t=new l(S,x.min,k.min),e=new l(S,x.min+v,k.min),this._line3d(f,t,e,this.axisColor),t=new l(S,x.max,k.min),e=new l(S,x.max-v,k.min),this._line3d(f,t,e,this.axisColor)),this.showXAxis){r=_.x>0?x.min:x.max,m=new l(S,r,k.min);var D=" "+this.xValueLabel(S)+" ";this.drawAxisLabelX(f,m,D,b,y)}i.next()}for(f.lineWidth=1,o=void 0===this.defaultYStep,i=new p(x.min,x.max,this.yStep,o),i.start(!0);!i.end();){var M=i.getCurrent();if(this.showGrid?(t=new l(w.min,M,k.min),e=new l(w.max,M,k.min),this._line3d(f,t,e,this.gridColor)):this.showYAxis&&(t=new l(w.min,M,k.min),e=new l(w.min+g,M,k.min),this._line3d(f,t,e,this.axisColor),t=new l(w.max,M,k.min),e=new l(w.max-g,M,k.min),this._line3d(f,t,e,this.axisColor)),this.showYAxis){s=_.y>0?w.min:w.max,m=new l(s,M,k.min);var C=" "+this.yValueLabel(M)+" ";this.drawAxisLabelY(f,m,C,b,y)}i.next()}if(this.showZAxis){for(f.lineWidth=1,o=void 0===this.defaultZStep,i=new p(k.min,k.max,this.zStep,o),i.start(!0),s=_.x>0?w.min:w.max,r=_.y<0?x.min:x.max;!i.end();){var O=i.getCurrent(),E=new l(s,r,O),T=this._convert3Dto2D(E);e=new u(T.x-y,T.y),this._line(f,T,e,this.axisColor);var P=this.zValueLabel(O)+" ";this.drawAxisLabelZ(f,E,P,5),i.next()}f.lineWidth=1,t=new l(s,r,k.min),e=new l(s,r,k.max),this._line3d(f,t,e,this.axisColor)}if(this.showXAxis){var I,N;f.lineWidth=1,I=new l(w.min,x.min,k.min),N=new l(w.max,x.min,k.min),this._line3d(f,I,N,this.axisColor),I=new l(w.min,x.max,k.min),N=new l(w.max,x.max,k.min),this._line3d(f,I,N,this.axisColor)}this.showYAxis&&(f.lineWidth=1,t=new l(w.min,x.min,k.min),e=new l(w.min,x.max,k.min),this._line3d(f,t,e,this.axisColor),t=new l(w.max,x.min,k.min),e=new l(w.max,x.max,k.min),this._line3d(f,t,e,this.axisColor));var R=this.xLabel;R.length>0&&this.showXAxis&&(c=.1/this.scale.y,s=(w.max+3*w.min)/4,r=_.x>0?x.min-c:x.max+c,n=new l(s,r,k.min),this.drawAxisLabelX(f,n,R,b));var A=this.yLabel;A.length>0&&this.showYAxis&&(d=.1/this.scale.x,s=_.y>0?w.min-d:w.max+d,r=(x.max+3*x.min)/4,n=new l(s,r,k.min),this.drawAxisLabelY(f,n,A,b));var z=this.zLabel;z.length>0&&this.showZAxis&&(h=30,s=_.x>0?w.min:w.max,r=_.y<0?x.min:x.max,a=(k.max+3*k.min)/4,n=new l(s,r,a),this.drawAxisLabelZ(f,n,z,h))},o.prototype._hsv2rgb=function(t,e,i){var o,n,s,r,a,h;switch(r=i*e,a=Math.floor(t/60),h=r*(1-Math.abs(t/60%2-1)),a){case 0:o=r,n=h,s=0;break;case 1:o=h,n=r,s=0;break;case 2:o=0,n=r,s=h;break;case 3:o=0,n=h,s=r;break;case 4:o=h,n=0,s=r;break;case 5:o=r,n=0,s=h;break;default:o=0,n=0,s=0}return"RGB("+parseInt(255*o)+","+parseInt(255*n)+","+parseInt(255*s)+")"},o.prototype._getStrokeWidth=function(t){return void 0!==t?this.showPerspective?1/-t.trans.z*this.dataColor.strokeWidth:-this.eye.z/this.camera.getArmLength()*this.dataColor.strokeWidth:this.dataColor.strokeWidth},o.prototype._redrawBar=function(t,e,i,o,n,s){var r,a=this,h=e.point,d=this.zRange.min,u=[{point:new l(h.x-i,h.y-o,h.z)},{point:new l(h.x+i,h.y-o,h.z)},{point:new l(h.x+i,h.y+o,h.z)},{point:new l(h.x-i,h.y+o,h.z)}],c=[{point:new l(h.x-i,h.y-o,d)},{point:new l(h.x+i,h.y-o,d)},{point:new l(h.x+i,h.y+o,d)},{point:new l(h.x-i,h.y+o,d)}];u.forEach(function(t){t.screen=a._convert3Dto2D(t.point)}),c.forEach(function(t){t.screen=a._convert3Dto2D(t.point)});var p=[{corners:u,center:l.avg(c[0].point,c[2].point)},{corners:[u[0],u[1],c[1],c[0]],center:l.avg(c[1].point,c[0].point)},{corners:[u[1],u[2],c[2],c[1]],center:l.avg(c[2].point,c[1].point)},{corners:[u[2],u[3],c[3],c[2]],center:l.avg(c[3].point,c[2].point)},{corners:[u[3],u[0],c[0],c[3]],center:l.avg(c[0].point,c[3].point)}];e.surfaces=p;for(var f=0;f<p.length;f++){r=p[f];var m=this._convertPointToTranslation(r.center);r.dist=this.showPerspective?m.length():-m.z}p.sort(function(t,e){var i=e.dist-t.dist;return i||(t.corners===u?1:e.corners===u?-1:0)}),t.lineWidth=this._getStrokeWidth(e),t.strokeStyle=s,t.fillStyle=n;for(var v=2;v<p.length;v++)r=p[v],this._polygon(t,r.corners)},o.prototype._polygon=function(t,e,i,o){if(!(e.length<2)){void 0!==i&&(t.fillStyle=i),void 0!==o&&(t.strokeStyle=o),t.beginPath(),t.moveTo(e[0].screen.x,e[0].screen.y);for(var n=1;n<e.length;++n){var s=e[n];t.lineTo(s.screen.x,s.screen.y)}t.closePath(),t.fill(),t.stroke()}},o.prototype._drawCircle=function(t,e,i,o,n){var s=this._calcRadius(e,n);t.lineWidth=this._getStrokeWidth(e),t.strokeStyle=o,t.fillStyle=i,t.beginPath(),t.arc(e.screen.x,e.screen.y,s,0,2*Math.PI,!0),t.fill(),t.stroke()},o.prototype._getColorsRegular=function(t){var e=240*(1-(t.point.z-this.zRange.min)*this.scale.z/this.verticalRatio);return{fill:this._hsv2rgb(e,1,1),border:this._hsv2rgb(e,1,.8)}},o.prototype._getColorsColor=function(t){var e,i;if("string"==typeof t.point.value)e=t.point.value,i=t.point.value;else{var o=240*(1-(t.point.value-this.valueRange.min)*this.scale.value);e=this._hsv2rgb(o,1,1),i=this._hsv2rgb(o,1,.8)}return{fill:e,border:i}},o.prototype._getColorsSize=function(){return{fill:this.dataColor.fill,border:this.dataColor.stroke}},o.prototype._calcRadius=function(t,e){void 0===e&&(e=this._dotSize());var i;return i=this.showPerspective?e/-t.trans.z:e*(-this.eye.z/this.camera.getArmLength()),i<0&&(i=0),i},o.prototype._redrawBarGraphPoint=function(t,e){var i=this.xBarWidth/2,o=this.yBarWidth/2,n=this._getColorsRegular(e);this._redrawBar(t,e,i,o,n.fill,n.border)},o.prototype._redrawBarColorGraphPoint=function(t,e){var i=this.xBarWidth/2,o=this.yBarWidth/2,n=this._getColorsColor(e);this._redrawBar(t,e,i,o,n.fill,n.border)},o.prototype._redrawBarSizeGraphPoint=function(t,e){var i=(e.point.value-this.valueRange.min)/this.valueRange.range(),o=this.xBarWidth/2*(.8*i+.2),n=this.yBarWidth/2*(.8*i+.2),s=this._getColorsSize();this._redrawBar(t,e,o,n,s.fill,s.border)},o.prototype._redrawDotGraphPoint=function(t,e){var i=this._getColorsRegular(e);this._drawCircle(t,e,i.fill,i.border)},o.prototype._redrawDotLineGraphPoint=function(t,e){var i=this._convert3Dto2D(e.bottom);t.lineWidth=1,this._line(t,i,e.screen,this.gridColor),this._redrawDotGraphPoint(t,e)},o.prototype._redrawDotColorGraphPoint=function(t,e){var i=this._getColorsColor(e);this._drawCircle(t,e,i.fill,i.border)},o.prototype._redrawDotSizeGraphPoint=function(t,e){var i=this._dotSize(),o=(e.point.value-this.valueRange.min)/this.valueRange.range(),n=i*this.dotSizeMinFraction,s=i*this.dotSizeMaxFraction-n,r=n+s*o,a=this._getColorsSize();this._drawCircle(t,e,a.fill,a.border,r)},o.prototype._redrawSurfaceGraphPoint=function(t,e){var i=e.pointRight,o=e.pointTop,n=e.pointCross;if(void 0!==e&&void 0!==i&&void 0!==o&&void 0!==n){var s,r,a=!0;if(this.showGrayBottom||this.showShadow){var h=l.subtract(n.trans,e.trans),d=l.subtract(o.trans,i.trans),u=l.crossProduct(h,d),c=u.length();a=u.z>0}if(a){var p,f=(e.point.z+i.point.z+o.point.z+n.point.z)/4,m=240*(1-(f-this.zRange.min)*this.scale.z/this.verticalRatio);this.showShadow?(p=Math.min(1+u.x/c/2,1),s=this._hsv2rgb(m,1,p),r=s):(p=1,s=this._hsv2rgb(m,1,p),r=this.axisColor)}else s="gray",r=this.axisColor;t.lineWidth=this._getStrokeWidth(e);var v=[e,i,n,o];this._polygon(t,v,s,r)}},o.prototype._drawGridLine=function(t,e,i){if(void 0!==e&&void 0!==i){var o=(e.point.z+i.point.z)/2,n=240*(1-(o-this.zRange.min)*this.scale.z/this.verticalRatio);t.lineWidth=2*this._getStrokeWidth(e),t.strokeStyle=this._hsv2rgb(n,1,1),this._line(t,e.screen,i.screen)}},o.prototype._redrawGridGraphPoint=function(t,e){this._drawGridLine(t,e,e.pointRight),this._drawGridLine(t,e,e.pointTop)},o.prototype._redrawLineGraphPoint=function(t,e){void 0!==e.pointNext&&(t.lineWidth=this._getStrokeWidth(e),t.strokeStyle=this.dataColor.stroke,this._line(t,e.screen,e.pointNext.screen))},o.prototype._redrawDataGraph=function(){var t,e=this._getContext();if(!(void 0===this.dataPoints||this.dataPoints.length<=0))for(this._calcTranslations(this.dataPoints),t=0;t<this.dataPoints.length;t++){var i=this.dataPoints[t];this._pointDrawingMethod.call(this,e,i)}},o.prototype._storeMousePosition=function(t){this.startMouseX=n(t),this.startMouseY=s(t),this._startCameraOffset=this.camera.getOffset()},o.prototype._onMouseDown=function(t){if(t=t||window.event,this.leftButtonDown&&this._onMouseUp(t),this.leftButtonDown=t.which?1===t.which:1===t.button,this.leftButtonDown||this.touchDown){this._storeMousePosition(t),this.startStart=new Date(this.start),this.startEnd=new Date(this.end),this.startArmRotation=this.camera.getArmRotation(),this.frame.style.cursor="move";var e=this;this.onmousemove=function(t){e._onMouseMove(t)},this.onmouseup=function(t){e._onMouseUp(t)},d.addEventListener(document,"mousemove",e.onmousemove),d.addEventListener(document,"mouseup",e.onmouseup),d.preventDefault(t)}},o.prototype._onMouseMove=function(t){this.moving=!0,t=t||window.event;var e=parseFloat(n(t))-this.startMouseX,i=parseFloat(s(t))-this.startMouseY;if(t&&!0===t.ctrlKey){var o=.5*this.frame.clientWidth,r=.5*this.frame.clientHeight,a=(this._startCameraOffset.x||0)-e/o*this.camera.armLength*.8,h=(this._startCameraOffset.y||0)+i/r*this.camera.armLength*.8;this.camera.setOffset(a,h),this._storeMousePosition(t)}else{var l=this.startArmRotation.horizontal+e/200,u=this.startArmRotation.vertical+i/200,c=Math.sin(4/360*2*Math.PI);Math.abs(Math.sin(l))<c&&(l=Math.round(l/Math.PI)*Math.PI-.001),Math.abs(Math.cos(l))<c&&(l=(Math.round(l/Math.PI-.5)+.5)*Math.PI-.001),Math.abs(Math.sin(u))<c&&(u=Math.round(u/Math.PI)*Math.PI),Math.abs(Math.cos(u))<c&&(u=(Math.round(u/Math.PI-.5)+.5)*Math.PI),this.camera.setArmRotation(l,u)}this.redraw();var p=this.getCameraPosition();this.emit("cameraPositionChange",p),d.preventDefault(t)},o.prototype._onMouseUp=function(t){this.frame.style.cursor="auto",this.leftButtonDown=!1,d.removeEventListener(document,"mousemove",this.onmousemove),d.removeEventListener(document,"mouseup",this.onmouseup),d.preventDefault(t)},o.prototype._onClick=function(t){if(this.onclick_callback){if(this.moving)this.moving=!1;else{var e=this.frame.getBoundingClientRect(),i=n(t)-e.left,o=s(t)-e.top,r=this._dataPointFromXY(i,o);r&&this.onclick_callback(r.point.data)}d.preventDefault(t)}},o.prototype._onTooltip=function(t){var e=this.frame.getBoundingClientRect(),i=n(t)-e.left,o=s(t)-e.top;if(this.showTooltip){if(this.tooltipTimeout&&clearTimeout(this.tooltipTimeout),this.leftButtonDown)return void this._hideTooltip();if(this.tooltip&&this.tooltip.dataPoint){var r=this._dataPointFromXY(i,o);r!==this.tooltip.dataPoint&&(r?this._showTooltip(r):this._hideTooltip())}else{var a=this;this.tooltipTimeout=setTimeout(function(){a.tooltipTimeout=null;var t=a._dataPointFromXY(i,o);t&&a._showTooltip(t)},300)}}},o.prototype._onTouchStart=function(t){this.touchDown=!0;var e=this;this.ontouchmove=function(t){e._onTouchMove(t)},this.ontouchend=function(t){e._onTouchEnd(t)},d.addEventListener(document,"touchmove",e.ontouchmove),d.addEventListener(document,"touchend",e.ontouchend),this._onMouseDown(t)},o.prototype._onTouchMove=function(t){this._onMouseMove(t)},o.prototype._onTouchEnd=function(t){this.touchDown=!1,d.removeEventListener(document,"touchmove",this.ontouchmove),d.removeEventListener(document,"touchend",this.ontouchend),this._onMouseUp(t)},o.prototype._onWheel=function(t){t||(t=window.event);var e=0;if(t.wheelDelta?e=t.wheelDelta/120:t.detail&&(e=-t.detail/3),e){var i=this.camera.getArmLength(),o=i*(1-e/10);this.camera.setArmLength(o),this.redraw(),this._hideTooltip()}var n=this.getCameraPosition();this.emit("cameraPositionChange",n),d.preventDefault(t)},o.prototype._insideTriangle=function(t,e){function i(t){return t>0?1:t<0?-1:0}var o=e[0],n=e[1],s=e[2],r=i((n.x-o.x)*(t.y-o.y)-(n.y-o.y)*(t.x-o.x)),a=i((s.x-n.x)*(t.y-n.y)-(s.y-n.y)*(t.x-n.x)),h=i((o.x-s.x)*(t.y-s.y)-(o.y-s.y)*(t.x-s.x));return!(0!=r&&0!=a&&r!=a||0!=a&&0!=h&&a!=h||0!=r&&0!=h&&r!=h)},o.prototype._dataPointFromXY=function(t,e){var i,n=null,s=null,r=null,a=new u(t,e);if(this.style===o.STYLE.BAR||this.style===o.STYLE.BARCOLOR||this.style===o.STYLE.BARSIZE)for(i=this.dataPoints.length-1;i>=0;i--){n=this.dataPoints[i];var h=n.surfaces;if(h)for(var d=h.length-1;d>=0;d--){var l=h[d],c=l.corners,p=[c[0].screen,c[1].screen,c[2].screen],f=[c[2].screen,c[3].screen,c[0].screen];if(this._insideTriangle(a,p)||this._insideTriangle(a,f))return n}}else for(i=0;i<this.dataPoints.length;i++){n=this.dataPoints[i];var m=n.screen;if(m){var v=Math.abs(t-m.x),g=Math.abs(e-m.y),y=Math.sqrt(v*v+g*g);(null===r||y<r)&&y<100&&(r=y,s=n)}}return s},o.prototype.hasBars=function(t){return t==o.STYLE.BAR||t==o.STYLE.BARCOLOR||t==o.STYLE.BARSIZE},o.prototype._showTooltip=function(t){var e,i,o;this.tooltip?(e=this.tooltip.dom.content,i=this.tooltip.dom.line,o=this.tooltip.dom.dot):(e=document.createElement("div"),(0,a.default)(e.style,{},this.tooltipStyle.content),e.style.position="absolute",i=document.createElement("div"),(0,a.default)(i.style,{},this.tooltipStyle.line),i.style.position="absolute",o=document.createElement("div"),(0,a.default)(o.style,{},this.tooltipStyle.dot),o.style.position="absolute",this.tooltip={dataPoint:null,dom:{content:e,line:i,dot:o}}),this._hideTooltip(),this.tooltip.dataPoint=t,"function"==typeof this.showTooltip?e.innerHTML=this.showTooltip(t.point):e.innerHTML="<table><tr><td>"+this.xLabel+":</td><td>"+t.point.x+"</td></tr><tr><td>"+this.yLabel+":</td><td>"+t.point.y+"</td></tr><tr><td>"+this.zLabel+":</td><td>"+t.point.z+"</td></tr></table>",e.style.left="0",e.style.top="0",this.frame.appendChild(e),this.frame.appendChild(i),this.frame.appendChild(o);var n=e.offsetWidth,s=e.offsetHeight,r=i.offsetHeight,h=o.offsetWidth,d=o.offsetHeight,l=t.screen.x-n/2;l=Math.min(Math.max(l,10),this.frame.clientWidth-10-n),i.style.left=t.screen.x+"px",i.style.top=t.screen.y-r+"px",e.style.left=l+"px",e.style.top=t.screen.y-r-s+"px",o.style.left=t.screen.x-h/2+"px",o.style.top=t.screen.y-d/2+"px"},o.prototype._hideTooltip=function(){if(this.tooltip){this.tooltip.dataPoint=null;for(var t in this.tooltip.dom)if(this.tooltip.dom.hasOwnProperty(t)){var e=this.tooltip.dom[t];e&&e.parentNode&&e.parentNode.removeChild(e)}}},o.prototype.setCameraPosition=function(t){f.setCameraPosition(t,this),this.redraw()},o.prototype.setSize=function(t,e){this._setSize(t,e),this.redraw()},t.exports=o},function(t,e,i){i(163),t.exports=i(7).Object.assign},function(t,e,i){var o=i(17);o(o.S+o.F,"Object",{assign:i(164)})},function(t,e,i){var o=i(33),n=i(63),s=i(42),r=i(41),a=i(78),h=Object.assign;t.exports=!h||i(28)(function(){var t={},e={},i=Symbol(),o="abcdefghijklmnopqrst";return t[i]=7,o.split("").forEach(function(t){e[t]=t}),7!=h({},t)[i]||Object.keys(h({},e)).join("")!=o})?function(t,e){for(var i=r(t),h=arguments.length,d=1,l=n.f,u=s.f;h>d;)for(var c,p=a(arguments[d++]),f=l?o(p).concat(l(p)):o(p),m=f.length,v=0;m>v;)u.call(p,c=f[v++])&&(i[c]=p[c]);return i}:h},function(t,e,i){t.exports={default:i(166),__esModule:!0}},function(t,e,i){i(167),t.exports=i(7).Math.sign},function(t,e,i){var o=i(17);o(o.S,"Math",{sign:i(168)})},function(t,e){t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},function(t,e,i){t.exports={default:i(170),__esModule:!0}},function(t,e,i){i(171);var o=i(7).Object;t.exports=function(t,e,i){return o.defineProperty(t,e,i)}},function(t,e,i){var o=i(17);o(o.S+o.F*!i(21),"Object",{defineProperty:i(20).f})},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var o="string",n="boolean",s="number",r={fill:{string:o},stroke:{string:o},strokeWidth:{number:s},__type__:{string:o,object:"object",undefined:"undefined"}},a={animationAutoStart:{boolean:n,undefined:"undefined"},animationInterval:{number:s},animationPreload:{boolean:n},axisColor:{string:o},backgroundColor:r,xBarWidth:{number:s,undefined:"undefined"},yBarWidth:{number:s,undefined:"undefined"},cameraPosition:{distance:{number:s},horizontal:{number:s},vertical:{number:s},__type__:{object:"object"}},xCenter:{string:o},yCenter:{string:o},dataColor:r,dotSizeMinFraction:{number:s},dotSizeMaxFraction:{number:s},dotSizeRatio:{number:s},filterLabel:{string:o},gridColor:{string:o},onclick:{function:"function"},keepAspectRatio:{boolean:n},xLabel:{string:o},yLabel:{string:o},zLabel:{string:o},legendLabel:{string:o},xMin:{number:s,undefined:"undefined"},yMin:{number:s,undefined:"undefined"},zMin:{number:s,undefined:"undefined"},xMax:{number:s,undefined:"undefined"},yMax:{number:s,undefined:"undefined"},zMax:{number:s,undefined:"undefined"},showAnimationControls:{boolean:n,undefined:"undefined"},showGrid:{boolean:n},showLegend:{boolean:n,undefined:"undefined"},showPerspective:{boolean:n},showShadow:{boolean:n},showXAxis:{boolean:n},showYAxis:{boolean:n},showZAxis:{boolean:n},xStep:{number:s,undefined:"undefined"},yStep:{number:s,undefined:"undefined"},zStep:{number:s,undefined:"undefined"},style:{number:s,string:["bar","bar-color","bar-size","dot","dot-line","dot-color","dot-size","line","grid","surface"]},tooltip:{boolean:n,function:"function"},tooltipStyle:{content:{color:{string:o},background:{string:o},border:{string:o},borderRadius:{string:o},boxShadow:{string:o},padding:{string:o},__type__:{object:"object"}},line:{borderLeft:{string:o},height:{string:o},width:{string:o},__type__:{object:"object"}},dot:{border:{string:o},borderRadius:{string:o},height:{string:o},width:{string:o},__type__:{object:"object"}},__type__:{object:"object"}},xValueLabel:{function:"function"},yValueLabel:{function:"function"},zValueLabel:{function:"function"},valueMax:{number:s,undefined:"undefined"},valueMin:{number:s,undefined:"undefined"},verticalRatio:{number:s},height:{string:o},width:{string:o},__type__:{object:"object"}};e.allOptions=a},function(t,e,i){function o(){this.dataTable=null}var n=i(11),s=i(12),r=i(174),a=i(96),h=i(94),d=i(34);o.prototype.initializeData=function(t,e,i){if(void 0!==e){Array.isArray(e)&&(e=new n(e));var o;if(!(e instanceof n||e instanceof s))throw new Error("Array, DataSet, or DataView expected");if(o=e.get(),0!=o.length){this.style=i,this.dataSet&&this.dataSet.off("*",this._onChange),this.dataSet=e,this.dataTable=o;var r=this;this._onChange=function(){t.setData(r.dataSet)},this.dataSet.on("*",this._onChange),this.colX="x",this.colY="y",this.colZ="z";var h=t.hasBars(i);if(h&&(void 0!==t.defaultXBarWidth?this.xBarWidth=t.defaultXBarWidth:this.xBarWidth=this.getSmallestDifference(o,this.colX)||1,void 0!==t.defaultYBarWidth?this.yBarWidth=t.defaultYBarWidth:this.yBarWidth=this.getSmallestDifference(o,this.colY)||1),this._initializeRange(o,this.colX,t,h),this._initializeRange(o,this.colY,t,h),this._initializeRange(o,this.colZ,t,!1),o[0].hasOwnProperty("style")){this.colValue="style";var d=this.getColumnRange(o,this.colValue);this._setRangeDefaults(d,t.defaultValueMin,t.defaultValueMax),this.valueRange=d}this.getDataTable()[0].hasOwnProperty("filter")&&void 0===this.dataFilter&&(this.dataFilter=new a(this,"filter",t),this.dataFilter.setOnLoadCallback(function(){t.redraw()}));return this.dataFilter?this.dataFilter._getDataPoints():this._getDataPoints(this.getDataTable())}}},o.prototype._collectRangeSettings=function(t,e){if(-1==["x","y","z"].indexOf(t))throw new Error("Column '"+t+"' invalid");var i=t.toUpperCase();return{barWidth:this[t+"BarWidth"],min:e["default"+i+"Min"],max:e["default"+i+"Max"],step:e["default"+i+"Step"],range_label:t+"Range",step_label:t+"Step"}},o.prototype._initializeRange=function(t,e,i,o){var n=this._collectRangeSettings(e,i),s=this.getColumnRange(t,e);o&&"z"!=e&&s.expand(n.barWidth/2),this._setRangeDefaults(s,n.min,n.max),this[n.range_label]=s,this[n.step_label]=void 0!==n.step?n.step:s.range()/5},o.prototype.getDistinctValues=function(t,e){void 0===e&&(e=this.dataTable);for(var i=[],o=0;o<e.length;o++){var n=e[o][t]||0;-1===i.indexOf(n)&&i.push(n)}return i.sort(function(t,e){return t-e})},o.prototype.getSmallestDifference=function(t,e){for(var i=this.getDistinctValues(t,e),o=null,n=1;n<i.length;n++){var s=i[n]-i[n-1];(null==o||o>s)&&(o=s)}return o},o.prototype.getColumnRange=function(t,e){for(var i=new r,o=0;o<t.length;o++){var n=t[o][e];i.adjust(n)}return i},o.prototype.getNumberOfRows=function(){return this.dataTable.length},o.prototype._setRangeDefaults=function(t,e,i){void 0!==e&&(t.min=e),void 0!==i&&(t.max=i),t.max<=t.min&&(t.max=t.min+1)},o.prototype.getDataTable=function(){return this.dataTable},o.prototype.getDataSet=function(){return this.dataSet},o.prototype.getDataPoints=function(t){for(var e=[],i=0;i<t.length;i++){var o=new d;o.x=t[i][this.colX]||0,o.y=t[i][this.colY]||0,o.z=t[i][this.colZ]||0,o.data=t[i],void 0!==this.colValue&&(o.value=t[i][this.colValue]||0);var n={};n.point=o,n.bottom=new d(o.x,o.y,this.zRange.min),n.trans=void 0,n.screen=void 0,e.push(n)}return e},o.prototype.initDataAsMatrix=function(t){var e,i,o,n,s=this.getDistinctValues(this.colX,t),r=this.getDistinctValues(this.colY,t),a=this.getDataPoints(t),h=[];for(o=0;o<a.length;o++){n=a[o];var d=s.indexOf(n.point.x),l=r.indexOf(n.point.y);void 0===h[d]&&(h[d]=[]),h[d][l]=n}for(e=0;e<h.length;e++)for(i=0;i<h[e].length;i++)h[e][i]&&(h[e][i].pointRight=e<h.length-1?h[e+1][i]:void 0,h[e][i].pointTop=i<h[e].length-1?h[e][i+1]:void 0,h[e][i].pointCross=e<h.length-1&&i<h[e].length-1?h[e+1][i+1]:void 0);return a},o.prototype.getInfo=function(){var t=this.dataFilter;if(t)return t.getLabel()+": "+t.getSelectedValue()},o.prototype.reload=function(){this.dataTable&&this.setData(this.dataTable)},o.prototype._getDataPoints=function(t){var e=[];if(this.style===h.STYLE.GRID||this.style===h.STYLE.SURFACE)e=this.initDataAsMatrix(t);else if(this._checkValueField(t),e=this.getDataPoints(t),this.style===h.STYLE.LINE)for(var i=0;i<e.length;i++)i>0&&(e[i-1].pointNext=e[i]);return e},o.prototype._checkValueField=function(t){if(this.style===h.STYLE.BARCOLOR||this.style===h.STYLE.BARSIZE||this.style===h.STYLE.DOTCOLOR||this.style===h.STYLE.DOTSIZE){if(void 0===this.colValue)throw new Error("Expected data to have field 'style' for graph style '"+this.style+"'");if(void 0===t[0][this.colValue])throw new Error("Expected data to have field '"+this.colValue+"' for graph style '"+this.style+"'")}},t.exports=o},function(t,e,i){function o(){this.min=void 0,this.max=void 0}o.prototype.adjust=function(t){void 0!==t&&((void 0===this.min||this.min>t)&&(this.min=t),(void 0===this.max||this.max<t)&&(this.max=t))},o.prototype.combine=function(t){this.add(t.min),this.add(t.max)},o.prototype.expand=function(t){if(void 0!==t){var e=this.min-t,i=this.max+t;if(e>i)throw new Error("Passed expansion value makes range invalid");this.min=e,this.max=i}},o.prototype.range=function(){return this.max-this.min},o.prototype.center=function(){return(this.min+this.max)/2},t.exports=o},function(t,e,i){var o,n,s;!function(i){n=[],o=i,void 0!==(s="function"==typeof o?o.apply(e,n):o)&&(t.exports=s)}(function(){var t=null;return function e(i,o){function n(t){return t.match(/[^ ]+/g)}function s(e){if("hammer.input"!==e.type){if(e.srcEvent._handled||(e.srcEvent._handled={}),e.srcEvent._handled[e.type])return;e.srcEvent._handled[e.type]=!0}var i=!1;e.stopPropagation=function(){i=!0};var o=e.srcEvent.stopPropagation.bind(e.srcEvent);"function"==typeof o&&(e.srcEvent.stopPropagation=function(){o(),e.stopPropagation()}),e.firstTarget=t;for(var n=t;n&&!i;){var s=n.hammer;if(s)for(var r,a=0;a<s.length;a++)if(r=s[a]._handlers[e.type])for(var h=0;h<r.length&&!i;h++)r[h](e);n=n.parentNode}}var r=o||{preventDefault:!1};if(i.Manager){var a=i,h=function(t,i){var o=Object.create(r);return i&&a.assign(o,i),e(new a(t,o),o)};return a.assign(h,a),h.Manager=function(t,i){var o=Object.create(r);return i&&a.assign(o,i),e(new a.Manager(t,o),o)},h}var d=Object.create(i),l=i.element;return l.hammer||(l.hammer=[]),l.hammer.push(d),i.on("hammer.input",function(e){!0!==r.preventDefault&&r.preventDefault!==e.pointerType||e.preventDefault(),e.isFirst&&(t=e.target)}),d._handlers={},d.on=function(t,e){return n(t).forEach(function(t){var o=d._handlers[t];o||(d._handlers[t]=o=[],i.on(t,s)),o.push(e)}),d},d.off=function(t,e){return n(t).forEach(function(t){var o=d._handlers[t];o&&(o=e?o.filter(function(t){return t!==e}):[],o.length>0?d._handlers[t]=o:(i.off(t,s),delete d._handlers[t]))}),d},d.emit=function(e,o){t=o.target,i.emit(e,o)},d.destroy=function(){var t=i.element.hammer,e=t.indexOf(d);-1!==e&&t.splice(e,1),t.length||delete i.element.hammer,d._handlers={},i.destroy()},d}})},function(t,e,i){var o;!function(n,s,r,a){function h(t,e,i){return setTimeout(p(t,i),e)}function d(t,e,i){return!!Array.isArray(t)&&(l(t,i[e],i),!0)}function l(t,e,i){var o;if(t)if(t.forEach)t.forEach(e,i);else if(t.length!==a)for(o=0;o<t.length;)e.call(i,t[o],o,t),o++;else for(o in t)t.hasOwnProperty(o)&&e.call(i,t[o],o,t)}function u(t,e,i){var o="DEPRECATED METHOD: "+e+"\n"+i+" AT \n";return function(){var e=new Error("get-stack-trace"),i=e&&e.stack?e.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",s=n.console&&(n.console.warn||n.console.log);return s&&s.call(n.console,o,i),t.apply(this,arguments)}}function c(t,e,i){var o,n=e.prototype;o=t.prototype=Object.create(n),o.constructor=t,o._super=n,i&&ft(o,i)}function p(t,e){return function(){return t.apply(e,arguments)}}function f(t,e){return typeof t==gt?t.apply(e?e[0]||a:a,e):t}function m(t,e){return t===a?e:t}function v(t,e,i){l(_(e),function(e){t.addEventListener(e,i,!1)})}function g(t,e,i){l(_(e),function(e){t.removeEventListener(e,i,!1)})}function y(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function b(t,e){return t.indexOf(e)>-1}function _(t){return t.trim().split(/\s+/g)}function w(t,e,i){if(t.indexOf&&!i)return t.indexOf(e);for(var o=0;o<t.length;){if(i&&t[o][i]==e||!i&&t[o]===e)return o;o++}return-1}function x(t){return Array.prototype.slice.call(t,0)}function k(t,e,i){for(var o=[],n=[],s=0;s<t.length;){var r=e?t[s][e]:t[s];w(n,r)<0&&o.push(t[s]),n[s]=r,s++}return i&&(o=e?o.sort(function(t,i){return t[e]>i[e]}):o.sort()),o}function S(t,e){for(var i,o,n=e[0].toUpperCase()+e.slice(1),s=0;s<mt.length;){if(i=mt[s],(o=i?i+n:e)in t)return o;s++}return a}function D(){return kt++}function M(t){var e=t.ownerDocument||t;return e.defaultView||e.parentWindow||n}function C(t,e){var i=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){f(t.options.enable,[t])&&i.handler(e)},this.init()}function O(t){var e=t.options.inputClass;return new(e||(Mt?W:Ct?V:Dt?q:H))(t,E)}function E(t,e,i){var o=i.pointers.length,n=i.changedPointers.length,s=e&Et&&o-n==0,r=e&(Pt|It)&&o-n==0;i.isFirst=!!s,i.isFinal=!!r,s&&(t.session={}),i.eventType=e,T(t,i),t.emit("hammer.input",i),t.recognize(i),t.session.prevInput=i}function T(t,e){var i=t.session,o=e.pointers,n=o.length;i.firstInput||(i.firstInput=N(e)),n>1&&!i.firstMultiple?i.firstMultiple=N(e):1===n&&(i.firstMultiple=!1);var s=i.firstInput,r=i.firstMultiple,a=r?r.center:s.center,h=e.center=R(o);e.timeStamp=_t(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=F(a,h),e.distance=L(a,h),P(i,e),e.offsetDirection=z(e.deltaX,e.deltaY);var d=A(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=bt(d.x)>bt(d.y)?d.x:d.y,e.scale=r?j(r.pointers,o):1,e.rotation=r?B(r.pointers,o):0,e.maxPointers=i.prevInput?e.pointers.length>i.prevInput.maxPointers?e.pointers.length:i.prevInput.maxPointers:e.pointers.length,I(i,e);var l=t.element;y(e.srcEvent.target,l)&&(l=e.srcEvent.target),e.target=l}function P(t,e){var i=e.center,o=t.offsetDelta||{},n=t.prevDelta||{},s=t.prevInput||{};e.eventType!==Et&&s.eventType!==Pt||(n=t.prevDelta={x:s.deltaX||0,y:s.deltaY||0},o=t.offsetDelta={x:i.x,y:i.y}),e.deltaX=n.x+(i.x-o.x),e.deltaY=n.y+(i.y-o.y)}function I(t,e){var i,o,n,s,r=t.lastInterval||e,h=e.timeStamp-r.timeStamp;if(e.eventType!=It&&(h>Ot||r.velocity===a)){var d=e.deltaX-r.deltaX,l=e.deltaY-r.deltaY,u=A(h,d,l);o=u.x,n=u.y,i=bt(u.x)>bt(u.y)?u.x:u.y,s=z(d,l),t.lastInterval=e}else i=r.velocity,o=r.velocityX,n=r.velocityY,s=r.direction;e.velocity=i,e.velocityX=o,e.velocityY=n,e.direction=s}function N(t){for(var e=[],i=0;i<t.pointers.length;)e[i]={clientX:yt(t.pointers[i].clientX),clientY:yt(t.pointers[i].clientY)},i++;return{timeStamp:_t(),pointers:e,center:R(e),deltaX:t.deltaX,deltaY:t.deltaY}}function R(t){var e=t.length;if(1===e)return{x:yt(t[0].clientX),y:yt(t[0].clientY)};for(var i=0,o=0,n=0;n<e;)i+=t[n].clientX,o+=t[n].clientY,n++;return{x:yt(i/e),y:yt(o/e)}}function A(t,e,i){return{x:e/t||0,y:i/t||0}}function z(t,e){return t===e?Nt:bt(t)>=bt(e)?t<0?Rt:At:e<0?zt:Lt}function L(t,e,i){i||(i=Ht);var o=e[i[0]]-t[i[0]],n=e[i[1]]-t[i[1]];return Math.sqrt(o*o+n*n)}function F(t,e,i){i||(i=Ht);var o=e[i[0]]-t[i[0]],n=e[i[1]]-t[i[1]];return 180*Math.atan2(n,o)/Math.PI}function B(t,e){return F(e[1],e[0],Wt)+F(t[1],t[0],Wt)}function j(t,e){return L(e[0],e[1],Wt)/L(t[0],t[1],Wt)}function H(){this.evEl=Gt,this.evWin=Vt,this.pressed=!1,C.apply(this,arguments)}function W(){this.evEl=Xt,this.evWin=Zt,C.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function Y(){this.evTarget=Jt,this.evWin=$t,this.started=!1,C.apply(this,arguments)}function G(t,e){var i=x(t.touches),o=x(t.changedTouches);return e&(Pt|It)&&(i=k(i.concat(o),"identifier",!0)),[i,o]}function V(){this.evTarget=te,this.targetIds={},C.apply(this,arguments)}function U(t,e){var i=x(t.touches),o=this.targetIds;if(e&(Et|Tt)&&1===i.length)return o[i[0].identifier]=!0,[i,i];var n,s,r=x(t.changedTouches),a=[],h=this.target;if(s=i.filter(function(t){return y(t.target,h)}),e===Et)for(n=0;n<s.length;)o[s[n].identifier]=!0,n++;for(n=0;n<r.length;)o[r[n].identifier]&&a.push(r[n]),e&(Pt|It)&&delete o[r[n].identifier],n++;return a.length?[k(s.concat(a),"identifier",!0),a]:void 0}function q(){C.apply(this,arguments);var t=p(this.handler,this);this.touch=new V(this.manager,t),this.mouse=new H(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}function X(t,e){t&Et?(this.primaryTouch=e.changedPointers[0].identifier,Z.call(this,e)):t&(Pt|It)&&Z.call(this,e)}function Z(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var i={x:e.clientX,y:e.clientY};this.lastTouches.push(i);var o=this.lastTouches,n=function(){var t=o.indexOf(i);t>-1&&o.splice(t,1)};setTimeout(n,ee)}}function K(t){for(var e=t.srcEvent.clientX,i=t.srcEvent.clientY,o=0;o<this.lastTouches.length;o++){var n=this.lastTouches[o],s=Math.abs(e-n.x),r=Math.abs(i-n.y);if(s<=ie&&r<=ie)return!0}return!1}function J(t,e){this.manager=t,this.set(e)}function $(t){if(b(t,ae))return ae;var e=b(t,he),i=b(t,de);return e&&i?ae:e||i?e?he:de:b(t,re)?re:se}function Q(t){this.options=ft({},this.defaults,t||{}),this.id=D(),this.manager=null,this.options.enable=m(this.options.enable,!0),this.state=ue,this.simultaneous={},this.requireFail=[]} +function tt(t){return t&ve?"cancel":t&fe?"end":t&pe?"move":t&ce?"start":""}function et(t){return t==Lt?"down":t==zt?"up":t==Rt?"left":t==At?"right":""}function it(t,e){var i=e.manager;return i?i.get(t):t}function ot(){Q.apply(this,arguments)}function nt(){ot.apply(this,arguments),this.pX=null,this.pY=null}function st(){ot.apply(this,arguments)}function rt(){Q.apply(this,arguments),this._timer=null,this._input=null}function at(){ot.apply(this,arguments)}function ht(){ot.apply(this,arguments)}function dt(){Q.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function lt(t,e){return e=e||{},e.recognizers=m(e.recognizers,lt.defaults.preset),new ut(t,e)}function ut(t,e){this.options=ft({},lt.defaults,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=O(this),this.touchAction=new J(this,this.options.touchAction),ct(this,!0),l(this.options.recognizers,function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])},this)}function ct(t,e){var i=t.element;if(i.style){var o;l(t.options.cssProps,function(n,s){o=S(i.style,s),e?(t.oldCssProps[o]=i.style[o],i.style[o]=n):i.style[o]=t.oldCssProps[o]||""}),e||(t.oldCssProps={})}}function pt(t,e){var i=s.createEvent("Event");i.initEvent(t,!0,!0),i.gesture=e,e.target.dispatchEvent(i)}var ft,mt=["","webkit","Moz","MS","ms","o"],vt=s.createElement("div"),gt="function",yt=Math.round,bt=Math.abs,_t=Date.now;ft="function"!=typeof Object.assign?function(t){if(t===a||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),i=1;i<arguments.length;i++){var o=arguments[i];if(o!==a&&null!==o)for(var n in o)o.hasOwnProperty(n)&&(e[n]=o[n])}return e}:Object.assign;var wt=u(function(t,e,i){for(var o=Object.keys(e),n=0;n<o.length;)(!i||i&&t[o[n]]===a)&&(t[o[n]]=e[o[n]]),n++;return t},"extend","Use `assign`."),xt=u(function(t,e){return wt(t,e,!0)},"merge","Use `assign`."),kt=1,St=/mobile|tablet|ip(ad|hone|od)|android/i,Dt="ontouchstart"in n,Mt=S(n,"PointerEvent")!==a,Ct=Dt&&St.test(navigator.userAgent),Ot=25,Et=1,Tt=2,Pt=4,It=8,Nt=1,Rt=2,At=4,zt=8,Lt=16,Ft=Rt|At,Bt=zt|Lt,jt=Ft|Bt,Ht=["x","y"],Wt=["clientX","clientY"];C.prototype={handler:function(){},init:function(){this.evEl&&v(this.element,this.evEl,this.domHandler),this.evTarget&&v(this.target,this.evTarget,this.domHandler),this.evWin&&v(M(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&g(this.element,this.evEl,this.domHandler),this.evTarget&&g(this.target,this.evTarget,this.domHandler),this.evWin&&g(M(this.element),this.evWin,this.domHandler)}};var Yt={mousedown:Et,mousemove:Tt,mouseup:Pt},Gt="mousedown",Vt="mousemove mouseup";c(H,C,{handler:function(t){var e=Yt[t.type];e&Et&&0===t.button&&(this.pressed=!0),e&Tt&&1!==t.which&&(e=Pt),this.pressed&&(e&Pt&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:"mouse",srcEvent:t}))}});var Ut={pointerdown:Et,pointermove:Tt,pointerup:Pt,pointercancel:It,pointerout:It},qt={2:"touch",3:"pen",4:"mouse",5:"kinect"},Xt="pointerdown",Zt="pointermove pointerup pointercancel";n.MSPointerEvent&&!n.PointerEvent&&(Xt="MSPointerDown",Zt="MSPointerMove MSPointerUp MSPointerCancel"),c(W,C,{handler:function(t){var e=this.store,i=!1,o=t.type.toLowerCase().replace("ms",""),n=Ut[o],s=qt[t.pointerType]||t.pointerType,r="touch"==s,a=w(e,t.pointerId,"pointerId");n&Et&&(0===t.button||r)?a<0&&(e.push(t),a=e.length-1):n&(Pt|It)&&(i=!0),a<0||(e[a]=t,this.callback(this.manager,n,{pointers:e,changedPointers:[t],pointerType:s,srcEvent:t}),i&&e.splice(a,1))}});var Kt={touchstart:Et,touchmove:Tt,touchend:Pt,touchcancel:It},Jt="touchstart",$t="touchstart touchmove touchend touchcancel";c(Y,C,{handler:function(t){var e=Kt[t.type];if(e===Et&&(this.started=!0),this.started){var i=G.call(this,t,e);e&(Pt|It)&&i[0].length-i[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:i[0],changedPointers:i[1],pointerType:"touch",srcEvent:t})}}});var Qt={touchstart:Et,touchmove:Tt,touchend:Pt,touchcancel:It},te="touchstart touchmove touchend touchcancel";c(V,C,{handler:function(t){var e=Qt[t.type],i=U.call(this,t,e);i&&this.callback(this.manager,e,{pointers:i[0],changedPointers:i[1],pointerType:"touch",srcEvent:t})}});var ee=2500,ie=25;c(q,C,{handler:function(t,e,i){var o="touch"==i.pointerType,n="mouse"==i.pointerType;if(!(n&&i.sourceCapabilities&&i.sourceCapabilities.firesTouchEvents)){if(o)X.call(this,e,i);else if(n&&K.call(this,i))return;this.callback(t,e,i)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var oe=S(vt.style,"touchAction"),ne=oe!==a,se="auto",re="manipulation",ae="none",he="pan-x",de="pan-y",le=function(){if(!ne)return!1;var t={},e=n.CSS&&n.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(i){t[i]=!e||n.CSS.supports("touch-action",i)}),t}();J.prototype={set:function(t){"compute"==t&&(t=this.compute()),ne&&this.manager.element.style&&le[t]&&(this.manager.element.style[oe]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return l(this.manager.recognizers,function(e){f(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))}),$(t.join(" "))},preventDefaults:function(t){var e=t.srcEvent,i=t.offsetDirection;if(this.manager.session.prevented)return void e.preventDefault();var o=this.actions,n=b(o,ae)&&!le[ae],s=b(o,de)&&!le[de],r=b(o,he)&&!le[he];if(n){var a=1===t.pointers.length,h=t.distance<2,d=t.deltaTime<250;if(a&&h&&d)return}return r&&s?void 0:n||s&&i&Ft||r&&i&Bt?this.preventSrc(e):void 0},preventSrc:function(t){this.manager.session.prevented=!0,t.preventDefault()}};var ue=1,ce=2,pe=4,fe=8,me=fe,ve=16;Q.prototype={defaults:{},set:function(t){return ft(this.options,t),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(d(t,"recognizeWith",this))return this;var e=this.simultaneous;return t=it(t,this),e[t.id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return d(t,"dropRecognizeWith",this)?this:(t=it(t,this),delete this.simultaneous[t.id],this)},requireFailure:function(t){if(d(t,"requireFailure",this))return this;var e=this.requireFail;return t=it(t,this),-1===w(e,t)&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(d(t,"dropRequireFailure",this))return this;t=it(t,this);var e=w(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){function e(e){i.manager.emit(e,t)}var i=this,o=this.state;o<fe&&e(i.options.event+tt(o)),e(i.options.event),t.additionalEvent&&e(t.additionalEvent),o>=fe&&e(i.options.event+tt(o))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=32},canEmit:function(){for(var t=0;t<this.requireFail.length;){if(!(this.requireFail[t].state&(32|ue)))return!1;t++}return!0},recognize:function(t){var e=ft({},t);if(!f(this.options.enable,[this,e]))return this.reset(),void(this.state=32);this.state&(me|ve|32)&&(this.state=ue),this.state=this.process(e),this.state&(ce|pe|fe|ve)&&this.tryEmit(e)},process:function(t){},getTouchAction:function(){},reset:function(){}},c(ot,Q,{defaults:{pointers:1},attrTest:function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},process:function(t){var e=this.state,i=t.eventType,o=e&(ce|pe),n=this.attrTest(t);return o&&(i&It||!n)?e|ve:o||n?i&Pt?e|fe:e&ce?e|pe:ce:32}}),c(nt,ot,{defaults:{event:"pan",threshold:10,pointers:1,direction:jt},getTouchAction:function(){var t=this.options.direction,e=[];return t&Ft&&e.push(de),t&Bt&&e.push(he),e},directionTest:function(t){var e=this.options,i=!0,o=t.distance,n=t.direction,s=t.deltaX,r=t.deltaY;return n&e.direction||(e.direction&Ft?(n=0===s?Nt:s<0?Rt:At,i=s!=this.pX,o=Math.abs(t.deltaX)):(n=0===r?Nt:r<0?zt:Lt,i=r!=this.pY,o=Math.abs(t.deltaY))),t.direction=n,i&&o>e.threshold&&n&e.direction},attrTest:function(t){return ot.prototype.attrTest.call(this,t)&&(this.state&ce||!(this.state&ce)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=et(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),c(st,ot,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[ae]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||this.state&ce)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),c(rt,Q,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[se]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,o=t.distance<e.threshold,n=t.deltaTime>e.time;if(this._input=t,!o||!i||t.eventType&(Pt|It)&&!n)this.reset();else if(t.eventType&Et)this.reset(),this._timer=h(function(){this.state=me,this.tryEmit()},e.time,this);else if(t.eventType&Pt)return me;return 32},reset:function(){clearTimeout(this._timer)},emit:function(t){this.state===me&&(t&&t.eventType&Pt?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=_t(),this.manager.emit(this.options.event,this._input)))}}),c(at,ot,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[ae]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||this.state&ce)}}),c(ht,ot,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:Ft|Bt,pointers:1},getTouchAction:function(){return nt.prototype.getTouchAction.call(this)},attrTest:function(t){var e,i=this.options.direction;return i&(Ft|Bt)?e=t.overallVelocity:i&Ft?e=t.overallVelocityX:i&Bt&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&i&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&bt(e)>this.options.velocity&&t.eventType&Pt},emit:function(t){var e=et(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),c(dt,Q,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[re]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,o=t.distance<e.threshold,n=t.deltaTime<e.time;if(this.reset(),t.eventType&Et&&0===this.count)return this.failTimeout();if(o&&n&&i){if(t.eventType!=Pt)return this.failTimeout();var s=!this.pTime||t.timeStamp-this.pTime<e.interval,r=!this.pCenter||L(this.pCenter,t.center)<e.posThreshold;this.pTime=t.timeStamp,this.pCenter=t.center,r&&s?this.count+=1:this.count=1,this._input=t;if(0===this.count%e.taps)return this.hasRequireFailures()?(this._timer=h(function(){this.state=me,this.tryEmit()},e.interval,this),ce):me}return 32},failTimeout:function(){return this._timer=h(function(){this.state=32},this.options.interval,this),32},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==me&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),lt.VERSION="2.0.7",lt.defaults={domEvents:!1,touchAction:"compute",enable:!0,inputTarget:null,inputClass:null,preset:[[at,{enable:!1}],[st,{enable:!1},["rotate"]],[ht,{direction:Ft}],[nt,{direction:Ft},["swipe"]],[dt],[dt,{event:"doubletap",taps:2},["tap"]],[rt]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};ut.prototype={set:function(t){return ft(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},stop:function(t){this.session.stopped=t?2:1},recognize:function(t){var e=this.session;if(!e.stopped){this.touchAction.preventDefaults(t);var i,o=this.recognizers,n=e.curRecognizer;(!n||n&&n.state&me)&&(n=e.curRecognizer=null);for(var s=0;s<o.length;)i=o[s],2===e.stopped||n&&i!=n&&!i.canRecognizeWith(n)?i.reset():i.recognize(t),!n&&i.state&(ce|pe|fe)&&(n=e.curRecognizer=i),s++}},get:function(t){if(t instanceof Q)return t;for(var e=this.recognizers,i=0;i<e.length;i++)if(e[i].options.event==t)return e[i];return null},add:function(t){if(d(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),t.manager=this,this.touchAction.update(),t},remove:function(t){if(d(t,"remove",this))return this;if(t=this.get(t)){var e=this.recognizers,i=w(e,t);-1!==i&&(e.splice(i,1),this.touchAction.update())}return this},on:function(t,e){if(t!==a&&e!==a){var i=this.handlers;return l(_(t),function(t){i[t]=i[t]||[],i[t].push(e)}),this}},off:function(t,e){if(t!==a){var i=this.handlers;return l(_(t),function(t){e?i[t]&&i[t].splice(w(i[t],e),1):delete i[t]}),this}},emit:function(t,e){this.options.domEvents&&pt(t,e);var i=this.handlers[t]&&this.handlers[t].slice();if(i&&i.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var o=0;o<i.length;)i[o](e),o++}},destroy:function(){this.element&&ct(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},ft(lt,{INPUT_START:Et,INPUT_MOVE:Tt,INPUT_END:Pt,INPUT_CANCEL:It,STATE_POSSIBLE:ue,STATE_BEGAN:ce,STATE_CHANGED:pe,STATE_ENDED:fe,STATE_RECOGNIZED:me,STATE_CANCELLED:ve,STATE_FAILED:32,DIRECTION_NONE:Nt,DIRECTION_LEFT:Rt,DIRECTION_RIGHT:At,DIRECTION_UP:zt,DIRECTION_DOWN:Lt,DIRECTION_HORIZONTAL:Ft,DIRECTION_VERTICAL:Bt,DIRECTION_ALL:jt,Manager:ut,Input:C,TouchAction:J,TouchInput:V,MouseInput:H,PointerEventInput:W,TouchMouseInput:q,SingleTouchInput:Y,Recognizer:Q,AttrRecognizer:ot,Tap:dt,Pan:nt,Swipe:ht,Pinch:st,Rotate:at,Press:rt,on:v,off:g,each:l,merge:xt,extend:wt,assign:ft,inherit:c,bindFn:p,prefixed:S}),(void 0!==n?n:"undefined"!=typeof self?self:{}).Hammer=lt,(o=function(){return lt}.call(e,i,e,t))!==a&&(t.exports=o)}(window,document)},function(t,e,i){e.util=i(2),e.DOMutil=i(14),e.DataSet=i(11),e.DataView=i(12),e.Queue=i(43),e.Timeline=i(178),e.Graph2d=i(180),e.timeline={Core:i(65),DateUtil:i(36),Range:i(64),stack:i(100),TimeStep:i(66),components:{items:{Item:i(38),BackgroundItem:i(103),BoxItem:i(101),PointItem:i(102),RangeItem:i(70)},BackgroundGroup:i(69),Component:i(16),CurrentTime:i(67),CustomTime:i(46),DataAxis:i(107),DataScale:i(108),GraphGroup:i(109),Group:i(68),ItemSet:i(99),Legend:i(112),LineGraph:i(106),TimeAxis:i(45)}},e.moment=i(9),e.Hammer=i(10),e.keycharm=i(35)},function(t,e,i){function o(t,e,i,n){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(!(Array.isArray(i)||i instanceof d||i instanceof l)&&i instanceof Object){var s=n;n=i,i=s}n&&n.throttleRedraw&&console.warn('Timeline option "throttleRedraw" is DEPRICATED and no longer supported. It will be removed in the next MAJOR release.');var r=this;if(this.defaultOptions={start:null,end:null,autoResize:!0,orientation:{axis:"bottom",item:"bottom"},moment:a,width:null,height:null,maxHeight:null,minHeight:null},this.options=h.deepExtend({},this.defaultOptions),this._create(t),!n||n&&void 0===n.rtl){this.dom.root.style.visibility="hidden";for(var c,m=this.dom.root;!c&&m;)c=window.getComputedStyle(m,null).direction,m=m.parentElement;this.options.rtl=c&&"rtl"==c.toLowerCase()}else this.options.rtl=n.rtl;this.options.rollingMode=n&&n.rollingMode,this.options.onInitialDrawComplete=n&&n.onInitialDrawComplete,this.components=[],this.body={dom:this.dom,domProps:this.props,emitter:{on:this.on.bind(this),off:this.off.bind(this),emit:this.emit.bind(this)},hiddenDates:[],util:{getScale:function(){return r.timeAxis.step.scale},getStep:function(){return r.timeAxis.step.step},toScreen:r._toScreen.bind(r),toGlobalScreen:r._toGlobalScreen.bind(r),toTime:r._toTime.bind(r),toGlobalTime:r._toGlobalTime.bind(r)}},this.range=new u(this.body,this.options),this.components.push(this.range),this.body.range=this.range,this.timeAxis=new p(this.body,this.options),this.timeAxis2=null,this.components.push(this.timeAxis),this.currentTime=new f(this.body,this.options),this.components.push(this.currentTime),this.itemSet=new v(this.body,this.options),this.components.push(this.itemSet),this.itemsData=null,this.groupsData=null,this.dom.root.onclick=function(t){r.emit("click",r.getEventProperties(t))},this.dom.root.ondblclick=function(t){r.emit("doubleClick",r.getEventProperties(t))},this.dom.root.oncontextmenu=function(t){r.emit("contextmenu",r.getEventProperties(t))},this.dom.root.onmouseover=function(t){r.emit("mouseOver",r.getEventProperties(t))},window.PointerEvent?(this.dom.root.onpointerdown=function(t){r.emit("mouseDown",r.getEventProperties(t))},this.dom.root.onpointermove=function(t){r.emit("mouseMove",r.getEventProperties(t))},this.dom.root.onpointerup=function(t){r.emit("mouseUp",r.getEventProperties(t))}):(this.dom.root.onmousemove=function(t){r.emit("mouseMove",r.getEventProperties(t))},this.dom.root.onmousedown=function(t){r.emit("mouseDown",r.getEventProperties(t))},this.dom.root.onmouseup=function(t){r.emit("mouseUp",r.getEventProperties(t))}),this.initialFitDone=!1,this.on("changed",function(){if(null!=this.itemsData&&!this.options.rollingMode){if(!r.initialFitDone)if(r.initialFitDone=!0,void 0!=r.options.start||void 0!=r.options.end){if(void 0==r.options.start||void 0==r.options.end)var t=r.getItemRange();var e=void 0!=r.options.start?r.options.start:t.min,i=void 0!=r.options.end?r.options.end:t.max;r.setWindow(e,i,{animation:!1})}else r.fit({animation:!1});!r.initialDrawDone&&r.initialRangeChangeDone&&(r.initialDrawDone=!0,r.dom.root.style.visibility="visible",r.options.onInitialDrawComplete&&setTimeout(function(){return r.options.onInitialDrawComplete()},0))}}),n&&this.setOptions(n),i&&this.setGroups(i),e&&this.setItems(e),this._redraw()}function n(t){return h.convert(t.data.start,"Date").valueOf()}function s(t){var e=void 0!=t.data.end?t.data.end:t.data.start;return h.convert(e,"Date").valueOf()}function r(t,e){var i=t.props.leftContainer.height,o=t.props.left.height,n=e.parent,s=n.top,r=!0,a=t.timeAxis.options.orientation.axis,h=function(){return"bottom"==a?n.height-e.top-e.height:e.top},d=-1*t._getScrollTop(),l=s+h(),u=e.height;return l<d?s+i<=s+h()+u&&(s+=h()-t.itemSet.options.margin.item.vertical):l+u>d+i?s+=h()+u-i+t.itemSet.options.margin.item.vertical:r=!1,s=Math.min(s,o-i),{shouldScroll:r,scrollOffset:s,itemTop:l}}var a=i(9),h=i(2),d=i(11),l=i(12),u=i(64),c=i(65),p=i(45),f=i(67),m=i(46),v=i(99),g=i(15).printStyle,y=i(105).allOptions,b=i(105).configureOptions,_=i(71).default,w=i(15).default;o.prototype=new c,o.prototype._createConfigurator=function(){return new _(this,this.dom.container,b)},o.prototype.redraw=function(){this.itemSet&&this.itemSet.markDirty({refreshItems:!0}),this._redraw()},o.prototype.setOptions=function(t){if(!0===w.validate(t,y)&&console.log("%cErrors have been found in the supplied options object.",g),c.prototype.setOptions.call(this,t),"type"in t&&t.type!==this.options.type){this.options.type=t.type;var e=this.itemsData;if(e){var i=this.getSelection();this.setItems(null),this.setItems(e),this.setSelection(i)}}},o.prototype.setItems=function(t){var e;e=t?t instanceof d||t instanceof l?t:new d(t,{type:{start:"Date",end:"Date"}}):null,this.itemsData=e,this.itemSet&&this.itemSet.setItems(e)},o.prototype.setGroups=function(t){var e;if(t){var i=function(t){return!1!==t.visible};e=t instanceof d||t instanceof l?new l(t,{filter:i}):new d(t.filter(i))}else e=null;this.groupsData=e,this.itemSet.setGroups(e)},o.prototype.setData=function(t){t&&t.groups&&this.setGroups(t.groups),t&&t.items&&this.setItems(t.items)},o.prototype.setSelection=function(t,e){this.itemSet&&this.itemSet.setSelection(t),e&&e.focus&&this.focus(t,e)},o.prototype.getSelection=function(){return this.itemSet&&this.itemSet.getSelection()||[]},o.prototype.focus=function(t,e){if(this.itemsData&&void 0!=t){var i=Array.isArray(t)?t:[t],o=this.itemsData.getDataSet().get(i,{type:{start:"Date",end:"Date"}}),n=null,s=null;if(o.forEach(function(t){var e=t.start.valueOf(),i="end"in t?t.end.valueOf():t.start.valueOf();(null===n||e<n)&&(n=e),(null===s||i>s)&&(s=i)}),null!==n&&null!==s){var a=this,h=this.itemSet.items[i[0]],d=-1*this._getScrollTop(),l=null,u=function(t,e,i){var o=r(a,h);if(l||(l=o),l.itemTop!=o.itemTop||l.shouldScroll){l.itemTop!=o.itemTop&&o.shouldScroll&&(l=o,d=-1*a._getScrollTop());var n=d,s=l.scrollOffset,u=i?s:n+(s-n)*t;a._setScrollTop(-u),e||a._redraw()}},c=function(){var t=r(a,h);t.shouldScroll&&t.itemTop!=l.itemTop&&(a._setScrollTop(-t.scrollOffset),a._redraw())},p=function(){c(),setTimeout(c,100)},f=(n+s)/2,m=Math.max(this.range.end-this.range.start,1.1*(s-n)),v=!e||void 0===e.animation||e.animation;v||(l={shouldScroll:!1,scrollOffset:-1,itemTop:-1}),this.range.setRange(f-m/2,f+m/2,{animation:v},p,u)}}},o.prototype.fit=function(t,e){var i,o=!t||void 0===t.animation||t.animation,n=this.itemsData&&this.itemsData.getDataSet();1===n.length&&void 0===n.get()[0].end?(i=this.getDataRange(),this.moveTo(i.min.valueOf(),{animation:o},e)):(i=this.getItemRange(),this.range.setRange(i.min,i.max,{animation:o},e))},o.prototype.getItemRange=function(){var t=this.getDataRange(),e=null!==t.min?t.min.valueOf():null,i=null!==t.max?t.max.valueOf():null,o=null,r=null;if(null!=e&&null!=i){var a=i-e;a<=0&&(a=10);var d=a/this.props.center.width,l={},u=0;h.forEach(this.itemSet.items,function(t,e){if(t.groupShowing){l[e]=t.redraw(!0),u=l[e].length}});if(u>0)for(var c=0;c<u;c++)h.forEach(l,function(t){t[c]()});if(h.forEach(this.itemSet.items,function(t){var a,h,l=n(t),u=s(t);this.options.rtl?(a=l-(t.getWidthRight()+10)*d,h=u+(t.getWidthLeft()+10)*d):(a=l-(t.getWidthLeft()+10)*d,h=u+(t.getWidthRight()+10)*d),a<e&&(e=a,o=t),h>i&&(i=h,r=t)}.bind(this)),o&&r){var p=o.getWidthLeft()+10,f=r.getWidthRight()+10,m=this.props.center.width-p-f;m>0&&(this.options.rtl?(e=n(o)-f*a/m,i=s(r)+p*a/m):(e=n(o)-p*a/m,i=s(r)+f*a/m))}}return{min:null!=e?new Date(e):null,max:null!=i?new Date(i):null}},o.prototype.getDataRange=function(){var t=null,e=null,i=this.itemsData&&this.itemsData.getDataSet();return i&&i.forEach(function(i){var o=h.convert(i.start,"Date").valueOf(),n=h.convert(void 0!=i.end?i.end:i.start,"Date").valueOf();(null===t||o<t)&&(t=o),(null===e||n>e)&&(e=n)}),{min:null!=t?new Date(t):null,max:null!=e?new Date(e):null}},o.prototype.getEventProperties=function(t){var e,i=t.center?t.center.x:t.clientX,o=t.center?t.center.y:t.clientY;e=this.options.rtl?h.getAbsoluteRight(this.dom.centerContainer)-i:i-h.getAbsoluteLeft(this.dom.centerContainer);var n=o-h.getAbsoluteTop(this.dom.centerContainer),s=this.itemSet.itemFromTarget(t),r=this.itemSet.groupFromTarget(t),a=m.customTimeFromTarget(t),d=this.itemSet.options.snap||null,l=this.body.util.getScale(),u=this.body.util.getStep(),c=this._toTime(e),p=d?d(c,l,u):c,f=h.getTarget(t),v=null;return null!=s?v="item":null!=a?v="custom-time":h.hasParent(f,this.timeAxis.dom.foreground)?v="axis":this.timeAxis2&&h.hasParent(f,this.timeAxis2.dom.foreground)?v="axis":h.hasParent(f,this.itemSet.dom.labelSet)?v="group-label":h.hasParent(f,this.currentTime.bar)?v="current-time":h.hasParent(f,this.dom.center)&&(v="background"),{event:t,item:s?s.id:null,group:r?r.groupId:null,what:v,pageX:t.srcEvent?t.srcEvent.pageX:t.pageX,pageY:t.srcEvent?t.srcEvent.pageY:t.pageY,x:e,y:n,time:c,snappedTime:p}},o.prototype.toggleRollingMode=function(){this.range.rolling?this.range.stopRolling():(void 0==this.options.rollingMode&&this.setOptions(this.options),this.range.startRolling())},t.exports=o},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(19),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(10),u=i(37),c=i(2),p=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;(0,a.default)(this,t),this.pixelRatio=e,this.generated=!1,this.centerCoordinates={x:144.5,y:144.5},this.r=289*.49,this.color={r:255,g:255,b:255,a:1},this.hueCircle=void 0,this.initialColor={r:255,g:255,b:255,a:1},this.previousColor=void 0,this.applied=!1,this.updateCallback=function(){},this.closeCallback=function(){},this._create()}return(0,d.default)(t,[{key:"insertTo",value:function(t){void 0!==this.hammer&&(this.hammer.destroy(),this.hammer=void 0),this.container=t,this.container.appendChild(this.frame),this._bindHammer(),this._setSize()}},{key:"setUpdateCallback",value:function(t){if("function"!=typeof t)throw new Error("Function attempted to set as colorPicker update callback is not a function.");this.updateCallback=t}},{key:"setCloseCallback",value:function(t){if("function"!=typeof t)throw new Error("Function attempted to set as colorPicker closing callback is not a function.");this.closeCallback=t}},{key:"_isColorString",value:function(t){var e={black:"#000000",navy:"#000080",darkblue:"#00008B",mediumblue:"#0000CD",blue:"#0000FF",darkgreen:"#006400",green:"#008000",teal:"#008080",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",lime:"#00FF00",springgreen:"#00FF7F",aqua:"#00FFFF",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",mediumaquamarine:"#66CDAA",dimgray:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",lightslategray:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",maroon:"#800000",purple:"#800080",olive:"#808000",gray:"#808080",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370D8",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",silver:"#C0C0C0",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgrey:"#D3D3D3",palevioletred:"#D87093",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",red:"#FF0000",fuchsia:"#FF00FF",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",yellow:"#FFFF00",lightyellow:"#FFFFE0",ivory:"#FFFFF0",white:"#FFFFFF"};if("string"==typeof t)return e[t]}},{key:"setColor",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("none"!==t){var i=void 0,o=this._isColorString(t);if(void 0!==o&&(t=o),!0===c.isString(t)){if(!0===c.isValidRGB(t)){var n=t.substr(4).substr(0,t.length-5).split(",");i={r:n[0],g:n[1],b:n[2],a:1}}else if(!0===c.isValidRGBA(t)){var r=t.substr(5).substr(0,t.length-6).split(",");i={r:r[0],g:r[1],b:r[2],a:r[3]}}else if(!0===c.isValidHex(t)){var a=c.hexToRGB(t);i={r:a.r,g:a.g,b:a.b,a:1}}}else if(t instanceof Object&&void 0!==t.r&&void 0!==t.g&&void 0!==t.b){var h=void 0!==t.a?t.a:"1.0";i={r:t.r,g:t.g,b:t.b,a:h}}if(void 0===i)throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: "+(0,s.default)(t));this._setColor(i,e)}}},{key:"show",value:function(){void 0!==this.closeCallback&&(this.closeCallback(),this.closeCallback=void 0),this.applied=!1,this.frame.style.display="block",this._generateHueCircle()}},{key:"_hide",value:function(){var t=this;!0===(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(this.previousColor=c.extend({},this.color)),!0===this.applied&&this.updateCallback(this.initialColor),this.frame.style.display="none",setTimeout(function(){void 0!==t.closeCallback&&(t.closeCallback(),t.closeCallback=void 0)},0)}},{key:"_save",value:function(){this.updateCallback(this.color),this.applied=!1,this._hide()}},{key:"_apply",value:function(){this.applied=!0,this.updateCallback(this.color),this._updatePicker(this.color)}},{key:"_loadLast",value:function(){void 0!==this.previousColor?this.setColor(this.previousColor,!1):alert("There is no last color to load...")}},{key:"_setColor",value:function(t){!0===(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&(this.initialColor=c.extend({},t)),this.color=t;var e=c.RGBToHSV(t.r,t.g,t.b),i=2*Math.PI,o=this.r*e.s,n=this.centerCoordinates.x+o*Math.sin(i*e.h),s=this.centerCoordinates.y+o*Math.cos(i*e.h);this.colorPickerSelector.style.left=n-.5*this.colorPickerSelector.clientWidth+"px",this.colorPickerSelector.style.top=s-.5*this.colorPickerSelector.clientHeight+"px",this._updatePicker(t)}},{key:"_setOpacity",value:function(t){this.color.a=t/100,this._updatePicker(this.color)}},{key:"_setBrightness",value:function(t){var e=c.RGBToHSV(this.color.r,this.color.g,this.color.b);e.v=t/100;var i=c.HSVToRGB(e.h,e.s,e.v);i.a=this.color.a,this.color=i,this._updatePicker()}},{key:"_updatePicker",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.color,e=c.RGBToHSV(t.r,t.g,t.b),i=this.colorPickerCanvas.getContext("2d");void 0===this.pixelRation&&(this.pixelRatio=(window.devicePixelRatio||1)/(i.webkitBackingStorePixelRatio||i.mozBackingStorePixelRatio||i.msBackingStorePixelRatio||i.oBackingStorePixelRatio||i.backingStorePixelRatio||1)),i.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);var o=this.colorPickerCanvas.clientWidth,n=this.colorPickerCanvas.clientHeight;i.clearRect(0,0,o,n),i.putImageData(this.hueCircle,0,0),i.fillStyle="rgba(0,0,0,"+(1-e.v)+")",i.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),i.fill(),this.brightnessRange.value=100*e.v,this.opacityRange.value=100*t.a,this.initialColorDiv.style.backgroundColor="rgba("+this.initialColor.r+","+this.initialColor.g+","+this.initialColor.b+","+this.initialColor.a+")",this.newColorDiv.style.backgroundColor="rgba("+this.color.r+","+this.color.g+","+this.color.b+","+this.color.a+")"}},{key:"_setSize",value:function(){this.colorPickerCanvas.style.width="100%",this.colorPickerCanvas.style.height="100%",this.colorPickerCanvas.width=289*this.pixelRatio,this.colorPickerCanvas.height=289*this.pixelRatio}},{key:"_create",value:function(){if(this.frame=document.createElement("div"),this.frame.className="vis-color-picker",this.colorPickerDiv=document.createElement("div"),this.colorPickerSelector=document.createElement("div"),this.colorPickerSelector.className="vis-selector",this.colorPickerDiv.appendChild(this.colorPickerSelector),this.colorPickerCanvas=document.createElement("canvas"),this.colorPickerDiv.appendChild(this.colorPickerCanvas),this.colorPickerCanvas.getContext){var t=this.colorPickerCanvas.getContext("2d") +;this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}else{var e=document.createElement("DIV");e.style.color="red",e.style.fontWeight="bold",e.style.padding="10px",e.innerHTML="Error: your browser does not support HTML canvas",this.colorPickerCanvas.appendChild(e)}this.colorPickerDiv.className="vis-color",this.opacityDiv=document.createElement("div"),this.opacityDiv.className="vis-opacity",this.brightnessDiv=document.createElement("div"),this.brightnessDiv.className="vis-brightness",this.arrowDiv=document.createElement("div"),this.arrowDiv.className="vis-arrow",this.opacityRange=document.createElement("input");try{this.opacityRange.type="range",this.opacityRange.min="0",this.opacityRange.max="100"}catch(t){}this.opacityRange.value="100",this.opacityRange.className="vis-range",this.brightnessRange=document.createElement("input");try{this.brightnessRange.type="range",this.brightnessRange.min="0",this.brightnessRange.max="100"}catch(t){}this.brightnessRange.value="100",this.brightnessRange.className="vis-range",this.opacityDiv.appendChild(this.opacityRange),this.brightnessDiv.appendChild(this.brightnessRange);var i=this;this.opacityRange.onchange=function(){i._setOpacity(this.value)},this.opacityRange.oninput=function(){i._setOpacity(this.value)},this.brightnessRange.onchange=function(){i._setBrightness(this.value)},this.brightnessRange.oninput=function(){i._setBrightness(this.value)},this.brightnessLabel=document.createElement("div"),this.brightnessLabel.className="vis-label vis-brightness",this.brightnessLabel.innerHTML="brightness:",this.opacityLabel=document.createElement("div"),this.opacityLabel.className="vis-label vis-opacity",this.opacityLabel.innerHTML="opacity:",this.newColorDiv=document.createElement("div"),this.newColorDiv.className="vis-new-color",this.newColorDiv.innerHTML="new",this.initialColorDiv=document.createElement("div"),this.initialColorDiv.className="vis-initial-color",this.initialColorDiv.innerHTML="initial",this.cancelButton=document.createElement("div"),this.cancelButton.className="vis-button vis-cancel",this.cancelButton.innerHTML="cancel",this.cancelButton.onclick=this._hide.bind(this,!1),this.applyButton=document.createElement("div"),this.applyButton.className="vis-button vis-apply",this.applyButton.innerHTML="apply",this.applyButton.onclick=this._apply.bind(this),this.saveButton=document.createElement("div"),this.saveButton.className="vis-button vis-save",this.saveButton.innerHTML="save",this.saveButton.onclick=this._save.bind(this),this.loadButton=document.createElement("div"),this.loadButton.className="vis-button vis-load",this.loadButton.innerHTML="load last",this.loadButton.onclick=this._loadLast.bind(this),this.frame.appendChild(this.colorPickerDiv),this.frame.appendChild(this.arrowDiv),this.frame.appendChild(this.brightnessLabel),this.frame.appendChild(this.brightnessDiv),this.frame.appendChild(this.opacityLabel),this.frame.appendChild(this.opacityDiv),this.frame.appendChild(this.newColorDiv),this.frame.appendChild(this.initialColorDiv),this.frame.appendChild(this.cancelButton),this.frame.appendChild(this.applyButton),this.frame.appendChild(this.saveButton),this.frame.appendChild(this.loadButton)}},{key:"_bindHammer",value:function(){var t=this;this.drag={},this.pinch={},this.hammer=new l(this.colorPickerCanvas),this.hammer.get("pinch").set({enable:!0}),u.onTouch(this.hammer,function(e){t._moveSelector(e)}),this.hammer.on("tap",function(e){t._moveSelector(e)}),this.hammer.on("panstart",function(e){t._moveSelector(e)}),this.hammer.on("panmove",function(e){t._moveSelector(e)}),this.hammer.on("panend",function(e){t._moveSelector(e)})}},{key:"_generateHueCircle",value:function(){if(!1===this.generated){var t=this.colorPickerCanvas.getContext("2d");void 0===this.pixelRation&&(this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)),t.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);var e=this.colorPickerCanvas.clientWidth,i=this.colorPickerCanvas.clientHeight;t.clearRect(0,0,e,i);var o=void 0,n=void 0,s=void 0,r=void 0;this.centerCoordinates={x:.5*e,y:.5*i},this.r=.49*e;var a=2*Math.PI/360,h=1/this.r,d=void 0;for(s=0;s<360;s++)for(r=0;r<this.r;r++)o=this.centerCoordinates.x+r*Math.sin(a*s),n=this.centerCoordinates.y+r*Math.cos(a*s),d=c.HSVToRGB(s*(1/360),r*h,1),t.fillStyle="rgb("+d.r+","+d.g+","+d.b+")",t.fillRect(o-.5,n-.5,2,2);t.strokeStyle="rgba(0,0,0,1)",t.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),t.stroke(),this.hueCircle=t.getImageData(0,0,e,i)}this.generated=!0}},{key:"_moveSelector",value:function(t){var e=this.colorPickerDiv.getBoundingClientRect(),i=t.center.x-e.left,o=t.center.y-e.top,n=.5*this.colorPickerDiv.clientHeight,s=.5*this.colorPickerDiv.clientWidth,r=i-s,a=o-n,h=Math.atan2(r,a),d=.98*Math.min(Math.sqrt(r*r+a*a),s),l=Math.cos(h)*d+n,u=Math.sin(h)*d+s;this.colorPickerSelector.style.top=l-.5*this.colorPickerSelector.clientHeight+"px",this.colorPickerSelector.style.left=u-.5*this.colorPickerSelector.clientWidth+"px";var p=h/(2*Math.PI);p=p<0?p+1:p;var f=d/this.r,m=c.RGBToHSV(this.color.r,this.color.g,this.color.b);m.h=p,m.s=f;var v=c.HSVToRGB(m.h,m.s,m.v);v.a=this.color.a,this.color=v,this.initialColorDiv.style.backgroundColor="rgba("+this.initialColor.r+","+this.initialColor.g+","+this.initialColor.b+","+this.initialColor.a+")",this.newColorDiv.style.backgroundColor="rgba("+this.color.r+","+this.color.g+","+this.color.b+","+this.color.a+")"}}]),t}();e.default=p},function(t,e,i){function o(t,e,i,o){if(!(Array.isArray(i)||i instanceof r||i instanceof a)&&i instanceof Object){var d=o;o=i,i=d}o&&o.throttleRedraw&&console.warn('Graph2d option "throttleRedraw" is DEPRICATED and no longer supported. It will be removed in the next MAJOR release.');var c=this;this.defaultOptions={start:null,end:null,autoResize:!0,orientation:{axis:"bottom",item:"bottom"},moment:n,width:null,height:null,maxHeight:null,minHeight:null},this.options=s.deepExtend({},this.defaultOptions),this._create(t),this.components=[],this.body={dom:this.dom,domProps:this.props,emitter:{on:this.on.bind(this),off:this.off.bind(this),emit:this.emit.bind(this)},hiddenDates:[],util:{toScreen:c._toScreen.bind(c),toGlobalScreen:c._toGlobalScreen.bind(c),toTime:c._toTime.bind(c),toGlobalTime:c._toGlobalTime.bind(c)}},this.range=new h(this.body),this.components.push(this.range),this.body.range=this.range,this.timeAxis=new l(this.body),this.components.push(this.timeAxis),this.currentTime=new u(this.body),this.components.push(this.currentTime),this.linegraph=new p(this.body),this.components.push(this.linegraph),this.itemsData=null,this.groupsData=null,this.on("tap",function(t){c.emit("click",c.getEventProperties(t))}),this.on("doubletap",function(t){c.emit("doubleClick",c.getEventProperties(t))}),this.dom.root.oncontextmenu=function(t){c.emit("contextmenu",c.getEventProperties(t))},o&&this.setOptions(o),i&&this.setGroups(i),e&&this.setItems(e),this._redraw()}var n=i(9),s=i(2),r=i(11),a=i(12),h=i(64),d=i(65),l=i(45),u=i(67),c=i(46),p=i(106),f=i(15).printStyle,m=i(113).allOptions,v=i(113).configureOptions,g=i(71).default,y=i(15).default;o.prototype=new d,o.prototype.setOptions=function(t){!0===y.validate(t,m)&&console.log("%cErrors have been found in the supplied options object.",f),d.prototype.setOptions.call(this,t)},o.prototype.setItems=function(t){var e,i=null==this.itemsData;if(e=t?t instanceof r||t instanceof a?t:new r(t,{type:{start:"Date",end:"Date"}}):null,this.itemsData=e,this.linegraph&&this.linegraph.setItems(e),i)if(void 0!=this.options.start||void 0!=this.options.end){var o=void 0!=this.options.start?this.options.start:null,n=void 0!=this.options.end?this.options.end:null;this.setWindow(o,n,{animation:!1})}else this.fit({animation:!1})},o.prototype.setGroups=function(t){var e;e=t?t instanceof r||t instanceof a?t:new r(t):null,this.groupsData=e,this.linegraph.setGroups(e)},o.prototype.getLegend=function(t,e,i){return void 0===e&&(e=15),void 0===i&&(i=15),void 0!==this.linegraph.groups[t]?this.linegraph.groups[t].getLegend(e,i):"cannot find group:'"+t+"'"},o.prototype.isGroupVisible=function(t){return void 0!==this.linegraph.groups[t]&&(this.linegraph.groups[t].visible&&(void 0===this.linegraph.options.groups.visibility[t]||1==this.linegraph.options.groups.visibility[t]))},o.prototype.getDataRange=function(){var t=null,e=null;for(var i in this.linegraph.groups)if(this.linegraph.groups.hasOwnProperty(i)&&1==this.linegraph.groups[i].visible)for(var o=0;o<this.linegraph.groups[i].itemsData.length;o++){var n=this.linegraph.groups[i].itemsData[o],r=s.convert(n.x,"Date").valueOf();t=null==t?r:t>r?r:t,e=null==e?r:e<r?r:e}return{min:null!=t?new Date(t):null,max:null!=e?new Date(e):null}},o.prototype.getEventProperties=function(t){var e=t.center?t.center.x:t.clientX,i=t.center?t.center.y:t.clientY,o=e-s.getAbsoluteLeft(this.dom.centerContainer),n=i-s.getAbsoluteTop(this.dom.centerContainer),r=this._toTime(o),a=c.customTimeFromTarget(t),h=s.getTarget(t),d=null;s.hasParent(h,this.timeAxis.dom.foreground)?d="axis":this.timeAxis2&&s.hasParent(h,this.timeAxis2.dom.foreground)?d="axis":s.hasParent(h,this.linegraph.yAxisLeft.dom.frame)?d="data-axis":s.hasParent(h,this.linegraph.yAxisRight.dom.frame)?d="data-axis":s.hasParent(h,this.linegraph.legendLeft.dom.frame)?d="legend":s.hasParent(h,this.linegraph.legendRight.dom.frame)?d="legend":null!=a?d="custom-time":s.hasParent(h,this.currentTime.bar)?d="current-time":s.hasParent(h,this.dom.center)&&(d="background");var l=[],u=this.linegraph.yAxisLeft,p=this.linegraph.yAxisRight;return!u.hidden&&this.itemsData.length>0&&l.push(u.screenToValue(n)),!p.hidden&&this.itemsData.length>0&&l.push(p.screenToValue(n)),{event:t,what:d,pageX:t.srcEvent?t.srcEvent.pageX:t.pageX,pageY:t.srcEvent?t.srcEvent.pageY:t.pageY,x:o,y:n,time:r,value:l}},o.prototype._createConfigurator=function(){return new g(this,this.dom.container,v)},t.exports=o},function(t,e,i){e.util=i(2),e.DOMutil=i(14),e.DataSet=i(11),e.DataView=i(12),e.Queue=i(43),e.Network=i(182),e.network={Images:i(116),dotparser:i(114),gephiParser:i(115),allOptions:i(122)},e.network.convertDot=function(t){return e.network.dotparser.DOTToGraph(t)},e.network.convertGephi=function(t,i){return e.network.gephiParser.parseGephi(t,i)},e.moment=i(9),e.Hammer=i(10),e.keycharm=i(35)},function(t,e,i){function o(t,e,i){var n=this;if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");this.options={},this.defaultOptions={locale:"en",locales:d,clickToUse:!1},s.extend(this.options,this.defaultOptions),this.body={container:t,nodes:{},nodeIndices:[],edges:{},edgeIndices:[],emitter:{on:this.on.bind(this),off:this.off.bind(this),emit:this.emit.bind(this),once:this.once.bind(this)},eventListeners:{onTap:function(){},onTouch:function(){},onDoubleTap:function(){},onHold:function(){},onDragStart:function(){},onDrag:function(){},onDragEnd:function(){},onMouseWheel:function(){},onPinch:function(){},onMouseMove:function(){},onRelease:function(){},onContext:function(){}},data:{nodes:null,edges:null},functions:{createNode:function(){},createEdge:function(){},getPointer:function(){}},modules:{},view:{scale:1,translation:{x:0,y:0}}},this.bindEventListeners(),this.images=new l(function(){return n.body.emitter.emit("_requestRedraw")}),this.groups=new u,this.canvas=new g(this.body),this.selectionHandler=new _(this.body,this.canvas),this.interactionHandler=new b(this.body,this.canvas,this.selectionHandler),this.view=new y(this.body,this.canvas),this.renderer=new v(this.body,this.canvas),this.physics=new f(this.body),this.layoutEngine=new w(this.body),this.clustering=new m(this.body),this.manipulation=new x(this.body,this.canvas,this.selectionHandler),this.nodesHandler=new c(this.body,this.images,this.groups,this.layoutEngine),this.edgesHandler=new p(this.body,this.images,this.groups),this.body.modules.kamadaKawai=new T(this.body,150,.05),this.body.modules.clustering=this.clustering,this.canvas._create(),this.setOptions(i),this.setData(e)}i(183);var n=i(44),s=i(2),r=i(114),a=i(115),h=i(97),d=i(184),l=i(116).default,u=i(186).default,c=i(187).default,p=i(214).default,f=i(220).default,m=i(227).default,v=i(229).default,g=i(230).default,y=i(231).default,b=i(232).default,_=i(234).default,w=i(235).default,x=i(237).default,k=i(71).default,S=i(15).default,D=i(15),M=D.printStyle,C=i(122),O=C.allOptions,E=C.configureOptions,T=i(238).default;n(o.prototype),o.prototype.setOptions=function(t){var e=this;if(void 0!==t){!0===S.validate(t,O)&&console.log("%cErrors have been found in the supplied options object.",M);var i=["locale","locales","clickToUse"];if(s.selectiveDeepExtend(i,this.options,t),t=this.layoutEngine.setOptions(t.layout,t),this.canvas.setOptions(t),this.groups.setOptions(t.groups),this.nodesHandler.setOptions(t.nodes),this.edgesHandler.setOptions(t.edges),this.physics.setOptions(t.physics),this.manipulation.setOptions(t.manipulation,t,this.options),this.interactionHandler.setOptions(t.interaction),this.renderer.setOptions(t.interaction),this.selectionHandler.setOptions(t.interaction),void 0!==t.groups&&this.body.emitter.emit("refreshNodes"),"configure"in t&&(this.configurator||(this.configurator=new k(this,this.body.container,E,this.canvas.pixelRatio)),this.configurator.setOptions(t.configure)),this.configurator&&!0===this.configurator.options.enabled){var o={nodes:{},edges:{},layout:{},interaction:{},manipulation:{},physics:{},global:{}};s.deepExtend(o.nodes,this.nodesHandler.options),s.deepExtend(o.edges,this.edgesHandler.options),s.deepExtend(o.layout,this.layoutEngine.options),s.deepExtend(o.interaction,this.selectionHandler.options),s.deepExtend(o.interaction,this.renderer.options),s.deepExtend(o.interaction,this.interactionHandler.options),s.deepExtend(o.manipulation,this.manipulation.options),s.deepExtend(o.physics,this.physics.options),s.deepExtend(o.global,this.canvas.options),s.deepExtend(o.global,this.options),this.configurator.setModuleOptions(o)}void 0!==t.clickToUse?!0===t.clickToUse?void 0===this.activator&&(this.activator=new h(this.canvas.frame),this.activator.on("change",function(){e.body.emitter.emit("activate")})):(void 0!==this.activator&&(this.activator.destroy(),delete this.activator),this.body.emitter.emit("activate")):this.body.emitter.emit("activate"),this.canvas.setSize(),this.body.emitter.emit("startSimulation")}},o.prototype._updateVisibleIndices=function(){var t=this.body.nodes,e=this.body.edges;this.body.nodeIndices=[],this.body.edgeIndices=[];for(var i in t)t.hasOwnProperty(i)&&(this.clustering._isClusteredNode(i)||!1!==t[i].options.hidden||this.body.nodeIndices.push(t[i].id));for(var o in e)if(e.hasOwnProperty(o)){var n=e[o],s=t[n.fromId],r=t[n.toId],a=void 0!==s&&void 0!==r,h=!this.clustering._isClusteredEdge(o)&&!1===n.options.hidden&&a&&!1===s.options.hidden&&!1===r.options.hidden;h&&this.body.edgeIndices.push(n.id)}},o.prototype.bindEventListeners=function(){var t=this;this.body.emitter.on("_dataChanged",function(){t.edgesHandler._updateState(),t.body.emitter.emit("_dataUpdated")}),this.body.emitter.on("_dataUpdated",function(){t.clustering._updateState(),t._updateVisibleIndices(),t._updateValueRange(t.body.nodes),t._updateValueRange(t.body.edges),t.body.emitter.emit("startSimulation"),t.body.emitter.emit("_requestRedraw")})},o.prototype.setData=function(t){if(this.body.emitter.emit("resetPhysics"),this.body.emitter.emit("_resetData"),this.selectionHandler.unselectAll(),t&&t.dot&&(t.nodes||t.edges))throw new SyntaxError('Data must contain either parameter "dot" or parameter pair "nodes" and "edges", but not both.');if(this.setOptions(t&&t.options),t&&t.dot){console.log("The dot property has been deprecated. Please use the static convertDot method to convert DOT into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertDot(dotString);");var e=r.DOTToGraph(t.dot);return void this.setData(e)}if(t&&t.gephi){console.log("The gephi property has been deprecated. Please use the static convertGephi method to convert gephi into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertGephi(gephiJson);");var i=a.parseGephi(t.gephi);return void this.setData(i)}this.nodesHandler.setData(t&&t.nodes,!0),this.edgesHandler.setData(t&&t.edges,!0),this.body.emitter.emit("_dataChanged"),this.body.emitter.emit("_dataLoaded"),this.body.emitter.emit("initPhysics")},o.prototype.destroy=function(){this.body.emitter.emit("destroy"),this.body.emitter.off(),this.off(),delete this.groups,delete this.canvas,delete this.selectionHandler,delete this.interactionHandler,delete this.view,delete this.renderer,delete this.physics,delete this.layoutEngine,delete this.clustering,delete this.manipulation,delete this.nodesHandler,delete this.edgesHandler,delete this.configurator,delete this.images;for(var t in this.body.nodes)this.body.nodes.hasOwnProperty(t)&&delete this.body.nodes[t];for(var e in this.body.edges)this.body.edges.hasOwnProperty(e)&&delete this.body.edges[e];s.recursiveDOMDelete(this.body.container)},o.prototype._updateValueRange=function(t){var e,i=void 0,o=void 0,n=0;for(e in t)if(t.hasOwnProperty(e)){var s=t[e].getValue();void 0!==s&&(i=void 0===i?s:Math.min(s,i),o=void 0===o?s:Math.max(s,o),n+=s)}if(void 0!==i&&void 0!==o)for(e in t)t.hasOwnProperty(e)&&t[e].setValueRange(i,o,n)},o.prototype.isActive=function(){return!this.activator||this.activator.active},o.prototype.setSize=function(){return this.canvas.setSize.apply(this.canvas,arguments)},o.prototype.canvasToDOM=function(){return this.canvas.canvasToDOM.apply(this.canvas,arguments)},o.prototype.DOMtoCanvas=function(){return this.canvas.DOMtoCanvas.apply(this.canvas,arguments)},o.prototype.findNode=function(){return this.clustering.findNode.apply(this.clustering,arguments)},o.prototype.isCluster=function(){return this.clustering.isCluster.apply(this.clustering,arguments)},o.prototype.openCluster=function(){return this.clustering.openCluster.apply(this.clustering,arguments)},o.prototype.cluster=function(){return this.clustering.cluster.apply(this.clustering,arguments)},o.prototype.getNodesInCluster=function(){return this.clustering.getNodesInCluster.apply(this.clustering,arguments)},o.prototype.clusterByConnection=function(){return this.clustering.clusterByConnection.apply(this.clustering,arguments)},o.prototype.clusterByHubsize=function(){return this.clustering.clusterByHubsize.apply(this.clustering,arguments)},o.prototype.clusterOutliers=function(){return this.clustering.clusterOutliers.apply(this.clustering,arguments)},o.prototype.getSeed=function(){return this.layoutEngine.getSeed.apply(this.layoutEngine,arguments)},o.prototype.enableEditMode=function(){return this.manipulation.enableEditMode.apply(this.manipulation,arguments)},o.prototype.disableEditMode=function(){return this.manipulation.disableEditMode.apply(this.manipulation,arguments)},o.prototype.addNodeMode=function(){return this.manipulation.addNodeMode.apply(this.manipulation,arguments)},o.prototype.editNode=function(){return this.manipulation.editNode.apply(this.manipulation,arguments)},o.prototype.editNodeMode=function(){return console.log("Deprecated: Please use editNode instead of editNodeMode."),this.manipulation.editNode.apply(this.manipulation,arguments)},o.prototype.addEdgeMode=function(){return this.manipulation.addEdgeMode.apply(this.manipulation,arguments)},o.prototype.editEdgeMode=function(){return this.manipulation.editEdgeMode.apply(this.manipulation,arguments)},o.prototype.deleteSelected=function(){return this.manipulation.deleteSelected.apply(this.manipulation,arguments)},o.prototype.getPositions=function(){return this.nodesHandler.getPositions.apply(this.nodesHandler,arguments)},o.prototype.storePositions=function(){return this.nodesHandler.storePositions.apply(this.nodesHandler,arguments)},o.prototype.moveNode=function(){return this.nodesHandler.moveNode.apply(this.nodesHandler,arguments)},o.prototype.getBoundingBox=function(){return this.nodesHandler.getBoundingBox.apply(this.nodesHandler,arguments)},o.prototype.getConnectedNodes=function(t){return void 0!==this.body.nodes[t]?this.nodesHandler.getConnectedNodes.apply(this.nodesHandler,arguments):this.edgesHandler.getConnectedNodes.apply(this.edgesHandler,arguments)},o.prototype.getConnectedEdges=function(){return this.nodesHandler.getConnectedEdges.apply(this.nodesHandler,arguments)},o.prototype.startSimulation=function(){return this.physics.startSimulation.apply(this.physics,arguments)},o.prototype.stopSimulation=function(){return this.physics.stopSimulation.apply(this.physics,arguments)},o.prototype.stabilize=function(){return this.physics.stabilize.apply(this.physics,arguments)},o.prototype.getSelection=function(){return this.selectionHandler.getSelection.apply(this.selectionHandler,arguments)},o.prototype.setSelection=function(){return this.selectionHandler.setSelection.apply(this.selectionHandler,arguments)},o.prototype.getSelectedNodes=function(){return this.selectionHandler.getSelectedNodes.apply(this.selectionHandler,arguments)},o.prototype.getSelectedEdges=function(){return this.selectionHandler.getSelectedEdges.apply(this.selectionHandler,arguments)},o.prototype.getNodeAt=function(){var t=this.selectionHandler.getNodeAt.apply(this.selectionHandler,arguments);return void 0!==t&&void 0!==t.id?t.id:t},o.prototype.getEdgeAt=function(){var t=this.selectionHandler.getEdgeAt.apply(this.selectionHandler,arguments);return void 0!==t&&void 0!==t.id?t.id:t},o.prototype.selectNodes=function(){return this.selectionHandler.selectNodes.apply(this.selectionHandler,arguments)},o.prototype.selectEdges=function(){return this.selectionHandler.selectEdges.apply(this.selectionHandler,arguments)},o.prototype.unselectAll=function(){this.selectionHandler.unselectAll.apply(this.selectionHandler,arguments),this.redraw()},o.prototype.redraw=function(){return this.renderer.redraw.apply(this.renderer,arguments)},o.prototype.getScale=function(){return this.view.getScale.apply(this.view,arguments)},o.prototype.getViewPosition=function(){return this.view.getViewPosition.apply(this.view,arguments)},o.prototype.fit=function(){return this.view.fit.apply(this.view,arguments)},o.prototype.moveTo=function(){return this.view.moveTo.apply(this.view,arguments)},o.prototype.focus=function(){return this.view.focus.apply(this.view,arguments)},o.prototype.releaseNode=function(){return this.view.releaseNode.apply(this.view,arguments)},o.prototype.getOptionsFromConfigurator=function(){var t={};return this.configurator&&(t=this.configurator.getOptions.apply(this.configurator)),t},t.exports=o},function(t,e,i){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.circle=function(t,e,i){this.beginPath(),this.arc(t,e,i,0,2*Math.PI,!1),this.closePath()},CanvasRenderingContext2D.prototype.square=function(t,e,i){this.beginPath(),this.rect(t-i,e-i,2*i,2*i),this.closePath()},CanvasRenderingContext2D.prototype.triangle=function(t,e,i){this.beginPath(),i*=1.15,e+=.275*i;var o=2*i,n=o/2,s=Math.sqrt(3)/6*o,r=Math.sqrt(o*o-n*n);this.moveTo(t,e-(r-s)),this.lineTo(t+n,e+s),this.lineTo(t-n,e+s),this.lineTo(t,e-(r-s)),this.closePath()},CanvasRenderingContext2D.prototype.triangleDown=function(t,e,i){this.beginPath(),i*=1.15,e-=.275*i;var o=2*i,n=o/2,s=Math.sqrt(3)/6*o,r=Math.sqrt(o*o-n*n);this.moveTo(t,e+(r-s)),this.lineTo(t+n,e-s),this.lineTo(t-n,e-s),this.lineTo(t,e+(r-s)),this.closePath()},CanvasRenderingContext2D.prototype.star=function(t,e,i){this.beginPath(),i*=.82,e+=.1*i;for(var o=0;o<10;o++){var n=o%2==0?1.3*i:.5*i;this.lineTo(t+n*Math.sin(2*o*Math.PI/10),e-n*Math.cos(2*o*Math.PI/10))}this.closePath()},CanvasRenderingContext2D.prototype.diamond=function(t,e,i){this.beginPath(),this.lineTo(t,e+i),this.lineTo(t+i,e),this.lineTo(t,e-i),this.lineTo(t-i,e),this.closePath()},CanvasRenderingContext2D.prototype.roundRect=function(t,e,i,o,n){var s=Math.PI/180;i-2*n<0&&(n=i/2),o-2*n<0&&(n=o/2),this.beginPath(),this.moveTo(t+n,e),this.lineTo(t+i-n,e),this.arc(t+i-n,e+n,n,270*s,360*s,!1),this.lineTo(t+i,e+o-n),this.arc(t+i-n,e+o-n,n,0,90*s,!1),this.lineTo(t+n,e+o),this.arc(t+n,e+o-n,n,90*s,180*s,!1),this.lineTo(t,e+n),this.arc(t+n,e+n,n,180*s,270*s,!1),this.closePath()},CanvasRenderingContext2D.prototype.ellipse_vis=function(t,e,i,o){var n=i/2*.5522848,s=o/2*.5522848,r=t+i,a=e+o,h=t+i/2,d=e+o/2;this.beginPath(),this.moveTo(t,d),this.bezierCurveTo(t,d-s,h-n,e,h,e),this.bezierCurveTo(h+n,e,r,d-s,r,d),this.bezierCurveTo(r,d+s,h+n,a,h,a),this.bezierCurveTo(h-n,a,t,d+s,t,d),this.closePath()},CanvasRenderingContext2D.prototype.database=function(t,e,i,o){var n=i,s=o*(1/3),r=n/2*.5522848,a=s/2*.5522848,h=t+n,d=e+s,l=t+n/2,u=e+s/2,c=e+(o-s/2),p=e+o;this.beginPath(),this.moveTo(h,u),this.bezierCurveTo(h,u+a,l+r,d,l,d),this.bezierCurveTo(l-r,d,t,u+a,t,u),this.bezierCurveTo(t,u-a,l-r,e,l,e),this.bezierCurveTo(l+r,e,h,u-a,h,u),this.lineTo(h,c),this.bezierCurveTo(h,c+a,l+r,p,l,p),this.bezierCurveTo(l-r,p,t,c+a,t,c),this.lineTo(t,u)},CanvasRenderingContext2D.prototype.dashedLine=function(t,e,i,o,n){this.beginPath(),this.moveTo(t,e);for(var s=n.length,r=i-t,a=o-e,h=a/r,d=Math.sqrt(r*r+a*a),l=0,u=!0,c=0,p=n[0];d>=.1;)p=n[l++%s],p>d&&(p=d),c=Math.sqrt(p*p/(1+h*h)),c=r<0?-c:c,t+=c,e+=h*c,!0===u?this.lineTo(t,e):this.moveTo(t,e),d-=p,u=!u},CanvasRenderingContext2D.prototype.hexagon=function(t,e,i){this.beginPath();var o=2*Math.PI/6;this.moveTo(t+i,e);for(var n=1;n<6;n++)this.lineTo(t+i*Math.cos(o*n),e+i*Math.sin(o*n));this.closePath()})},function(t,e,i){e.en={edit:"Edit",del:"Delete selected",back:"Back",addNode:"Add Node",addEdge:"Add Edge",editNode:"Edit Node",editEdge:"Edit Edge",addDescription:"Click in an empty space to place a new node.",edgeDescription:"Click on a node and drag the edge to another node to connect them.",editEdgeDescription:"Click on the control points and drag them to a node to connect to it.",createEdgeError:"Cannot link edges to a cluster.",deleteClusterError:"Clusters cannot be deleted.",editClusterError:"Clusters cannot be edited."},e.en_EN=e.en,e.en_US=e.en,e.de={edit:"Editieren",del:"Lösche Auswahl",back:"Zurück",addNode:"Knoten hinzufügen",addEdge:"Kante hinzufügen",editNode:"Knoten editieren",editEdge:"Kante editieren",addDescription:"Klicke auf eine freie Stelle, um einen neuen Knoten zu plazieren.",edgeDescription:"Klicke auf einen Knoten und ziehe die Kante zu einem anderen Knoten, um diese zu verbinden.",editEdgeDescription:"Klicke auf die Verbindungspunkte und ziehe diese auf einen Knoten, um sie zu verbinden.",createEdgeError:"Es ist nicht möglich, Kanten mit Clustern zu verbinden.",deleteClusterError:"Cluster können nicht gelöscht werden.",editClusterError:"Cluster können nicht editiert werden."},e.de_DE=e.de,e.es={edit:"Editar",del:"Eliminar selección",back:"Ãtras",addNode:"Añadir nodo",addEdge:"Añadir arista",editNode:"Editar nodo",editEdge:"Editar arista",addDescription:"Haga clic en un lugar vacÃo para colocar un nuevo nodo.",edgeDescription:"Haga clic en un nodo y arrastre la arista hacia otro nodo para conectarlos.",editEdgeDescription:"Haga clic en un punto de control y arrastrelo a un nodo para conectarlo.",createEdgeError:"No se puede conectar una arista a un grupo.",deleteClusterError:"No es posible eliminar grupos.",editClusterError:"No es posible editar grupos."},e.es_ES=e.es,e.it={edit:"Modifica",del:"Cancella la selezione",back:"Indietro",addNode:"Aggiungi un nodo",addEdge:"Aggiungi un vertice",editNode:"Modifica il nodo",editEdge:"Modifica il vertice",addDescription:"Clicca per aggiungere un nuovo nodo",edgeDescription:"Clicca su un nodo e trascinalo ad un altro nodo per connetterli.",editEdgeDescription:"Clicca sui Punti di controllo e trascinali ad un nodo per connetterli.",createEdgeError:"Non si possono collegare vertici ad un cluster",deleteClusterError:"I cluster non possono essere cancellati",editClusterError:"I clusters non possono essere modificati."},e.it_IT=e.it,e.nl={edit:"Wijzigen",del:"Selectie verwijderen",back:"Terug",addNode:"Node toevoegen",addEdge:"Link toevoegen",editNode:"Node wijzigen",editEdge:"Link wijzigen",addDescription:"Klik op een leeg gebied om een nieuwe node te maken.",edgeDescription:"Klik op een node en sleep de link naar een andere node om ze te verbinden.",editEdgeDescription:"Klik op de verbindingspunten en sleep ze naar een node om daarmee te verbinden.",createEdgeError:"Kan geen link maken naar een cluster.",deleteClusterError:"Clusters kunnen niet worden verwijderd.",editClusterError:"Clusters kunnen niet worden aangepast."},e.nl_NL=e.nl,e.nl_BE=e.nl,e["pt-br"]={edit:"Editar",del:"Remover selecionado",back:"Voltar",addNode:"Adicionar nó",addEdge:"Adicionar aresta",editNode:"Editar nó",editEdge:"Editar aresta",addDescription:"Clique em um espaço em branco para adicionar um novo nó",edgeDescription:"Clique em um nó e arraste a aresta até outro nó para conectá-los",editEdgeDescription:"Clique nos pontos de controle e os arraste para um nó para conectá-los",createEdgeError:"Não foi possÃvel linkar arestas a um cluster.",deleteClusterError:"Clusters não puderam ser removidos.",editClusterError:"Clusters não puderam ser editados."},e["pt-BR"]=e["pt-br"],e.pt_BR=e["pt-br"],e.pt_br=e["pt-br"],e.ru={edit:"Редактировать",del:"Удалить выбранное",back:"Ðазад",addNode:"Добавить узел",addEdge:"Добавить ребро",editNode:"Редактировать узел",editEdge:"Редактировать ребро",addDescription:"Кликните в Ñвободное меÑто, чтобы добавить новый узел.",edgeDescription:"Кликните на узел и протÑните ребро к другому узлу, чтобы Ñоединить их.",editEdgeDescription:"Кликните на контрольные точки и перетащите их в узел, чтобы подключитьÑÑ Ðº нему.",createEdgeError:"Ðевозможно Ñоединить ребра в клаÑтер.",deleteClusterError:"КлаÑтеры не могут быть удалены",editClusterError:"КлаÑтеры недоÑтупны Ð´Ð»Ñ Ñ€ÐµÐ´Ð°ÐºÑ‚Ð¸Ñ€Ð¾Ð²Ð°Ð½Ð¸Ñ."},e.ru_RU=e.ru,e.cn={edit:"编辑",del:"åˆ é™¤é€‰å®š",back:"返回",addNode:"æ·»åŠ èŠ‚ç‚¹",addEdge:"æ·»åŠ è¿žæŽ¥çº¿",editNode:"编辑节点",editEdge:"编辑连接线",addDescription:"å•击空白处放置新节点。",edgeDescription:"å•击æŸä¸ªèŠ‚ç‚¹å¹¶å°†è¯¥è¿žæŽ¥çº¿æ‹–åŠ¨åˆ°å¦ä¸€ä¸ªèŠ‚ç‚¹ä»¥è¿žæŽ¥å®ƒä»¬ã€‚",editEdgeDescription:"å•击控制节点并将它们拖到节点上连接。",createEdgeError:"æ— æ³•å°†è¿žæŽ¥çº¿è¿žæŽ¥åˆ°ç¾¤é›†ã€‚",deleteClusterError:"æ— æ³•åˆ é™¤ç¾¤é›†ã€‚",editClusterError:"æ— æ³•ç¼–è¾‘ç¾¤é›†ã€‚"},e.zh_CN=e.cn},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=function(){function t(){(0,s.default)(this,t),this.NUM_ITERATIONS=4,this.image=new Image,this.canvas=document.createElement("canvas")}return(0,a.default)(t,[{key:"init",value:function(){if(!this.initialized()){this.src=this.image.src;var t=this.image.width,e=this.image.height;this.width=t,this.height=e;var i=Math.floor(e/2),o=Math.floor(e/4),n=Math.floor(e/8),s=Math.floor(e/16),r=Math.floor(t/2),a=Math.floor(t/4),h=Math.floor(t/8),d=Math.floor(t/16);this.canvas.width=3*a,this.canvas.height=i,this.coordinates=[[0,0,r,i],[r,0,a,o],[r,o,h,n],[5*h,o,d,s]],this._fillMipMap()}}},{key:"initialized",value:function(){return void 0!==this.coordinates}},{key:"_fillMipMap",value:function(){var t=this.canvas.getContext("2d"),e=this.coordinates[0];t.drawImage(this.image,e[0],e[1],e[2],e[3]);for(var i=1;i<this.NUM_ITERATIONS;i++){var o=this.coordinates[i-1],n=this.coordinates[i];t.drawImage(this.canvas,o[0],o[1],o[2],o[3],n[0],n[1],n[2],n[3])}}},{key:"drawImageAtPosition",value:function(t,e,i,o,n,s){if(this.initialized())if(e>2){e*=.5;for(var r=0;e>2&&r<this.NUM_ITERATIONS;)e*=.5,r+=1;r>=this.NUM_ITERATIONS&&(r=this.NUM_ITERATIONS-1);var a=this.coordinates[r];t.drawImage(this.canvas,a[0],a[1],a[2],a[3],i,o,n,s)}else t.drawImage(this.image,i,o,n,s)}}]),t}();e.default=h},function(t,e,i){ +function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(2),d=function(){function t(){(0,s.default)(this,t),this.clear(),this.defaultIndex=0,this.groupsArray=[],this.groupIndex=0,this.defaultGroups=[{border:"#2B7CE9",background:"#97C2FC",highlight:{border:"#2B7CE9",background:"#D2E5FF"},hover:{border:"#2B7CE9",background:"#D2E5FF"}},{border:"#FFA500",background:"#FFFF00",highlight:{border:"#FFA500",background:"#FFFFA3"},hover:{border:"#FFA500",background:"#FFFFA3"}},{border:"#FA0A10",background:"#FB7E81",highlight:{border:"#FA0A10",background:"#FFAFB1"},hover:{border:"#FA0A10",background:"#FFAFB1"}},{border:"#41A906",background:"#7BE141",highlight:{border:"#41A906",background:"#A1EC76"},hover:{border:"#41A906",background:"#A1EC76"}},{border:"#E129F0",background:"#EB7DF4",highlight:{border:"#E129F0",background:"#F0B3F5"},hover:{border:"#E129F0",background:"#F0B3F5"}},{border:"#7C29F0",background:"#AD85E4",highlight:{border:"#7C29F0",background:"#D3BDF0"},hover:{border:"#7C29F0",background:"#D3BDF0"}},{border:"#C37F00",background:"#FFA807",highlight:{border:"#C37F00",background:"#FFCA66"},hover:{border:"#C37F00",background:"#FFCA66"}},{border:"#4220FB",background:"#6E6EFD",highlight:{border:"#4220FB",background:"#9B9BFD"},hover:{border:"#4220FB",background:"#9B9BFD"}},{border:"#FD5A77",background:"#FFC0CB",highlight:{border:"#FD5A77",background:"#FFD1D9"},hover:{border:"#FD5A77",background:"#FFD1D9"}},{border:"#4AD63A",background:"#C2FABC",highlight:{border:"#4AD63A",background:"#E6FFE3"},hover:{border:"#4AD63A",background:"#E6FFE3"}},{border:"#990000",background:"#EE0000",highlight:{border:"#BB0000",background:"#FF3333"},hover:{border:"#BB0000",background:"#FF3333"}},{border:"#FF6000",background:"#FF6000",highlight:{border:"#FF6000",background:"#FF6000"},hover:{border:"#FF6000",background:"#FF6000"}},{border:"#97C2FC",background:"#2B7CE9",highlight:{border:"#D2E5FF",background:"#2B7CE9"},hover:{border:"#D2E5FF",background:"#2B7CE9"}},{border:"#399605",background:"#255C03",highlight:{border:"#399605",background:"#255C03"},hover:{border:"#399605",background:"#255C03"}},{border:"#B70054",background:"#FF007E",highlight:{border:"#B70054",background:"#FF007E"},hover:{border:"#B70054",background:"#FF007E"}},{border:"#AD85E4",background:"#7C29F0",highlight:{border:"#D3BDF0",background:"#7C29F0"},hover:{border:"#D3BDF0",background:"#7C29F0"}},{border:"#4557FA",background:"#000EA1",highlight:{border:"#6E6EFD",background:"#000EA1"},hover:{border:"#6E6EFD",background:"#000EA1"}},{border:"#FFC0CB",background:"#FD5A77",highlight:{border:"#FFD1D9",background:"#FD5A77"},hover:{border:"#FFD1D9",background:"#FD5A77"}},{border:"#C2FABC",background:"#74D66A",highlight:{border:"#E6FFE3",background:"#74D66A"},hover:{border:"#E6FFE3",background:"#74D66A"}},{border:"#EE0000",background:"#990000",highlight:{border:"#FF3333",background:"#BB0000"},hover:{border:"#FF3333",background:"#BB0000"}}],this.options={},this.defaultOptions={useDefaultGroups:!0},h.extend(this.options,this.defaultOptions)}return(0,a.default)(t,[{key:"setOptions",value:function(t){var e=["useDefaultGroups"];if(void 0!==t)for(var i in t)if(t.hasOwnProperty(i)&&-1===e.indexOf(i)){var o=t[i];this.add(i,o)}}},{key:"clear",value:function(){this.groups={},this.groupsArray=[]}},{key:"get",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.groups[t];if(void 0===i&&e)if(!1===this.options.useDefaultGroups&&this.groupsArray.length>0){var o=this.groupIndex%this.groupsArray.length;this.groupIndex++,i={},i.color=this.groups[this.groupsArray[o]],this.groups[t]=i}else{var n=this.defaultIndex%this.defaultGroups.length;this.defaultIndex++,i={},i.color=this.defaultGroups[n],this.groups[t]=i}return i}},{key:"add",value:function(t,e){return this.groups[t]=e,this.groupsArray.push(t),e}}]),t}();e.default=d},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(2),d=i(11),l=i(12),u=i(47).default,c=function(){function t(e,i,o,n){var r=this;if((0,s.default)(this,t),this.body=e,this.images=i,this.groups=o,this.layoutEngine=n,this.body.functions.createNode=this.create.bind(this),this.nodesListeners={add:function(t,e){r.add(e.items)},update:function(t,e){r.update(e.items,e.data,e.oldData)},remove:function(t,e){r.remove(e.items)}},this.defaultOptions={borderWidth:1,borderWidthSelected:2,brokenImage:void 0,color:{border:"#2B7CE9",background:"#97C2FC",highlight:{border:"#2B7CE9",background:"#D2E5FF"},hover:{border:"#2B7CE9",background:"#D2E5FF"}},fixed:{x:!1,y:!1},font:{color:"#343434",size:14,face:"arial",background:"none",strokeWidth:0,strokeColor:"#ffffff",align:"center",vadjust:0,multi:!1,bold:{mod:"bold"},boldital:{mod:"bold italic"},ital:{mod:"italic"},mono:{mod:"",size:15,face:"monospace",vadjust:2}},group:void 0,hidden:!1,icon:{face:"FontAwesome",code:void 0,size:50,color:"#2B7CE9"},image:void 0,label:void 0,labelHighlightBold:!0,level:void 0,margin:{top:5,right:5,bottom:5,left:5},mass:1,physics:!0,scaling:{min:10,max:30,label:{enabled:!1,min:14,max:30,maxVisible:30,drawThreshold:5},customScalingFunction:function(t,e,i,o){if(e===t)return.5;var n=1/(e-t);return Math.max(0,(o-t)*n)}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:10,x:5,y:5},shape:"ellipse",shapeProperties:{borderDashes:!1,borderRadius:6,interpolation:!0,useImageSize:!1,useBorderWithImage:!1},size:25,title:void 0,value:void 0,x:void 0,y:void 0},this.defaultOptions.mass<=0)throw"Internal error: mass in defaultOptions of NodesHandler may not be zero or negative";this.options=h.bridgeObject(this.defaultOptions),this.bindEventListeners()}return(0,a.default)(t,[{key:"bindEventListeners",value:function(){var t=this;this.body.emitter.on("refreshNodes",this.refresh.bind(this)),this.body.emitter.on("refresh",this.refresh.bind(this)),this.body.emitter.on("destroy",function(){h.forEach(t.nodesListeners,function(e,i){t.body.data.nodes&&t.body.data.nodes.off(i,e)}),delete t.body.functions.createNode,delete t.nodesListeners.add,delete t.nodesListeners.update,delete t.nodesListeners.remove,delete t.nodesListeners})}},{key:"setOptions",value:function(t){if(void 0!==t){if(u.parseOptions(this.options,t),void 0!==t.shape)for(var e in this.body.nodes)this.body.nodes.hasOwnProperty(e)&&this.body.nodes[e].updateShape();if(void 0!==t.font)for(var i in this.body.nodes)this.body.nodes.hasOwnProperty(i)&&(this.body.nodes[i].updateLabelModule(),this.body.nodes[i].needsRefresh());if(void 0!==t.size)for(var o in this.body.nodes)this.body.nodes.hasOwnProperty(o)&&this.body.nodes[o].needsRefresh();void 0===t.hidden&&void 0===t.physics||this.body.emitter.emit("_dataChanged")}}},{key:"setData",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.body.data.nodes;if(t instanceof d||t instanceof l)this.body.data.nodes=t;else if(Array.isArray(t))this.body.data.nodes=new d,this.body.data.nodes.add(t);else{if(t)throw new TypeError("Array or DataSet expected");this.body.data.nodes=new d}if(i&&h.forEach(this.nodesListeners,function(t,e){i.off(e,t)}),this.body.nodes={},this.body.data.nodes){var o=this;h.forEach(this.nodesListeners,function(t,e){o.body.data.nodes.on(e,t)});var n=this.body.data.nodes.getIds();this.add(n,!0)}!1===e&&this.body.emitter.emit("_dataChanged")}},{key:"add",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=void 0,o=[],n=0;n<t.length;n++){i=t[n];var s=this.body.data.nodes.get(i),r=this.create(s);o.push(r),this.body.nodes[i]=r}this.layoutEngine.positionInitially(o),!1===e&&this.body.emitter.emit("_dataChanged")}},{key:"update",value:function(t,e,i){for(var o=this.body.nodes,n=!1,s=0;s<t.length;s++){var r=t[s],a=o[r],h=e[s];void 0!==a?a.setOptions(h)&&(n=!0):(n=!0,a=this.create(h),o[r]=a)}n||void 0===i||(n=e.some(function(t,e){var o=i[e];return o&&o.level!==t.level})),!0===n?this.body.emitter.emit("_dataChanged"):this.body.emitter.emit("_dataUpdated")}},{key:"remove",value:function(t){for(var e=this.body.nodes,i=0;i<t.length;i++){delete e[t[i]]}this.body.emitter.emit("_dataChanged")}},{key:"create",value:function(t){return new(arguments.length>1&&void 0!==arguments[1]?arguments[1]:u)(t,this.body,this.images,this.groups,this.options,this.defaultOptions)}},{key:"refresh",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];h.forEach(this.body.nodes,function(i,o){var n=t.body.data.nodes.get(o);void 0!==n&&(!0===e&&i.setOptions({x:null,y:null}),i.setOptions({fixed:!1}),i.setOptions(n))})}},{key:"getPositions",value:function(t){var e={};if(void 0!==t){if(!0===Array.isArray(t)){for(var i=0;i<t.length;i++)if(void 0!==this.body.nodes[t[i]]){var o=this.body.nodes[t[i]];e[t[i]]={x:Math.round(o.x),y:Math.round(o.y)}}}else if(void 0!==this.body.nodes[t]){var n=this.body.nodes[t];e[t]={x:Math.round(n.x),y:Math.round(n.y)}}}else for(var s=0;s<this.body.nodeIndices.length;s++){var r=this.body.nodes[this.body.nodeIndices[s]];e[this.body.nodeIndices[s]]={x:Math.round(r.x),y:Math.round(r.y)}}return e}},{key:"storePositions",value:function(){var t=[],e=this.body.data.nodes.getDataSet();for(var i in e._data)if(e._data.hasOwnProperty(i)){var o=this.body.nodes[i];e._data[i].x==Math.round(o.x)&&e._data[i].y==Math.round(o.y)||t.push({id:o.id,x:Math.round(o.x),y:Math.round(o.y)})}e.update(t)}},{key:"getBoundingBox",value:function(t){if(void 0!==this.body.nodes[t])return this.body.nodes[t].shape.boundingBox}},{key:"getConnectedNodes",value:function(t,e){var i=[];if(void 0!==this.body.nodes[t])for(var o=this.body.nodes[t],n={},s=0;s<o.edges.length;s++){var r=o.edges[s];"to"!==e&&r.toId==o.id?void 0===n[r.fromId]&&(i.push(r.fromId),n[r.fromId]=!0):"from"!==e&&r.fromId==o.id&&void 0===n[r.toId]&&(i.push(r.toId),n[r.toId]=!0)}return i}},{key:"getConnectedEdges",value:function(t){var e=[];if(void 0!==this.body.nodes[t])for(var i=this.body.nodes[t],o=0;o<i.edges.length;o++)e.push(i.edges[o].id);else console.log("NodeId provided for getConnectedEdges does not exist. Provided: ",t);return e}},{key:"moveNode",value:function(t,e,i){var o=this;void 0!==this.body.nodes[t]?(this.body.nodes[t].x=Number(e),this.body.nodes[t].y=Number(i),setTimeout(function(){o.body.emitter.emit("startSimulation")},0)):console.log("Node id supplied to moveNode does not exist. Provided: ",t)}}]),t}();e.default=c},function(t,e,i){t.exports={default:i(189),__esModule:!0}},function(t,e,i){i(49),i(60),t.exports=i(190)},function(t,e,i){var o=i(86),n=i(13)("iterator"),s=i(31);t.exports=i(7).isIterable=function(t){var e=Object(t);return void 0!==e[n]||"@@iterator"in e||s.hasOwnProperty(o(e))}},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(192).default,d=i(48).default,l=function(){function t(e,i,o,n){var r=this;(0,s.default)(this,t),this.ctx=e,this.parent=i;var a=function(t,i){if(void 0===t)return 0;var s=r.parent.getFormattingValues(e,o,n,i),a=0;if(""!==t){a=r.ctx.measureText(t).width}return{width:a,values:s}};this.lines=new h(a)}return(0,a.default)(t,[{key:"process",value:function(t){if(!d.isValidLabel(t))return this.lines.finalize();var e=this.parent.fontOptions;t=t.replace(/\r\n/g,"\n"),t=t.replace(/\r/g,"\n");var i=String(t).split("\n"),o=i.length;if(e.multi)for(var n=0;n<o;n++){var s=this.splitBlocks(i[n],e.multi);if(void 0!==s)if(0!==s.length){if(e.maxWdt>0)for(var r=0;r<s.length;r++){var a=s[r].mod,h=s[r].text;this.splitStringIntoLines(h,a,!0)}else for(var l=0;l<s.length;l++){var u=s[l].mod,c=s[l].text;this.lines.append(c,u)}this.lines.newLine()}else this.lines.newLine("")}else if(e.maxWdt>0)for(var p=0;p<o;p++)this.splitStringIntoLines(i[p]);else for(var f=0;f<o;f++)this.lines.newLine(i[f]);return this.lines.finalize()}},{key:"decodeMarkupSystem",value:function(t){var e="none";return"markdown"===t||"md"===t?e="markdown":!0!==t&&"html"!==t||(e="html"),e}},{key:"splitHtmlBlocks",value:function(t){var e=[],i={bold:!1,ital:!1,mono:!1,spacing:!1,position:0,buffer:"",modStack:[]};for(i.mod=function(){return 0===this.modStack.length?"normal":this.modStack[0]},i.modName=function(){return 0===this.modStack.length?"normal":"mono"===this.modStack[0]?"mono":i.bold&&i.ital?"boldital":i.bold?"bold":i.ital?"ital":void 0},i.emitBlock=function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.spacing&&(this.add(" "),this.spacing=!1),this.buffer.length>0&&(e.push({text:this.buffer,mod:this.modName()}),this.buffer="")},i.add=function(t){" "===t&&(i.spacing=!0),i.spacing&&(this.buffer+=" ",this.spacing=!1)," "!=t&&(this.buffer+=t)};i.position<t.length;){var o=t.charAt(i.position);/[ \t]/.test(o)?i.mono?i.add(o):i.spacing=!0:/</.test(o)?i.mono||i.bold||!/<b>/.test(t.substr(i.position,3))?i.mono||i.ital||!/<i>/.test(t.substr(i.position,3))?!i.mono&&/<code>/.test(t.substr(i.position,6))?(i.emitBlock(),i.mono=!0,i.modStack.unshift("mono"),i.position+=5):!i.mono&&"bold"===i.mod()&&/<\/b>/.test(t.substr(i.position,4))?(i.emitBlock(),i.bold=!1,i.modStack.shift(),i.position+=3):!i.mono&&"ital"===i.mod()&&/<\/i>/.test(t.substr(i.position,4))?(i.emitBlock(),i.ital=!1,i.modStack.shift(),i.position+=3):"mono"===i.mod()&&/<\/code>/.test(t.substr(i.position,7))?(i.emitBlock(),i.mono=!1,i.modStack.shift(),i.position+=6):i.add(o):(i.emitBlock(),i.ital=!0,i.modStack.unshift("ital"),i.position+=2):(i.emitBlock(),i.bold=!0,i.modStack.unshift("bold"),i.position+=2):/&/.test(o)?/</.test(t.substr(i.position,4))?(i.add("<"),i.position+=3):/&/.test(t.substr(i.position,5))?(i.add("&"),i.position+=4):i.add("&"):i.add(o),i.position++}return i.emitBlock(),e}},{key:"splitMarkdownBlocks",value:function(t){var e=[],i={bold:!1,ital:!1,mono:!1,beginable:!0,spacing:!1,position:0,buffer:"",modStack:[]};for(i.mod=function(){return 0===this.modStack.length?"normal":this.modStack[0]},i.modName=function(){return 0===this.modStack.length?"normal":"mono"===this.modStack[0]?"mono":i.bold&&i.ital?"boldital":i.bold?"bold":i.ital?"ital":void 0},i.emitBlock=function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.spacing&&(this.add(" "),this.spacing=!1),this.buffer.length>0&&(e.push({text:this.buffer,mod:this.modName()}),this.buffer="")},i.add=function(t){" "===t&&(i.spacing=!0),i.spacing&&(this.buffer+=" ",this.spacing=!1)," "!=t&&(this.buffer+=t)};i.position<t.length;){var o=t.charAt(i.position);/[ \t]/.test(o)?(i.mono?i.add(o):i.spacing=!0,i.beginable=!0):/\\/.test(o)?i.position<t.length+1&&(i.position++,o=t.charAt(i.position),/ \t/.test(o)?i.spacing=!0:(i.add(o),i.beginable=!1)):i.mono||i.bold||!i.beginable&&!i.spacing||!/\*/.test(o)?i.mono||i.ital||!i.beginable&&!i.spacing||!/\_/.test(o)?!i.mono&&(i.beginable||i.spacing)&&/`/.test(o)?(i.emitBlock(),i.mono=!0,i.modStack.unshift("mono")):!i.mono&&"bold"===i.mod()&&/\*/.test(o)?i.position===t.length-1||/[.,_` \t\n]/.test(t.charAt(i.position+1))?(i.emitBlock(),i.bold=!1,i.modStack.shift()):i.add(o):!i.mono&&"ital"===i.mod()&&/\_/.test(o)?i.position===t.length-1||/[.,*` \t\n]/.test(t.charAt(i.position+1))?(i.emitBlock(),i.ital=!1,i.modStack.shift()):i.add(o):i.mono&&"mono"===i.mod()&&/`/.test(o)?i.position===t.length-1||/[.,*_ \t\n]/.test(t.charAt(i.position+1))?(i.emitBlock(),i.mono=!1,i.modStack.shift()):i.add(o):(i.add(o),i.beginable=!1):(i.emitBlock(),i.ital=!0,i.modStack.unshift("ital")):(i.emitBlock(),i.bold=!0,i.modStack.unshift("bold")),i.position++}return i.emitBlock(),e}},{key:"splitBlocks",value:function(t,e){var i=this.decodeMarkupSystem(e);return"none"===i?[{text:t,mod:"normal"}]:"markdown"===i?this.splitMarkdownBlocks(t):"html"===i?this.splitHtmlBlocks(t):void 0}},{key:"overMaxWidth",value:function(t){var e=this.ctx.measureText(t).width;return this.lines.curWidth()+e>this.parent.fontOptions.maxWdt}},{key:"getLongestFit",value:function(t){for(var e="",i=0;i<t.length;){var o=""===e?"":" ",n=e+o+t[i];if(this.overMaxWidth(n))break;e=n,i++}return i}},{key:"getLongestFitWord",value:function(t){for(var e=0;e<t.length&&!this.overMaxWidth(t.slice(0,e));)e++;return e}},{key:"splitStringIntoLines",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"normal",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t=t.replace(/^( +)/g,"$1\r"),t=t.replace(/([^\r][^ ]*)( +)/g,"$1\r$2\r");for(var o=t.split("\r");o.length>0;){var n=this.getLongestFit(o);if(0===n){var s=o[0],r=this.getLongestFitWord(s);this.lines.newLine(s.slice(0,r),e),o[0]=s.slice(r)}else{var a=n;" "===o[n-1]?n--:" "===o[a]&&a++;var h=o.slice(0,n).join("");n==o.length&&i?this.lines.append(h,e):this.lines.newLine(h,e),o=o.slice(a)}}}}]),t}();e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(90),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=function(){function t(e){(0,a.default)(this,t),this.measureText=e,this.current=0,this.width=0,this.height=0,this.lines=[]}return(0,d.default)(t,[{key:"_add",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"normal";void 0===this.lines[t]&&(this.lines[t]={width:0,height:0,blocks:[]});var o=e;void 0!==e&&""!==e||(o=" ");var n=this.measureText(o,i),r=(0,s.default)({},n.values);r.text=e,r.width=n.width,r.mod=i,void 0!==e&&""!==e||(r.width=0),this.lines[t].blocks.push(r),this.lines[t].width+=r.width}},{key:"curWidth",value:function(){var t=this.lines[this.current];return void 0===t?0:t.width}},{key:"append",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"normal";this._add(this.current,t,e)}},{key:"newLine",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"normal";this._add(this.current,t,e),this.current++}},{key:"determineLineHeights",value:function(){for(var t=0;t<this.lines.length;t++){var e=this.lines[t],i=0;if(void 0!==e.blocks)for(var o=0;o<e.blocks.length;o++){var n=e.blocks[o];i<n.height&&(i=n.height)}e.height=i}}},{key:"determineLabelSize",value:function(){for(var t=0,e=0,i=0;i<this.lines.length;i++){var o=this.lines[i];o.width>t&&(t=o.width),e+=o.height}this.width=t,this.height=e}},{key:"removeEmptyBlocks",value:function(){for(var t=[],e=0;e<this.lines.length;e++){var i=this.lines[e];if(0!==i.blocks.length&&(e!==this.lines.length-1||0!==i.width)){var o={};(0,s.default)(o,i),o.blocks=[];for(var n=void 0,r=[],a=0;a<i.blocks.length;a++){var h=i.blocks[a];0!==h.width?r.push(h):void 0===n&&(n=h)}0===r.length&&void 0!==n&&r.push(n),o.blocks=r,t.push(o)}}return t}},{key:"finalize",value:function(){this.determineLineHeights(),this.determineLabelSize();var t=this.removeEmptyBlocks();return{width:this.width,height:this.height,lines:t}}}]),t}();e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(23),m=o(f),v=function(t){function e(t,i,o){(0,a.default)(this,e);var n=(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o));return n._setMargins(o),n}return(0,p.default)(e,t),(0,d.default)(e,[{key:"resize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(this.needsRefresh(e,i)){var o=this.getDimensionsFromLabel(t,e,i);this.width=o.width+this.margin.right+this.margin.left,this.height=o.height+this.margin.top+this.margin.bottom,this.radius=this.width/2}}},{key:"draw",value:function(t,e,i,o,n,s){this.resize(t,o,n),this.left=e-this.width/2,this.top=i-this.height/2,this.initContextForDraw(t,s),t.roundRect(this.left,this.top,this.width,this.height,s.borderRadius),this.performFill(t,s),this.updateBoundingBox(e,i,t,o,n),this.labelModule.draw(t,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,o,n)}},{key:"updateBoundingBox",value:function(t,e,i,o,n){this._updateBoundingBox(t,e,i,o,n);var s=this.options.shapeProperties.borderRadius;this._addBoundingBoxMargin(s)}},{key:"distanceToBorder",value:function(t,e){this.resize(t);var i=this.options.borderWidth;return Math.min(Math.abs(this.width/2/Math.cos(e)),Math.abs(this.height/2/Math.sin(e)))+i}}]),e}(m.default);e.default=v},function(t,e,i){i(195),t.exports=i(7).Object.getPrototypeOf},function(t,e,i){var o=i(41),n=i(85);i(87)("getPrototypeOf",function(){return function(t){return n(o(t))}})},function(t,e,i){t.exports={default:i(197),__esModule:!0}},function(t,e,i){i(198),t.exports=i(7).Object.setPrototypeOf},function(t,e,i){var o=i(17);o(o.S,"Object",{setPrototypeOf:i(199).set})},function(t,e,i){var o=i(32),n=i(27),s=function(t,e){if(n(t),!o(e)&&null!==e)throw TypeError(e+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,o){try{o=i(80)(Function.call,i(89).f(Object.prototype,"__proto__").set,2),o(t,[]),e=!(t instanceof Array)}catch(t){e=!0}return function(t,i){return s(t,i),e?t.__proto__=i:o(t,i),t}}({},!1):void 0),check:s}},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(73),m=o(f),v=function(t){function e(t,i,o){(0,a.default)(this,e);var n=(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o));return n._setMargins(o),n}return(0,p.default)(e,t),(0,d.default)(e,[{key:"resize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(this.needsRefresh(e,i)){var o=this.getDimensionsFromLabel(t,e,i),n=Math.max(o.width+this.margin.right+this.margin.left,o.height+this.margin.top+this.margin.bottom);this.options.size=n/2,this.width=n,this.height=n,this.radius=this.width/2}}},{key:"draw",value:function(t,e,i,o,n,s){this.resize(t,o,n),this.left=e-this.width/2,this.top=i-this.height/2,this._drawRawCircle(t,e,i,s),this.updateBoundingBox(e,i),this.labelModule.draw(t,this.left+this.textSize.width/2+this.margin.left,i,o,n)}},{key:"updateBoundingBox",value:function(t,e){this.boundingBox.top=e-this.options.size,this.boundingBox.left=t-this.options.size,this.boundingBox.right=t+this.options.size,this.boundingBox.bottom=e+this.options.size}},{key:"distanceToBorder",value:function(t,e){return this.resize(t),.5*this.width}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(73),m=o(f),v=function(t){function e(t,i,o,n,r){(0,a.default)(this,e);var h=(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o));return h.setImages(n,r),h}return(0,p.default)(e,t),(0,d.default)(e,[{key:"resize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(void 0===this.imageObj.src||void 0===this.imageObj.width||void 0===this.imageObj.height){var o=2*this.options.size;return this.width=o,this.height=o,void(this.radius=.5*this.width)}this.needsRefresh(e,i)&&this._resizeImage()}},{key:"draw",value:function(t,e,i,o,n,s){this.switchImages(o),this.resize(),this.left=e-this.width/2,this.top=i-this.height/2,this._drawRawCircle(t,e,i,s),t.save(),t.clip(),this._drawImageAtPosition(t,s),t.restore(),this._drawImageLabel(t,e,i,o,n),this.updateBoundingBox(e,i)}},{key:"updateBoundingBox",value:function(t,e){this.boundingBox.top=e-this.options.size,this.boundingBox.left=t-this.options.size,this.boundingBox.right=t+this.options.size,this.boundingBox.bottom=e+this.options.size,this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset)}},{key:"distanceToBorder",value:function(t,e){return this.resize(t),.5*this.width}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(23),m=o(f),v=function(t){function e(t,i,o){(0,a.default)(this,e);var n=(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o));return n._setMargins(o),n}return(0,p.default)(e,t),(0,d.default)(e,[{key:"resize",value:function(t,e,i){if(this.needsRefresh(e,i)){var o=this.getDimensionsFromLabel(t,e,i),n=o.width+this.margin.right+this.margin.left;this.width=n,this.height=n,this.radius=this.width/2}}},{key:"draw",value:function(t,e,i,o,n,s){this.resize(t,o,n),this.left=e-this.width/2,this.top=i-this.height/2,this.initContextForDraw(t,s),t.database(e-this.width/2,i-this.height/2,this.width,this.height),this.performFill(t,s),this.updateBoundingBox(e,i,t,o,n),this.labelModule.draw(t,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,o,n)}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(24),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"draw",value:function(t,e,i,o,n,s){this._drawShape(t,"diamond",4,e,i,o,n,s)}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(24),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"draw",value:function(t,e,i,o,n,s){this._drawShape(t,"circle",2,e,i,o,n,s)}},{key:"distanceToBorder",value:function(t,e){return this.resize(t),this.options.size}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(23),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"resize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(this.needsRefresh(e,i)){var o=this.getDimensionsFromLabel(t,e,i);this.height=2*o.height,this.width=o.width+o.height,this.radius=.5*this.width}}},{key:"draw",value:function(t,e,i,o,n,s){this.resize(t,o,n),this.left=e-.5*this.width,this.top=i-.5*this.height,this.initContextForDraw(t,s),t.ellipse_vis(this.left,this.top,this.width,this.height),this.performFill(t,s),this.updateBoundingBox(e,i,t,o,n),this.labelModule.draw(t,e,i,o,n)}},{key:"distanceToBorder",value:function(t,e){this.resize(t);var i=.5*this.width,o=.5*this.height,n=Math.sin(e)*i,s=Math.cos(e)*o;return i*o/Math.sqrt(n*n+s*s)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(23),m=o(f),v=function(t){function e(t,i,o){(0,a.default)(this,e);var n=(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o));return n._setMargins(o),n}return(0,p.default)(e,t),(0,d.default)(e,[{key:"resize",value:function(t,e,i){this.needsRefresh(e,i)&&(this.iconSize={width:Number(this.options.icon.size),height:Number(this.options.icon.size)},this.width=this.iconSize.width+this.margin.right+this.margin.left,this.height=this.iconSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}},{key:"draw",value:function(t,e,i,o,n,s){if(this.resize(t,o,n),this.options.icon.size=this.options.icon.size||50,this.left=e-this.width/2,this.top=i-this.height/2,this._icon(t,e,i,o,n,s),void 0!==this.options.label){this.labelModule.draw(t,this.left+this.iconSize.width/2+this.margin.left,i+this.height/2+5,o)}this.updateBoundingBox(e,i)}},{key:"updateBoundingBox",value:function(t,e){if(this.boundingBox.top=e-.5*this.options.icon.size,this.boundingBox.left=t-.5*this.options.icon.size,this.boundingBox.right=t+.5*this.options.icon.size,this.boundingBox.bottom=e+.5*this.options.icon.size,void 0!==this.options.label&&this.labelModule.size.width>0){this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height+5)}}},{key:"_icon",value:function(t,e,i,o,n,s){var r=Number(this.options.icon.size);void 0!==this.options.icon.code?(t.font=(o?"bold ":"")+r+"px "+this.options.icon.face,t.fillStyle=this.options.icon.color||"black",t.textAlign="center",t.textBaseline="middle",this.enableShadow(t,s),t.fillText(this.options.icon.code,e,i),this.disableShadow(t,s)):console.error("When using the icon shape, you need to define the code in the icon options object. This can be done per node or globally.")}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(73),m=o(f),v=function(t){function e(t,i,o,n,r){(0,a.default)(this,e);var h=(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o));return h.setImages(n,r),h}return(0,p.default)(e,t),(0,d.default)(e,[{key:"resize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(void 0===this.imageObj.src||void 0===this.imageObj.width||void 0===this.imageObj.height){var o=2*this.options.size;return this.width=o,void(this.height=o)}this.needsRefresh(e,i)&&this._resizeImage()}},{key:"draw",value:function(t,e,i,o,n,s){if(this.switchImages(o),this.resize(),this.left=e-this.width/2,this.top=i-this.height/2,!0===this.options.shapeProperties.useBorderWithImage){var r=this.options.borderWidth,a=this.options.borderWidthSelected||2*this.options.borderWidth,h=(o?a:r)/this.body.view.scale;t.lineWidth=Math.min(this.width,h),t.beginPath(),t.strokeStyle=o?this.options.color.highlight.border:n?this.options.color.hover.border:this.options.color.border,t.fillStyle=o?this.options.color.highlight.background:n?this.options.color.hover.background:this.options.color.background,t.rect(this.left-.5*t.lineWidth,this.top-.5*t.lineWidth,this.width+t.lineWidth,this.height+t.lineWidth),t.fill(),this.performStroke(t,s),t.closePath()}this._drawImageAtPosition(t,s),this._drawImageLabel(t,e,i,o,n),this.updateBoundingBox(e,i)}},{key:"updateBoundingBox",value:function(t,e){this.resize(),this._updateBoundingBox(t,e),void 0!==this.options.label&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset))}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)} +}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(24),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"draw",value:function(t,e,i,o,n,s){this._drawShape(t,"square",2,e,i,o,n,s)}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(24),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"draw",value:function(t,e,i,o,n,s){this._drawShape(t,"hexagon",4,e,i,o,n,s)}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(24),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"draw",value:function(t,e,i,o,n,s){this._drawShape(t,"star",4,e,i,o,n,s)}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(23),m=o(f),v=function(t){function e(t,i,o){(0,a.default)(this,e);var n=(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o));return n._setMargins(o),n}return(0,p.default)(e,t),(0,d.default)(e,[{key:"resize",value:function(t,e,i){this.needsRefresh(e,i)&&(this.textSize=this.labelModule.getTextSize(t,e,i),this.width=this.textSize.width+this.margin.right+this.margin.left,this.height=this.textSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}},{key:"draw",value:function(t,e,i,o,n,s){this.resize(t,o,n),this.left=e-this.width/2,this.top=i-this.height/2,this.enableShadow(t,s),this.labelModule.draw(t,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,o,n),this.disableShadow(t,s),this.updateBoundingBox(e,i,t,o,n)}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(24),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"draw",value:function(t,e,i,o,n,s){this._drawShape(t,"triangle",3,e,i,o,n,s)}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(24),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"draw",value:function(t,e,i,o,n,s){this._drawShape(t,"triangleDown",3,e,i,o,n,s)}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(2),d=i(11),l=i(12),u=i(74).default,c=function(){function t(e,i,o){var n=this;(0,s.default)(this,t),this.body=e,this.images=i,this.groups=o,this.body.functions.createEdge=this.create.bind(this),this.edgesListeners={add:function(t,e){n.add(e.items)},update:function(t,e){n.update(e.items)},remove:function(t,e){n.remove(e.items)}},this.options={},this.defaultOptions={arrows:{to:{enabled:!1,scaleFactor:1,type:"arrow"},middle:{enabled:!1,scaleFactor:1,type:"arrow"},from:{enabled:!1,scaleFactor:1,type:"arrow"}},arrowStrikethrough:!0,color:{color:"#848484",highlight:"#848484",hover:"#848484",inherit:"from",opacity:1},dashes:!1,font:{color:"#343434",size:14,face:"arial",background:"none",strokeWidth:2,strokeColor:"#ffffff",align:"horizontal",multi:!1,vadjust:0,bold:{mod:"bold"},boldital:{mod:"bold italic"},ital:{mod:"italic"},mono:{mod:"",size:15,face:"courier new",vadjust:2}},hidden:!1,hoverWidth:1.5,label:void 0,labelHighlightBold:!0,length:void 0,physics:!0,scaling:{min:1,max:15,label:{enabled:!0,min:14,max:30,maxVisible:30,drawThreshold:5},customScalingFunction:function(t,e,i,o){if(e===t)return.5;var n=1/(e-t);return Math.max(0,(o-t)*n)}},selectionWidth:1.5,selfReferenceSize:20,shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:10,x:5,y:5},smooth:{enabled:!0,type:"dynamic",forceDirection:"none",roundness:.5},title:void 0,width:1,value:void 0},h.deepExtend(this.options,this.defaultOptions),this.bindEventListeners()}return(0,a.default)(t,[{key:"bindEventListeners",value:function(){var t=this;this.body.emitter.on("_forceDisableDynamicCurves",function(e){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"dynamic"===e&&(e="continuous");var o=!1;for(var n in t.body.edges)if(t.body.edges.hasOwnProperty(n)){var s=t.body.edges[n],r=t.body.data.edges._data[n];if(void 0!==r){var a=r.smooth;void 0!==a&&!0===a.enabled&&"dynamic"===a.type&&(void 0===e?s.setOptions({smooth:!1}):s.setOptions({smooth:{type:e}}),o=!0)}}!0===i&&!0===o&&t.body.emitter.emit("_dataChanged")}),this.body.emitter.on("_dataUpdated",function(){t.reconnectEdges()}),this.body.emitter.on("refreshEdges",this.refresh.bind(this)),this.body.emitter.on("refresh",this.refresh.bind(this)),this.body.emitter.on("destroy",function(){h.forEach(t.edgesListeners,function(e,i){t.body.data.edges&&t.body.data.edges.off(i,e)}),delete t.body.functions.createEdge,delete t.edgesListeners.add,delete t.edgesListeners.update,delete t.edgesListeners.remove,delete t.edgesListeners})}},{key:"setOptions",value:function(t){if(void 0!==t){u.parseOptions(this.options,t,!0,this.defaultOptions,!0);var e=!1;if(void 0!==t.smooth)for(var i in this.body.edges)this.body.edges.hasOwnProperty(i)&&(e=this.body.edges[i].updateEdgeType()||e);if(void 0!==t.font)for(var o in this.body.edges)this.body.edges.hasOwnProperty(o)&&this.body.edges[o].updateLabelModule();void 0===t.hidden&&void 0===t.physics&&!0!==e||this.body.emitter.emit("_dataChanged")}}},{key:"setData",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=this.body.data.edges;if(t instanceof d||t instanceof l)this.body.data.edges=t;else if(Array.isArray(t))this.body.data.edges=new d,this.body.data.edges.add(t);else{if(t)throw new TypeError("Array or DataSet expected");this.body.data.edges=new d}if(o&&h.forEach(this.edgesListeners,function(t,e){o.off(e,t)}),this.body.edges={},this.body.data.edges){h.forEach(this.edgesListeners,function(t,i){e.body.data.edges.on(i,t)});var n=this.body.data.edges.getIds();this.add(n,!0)}this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),!1===i&&this.body.emitter.emit("_dataChanged")}},{key:"add",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.body.edges,o=this.body.data.edges,n=0;n<t.length;n++){var s=t[n],r=i[s];r&&r.disconnect();var a=o.get(s,{showInternalIds:!0});i[s]=this.create(a)}this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),!1===e&&this.body.emitter.emit("_dataChanged")}},{key:"update",value:function(t){for(var e=this.body.edges,i=this.body.data.edges,o=!1,n=0;n<t.length;n++){var s=t[n],r=i.get(s),a=e[s];void 0!==a?(a.disconnect(),o=a.setOptions(r)||o,a.connect()):(this.body.edges[s]=this.create(r),o=!0)}!0===o?(this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),this.body.emitter.emit("_dataChanged")):this.body.emitter.emit("_dataUpdated")}},{key:"remove",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(0!==t.length){var i=this.body.edges;h.forEach(t,function(t){var e=i[t];void 0!==e&&e.remove()}),e&&this.body.emitter.emit("_dataChanged")}}},{key:"refresh",value:function(){var t=this;h.forEach(this.body.edges,function(e,i){var o=t.body.data.edges._data[i];void 0!==o&&e.setOptions(o)})}},{key:"create",value:function(t){return new u(t,this.body,this.options,this.defaultOptions)}},{key:"reconnectEdges",value:function(){var t,e=this.body.nodes,i=this.body.edges;for(t in e)e.hasOwnProperty(t)&&(e[t].edges=[]);for(t in i)if(i.hasOwnProperty(t)){var o=i[t];o.from=null,o.to=null,o.connect()}}},{key:"getConnectedNodes",value:function(t){var e=[];if(void 0!==this.body.edges[t]){var i=this.body.edges[t];void 0!==i.fromId&&e.push(i.fromId),void 0!==i.toId&&e.push(i.toId)}return e}},{key:"_updateState",value:function(){this._addMissingEdges(),this._removeInvalidEdges()}},{key:"_removeInvalidEdges",value:function(){var t=this,e=[];h.forEach(this.body.edges,function(i,o){var n=t.body.nodes[i.toId],s=t.body.nodes[i.fromId];void 0!==n&&!0===n.isCluster||void 0!==s&&!0===s.isCluster||void 0!==n&&void 0!==s||e.push(o)}),this.remove(e,!1)}},{key:"_addMissingEdges",value:function(){var t=this.body.edges,e=this.body.data.edges,i=[];e.forEach(function(e,o){void 0===t[o]&&i.push(o)}),this.add(i,!0)}}]),t}();e.default=c},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(30),s=o(n),r=i(3),a=o(r),h=i(0),d=o(h),l=i(1),u=o(l),c=i(4),p=o(c),f=i(5),m=o(f),v=i(216),g=o(v),y=function(t){function e(t,i,o){return(0,d.default)(this,e),(0,p.default)(this,(e.__proto__||(0,a.default)(e)).call(this,t,i,o))}return(0,m.default)(e,t),(0,u.default)(e,[{key:"_line",value:function(t,e,i){var o=i[0],n=i[1];this._bezierCurve(t,e,o,n)}},{key:"_getViaCoordinates",value:function(){var t=this.from.x-this.to.x,e=this.from.y-this.to.y,i=void 0,o=void 0,n=void 0,s=void 0,r=this.options.smooth.roundness;return(Math.abs(t)>Math.abs(e)||!0===this.options.smooth.forceDirection||"horizontal"===this.options.smooth.forceDirection)&&"vertical"!==this.options.smooth.forceDirection?(o=this.from.y,s=this.to.y,i=this.from.x-r*t,n=this.to.x+r*t):(o=this.from.y-r*e,s=this.to.y+r*e,i=this.from.x,n=this.to.x),[{x:i,y:o},{x:n,y:s}]}},{key:"getViaNode",value:function(){return this._getViaCoordinates()}},{key:"_findBorderPosition",value:function(t,e){return this._findBorderPositionBezier(t,e)}},{key:"_getDistanceToEdge",value:function(t,e,i,o,n,r){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this._getViaCoordinates(),h=(0,s.default)(a,2),d=h[0],l=h[1];return this._getDistanceToBezierEdge(t,e,i,o,n,r,d,l)}},{key:"getPoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getViaCoordinates(),i=(0,s.default)(e,2),o=i[0],n=i[1],r=t,a=[];return a[0]=Math.pow(1-r,3),a[1]=3*r*Math.pow(1-r,2),a[2]=3*Math.pow(r,2)*(1-r),a[3]=Math.pow(r,3),{x:a[0]*this.fromPoint.x+a[1]*o.x+a[2]*n.x+a[3]*this.toPoint.x,y:a[0]*this.fromPoint.y+a[1]*o.y+a[2]*n.y+a[3]*this.toPoint.y}}}]),e}(g.default);e.default=y},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(75),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"_getDistanceToBezierEdge",value:function(t,e,i,o,n,s,r,a){var h=1e9,d=void 0,l=void 0,u=void 0,c=void 0,p=void 0,f=t,m=e,v=[0,0,0,0];for(l=1;l<10;l++)u=.1*l,v[0]=Math.pow(1-u,3),v[1]=3*u*Math.pow(1-u,2),v[2]=3*Math.pow(u,2)*(1-u),v[3]=Math.pow(u,3),c=v[0]*t+v[1]*r.x+v[2]*a.x+v[3]*i,p=v[0]*e+v[1]*r.y+v[2]*a.y+v[3]*o,l>0&&(d=this._getDistanceToLine(f,m,c,p,n,s),h=d<h?d:h),f=c,m=p;return h}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(30),s=o(n),r=i(3),a=o(r),h=i(0),d=o(h),l=i(1),u=o(l),c=i(4),p=o(c),f=i(5),m=o(f),v=i(75),g=o(v),y=function(t){function e(t,i,o){(0,d.default)(this,e);var n=(0,p.default)(this,(e.__proto__||(0,a.default)(e)).call(this,t,i,o));return n._boundFunction=function(){n.positionBezierNode()},n.body.emitter.on("_repositionBezierNodes",n._boundFunction),n}return(0,m.default)(e,t),(0,u.default)(e,[{key:"setOptions",value:function(t){var e=!1;this.options.physics!==t.physics&&(e=!0),this.options=t,this.id=this.options.id,this.from=this.body.nodes[this.options.from],this.to=this.body.nodes[this.options.to],this.setupSupportNode(),this.connect(),!0===e&&(this.via.setOptions({physics:this.options.physics}),this.positionBezierNode())}},{key:"connect",value:function(){this.from=this.body.nodes[this.options.from],this.to=this.body.nodes[this.options.to],void 0===this.from||void 0===this.to||!1===this.options.physics?this.via.setOptions({physics:!1}):this.from.id===this.to.id?this.via.setOptions({physics:!1}):this.via.setOptions({physics:!0})}},{key:"cleanup",value:function(){return this.body.emitter.off("_repositionBezierNodes",this._boundFunction),void 0!==this.via&&(delete this.body.nodes[this.via.id],this.via=void 0,!0)}},{key:"setupSupportNode",value:function(){if(void 0===this.via){var t="edgeId:"+this.id,e=this.body.functions.createNode({id:t,shape:"circle",physics:!0,hidden:!0});this.body.nodes[t]=e,this.via=e,this.via.parentEdgeId=this.id,this.positionBezierNode()}}},{key:"positionBezierNode",value:function(){void 0!==this.via&&void 0!==this.from&&void 0!==this.to?(this.via.x=.5*(this.from.x+this.to.x),this.via.y=.5*(this.from.y+this.to.y)):void 0!==this.via&&(this.via.x=0,this.via.y=0)}},{key:"_line",value:function(t,e,i){this._bezierCurve(t,e,i)}},{key:"getViaNode",value:function(){return this.via}},{key:"getPoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.via,i=t,o=void 0,n=void 0;if(this.from===this.to){var r=this._getCircleData(this.from),a=(0,s.default)(r,3),h=a[0],d=a[1],l=a[2],u=2*Math.PI*(1-i);o=h+l*Math.sin(u),n=d+l-l*(1-Math.cos(u))}else o=Math.pow(1-i,2)*this.fromPoint.x+2*i*(1-i)*e.x+Math.pow(i,2)*this.toPoint.x,n=Math.pow(1-i,2)*this.fromPoint.y+2*i*(1-i)*e.y+Math.pow(i,2)*this.toPoint.y;return{x:o,y:n}}},{key:"_findBorderPosition",value:function(t,e){return this._findBorderPositionBezier(t,e,this.via)}},{key:"_getDistanceToEdge",value:function(t,e,i,o,n,s){return this._getDistanceToBezierEdge(t,e,i,o,n,s,this.via)}}]),e}(g.default);e.default=y},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(75),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"_line",value:function(t,e,i){this._bezierCurve(t,e,i)}},{key:"getViaNode",value:function(){return this._getViaCoordinates()}},{key:"_getViaCoordinates",value:function(){var t=void 0,e=void 0,i=this.options.smooth.roundness,o=this.options.smooth.type,n=Math.abs(this.from.x-this.to.x),s=Math.abs(this.from.y-this.to.y);if("discrete"===o||"diagonalCross"===o){var r=void 0,a=void 0;r=a=n<=s?i*s:i*n,this.from.x>this.to.x&&(r=-r),this.from.y>=this.to.y&&(a=-a),t=this.from.x+r,e=this.from.y+a,"discrete"===o&&(n<=s?t=n<i*s?this.from.x:t:e=s<i*n?this.from.y:e)}else if("straightCross"===o){var h=(1-i)*n,d=(1-i)*s;n<=s?(h=0,this.from.y<this.to.y&&(d=-d)):(this.from.x<this.to.x&&(h=-h),d=0),t=this.to.x+h,e=this.to.y+d}else if("horizontal"===o){var l=(1-i)*n;this.from.x<this.to.x&&(l=-l),t=this.to.x+l,e=this.from.y}else if("vertical"===o){var u=(1-i)*s;this.from.y<this.to.y&&(u=-u),t=this.from.x,e=this.to.y+u}else if("curvedCW"===o){n=this.to.x-this.from.x,s=this.from.y-this.to.y;var c=Math.sqrt(n*n+s*s),p=Math.PI,f=Math.atan2(s,n),m=(f+(.5*i+.5)*p)%(2*p);t=this.from.x+(.5*i+.5)*c*Math.sin(m),e=this.from.y+(.5*i+.5)*c*Math.cos(m)}else if("curvedCCW"===o){n=this.to.x-this.from.x,s=this.from.y-this.to.y;var v=Math.sqrt(n*n+s*s),g=Math.PI,y=Math.atan2(s,n),b=(y+(.5*-i+.5)*g)%(2*g);t=this.from.x+(.5*i+.5)*v*Math.sin(b),e=this.from.y+(.5*i+.5)*v*Math.cos(b)}else{var _=void 0,w=void 0;_=w=n<=s?i*s:i*n,this.from.x>this.to.x&&(_=-_),this.from.y>=this.to.y&&(w=-w),t=this.from.x+_,e=this.from.y+w,n<=s?t=this.from.x<=this.to.x?this.to.x<t?this.to.x:t:this.to.x>t?this.to.x:t:e=this.from.y>=this.to.y?this.to.y>e?this.to.y:e:this.to.y<e?this.to.y:e}return{x:t,y:e}}},{key:"_findBorderPosition",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._findBorderPositionBezier(t,e,i.via)}},{key:"_getDistanceToEdge",value:function(t,e,i,o,n,s){var r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this._getViaCoordinates();return this._getDistanceToBezierEdge(t,e,i,o,n,s,r)}},{key:"getPoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getViaCoordinates(),i=t;return{x:Math.pow(1-i,2)*this.fromPoint.x+2*i*(1-i)*e.x+Math.pow(i,2)*this.toPoint.x,y:Math.pow(1-i,2)*this.fromPoint.y+2*i*(1-i)*e.y+Math.pow(i,2)*this.toPoint.y}}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(118),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"_line",value:function(t,e){t.beginPath(),t.moveTo(this.fromPoint.x,this.fromPoint.y),t.lineTo(this.toPoint.x,this.toPoint.y),this.enableShadow(t,e),t.stroke(),this.disableShadow(t,e)}},{key:"getViaNode",value:function(){}},{key:"getPoint",value:function(t){return{x:(1-t)*this.fromPoint.x+t*this.toPoint.x,y:(1-t)*this.fromPoint.y+t*this.toPoint.y}}},{key:"_findBorderPosition",value:function(t,e){var i=this.to,o=this.from;t.id===this.from.id&&(i=this.from,o=this.to);var n=Math.atan2(i.y-o.y,i.x-o.x),s=i.x-o.x,r=i.y-o.y,a=Math.sqrt(s*s+r*r),h=t.distanceToBorder(e,n),d=(a-h)/a,l={};return l.x=(1-d)*o.x+d*i.x,l.y=(1-d)*o.y+d*i.y,l}},{key:"_getDistanceToEdge",value:function(t,e,i,o,n,s){return this._getDistanceToLine(t,e,i,o,n,s)}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(8),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(120).default,u=i(221).default,c=i(222).default,p=i(223).default,f=i(224).default,m=i(121).default,v=i(225).default,g=i(226).default,y=i(2),b=i(119).default,_=function(){function t(e){(0,a.default)(this,t),this.body=e,this.physicsBody={physicsNodeIndices:[],physicsEdgeIndices:[],forces:{},velocities:{}},this.physicsEnabled=!0,this.simulationInterval=1e3/60,this.requiresTimeout=!0,this.previousStates={},this.referenceState={},this.freezeCache={},this.renderTimer=void 0,this.adaptiveTimestep=!1,this.adaptiveTimestepEnabled=!1,this.adaptiveCounter=0,this.adaptiveInterval=3,this.stabilized=!1,this.startedStabilization=!1,this.stabilizationIterations=0,this.ready=!1,this.options={},this.defaultOptions={enabled:!0,barnesHut:{theta:.5,gravitationalConstant:-2e3,centralGravity:.3,springLength:95,springConstant:.04,damping:.09,avoidOverlap:0},forceAtlas2Based:{theta:.5,gravitationalConstant:-50,centralGravity:.01,springConstant:.08,springLength:100,damping:.4,avoidOverlap:0},repulsion:{centralGravity:.2,springLength:200,springConstant:.05,nodeDistance:100,damping:.09,avoidOverlap:0},hierarchicalRepulsion:{centralGravity:0,springLength:100,springConstant:.01,nodeDistance:120,damping:.09},maxVelocity:50,minVelocity:.75,solver:"barnesHut",stabilization:{enabled:!0,iterations:1e3,updateInterval:50,onlyDynamicEdges:!1,fit:!0},timestep:.5,adaptiveTimestep:!0},y.extend(this.options,this.defaultOptions),this.timestep=.5,this.layoutFailed=!1,this.bindEventListeners()}return(0,d.default)(t,[{key:"bindEventListeners",value:function(){var t=this;this.body.emitter.on("initPhysics",function(){t.initPhysics()}),this.body.emitter.on("_layoutFailed",function(){t.layoutFailed=!0}),this.body.emitter.on("resetPhysics",function(){t.stopSimulation(),t.ready=!1}),this.body.emitter.on("disablePhysics",function(){t.physicsEnabled=!1,t.stopSimulation()}),this.body.emitter.on("restorePhysics",function(){t.setOptions(t.options),!0===t.ready&&t.startSimulation()}),this.body.emitter.on("startSimulation",function(){!0===t.ready&&t.startSimulation()}),this.body.emitter.on("stopSimulation",function(){t.stopSimulation()}),this.body.emitter.on("destroy",function(){t.stopSimulation(!1),t.body.emitter.off()}),this.body.emitter.on("_dataChanged",function(){t.updatePhysicsData()})}},{key:"setOptions",value:function(t){void 0!==t&&(!1===t?(this.options.enabled=!1,this.physicsEnabled=!1,this.stopSimulation()):!0===t?(this.options.enabled=!0,this.physicsEnabled=!0,this.startSimulation()):(this.physicsEnabled=!0,y.selectiveNotDeepExtend(["stabilization"],this.options,t),y.mergeOptions(this.options,t,"stabilization"),void 0===t.enabled&&(this.options.enabled=!0),!1===this.options.enabled&&(this.physicsEnabled=!1,this.stopSimulation()),this.timestep=this.options.timestep)),this.init()}},{key:"init",value:function(){var t;"forceAtlas2Based"===this.options.solver?(t=this.options.forceAtlas2Based,this.nodesSolver=new v(this.body,this.physicsBody,t),this.edgesSolver=new p(this.body,this.physicsBody,t),this.gravitySolver=new g(this.body,this.physicsBody,t)):"repulsion"===this.options.solver?(t=this.options.repulsion,this.nodesSolver=new u(this.body,this.physicsBody,t),this.edgesSolver=new p(this.body,this.physicsBody,t),this.gravitySolver=new m(this.body,this.physicsBody,t)):"hierarchicalRepulsion"===this.options.solver?(t=this.options.hierarchicalRepulsion,this.nodesSolver=new c(this.body,this.physicsBody,t),this.edgesSolver=new f(this.body,this.physicsBody,t),this.gravitySolver=new m(this.body,this.physicsBody,t)):(t=this.options.barnesHut,this.nodesSolver=new l(this.body,this.physicsBody,t),this.edgesSolver=new p(this.body,this.physicsBody,t),this.gravitySolver=new m(this.body,this.physicsBody,t)),this.modelOptions=t}},{key:"initPhysics",value:function(){!0===this.physicsEnabled&&!0===this.options.enabled?!0===this.options.stabilization.enabled?this.stabilize():(this.stabilized=!1,this.ready=!0,this.body.emitter.emit("fit",{},this.layoutFailed),this.startSimulation()):(this.ready=!0,this.body.emitter.emit("fit"))}},{key:"startSimulation",value:function(){!0===this.physicsEnabled&&!0===this.options.enabled?(this.stabilized=!1,this.adaptiveTimestep=!1,this.body.emitter.emit("_resizeNodes"),void 0===this.viewFunction&&(this.viewFunction=this.simulationStep.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))):this.body.emitter.emit("_redraw")}},{key:"stopSimulation",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.stabilized=!0,!0===t&&this._emitStabilized(),void 0!==this.viewFunction&&(this.body.emitter.off("initRedraw",this.viewFunction),this.viewFunction=void 0,!0===t&&this.body.emitter.emit("_stopRendering"))}},{key:"simulationStep",value:function(){var t=Date.now();this.physicsTick(),(Date.now()-t<.4*this.simulationInterval||!0===this.runDoubleSpeed)&&!1===this.stabilized&&(this.physicsTick(),this.runDoubleSpeed=!0),!0===this.stabilized&&this.stopSimulation()}},{key:"_emitStabilized",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.stabilizationIterations;(this.stabilizationIterations>1||!0===this.startedStabilization)&&setTimeout(function(){t.body.emitter.emit("stabilized",{iterations:e}),t.startedStabilization=!1,t.stabilizationIterations=0},0)}},{key:"physicsStep",value:function(){this.gravitySolver.solve(),this.nodesSolver.solve(),this.edgesSolver.solve(),this.moveNodes()}},{key:"adjustTimeStep",value:function(){!0===this._evaluateStepQuality()?this.timestep=1.2*this.timestep:this.timestep/1.2<this.options.timestep?this.timestep=this.options.timestep:(this.adaptiveCounter=-1,this.timestep=Math.max(this.options.timestep,this.timestep/1.2))}},{key:"physicsTick",value:function(){if(this._startStabilizing(),!0!==this.stabilized){if(!0===this.adaptiveTimestep&&!0===this.adaptiveTimestepEnabled){this.adaptiveCounter%this.adaptiveInterval==0?(this.timestep=2*this.timestep,this.physicsStep(),this.revert(),this.timestep=.5*this.timestep,this.physicsStep(),this.physicsStep(),this.adjustTimeStep()):this.physicsStep(),this.adaptiveCounter+=1}else this.timestep=this.options.timestep,this.physicsStep();!0===this.stabilized&&this.revert(),this.stabilizationIterations++}}},{key:"updatePhysicsData",value:function(){this.physicsBody.forces={},this.physicsBody.physicsNodeIndices=[],this.physicsBody.physicsEdgeIndices=[];var t=this.body.nodes,e=this.body.edges;for(var i in t)t.hasOwnProperty(i)&&!0===t[i].options.physics&&this.physicsBody.physicsNodeIndices.push(t[i].id);for(var o in e)e.hasOwnProperty(o)&&!0===e[o].options.physics&&this.physicsBody.physicsEdgeIndices.push(e[o].id);for(var n=0;n<this.physicsBody.physicsNodeIndices.length;n++){var s=this.physicsBody.physicsNodeIndices[n];this.physicsBody.forces[s]={x:0,y:0},void 0===this.physicsBody.velocities[s]&&(this.physicsBody.velocities[s]={x:0,y:0})}for(var r in this.physicsBody.velocities)void 0===t[r]&&delete this.physicsBody.velocities[r]}},{key:"revert",value:function(){var t=(0,s.default)(this.previousStates),e=this.body.nodes,i=this.physicsBody.velocities;this.referenceState={};for(var o=0;o<t.length;o++){var n=t[o];void 0!==e[n]?!0===e[n].options.physics&&(this.referenceState[n]={positions:{x:e[n].x,y:e[n].y}},i[n].x=this.previousStates[n].vx,i[n].y=this.previousStates[n].vy,e[n].x=this.previousStates[n].x,e[n].y=this.previousStates[n].y):delete this.previousStates[n]}}},{key:"_evaluateStepQuality",value:function(){var t=void 0,e=void 0,i=this.body.nodes,o=this.referenceState;for(var n in this.referenceState)if(this.referenceState.hasOwnProperty(n)&&void 0!==i[n]&&(t=i[n].x-o[n].positions.x,e=i[n].y-o[n].positions.y,Math.sqrt(Math.pow(t,2)+Math.pow(e,2))>.3))return!1;return!0}},{key:"moveNodes",value:function(){for(var t=this.physicsBody.physicsNodeIndices,e=0,i=0,o=0;o<t.length;o++){var n=t[o],s=this._performStep(n);e=Math.max(e,s),i+=s}this.adaptiveTimestepEnabled=i/t.length<5,this.stabilized=e<this.options.minVelocity}},{key:"calculateComponentVelocity",value:function(t,e,i){t+=(e-this.modelOptions.damping*t)/i*this.timestep;var o=this.options.maxVelocity||1e9;return Math.abs(t)>o&&(t=t>0?o:-o),t}},{key:"_performStep",value:function(t){var e=this.body.nodes[t],i=this.physicsBody.forces[t],o=this.physicsBody.velocities[t];return this.previousStates[t]={x:e.x,y:e.y,vx:o.x,vy:o.y},!1===e.options.fixed.x?(o.x=this.calculateComponentVelocity(o.x,i.x,e.options.mass),e.x+=o.x*this.timestep):(i.x=0,o.x=0),!1===e.options.fixed.y?(o.y=this.calculateComponentVelocity(o.y,i.y,e.options.mass),e.y+=o.y*this.timestep):(i.y=0,o.y=0),Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2))}},{key:"_freezeNodes",value:function(){var t=this.body.nodes;for(var e in t)if(t.hasOwnProperty(e)&&t[e].x&&t[e].y){var i=t[e].options.fixed;this.freezeCache[e]={x:i.x,y:i.y},i.x=!0,i.y=!0}}},{key:"_restoreFrozenNodes",value:function(){var t=this.body.nodes;for(var e in t)t.hasOwnProperty(e)&&void 0!==this.freezeCache[e]&&(t[e].options.fixed.x=this.freezeCache[e].x,t[e].options.fixed.y=this.freezeCache[e].y);this.freezeCache={}}},{key:"stabilize",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.stabilization.iterations;if("number"!=typeof e&&(e=this.options.stabilization.iterations,console.log("The stabilize method needs a numeric amount of iterations. Switching to default: ",e)),0===this.physicsBody.physicsNodeIndices.length)return void(this.ready=!0);this.adaptiveTimestep=this.options.adaptiveTimestep,this.body.emitter.emit("_resizeNodes"),this.stopSimulation(),this.stabilized=!1,this.body.emitter.emit("_blockRedraw"),this.targetIterations=e,!0===this.options.stabilization.onlyDynamicEdges&&this._freezeNodes(),this.stabilizationIterations=0,setTimeout(function(){return t._stabilizationBatch()},0)}},{key:"_startStabilizing",value:function(){return!0!==this.startedStabilization&&(this.body.emitter.emit("startStabilizing"),this.startedStabilization=!0,!0)}},{key:"_stabilizationBatch",value:function(){var t=this,e=function(){return!1===t.stabilized&&t.stabilizationIterations<t.targetIterations},i=function(){t.body.emitter.emit("stabilizationProgress",{iterations:t.stabilizationIterations,total:t.targetIterations})};this._startStabilizing()&&i();for(var o=0;e()&&o<this.options.stabilization.updateInterval;)this.physicsTick(),o++;i(),e()?setTimeout(this._stabilizationBatch.bind(this),0):this._finalizeStabilization()}},{key:"_finalizeStabilization",value:function(){this.body.emitter.emit("_allowRedraw"),!0===this.options.stabilization.fit&&this.body.emitter.emit("fit"),!0===this.options.stabilization.onlyDynamicEdges&&this._restoreFrozenNodes(),this.body.emitter.emit("stabilizationIterationsDone"),this.body.emitter.emit("_requestRedraw"),!0===this.stabilized?this._emitStabilized():this.startSimulation(),this.ready=!0}},{key:"_drawForces",value:function(t){for(var e=0;e<this.physicsBody.physicsNodeIndices.length;e++){var i=this.physicsBody.physicsNodeIndices[e],o=this.body.nodes[i],n=this.physicsBody.forces[i],s=Math.sqrt(Math.pow(n.x,2)+Math.pow(n.x,2)),r=Math.min(Math.max(5,s),15),a=3*r,h=y.HSVToHex((180-180*Math.min(1,Math.max(0,.03*s)))/360,1,1),d={x:o.x+20*n.x,y:o.y+20*n.y};t.lineWidth=r,t.strokeStyle=h,t.beginPath(),t.moveTo(o.x,o.y),t.lineTo(d.x,d.y),t.stroke();var l=Math.atan2(n.y,n.x);t.fillStyle=h,b.draw(t,{type:"arrow",point:d,angle:l,length:a}),t.fill()}}}]),t}();e.default=_},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=function(){function t(e,i,o){(0,s.default)(this,t),this.body=e,this.physicsBody=i,this.setOptions(o)}return(0,a.default)(t,[{key:"setOptions",value:function(t){this.options=t}},{key:"solve",value:function(){for(var t,e,i,o,n,s,r,a,h=this.body.nodes,d=this.physicsBody.physicsNodeIndices,l=this.physicsBody.forces,u=this.options.nodeDistance,c=-2/3/u,p=0;p<d.length-1;p++){r=h[d[p]];for(var f=p+1;f<d.length;f++)a=h[d[f]],t=a.x-r.x,e=a.y-r.y,i=Math.sqrt(t*t+e*e),0===i&&(i=.1*Math.random(),t=i),i<2*u&&(s=i<.5*u?1:c*i+4/3,s/=i,o=t*s,n=e*s,l[r.id].x-=o,l[r.id].y-=n,l[a.id].x+=o,l[a.id].y+=n)}}}]),t}();e.default=h},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=function(){function t(e,i,o){(0,s.default)(this,t),this.body=e,this.physicsBody=i,this.setOptions(o)}return(0,a.default)(t,[{key:"setOptions",value:function(t){this.options=t}},{key:"solve",value:function(){var t,e,i,o,n,s,r,a,h,d,l=this.body.nodes,u=this.physicsBody.physicsNodeIndices,c=this.physicsBody.forces,p=this.options.nodeDistance;for(h=0;h<u.length-1;h++)for(r=l[u[h]],d=h+1;d<u.length;d++)if(a=l[u[d]],r.level===a.level){t=a.x-r.x,e=a.y-r.y,i=Math.sqrt(t*t+e*e) +;s=i<p?-Math.pow(.05*i,2)+Math.pow(.05*p,2):0,0===i?i=.01:s/=i,o=t*s,n=e*s,c[r.id].x-=o,c[r.id].y-=n,c[a.id].x+=o,c[a.id].y+=n}}}]),t}();e.default=h},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=function(){function t(e,i,o){(0,s.default)(this,t),this.body=e,this.physicsBody=i,this.setOptions(o)}return(0,a.default)(t,[{key:"setOptions",value:function(t){this.options=t}},{key:"solve",value:function(){for(var t=void 0,e=void 0,i=this.physicsBody.physicsEdgeIndices,o=this.body.edges,n=void 0,s=void 0,r=void 0,a=0;a<i.length;a++)e=o[i[a]],!0===e.connected&&e.toId!==e.fromId&&void 0!==this.body.nodes[e.toId]&&void 0!==this.body.nodes[e.fromId]&&(void 0!==e.edgeType.via?(t=void 0===e.options.length?this.options.springLength:e.options.length,n=e.to,s=e.edgeType.via,r=e.from,this._calculateSpringForce(n,s,.5*t),this._calculateSpringForce(s,r,.5*t)):(t=void 0===e.options.length?1.5*this.options.springLength:e.options.length,this._calculateSpringForce(e.from,e.to,t)))}},{key:"_calculateSpringForce",value:function(t,e,i){var o=t.x-e.x,n=t.y-e.y,s=Math.max(Math.sqrt(o*o+n*n),.01),r=this.options.springConstant*(i-s)/s,a=o*r,h=n*r;void 0!==this.physicsBody.forces[t.id]&&(this.physicsBody.forces[t.id].x+=a,this.physicsBody.forces[t.id].y+=h),void 0!==this.physicsBody.forces[e.id]&&(this.physicsBody.forces[e.id].x-=a,this.physicsBody.forces[e.id].y-=h)}}]),t}();e.default=h},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=function(){function t(e,i,o){(0,s.default)(this,t),this.body=e,this.physicsBody=i,this.setOptions(o)}return(0,a.default)(t,[{key:"setOptions",value:function(t){this.options=t}},{key:"solve",value:function(){for(var t,e,i,o,n,s,r,a,h=this.body.edges,d=this.physicsBody.physicsEdgeIndices,l=this.physicsBody.physicsNodeIndices,u=this.physicsBody.forces,c=0;c<l.length;c++){var p=l[c];u[p].springFx=0,u[p].springFy=0}for(var f=0;f<d.length;f++)e=h[d[f]],!0===e.connected&&(t=void 0===e.options.length?this.options.springLength:e.options.length,i=e.from.x-e.to.x,o=e.from.y-e.to.y,a=Math.sqrt(i*i+o*o),a=0===a?.01:a,r=this.options.springConstant*(t-a)/a,n=i*r,s=o*r,e.to.level!=e.from.level?(void 0!==u[e.toId]&&(u[e.toId].springFx-=n,u[e.toId].springFy-=s),void 0!==u[e.fromId]&&(u[e.fromId].springFx+=n,u[e.fromId].springFy+=s)):(void 0!==u[e.toId]&&(u[e.toId].x-=.5*n,u[e.toId].y-=.5*s),void 0!==u[e.fromId]&&(u[e.fromId].x+=.5*n,u[e.fromId].y+=.5*s)));r=1;for(var m,v,g=0;g<l.length;g++){var y=l[g];m=Math.min(r,Math.max(-r,u[y].springFx)),v=Math.min(r,Math.max(-r,u[y].springFy)),u[y].x+=m,u[y].y+=v}for(var b=0,_=0,w=0;w<l.length;w++){var x=l[w];b+=u[x].x,_+=u[x].y}for(var k=b/l.length,S=_/l.length,D=0;D<l.length;D++){var M=l[D];u[M].x-=k,u[M].y-=S}}}]),t}();e.default=h},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(120),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"_calculateForces",value:function(t,e,i,o,n){0===t&&(t=.1*Math.random(),e=t),this.overlapAvoidanceFactor<1&&o.shape.radius&&(t=Math.max(.1+this.overlapAvoidanceFactor*o.shape.radius,t-o.shape.radius));var s=o.edges.length+1,r=this.options.gravitationalConstant*n.mass*o.options.mass*s/Math.pow(t,2),a=e*r,h=i*r;this.physicsBody.forces[o.id].x+=a,this.physicsBody.forces[o.id].y+=h}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(121),m=o(f),v=function(t){function e(t,i,o){return(0,a.default)(this,e),(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o))}return(0,p.default)(e,t),(0,d.default)(e,[{key:"_calculateForces",value:function(t,e,i,o,n){if(t>0){var s=n.edges.length+1,r=this.options.centralGravity*s*n.options.mass;o[n.id].x=e*r,o[n.id].y=i*r}}}]),e}(m.default);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(8),s=o(n),r=i(6),a=o(r),h=i(0),d=o(h),l=i(1),u=o(l),c=i(2),p=i(76).default,f=i(228).default,m=i(74).default,v=i(47).default,g=function(){function t(e){var i=this;(0,d.default)(this,t),this.body=e,this.clusteredNodes={},this.clusteredEdges={},this.options={},this.defaultOptions={},c.extend(this.options,this.defaultOptions),this.body.emitter.on("_resetData",function(){i.clusteredNodes={},i.clusteredEdges={}})}return(0,u.default)(t,[{key:"clusterByHubsize",value:function(t,e){void 0===t?t=this._getHubSize():"object"===(void 0===t?"undefined":(0,a.default)(t))&&(e=this._checkOptions(t),t=this._getHubSize());for(var i=[],o=0;o<this.body.nodeIndices.length;o++){var n=this.body.nodes[this.body.nodeIndices[o]];n.edges.length>=t&&i.push(n.id)}for(var s=0;s<i.length;s++)this.clusterByConnection(i[s],e,!0);this.body.emitter.emit("_dataChanged")}},{key:"cluster",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(void 0===e.joinCondition)throw new Error("Cannot call clusterByNodeData without a joinCondition function in the options.");e=this._checkOptions(e);var o={},n={};c.forEach(this.body.nodes,function(i,s){var r=p.cloneOptions(i);!0===e.joinCondition(r)&&(o[s]=i,c.forEach(i.edges,function(e){void 0===t.clusteredEdges[e.id]&&(n[e.id]=e)}))}),this._cluster(o,n,e,i)}},{key:"clusterByEdgeCount",value:function(t,e){var i=this,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e=this._checkOptions(e);for(var n=[],r={},a=void 0,h=void 0,d=void 0,l=0;l<this.body.nodeIndices.length;l++){var u,c,f;!function(o){var l={},m={},v=i.body.nodeIndices[o],g=i.body.nodes[v];if(void 0===r[v]){d=0,h=[];for(var y=0;y<g.edges.length;y++)a=g.edges[y],void 0===i.clusteredEdges[a.id]&&(a.toId!==a.fromId&&d++,h.push(a));if(d===t){u=function(t){if(void 0===e.joinCondition||null===e.joinCondition)return!0;var i=p.cloneOptions(t);return e.joinCondition(i)};for(var b=!0,_=0;_<h.length;_++){a=h[_];var w=i._getConnectedId(a,v);if(!u(g)){b=!1;break}m[a.id]=a,l[v]=g,l[w]=i.body.nodes[w],r[v]=!0}if((0,s.default)(l).length>0&&(0,s.default)(m).length>0&&!0===b)if(c=function(){for(var t=0;t<n.length;++t)for(var e in l)if(void 0!==n[t].nodes[e])return n[t]},void 0!==(f=c())){for(var x in l)void 0===f.nodes[x]&&(f.nodes[x]=l[x]);for(var k in m)void 0===f.edges[k]&&(f.edges[k]=m[k])}else n.push({nodes:l,edges:m})}}}(l)}for(var l=0;l<n.length;l++)this._cluster(n[l].nodes,n[l].edges,e,!1);!0===o&&this.body.emitter.emit("_dataChanged")}},{key:"clusterOutliers",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.clusterByEdgeCount(1,t,e)}},{key:"clusterBridges",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.clusterByEdgeCount(2,t,e)}},{key:"clusterByConnection",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0===t)throw new Error("No nodeId supplied to clusterByConnection!");if(void 0===this.body.nodes[t])throw new Error("The nodeId given to clusterByConnection does not exist!");var o=this.body.nodes[t];e=this._checkOptions(e,o),void 0===e.clusterNodeProperties.x&&(e.clusterNodeProperties.x=o.x),void 0===e.clusterNodeProperties.y&&(e.clusterNodeProperties.y=o.y),void 0===e.clusterNodeProperties.fixed&&(e.clusterNodeProperties.fixed={},e.clusterNodeProperties.fixed.x=o.options.fixed.x,e.clusterNodeProperties.fixed.y=o.options.fixed.y);var n={},r={},a=o.id,h=p.cloneOptions(o);n[a]=o;for(var d=0;d<o.edges.length;d++){var l=o.edges[d];if(void 0===this.clusteredEdges[l.id]){var u=this._getConnectedId(l,a);if(void 0===this.clusteredNodes[u])if(u!==a)if(void 0===e.joinCondition)r[l.id]=l,n[u]=this.body.nodes[u];else{var c=p.cloneOptions(this.body.nodes[u]);!0===e.joinCondition(h,c)&&(r[l.id]=l,n[u]=this.body.nodes[u])}else r[l.id]=l}}var f=(0,s.default)(n).map(function(t){return n[t].id});for(m in n)if(n.hasOwnProperty(m))for(var m=n[m],v=0;v<m.edges.length;v++){var g=m.edges[v];f.indexOf(this._getConnectedId(g,m.id))>-1&&(r[g.id]=g)}this._cluster(n,r,e,i)}},{key:"_createClusterEdges",value:function(t,e,i,o){for(var n=void 0,r=void 0,a=void 0,h=void 0,d=void 0,l=void 0,u=(0,s.default)(t),c=[],p=0;p<u.length;p++){r=u[p],a=t[r];for(var f=0;f<a.edges.length;f++)n=a.edges[f],void 0===this.clusteredEdges[n.id]&&(n.toId==n.fromId?e[n.id]=n:n.toId==r?(h=i.id,d=n.fromId,l=d):(h=n.toId,d=i.id,l=h),void 0===t[l]&&c.push({edge:n,fromId:d,toId:h}))}for(var m=[],v=0;v<c.length;v++){var g=c[v],y=g.edge,b=function(t){for(var e=0;e<m.length;e++){var i=m[e],o=t.fromId===i.fromId&&t.toId===i.toId,n=t.fromId===i.toId&&t.toId===i.fromId;if(o||n)return i}return null}(g);null===b?(b=this._createClusteredEdge(g.fromId,g.toId,y,o),m.push(b)):b.clusteringEdgeReplacingIds.push(y.id),this.body.edges[y.id].edgeReplacedById=b.id,this._backupEdgeOptions(y),y.setOptions({physics:!1})}}},{key:"_checkOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return void 0===t.clusterEdgeProperties&&(t.clusterEdgeProperties={}),void 0===t.clusterNodeProperties&&(t.clusterNodeProperties={}),t}},{key:"_cluster",value:function(t,e,i){var o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(0!=(0,s.default)(t).length&&(1!=(0,s.default)(t).length||1==i.clusterNodeProperties.allowSingleNodeCluster)){for(var n in t)if(t.hasOwnProperty(n)&&void 0!==this.clusteredNodes[n])return;var r=c.deepExtend({},i.clusterNodeProperties);if(void 0!==i.processProperties){var a=[];for(var h in t)if(t.hasOwnProperty(h)){var d=p.cloneOptions(t[h]);a.push(d)}var l=[];for(var u in e)if(e.hasOwnProperty(u)&&"clusterEdge:"!==u.substr(0,12)){var m=p.cloneOptions(e[u],"edge");l.push(m)}if(!(r=i.processProperties(r,a,l)))throw new Error("The processProperties function does not return properties!")}void 0===r.id&&(r.id="cluster:"+c.randomUUID());var v=r.id;void 0===r.label&&(r.label="cluster");var g=void 0;void 0===r.x&&(g=this._getClusterPosition(t),r.x=g.x),void 0===r.y&&(void 0===g&&(g=this._getClusterPosition(t)),r.y=g.y),r.id=v;var y=this.body.functions.createNode(r,f);y.containedNodes=t,y.containedEdges=e,y.clusterEdgeProperties=i.clusterEdgeProperties,this.body.nodes[r.id]=y,this._clusterEdges(t,e,r,i.clusterEdgeProperties),r.id=void 0,!0===o&&this.body.emitter.emit("_dataChanged")}}},{key:"_backupEdgeOptions",value:function(t){void 0===this.clusteredEdges[t.id]&&(this.clusteredEdges[t.id]={physics:t.options.physics})}},{key:"_restoreEdge",value:function(t){var e=this.clusteredEdges[t.id];void 0!==e&&(t.setOptions({physics:e.physics}),delete this.clusteredEdges[t.id])}},{key:"isCluster",value:function(t){return void 0!==this.body.nodes[t]?!0===this.body.nodes[t].isCluster:(console.log("Node does not exist."),!1)}},{key:"_getClusterPosition",value:function(t){for(var e=(0,s.default)(t),i=t[e[0]].x,o=t[e[0]].x,n=t[e[0]].y,r=t[e[0]].y,a=void 0,h=1;h<e.length;h++)a=t[e[h]],i=a.x<i?a.x:i,o=a.x>o?a.x:o,n=a.y<n?a.y:n,r=a.y>r?a.y:r;return{x:.5*(i+o),y:.5*(n+r)}}},{key:"openCluster",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0===t)throw new Error("No clusterNodeId supplied to openCluster.");var o=this.body.nodes[t];if(void 0===o)throw new Error("The clusterNodeId supplied to openCluster does not exist.");if(!0!==o.isCluster||void 0===o.containedNodes||void 0===o.containedEdges)throw new Error("The node:"+t+" is not a valid cluster.");var n=this.findNode(t),s=n.indexOf(t)-1;if(s>=0){var r=n[s];return this.body.nodes[r]._openChildCluster(t),delete this.body.nodes[t],void(!0===i&&this.body.emitter.emit("_dataChanged"))}var a=o.containedNodes,h=o.containedEdges;if(void 0!==e&&void 0!==e.releaseFunction&&"function"==typeof e.releaseFunction){var d={},l={x:o.x,y:o.y};for(var u in a)if(a.hasOwnProperty(u)){var p=this.body.nodes[u];d[u]={x:p.x,y:p.y}}var f=e.releaseFunction(l,d);for(var m in a)if(a.hasOwnProperty(m)){var v=this.body.nodes[m];void 0!==f[m]&&(v.x=void 0===f[m].x?o.x:f[m].x,v.y=void 0===f[m].y?o.y:f[m].y)}}else c.forEach(a,function(t){!1===t.options.fixed.x&&(t.x=o.x),!1===t.options.fixed.y&&(t.y=o.y)});for(var g in a)if(a.hasOwnProperty(g)){var y=this.body.nodes[g];y.vx=o.vx,y.vy=o.vy,y.setOptions({physics:!0}),delete this.clusteredNodes[g]}for(var b=[],_=0;_<o.edges.length;_++)b.push(o.edges[_]);for(var w=0;w<b.length;w++){for(var x=b[w],k=this._getConnectedId(x,t),S=this.clusteredNodes[k],D=0;D<x.clusteringEdgeReplacingIds.length;D++){var M=x.clusteringEdgeReplacingIds[D],C=this.body.edges[M];if(void 0!==C)if(void 0!==S){var O=this.body.nodes[S.clusterId];O.containedEdges[C.id]=C,delete h[C.id];var E=C.fromId,T=C.toId;C.toId==k?T=S.clusterId:E=S.clusterId,this._createClusteredEdge(E,T,C,O.clusterEdgeProperties,{hidden:!1,physics:!0})}else this._restoreEdge(C)}x.remove()}for(var P in h)h.hasOwnProperty(P)&&this._restoreEdge(h[P]);delete this.body.nodes[t],!0===i&&this.body.emitter.emit("_dataChanged")}},{key:"getNodesInCluster",value:function(t){var e=[];if(!0===this.isCluster(t)){var i=this.body.nodes[t].containedNodes;for(var o in i)i.hasOwnProperty(o)&&e.push(this.body.nodes[o].id)}return e}},{key:"findNode",value:function(t){for(var e=[],i=0,o=void 0;void 0!==this.clusteredNodes[t]&&i<100;){if(void 0===(o=this.body.nodes[t]))return[];e.push(o.id),t=this.clusteredNodes[t].clusterId,i++}return void 0===(o=this.body.nodes[t])?[]:(e.push(o.id),e.reverse(),e)}},{key:"updateClusteredNode",value:function(t,e){if(void 0===t)throw new Error("No clusteredNodeId supplied to updateClusteredNode.");if(void 0===e)throw new Error("No newOptions supplied to updateClusteredNode.");if(void 0===this.body.nodes[t])throw new Error("The clusteredNodeId supplied to updateClusteredNode does not exist.");this.body.nodes[t].setOptions(e),this.body.emitter.emit("_dataChanged")}},{key:"updateEdge",value:function(t,e){if(void 0===t)throw new Error("No startEdgeId supplied to updateEdge.");if(void 0===e)throw new Error("No newOptions supplied to updateEdge.");if(void 0===this.body.edges[t])throw new Error("The startEdgeId supplied to updateEdge does not exist.");for(var i=this.getClusteredEdges(t),o=0;o<i.length;o++){this.body.edges[i[o]].setOptions(e)}this.body.emitter.emit("_dataChanged")}},{key:"getClusteredEdges",value:function(t){for(var e=[],i=0;void 0!==t&&void 0!==this.body.edges[t]&&i<100;)e.push(this.body.edges[t].id),t=this.body.edges[t].edgeReplacedById,i++;return e.reverse(),e}},{key:"getBaseEdge",value:function(t){return this.getBaseEdges(t)[0]}},{key:"getBaseEdges",value:function(t){for(var e=[t],i=[],o=[],n=0;e.length>0&&n<100;){var s=e.pop();if(void 0!==s){var r=this.body.edges[s];if(void 0!==r){n++;var a=r.clusteringEdgeReplacingIds;if(void 0===a)o.push(s);else for(var h=0;h<a.length;++h){var d=a[h];-1===e.indexOf(a)&&-1===i.indexOf(a)&&e.push(d)}i.push(s)}}}return o}},{key:"_getConnectedId",value:function(t,e){return t.toId!=e?t.toId:(t.fromId,t.fromId)}},{key:"_getHubSize",value:function(){for(var t=0,e=0,i=0,o=0,n=0;n<this.body.nodeIndices.length;n++){var s=this.body.nodes[this.body.nodeIndices[n]];s.edges.length>o&&(o=s.edges.length),t+=s.edges.length,e+=Math.pow(s.edges.length,2),i+=1}t/=i,e/=i;var r=e-Math.pow(t,2),a=Math.sqrt(r),h=Math.floor(t+2*a);return h>o&&(h=o),h}},{key:"_createClusteredEdge",value:function(t,e,i,o,n){var s=p.cloneOptions(i,"edge");c.deepExtend(s,o),s.from=t,s.to=e,s.id="clusterEdge:"+c.randomUUID(),void 0!==n&&c.deepExtend(s,n);var r=this.body.functions.createEdge(s);return r.clusteringEdgeReplacingIds=[i.id],r.connect(),this.body.edges[r.id]=r,r}},{key:"_clusterEdges",value:function(t,e,i,o){if(e instanceof m){var n=e,s={};s[n.id]=n,e=s}if(t instanceof v){var r=t,a={};a[r.id]=r,t=a}if(void 0===i||null===i)throw new Error("_clusterEdges: parameter clusterNode required");void 0===o&&(o=i.clusterEdgeProperties),this._createClusterEdges(t,e,i,o);for(var h in e)if(e.hasOwnProperty(h)&&void 0!==this.body.edges[h]){var d=this.body.edges[h];this._backupEdgeOptions(d),d.setOptions({physics:!1})}for(var l in t)t.hasOwnProperty(l)&&(this.clusteredNodes[l]={clusterId:i.id,node:this.body.nodes[l]},this.body.nodes[l].setOptions({physics:!1}))}},{key:"_getClusterNodeForNode",value:function(t){if(void 0!==t){var e=this.clusteredNodes[t];if(void 0!==e){var i=e.clusterId;if(void 0!==i)return this.body.nodes[i]}}}},{key:"_filter",value:function(t,e){var i=[];return c.forEach(t,function(t){e(t)&&i.push(t)}),i}},{key:"_updateState",value:function(){var t=this,e=void 0,i=[],o=[],n=function(e){c.forEach(t.body.nodes,function(t){!0===t.isCluster&&e(t)})};for(e in this.clusteredNodes)if(this.clusteredNodes.hasOwnProperty(e)){var r=this.body.nodes[e];void 0===r&&i.push(e)}n(function(t){for(var e=0;e<i.length;e++)delete t.containedNodes[i[e]]});for(var a=0;a<i.length;a++)delete this.clusteredNodes[i[a]];c.forEach(this.clusteredEdges,function(e){var i=t.body.edges[e];void 0!==i&&i.endPointsValid()||o.push(e)}),n(function(t){c.forEach(t.containedEdges,function(t,e){t.endPointsValid()||-1!==o.indexOf(e)||o.push(e)})}),c.forEach(this.body.edges,function(e,i){var n=!0,s=e.clusteringEdgeReplacingIds;if(void 0!==s){var r=0;c.forEach(s,function(e){var i=t.body.edges[e];void 0!==i&&i.endPointsValid()&&(r+=1)}),n=r>0}e.endPointsValid()&&n||o.push(i)}),n(function(e){c.forEach(o,function(i){delete e.containedEdges[i],c.forEach(e.edges,function(n,s){if(n.id===i)return void(e.edges[s]=null);n.clusteringEdgeReplacingIds=t._filter(n.clusteringEdgeReplacingIds,function(t){return-1===o.indexOf(t)})}),e.edges=t._filter(e.edges,function(t){return null!==t})})}),c.forEach(o,function(e){delete t.clusteredEdges[e]}),c.forEach(o,function(e){delete t.body.edges[e]});var h=(0,s.default)(this.body.edges);c.forEach(h,function(e){var i=t.body.edges[e],o=t._isClusteredNode(i.fromId)||t._isClusteredNode(i.toId);if(o!==t._isClusteredEdge(i.id)){if(!o)throw new Error("remove edge from clustering not implemented!");var n=t._getClusterNodeForNode(i.fromId);void 0!==n&&t._clusterEdges(t.body.nodes[i.fromId],i,n);var s=t._getClusterNodeForNode(i.toId);void 0!==s&&t._clusterEdges(t.body.nodes[i.toId],i,s)}});for(var d=!1,l=!0;l;)!function(){var e=[];n(function(t){var i=(0,s.default)(t.containedNodes).length,o=!0===t.options.allowSingleNodeCluster;(o&&i<1||!o&&i<2)&&e.push(t.id)});for(var i=0;i<e.length;++i)t.openCluster(e[i],{},!1);l=e.length>0,d=d||l}();d&&this._updateState()}},{key:"_isClusteredNode",value:function(t){return void 0!==this.clusteredNodes[t]}},{key:"_isClusteredEdge",value:function(t){return void 0!==this.clusteredEdges[t]}}]),t}();e.default=g},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(3),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(4),u=o(l),c=i(5),p=o(c),f=i(2),m=i(47).default,v=function(t){function e(t,i,o,n,r,h){(0,a.default)(this,e);var d=(0,u.default)(this,(e.__proto__||(0,s.default)(e)).call(this,t,i,o,n,r,h));return d.isCluster=!0,d.containedNodes={},d.containedEdges={},d}return(0,p.default)(e,t),(0,d.default)(e,[{key:"_openChildCluster",value:function(t){var e=this,i=this.body.nodes[t];if(void 0===this.containedNodes[t])throw new Error("node with id: "+t+" not in current cluster");if(!i.isCluster)throw new Error("node with id: "+t+" is not a cluster");delete this.containedNodes[t],f.forEach(i.edges,function(t){delete e.containedEdges[t.id]}),f.forEach(i.containedNodes,function(t,i){e.containedNodes[i]=t}),i.containedNodes={},f.forEach(i.containedEdges,function(t,i){e.containedEdges[i]=t}),i.containedEdges={},f.forEach(i.edges,function(t){f.forEach(e.edges,function(i){var o=i.clusteringEdgeReplacingIds.indexOf(t.id);-1!==o&&(f.forEach(t.clusteringEdgeReplacingIds,function(t){i.clusteringEdgeReplacingIds.push(t),e.body.edges[t].edgeReplacedById=i.id}),i.clusteringEdgeReplacingIds.splice(o,1))})}),i.edges=[]}}]),e}(m);e.default=v},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(){var t;void 0!==window&&(t=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),window.requestAnimationFrame=void 0===t?function(t){t()}:t}Object.defineProperty(e,"__esModule",{value:!0});var s=i(0),r=o(s),a=i(1),h=o(a),d=i(2),l=function(){function t(e,i){(0,r.default)(this,t),n(),this.body=e,this.canvas=i,this.redrawRequested=!1,this.renderTimer=void 0,this.requiresTimeout=!0,this.renderingActive=!1,this.renderRequests=0,this.allowRedraw=!0,this.dragging=!1,this.options={},this.defaultOptions={hideEdgesOnDrag:!1,hideNodesOnDrag:!1},d.extend(this.options,this.defaultOptions),this._determineBrowserMethod(),this.bindEventListeners()}return(0,h.default)(t,[{key:"bindEventListeners",value:function(){var t=this;this.body.emitter.on("dragStart",function(){t.dragging=!0}),this.body.emitter.on("dragEnd",function(){t.dragging=!1}),this.body.emitter.on("_resizeNodes",function(){t._resizeNodes()}),this.body.emitter.on("_redraw",function(){!1===t.renderingActive&&t._redraw()}),this.body.emitter.on("_blockRedraw",function(){t.allowRedraw=!1}),this.body.emitter.on("_allowRedraw",function(){t.allowRedraw=!0,t.redrawRequested=!1}),this.body.emitter.on("_requestRedraw",this._requestRedraw.bind(this)),this.body.emitter.on("_startRendering",function(){t.renderRequests+=1,t.renderingActive=!0,t._startRendering()}),this.body.emitter.on("_stopRendering",function(){t.renderRequests-=1,t.renderingActive=t.renderRequests>0,t.renderTimer=void 0}),this.body.emitter.on("destroy",function(){t.renderRequests=0,t.allowRedraw=!1,t.renderingActive=!1,!0===t.requiresTimeout?clearTimeout(t.renderTimer):window.cancelAnimationFrame(t.renderTimer),t.body.emitter.off()})}},{key:"setOptions",value:function(t){if(void 0!==t){var e=["hideEdgesOnDrag","hideNodesOnDrag"];d.selectiveDeepExtend(e,this.options,t)}}},{key:"_requestNextFrame",value:function(t,e){if("undefined"!=typeof window){var i=void 0,o=window;return!0===this.requiresTimeout?i=o.setTimeout(t,e):o.requestAnimationFrame&&(i=o.requestAnimationFrame(t)),i}}},{key:"_startRendering",value:function(){!0===this.renderingActive&&void 0===this.renderTimer&&(this.renderTimer=this._requestNextFrame(this._renderStep.bind(this),this.simulationInterval))}},{key:"_renderStep",value:function(){!0===this.renderingActive&&(this.renderTimer=void 0,!0===this.requiresTimeout&&this._startRendering(),this._redraw(),!1===this.requiresTimeout&&this._startRendering())}},{key:"redraw",value:function(){this.body.emitter.emit("setSize"),this._redraw()}},{key:"_requestRedraw",value:function(){var t=this;!0!==this.redrawRequested&&!1===this.renderingActive&&!0===this.allowRedraw&&(this.redrawRequested=!0,this._requestNextFrame(function(){t._redraw(!1)},0))}},{key:"_redraw",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!0===this.allowRedraw){this.body.emitter.emit("initRedraw"),this.redrawRequested=!1,0!==this.canvas.frame.canvas.width&&0!==this.canvas.frame.canvas.height||this.canvas.setSize(),this.canvas.setTransform();var e=this.canvas.getContext(),i=this.canvas.frame.canvas.clientWidth,o=this.canvas.frame.canvas.clientHeight;if(e.clearRect(0,0,i,o),0===this.canvas.frame.clientWidth)return;e.save(),e.translate(this.body.view.translation.x,this.body.view.translation.y),e.scale(this.body.view.scale,this.body.view.scale),e.beginPath(),this.body.emitter.emit("beforeDrawing",e),e.closePath(),!1===t&&(!1===this.dragging||!0===this.dragging&&!1===this.options.hideEdgesOnDrag)&&this._drawEdges(e),(!1===this.dragging||!0===this.dragging&&!1===this.options.hideNodesOnDrag)&&this._drawNodes(e,t),e.beginPath(),this.body.emitter.emit("afterDrawing",e),e.closePath(),e.restore(),!0===t&&e.clearRect(0,0,i,o)}}},{key:"_resizeNodes",value:function(){this.canvas.setTransform();var t=this.canvas.getContext();t.save(),t.translate(this.body.view.translation.x,this.body.view.translation.y),t.scale(this.body.view.scale,this.body.view.scale);var e=this.body.nodes,i=void 0;for(var o in e)e.hasOwnProperty(o)&&(i=e[o],i.resize(t),i.updateBoundingBox(t,i.selected));t.restore()}},{key:"_drawNodes",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.body.nodes,o=this.body.nodeIndices,n=void 0,s=[],r=this.canvas.DOMtoCanvas({x:-20,y:-20}),a=this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth+20,y:this.canvas.frame.canvas.clientHeight+20}),h={top:r.y,left:r.x,bottom:a.y,right:a.x},d=0;d<o.length;d++)n=i[o[d]],n.isSelected()?s.push(o[d]):!0===e?n.draw(t):!0===n.isBoundingBoxOverlappingWith(h)?n.draw(t):n.updateBoundingBox(t,n.selected);for(var l=0;l<s.length;l++)n=i[s[l]],n.draw(t)}},{key:"_drawEdges",value:function(t){for(var e=this.body.edges,i=this.body.edgeIndices,o=void 0,n=0;n<i.length;n++)o=e[i[n]],!0===o.connected&&o.draw(t)}},{key:"_determineBrowserMethod",value:function(){if("undefined"!=typeof window){var t=navigator.userAgent.toLowerCase();this.requiresTimeout=!1,-1!=t.indexOf("msie 9.0")?this.requiresTimeout=!0:-1!=t.indexOf("safari")&&t.indexOf("chrome")<=-1&&(this.requiresTimeout=!0)}else this.requiresTimeout=!0}}]),t}();e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(10),d=i(37),l=i(2),u=function(){function t(e){(0,s.default)(this,t),this.body=e,this.pixelRatio=1,this.resizeTimer=void 0,this.resizeFunction=this._onResize.bind(this),this.cameraState={},this.initialized=!1,this.canvasViewCenter={},this.options={},this.defaultOptions={autoResize:!0,height:"100%",width:"100%"},l.extend(this.options,this.defaultOptions),this.bindEventListeners()}return(0,a.default)(t,[{key:"bindEventListeners",value:function(){var t=this;this.body.emitter.once("resize",function(e){0!==e.width&&(t.body.view.translation.x=.5*e.width),0!==e.height&&(t.body.view.translation.y=.5*e.height)}),this.body.emitter.on("setSize",this.setSize.bind(this)),this.body.emitter.on("destroy",function(){t.hammerFrame.destroy(),t.hammer.destroy(),t._cleanUp()})}},{key:"setOptions",value:function(t){var e=this;if(void 0!==t){var i=["width","height","autoResize"];l.selectiveDeepExtend(i,this.options,t)}!0===this.options.autoResize&&(this._cleanUp(),this.resizeTimer=setInterval(function(){!0===e.setSize()&&e.body.emitter.emit("_requestRedraw")},1e3),this.resizeFunction=this._onResize.bind(this),l.addEventListener(window,"resize",this.resizeFunction))}},{key:"_cleanUp",value:function(){void 0!==this.resizeTimer&&clearInterval(this.resizeTimer),l.removeEventListener(window,"resize",this.resizeFunction),this.resizeFunction=void 0}},{key:"_onResize",value:function(){this.setSize(),this.body.emitter.emit("_redraw")}},{key:"_getCameraState",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.pixelRatio;!0===this.initialized&&(this.cameraState.previousWidth=this.frame.canvas.width/t,this.cameraState.previousHeight=this.frame.canvas.height/t,this.cameraState.scale=this.body.view.scale,this.cameraState.position=this.DOMtoCanvas({x:.5*this.frame.canvas.width/t,y:.5*this.frame.canvas.height/t}))}},{key:"_setCameraState",value:function(){if(void 0!==this.cameraState.scale&&0!==this.frame.canvas.clientWidth&&0!==this.frame.canvas.clientHeight&&0!==this.pixelRatio&&this.cameraState.previousWidth>0){var t=this.frame.canvas.width/this.pixelRatio/this.cameraState.previousWidth,e=this.frame.canvas.height/this.pixelRatio/this.cameraState.previousHeight,i=this.cameraState.scale;1!=t&&1!=e?i=.5*this.cameraState.scale*(t+e):1!=t?i=this.cameraState.scale*t:1!=e&&(i=this.cameraState.scale*e),this.body.view.scale=i;var o=this.DOMtoCanvas({x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight}),n={x:o.x-this.cameraState.position.x,y:o.y-this.cameraState.position.y};this.body.view.translation.x+=n.x*this.body.view.scale,this.body.view.translation.y+=n.y*this.body.view.scale}}},{key:"_prepareValue",value:function(t){if("number"==typeof t)return t+"px";if("string"==typeof t){if(-1!==t.indexOf("%")||-1!==t.indexOf("px"))return t;if(-1===t.indexOf("%"))return t+"px"}throw new Error("Could not use the value supplied for width or height:"+t)}},{key:"_create",value:function(){for(;this.body.container.hasChildNodes();)this.body.container.removeChild(this.body.container.firstChild);if(this.frame=document.createElement("div"),this.frame.className="vis-network",this.frame.style.position="relative",this.frame.style.overflow="hidden",this.frame.tabIndex=900,this.frame.canvas=document.createElement("canvas"),this.frame.canvas.style.position="relative",this.frame.appendChild(this.frame.canvas),this.frame.canvas.getContext)this._setPixelRatio(),this.setTransform();else{var t=document.createElement("DIV");t.style.color="red",t.style.fontWeight="bold",t.style.padding="10px",t.innerHTML="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(t)}this.body.container.appendChild(this.frame),this.body.view.scale=1,this.body.view.translation={x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight},this._bindHammer()}},{key:"_bindHammer",value:function(){var t=this;void 0!==this.hammer&&this.hammer.destroy(),this.drag={},this.pinch={},this.hammer=new h(this.frame.canvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:h.DIRECTION_ALL}),d.onTouch(this.hammer,function(e){t.body.eventListeners.onTouch(e)}),this.hammer.on("tap",function(e){t.body.eventListeners.onTap(e)}),this.hammer.on("doubletap",function(e){t.body.eventListeners.onDoubleTap(e)}),this.hammer.on("press",function(e){t.body.eventListeners.onHold(e)}),this.hammer.on("panstart",function(e){t.body.eventListeners.onDragStart(e)}),this.hammer.on("panmove",function(e){t.body.eventListeners.onDrag(e)}),this.hammer.on("panend",function(e){t.body.eventListeners.onDragEnd(e)}),this.hammer.on("pinch",function(e){t.body.eventListeners.onPinch(e)}),this.frame.canvas.addEventListener("mousewheel",function(e){t.body.eventListeners.onMouseWheel(e)}),this.frame.canvas.addEventListener("DOMMouseScroll",function(e){t.body.eventListeners.onMouseWheel(e)}),this.frame.canvas.addEventListener("mousemove",function(e){t.body.eventListeners.onMouseMove(e)}),this.frame.canvas.addEventListener("contextmenu",function(e){t.body.eventListeners.onContext(e)}),this.hammerFrame=new h(this.frame),d.onRelease(this.hammerFrame,function(e){t.body.eventListeners.onRelease(e)})}},{key:"setSize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.width,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.height;t=this._prepareValue(t),e=this._prepareValue(e);var i=!1,o=this.frame.canvas.width,n=this.frame.canvas.height,s=this.pixelRatio;if(this._setPixelRatio(),t!=this.options.width||e!=this.options.height||this.frame.style.width!=t||this.frame.style.height!=e)this._getCameraState(s),this.frame.style.width=t,this.frame.style.height=e,this.frame.canvas.style.width="100%",this.frame.canvas.style.height="100%",this.frame.canvas.width=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),this.frame.canvas.height=Math.round(this.frame.canvas.clientHeight*this.pixelRatio),this.options.width=t,this.options.height=e,this.canvasViewCenter={x:.5*this.frame.clientWidth,y:.5*this.frame.clientHeight},i=!0;else{var r=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),a=Math.round(this.frame.canvas.clientHeight*this.pixelRatio);this.frame.canvas.width===r&&this.frame.canvas.height===a||this._getCameraState(s), +this.frame.canvas.width!==r&&(this.frame.canvas.width=r,i=!0),this.frame.canvas.height!==a&&(this.frame.canvas.height=a,i=!0)}return!0===i&&(this.body.emitter.emit("resize",{width:Math.round(this.frame.canvas.width/this.pixelRatio),height:Math.round(this.frame.canvas.height/this.pixelRatio),oldWidth:Math.round(o/this.pixelRatio),oldHeight:Math.round(n/this.pixelRatio)}),this._setCameraState()),this.initialized=!0,i}},{key:"getContext",value:function(){return this.frame.canvas.getContext("2d")}},{key:"_determinePixelRatio",value:function(){var t=this.getContext();if(void 0===t)throw new Error("Could not get canvax context");var e=1;return"undefined"!=typeof window&&(e=window.devicePixelRatio||1),e/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)}},{key:"_setPixelRatio",value:function(){this.pixelRatio=this._determinePixelRatio()}},{key:"setTransform",value:function(){var t=this.getContext();if(void 0===t)throw new Error("Could not get canvax context");t.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}},{key:"_XconvertDOMtoCanvas",value:function(t){return(t-this.body.view.translation.x)/this.body.view.scale}},{key:"_XconvertCanvasToDOM",value:function(t){return t*this.body.view.scale+this.body.view.translation.x}},{key:"_YconvertDOMtoCanvas",value:function(t){return(t-this.body.view.translation.y)/this.body.view.scale}},{key:"_YconvertCanvasToDOM",value:function(t){return t*this.body.view.scale+this.body.view.translation.y}},{key:"canvasToDOM",value:function(t){return{x:this._XconvertCanvasToDOM(t.x),y:this._YconvertCanvasToDOM(t.y)}}},{key:"DOMtoCanvas",value:function(t){return{x:this._XconvertDOMtoCanvas(t.x),y:this._YconvertDOMtoCanvas(t.y)}}}]),t}();e.default=u},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(2),d=i(76).default,l=function(){function t(e,i){var o=this;(0,s.default)(this,t),this.body=e,this.canvas=i,this.animationSpeed=1/this.renderRefreshRate,this.animationEasingFunction="easeInOutQuint",this.easingTime=0,this.sourceScale=0,this.targetScale=0,this.sourceTranslation=0,this.targetTranslation=0,this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0,this.touchTime=0,this.viewFunction=void 0,this.body.emitter.on("fit",this.fit.bind(this)),this.body.emitter.on("animationFinished",function(){o.body.emitter.emit("_stopRendering")}),this.body.emitter.on("unlockNode",this.releaseNode.bind(this))}return(0,a.default)(t,[{key:"setOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=t}},{key:"fit",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{nodes:[]},e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=void 0,o=void 0;if(void 0!==t.nodes&&0!==t.nodes.length||(t.nodes=this.body.nodeIndices),!0===e){var n=0;for(var s in this.body.nodes)if(this.body.nodes.hasOwnProperty(s)){var r=this.body.nodes[s];!0===r.predefinedPosition&&(n+=1)}if(n>.5*this.body.nodeIndices.length)return void this.fit(t,!1);i=d.getRange(this.body.nodes,t.nodes);o=12.662/(this.body.nodeIndices.length+7.4147)+.0964822;o*=Math.min(this.canvas.frame.canvas.clientWidth/600,this.canvas.frame.canvas.clientHeight/600)}else{this.body.emitter.emit("_resizeNodes"),i=d.getRange(this.body.nodes,t.nodes);var a=1.1*Math.abs(i.maxX-i.minX),h=1.1*Math.abs(i.maxY-i.minY),l=this.canvas.frame.canvas.clientWidth/a,u=this.canvas.frame.canvas.clientHeight/h;o=l<=u?l:u}o>1?o=1:0===o&&(o=1);var c=d.findCenter(i),p={position:c,scale:o,animation:t.animation};this.moveTo(p)}},{key:"focus",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==this.body.nodes[t]){var i={x:this.body.nodes[t].x,y:this.body.nodes[t].y};e.position=i,e.lockedOnNode=t,this.moveTo(e)}else console.log("Node: "+t+" cannot be found.")}},{key:"moveTo",value:function(t){if(void 0===t)return void(t={});void 0===t.offset&&(t.offset={x:0,y:0}),void 0===t.offset.x&&(t.offset.x=0),void 0===t.offset.y&&(t.offset.y=0),void 0===t.scale&&(t.scale=this.body.view.scale),void 0===t.position&&(t.position=this.getViewPosition()),void 0===t.animation&&(t.animation={duration:0}),!1===t.animation&&(t.animation={duration:0}),!0===t.animation&&(t.animation={}),void 0===t.animation.duration&&(t.animation.duration=1e3),void 0===t.animation.easingFunction&&(t.animation.easingFunction="easeInOutQuad"),this.animateView(t)}},{key:"animateView",value:function(t){if(void 0!==t){this.animationEasingFunction=t.animation.easingFunction,this.releaseNode(),!0===t.locked&&(this.lockedOnNodeId=t.lockedOnNode,this.lockedOnNodeOffset=t.offset),0!=this.easingTime&&this._transitionRedraw(!0),this.sourceScale=this.body.view.scale,this.sourceTranslation=this.body.view.translation,this.targetScale=t.scale,this.body.view.scale=this.targetScale;var e=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:e.x-t.position.x,y:e.y-t.position.y};this.targetTranslation={x:this.sourceTranslation.x+i.x*this.targetScale+t.offset.x,y:this.sourceTranslation.y+i.y*this.targetScale+t.offset.y},0===t.animation.duration?void 0!=this.lockedOnNodeId?(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)):(this.body.view.scale=this.targetScale,this.body.view.translation=this.targetTranslation,this.body.emitter.emit("_requestRedraw")):(this.animationSpeed=1/(60*t.animation.duration*.001)||1/60,this.animationEasingFunction=t.animation.easingFunction,this.viewFunction=this._transitionRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))}}},{key:"_lockedRedraw",value:function(){var t={x:this.body.nodes[this.lockedOnNodeId].x,y:this.body.nodes[this.lockedOnNodeId].y},e=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:e.x-t.x,y:e.y-t.y},o=this.body.view.translation,n={x:o.x+i.x*this.body.view.scale+this.lockedOnNodeOffset.x,y:o.y+i.y*this.body.view.scale+this.lockedOnNodeOffset.y};this.body.view.translation=n}},{key:"releaseNode",value:function(){void 0!==this.lockedOnNodeId&&void 0!==this.viewFunction&&(this.body.emitter.off("initRedraw",this.viewFunction),this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0)}},{key:"_transitionRedraw",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.easingTime+=this.animationSpeed,this.easingTime=!0===t?1:this.easingTime;var e=h.easingFunctions[this.animationEasingFunction](this.easingTime);this.body.view.scale=this.sourceScale+(this.targetScale-this.sourceScale)*e,this.body.view.translation={x:this.sourceTranslation.x+(this.targetTranslation.x-this.sourceTranslation.x)*e,y:this.sourceTranslation.y+(this.targetTranslation.y-this.sourceTranslation.y)*e},this.easingTime>=1&&(this.body.emitter.off("initRedraw",this.viewFunction),this.easingTime=0,void 0!=this.lockedOnNodeId&&(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)),this.body.emitter.emit("animationFinished"))}},{key:"getScale",value:function(){return this.body.view.scale}},{key:"getViewPosition",value:function(){return this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight})}}]),t}();e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(2),d=i(233).default,l=i(104).default,u=function(){function t(e,i,o){(0,s.default)(this,t),this.body=e,this.canvas=i,this.selectionHandler=o,this.navigationHandler=new d(e,i),this.body.eventListeners.onTap=this.onTap.bind(this),this.body.eventListeners.onTouch=this.onTouch.bind(this),this.body.eventListeners.onDoubleTap=this.onDoubleTap.bind(this),this.body.eventListeners.onHold=this.onHold.bind(this),this.body.eventListeners.onDragStart=this.onDragStart.bind(this),this.body.eventListeners.onDrag=this.onDrag.bind(this),this.body.eventListeners.onDragEnd=this.onDragEnd.bind(this),this.body.eventListeners.onMouseWheel=this.onMouseWheel.bind(this),this.body.eventListeners.onPinch=this.onPinch.bind(this),this.body.eventListeners.onMouseMove=this.onMouseMove.bind(this),this.body.eventListeners.onRelease=this.onRelease.bind(this),this.body.eventListeners.onContext=this.onContext.bind(this),this.touchTime=0,this.drag={},this.pinch={},this.popup=void 0,this.popupObj=void 0,this.popupTimer=void 0,this.body.functions.getPointer=this.getPointer.bind(this),this.options={},this.defaultOptions={dragNodes:!0,dragView:!0,hover:!1,keyboard:{enabled:!1,speed:{x:10,y:10,zoom:.02},bindToWindow:!0},navigationButtons:!1,tooltipDelay:300,zoomView:!0},h.extend(this.options,this.defaultOptions),this.bindEventListeners()}return(0,a.default)(t,[{key:"bindEventListeners",value:function(){var t=this;this.body.emitter.on("destroy",function(){clearTimeout(t.popupTimer),delete t.body.functions.getPointer})}},{key:"setOptions",value:function(t){if(void 0!==t){var e=["hideEdgesOnDrag","hideNodesOnDrag","keyboard","multiselect","selectable","selectConnectedEdges"];h.selectiveNotDeepExtend(e,this.options,t),h.mergeOptions(this.options,t,"keyboard"),t.tooltip&&(h.extend(this.options.tooltip,t.tooltip),t.tooltip.color&&(this.options.tooltip.color=h.parseColor(t.tooltip.color)))}this.navigationHandler.setOptions(this.options)}},{key:"getPointer",value:function(t){return{x:t.x-h.getAbsoluteLeft(this.canvas.frame.canvas),y:t.y-h.getAbsoluteTop(this.canvas.frame.canvas)}}},{key:"onTouch",value:function(t){(new Date).valueOf()-this.touchTime>50&&(this.drag.pointer=this.getPointer(t.center),this.drag.pinched=!1,this.pinch.scale=this.body.view.scale,this.touchTime=(new Date).valueOf())}},{key:"onTap",value:function(t){var e=this.getPointer(t.center),i=this.selectionHandler.options.multiselect&&(t.changedPointers[0].ctrlKey||t.changedPointers[0].metaKey);this.checkSelectionChanges(e,t,i),this.selectionHandler._generateClickEvent("click",t,e)}},{key:"onDoubleTap",value:function(t){var e=this.getPointer(t.center);this.selectionHandler._generateClickEvent("doubleClick",t,e)}},{key:"onHold",value:function(t){var e=this.getPointer(t.center),i=this.selectionHandler.options.multiselect;this.checkSelectionChanges(e,t,i),this.selectionHandler._generateClickEvent("click",t,e),this.selectionHandler._generateClickEvent("hold",t,e)}},{key:"onRelease",value:function(t){if((new Date).valueOf()-this.touchTime>10){var e=this.getPointer(t.center);this.selectionHandler._generateClickEvent("release",t,e),this.touchTime=(new Date).valueOf()}}},{key:"onContext",value:function(t){var e=this.getPointer({x:t.clientX,y:t.clientY});this.selectionHandler._generateClickEvent("oncontext",t,e)}},{key:"checkSelectionChanges",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=this.selectionHandler.getSelection(),n=!1;n=!0===i?this.selectionHandler.selectAdditionalOnPoint(t):this.selectionHandler.selectOnPoint(t);var s=this.selectionHandler.getSelection(),r=this._determineDifference(o,s),a=this._determineDifference(s,o);r.edges.length>0&&(this.selectionHandler._generateClickEvent("deselectEdge",e,t,o),n=!0),r.nodes.length>0&&(this.selectionHandler._generateClickEvent("deselectNode",e,t,o),n=!0),a.nodes.length>0&&(this.selectionHandler._generateClickEvent("selectNode",e,t),n=!0),a.edges.length>0&&(this.selectionHandler._generateClickEvent("selectEdge",e,t),n=!0),!0===n&&this.selectionHandler._generateClickEvent("select",e,t)}},{key:"_determineDifference",value:function(t,e){var i=function(t,e){for(var i=[],o=0;o<t.length;o++){var n=t[o];-1===e.indexOf(n)&&i.push(n)}return i};return{nodes:i(t.nodes,e.nodes),edges:i(t.edges,e.edges)}}},{key:"onDragStart",value:function(t){void 0===this.drag.pointer&&this.onTouch(t);var e=this.selectionHandler.getNodeAt(this.drag.pointer);if(this.drag.dragging=!0,this.drag.selection=[],this.drag.translation=h.extend({},this.body.view.translation),this.drag.nodeId=void 0,void 0!==e&&!0===this.options.dragNodes){this.drag.nodeId=e.id,!1===e.isSelected()&&(this.selectionHandler.unselectAll(),this.selectionHandler.selectObject(e)),this.selectionHandler._generateClickEvent("dragStart",t,this.drag.pointer);var i=this.selectionHandler.selectionObj.nodes;for(var o in i)if(i.hasOwnProperty(o)){var n=i[o],s={id:n.id,node:n,x:n.x,y:n.y,xFixed:n.options.fixed.x,yFixed:n.options.fixed.y};n.options.fixed.x=!0,n.options.fixed.y=!0,this.drag.selection.push(s)}}else this.selectionHandler._generateClickEvent("dragStart",t,this.drag.pointer,void 0,!0)}},{key:"onDrag",value:function(t){var e=this;if(!0!==this.drag.pinched){this.body.emitter.emit("unlockNode");var i=this.getPointer(t.center),o=this.drag.selection;if(o&&o.length&&!0===this.options.dragNodes){this.selectionHandler._generateClickEvent("dragging",t,i);var n=i.x-this.drag.pointer.x,s=i.y-this.drag.pointer.y;o.forEach(function(t){var i=t.node;!1===t.xFixed&&(i.x=e.canvas._XconvertDOMtoCanvas(e.canvas._XconvertCanvasToDOM(t.x)+n)),!1===t.yFixed&&(i.y=e.canvas._YconvertDOMtoCanvas(e.canvas._YconvertCanvasToDOM(t.y)+s))}),this.body.emitter.emit("startSimulation")}else if(!0===this.options.dragView){if(this.selectionHandler._generateClickEvent("dragging",t,i,void 0,!0),void 0===this.drag.pointer)return void this.onDragStart(t);var r=i.x-this.drag.pointer.x,a=i.y-this.drag.pointer.y;this.body.view.translation={x:this.drag.translation.x+r,y:this.drag.translation.y+a},this.body.emitter.emit("_requestRedraw")}}}},{key:"onDragEnd",value:function(t){this.drag.dragging=!1;var e=this.drag.selection;e&&e.length?(e.forEach(function(t){t.node.options.fixed.x=t.xFixed,t.node.options.fixed.y=t.yFixed}),this.selectionHandler._generateClickEvent("dragEnd",t,this.getPointer(t.center)),this.body.emitter.emit("startSimulation")):(this.selectionHandler._generateClickEvent("dragEnd",t,this.getPointer(t.center),void 0,!0),this.body.emitter.emit("_requestRedraw"))}},{key:"onPinch",value:function(t){var e=this.getPointer(t.center);this.drag.pinched=!0,void 0===this.pinch.scale&&(this.pinch.scale=1);var i=this.pinch.scale*t.scale;this.zoom(i,e)}},{key:"zoom",value:function(t,e){if(!0===this.options.zoomView){var i=this.body.view.scale;t<1e-5&&(t=1e-5),t>10&&(t=10);var o=void 0;void 0!==this.drag&&!0===this.drag.dragging&&(o=this.canvas.DOMtoCanvas(this.drag.pointer));var n=this.body.view.translation,s=t/i,r=(1-s)*e.x+n.x*s,a=(1-s)*e.y+n.y*s;if(this.body.view.scale=t,this.body.view.translation={x:r,y:a},void 0!=o){var h=this.canvas.canvasToDOM(o);this.drag.pointer.x=h.x,this.drag.pointer.y=h.y}this.body.emitter.emit("_requestRedraw"),i<t?this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale,pointer:e}):this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale,pointer:e})}}},{key:"onMouseWheel",value:function(t){if(!0===this.options.zoomView){var e=0;if(t.wheelDelta?e=t.wheelDelta/120:t.detail&&(e=-t.detail/3),0!==e){var i=this.body.view.scale,o=e/10;e<0&&(o/=1-o),i*=1+o;var n=this.getPointer({x:t.clientX,y:t.clientY});this.zoom(i,n)}t.preventDefault()}}},{key:"onMouseMove",value:function(t){var e=this,i=this.getPointer({x:t.clientX,y:t.clientY}),o=!1;void 0!==this.popup&&(!1===this.popup.hidden&&this._checkHidePopup(i),!1===this.popup.hidden&&(o=!0,this.popup.setPosition(i.x+3,i.y-5),this.popup.show())),!1===this.options.keyboard.bindToWindow&&!0===this.options.keyboard.enabled&&this.canvas.frame.focus(),!1===o&&(void 0!==this.popupTimer&&(clearInterval(this.popupTimer),this.popupTimer=void 0),this.drag.dragging||(this.popupTimer=setTimeout(function(){return e._checkShowPopup(i)},this.options.tooltipDelay))),!0===this.options.hover&&this.selectionHandler.hoverObject(t,i)}},{key:"_checkShowPopup",value:function(t){var e=this.canvas._XconvertDOMtoCanvas(t.x),i=this.canvas._YconvertDOMtoCanvas(t.y),o={left:e,top:i,right:e,bottom:i},n=void 0===this.popupObj?void 0:this.popupObj.id,s=!1,r="node";if(void 0===this.popupObj){for(var a=this.body.nodeIndices,h=this.body.nodes,d=void 0,u=[],c=0;c<a.length;c++)d=h[a[c]],!0===d.isOverlappingWith(o)&&void 0!==d.getTitle()&&u.push(a[c]);u.length>0&&(this.popupObj=h[u[u.length-1]],s=!0)}if(void 0===this.popupObj&&!1===s){for(var p=this.body.edgeIndices,f=this.body.edges,m=void 0,v=[],g=0;g<p.length;g++)m=f[p[g]],!0===m.isOverlappingWith(o)&&!0===m.connected&&void 0!==m.getTitle()&&v.push(p[g]);v.length>0&&(this.popupObj=f[v[v.length-1]],r="edge")}void 0!==this.popupObj?this.popupObj.id!==n&&(void 0===this.popup&&(this.popup=new l(this.canvas.frame)),this.popup.popupTargetType=r,this.popup.popupTargetId=this.popupObj.id,this.popup.setPosition(t.x+3,t.y-5),this.popup.setText(this.popupObj.getTitle()),this.popup.show(),this.body.emitter.emit("showPopup",this.popupObj.id)):void 0!==this.popup&&(this.popup.hide(),this.body.emitter.emit("hidePopup"))}},{key:"_checkHidePopup",value:function(t){var e=this.selectionHandler._pointerToPositionObject(t),i=!1;if("node"===this.popup.popupTargetType){if(void 0!==this.body.nodes[this.popup.popupTargetId]&&!0===(i=this.body.nodes[this.popup.popupTargetId].isOverlappingWith(e))){var o=this.selectionHandler.getNodeAt(t);i=void 0!==o&&o.id===this.popup.popupTargetId}}else void 0===this.selectionHandler.getNodeAt(t)&&void 0!==this.body.edges[this.popup.popupTargetId]&&(i=this.body.edges[this.popup.popupTargetId].isOverlappingWith(e));!1===i&&(this.popupObj=void 0,this.popup.hide(),this.body.emitter.emit("hidePopup"))}}]),t}();e.default=u},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(10),d=i(37),l=i(35),u=function(){function t(e,i){var o=this;(0,s.default)(this,t),this.body=e,this.canvas=i,this.iconsCreated=!1,this.navigationHammers=[],this.boundFunctions={},this.touchTime=0,this.activated=!1,this.body.emitter.on("activate",function(){o.activated=!0,o.configureKeyboardBindings()}),this.body.emitter.on("deactivate",function(){o.activated=!1,o.configureKeyboardBindings()}),this.body.emitter.on("destroy",function(){void 0!==o.keycharm&&o.keycharm.destroy()}),this.options={}}return(0,a.default)(t,[{key:"setOptions",value:function(t){void 0!==t&&(this.options=t,this.create())}},{key:"create",value:function(){!0===this.options.navigationButtons?!1===this.iconsCreated&&this.loadNavigationElements():!0===this.iconsCreated&&this.cleanNavigation(),this.configureKeyboardBindings()}},{key:"cleanNavigation",value:function(){if(0!=this.navigationHammers.length){for(var t=0;t<this.navigationHammers.length;t++)this.navigationHammers[t].destroy();this.navigationHammers=[]}this.navigationDOM&&this.navigationDOM.wrapper&&this.navigationDOM.wrapper.parentNode&&this.navigationDOM.wrapper.parentNode.removeChild(this.navigationDOM.wrapper),this.iconsCreated=!1}},{key:"loadNavigationElements",value:function(){var t=this;this.cleanNavigation(),this.navigationDOM={};var e=["up","down","left","right","zoomIn","zoomOut","zoomExtends"],i=["_moveUp","_moveDown","_moveLeft","_moveRight","_zoomIn","_zoomOut","_fit"];this.navigationDOM.wrapper=document.createElement("div"),this.navigationDOM.wrapper.className="vis-navigation",this.canvas.frame.appendChild(this.navigationDOM.wrapper);for(var o=0;o<e.length;o++){this.navigationDOM[e[o]]=document.createElement("div"),this.navigationDOM[e[o]].className="vis-button vis-"+e[o],this.navigationDOM.wrapper.appendChild(this.navigationDOM[e[o]]);var n=new h(this.navigationDOM[e[o]]);"_fit"===i[o]?d.onTouch(n,this._fit.bind(this)):d.onTouch(n,this.bindToRedraw.bind(this,i[o])),this.navigationHammers.push(n)}var s=new h(this.canvas.frame);d.onRelease(s,function(){t._stopMovement()}),this.navigationHammers.push(s),this.iconsCreated=!0}},{key:"bindToRedraw",value:function(t){void 0===this.boundFunctions[t]&&(this.boundFunctions[t]=this[t].bind(this),this.body.emitter.on("initRedraw",this.boundFunctions[t]),this.body.emitter.emit("_startRendering"))}},{key:"unbindFromRedraw",value:function(t){void 0!==this.boundFunctions[t]&&(this.body.emitter.off("initRedraw",this.boundFunctions[t]),this.body.emitter.emit("_stopRendering"),delete this.boundFunctions[t])}},{key:"_fit",value:function(){(new Date).valueOf()-this.touchTime>700&&(this.body.emitter.emit("fit",{duration:700}),this.touchTime=(new Date).valueOf())}},{key:"_stopMovement",value:function(){for(var t in this.boundFunctions)this.boundFunctions.hasOwnProperty(t)&&(this.body.emitter.off("initRedraw",this.boundFunctions[t]),this.body.emitter.emit("_stopRendering"));this.boundFunctions={}}},{key:"_moveUp",value:function(){this.body.view.translation.y+=this.options.keyboard.speed.y}},{key:"_moveDown",value:function(){this.body.view.translation.y-=this.options.keyboard.speed.y}},{key:"_moveLeft",value:function(){this.body.view.translation.x+=this.options.keyboard.speed.x}},{key:"_moveRight",value:function(){this.body.view.translation.x-=this.options.keyboard.speed.x}},{key:"_zoomIn",value:function(){var t=this.body.view.scale,e=this.body.view.scale*(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,o=e/t,n=(1-o)*this.canvas.canvasViewCenter.x+i.x*o,s=(1-o)*this.canvas.canvasViewCenter.y+i.y*o;this.body.view.scale=e,this.body.view.translation={x:n,y:s},this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale,pointer:null})}},{key:"_zoomOut",value:function(){var t=this.body.view.scale,e=this.body.view.scale/(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,o=e/t,n=(1-o)*this.canvas.canvasViewCenter.x+i.x*o,s=(1-o)*this.canvas.canvasViewCenter.y+i.y*o;this.body.view.scale=e,this.body.view.translation={x:n,y:s},this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale,pointer:null})}},{key:"configureKeyboardBindings",value:function(){var t=this;void 0!==this.keycharm&&this.keycharm.destroy(),!0===this.options.keyboard.enabled&&(!0===this.options.keyboard.bindToWindow?this.keycharm=l({container:window,preventDefault:!0}):this.keycharm=l({container:this.canvas.frame,preventDefault:!0}),this.keycharm.reset(),!0===this.activated&&(this.keycharm.bind("up",function(){t.bindToRedraw("_moveUp")},"keydown"),this.keycharm.bind("down",function(){t.bindToRedraw("_moveDown")},"keydown"),this.keycharm.bind("left",function(){t.bindToRedraw("_moveLeft")},"keydown"),this.keycharm.bind("right",function(){t.bindToRedraw("_moveRight")},"keydown"),this.keycharm.bind("=",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num+",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num-",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("-",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("[",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("]",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pageup",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pagedown",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("up",function(){t.unbindFromRedraw("_moveUp")},"keyup"),this.keycharm.bind("down",function(){t.unbindFromRedraw("_moveDown")},"keyup"),this.keycharm.bind("left",function(){t.unbindFromRedraw("_moveLeft")},"keyup"),this.keycharm.bind("right",function(){t.unbindFromRedraw("_moveRight")},"keyup"),this.keycharm.bind("=",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num+",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num-",function(){t.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("-",function(){t.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("[",function(){t.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("]",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pageup",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pagedown",function(){t.unbindFromRedraw("_zoomOut")},"keyup")))}}]),t}();e.default=u},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=i(47).default,d=i(74).default,l=i(2),u=function(){function t(e,i){var o=this;(0,s.default)(this,t),this.body=e,this.canvas=i,this.selectionObj={nodes:[],edges:[]},this.hoverObj={nodes:{},edges:{}},this.options={},this.defaultOptions={multiselect:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0},l.extend(this.options,this.defaultOptions),this.body.emitter.on("_dataChanged",function(){o.updateSelection()})}return(0,a.default)(t,[{key:"setOptions",value:function(t){if(void 0!==t){var e=["multiselect","hoverConnectedEdges","selectable","selectConnectedEdges"];l.selectiveDeepExtend(e,this.options,t)}}},{key:"selectOnPoint",value:function(t){var e=!1;if(!0===this.options.selectable){var i=this.getNodeAt(t)||this.getEdgeAt(t);this.unselectAll(),void 0!==i&&(e=this.selectObject(i)),this.body.emitter.emit("_requestRedraw")}return e}},{key:"selectAdditionalOnPoint",value:function(t){var e=!1;if(!0===this.options.selectable){var i=this.getNodeAt(t)||this.getEdgeAt(t);void 0!==i&&(e=!0,!0===i.isSelected()?this.deselectObject(i):this.selectObject(i),this.body.emitter.emit("_requestRedraw"))}return e}},{key:"_initBaseEvent",value:function(t,e){var i={};return i.pointer={DOM:{x:e.x,y:e.y},canvas:this.canvas.DOMtoCanvas(e)},i.event=t,i}},{key:"_generateClickEvent",value:function(t,e,i,o){var n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=this._initBaseEvent(e,i);if(!0===n)s.nodes=[],s.edges=[];else{var r=this.getSelection();s.nodes=r.nodes,s.edges=r.edges}void 0!==o&&(s.previousSelection=o),"click"==t&&(s.items=this.getClickedItems(i)),this.body.emitter.emit(t,s)}},{key:"selectObject",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.selectConnectedEdges;return void 0!==t&&(t instanceof h&&!0===e&&this._selectConnectedEdges(t),t.select(),this._addToSelection(t),!0)}},{key:"deselectObject",value:function(t){!0===t.isSelected()&&(t.selected=!1,this._removeFromSelection(t))}},{key:"_getAllNodesOverlappingWith",value:function(t){for(var e=[],i=this.body.nodes,o=0;o<this.body.nodeIndices.length;o++){var n=this.body.nodeIndices[o];i[n].isOverlappingWith(t)&&e.push(n)}return e}},{key:"_pointerToPositionObject",value:function(t){var e=this.canvas.DOMtoCanvas(t);return{left:e.x-1,top:e.y+1,right:e.x+1,bottom:e.y-1}}},{key:"getNodeAt",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this._pointerToPositionObject(t),o=this._getAllNodesOverlappingWith(i);return o.length>0?!0===e?this.body.nodes[o[o.length-1]]:o[o.length-1]:void 0}},{key:"_getEdgesOverlappingWith",value:function(t,e){for(var i=this.body.edges,o=0;o<this.body.edgeIndices.length;o++){var n=this.body.edgeIndices[o];i[n].isOverlappingWith(t)&&e.push(n)}}},{key:"_getAllEdgesOverlappingWith",value:function(t){var e=[];return this._getEdgesOverlappingWith(t,e),e}},{key:"getEdgeAt",value:function(t){for(var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.canvas.DOMtoCanvas(t),o=10,n=null,s=this.body.edges,r=0;r<this.body.edgeIndices.length;r++){var a=this.body.edgeIndices[r],h=s[a];if(h.connected){var d=h.from.x,l=h.from.y,u=h.to.x,c=h.to.y,p=h.edgeType.getDistanceToEdge(d,l,u,c,i.x,i.y);p<o&&(n=a,o=p)}}return null!==n?!0===e?this.body.edges[n]:n:void 0}},{key:"_addToSelection",value:function(t){t instanceof h?this.selectionObj.nodes[t.id]=t:this.selectionObj.edges[t.id]=t}},{key:"_addToHover",value:function(t){t instanceof h?this.hoverObj.nodes[t.id]=t:this.hoverObj.edges[t.id]=t}},{key:"_removeFromSelection",value:function(t){t instanceof h?(delete this.selectionObj.nodes[t.id],this._unselectConnectedEdges(t)):delete this.selectionObj.edges[t.id]}},{key:"unselectAll",value:function(){for(var t in this.selectionObj.nodes)this.selectionObj.nodes.hasOwnProperty(t)&&this.selectionObj.nodes[t].unselect();for(var e in this.selectionObj.edges)this.selectionObj.edges.hasOwnProperty(e)&&this.selectionObj.edges[e].unselect();this.selectionObj={nodes:{},edges:{}}}},{key:"_getSelectedNodeCount",value:function(){var t=0;for(var e in this.selectionObj.nodes)this.selectionObj.nodes.hasOwnProperty(e)&&(t+=1);return t}},{key:"_getSelectedNode",value:function(){for(var t in this.selectionObj.nodes)if(this.selectionObj.nodes.hasOwnProperty(t))return this.selectionObj.nodes[t]}},{key:"_getSelectedEdge",value:function(){for(var t in this.selectionObj.edges)if(this.selectionObj.edges.hasOwnProperty(t))return this.selectionObj.edges[t]}},{key:"_getSelectedEdgeCount",value:function(){var t=0;for(var e in this.selectionObj.edges)this.selectionObj.edges.hasOwnProperty(e)&&(t+=1);return t}},{key:"_getSelectedObjectCount",value:function(){var t=0;for(var e in this.selectionObj.nodes)this.selectionObj.nodes.hasOwnProperty(e)&&(t+=1);for(var i in this.selectionObj.edges)this.selectionObj.edges.hasOwnProperty(i)&&(t+=1);return t}},{key:"_selectionIsEmpty",value:function(){for(var t in this.selectionObj.nodes)if(this.selectionObj.nodes.hasOwnProperty(t))return!1;for(var e in this.selectionObj.edges)if(this.selectionObj.edges.hasOwnProperty(e))return!1;return!0}},{key:"_clusterInSelection",value:function(){for(var t in this.selectionObj.nodes)if(this.selectionObj.nodes.hasOwnProperty(t)&&this.selectionObj.nodes[t].clusterSize>1)return!0;return!1}},{key:"_selectConnectedEdges",value:function(t){for(var e=0;e<t.edges.length;e++){var i=t.edges[e];i.select(),this._addToSelection(i)}}},{key:"_hoverConnectedEdges",value:function(t){for(var e=0;e<t.edges.length;e++){var i=t.edges[e];i.hover=!0,this._addToHover(i)}}},{key:"_unselectConnectedEdges",value:function(t){for(var e=0;e<t.edges.length;e++){var i=t.edges[e];i.unselect(),this._removeFromSelection(i)}}},{key:"emitBlurEvent",value:function(t,e,i){var o=this._initBaseEvent(t,e);!0===i.hover&&(i.hover=!1,i instanceof h?(o.node=i.id,this.body.emitter.emit("blurNode",o)):(o.edge=i.id,this.body.emitter.emit("blurEdge",o)))}},{key:"emitHoverEvent",value:function(t,e,i){var o=this._initBaseEvent(t,e),n=!1;return!1===i.hover&&(i.hover=!0,this._addToHover(i),n=!0,i instanceof h?(o.node=i.id,this.body.emitter.emit("hoverNode",o)):(o.edge=i.id,this.body.emitter.emit("hoverEdge",o))),n}},{key:"hoverObject",value:function(t,e){var i=this.getNodeAt(e);void 0===i&&(i=this.getEdgeAt(e));var o=!1;for(var n in this.hoverObj.nodes)this.hoverObj.nodes.hasOwnProperty(n)&&(void 0===i||i instanceof h&&i.id!=n||i instanceof d)&&(this.emitBlurEvent(t,e,this.hoverObj.nodes[n]),delete this.hoverObj.nodes[n],o=!0);for(var s in this.hoverObj.edges)this.hoverObj.edges.hasOwnProperty(s)&&(!0===o?(this.hoverObj.edges[s].hover=!1,delete this.hoverObj.edges[s]):(void 0===i||i instanceof d&&i.id!=s||i instanceof h&&!i.hover)&&(this.emitBlurEvent(t,e,this.hoverObj.edges[s]),delete this.hoverObj.edges[s],o=!0));void 0!==i&&(o=o||this.emitHoverEvent(t,e,i),i instanceof h&&!0===this.options.hoverConnectedEdges&&this._hoverConnectedEdges(i)),!0===o&&this.body.emitter.emit("_requestRedraw")}},{key:"getSelection",value:function(){return{nodes:this.getSelectedNodes(),edges:this.getSelectedEdges()}}},{key:"getSelectedNodes",value:function(){var t=[];if(!0===this.options.selectable)for(var e in this.selectionObj.nodes)this.selectionObj.nodes.hasOwnProperty(e)&&t.push(this.selectionObj.nodes[e].id);return t}},{key:"getSelectedEdges",value:function(){var t=[];if(!0===this.options.selectable)for(var e in this.selectionObj.edges)this.selectionObj.edges.hasOwnProperty(e)&&t.push(this.selectionObj.edges[e].id);return t}},{key:"setSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=void 0,o=void 0;if(!t||!t.nodes&&!t.edges)throw"Selection must be an object with nodes and/or edges properties" +;if((e.unselectAll||void 0===e.unselectAll)&&this.unselectAll(),t.nodes)for(i=0;i<t.nodes.length;i++){o=t.nodes[i];var n=this.body.nodes[o];if(!n)throw new RangeError('Node with id "'+o+'" not found');this.selectObject(n,e.highlightEdges)}if(t.edges)for(i=0;i<t.edges.length;i++){o=t.edges[i];var s=this.body.edges[o];if(!s)throw new RangeError('Edge with id "'+o+'" not found');this.selectObject(s)}this.body.emitter.emit("_requestRedraw")}},{key:"selectNodes",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t||void 0===t.length)throw"Selection must be an array with ids";this.setSelection({nodes:t},{highlightEdges:e})}},{key:"selectEdges",value:function(t){if(!t||void 0===t.length)throw"Selection must be an array with ids";this.setSelection({edges:t})}},{key:"updateSelection",value:function(){for(var t in this.selectionObj.nodes)this.selectionObj.nodes.hasOwnProperty(t)&&(this.body.nodes.hasOwnProperty(t)||delete this.selectionObj.nodes[t]);for(var e in this.selectionObj.edges)this.selectionObj.edges.hasOwnProperty(e)&&(this.body.edges.hasOwnProperty(e)||delete this.selectionObj.edges[e])}},{key:"getClickedItems",value:function(t){for(var e=this.canvas.DOMtoCanvas(t),i=[],o=this.body.nodeIndices,n=this.body.nodes,s=o.length-1;s>=0;s--){var r=n[o[s]],a=r.getItemsOnPoint(e);i.push.apply(i,a)}for(var h=this.body.edgeIndices,d=this.body.edges,l=h.length-1;l>=0;l--){var u=d[h[l]],c=u.getItemsOnPoint(e);i.push.apply(i,c)}return i}}]),t}();e.default=u},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(30),s=o(n),r=i(6),a=o(r),h=i(8),d=o(h),l=i(0),u=o(l),c=i(1),p=o(c),f=i(2),m=i(76).default,v=i(236),g=v.HorizontalStrategy,y=v.VerticalStrategy,b=function(){function t(){(0,u.default)(this,t),this.childrenReference={},this.parentReference={},this.trees={},this.distributionOrdering={},this.levels={},this.distributionIndex={},this.isTree=!1,this.treeIndex=-1}return(0,p.default)(t,[{key:"addRelation",value:function(t,e){void 0===this.childrenReference[t]&&(this.childrenReference[t]=[]),this.childrenReference[t].push(e),void 0===this.parentReference[e]&&(this.parentReference[e]=[]),this.parentReference[e].push(t)}},{key:"checkIfTree",value:function(){for(var t in this.parentReference)if(this.parentReference[t].length>1)return void(this.isTree=!1);this.isTree=!0}},{key:"numTrees",value:function(){return this.treeIndex+1}},{key:"setTreeIndex",value:function(t,e){void 0!==e&&void 0===this.trees[t.id]&&(this.trees[t.id]=e,this.treeIndex=Math.max(e,this.treeIndex))}},{key:"ensureLevel",value:function(t){void 0===this.levels[t]&&(this.levels[t]=0)}},{key:"getMaxLevel",value:function(t){var e=this,i={};return function t(o){if(void 0!==i[o])return i[o];var n=e.levels[o];if(e.childrenReference[o]){var s=e.childrenReference[o];if(s.length>0)for(var r=0;r<s.length;r++)n=Math.max(n,t(s[r]))}return i[o]=n,n}(t)}},{key:"levelDownstream",value:function(t,e){void 0===this.levels[e.id]&&(void 0===this.levels[t.id]&&(this.levels[t.id]=0),this.levels[e.id]=this.levels[t.id]+1)}},{key:"setMinLevelToZero",value:function(t){var e=1e9;for(var i in t)t.hasOwnProperty(i)&&void 0!==this.levels[i]&&(e=Math.min(this.levels[i],e));for(var o in t)t.hasOwnProperty(o)&&void 0!==this.levels[o]&&(this.levels[o]-=e)}},{key:"getTreeSize",value:function(t,e){var i=1e9,o=-1e9,n=1e9,s=-1e9;for(var r in this.trees)if(this.trees.hasOwnProperty(r)&&this.trees[r]===e){var a=t[r];i=Math.min(a.x,i),o=Math.max(a.x,o),n=Math.min(a.y,n),s=Math.max(a.y,s)}return{min_x:i,max_x:o,min_y:n,max_y:s}}},{key:"hasSameParent",value:function(t,e){var i=this.parentReference[t.id],o=this.parentReference[e.id];if(void 0===i||void 0===o)return!1;for(var n=0;n<i.length;n++)for(var s=0;s<o.length;s++)if(i[n]==o[s])return!0;return!1}},{key:"inSameSubNetwork",value:function(t,e){return this.trees[t.id]===this.trees[e.id]}},{key:"getLevels",value:function(){return(0,d.default)(this.distributionOrdering)}},{key:"addToOrdering",value:function(t,e){void 0===this.distributionOrdering[e]&&(this.distributionOrdering[e]=[]);var i=!1,o=this.distributionOrdering[e];for(var n in o)if(o[n]===t){i=!0;break}i||(this.distributionOrdering[e].push(t),this.distributionIndex[t.id]=this.distributionOrdering[e].length-1)}}]),t}(),_=function(){function t(e){(0,u.default)(this,t),this.body=e,this.initialRandomSeed=Math.round(1e6*Math.random()),this.randomSeed=this.initialRandomSeed,this.setPhysics=!1,this.options={},this.optionsBackup={physics:{}},this.defaultOptions={randomSeed:void 0,improvedLayout:!0,hierarchical:{enabled:!1,levelSeparation:150,nodeSpacing:100,treeSpacing:200,blockShifting:!0,edgeMinimization:!0,parentCentralization:!0,direction:"UD",sortMethod:"hubsize"}},f.extend(this.options,this.defaultOptions),this.bindEventListeners()}return(0,p.default)(t,[{key:"bindEventListeners",value:function(){var t=this;this.body.emitter.on("_dataChanged",function(){t.setupHierarchicalLayout()}),this.body.emitter.on("_dataLoaded",function(){t.layoutNetwork()}),this.body.emitter.on("_resetHierarchicalLayout",function(){t.setupHierarchicalLayout()}),this.body.emitter.on("_adjustEdgesForHierarchicalLayout",function(){if(!0===t.options.hierarchical.enabled){var e=t.direction.curveType();t.body.emitter.emit("_forceDisableDynamicCurves",e,!1)}})}},{key:"setOptions",value:function(t,e){if(void 0!==t){var i=this.options.hierarchical,o=i.enabled;if(f.selectiveDeepExtend(["randomSeed","improvedLayout"],this.options,t),f.mergeOptions(this.options,t,"hierarchical"),void 0!==t.randomSeed&&(this.initialRandomSeed=t.randomSeed),!0===i.enabled)return!0===o&&this.body.emitter.emit("refresh",!0),"RL"===i.direction||"DU"===i.direction?i.levelSeparation>0&&(i.levelSeparation*=-1):i.levelSeparation<0&&(i.levelSeparation*=-1),this.setDirectionStrategy(),this.body.emitter.emit("_resetHierarchicalLayout"),this.adaptAllOptionsForHierarchicalLayout(e);if(!0===o)return this.body.emitter.emit("refresh"),f.deepExtend(e,this.optionsBackup)}return e}},{key:"adaptAllOptionsForHierarchicalLayout",value:function(t){if(!0===this.options.hierarchical.enabled){var e=this.optionsBackup.physics;void 0===t.physics||!0===t.physics?(t.physics={enabled:void 0===e.enabled||e.enabled,solver:"hierarchicalRepulsion"},e.enabled=void 0===e.enabled||e.enabled,e.solver=e.solver||"barnesHut"):"object"===(0,a.default)(t.physics)?(e.enabled=void 0===t.physics.enabled||t.physics.enabled,e.solver=t.physics.solver||"barnesHut",t.physics.solver="hierarchicalRepulsion"):!1!==t.physics&&(e.solver="barnesHut",t.physics={solver:"hierarchicalRepulsion"});var i=this.direction.curveType();if(void 0===t.edges)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},t.edges={smooth:!1};else if(void 0===t.edges.smooth)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},t.edges.smooth=!1;else if("boolean"==typeof t.edges.smooth)this.optionsBackup.edges={smooth:t.edges.smooth},t.edges.smooth={enabled:t.edges.smooth,type:i};else{var o=t.edges.smooth;void 0!==o.type&&"dynamic"!==o.type&&(i=o.type),this.optionsBackup.edges={smooth:void 0===o.enabled||o.enabled,type:void 0===o.type?"dynamic":o.type,roundness:void 0===o.roundness?.5:o.roundness,forceDirection:void 0!==o.forceDirection&&o.forceDirection},t.edges.smooth={enabled:void 0===o.enabled||o.enabled,type:i,roundness:void 0===o.roundness?.5:o.roundness,forceDirection:void 0!==o.forceDirection&&o.forceDirection}}this.body.emitter.emit("_forceDisableDynamicCurves",i)}return t}},{key:"seededRandom",value:function(){var t=1e4*Math.sin(this.randomSeed++);return t-Math.floor(t)}},{key:"positionInitially",value:function(t){if(!0!==this.options.hierarchical.enabled){this.randomSeed=this.initialRandomSeed;for(var e=t.length+50,i=0;i<t.length;i++){var o=t[i],n=2*Math.PI*this.seededRandom();void 0===o.x&&(o.x=e*Math.cos(n)),void 0===o.y&&(o.y=e*Math.sin(n))}}}},{key:"layoutNetwork",value:function(){if(!0!==this.options.hierarchical.enabled&&!0===this.options.improvedLayout){for(var t=this.body.nodeIndices,e=0,i=0;i<t.length;i++){!0===this.body.nodes[t[i]].predefinedPosition&&(e+=1)}if(e<.5*t.length){var o=0,n={clusterNodeProperties:{shape:"ellipse",label:"",group:"",font:{multi:!1}},clusterEdgeProperties:{label:"",font:{multi:!1},smooth:{enabled:!1}}};if(t.length>150){for(var s=t.length;t.length>150&&o<=10;){o+=1;var r=t.length;o%3==0?this.body.modules.clustering.clusterBridges(n):this.body.modules.clustering.clusterOutliers(n);if(r==t.length&&o%3!=0)return this._declusterAll(),this.body.emitter.emit("_layoutFailed"),void console.info("This network could not be positioned by this version of the improved layout algorithm. Please disable improvedLayout for better performance.")}this.body.modules.kamadaKawai.setOptions({springLength:Math.max(150,2*s)})}o>10&&console.info("The clustering didn't succeed within the amount of interations allowed, progressing with partial result."),this.body.modules.kamadaKawai.solve(t,this.body.edgeIndices,!0),this._shiftToCenter();for(var a=0;a<t.length;a++){var h=this.body.nodes[t[a]];!1===h.predefinedPosition&&(h.x+=70*(.5-this.seededRandom()),h.y+=70*(.5-this.seededRandom()))}this._declusterAll(),this.body.emitter.emit("_repositionBezierNodes")}}}},{key:"_shiftToCenter",value:function(){for(var t=m.getRangeCore(this.body.nodes,this.body.nodeIndices),e=m.findCenter(t),i=0;i<this.body.nodeIndices.length;i++){var o=this.body.nodes[this.body.nodeIndices[i]];o.x-=e.x,o.y-=e.y}}},{key:"_declusterAll",value:function(){for(var t=!0;!0===t;){t=!1;for(var e=0;e<this.body.nodeIndices.length;e++)!0===this.body.nodes[this.body.nodeIndices[e]].isCluster&&(t=!0,this.body.modules.clustering.openCluster(this.body.nodeIndices[e],{},!1));!0===t&&this.body.emitter.emit("_dataChanged")}}},{key:"getSeed",value:function(){return this.initialRandomSeed}},{key:"setupHierarchicalLayout",value:function(){if(!0===this.options.hierarchical.enabled&&this.body.nodeIndices.length>0){var t=void 0,e=void 0,i=!1,o=!1;this.lastNodeOnLevel={},this.hierarchical=new b;for(e in this.body.nodes)this.body.nodes.hasOwnProperty(e)&&(t=this.body.nodes[e],void 0!==t.options.level?(i=!0,this.hierarchical.levels[e]=t.options.level):o=!0);if(!0===o&&!0===i)throw new Error("To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.");if(!0===o){var n=this.options.hierarchical.sortMethod;"hubsize"===n?this._determineLevelsByHubsize():"directed"===n?this._determineLevelsDirected():"custom"===n&&this._determineLevelsCustomCallback()}for(var s in this.body.nodes)this.body.nodes.hasOwnProperty(s)&&this.hierarchical.ensureLevel(s);var r=this._getDistribution();this._generateMap(),this._placeNodesByHierarchy(r),this._condenseHierarchy(),this._shiftToCenter()}}},{key:"_condenseHierarchy",value:function(){var t=this,e=!1,i={},o=function(e,i){var o=t.hierarchical.trees;for(var n in o)o.hasOwnProperty(n)&&o[n]===e&&t.direction.shift(n,i)},n=function(){for(var e=[],i=0;i<t.hierarchical.numTrees();i++)e.push(t.direction.getTreeSize(i));return e},r=function e(i,o){if(!o[i.id]&&(o[i.id]=!0,t.hierarchical.childrenReference[i.id])){var n=t.hierarchical.childrenReference[i.id];if(n.length>0)for(var s=0;s<n.length;s++)e(t.body.nodes[n[s]],o)}},a=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e9,o=1e9,n=1e9,r=1e9,a=-1e9;for(var h in e)if(e.hasOwnProperty(h)){var d=t.body.nodes[h],l=t.hierarchical.levels[d.id],u=t.direction.getPosition(d),c=t._getSpaceAroundNode(d,e),p=(0,s.default)(c,2),f=p[0],m=p[1];o=Math.min(f,o),n=Math.min(m,n),l<=i&&(r=Math.min(u,r),a=Math.max(u,a))}return[r,a,o,n]},h=function(e,i){var o=t.hierarchical.getMaxLevel(e.id),n=t.hierarchical.getMaxLevel(i.id);return Math.min(o,n)},d=function(e,i,o){for(var n=t.hierarchical,s=0;s<i.length;s++){var r=i[s],a=n.distributionOrdering[r];if(a.length>1)for(var h=0;h<a.length-1;h++){var d=a[h],l=a[h+1];n.hasSameParent(d,l)&&n.inSameSubNetwork(d,l)&&e(d,l,o)}}},l=function(i,o){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=t.direction.getPosition(i),d=t.direction.getPosition(o),l=Math.abs(d-s),u=t.options.hierarchical.nodeSpacing;if(l>u){var c={},p={};r(i,c),r(o,p);var f=h(i,o),m=a(c,f),v=a(p,f),g=m[1],y=v[0],b=v[2];if(Math.abs(g-y)>u){var _=g-y+u;_<-b+u&&(_=-b+u),_<0&&(t._shiftBlock(o.id,_),e=!0,!0===n&&t._centerParent(o))}}},u=function(o,n){for(var h=n.id,d=n.edges,l=t.hierarchical.levels[n.id],u=t.options.hierarchical.levelSeparation*t.options.hierarchical.levelSeparation,c={},p=[],f=0;f<d.length;f++){var m=d[f];if(m.toId!=m.fromId){var v=m.toId==h?m.from:m.to;c[d[f].id]=v,t.hierarchical.levels[v.id]<l&&p.push(m)}}var g=function(e,i){for(var o=0,n=0;n<i.length;n++)if(void 0!==c[i[n].id]){var s=t.direction.getPosition(c[i[n].id])-e;o+=s/Math.sqrt(s*s+u)}return o},y=function(e,i){for(var o=0,n=0;n<i.length;n++)if(void 0!==c[i[n].id]){var s=t.direction.getPosition(c[i[n].id])-e;o-=u*Math.pow(s*s+u,-1.5)}return o},b=function(e,i){for(var o=t.direction.getPosition(n),s={},r=0;r<e;r++){var a=g(o,i),h=y(o,i);if(o-=Math.max(-40,Math.min(40,Math.round(a/h))),void 0!==s[o])break;s[o]=r}return o},_=b(o,p);!function(o){var s=t.direction.getPosition(n);if(void 0===i[n.id]){var h={};r(n,h),i[n.id]=h}var d=a(i[n.id]),l=d[2],u=d[3],c=o-s,p=0;c>0?p=Math.min(c,u-t.options.hierarchical.nodeSpacing):c<0&&(p=-Math.min(-c,l-t.options.hierarchical.nodeSpacing)),0!=p&&(t._shiftBlock(n.id,p),e=!0)}(_),_=b(o,d),function(i){var o=t.direction.getPosition(n),r=t._getSpaceAroundNode(n),a=(0,s.default)(r,2),h=a[0],d=a[1],l=i-o,u=o;l>0?u=Math.min(o+(d-t.options.hierarchical.nodeSpacing),i):l<0&&(u=Math.max(o-(h-t.options.hierarchical.nodeSpacing),i)),u!==o&&(t.direction.setPosition(n,u),e=!0)}(_)};!0===this.options.hierarchical.blockShifting&&(function(i){var o=t.hierarchical.getLevels();o=o.reverse();for(var n=0;n<i&&(e=!1,d(l,o,!0),!0===e);n++);}(5),function(){for(var e in t.body.nodes)t.body.nodes.hasOwnProperty(e)&&t._centerParent(t.body.nodes[e])}()),!0===this.options.hierarchical.edgeMinimization&&function(i){var o=t.hierarchical.getLevels();o=o.reverse();for(var n=0;n<i;n++){e=!1;for(var s=0;s<o.length;s++)for(var r=o[s],a=t.hierarchical.distributionOrdering[r],h=0;h<a.length;h++)u(1e3,a[h]);if(!0!==e)break}}(20),!0===this.options.hierarchical.parentCentralization&&function(){var e=t.hierarchical.getLevels();e=e.reverse();for(var i=0;i<e.length;i++)for(var o=e[i],n=t.hierarchical.distributionOrdering[o],s=0;s<n.length;s++)t._centerParent(n[s])}(),function(){for(var e=n(),i=0,s=0;s<e.length-1;s++){i+=e[s].max-e[s+1].min+t.options.hierarchical.treeSpacing,o(s+1,i)}}()}},{key:"_getSpaceAroundNode",value:function(t,e){var i=!0;void 0===e&&(i=!1);var o=this.hierarchical.levels[t.id];if(void 0!==o){var n=this.hierarchical.distributionIndex[t.id],s=this.direction.getPosition(t),r=this.hierarchical.distributionOrdering[o],a=1e9,h=1e9;if(0!==n){var d=r[n-1];if(!0===i&&void 0===e[d.id]||!1===i){a=s-this.direction.getPosition(d)}}if(n!=r.length-1){var l=r[n+1];if(!0===i&&void 0===e[l.id]||!1===i){var u=this.direction.getPosition(l);h=Math.min(h,u-s)}}return[a,h]}return[0,0]}},{key:"_centerParent",value:function(t){if(this.hierarchical.parentReference[t.id])for(var e=this.hierarchical.parentReference[t.id],i=0;i<e.length;i++){var o=e[i],n=this.body.nodes[o],r=this.hierarchical.childrenReference[o];if(void 0!==r){var a=this._getCenterPosition(r),h=this.direction.getPosition(n),d=this._getSpaceAroundNode(n),l=(0,s.default)(d,2),u=l[0],c=l[1],p=h-a;(p<0&&Math.abs(p)<c-this.options.hierarchical.nodeSpacing||p>0&&Math.abs(p)<u-this.options.hierarchical.nodeSpacing)&&this.direction.setPosition(n,a)}}}},{key:"_placeNodesByHierarchy",value:function(t){this.positionedNodes={};for(var e in t)if(t.hasOwnProperty(e)){var i=(0,d.default)(t[e]);i=this._indexArrayToNodes(i),this.direction.sort(i);for(var o=0,n=0;n<i.length;n++){var s=i[n];if(void 0===this.positionedNodes[s.id]){var r=this.options.hierarchical.nodeSpacing,a=r*o;o>0&&(a=this.direction.getPosition(i[n-1])+r),this.direction.setPosition(s,a,e),this._validatePositionAndContinue(s,e,a),o++}}}}},{key:"_placeBranchNodes",value:function(t,e){var i=this.hierarchical.childrenReference[t];if(void 0!==i){for(var o=[],n=0;n<i.length;n++)o.push(this.body.nodes[i[n]]);this.direction.sort(o);for(var s=0;s<o.length;s++){var r=o[s],a=this.hierarchical.levels[r.id];if(!(a>e&&void 0===this.positionedNodes[r.id]))return;var h=this.options.hierarchical.nodeSpacing,d=void 0;d=0===s?this.direction.getPosition(this.body.nodes[t]):this.direction.getPosition(o[s-1])+h,this.direction.setPosition(r,d,a),this._validatePositionAndContinue(r,a,d)}var l=this._getCenterPosition(o);this.direction.setPosition(this.body.nodes[t],l,e)}}},{key:"_validatePositionAndContinue",value:function(t,e,i){if(this.hierarchical.isTree){if(void 0!==this.lastNodeOnLevel[e]){var o=this.direction.getPosition(this.body.nodes[this.lastNodeOnLevel[e]]);if(i-o<this.options.hierarchical.nodeSpacing){var n=o+this.options.hierarchical.nodeSpacing-i,s=this._findCommonParent(this.lastNodeOnLevel[e],t.id);this._shiftBlock(s.withChild,n)}}this.lastNodeOnLevel[e]=t.id,this.positionedNodes[t.id]=!0,this._placeBranchNodes(t.id,e)}}},{key:"_indexArrayToNodes",value:function(t){for(var e=[],i=0;i<t.length;i++)e.push(this.body.nodes[t[i]]);return e}},{key:"_getDistribution",value:function(){var t={},e=void 0,i=void 0;for(e in this.body.nodes)if(this.body.nodes.hasOwnProperty(e)){i=this.body.nodes[e];var o=void 0===this.hierarchical.levels[e]?0:this.hierarchical.levels[e];this.direction.fix(i,o),void 0===t[o]&&(t[o]={}),t[o][e]=i}return t}},{key:"_getActiveEdges",value:function(t){var e=this,i=[];return f.forEach(t.edges,function(t){-1!==e.body.edgeIndices.indexOf(t.id)&&i.push(t)}),i}},{key:"_getHubSizes",value:function(){var t=this,e={},i=this.body.nodeIndices;f.forEach(i,function(i){var o=t.body.nodes[i],n=t._getActiveEdges(o).length;e[n]=!0});var o=[];return f.forEach(e,function(t){o.push(Number(t))}),o.sort(function(t,e){return e-t}),o}},{key:"_determineLevelsByHubsize",value:function(){for(var t=this,e=function(e,i){t.hierarchical.levelDownstream(e,i)},i=this._getHubSizes(),o=0;o<i.length;++o){if("break"===function(o){var n=i[o];if(0===n)return"break";f.forEach(t.body.nodeIndices,function(i){var o=t.body.nodes[i];n===t._getActiveEdges(o).length&&t._crawlNetwork(e,i)})}(o))break}}},{key:"_determineLevelsCustomCallback",value:function(){var t=this,e=function(e,i,o){var n=t.hierarchical.levels[e.id];void 0===n&&(n=t.hierarchical.levels[e.id]=1e5);var s=(m.cloneOptions(e,"node"),m.cloneOptions(i,"node"),void m.cloneOptions(o,"edge"));t.hierarchical.levels[i.id]=n+s};this._crawlNetwork(e),this.hierarchical.setMinLevelToZero(this.body.nodes)}},{key:"_determineLevelsDirected",value:function(){var t=this,e=function(e){return f.forEach(t.body.edges,function(t){if(t.toId===e.fromId&&t.fromId===e.toId)return!0}),!1},i=function(i,o,n){var s=t.hierarchical.levels[i.id],r=t.hierarchical.levels[o.id];e(n)&&void 0!==s&&void 0!==r||(void 0===s&&(s=t.hierarchical.levels[i.id]=1e4),n.toId==o.id?t.hierarchical.levels[o.id]=s+1:t.hierarchical.levels[o.id]=s-1)};this._crawlNetwork(i),this.hierarchical.setMinLevelToZero(this.body.nodes)}},{key:"_generateMap",value:function(){var t=this,e=function(e,i){t.hierarchical.levels[i.id]>t.hierarchical.levels[e.id]&&t.hierarchical.addRelation(e.id,i.id)};this._crawlNetwork(e),this.hierarchical.checkIfTree()}},{key:"_crawlNetwork",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},i=arguments[1],o={},n=function i(n,s){if(void 0===o[n.id]){t.hierarchical.setTreeIndex(n,s),o[n.id]=!0;for(var r=void 0,a=t._getActiveEdges(n),h=0;h<a.length;h++){var d=a[h];!0===d.connected&&(r=d.toId==n.id?d.from:d.to,n.id!=r.id&&(e(n,r,d),i(r,s)))}}};if(void 0===i)for(var s=0,r=0;r<this.body.nodeIndices.length;r++){var a=this.body.nodeIndices[r];if(void 0===o[a]){var h=this.body.nodes[a];n(h,s),s+=1}}else{var d=this.body.nodes[i];if(void 0===d)return void console.error("Node not found:",i);n(d)}}},{key:"_shiftBlock",value:function(t,e){var i=this,o={};!function t(n){if(!o[n]){o[n]=!0,i.direction.shift(n,e);var s=i.hierarchical.childrenReference[n];if(void 0!==s)for(var r=0;r<s.length;r++)t(s[r])}}(t)}},{key:"_findCommonParent",value:function(t,e){var i=this,o={};return function t(e,o){var n=i.hierarchical.parentReference[o];if(void 0!==n)for(var s=0;s<n.length;s++){var r=n[s];e[r]=!0,t(e,r)}}(o,t),function t(e,o){var n=i.hierarchical.parentReference[o];if(void 0!==n)for(var s=0;s<n.length;s++){var r=n[s];if(void 0!==e[r])return{foundParent:r,withChild:o};var a=t(e,r);if(null!==a.foundParent)return a}return{foundParent:null,withChild:o}}(o,e)}},{key:"setDirectionStrategy",value:function(){var t="UD"===this.options.hierarchical.direction||"DU"===this.options.hierarchical.direction;this.direction=t?new y(this):new g(this)}},{key:"_getCenterPosition",value:function(t){for(var e=1e9,i=-1e9,o=0;o<t.length;o++){var n=void 0;if(void 0!==t[o].id)n=t[o];else{var s=t[o];n=this.body.nodes[s]}var r=this.direction.getPosition(n);e=Math.min(e,r),i=Math.max(i,r)}return.5*(e+i)}}]),t}();e.default=_},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.VerticalStrategy=e.HorizontalStrategy=void 0;var n=i(3),s=o(n),r=i(4),a=o(r),h=i(5),d=o(h),l=i(0),u=o(l),c=i(1),p=o(c),f=function(){function t(){(0,u.default)(this,t)}return(0,p.default)(t,[{key:"abstract",value:function(){throw new Error("Can't instantiate abstract class!")}},{key:"fake_use",value:function(){}},{key:"curveType",value:function(){return this.abstract()}},{key:"getPosition",value:function(t){return this.fake_use(t),this.abstract()}},{key:"setPosition",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;this.fake_use(t,e,i),this.abstract()}},{key:"getTreeSize",value:function(t){return this.fake_use(t),this.abstract()}},{key:"sort",value:function(t){this.fake_use(t),this.abstract()}},{key:"fix",value:function(t,e){this.fake_use(t,e),this.abstract()}},{key:"shift",value:function(t,e){this.fake_use(t,e),this.abstract()}}]),t}(),m=function(t){function e(t){(0,u.default)(this,e);var i=(0,a.default)(this,(e.__proto__||(0,s.default)(e)).call(this));return i.layout=t,i}return(0,d.default)(e,t),(0,p.default)(e,[{key:"curveType",value:function(){return"horizontal"}},{key:"getPosition",value:function(t){return t.x}},{key:"setPosition",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;void 0!==i&&this.layout.hierarchical.addToOrdering(t,i),t.x=e}},{key:"getTreeSize",value:function(t){var e=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,t);return{min:e.min_x,max:e.max_x}}},{key:"sort",value:function(t){t.sort(function(t,e){return void 0===t.x||void 0===e.x?0:t.x-e.x})}},{key:"fix",value:function(t,e){t.y=this.layout.options.hierarchical.levelSeparation*e,t.options.fixed.y=!0}},{key:"shift",value:function(t,e){this.layout.body.nodes[t].x+=e}}]),e}(f),v=function(t){function e(t){(0,u.default)(this,e);var i=(0,a.default)(this,(e.__proto__||(0,s.default)(e)).call(this));return i.layout=t,i}return(0,d.default)(e,t),(0,p.default)(e,[{key:"curveType",value:function(){return"vertical"}},{key:"getPosition",value:function(t){return t.y}},{key:"setPosition",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;void 0!==i&&this.layout.hierarchical.addToOrdering(t,i),t.y=e}},{key:"getTreeSize",value:function(t){var e=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,t);return{min:e.min_y,max:e.max_y}}},{key:"sort",value:function(t){t.sort(function(t,e){return void 0===t.y||void 0===e.y?0:t.y-e.y})}},{key:"fix",value:function(t,e){t.x=this.layout.options.hierarchical.levelSeparation*e,t.options.fixed.x=!0}},{key:"shift",value:function(t,e){this.layout.body.nodes[t].y+=e}}]),e}(f);e.HorizontalStrategy=v,e.VerticalStrategy=m},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(8),s=o(n),r=i(19),a=o(r),h=i(6),d=o(h),l=i(0),u=o(l),c=i(1),p=o(c),f=i(2),m=i(10),v=i(37),g=function(){function t(e,i,o){var n=this;(0,u.default)(this,t),this.body=e,this.canvas=i,this.selectionHandler=o,this.editMode=!1,this.manipulationDiv=void 0,this.editModeDiv=void 0,this.closeDiv=void 0,this.manipulationHammers=[],this.temporaryUIFunctions={},this.temporaryEventFunctions=[],this.touchTime=0,this.temporaryIds={nodes:[],edges:[]},this.guiEnabled=!1,this.inMode=!1,this.selectedControlNode=void 0,this.options={},this.defaultOptions={enabled:!1,initiallyActive:!1,addNode:!0,addEdge:!0,editNode:void 0,editEdge:!0,deleteNode:!0,deleteEdge:!0,controlNodeStyle:{shape:"dot",size:6,color:{background:"#ff0000",border:"#3c3c3c",highlight:{background:"#07f968",border:"#3c3c3c"}},borderWidth:2,borderWidthSelected:2}},f.extend(this.options,this.defaultOptions),this.body.emitter.on("destroy",function(){n._clean()}),this.body.emitter.on("_dataChanged",this._restore.bind(this)),this.body.emitter.on("_resetData",this._restore.bind(this))}return(0,p.default)(t,[{key:"_restore",value:function(){!1!==this.inMode&&(!0===this.options.initiallyActive?this.enableEditMode():this.disableEditMode())}},{key:"setOptions",value:function(t,e,i){void 0!==e&&(void 0!==e.locale?this.options.locale=e.locale:this.options.locale=i.locale,void 0!==e.locales?this.options.locales=e.locales:this.options.locales=i.locales),void 0!==t&&("boolean"==typeof t?this.options.enabled=t:(this.options.enabled=!0,f.deepExtend(this.options,t)),!0===this.options.initiallyActive&&(this.editMode=!0),this._setup())}},{key:"toggleEditMode",value:function(){!0===this.editMode?this.disableEditMode():this.enableEditMode()}},{key:"enableEditMode",value:function(){this.editMode=!0,this._clean(),!0===this.guiEnabled&&(this.manipulationDiv.style.display="block",this.closeDiv.style.display="block",this.editModeDiv.style.display="none",this.showManipulatorToolbar())}},{key:"disableEditMode",value:function(){this.editMode=!1,this._clean(),!0===this.guiEnabled&&(this.manipulationDiv.style.display="none",this.closeDiv.style.display="none",this.editModeDiv.style.display="block",this._createEditButton())}},{key:"showManipulatorToolbar",value:function(){if(this._clean(),this.manipulationDOM={},!0===this.guiEnabled){this.editMode=!0,this.manipulationDiv.style.display="block",this.closeDiv.style.display="block";var t=this.selectionHandler._getSelectedNodeCount(),e=this.selectionHandler._getSelectedEdgeCount(),i=t+e,o=this.options.locales[this.options.locale],n=!1;!1!==this.options.addNode&&(this._createAddNodeButton(o),n=!0),!1!==this.options.addEdge&&(!0===n?this._createSeperator(1):n=!0,this._createAddEdgeButton(o)),1===t&&"function"==typeof this.options.editNode?(!0===n?this._createSeperator(2):n=!0,this._createEditNodeButton(o)):1===e&&0===t&&!1!==this.options.editEdge&&(!0===n?this._createSeperator(3):n=!0,this._createEditEdgeButton(o)),0!==i&&(t>0&&!1!==this.options.deleteNode?(!0===n&&this._createSeperator(4),this._createDeleteButton(o)):0===t&&!1!==this.options.deleteEdge&&(!0===n&&this._createSeperator(4),this._createDeleteButton(o))),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this)),this._temporaryBindEvent("select",this.showManipulatorToolbar.bind(this))}this.body.emitter.emit("_redraw")}},{key:"addNodeMode",value:function(){if(!0!==this.editMode&&this.enableEditMode(),this._clean(),this.inMode="addNode",!0===this.guiEnabled){var t=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(t),this._createSeperator(),this._createDescription(t.addDescription||this.options.locales.en.addDescription),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindEvent("click",this._performAddNode.bind(this))}},{key:"editNode",value:function(){var t=this;!0!==this.editMode&&this.enableEditMode(),this._clean();var e=this.selectionHandler._getSelectedNode();if(void 0!==e){if(this.inMode="editNode","function"!=typeof this.options.editNode)throw new Error("No function has been configured to handle the editing of nodes.");if(!0!==e.isCluster){var i=f.deepExtend({},e.options,!1);if(i.x=e.x,i.y=e.y,2!==this.options.editNode.length)throw new Error("The function for edit does not support two arguments (data, callback)");this.options.editNode(i,function(e){null!==e&&void 0!==e&&"editNode"===t.inMode&&t.body.data.nodes.getDataSet().update(e),t.showManipulatorToolbar()})}else alert(this.options.locales[this.options.locale].editClusterError||this.options.locales.en.editClusterError)}else this.showManipulatorToolbar()}},{key:"addEdgeMode",value:function(){if(!0!==this.editMode&&this.enableEditMode(),this._clean(),this.inMode="addEdge",!0===this.guiEnabled){var t=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(t),this._createSeperator(),this._createDescription(t.edgeDescription||this.options.locales.en.edgeDescription),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindUI("onTouch",this._handleConnect.bind(this)),this._temporaryBindUI("onDragEnd",this._finishConnect.bind(this)),this._temporaryBindUI("onDrag",this._dragControlNode.bind(this)),this._temporaryBindUI("onRelease",this._finishConnect.bind(this)),this._temporaryBindUI("onDragStart",this._dragStartEdge.bind(this)),this._temporaryBindUI("onHold",function(){})}},{key:"editEdgeMode",value:function(){if(!0!==this.editMode&&this.enableEditMode(),this._clean(),this.inMode="editEdge","object"===(0,d.default)(this.options.editEdge)&&"function"==typeof this.options.editEdge.editWithoutDrag&&(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdges()[0],void 0!==this.edgeBeingEditedId)){var t=this.body.edges[this.edgeBeingEditedId];return void this._performEditEdge(t.from,t.to)}if(!0===this.guiEnabled){var e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.editEdgeDescription||this.options.locales.en.editEdgeDescription),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this))}if(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdges()[0],void 0!==this.edgeBeingEditedId){var i=this.body.edges[this.edgeBeingEditedId],o=this._getNewTargetNode(i.from.x,i.from.y),n=this._getNewTargetNode(i.to.x,i.to.y);this.temporaryIds.nodes.push(o.id),this.temporaryIds.nodes.push(n.id),this.body.nodes[o.id]=o,this.body.nodeIndices.push(o.id),this.body.nodes[n.id]=n,this.body.nodeIndices.push(n.id),this._temporaryBindUI("onTouch",this._controlNodeTouch.bind(this)),this._temporaryBindUI("onTap",function(){}),this._temporaryBindUI("onHold",function(){}),this._temporaryBindUI("onDragStart",this._controlNodeDragStart.bind(this)),this._temporaryBindUI("onDrag",this._controlNodeDrag.bind(this)),this._temporaryBindUI("onDragEnd",this._controlNodeDragEnd.bind(this)),this._temporaryBindUI("onMouseMove",function(){}),this._temporaryBindEvent("beforeDrawing",function(t){var e=i.edgeType.findBorderPositions(t);!1===o.selected&&(o.x=e.from.x,o.y=e.from.y),!1===n.selected&&(n.x=e.to.x,n.y=e.to.y)}),this.body.emitter.emit("_redraw")}else this.showManipulatorToolbar()}},{key:"deleteSelected",value:function(){var t=this;!0!==this.editMode&&this.enableEditMode(),this._clean(),this.inMode="delete";var e=this.selectionHandler.getSelectedNodes(),i=this.selectionHandler.getSelectedEdges(),o=void 0;if(e.length>0){for(var n=0;n<e.length;n++)if(!0===this.body.nodes[e[n]].isCluster)return void alert(this.options.locales[this.options.locale].deleteClusterError||this.options.locales.en.deleteClusterError);"function"==typeof this.options.deleteNode&&(o=this.options.deleteNode)}else i.length>0&&"function"==typeof this.options.deleteEdge&&(o=this.options.deleteEdge);if("function"==typeof o){var s={nodes:e,edges:i} +;if(2!==o.length)throw new Error("The function for delete does not support two arguments (data, callback)");o(s,function(e){null!==e&&void 0!==e&&"delete"===t.inMode?(t.body.data.edges.getDataSet().remove(e.edges),t.body.data.nodes.getDataSet().remove(e.nodes),t.body.emitter.emit("startSimulation"),t.showManipulatorToolbar()):(t.body.emitter.emit("startSimulation"),t.showManipulatorToolbar())})}else this.body.data.edges.getDataSet().remove(i),this.body.data.nodes.getDataSet().remove(e),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()}},{key:"_setup",value:function(){!0===this.options.enabled?(this.guiEnabled=!0,this._createWrappers(),!1===this.editMode?this._createEditButton():this.showManipulatorToolbar()):(this._removeManipulationDOM(),this.guiEnabled=!1)}},{key:"_createWrappers",value:function(){void 0===this.manipulationDiv&&(this.manipulationDiv=document.createElement("div"),this.manipulationDiv.className="vis-manipulation",!0===this.editMode?this.manipulationDiv.style.display="block":this.manipulationDiv.style.display="none",this.canvas.frame.appendChild(this.manipulationDiv)),void 0===this.editModeDiv&&(this.editModeDiv=document.createElement("div"),this.editModeDiv.className="vis-edit-mode",!0===this.editMode?this.editModeDiv.style.display="none":this.editModeDiv.style.display="block",this.canvas.frame.appendChild(this.editModeDiv)),void 0===this.closeDiv&&(this.closeDiv=document.createElement("div"),this.closeDiv.className="vis-close",this.closeDiv.style.display=this.manipulationDiv.style.display,this.canvas.frame.appendChild(this.closeDiv))}},{key:"_getNewTargetNode",value:function(t,e){var i=f.deepExtend({},this.options.controlNodeStyle);i.id="targetNode"+f.randomUUID(),i.hidden=!1,i.physics=!1,i.x=t,i.y=e;var o=this.body.functions.createNode(i);return o.shape.boundingBox={left:t,right:t,top:e,bottom:e},o}},{key:"_createEditButton",value:function(){this._clean(),this.manipulationDOM={},f.recursiveDOMDelete(this.editModeDiv);var t=this.options.locales[this.options.locale],e=this._createButton("editMode","vis-button vis-edit vis-edit-mode",t.edit||this.options.locales.en.edit);this.editModeDiv.appendChild(e),this._bindHammerToDiv(e,this.toggleEditMode.bind(this))}},{key:"_clean",value:function(){this.inMode=!1,!0===this.guiEnabled&&(f.recursiveDOMDelete(this.editModeDiv),f.recursiveDOMDelete(this.manipulationDiv),this._cleanManipulatorHammers()),this._cleanupTemporaryNodesAndEdges(),this._unbindTemporaryUIs(),this._unbindTemporaryEvents(),this.body.emitter.emit("restorePhysics")}},{key:"_cleanManipulatorHammers",value:function(){if(0!=this.manipulationHammers.length){for(var t=0;t<this.manipulationHammers.length;t++)this.manipulationHammers[t].destroy();this.manipulationHammers=[]}}},{key:"_removeManipulationDOM",value:function(){this._clean(),f.recursiveDOMDelete(this.manipulationDiv),f.recursiveDOMDelete(this.editModeDiv),f.recursiveDOMDelete(this.closeDiv),this.manipulationDiv&&this.canvas.frame.removeChild(this.manipulationDiv),this.editModeDiv&&this.canvas.frame.removeChild(this.editModeDiv),this.closeDiv&&this.canvas.frame.removeChild(this.closeDiv),this.manipulationDiv=void 0,this.editModeDiv=void 0,this.closeDiv=void 0}},{key:"_createSeperator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.manipulationDOM["seperatorLineDiv"+t]=document.createElement("div"),this.manipulationDOM["seperatorLineDiv"+t].className="vis-separator-line",this.manipulationDiv.appendChild(this.manipulationDOM["seperatorLineDiv"+t])}},{key:"_createAddNodeButton",value:function(t){var e=this._createButton("addNode","vis-button vis-add",t.addNode||this.options.locales.en.addNode);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.addNodeMode.bind(this))}},{key:"_createAddEdgeButton",value:function(t){var e=this._createButton("addEdge","vis-button vis-connect",t.addEdge||this.options.locales.en.addEdge);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.addEdgeMode.bind(this))}},{key:"_createEditNodeButton",value:function(t){var e=this._createButton("editNode","vis-button vis-edit",t.editNode||this.options.locales.en.editNode);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.editNode.bind(this))}},{key:"_createEditEdgeButton",value:function(t){var e=this._createButton("editEdge","vis-button vis-edit",t.editEdge||this.options.locales.en.editEdge);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.editEdgeMode.bind(this))}},{key:"_createDeleteButton",value:function(t){var e;e=this.options.rtl?"vis-button vis-delete-rtl":"vis-button vis-delete";var i=this._createButton("delete",e,t.del||this.options.locales.en.del);this.manipulationDiv.appendChild(i),this._bindHammerToDiv(i,this.deleteSelected.bind(this))}},{key:"_createBackButton",value:function(t){var e=this._createButton("back","vis-button vis-back",t.back||this.options.locales.en.back);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.showManipulatorToolbar.bind(this))}},{key:"_createButton",value:function(t,e,i){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"vis-label";return this.manipulationDOM[t+"Div"]=document.createElement("div"),this.manipulationDOM[t+"Div"].className=e,this.manipulationDOM[t+"Label"]=document.createElement("div"),this.manipulationDOM[t+"Label"].className=o,this.manipulationDOM[t+"Label"].innerHTML=i,this.manipulationDOM[t+"Div"].appendChild(this.manipulationDOM[t+"Label"]),this.manipulationDOM[t+"Div"]}},{key:"_createDescription",value:function(t){this.manipulationDiv.appendChild(this._createButton("description","vis-button vis-none",t))}},{key:"_temporaryBindEvent",value:function(t,e){this.temporaryEventFunctions.push({event:t,boundFunction:e}),this.body.emitter.on(t,e)}},{key:"_temporaryBindUI",value:function(t,e){if(void 0===this.body.eventListeners[t])throw new Error("This UI function does not exist. Typo? You tried: "+t+" possible are: "+(0,a.default)((0,s.default)(this.body.eventListeners)));this.temporaryUIFunctions[t]=this.body.eventListeners[t],this.body.eventListeners[t]=e}},{key:"_unbindTemporaryUIs",value:function(){for(var t in this.temporaryUIFunctions)this.temporaryUIFunctions.hasOwnProperty(t)&&(this.body.eventListeners[t]=this.temporaryUIFunctions[t],delete this.temporaryUIFunctions[t]);this.temporaryUIFunctions={}}},{key:"_unbindTemporaryEvents",value:function(){for(var t=0;t<this.temporaryEventFunctions.length;t++){var e=this.temporaryEventFunctions[t].event,i=this.temporaryEventFunctions[t].boundFunction;this.body.emitter.off(e,i)}this.temporaryEventFunctions=[]}},{key:"_bindHammerToDiv",value:function(t,e){var i=new m(t,{});v.onTouch(i,e),this.manipulationHammers.push(i)}},{key:"_cleanupTemporaryNodesAndEdges",value:function(){for(var t=0;t<this.temporaryIds.edges.length;t++){this.body.edges[this.temporaryIds.edges[t]].disconnect(),delete this.body.edges[this.temporaryIds.edges[t]];var e=this.body.edgeIndices.indexOf(this.temporaryIds.edges[t]);-1!==e&&this.body.edgeIndices.splice(e,1)}for(var i=0;i<this.temporaryIds.nodes.length;i++){delete this.body.nodes[this.temporaryIds.nodes[i]];var o=this.body.nodeIndices.indexOf(this.temporaryIds.nodes[i]);-1!==o&&this.body.nodeIndices.splice(o,1)}this.temporaryIds={nodes:[],edges:[]}}},{key:"_controlNodeTouch",value:function(t){this.selectionHandler.unselectAll(),this.lastTouch=this.body.functions.getPointer(t.center),this.lastTouch.translation=f.extend({},this.body.view.translation)}},{key:"_controlNodeDragStart",value:function(t){var e=this.lastTouch,i=this.selectionHandler._pointerToPositionObject(e),o=this.body.nodes[this.temporaryIds.nodes[0]],n=this.body.nodes[this.temporaryIds.nodes[1]],s=this.body.edges[this.edgeBeingEditedId];this.selectedControlNode=void 0;var r=o.isOverlappingWith(i),a=n.isOverlappingWith(i);!0===r?(this.selectedControlNode=o,s.edgeType.from=o):!0===a&&(this.selectedControlNode=n,s.edgeType.to=n),void 0!==this.selectedControlNode&&this.selectionHandler.selectObject(this.selectedControlNode),this.body.emitter.emit("_redraw")}},{key:"_controlNodeDrag",value:function(t){this.body.emitter.emit("disablePhysics");var e=this.body.functions.getPointer(t.center),i=this.canvas.DOMtoCanvas(e);if(void 0!==this.selectedControlNode)this.selectedControlNode.x=i.x,this.selectedControlNode.y=i.y;else{var o=e.x-this.lastTouch.x,n=e.y-this.lastTouch.y;this.body.view.translation={x:this.lastTouch.translation.x+o,y:this.lastTouch.translation.y+n}}this.body.emitter.emit("_redraw")}},{key:"_controlNodeDragEnd",value:function(t){var e=this.body.functions.getPointer(t.center),i=this.selectionHandler._pointerToPositionObject(e),o=this.body.edges[this.edgeBeingEditedId];if(void 0!==this.selectedControlNode){this.selectionHandler.unselectAll();for(var n=this.selectionHandler._getAllNodesOverlappingWith(i),s=void 0,r=n.length-1;r>=0;r--)if(n[r]!==this.selectedControlNode.id){s=this.body.nodes[n[r]];break}if(void 0!==s&&void 0!==this.selectedControlNode)if(!0===s.isCluster)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var a=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===a.id?this._performEditEdge(s.id,o.to.id):this._performEditEdge(o.from.id,s.id)}else o.updateEdgeType(),this.body.emitter.emit("restorePhysics");this.body.emitter.emit("_redraw")}}},{key:"_handleConnect",value:function(t){if((new Date).valueOf()-this.touchTime>100){this.lastTouch=this.body.functions.getPointer(t.center),this.lastTouch.translation=f.extend({},this.body.view.translation);var e=this.lastTouch,i=this.selectionHandler.getNodeAt(e);if(void 0!==i)if(!0===i.isCluster)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var o=this._getNewTargetNode(i.x,i.y);this.body.nodes[o.id]=o,this.body.nodeIndices.push(o.id);var n=this.body.functions.createEdge({id:"connectionEdge"+f.randomUUID(),from:i.id,to:o.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[n.id]=n,this.body.edgeIndices.push(n.id),this.temporaryIds.nodes.push(o.id),this.temporaryIds.edges.push(n.id)}this.touchTime=(new Date).valueOf()}}},{key:"_dragControlNode",value:function(t){var e=this.body.functions.getPointer(t.center);if(void 0!==this.temporaryIds.nodes[0]){var i=this.body.nodes[this.temporaryIds.nodes[0]];i.x=this.canvas._XconvertDOMtoCanvas(e.x),i.y=this.canvas._YconvertDOMtoCanvas(e.y),this.body.emitter.emit("_redraw")}else{var o=e.x-this.lastTouch.x,n=e.y-this.lastTouch.y;this.body.view.translation={x:this.lastTouch.translation.x+o,y:this.lastTouch.translation.y+n}}}},{key:"_finishConnect",value:function(t){var e=this.body.functions.getPointer(t.center),i=this.selectionHandler._pointerToPositionObject(e),o=void 0;void 0!==this.temporaryIds.edges[0]&&(o=this.body.edges[this.temporaryIds.edges[0]].fromId);for(var n=this.selectionHandler._getAllNodesOverlappingWith(i),s=void 0,r=n.length-1;r>=0;r--)if(-1===this.temporaryIds.nodes.indexOf(n[r])){s=this.body.nodes[n[r]];break}this._cleanupTemporaryNodesAndEdges(),void 0!==s&&(!0===s.isCluster?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):void 0!==this.body.nodes[o]&&void 0!==this.body.nodes[s.id]&&this._performAddEdge(o,s.id)),this.body.emitter.emit("_redraw")}},{key:"_dragStartEdge",value:function(t){var e=this.lastTouch;this.selectionHandler._generateClickEvent("dragStart",t,e,void 0,!0)}},{key:"_performAddNode",value:function(t){var e=this,i={id:f.randomUUID(),x:t.pointer.canvas.x,y:t.pointer.canvas.y,label:"new"};if("function"==typeof this.options.addNode){if(2!==this.options.addNode.length)throw this.showManipulatorToolbar(),new Error("The function for add does not support two arguments (data,callback)");this.options.addNode(i,function(t){null!==t&&void 0!==t&&"addNode"===e.inMode&&(e.body.data.nodes.getDataSet().add(t),e.showManipulatorToolbar())})}else this.body.data.nodes.getDataSet().add(i),this.showManipulatorToolbar()}},{key:"_performAddEdge",value:function(t,e){var i=this,o={from:t,to:e};if("function"==typeof this.options.addEdge){if(2!==this.options.addEdge.length)throw new Error("The function for connect does not support two arguments (data,callback)");this.options.addEdge(o,function(t){null!==t&&void 0!==t&&"addEdge"===i.inMode&&(i.body.data.edges.getDataSet().add(t),i.selectionHandler.unselectAll(),i.showManipulatorToolbar())})}else this.body.data.edges.getDataSet().add(o),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},{key:"_performEditEdge",value:function(t,e){var i=this,o={id:this.edgeBeingEditedId,from:t,to:e,label:this.body.data.edges._data[this.edgeBeingEditedId].label},n=this.options.editEdge;if("object"===(void 0===n?"undefined":(0,d.default)(n))&&(n=n.editWithoutDrag),"function"==typeof n){if(2!==n.length)throw new Error("The function for edit does not support two arguments (data, callback)");n(o,function(t){null===t||void 0===t||"editEdge"!==i.inMode?(i.body.edges[o.id].updateEdgeType(),i.body.emitter.emit("_redraw"),i.showManipulatorToolbar()):(i.body.data.edges.getDataSet().update(t),i.selectionHandler.unselectAll(),i.showManipulatorToolbar())})}else this.body.data.edges.getDataSet().update(o),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}}]),t}();e.default=g},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(30),s=o(n),r=i(0),a=o(r),h=i(1),d=o(h),l=i(239),u=o(l),c=function(){function t(e,i,o){(0,a.default)(this,t),this.body=e,this.springLength=i,this.springConstant=o,this.distanceSolver=new u.default}return(0,d.default)(t,[{key:"setOptions",value:function(t){t&&(t.springLength&&(this.springLength=t.springLength),t.springConstant&&(this.springConstant=t.springConstant))}},{key:"solve",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=this.distanceSolver.getDistances(this.body,t,e);this._createL_matrix(o),this._createK_matrix(o),this._createE_matrix();for(var n=0,r=Math.max(1e3,Math.min(10*this.body.nodeIndices.length,6e3)),a=1e9,h=0,d=0,l=0,u=0,c=0;a>.01&&n<r;){n+=1;var p=this._getHighestEnergyNode(i),f=(0,s.default)(p,4);for(h=f[0],a=f[1],d=f[2],l=f[3],u=a,c=0;u>1&&c<5;){c+=1,this._moveNode(h,d,l);var m=this._getEnergy(h),v=(0,s.default)(m,3);u=v[0],d=v[1],l=v[2]}}}},{key:"_getHighestEnergyNode",value:function(t){for(var e=this.body.nodeIndices,i=this.body.nodes,o=0,n=e[0],r=0,a=0,h=0;h<e.length;h++){var d=e[h];if(!1===i[d].predefinedPosition||!0===i[d].isCluster&&!0===t||!0===i[d].options.fixed.x||!0===i[d].options.fixed.y){var l=this._getEnergy(d),u=(0,s.default)(l,3),c=u[0],p=u[1],f=u[2];o<c&&(o=c,n=d,r=p,a=f)}}return[n,o,r,a]}},{key:"_getEnergy",value:function(t){var e=(0,s.default)(this.E_sums[t],2),i=e[0],o=e[1];return[Math.sqrt(Math.pow(i,2)+Math.pow(o,2)),i,o]}},{key:"_moveNode",value:function(t,e,i){for(var o=this.body.nodeIndices,n=this.body.nodes,s=0,r=0,a=0,h=n[t].x,d=n[t].y,l=this.K_matrix[t],u=this.L_matrix[t],c=0;c<o.length;c++){var p=o[c];if(p!==t){var f=n[p].x,m=n[p].y,v=l[p],g=u[p],y=1/Math.pow(Math.pow(h-f,2)+Math.pow(d-m,2),1.5);s+=v*(1-g*Math.pow(d-m,2)*y),r+=v*(g*(h-f)*(d-m)*y),a+=v*(1-g*Math.pow(h-f,2)*y)}}var b=s,_=r,w=e,x=a,k=i,S=(w/b+k/_)/(_/b-x/_),D=-(_*S+w)/b;n[t].x+=D,n[t].y+=S,this._updateE_matrix(t)}},{key:"_createL_matrix",value:function(t){var e=this.body.nodeIndices,i=this.springLength;this.L_matrix=[];for(var o=0;o<e.length;o++){this.L_matrix[e[o]]={};for(var n=0;n<e.length;n++)this.L_matrix[e[o]][e[n]]=i*t[e[o]][e[n]]}}},{key:"_createK_matrix",value:function(t){var e=this.body.nodeIndices,i=this.springConstant;this.K_matrix=[];for(var o=0;o<e.length;o++){this.K_matrix[e[o]]={};for(var n=0;n<e.length;n++)this.K_matrix[e[o]][e[n]]=i*Math.pow(t[e[o]][e[n]],-2)}}},{key:"_createE_matrix",value:function(){var t=this.body.nodeIndices,e=this.body.nodes;this.E_matrix={},this.E_sums={};for(var i=0;i<t.length;i++)this.E_matrix[t[i]]=[];for(var o=0;o<t.length;o++){for(var n=t[o],s=e[n].x,r=e[n].y,a=0,h=0,d=o;d<t.length;d++){var l=t[d];if(l!==n){var u=e[l].x,c=e[l].y,p=1/Math.sqrt(Math.pow(s-u,2)+Math.pow(r-c,2));this.E_matrix[n][d]=[this.K_matrix[n][l]*(s-u-this.L_matrix[n][l]*(s-u)*p),this.K_matrix[n][l]*(r-c-this.L_matrix[n][l]*(r-c)*p)],this.E_matrix[l][o]=this.E_matrix[n][d],a+=this.E_matrix[n][d][0],h+=this.E_matrix[n][d][1]}}this.E_sums[n]=[a,h]}}},{key:"_updateE_matrix",value:function(t){for(var e=this.body.nodeIndices,i=this.body.nodes,o=this.E_matrix[t],n=this.K_matrix[t],s=this.L_matrix[t],r=i[t].x,a=i[t].y,h=0,d=0,l=0;l<e.length;l++){var u=e[l];if(u!==t){var c=o[l],p=c[0],f=c[1],m=i[u].x,v=i[u].y,g=1/Math.sqrt(Math.pow(r-m,2)+Math.pow(a-v,2)),y=n[u]*(r-m-s[u]*(r-m)*g),b=n[u]*(a-v-s[u]*(a-v)*g);o[l]=[y,b],h+=y,d+=b;var _=this.E_sums[u];_[0]+=y-p,_[1]+=b-f}}this.E_sums[t]=[h,d]}}]),t}();e.default=c},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=o(n),r=i(1),a=o(r),h=function(){function t(){(0,s.default)(this,t)}return(0,a.default)(t,[{key:"getDistances",value:function(t,e,i){for(var o={},n=t.edges,s=0;s<e.length;s++){var r=e[s],a={};o[r]=a;for(var h=0;h<e.length;h++)a[e[h]]=s==h?0:1e9}for(var d=0;d<i.length;d++){var l=n[i[d]];!0===l.connected&&void 0!==o[l.fromId]&&void 0!==o[l.toId]&&(o[l.fromId][l.toId]=1,o[l.toId][l.fromId]=1)}for(var u=e.length,c=0;c<u;c++)for(var p=e[c],f=o[p],m=0;m<u-1;m++)for(var v=e[m],g=o[v],y=m+1;y<u;y++){var b=e[y],_=o[b],w=Math.min(g[b],g[p]+f[b]);g[b]=w,_[v]=w}return o}}]),t}();e.default=h}])}); +//# sourceMappingURL=vis.map diff --git a/opts.mk b/opts.mk new file mode 100644 index 0000000000000000000000000000000000000000..607c5ddf74dd0d83dd623e4edb733ede96c0d6bf --- /dev/null +++ b/opts.mk @@ -0,0 +1,13 @@ +CONF_OPTS= + +# Use handwritten lexer +CONF_OPTS+=-l + +# Use ocamllex lexer +#CONF_OPTS+=-L + +# Use alpaga parser +CONF_OPTS+=-a + +# Use menhir parser +#CONF_OPTS+=-m diff --git a/runtime/.gitignore b/runtime/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..38dd463d7294caf96a0f49672aa21f0632b889fb --- /dev/null +++ b/runtime/.gitignore @@ -0,0 +1,2 @@ +tmp/ +*.o \ No newline at end of file diff --git a/runtime/lib32.s b/runtime/lib32.s new file mode 100644 index 0000000000000000000000000000000000000000..1249dd2695e39b72383836cf596e32c41fca1bf5 --- /dev/null +++ b/runtime/lib32.s @@ -0,0 +1,228 @@ + .include "syscall_numbers.s" + .global atoi + .global print_int + .global println + .global print + .global print_a1 + .global print_char + .global strlen + .global ltoa + .global print_string + +atoi: + +addi sp,sp,-48 +sw s0,44(sp) +addi s0,sp,48 +sw a0,-36(s0) +sw zero,-20(s0) +j .L2 + +.L3: +lw a5,-20(s0) +slli a4,a5,0x3 +lw a5,-20(s0) +slli a5,a5,0x1 +add a5,a4,a5 +lw a4,-36(s0) +lbu a4,0(a4) +add a5,a5,a4 +addi a5,a5,-48 +sw a5,-20(s0) +lw a5,-36(s0) +addi a5,a5,1 +sw a5,-36(s0) + +.L2: +lw a5,-36(s0) +lbu a5,0(a5) +bnez a5,.L3 +lw a5,-20(s0) +mv a0,a5 +lw s0,44(sp) +addi sp,sp,48 +ret + +print_int: +addi sp, sp, -8 +sw ra,0(sp) +lui a1, %hi(buf) +addi a1, a1, %lo(buf) +jal ra, itoa +mv a1, a0 +jal ra, print_a1 +lw ra, 0(sp) +addi sp, sp, 8 +jr ra +print_a1: +addi sp, sp, -8 +sw ra,0(sp) +mv a0, a1 +jal ra, strlen +lw ra, 0(sp) +addi sp, sp, 8 +mv a2, a0 +li a0, 1 +li a3, 0 +li a4, 0 +li a5, 0 +li a6, 0 +li a7, SYSCALL_WRITE +ecall +jr ra +print_char: +addi sp, sp, -8 +sw ra, 0(sp) +la a1, buf +sb a0, 0(a1) +sb zero, 1(a1) +jal ra, print_a1 +lw ra, 0(sp) +addi sp, sp, 8 +jr ra + +print: +addi sp,sp,-32 +sw ra,24(sp) +sw s0,16(sp) +addi s0,sp,32 +sw a0,-24(s0) +lw a0,-24(s0) +jal ra,print_int +jal ra,println +nop +lw ra,24(sp) +lw s0,16(sp) +addi sp,sp,32 +ret +strlen: +addi sp,sp,-48 +sw s0,44(sp) +addi s0,sp,48 +sw a0,-36(s0) +sw zero,-20(s0) +j .strlenL2 +.strlenL3: +lw a5,-20(s0) +addi a5,a5,1 +sw a5,-20(s0) +.strlenL2: +lw a5,-36(s0) +addi a4,a5,1 +sw a4,-36(s0) +lbu a5,0(a5) +bnez a5,.strlenL3 +lw a5,-20(s0) +mv a0,a5 +lw s0,44(sp) +addi sp,sp,48 +jr ra +itoa: +addi sp,sp,-48 +sw s0,44(sp) +addi s0,sp,48 +sw a0,-36(s0) +sw a1,-40(s0) +lw a5,-40(s0) +addi a5,a5,10 +sw a5,-20(s0) +lw a5,-20(s0) +sb zero,0(a5) +sb zero,-21(s0) +lw a5,-36(s0) +bgez a5,.itoaL2 +li a5,1 +sb a5,-21(s0) +lw a5,-36(s0) +neg a5,a5 +sw a5,-36(s0) +.itoaL2: +lw a5,-36(s0) +bnez a5,.itoaL5 +lw a5,-20(s0) +addi a5,a5,-1 +sw a5,-20(s0) +lw a5,-20(s0) +li a4,48 +sb a4,0(a5) +lw a5,-20(s0) +j .itoaL4 +.itoaL6: +lw a4,-36(s0) +li a5,10 +rem a5,a4,a5 +andi a5,a5,0xff +lw a4,-20(s0) +addi a4,a4,-1 +sw a4,-20(s0) +addi a5,a5,48 +andi a4,a5,0xff +lw a5,-20(s0) +sb a4,0(a5) +lw a4,-36(s0) +li a5,10 +div a5,a4,a5 +sw a5,-36(s0) +.itoaL5: +lw a5,-36(s0) +bgtz a5,.itoaL6 +lbu a5,-21(s0) +beqz a5,.itoaL7 +lw a5,-20(s0) +addi a5,a5,-1 +sw a5,-20(s0) +lw a5,-20(s0) +li a4,45 +sb a4,0(a5) +.itoaL7: +lw a5,-20(s0) +.itoaL4: +mv a0,a5 +lw s0,44(sp) +addi sp,sp,48 +jr ra + + +println: +mv t6, ra +lui a1, %hi(nl) +addi a1, a1, %lo(nl) +jal ra, print_a1 +jr t6 +print_string: +addi sp, sp, -8 +sw ra, 0(sp) +addi sp, sp, -8 +sw s0, 0(sp) +addi sp, sp, -64 +sw a0, 56(sp) +sw a1, 48(sp) +sw a2, 40(sp) +sw a3, 32(sp) +sw a4, 24(sp) +sw a5, 16(sp) +sw a6, 8(sp) +sw a7, 0(sp) +mv a1, a0 +jal print_a1 +lw a0, 56(sp) +lw a1, 48(sp) +lw a2, 40(sp) +lw a3, 32(sp) +lw a4, 24(sp) +lw a5, 16(sp) +lw a6, 8(sp) +lw a7, 0(sp) +addi sp, sp, 64 +lw s0, 0(sp) +addi sp, sp, 8 +lw ra, 0(sp) +addi sp, sp, 8 +jr ra + .section .rodata + nl: + .string "\n" + + .section .data + buf: + .string "XXXXXXXXXXXXXXXXXXXX" diff --git a/runtime/lib64.s b/runtime/lib64.s new file mode 100644 index 0000000000000000000000000000000000000000..8a4710e71379bfcf163554cbd98dfbb4c718d25e --- /dev/null +++ b/runtime/lib64.s @@ -0,0 +1,202 @@ +.include "syscall_numbers.s" + .global atoi + .global print_int + .global println + .global print + .global print_a1 + .global print_char + .global strlen + .global ltoa + .global print_string + +atoi: +addi sp,sp,-48 +sd s0,40(sp) +addi s0,sp,48 +sd a0,-40(s0) +sw zero,-20(s0) +j .L2 + +.L3: +lw a4,-20(s0) +mv a5,a4 +slliw a5,a5,0x2 +addw a5,a5,a4 +slliw a5,a5,0x1 +sext.w a4,a5 +lbu a5,-21(s0) +sext.w a5,a5 +addw a5,a5,a4 +sext.w a5,a5 +addiw a5,a5,-48 +sw a5,-20(s0) + +.L2: +ld a5,-40(s0) +addi a4,a5,1 +sd a4,-40(s0) +lbu a5,0(a5) +sb a5,-21(s0) +lbu a5,-21(s0) +andi a5,a5,255 +bnez a5, .L3 +lw a5,-20(s0) +mv a0,a5 +ld s0,40(sp) +addi sp,sp,48 +ret +print_int: +addi sp, sp, -8 +sd ra,0(sp) +lui a1, %hi(buf) +addi a1, a1, %lo(buf) +jal ra, ltoa +mv a1, a0 +jal ra, print_a1 +ld ra, 0(sp) +addi sp, sp, 8 +jr ra + +print_a1: +addi sp, sp, -8 +sd ra,0(sp) +mv a0, a1 +jal ra, strlen +ld ra, 0(sp) +addi sp, sp, 8 +mv a2, a0 +li a0, 1 +li a3, 0 +li a4, 0 +li a5, 0 +li a6, 0 +li a7, SYSCALL_WRITE +ecall +jr ra + +print_char: +addi sp, sp, -8 +sd ra, 0(sp) +la a1, buf +sb a0, 0(a1) +sb zero, 1(a1) +jal ra, print_a1 +ld ra, 0(sp) +addi sp, sp, 8 +jr ra + +print: +addi sp,sp,-32 +sd ra,24(sp) +sd s0,16(sp) +addi s0,sp,32 +sd a0,-24(s0) +ld a0,-24(s0) +jal ra,print_int +jal ra,println +nop +ld ra,24(sp) +ld s0,16(sp) +addi sp,sp,32 +ret + strlen: +addi sp,sp,-48 +sd s0,40(sp) +addi s0,sp,48 +sd a0,-40(s0) +sw zero,-20(s0) +j .L6 + +.L7: +lw a5,-20(s0) +addiw a5,a5,1 +sw a5,-20(s0) + +.L6: +ld a5,-40(s0) +addi a4,a5,1 +sd a4,-40(s0) +lbu a5,0(a5) +bnez a5,.L7 +lw a5,-20(s0) +mv a0,a5 +ld s0,40(sp) +addi sp,sp,48 +ret +ltoa: +mv a5,a0 +addi a3,a1,20 +sb zero,20(a1) +li a1,0 +bltz a0,.L27 + +.L22: +li a2,10 +j .L23 + +.L27: +neg a5,a0 +li a1,1 +j .L22 + +.L26: +mv a3,a0 + +.L23: +rem a4,a5,a2 +addiw a4,a4,48 +sb a4,-1(a3) +addi a0,a3,-1 +div a5,a5,a2 +bgtz a5,.L26 +beqz a1,.L21 +li a5,45 +sb a5,-1(a0) +addi a0,a3,-2 + +.L21: +ret +println: +mv t6, ra +lui a1, %hi(nl) +addi a1, a1, %lo(nl) +jal ra, print_a1 +jr t6 +print_string: +addi sp, sp, -8 +sd ra, 0(sp) +addi sp, sp, -8 +sd s0, 0(sp) +addi sp, sp, -64 +sd a0, 56(sp) +sd a1, 48(sp) +sd a2, 40(sp) +sd a3, 32(sp) +sd a4, 24(sp) +sd a5, 16(sp) +sd a6, 8(sp) +sd a7, 0(sp) +mv a1, a0 +jal print_a1 +ld a0, 56(sp) +ld a1, 48(sp) +ld a2, 40(sp) +ld a3, 32(sp) +ld a4, 24(sp) +ld a5, 16(sp) +ld a6, 8(sp) +ld a7, 0(sp) +addi sp, sp, 64 +ld s0, 0(sp) +addi sp, sp, 8 +ld ra, 0(sp) +addi sp, sp, 8 +jr ra + + .section .rodata + nl: + .string "\n" + + .section .data + buf: + .string "XXXXXXXXXXXXXXXXXXXX" diff --git a/runtime/link.ld b/runtime/link.ld new file mode 100644 index 0000000000000000000000000000000000000000..6aa203cde1ec13205db557a0f56cf98e076e9ddf --- /dev/null +++ b/runtime/link.ld @@ -0,0 +1,24 @@ +OUTPUT_ARCH( "riscv" ) +ENTRY( _start ) +heap_size = 0x2000; +SECTIONS +{ +/* text: test code section */ +. = 0x2000000; +.text : +{ +*(.text) +} +. = 0x8000000; +/* data: Initialized data segment */ +.data : +{ +. = ALIGN(8); +_heap_start = .; +. = . + heap_size; +_heap_end = .; +*(.data) +} +/* End of uninitalized data segement */ +_end = .; +} diff --git a/runtime/linux/syscall_numbers.s b/runtime/linux/syscall_numbers.s new file mode 100644 index 0000000000000000000000000000000000000000..d95e1e236beab72a6e3c47af0b0a218ab82c73c2 --- /dev/null +++ b/runtime/linux/syscall_numbers.s @@ -0,0 +1,2 @@ +.equ SYSCALL_WRITE, 64 +.equ SYSCALL_EXIT, 93 diff --git a/runtime/mul32.S b/runtime/mul32.S new file mode 100644 index 0000000000000000000000000000000000000000..c3a2b64c761de289ba0b7bad19b0af1ee23cfc91 --- /dev/null +++ b/runtime/mul32.S @@ -0,0 +1,87 @@ + .text + .global __muldi3 +__muldi3: + mv a2, a0 + li a0, 0 + .L101: + andi a3, a1, 1 + beqz a3, .L102 + add a0, a0, a2 + .L102: + srli a1, a1, 1 + slli a2, a2, 1 + bnez a1, .L101 + ret + +.global __divdi3 +__divdi3: + bltz a0, .L10 + bltz a1, .L11 + /* Since the quotient is positive, fall into __udivdi3. */ + +.global __udivdi3 +__udivdi3: + mv a2, a1 + mv a1, a0 + li a0, -1 + beqz a2, .L5 + li a3, 1 + bgeu a2, a1, .L2 +.L1: + blez a2, .L2 + slli a2, a2, 1 + slli a3, a3, 1 + bgtu a1, a2, .L1 +.L2: + li a0, 0 +.L3: + bltu a1, a2, .L4 + sub a1, a1, a2 + or a0, a0, a3 +.L4: + srli a3, a3, 1 + srli a2, a2, 1 + bnez a3, .L3 +.L5: + ret + +.global __umoddi3 +__umoddi3: + /* Call __udivdi3(a0, a1), then return the remainder, which is in a1. */ + move t0, ra + jal __udivdi3 + move a0, a1 + jr t0 + + /* Handle negative arguments to __divdi3. */ +.L10: + neg a0, a0 + bgez a1, .L12 /* Compute __udivdi3(-a0, a1), then negate the result. */ + neg a1, a1 + j __udivdi3 /* Compute __udivdi3(-a0, -a1). */ +.L11: /* Compute __udivdi3(a0, -a1), then negate the result. */ + neg a1, a1 +.L12: + move t0, ra + jal __udivdi3 + neg a0, a0 + jr t0 + + +.global __moddi3 +__moddi3: + move t0, ra + bltz a1, .L31 + bltz a0, .L32 +.L30: + jal __udivdi3 /* The dividend is not negative. */ + move a0, a1 + jr t0 +.L31: + neg a1, a1 + bgez a0, .L30 +.L32: + neg a0, a0 + jal __udivdi3 /* The dividend is hella negative. */ + neg a0, a1 + jr t0 diff --git a/runtime/mul64.S b/runtime/mul64.S new file mode 100644 index 0000000000000000000000000000000000000000..8d7d4a9805c9ecc627ff5a92abc77e8d6b0a9534 --- /dev/null +++ b/runtime/mul64.S @@ -0,0 +1,120 @@ + .text + .global __muldi3 +__muldi3: + mv a2, a0 + li a0, 0 + .L101: + andi a3, a1, 1 + beqz a3, .L102 + add a0, a0, a2 + .L102: + srli a1, a1, 1 + slli a2, a2, 1 + bnez a1, .L101 + ret + + .global __udivsi3 +__udivsi3: + /* Compute __udivdi3(a0 << 32, a1 << 32); cast result to uint32_t. */ + sll a0, a0, 32 + sll a1, a1, 32 + move t0, ra + jal __udivdi3 + sext.w a0, a0 + jr t0 + +.global __umodsi3 +__umodsi3: + /* Compute __udivdi3((uint32_t)a0, (uint32_t)a1); cast a1 to uint32_t. */ + sll a0, a0, 32 + sll a1, a1, 32 + srl a0, a0, 32 + srl a1, a1, 32 + move t0, ra + jal __udivdi3 + sext.w a0, a1 + jr t0 + +.global __divsi3 +__divsi3: + /* Check for special case of INT_MIN/-1. Otherwise, fall into __divdi3. */ + li t0, -1 + beq a1, t0, .L20 + +.global __divdi3 +__divdi3: + bltz a0, .L10 + bltz a1, .L11 + /* Since the quotient is positive, fall into __udivdi3. */ + +.global __udivdi3 +__udivdi3: + mv a2, a1 + mv a1, a0 + li a0, -1 + beqz a2, .L5 + li a3, 1 + bgeu a2, a1, .L2 +.L1: + blez a2, .L2 + slli a2, a2, 1 + slli a3, a3, 1 + bgtu a1, a2, .L1 +.L2: + li a0, 0 +.L3: + bltu a1, a2, .L4 + sub a1, a1, a2 + or a0, a0, a3 +.L4: + srli a3, a3, 1 + srli a2, a2, 1 + bnez a3, .L3 +.L5: + ret + +.global __umoddi3 +__umoddi3: + /* Call __udivdi3(a0, a1), then return the remainder, which is in a1. */ + move t0, ra + jal __udivdi3 + move a0, a1 + jr t0 + + /* Handle negative arguments to __divdi3. */ +.L10: + neg a0, a0 + bgez a1, .L12 /* Compute __udivdi3(-a0, a1), then negate the result. */ + neg a1, a1 + j __udivdi3 /* Compute __udivdi3(-a0, -a1). */ +.L11: /* Compute __udivdi3(a0, -a1), then negate the result. */ + neg a1, a1 +.L12: + move t0, ra + jal __udivdi3 + neg a0, a0 + jr t0 + + +.global __moddi3 +__moddi3: + move t0, ra + bltz a1, .L31 + bltz a0, .L32 +.L30: + jal __udivdi3 /* The dividend is not negative. */ + move a0, a1 + jr t0 +.L31: + neg a1, a1 + bgez a0, .L30 +.L32: + neg a0, a0 + jal __udivdi3 /* The dividend is hella negative. */ + neg a0, a1 + jr t0 + +.L20: + sll t0, t0, 31 + bne a0, t0, __divdi3 + ret diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..a4123a9d9de4517284153781e0a3bf5453a04b85 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,32 @@ +include ../opts.mk + +SRC=archi.ml ast.ml builtins.ml config.ml cfg_constprop.ml cfg_dead_assign.ml \ +cfg.ml cfg_print.ml cfg_gen.ml cfg_liveness.ml cfg_nop_elim.ml cfg_run.ml \ +elang.ml elang_print.ml elang_gen.ml elang_run.ml e_regexp.ml \ +generated_parser.ml lexer_generator.ml linear_dse.ml linear_liveness.ml \ +linear.ml linear_print.ml linear_gen.ml linear_run.ml ltl.ml ltl_print.ml \ +ltl_gen.ml ltl_run.ml ltl_debug.ml main.ml options.ml parser.ml prog.ml \ +regalloc.ml report.ml riscv.ml rtl.ml rtl_print.ml rtl_gen.ml rtl_run.ml \ +symbols.ml tokenize.ml utils.ml + +TG = main.exe + +PROF:=$(if $(PROF),-ocamlopt ocamloptp,) + +all: $(TG) + +$(TG): $(SRC) + dune build $(TG) + # ocamlbuild $(PROF) -cflags -warn-error,"+a-26" -cflags -w,"-26" -menhir "menhir --unused-tokens" -use-ocamlfind $(TG) + +test_lexer: archi.ml config.ml e_regexp.ml lexer_generator.ml symbols.ml test_lexer.ml utils.ml + dune exec ./test_lexer.exe + dot -Tsvg /tmp/dfa.dot -o /tmp/dfa.svg + dot -Tsvg /tmp/nfa.dot -o /tmp/nfa.svg + +config.ml: ../configure ../opts.mk + cd .. && ./configure ${CONF_OPTS} + +clean: + dune clean + rm -f config.ml diff --git a/src/archi.ml b/src/archi.ml new file mode 100644 index 0000000000000000000000000000000000000000..cfaa1b381f91cdf88d6b055240323e8447c393a8 --- /dev/null +++ b/src/archi.ml @@ -0,0 +1,60 @@ + +type archi = A64 | A32 + +let archi = ref A64 +let nbits () = + match !archi with + | A64 -> 64 + | A32 -> 32 + +let wordsize () = nbits () / 8 + +let assembler () = + let opts = + match !archi with + | A64 -> "-march=rv64imafdc -mabi=lp64d" + | A32 -> "-march=rv32imafdc -mabi=ilp32" + in + Format.sprintf "%s %s" Config.rv_as opts + +let linker () = + let opts = + match !archi with + A64 -> "-melf64lriscv" + | A32 -> "-melf32lriscv" + in + Format.sprintf "%s %s" Config.rv_ld opts + +let instrsuffix () = + match !archi with + | A64 -> 'd' + | A32 -> 'w' + +let qemu () = + match !archi with + | A64 -> Config.qemu64 + | A32 -> Config.qemu32 + +let heapstart = ref 8 + +type target_system = + | Linux + | Xv6 + +let target = ref Linux + +let lib_syscall () = + match !target with + | Linux -> "linux" + | Xv6 -> "xv6" + +let target_data_segment t = + match t with + | Linux -> "8000000" + | Xv6 -> "2000" + +let runtime_lib_include_path () = + Format.sprintf "%s/%s" Config.runtime_dir (lib_syscall ()) + +let runtime_lib_path () = + Format.sprintf "%s/lib%d.s" Config.runtime_dir (nbits ()) diff --git a/src/ast.ml b/src/ast.ml new file mode 100644 index 0000000000000000000000000000000000000000..bfd93a8a25c70dd90d9f6504fa19e221ed3bb193 --- /dev/null +++ b/src/ast.ml @@ -0,0 +1,117 @@ +open Batteries + +(* Les AST sont des arbres, du type [tree], étiquetés par des [tag]. + + Un arbre [tree] est soit un nÅ“ud [Node(t, children)] où [t] est un tag et + [children] une liste de sous-arbres ; soit une feuille qui contient une + chaîne de caractères ([StringLeaf]), un entier ([IntLeaf]), un caractère + ([CharLeaf]), ou rien du tout ([NullLeaf]). + + La signification des différents tags : + + - importe peu : vous pouvez définir de nouveaux types de tags si ça vous + semble nécessaire / profitable, pour peu de compléter la fonction + [string_of_tag] ci-dessous. + + - devrait être assez claire d'après le nom du tag ou l'utilisation qui en est + faite dans l'exemple donné dans le sujet. + + - peut être demandée à votre encadrant de TP favori (ou celui présent en + séance, à défaut) + + +*) + +type tag = Tassign | Tif | Twhile | Tblock | Treturn | Tprint + | Tint + | Tadd | Tmul | Tdiv | Tmod | Txor | Tsub + | Tclt | Tcgt | Tcle | Tcge | Tceq | Tne + | Tneg + | Tlistglobdef + | Tfundef | Tfunname | Tfunargs | Tfunbody + | Tassignvar + | Targ + +type tree = | Node of tag * tree list + | StringLeaf of string + | IntLeaf of int + | NullLeaf + | CharLeaf of char + +let string_of_stringleaf = function + | StringLeaf s -> s + | _ -> failwith "string_of_stringleaf called on non-stringleaf nodes." + +type astfun = (string list * tree) +type ast = (string * astfun) list + +let string_of_tag = function + | Tassign -> "Tassign" + | Tif -> "Tif" + | Twhile -> "Twhile" + | Tblock -> "Tblock" + | Treturn -> "Treturn" + | Tprint -> "Tprint" + | Tint -> "Tint" + | Tadd -> "Tadd" + | Tmul -> "Tmul" + | Tdiv -> "Tdiv" + | Tmod -> "Tmod" + | Txor -> "Txor" + | Tsub -> "Tsub" + | Tclt -> "Tclt" + | Tcgt -> "Tcgt" + | Tcle -> "Tcle" + | Tcge -> "Tcge" + | Tceq -> "Tceq" + | Tne -> "Tne" + | Tneg -> "Tneg" + | Tlistglobdef -> "Tlistglobdef" + | Tfundef -> "Tfundef" + | Tfunname -> "Tfunname" + | Tfunargs -> "Tfunargs" + | Tfunbody -> "Tfunbody" + | Tassignvar -> "Tassignvar" + | Targ -> "Targ" + + +(* Écrit un fichier .dot qui correspond à un AST *) +let rec draw_ast a next = + match a with + | Node (t, l) -> + + let (code, nodes, next) = + List.fold_left (fun (code, nodes, nextnode) n -> + let (node, next, ncode) = draw_ast n nextnode in + (code @ ncode, node::nodes, next) + ) ([], [], next) + l in + (next, next+1, code @ [ + Format.sprintf "n%d [label=\"%s\"]\n" next (string_of_tag t) + ] @ List.map (fun n -> + Format.sprintf "n%d -> n%d\n" next n + )nodes) + + | StringLeaf s -> + (next, next+1, [ Format.sprintf "n%d [label=\"%s\"]\n" next s]) + | IntLeaf i -> + (next, next+1, [ Format.sprintf "n%d [label=\"%d\"]\n" next i]) + | NullLeaf -> + (next, next+1, [ Format.sprintf "n%d [label=\"null\"]\n" next]) + | CharLeaf i -> + (next, next+1, [ Format.sprintf "n%d [label=\"%c\"]\n" next i]) + +let draw_ast_tree oc ast = + let (_, _, s) = draw_ast ast 1 in + let s = String.concat "" s in + Format.fprintf oc "digraph G{\n%s\n}\n" s + +let rec string_of_ast a = + match a with + | Node (t, l) -> + Format.sprintf "Node(%s,%s)" (string_of_tag t) + (String.concat ", " (List.map string_of_ast l)) + | StringLeaf s -> Format.sprintf "\"%s\"" s + | IntLeaf i -> Format.sprintf "%d" i + | CharLeaf i -> Format.sprintf "%c" i + | NullLeaf -> "null" diff --git a/src/builtins.ml b/src/builtins.ml new file mode 100644 index 0000000000000000000000000000000000000000..dcb709c4dde6a4a61654fd26e2495e755106e831 --- /dev/null +++ b/src/builtins.ml @@ -0,0 +1,70 @@ +open Batteries +open BatList +open Utils + +let dump_int oc i = + Format.fprintf oc "%d, " i + +let dump_list pp oc l = + List.iter (pp oc) l + +let rec read_chars_rec mem addr (chars_read) = + Mem.read_char mem addr >>= fun (v) -> + if v = 0 then + (OK (rev chars_read)) + else read_chars_rec mem (addr + 1) (v::chars_read) + +let read_string mem addr = + read_chars_rec mem addr ([]) >>= fun (s) -> + let s = s |> List.map char_of_int |> String.of_list in + OK (s) + +let dump_mem oc mem arg = + Format.fprintf oc "Address accessed : %d\n" arg; + List.iter (fun i -> + Mem.read_char mem (arg + i) >>! fun (v) -> + Format.fprintf oc "%d: %c (%d)" (arg + i) (char_of_int v) v; + if (i+1) mod 8 == 0 then Format.fprintf oc "\n" else Format.fprintf oc "\t"; + ) (list_ints_inc 200); + Format.fprintf oc "MEM :-)\n"; OK (None, []) + + +let rec do_builtin oc mem fname vargs = + match fname, vargs with + | "print", arg::_ -> + Format.fprintf oc "%d\n" arg; + OK(None) + | "print_int", arg::_ -> + Format.fprintf oc "%d" arg; + OK(None) + | "print_char", arg::_ -> + Format.fprintf oc "%c" (char_of_int arg); + OK(None) + | "print_string", arg::_ -> + read_string mem arg >>= fun s -> + Format.fprintf oc "%s" s; + OK (None) + | "atoi", arg :: _ -> + read_string mem arg >>= fun (s) -> + begin + let i = try int_of_string s with _ -> -1 in + OK (Some i) + end + | "dump_mem", arg :: _ -> + Format.fprintf oc "Address accessed : %d\n" arg; + List.iter (fun i -> + Mem.read_char mem (arg + i) >>! fun v -> + Format.fprintf oc "%d: %c (%d)" (arg + i) (char_of_int v) v; + if (i+1) mod 8 == 0 then Format.fprintf oc "\n" else Format.fprintf oc "\t"; + ) (list_ints_inc 200); + Format.fprintf oc "MEM :-)\n"; OK (None) + | "__muldi3", arg1 :: arg2 :: _ -> + OK(Some (arg1*arg2)) + | "__udivdi3", arg1 :: arg2 :: _ -> + OK(Some (arg1/arg2)) + | "__umoddi3", arg1 :: arg2 :: _ -> + OK(Some (arg1 mod arg2)) + | "error", _ -> + do_builtin oc mem "print_string" vargs >>= fun _ -> + Error (Format.sprintf "exited") + | _ -> Error (Format.sprintf "Unknown function %s\n" fname) diff --git a/src/cfg.ml b/src/cfg.ml new file mode 100644 index 0000000000000000000000000000000000000000..7c4cb023ce56fa2c68501c5b9369ec311c7996cc --- /dev/null +++ b/src/cfg.ml @@ -0,0 +1,76 @@ +open Elang +open Prog +open Batteries +open BatList + +type expr = + Ebinop of binop * expr * expr + | Eunop of unop * expr + | Eint of int + | Evar of string + +type cfg_node = + | Cassign of string * expr * int + | Creturn of expr + | Cprint of expr * int + | Ccmp of expr * int * int + | Cnop of int + +type cfg_fun = { + cfgfunargs: string list; + cfgfunbody: (int, cfg_node) Hashtbl.t; + cfgentry: int; +} + +type cprog = cfg_fun prog + + +(* [succs cfg n] donne l'ensemble des successeurs d'un nÅ“ud [n] dans un CFG + [cfg]. *) +let succs cfg n = + match Hashtbl.find_option cfg n with + | None -> Set.empty + | Some (Cprint (_, s)) + | Some (Cassign (_, _, s)) -> Set.singleton s + | Some (Creturn _) -> Set.empty + | Some (Ccmp (_, s1, s2)) -> Set.of_list [s1;s2] + | Some (Cnop s) -> Set.singleton s + + +(* [preds cfg n] donne l'ensemble des prédécesseurs d'un nÅ“ud [n] dans un CFG [cfg] + *) +let preds cfgfunbody n = + Hashtbl.fold (fun m m' acc -> + match m' with + | Cassign (_, _, s) + | Cprint (_, s) + | Cnop s -> if s = n then Set.add m acc else acc + | Creturn _ -> acc + | Ccmp (_, s1, s2) -> if s1 = n || s2 = n then Set.add m acc else acc + ) cfgfunbody Set.empty + + +let size_binop _ e1 e2 = + 1 + e1 + e2 + +let size_unop _ e = + 1 + e + +let rec size_expr (e: expr) : int = + match e with + | Ebinop (b, e1, e2) -> size_binop b (size_expr e1) (size_expr e2) + | Eunop (u, e) -> size_unop u (size_expr e) + | Eint _ -> 1 + | Evar _ -> 1 + +let size_instr (i: cfg_node) : int = + match (i : cfg_node) with + | Cassign (_, e, _) -> 1 + size_expr e + | Creturn e -> 1 + (size_expr e) + | Cprint (e, _) -> 1 + (size_expr e) + | Ccmp (e, _, _) -> 1 + size_expr e + | Cnop _ -> 1 + +let size_fun f = + Hashtbl.fold (fun _ v acc -> acc + size_instr v) f 0 + diff --git a/src/cfg_constprop.ml b/src/cfg_constprop.ml new file mode 100644 index 0000000000000000000000000000000000000000..7309a1a170c5fe60a043427be4d9ffc6ab651cb9 --- /dev/null +++ b/src/cfg_constprop.ml @@ -0,0 +1,60 @@ +open Batteries +open Cfg +open Elang_run +open Prog +open Utils +open Report +open Cfg_print +open Options + +(* [simple_eval_eexpr e] evaluates an expression [e] with no variables. Raises + an exception if the expression contains variables. *) +let rec simple_eval_eexpr (e: expr) : int = + 0 + +(* If an expression contains variables, we cannot simply evaluate it. *) + +(* [has_vars e] indicates whether [e] contains variables. *) +let rec has_vars (e: expr) = + true + +let const_prop_binop b e1 e2 = + let e = Ebinop (b, e1, e2) in + if has_vars e + then e + else Eint (simple_eval_eexpr e) + +let const_prop_unop u e = + let e = Eunop (u, e) in + if has_vars e + then e + else Eint (simple_eval_eexpr e) + + +let rec const_prop_expr (e: expr) = + e + +let constant_propagation_instr (i: cfg_node) : cfg_node = + i + +let constant_propagation_fun ({ cfgfunbody; _ } as f: cfg_fun) = + let ht = Hashtbl.map (fun _ m -> + constant_propagation_instr m + ) cfgfunbody in + { f with cfgfunbody = ht} + +let constant_propagation_gdef = function + Gfun f -> + Gfun (constant_propagation_fun f) + +let constant_propagation p = + if !Options.no_cfg_constprop + then p + else assoc_map constant_propagation_gdef p + +let pass_constant_propagation p = + let cfg = constant_propagation p in + record_compile_result "Constprop"; + dump (!cfg_dump >*> fun s -> s ^ "1") dump_cfg_prog cfg + (call_dot "cfg-after-cstprop" "CFG after Constant Propagation"); + OK cfg diff --git a/src/cfg_dead_assign.ml b/src/cfg_dead_assign.ml new file mode 100644 index 0000000000000000000000000000000000000000..e35fc4762eb958bb4ec5ad1be98fbbb409a6e39e --- /dev/null +++ b/src/cfg_dead_assign.ml @@ -0,0 +1,46 @@ +open Batteries +open Cfg +open Prog +open Utils +open Cfg_liveness +open Report +open Cfg_print +open Options + +(* Dead Assign Elimination -- Élimination des affectations mortes *) + +(* [dead_assign_elimination_fun f] élimine les affectations mortes dans la + function [f]. Cette fonction renvoie un couple [(f',c)] oú [f'] est la + nouvelle fonction, et [c] est un booléen qui indique si du progrès a été + fait. *) +let dead_assign_elimination_fun ({ cfgfunbody; _ } as f: cfg_fun) = + let changed = ref false in + let cfgfunbody = + Hashtbl.map (fun (n: int) (m: cfg_node) -> + match m with + (* TODO *) + | _ -> m + ) cfgfunbody in + ({ f with cfgfunbody }, !changed ) + +(* Applique l'élimination de code mort autant de fois que nécessaire. Testez + notamment sur le fichier de test [basic/useless_assigns.e]. *) +let rec iter_dead_assign_elimination_fun f = + let f, c = dead_assign_elimination_fun f in + (* TODO *) + f + +let dead_assign_elimination_gdef = function + Gfun f -> Gfun (iter_dead_assign_elimination_fun f) + +let dead_assign_elimination p = + if !Options.no_cfg_dae + then p + else assoc_map dead_assign_elimination_gdef p + +let pass_dead_assign_elimination cfg = + let cfg = dead_assign_elimination cfg in + record_compile_result "DeadAssign"; + dump (!cfg_dump >*> fun s -> s ^ "2") dump_cfg_prog cfg + (call_dot "cfg-after-dae" "CFG after DAE"); + OK cfg diff --git a/src/cfg_gen.ml b/src/cfg_gen.ml new file mode 100644 index 0000000000000000000000000000000000000000..18509ef62dd1711bdfe41db26dfd56fe3e5676f5 --- /dev/null +++ b/src/cfg_gen.ml @@ -0,0 +1,118 @@ +open Batteries +open Elang +open Cfg +open Utils +open Prog +open Report +open Cfg_print +open Options + +(* [cfg_expr_of_eexpr e] converts an [Elang.expr] into a [expr res]. This should + always succeed and be straightforward. + + In later versions of this compiler, you will add more things to [Elang.expr] + but not to [Cfg.expr], hence the distinction. +*) +let rec cfg_expr_of_eexpr (e: Elang.expr) : expr res = + match e with + | Elang.Ebinop (b, e1, e2) -> + cfg_expr_of_eexpr e1 >>= fun ee1 -> + cfg_expr_of_eexpr e2 >>= fun ee2 -> + OK (Ebinop (b, ee1, ee2)) + | Elang.Eunop (u, e) -> + cfg_expr_of_eexpr e >>= fun ee -> + OK (Eunop (u, ee)) + | Elang.Eint i -> OK (Eint i) + | Elang.Evar v -> + OK (Evar v) + +(* [cfg_node_of_einstr next cfg succ i] builds the CFG node(s) that correspond + to the E instruction [i]. + + [cfg] is the current state of the control-flow graph. + + [succ] is the successor of this node in the CFG, i.e. where to go after this + instruction. + + [next] is the next available CFG node identifier. + + This function returns a pair (n, next) where [n] is the identifer of the + node generated, and [next] is the new next available CFG node identifier. + + Hint: several nodes may be generated for a single E instruction. +*) +let rec cfg_node_of_einstr (next: int) (cfg : (int, cfg_node) Hashtbl.t) + (succ: int) (i: instr) : (int * int) res = + match i with + | Elang.Iassign (v, e) -> + cfg_expr_of_eexpr e >>= fun e -> + Hashtbl.replace cfg next (Cassign(v,e,succ)); + OK (next, next + 1) + | Elang.Iif (c, ithen, ielse) -> + cfg_expr_of_eexpr c >>= fun c -> + cfg_node_of_einstr next cfg succ ithen >>= fun (nthen, next) -> + cfg_node_of_einstr next cfg succ ielse >>= fun (nelse, next) -> + Hashtbl.replace cfg next (Ccmp(c, nthen, nelse)); OK (next, next + 1) + | Elang.Iwhile (c, i) -> + cfg_expr_of_eexpr c >>= fun c -> + let (cmp, next) = (next, next+1) in + cfg_node_of_einstr next cfg cmp i >>= fun (nthen, next) -> + Hashtbl.replace cfg cmp (Ccmp(c, nthen, succ)); OK (cmp, next + 1) + | Elang.Iblock il -> + List.fold_right (fun i acc -> + acc >>= fun (succ, next) -> + cfg_node_of_einstr next cfg succ i + ) il (OK (succ, next)) + | Elang.Ireturn e -> + cfg_expr_of_eexpr e >>= fun e -> + Hashtbl.replace cfg next (Creturn e); OK (next, next + 1) + | Elang.Iprint e -> + cfg_expr_of_eexpr e >>= fun e -> + Hashtbl.replace cfg next (Cprint (e,succ)); + OK (next, next + 1) + +(* Some nodes may be unreachable after the CFG is entirely generated. The + [reachable_nodes n cfg] constructs the set of node identifiers that are + reachable from the entry node [n]. *) +let rec reachable_nodes n (cfg: (int,cfg_node) Hashtbl.t) = + let rec reachable_aux n reach = + if Set.mem n reach then reach + else let reach = Set.add n reach in + match Hashtbl.find_option cfg n with + | None -> reach + | Some (Cnop succ) + | Some (Cprint (_, succ)) + | Some (Cassign (_, _, succ)) -> reachable_aux succ reach + | Some (Creturn _) -> reach + | Some (Ccmp (_, s1, s2)) -> + reachable_aux s1 (reachable_aux s2 reach) + in reachable_aux n Set.empty + +(* [cfg_fun_of_efun f] builds the CFG for E function [f]. *) +let cfg_fun_of_efun { funargs; funbody } = + let cfg = Hashtbl.create 17 in + Hashtbl.replace cfg 0 (Creturn (Eint 0)); + cfg_node_of_einstr 1 cfg 0 funbody >>= fun (node, _) -> + (* remove unreachable nodes *) + let r = reachable_nodes node cfg in + Hashtbl.filteri_inplace (fun k _ -> Set.mem k r) cfg; + OK { cfgfunargs = funargs; + cfgfunbody = cfg; + cfgentry = node; + } + +let cfg_gdef_of_edef gd = + match gd with + Gfun f -> cfg_fun_of_efun f >>= fun f -> OK (Gfun f) + +let cfg_prog_of_eprog (ep: eprog) : cfg_fun prog res = + assoc_map_res (fun _ -> cfg_gdef_of_edef) ep + +let pass_cfg_gen ep = + match cfg_prog_of_eprog ep with + | Error msg -> + record_compile_result ~error:(Some msg) "CFG"; Error msg + | OK cfg -> + record_compile_result "CFG"; + dump !cfg_dump dump_cfg_prog cfg (call_dot "cfg" "CFG"); + OK cfg diff --git a/src/cfg_liveness.ml b/src/cfg_liveness.ml new file mode 100644 index 0000000000000000000000000000000000000000..194a291e76ca270951a3b881023f504b3355174e --- /dev/null +++ b/src/cfg_liveness.ml @@ -0,0 +1,42 @@ +open Batteries +open Cfg + +(* Analyse de vivacité *) + +(* [vars_in_expr e] renvoie l'ensemble des variables qui apparaissent dans [e]. *) +let rec vars_in_expr (e: expr) = + (* TODO *) + Set.empty + +(* [live_after_node cfg n] renvoie l'ensemble des variables vivantes après le + nÅ“ud [n] dans un CFG [cfg]. [lives] est l'état courant de l'analyse, + c'est-à -dire une table dont les clés sont des identifiants de nÅ“uds du CFG et + les valeurs sont les ensembles de variables vivantes avant chaque nÅ“ud. *) +let live_after_node cfg n (lives: (int, string Set.t) Hashtbl.t) : string Set.t = + (* TODO *) + Set.empty + +(* [live_cfg_node node live_after] renvoie l'ensemble des variables vivantes + avant un nÅ“ud [node], étant donné l'ensemble [live_after] des variables + vivantes après ce nÅ“ud. *) +let live_cfg_node (node: cfg_node) (live_after: string Set.t) = + (* TODO *) + live_after + +(* [live_cfg_nodes cfg lives] effectue une itération du calcul de point fixe. + + Cette fonction met à jour l'état de l'analyse [lives] et renvoie un booléen + qui indique si le calcul a progressé durant cette itération (i.e. s'il existe + au moins un nÅ“ud n pour lequel l'ensemble des variables vivantes avant ce + nÅ“ud a changé). *) +let live_cfg_nodes cfg (lives : (int, string Set.t) Hashtbl.t) = + (* TODO *) + false + +(* [live_cfg_fun f] calcule l'ensemble des variables vivantes avant chaque nÅ“ud + du CFG en itérant [live_cfg_nodes] jusqu'à ce qu'un point fixe soit atteint. + *) +let live_cfg_fun (f: cfg_fun) : (int, string Set.t) Hashtbl.t = + let lives = Hashtbl.create 17 in + (* TODO *) + lives diff --git a/src/cfg_nop_elim.ml b/src/cfg_nop_elim.ml new file mode 100644 index 0000000000000000000000000000000000000000..da45a5a8656f295bd0f6dc9cdab2d9101d5554d0 --- /dev/null +++ b/src/cfg_nop_elim.ml @@ -0,0 +1,92 @@ +open BatList +open Batteries +open Prog +open Utils +open Cfg +open Report +open Cfg_print +open Options + +(* Élimination des NOPs. *) + +(* [nop_transitions cfg] donne la liste des transitions NOP dans un CFG. + + Si le nÅ“ud [n] contient [Cnop s], alors [(n,s)] devrait être dans le résultat. +*) +let nop_transitions (cfgfunbody: (int, cfg_node) Hashtbl.t) : (int * int) list = + (* TODO *) + [] + + +(* [follow n l visited] donne le premier successeur à partir de [n] qui ne soit + pas un NOP. Pour connaître le successeur d'un nÅ“ud NOP, on utilisara la liste + [l] telle que produite précédemment. Pour rappel [(x,y)] dans [l] signifie + qu'il y a un transition depuis un nÅ“ud [x] qui contient une instruction [Cnop + y]. + + L'ensemble [visited] est utilisé pour éviter les boucles. + *) +let rec follow (n: int) (l: (int * int) list) (visited: int Set.t) : int = + (* TODO *) + n + +(* [nop_transitions_closed] contient la liste [(n,s)] telle que l'instruction au + nÅ“ud [n] est le début d'une chaîne de NOPs qui termine au nÅ“ud [s]. Les + enseignants du cours de compiilation sont heureux de vous offrir cette + fonction. *) +let nop_transitions_closed cfgfunbody = + List.map (fun (node_id, node) -> + (node_id, follow node_id (nop_transitions cfgfunbody) Set.empty)) + (nop_transitions cfgfunbody) + +(* Nous allons maintenant réécrire notre programme pour remplacer les + successeurs [s] de chaque nÅ“ud du CFG de la manière suivante : si [s] est le + début d'une chaîne de NOPs, on remplace [s] par la fin de cette chaîne, en + éliminant ainsi les nÅ“uds NOPs. *) + +(* [replace_succ nop_succs s] donne le nouveau nom du nÅ“ud [s], en utilisant la + liste [nop_succs] (telle que renvoyée par [nop_transitions_closed]). *) +let replace_succ nop_succs s = + (* TODO *) + s + +(* [replace_succs nop_succs n] remplace le nÅ“ud [n] par un nÅ“ud équivalent où on + a remplacé les successeurs, en utilisant la liste [nop_succs]. *) +let replace_succs nop_succs (n: cfg_node) = + (* TODO *) + n + +(* [nop_elim_fun f] applique la fonction [replace_succs] à chaque nÅ“ud du CFG. *) +let nop_elim_fun ({ cfgfunargs; cfgfunbody; cfgentry } as f: cfg_fun) = + let nop_transf = nop_transitions_closed cfgfunbody in + (* On utilise la fonction [Hashtbl.filter_map f h] qui permet d'appliquer une + fonction à chaque nÅ“ud de [h] et d'éliminer ceux pour lesquels [f] renvoie + [None]. + + On souhaite éliminer les nÅ“uds qui n'ont pas de prédécesseurs + (inaccessibles), et appliquer la fonction [replace_succs] aux nÅ“uds qui + resteront. + *) + let cfgfunbody = Hashtbl.filter_map (fun n node -> + (* TODO *) + Some node + ) cfgfunbody in + (* La fonction renvoyée est composée du nouveau [cfgfunbody] que l'on vient de + calculer, et le point d'entrée est transformé en conséquence. *) + {f with cfgfunbody; cfgentry = replace_succ nop_transf cfgentry } + +let nop_elim_gdef gd = + match gd with + Gfun f -> Gfun (nop_elim_fun f) + +let nop_elimination cp = + if !Options.no_cfg_ne + then cp + else assoc_map nop_elim_gdef cp + +let pass_nop_elimination cfg = + let cfg = nop_elimination cfg in + record_compile_result "NopElim"; + dump (!cfg_dump >*> fun s -> s ^ "3") dump_cfg_prog cfg + (call_dot "cfg-after-nop" "CFG after NOP elim"); + OK cfg diff --git a/src/cfg_print.ml b/src/cfg_print.ml new file mode 100644 index 0000000000000000000000000000000000000000..6ec810a6254e741900bea58fd5954da1e5f8062a --- /dev/null +++ b/src/cfg_print.ml @@ -0,0 +1,58 @@ +open Batteries +open Cfg +open Elang_print +open Prog + +let rec dump_cfgexpr : expr -> string = function + | Ebinop(b, e1, e2) -> Format.sprintf "(%s %s %s)" (dump_cfgexpr e1) (dump_binop b) (dump_cfgexpr e2) + | Eunop(u, e) -> Format.sprintf "(%s %s)" (dump_unop u) (dump_cfgexpr e) + | Eint i -> Format.sprintf "%d" i + | Evar s -> Format.sprintf "%s" s + +let dump_list_cfgexpr l = + l |> List.map dump_cfgexpr |> String.concat ", " + + +let dump_arrows oc fname n (node: cfg_node) = + match node with + | Cassign (_, _, succ) + | Cprint (_, succ) + | Cnop succ -> + Format.fprintf oc "n_%s_%d -> n_%s_%d\n" fname n fname succ + | Creturn _ -> () + | Ccmp (_, succ1, succ2) -> + Format.fprintf oc "n_%s_%d -> n_%s_%d [label=\"then\"]\n" fname n fname succ1; + Format.fprintf oc "n_%s_%d -> n_%s_%d [label=\"else\"]\n" fname n fname succ2 + + +let dump_cfg_node oc (node: cfg_node) = + match node with + | Cassign (v, e, _) -> Format.fprintf oc "%s = %s" v (dump_cfgexpr e) + | Cprint (e, _) -> Format.fprintf oc "print %s" (dump_cfgexpr e) + | Creturn e -> Format.fprintf oc "return %s" (dump_cfgexpr e) + | Ccmp (e, _, _) -> Format.fprintf oc "%s" (dump_cfgexpr e) + | Cnop _ -> Format.fprintf oc "nop" + + +let dump_liveness_state oc ht state = + Hashtbl.iter (fun n cn -> + Format.fprintf oc "%a : " dump_cfg_node cn; + let vs = Hashtbl.find_default state n Set.empty in + Set.iter (fun v ->Format.fprintf oc "%s, " v) vs; + Format.fprintf oc "\n"; + flush_all () + ) ht + +let dump_cfg_fun oc cfgfunname ({ cfgfunbody; cfgentry; _ }: cfg_fun) = + Format.fprintf oc "subgraph cluster_%s {\n label=\"%s\";\n" cfgfunname cfgfunname; + Hashtbl.iter (fun n node -> + Format.fprintf oc "n_%s_%d [label=\"%a\" xlabel=\"%d\" shape=%s];\n" cfgfunname n dump_cfg_node node n (if n = cfgentry then "rectangle peripheries=2" else "rectangle"); + dump_arrows oc cfgfunname n node + ) cfgfunbody; + Format.fprintf oc "}\n" + +let dump_cfg_prog oc (cp: cprog) = + Format.fprintf oc "digraph G{\n"; + dump_prog dump_cfg_fun oc cp; + Format.fprintf oc "\n}" + diff --git a/src/cfg_run.ml b/src/cfg_run.ml new file mode 100644 index 0000000000000000000000000000000000000000..6557acdb2f0ad6996e7b33f2a469536df24118c8 --- /dev/null +++ b/src/cfg_run.ml @@ -0,0 +1,70 @@ +open Prog +open Elang +open Elang_run +open Batteries +open BatList +open Cfg +open Utils +open Builtins + +let rec eval_cfgexpr st (e: expr) : int res = + match e with + | Ebinop(b, e1, e2) -> + eval_cfgexpr st e1 >>= fun v1 -> + eval_cfgexpr st e2 >>= fun v2 -> + let v = eval_binop b v1 v2 in + OK v + | Eunop(u, e) -> + eval_cfgexpr st e >>= fun v1 -> + let v = (eval_unop u v1) in + OK v + | Eint i -> OK i + | Evar s -> + begin match Hashtbl.find_option st.env s with + | Some v -> OK v + | None -> Error (Printf.sprintf "Unknown variable %s\n" s) + end + +let rec eval_cfginstr oc st ht (n: int): (int * int state) res = + match Hashtbl.find_option ht n with + | None -> Error (Printf.sprintf "Invalid node identifier\n") + | Some node -> + match node with + | Cnop succ -> + eval_cfginstr oc st ht succ + | Cassign(v, e, succ) -> + eval_cfgexpr st e >>= fun i -> + Hashtbl.replace st.env v i; + eval_cfginstr oc st ht succ + | Ccmp(cond, i1, i2) -> + eval_cfgexpr st cond >>= fun i -> + if i = 0 then eval_cfginstr oc st ht i2 else eval_cfginstr oc st ht i1 + | Creturn(e) -> + eval_cfgexpr st e >>= fun e -> + OK (e, st) + | Cprint(e, succ) -> + eval_cfgexpr st e >>= fun e -> + Format.fprintf oc "%d\n" e; + eval_cfginstr oc st ht succ + +let eval_cfgfun oc st cfgfunname { cfgfunargs; + cfgfunbody; + cfgentry} vargs = + let st' = { st with env = Hashtbl.create 17 } in + match List.iter2 (fun a v -> Hashtbl.replace st'.env a v) cfgfunargs vargs with + | () -> eval_cfginstr oc st' cfgfunbody cfgentry >>= fun (v, st') -> + OK (Some v, {st' with env = st.env}) + | exception Invalid_argument _ -> + Error (Format.sprintf "CFG: Called function %s with %d arguments, expected %d.\n" + cfgfunname (List.length vargs) (List.length cfgfunargs) + ) + +let eval_cfgprog oc cp memsize params = + let st = init_state memsize in + find_function cp "main" >>= fun f -> + let n = List.length f.cfgfunargs in + let params = take n params in + eval_cfgfun oc st "main" f params >>= fun (v, st) -> + OK v + + diff --git a/src/dune b/src/dune new file mode 100644 index 0000000000000000000000000000000000000000..cf85350de0f4d92b71fcff9ae2f45883249ab870 --- /dev/null +++ b/src/dune @@ -0,0 +1,19 @@ +(menhir + (modules yaccparser) + (flags (--unused-tokens)) + ; unused-tokens +) +(ocamllex lexer) + +(executables + (names main test_lexer) + (libraries + batteries + yojson + lwt + websocket + websocket-lwt-unix + menhirLib + ) + (flags (:standard -warn-error -A -w -27 -w -33 -w -9 -w -39)) +) diff --git a/src/dune-project b/src/dune-project new file mode 100644 index 0000000000000000000000000000000000000000..192d77fdc7853a217a9338cf6209a8cdf00597c5 --- /dev/null +++ b/src/dune-project @@ -0,0 +1,2 @@ +(lang dune 2.9) +(using menhir 2.1) diff --git a/src/e_regexp.ml b/src/e_regexp.ml new file mode 100644 index 0000000000000000000000000000000000000000..bbc5b204ba11e4fcba87a032c342ff699b2719e6 --- /dev/null +++ b/src/e_regexp.ml @@ -0,0 +1,148 @@ +open Batteries +open Symbols +open Utils +(* Expressions régulières *) + +(* Nous modélisons les expressions régulières avec le type suivant. + + Une expressions régulière est soit : + - [Eps] qui dénote l'expressions vide. + - [Charset cs] dénote l'expression régulière qui matche l'ensemble + des caractères de l'ensemble [cs]. + - [Cat(r1,r2)] dénote la concaténation de [r1] et [r2] : reconnaît les mots + [uv] tels que [u] appartient à [r1] et [v] appartient à [r2]. + - [Alt(r1,r2)] dénote un choix entre [r1] et [r2] : reconnaît les mots reconnus + par [r1] et les mots reconnus par [r2]. + - [Star r] dénote la répétition 0, 1 ou plusieurs fois de l'expression [r]. +*) + +type 'a set = 'a Set.t + +type regexp = + | Eps + | Charset of char set + | Cat of regexp * regexp + | Alt of regexp * regexp + | Star of regexp + +(* [char_regexp c] reconnaît le caractère [c] uniquement. *) +let char_regexp c = Charset (Set.singleton c) + +(* [char_range l] reconnaît l'ensemble des caractères de [l]. *) +let char_range (l: char list) = + Charset (Set.of_list l) + +(* [str_regexp s] reconnaît la chaîne de caractère [s]. *) +let str_regexp (s: char list) = + List.fold_right (fun c reg -> Cat(Charset (Set.singleton c), reg)) s Eps + +(* [plus r] reconnaît 1 fois ou plus l'expression [r]. *) +let plus r = Cat(r,Star r) + +(* Fonction d'affichage. Peut être utile pour déboguer. *) +let rec string_of_regexp r = + match r with + Eps -> "Eps" + | Charset c -> Printf.sprintf "[%s]" (string_of_char_list (Set.to_list c)) + | Alt (r1,r2) -> Printf.sprintf "(%s)|(%s)" + (string_of_regexp r1) (string_of_regexp r2) + | Cat (r1,r2) -> Printf.sprintf "(%s).(%s)" + (string_of_regexp r1) (string_of_regexp r2) + | Star r -> Printf.sprintf "(%s)*" (string_of_regexp r) + + +let lowercase_letters = "abcdefghijklmnopqrstuvwxyz" +let uppercase_letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +let digits = "0123456789" +let other_characters = "?!=<>_ :;,{}()[]^`-+*/%@\n\t\x00.\"\'\\|~#$&" + +(* L'opérateur ^ dénote la concaténation des chaînes de caractères. *) +let alphabet = char_list_of_string (lowercase_letters ^ uppercase_letters ^ digits ^ other_characters) +let letter_regexp = char_range (char_list_of_string (uppercase_letters ^ lowercase_letters)) +let digit_regexp = char_range (char_list_of_string digits) +let identifier_material = char_range (char_list_of_string (uppercase_letters ^ lowercase_letters ^ digits ^ "_")) +let keyword_regexp s = str_regexp (char_list_of_string s) + +(* La liste des expressions régulières permettant d'identifier les tokens du langage E *) +let list_regexp : (regexp * (string -> token option)) list = + [ + (keyword_regexp "while", fun _ -> Some (SYM_WHILE)); + (keyword_regexp "int", fun _ -> Some (SYM_INT)); + (* begin TODO *) + (Eps, fun _ -> Some (SYM_VOID)); + (Eps, fun _ -> Some (SYM_CHAR)); + (Eps, fun _ -> Some (SYM_IF)); + (Eps, fun _ -> Some (SYM_ELSE)); + (Eps, fun _ -> Some (SYM_RETURN)); + (Eps, fun _ -> Some (SYM_PRINT)); + (Eps, fun _ -> Some (SYM_STRUCT)); + (Eps, fun _ -> Some (SYM_POINT)); + (Eps, fun _ -> Some (SYM_PLUS)); + (Eps, fun _ -> Some (SYM_MINUS)); + (Eps, fun _ -> Some (SYM_ASTERISK)); + (Eps, fun _ -> Some (SYM_DIV)); + (Eps, fun _ -> Some (SYM_MOD)); + (Eps, fun _ -> Some (SYM_LBRACE)); + (Eps, fun _ -> Some (SYM_RBRACE)); + (Eps, fun _ -> Some (SYM_LBRACKET)); + (Eps, fun _ -> Some (SYM_RBRACKET)); + (Eps, fun _ -> Some (SYM_LPARENTHESIS)); + (Eps, fun _ -> Some (SYM_RPARENTHESIS)); + (Eps, fun _ -> Some (SYM_SEMICOLON)); + (Eps, fun _ -> Some (SYM_COMMA)); + (Eps, fun _ -> Some (SYM_ASSIGN)); + (Eps, fun _ -> Some (SYM_EQUALITY)); + (Eps, fun _ -> Some (SYM_NOTEQ)); + (Eps, fun _ -> Some (SYM_LT)); + (Eps, fun _ -> Some (SYM_GT)); + (Eps, fun _ -> Some (SYM_LEQ)); + (Eps, fun _ -> Some (SYM_GEQ)); + (Eps, fun s -> Some (SYM_IDENTIFIER s)); + (* end TODO *) + (Cat(keyword_regexp "//", + Cat(Star (char_range (List.filter (fun c -> c <> '\n') alphabet)), + Alt (char_regexp '\n', Eps))), + fun _ -> None); + (Cat(keyword_regexp "/*", + Cat( + Cat (Star (Alt ( + char_range (List.filter (fun c -> c <> '*') alphabet), + Cat (Star(char_regexp '*'), + plus(char_range (List.filter (fun c -> c <> '/' && c <> '*') alphabet))) + )), Star (char_range ['*'])), + keyword_regexp "*/")), + fun _ -> None); + (Cat (char_regexp '\'', + Cat (char_range (List.filter (fun c -> c <> '\'' && c <> '\\') alphabet), + char_regexp '\'')), + fun s -> + match String.get s 1 with + | a -> Some (SYM_CHARACTER a) + | exception Invalid_argument _ -> Some (SYM_CHARACTER 'a') + ); + (Cat (char_regexp '\'', Cat (char_regexp '\\', + Cat (char_range (char_list_of_string "\\tn0'"), + char_regexp '\''))), + fun s -> match String.get s 2 with + | '\\' -> Some (SYM_CHARACTER '\\') + | 'n' -> Some (SYM_CHARACTER '\n') + | 't' -> Some (SYM_CHARACTER '\t') + | '\'' -> Some (SYM_CHARACTER '\'') + | '0' -> Some (SYM_CHARACTER 'a') + | _ -> None + | exception _ -> Some (SYM_CHARACTER 'a') + ); + (Cat (char_regexp '"', + Cat (Star ( + Alt ( + char_range (List.filter (fun c -> c <> '"' && c <> '\\') alphabet), + Cat (char_regexp '\\', char_range (char_list_of_string "tn0\\\"")) + ) + ), + char_regexp '"')), + fun s -> Some (SYM_STRING (Stdlib.Scanf.unescaped (String.slice ~first:1 ~last:(-1) s)))); + (char_range (char_list_of_string " \t\n"), fun _ -> None); + (plus digit_regexp, fun s -> Some (SYM_INTEGER (int_of_string s))); + (Eps, fun _ -> Some (SYM_EOF)) + ] + diff --git a/src/elang.ml b/src/elang.ml new file mode 100644 index 0000000000000000000000000000000000000000..72b8e18b5c4a94b0226063a502ed274af1822d59 --- /dev/null +++ b/src/elang.ml @@ -0,0 +1,26 @@ +open Prog + +type binop = Eadd | Emul | Emod | Exor | Ediv | Esub (* binary operations *) + | Eclt | Ecle | Ecgt | Ecge | Eceq | Ecne (* comparisons *) +type unop = Eneg + +type expr = + Ebinop of binop * expr * expr + | Eunop of unop * expr + | Eint of int + | Evar of string + +type instr = + | Iassign of string * expr + | Iif of expr * instr * instr + | Iwhile of expr * instr + | Iblock of instr list + | Ireturn of expr + | Iprint of expr + +type efun = { + funargs: ( string ) list; + funbody: instr; +} + +type eprog = efun prog diff --git a/src/elang_gen.ml b/src/elang_gen.ml new file mode 100644 index 0000000000000000000000000000000000000000..be904b1e67d18e2c0f25d8896b1610cc1dbe287e --- /dev/null +++ b/src/elang_gen.ml @@ -0,0 +1,103 @@ +open Ast +open Elang +open Prog +open Report +open Options +open Batteries +open Elang_print +open Utils + +let tag_is_binop = + function + Tadd -> true + | Tsub -> true + | Tmul -> true + | Tdiv -> true + | Tmod -> true + | Txor -> true + | Tcle -> true + | Tclt -> true + | Tcge -> true + | Tcgt -> true + | Tceq -> true + | Tne -> true + | _ -> false + +let binop_of_tag = + function + Tadd -> Eadd + | Tsub -> Esub + | Tmul -> Emul + | Tdiv -> Ediv + | Tmod -> Emod + | Txor -> Exor + | Tcle -> Ecle + | Tclt -> Eclt + | Tcge -> Ecge + | Tcgt -> Ecgt + | Tceq -> Eceq + | Tne -> Ecne + | _ -> assert false + +(* [make_eexpr_of_ast a] builds an expression corresponding to a tree [a]. If + the tree is not well-formed, fails with an [Error] message. *) +let rec make_eexpr_of_ast (a: tree) : expr res = + let res = + match a with + | Node(t, [e1; e2]) when tag_is_binop t -> + Error (Printf.sprintf "Unacceptable ast in make_eexpr_of_ast %s" + (string_of_ast a)) + | _ -> Error (Printf.sprintf "Unacceptable ast in make_eexpr_of_ast %s" + (string_of_ast a)) + in + match res with + OK o -> res + | Error msg -> Error (Format.sprintf "In make_eexpr_of_ast %s:\n%s" + (string_of_ast a) msg) + +let rec make_einstr_of_ast (a: tree) : instr res = + let res = + match a with + (* TODO *) + | _ -> Error (Printf.sprintf "Unacceptable ast in make_einstr_of_ast %s" + (string_of_ast a)) + in + match res with + OK o -> res + | Error msg -> Error (Format.sprintf "In make_einstr_of_ast %s:\n%s" + (string_of_ast a) msg) + +let make_ident (a: tree) : string res = + match a with + | Node (Targ, [s]) -> + OK (string_of_stringleaf s) + | a -> Error (Printf.sprintf "make_ident: unexpected AST: %s" + (string_of_ast a)) + +let make_fundef_of_ast (a: tree) : (string * efun) res = + match a with + | Node (Tfundef, [StringLeaf fname; Node (Tfunargs, fargs); fbody]) -> + list_map_res make_ident fargs >>= fun fargs -> + (* TODO *) + Error "make_fundef_of_ast: Not implemented, yet." + | _ -> + Error (Printf.sprintf "make_fundef_of_ast: Expected a Tfundef, got %s." + (string_of_ast a)) + +let make_eprog_of_ast (a: tree) : eprog res = + match a with + | Node (Tlistglobdef, l) -> + list_map_res (fun a -> make_fundef_of_ast a >>= fun (fname, efun) -> OK (fname, Gfun efun)) l + | _ -> + Error (Printf.sprintf "make_fundef_of_ast: Expected a Tlistglobdef, got %s." + (string_of_ast a)) + +let pass_elang ast = + match make_eprog_of_ast ast with + | Error msg -> + record_compile_result ~error:(Some msg) "Elang"; + Error msg + | OK ep -> + dump !e_dump dump_e ep (fun file () -> + add_to_report "e" "E" (Code (file_contents file))); OK ep + diff --git a/src/elang_print.ml b/src/elang_print.ml new file mode 100644 index 0000000000000000000000000000000000000000..2da36d9e99f479b155b024d2cb9aefd56247c39e --- /dev/null +++ b/src/elang_print.ml @@ -0,0 +1,74 @@ +open Batteries +open Elang +open Prog +open Utils + + +let dump_binop = function + | Eadd -> Printf.sprintf "+" + | Esub -> Printf.sprintf "-" + | Emul -> Printf.sprintf "*" + | Ediv -> Printf.sprintf "/" + | Emod -> Printf.sprintf "%%" + | Exor -> Printf.sprintf "^" + | Eclt -> Printf.sprintf "<" + | Ecle -> Printf.sprintf "<=" + | Ecgt -> Printf.sprintf ">" + | Ecge -> Printf.sprintf ">=" + | Eceq -> Printf.sprintf "==" + | Ecne -> Printf.sprintf "!=" + +let dump_unop = function + | Eneg -> Printf.sprintf "-" + +let rec dump_eexpr = function + | Ebinop(b, e1, e2) -> Printf.sprintf "(%s %s %s)" (dump_eexpr e1) (dump_binop b) (dump_eexpr e2) + | Eunop(u, e) -> Printf.sprintf "(%s %s)" (dump_unop u) (dump_eexpr e) + | Eint i -> Printf.sprintf "%d" i + | Evar s -> Printf.sprintf "%s" s + +let indent_size = 2 +let spaces n = + range (indent_size*n) |> List.map (fun _ -> ' ') |> String.of_list + +let print_spaces oc n = + Format.fprintf oc "%s" (spaces n) + +let rec dump_einstr_rec indent oc i = + match i with + | Iassign(v, e) -> + print_spaces oc indent; + Format.fprintf oc "%s = %s;\n" v (dump_eexpr e) + | Iif(cond, i1, i2) -> + print_spaces oc indent; + Format.fprintf oc "if (%s) %a else %a\n" + (dump_eexpr cond) (dump_einstr_rec (indent)) i1 (dump_einstr_rec (indent)) i2 + | Iwhile(cond, i) -> + print_spaces oc indent; + Format.fprintf oc "while (%s) %a\n" + (dump_eexpr cond) (dump_einstr_rec (indent)) i + | Iblock(il) -> + Format.fprintf oc "{\n"; + List.iter (Format.fprintf oc "%a" (dump_einstr_rec (indent + 1))) il; + print_spaces oc indent; + Format.fprintf oc "}"; + | Ireturn(e) -> + print_spaces oc indent; + Format.fprintf oc "return %s;\n" (dump_eexpr e) + | Iprint(e) -> + print_spaces oc indent; + Format.fprintf oc "print %s;\n" (dump_eexpr e) + +let dump_einstr oc i = dump_einstr_rec 0 oc i + + +let dump_efun oc funname {funargs; funbody} = + Format.fprintf oc "%s(%s) {\n%a\n}\n" + funname + (String.concat "," funargs) + dump_einstr funbody + +let dump_eprog oc = dump_prog dump_efun oc + +let dump_e oc p = + dump_eprog oc p diff --git a/src/elang_run.ml b/src/elang_run.ml new file mode 100644 index 0000000000000000000000000000000000000000..494b2c6ac0da84d327a4e1016b7da8f57b3ae57e --- /dev/null +++ b/src/elang_run.ml @@ -0,0 +1,89 @@ +open Elang +open Batteries +open Prog +open Utils + +let binop_bool_to_int f x y = if f x y then 1 else 0 + +(* [eval_binop b x y] évalue l'opération binaire [b] sur les arguments [x] + et [y]. *) +let eval_binop (b: binop) : int -> int -> int = + match b with + | _ -> fun x y -> 0 + +(* [eval_unop u x] évalue l'opération unaire [u] sur l'argument [x]. *) +let eval_unop (u: unop) : int -> int = + match u with + | _ -> fun x -> 0 + +(* [eval_eexpr st e] évalue l'expression [e] dans l'état [st]. Renvoie une + erreur si besoin. *) +let rec eval_eexpr st (e : expr) : int res = + Error "eval_eexpr not implemented yet." + +(* [eval_einstr oc st ins] évalue l'instrution [ins] en partant de l'état [st]. + + Le paramètre [oc] est un "output channel", dans lequel la fonction "print" + écrit sa sortie, au moyen de l'instruction [Format.fprintf]. + + Cette fonction renvoie [(ret, st')] : + + - [ret] est de type [int option]. [Some v] doit être renvoyé lorsqu'une + instruction [return] est évaluée. [None] signifie qu'aucun [return] n'a eu + lieu et que l'exécution doit continuer. + + - [st'] est l'état mis à jour. *) +let rec eval_einstr oc (st: int state) (ins: instr) : + (int option * int state) res = + Error "eval_einstr not implemented yet." + +(* [eval_efun oc st f fname vargs] évalue la fonction [f] (dont le nom est + [fname]) en partant de l'état [st], avec les arguments [vargs]. + + Cette fonction renvoie un couple (ret, st') avec la même signification que + pour [eval_einstr]. *) +let eval_efun oc (st: int state) ({ funargs; funbody}: efun) + (fname: string) (vargs: int list) + : (int option * int state) res = + (* L'environnement d'une fonction (mapping des variables locales vers leurs + valeurs) est local et un appel de fonction ne devrait pas modifier les + variables de l'appelant. Donc, on sauvegarde l'environnement de l'appelant + dans [env_save], on appelle la fonction dans un environnement propre (Avec + seulement ses arguments), puis on restore l'environnement de l'appelant. *) + let env_save = Hashtbl.copy st.env in + let env = Hashtbl.create 17 in + match List.iter2 (fun a v -> Hashtbl.replace env a v) funargs vargs with + | () -> + eval_einstr oc { st with env } funbody >>= fun (v, st') -> + OK (v, { st' with env = env_save }) + | exception Invalid_argument _ -> + Error (Format.sprintf + "E: Called function %s with %d arguments, expected %d.\n" + fname (List.length vargs) (List.length funargs) + ) + +(* [eval_eprog oc ep memsize params] évalue un programme complet [ep], avec les + arguments [params]. + + Le paramètre [memsize] donne la taille de la mémoire dont ce programme va + disposer. Ce n'est pas utile tout de suite (nos programmes n'utilisent pas de + mémoire), mais ça le sera lorsqu'on ajoutera de l'allocation dynamique dans + nos programmes. + + Renvoie: + + - [OK (Some v)] lorsque l'évaluation de la fonction a lieu sans problèmes et renvoie une valeur [v]. + + - [OK None] lorsque l'évaluation de la fonction termine sans renvoyer de valeur. + + - [Error msg] lorsqu'une erreur survient. + *) +let eval_eprog oc (ep: eprog) (memsize: int) (params: int list) + : int option res = + let st = init_state memsize in + find_function ep "main" >>= fun f -> + (* ne garde que le nombre nécessaire de paramètres pour la fonction "main". *) + let n = List.length f.funargs in + let params = take n params in + eval_efun oc st f "main" params >>= fun (v, _) -> + OK v diff --git a/src/lexer.mll b/src/lexer.mll new file mode 100644 index 0000000000000000000000000000000000000000..9aa999daef2ff056c38dcc9864da6727fc7baec6 --- /dev/null +++ b/src/lexer.mll @@ -0,0 +1,96 @@ +{ +open Symbols +exception SyntaxError of string +exception Eof +} + + +let digit = ['0'-'9'] +let letter = ['a'-'z' 'A'-'Z'] +let id = letter (digit|letter|'_')* + +rule token = parse + | [' ' '\t' '\r'] { token lexbuf } + | '\n' { Lexing.new_line lexbuf; token lexbuf } + | ("0x" ['0'-'9''a'-'f''A'-'F']+) as i { SYM_INTEGER (int_of_string i) } + | ['0'-'9']+ as i { SYM_INTEGER (int_of_string i) } + | '+' { SYM_PLUS } + | "->" { SYM_ARROW } + | "&&" { SYM_BOOL_AND } + | "||" { SYM_BOOL_OR } + | "!" { SYM_BOOL_NOT } + | '&' { SYM_BITWISE_AND } + | '~' { SYM_BIT_NOT } + | '-' { SYM_MINUS } + | '*' { SYM_ASTERISK } + | "//" { single_line_comment lexbuf } + | "/*" { multi_line_comment lexbuf } + | '/' { SYM_DIV } + | '.' { SYM_POINT } + | "void" { SYM_VOID } + | "char" { SYM_CHAR } + | "int" { SYM_INT } + | "print" { SYM_PRINT } + | "struct" { SYM_STRUCT } + | "if" { SYM_IF } + | "else" { SYM_ELSE } + | "alloc" { SYM_ALLOC } + | "==" { SYM_EQUALITY } + | "=" { SYM_ASSIGN } + | "while" { SYM_WHILE } + | "return" { SYM_RETURN } + | id as s { SYM_IDENTIFIER s} + | '{' { SYM_LBRACE } + | '}' { SYM_RBRACE } + | '(' { SYM_LPARENTHESIS } + | ')' { SYM_RPARENTHESIS } + | '[' { SYM_LBRACKET } + | ']' { SYM_RBRACKET } + | ';' { SYM_SEMICOLON } + | ',' { SYM_COMMA } + | ">=" { SYM_GEQ } + | "<=" { SYM_LEQ } + | '>' { SYM_GT } + | '<' { SYM_LT } + | "!=" { SYM_NOTEQ } + | '^' { SYM_XOR } + | '%' { SYM_MOD } + | '\'' { parse_char lexbuf } + | '"' { read_string (Buffer.create 17) lexbuf } + | eof { SYM_EOF } + | _ as x { failwith (Printf.sprintf "unexpected char '%c' at %s \n" x (string_of_position (Lexing.lexeme_start_p lexbuf)))} + + +and parse_char = parse + | "\\n'" { SYM_CHARACTER '\n' } + | "\\0'" { SYM_CHARACTER (char_of_int 0) } + | "\\r'" { SYM_CHARACTER '\r' } + | "\\t'" { SYM_CHARACTER '\t' } + | _ as c '\'' { SYM_CHARACTER c} + | _ as x { failwith (Printf.sprintf "unexpected char literal '%c'\n" x) } + +and read_string buf = + parse + | '"' { SYM_STRING (Buffer.contents buf) } + | '\\' '/' { Buffer.add_char buf '/'; read_string buf lexbuf } + | '\\' '\\' { Buffer.add_char buf '\\'; read_string buf lexbuf } + | '\\' 'b' { Buffer.add_char buf '\b'; read_string buf lexbuf } + | '\\' 'f' { Buffer.add_char buf '\012'; read_string buf lexbuf } + | '\\' 'n' { Buffer.add_char buf '\n'; read_string buf lexbuf } + | '\\' 'r' { Buffer.add_char buf '\r'; read_string buf lexbuf } + | '\\' 't' { Buffer.add_char buf '\t'; read_string buf lexbuf } + | [^ '"' '\\']+ + { Buffer.add_string buf (Lexing.lexeme lexbuf); + read_string buf lexbuf + } + | _ { raise (SyntaxError ("Illegal string character: " ^ Lexing.lexeme lexbuf)) } + | eof { raise (SyntaxError ("String is not terminated")) } + +and single_line_comment = parse + | ['\n' '\r'] { Lexing.new_line lexbuf; token lexbuf } + | _ { single_line_comment lexbuf } + +and multi_line_comment = parse + | "*/" { token lexbuf } + | '\n' { Lexing.new_line lexbuf; multi_line_comment lexbuf } + | _ {multi_line_comment lexbuf} diff --git a/src/lexer_generator.ml b/src/lexer_generator.ml new file mode 100644 index 0000000000000000000000000000000000000000..06192ef87ea5c27187c59a50121930bdc00ec905 --- /dev/null +++ b/src/lexer_generator.ml @@ -0,0 +1,483 @@ +open Batteries +open BatList +open Symbols +open Utils +open E_regexp + +type 'a set = 'a Set.t + +(* Non-deterministic Finite Automata (NFA) *) + +(* Les états d'un NFA [nfa_state] sont des entiers. + + Un NFA est modélisé sous la forme d'un record, avec les quatre champs + suivants: + - [nfa_states] contient la liste des états de l'automate. + - [nfa_initial] contient la liste des états initiaux de l'automate. + - [nfa_final] contient la liste des états finaux de l'automate sous la + forme (q, t), où q est un état de l'automate, et t, de type + [string -> token option] est une fonction qui construit un token + à partir d'une chaîne de caractères. + - [nfa_step q] donne la liste des transitions depuis l'état [q] sous la + forme d'une liste [(charset, q')]. [charset] est l'ensemble des caractères + qui permettent de prendre la transition vers l'état [q']. [charset] peut + éventuellement être [None], ce qui indique une epsilon-transition. +*) + +type nfa_state = int + +type nfa = + { + nfa_states: nfa_state list; + nfa_initial: nfa_state list; + nfa_final: (nfa_state * (string -> token option)) list; + nfa_step: nfa_state -> (char set option * nfa_state) list + } + +(* [empty_nfa] est un NFA vide. *) +let empty_nfa = + { + nfa_states = []; + nfa_initial = []; + nfa_final = []; + nfa_step = fun q -> []; + } + +(* Concaténation de NFAs. *) +let cat_nfa n1 n2 = + (* TODO *) + empty_nfa + +(* Alternatives de NFAs *) +let alt_nfa n1 n2 = + (* TODO *) + empty_nfa + +(* Répétition de NFAs *) +(* t est de type [string -> token option] *) +let star_nfa n t = + (* TODO *) + empty_nfa + + +(* [nfa_of_regexp r freshstate t] construit un NFA qui reconnaît le même langage + que l'expression régulière [r]. + [freshstate] correspond à un entier pour lequel il n'y a pas encore d'état dans + le nfa. Il suffit d'incrémenter [freshstate] pour obtenir de nouveaux états non utilisés. + [t] est une fonction du type [string -> token option] utile pour les états finaux. +*) +let rec nfa_of_regexp r freshstate t = + match r with + | Eps -> { nfa_states = [freshstate]; + nfa_initial = [freshstate]; + nfa_final = [(freshstate,t)]; + nfa_step = fun q -> []}, freshstate + 1 + | Charset c -> { nfa_states = [freshstate; freshstate + 1]; + nfa_initial = [freshstate]; + nfa_final = [freshstate + 1, t]; + nfa_step = fun q -> if q = freshstate then [(Some c, freshstate + 1)] else [] + }, freshstate + 2 + (* TODO *) + | _ -> empty_nfa, freshstate + +(* Deterministic Finite Automaton (DFA) *) + +(* Les états d'un DFA [dfa_state] sont des ensembles d'entiers. + + Similairement aux NFA, un DFA est modélisé sous la forme d'un record, avec + les quatre champs suivants: + + - [dfa_states] contient la liste des états de l'automate. + - [dfa_initial] contient l'état initial de l'automate. + - [dfa_final] contient la liste des états finaux de l'automate sous la + forme (q, t), où q est un état de l'automate, et t, de type + [string -> token option] est une fonction qui construit un token + à partir d'une chaîne de caractères. + - [dfa_step q c] donne l'état [q'] accessible après avoir lu le caractère + [c], depuis l'état [q]. [charset] peut éventuellement être [None], ce qui + indique qu'aucune transition n'est possible depuis cet état, et avec ce + caractère. +*) + +type dfa_state = int set + +type dfa = + { + dfa_states: dfa_state list; + dfa_initial: dfa_state; + dfa_final: (dfa_state * (string -> token option)) list; + dfa_step: dfa_state -> char -> dfa_state option + } + +(* On va maintenant déterminiser notre NFA pour en faire un DFA. *) + + +(* [epsilon_closure] calcule la epsilon-fermeture d'un état [s] dans un NFA [n], + c'est-à -dire l'ensemble des états accessibles depuis [s] en ne prenant que + des epsilon-transitions. *) +let epsilon_closure (n: nfa) (s: nfa_state) : nfa_state set = + (* La fonction [traversal visited s] effectue un parcours de l'automate en + partant de l'état [s], et en suivant uniquement les epsilon-transitions. *) + let rec traversal (visited: nfa_state set) (s: nfa_state) : nfa_state set = + (* TODO *) + visited + in + traversal Set.empty s + +(* [epsilon_closure_set n ls] calcule l'union des epsilon-fermeture de chacun + des états du NFA [n] dans l'ensemble [ls]. *) +let epsilon_closure_set (n: nfa) (ls: nfa_state set) : nfa_state set = + (* TODO *) + ls + +(* [dfa_initial_state n] calcule l'état initial de l'automate déterminisé. *) +let dfa_initial_state (n: nfa) : dfa_state = + (* TODO *) + Set.empty + +(* Construction de la table de transitions de l'automate DFA. *) + +(* Comme vu en cours, pour construire la table de l'automate DFA à partir de + l'automate NFA [n], on part d'un état [q] de l'automate (initialement, l'état + initial, que l'on vient de calculer ci-dessus). + + On calcule l'ensemble [t] des transitions dans [n] de chacun des états de + [q]. Cet ensemble est de type [(char set option * nfa_state) list]. + + On transforme cet ensemble [t] de la manière suivante : + - on jette les epsilon-transitions : [assoc_throw_none] + - on transforme chaque transition ({c1,c2,..,cn}, q) en une liste de + transitions [(c1,q); (c2,q); ...; (cn,q)] : [assoc_distribute_key] + - on fusionne les transitions qui consomment le même caractère: + [(c1,q1);(c1,q2);...;(c1,qn);(c2,q'1);...(c2,q'm)] -> + [(c1,{q1,q2,...,qn});(c2,{q'1,...,q'm})] : [assoc_merge_vals] + - on applique la epsilon-fermeture sur tous les états: + [(c1,{q1,q2,...,qn});...;(cn,{qn}])] -> [(c1, eps({q1,q2,...,qn})); ...; (cn, eps({qn}))] : + [epsilon_closure_set] + + On obtient alors l'ensemble des transitions depuis l'état [q] dans + l'automate DFA. + + On réitère ce processus pour tous les nouveaux états que l'on atteint. +*) + +let assoc_throw_none (l : ('a option * 'b) list) : ('a * 'b) list = + List.filter_map (fun (o,n) -> + match o with + None -> None + | Some x -> Some (x,n) + ) l + +let assoc_distribute_key (l : ('a set * 'b) list) : ('a * 'b) list = + List.fold_left (fun (acc : ('a * 'b) list) (k, v) -> + Set.fold (fun c acc -> (c, v)::acc) k acc) + [] l + +let assoc_merge_vals (l : ('a * 'b) list) : ('a * 'b set) list = + List.fold_left (fun (acc : ('a * 'b set) list) (k, v) -> + match List.assoc_opt k acc with + | None -> (k, Set.singleton v)::acc + | Some vl -> (k, Set.add v vl)::List.remove_assoc k acc + ) [] l + +let rec build_dfa_table (table: (dfa_state, (char * dfa_state) list) Hashtbl.t) + (n: nfa) + (ds: dfa_state) : unit = + match Hashtbl.find_option table ds with + | Some _ -> () + | None -> + (* [transitions] contient les transitions du DFA construites + * à partir des transitions du NFA comme décrit auparavant *) + let transitions : (char * dfa_state) list = + (* TODO *) + [] + in + Hashtbl.replace table ds transitions; + List.iter (build_dfa_table table n) (List.map snd transitions) + +(* Calcul des états finaux de l'automate DFA *) + +(* Comme vu en cours, un état [q] du DFA est final si et seulement si il existe + un état [q'] dans [q] qui soit un état final dans le NFA. + + Il nous faut de plus calculer le token qui sera reconnu par chaque état + final. + + Supposons que l'on ait deux états finaux [q1, fun s -> SYM_IDENTIFIER s] et + [q2, fun s -> SYM_WHILE] dans notre NFA. + L'état [q = {q1,q2}] est final, mais comment choisir le token à reconnaître ? + + Dans ce cas précis, on souhaite reconnaître le mot-clé 'while' plutôt qu'un + identifiant quelconque. + + Pour résoudre ce problème plus généralement, on introduit une fonction de + priorité pour départager les tokens. La fonction [priority : token -> int] + donne une valeur plus petite aux tokens les plus prioritaires. + +*) + +let priority t = + match t with + | SYM_EOF -> 100 + | SYM_IDENTIFIER _ -> 50 + | _ -> 0 + +(* [min_priority l] renvoie le token de [l] qui a la plus petite priorité, ou + [None] si la liste [l] est vide. *) +let min_priority (l: token list) : token option = + (* TODO *) + None + +(* [dfa_final_states n dfa_states] renvoie la liste des états finaux du DFA, + accompagnés du token qu'ils reconnaissent. *) +let dfa_final_states (n: nfa) (dfa_states: dfa_state list) : + (dfa_state * (string -> token option)) list = + (* TODO *) + [] + +(* Construction de la relation de transition du DFA. *) + +(* [make_dfa_step table] construit la fonction de transition du DFA, où [table] + est la table générée par [build_dfa_table], définie ci-dessus. *) +let make_dfa_step (table: (dfa_state, (char * dfa_state) list) Hashtbl.t) = + fun (q: dfa_state) (a: char) -> + (* TODO *) + None + +(* Finalement, on assemble tous ces morceaux pour construire l'automate. La + fonction [dfa_of_nfa n] vous est grâcieusement offerte. *) +let dfa_of_nfa (n: nfa) : dfa = + let table : (dfa_state, (char * dfa_state) list) Hashtbl.t = + Hashtbl.create (List.length n.nfa_states) in + let dfa_initial = dfa_initial_state n in + build_dfa_table table n dfa_initial; + let dfa_states = Hashtbl.keys table |> List.of_enum in + let dfa_final = dfa_final_states n dfa_states in + let dfa_step = make_dfa_step table in + { + dfa_states ; + dfa_initial ; + dfa_final ; + dfa_step ; + } + +(* Analyse lexicale *) + +(* Maintenant que tout est en place, on va pouvoir écrire un analyseur lexical, + qui va découper notre programme source en une liste de tokens. *) + +(* La fonction [tokenize_one d w] tente de reconnaître le plus grand préfixe + possible de [w]. Elle renvoie un couple [(res,w')], où [res] est le résultat + de l'analyse lexicale d'un mot et [w'] est le reste du programme à analyser. + + Le résultat est de type [lexer_result], défini ci-dessous: + - [LRToken tok] indique que l'automate a reconnu le token [tok] + - [LRskip] indique que l'automate a reconnu un mot qui ne génère pas de token + (c'est le cas par exemple des espaces, tabulations, retours à la ligne et + commentaires) + - [LRerror] indique que l'automate n'a rien reconnu du tout : il s'agit donc + d'une erreur. + +*) + +type lexer_result = + | LRtoken of token + | LRskip + | LRerror + +(* La fonction [tokenize_one] utilise une fonction interne [recognize q w + current_word last_accepted] qui essaie de lire le plus grand préfixe de [w] + reconnu par l'automate. + + - [q] est l'état courant de l'automate. + - [w] est le reste du programme source à analyser. + - [current_word] est le mot reconnu depuis l'état initial de l'automate. + - [last_accepted] est de type [lexer_result * char list]. La première + composante est le dernier résultat valable de l'analyseur : celui vers + lequel on se rabattra lorsque l'on sera bloqué dans un état non final de + l'automate. La deuxième composante est le reste du programme à analyser, + après ce dernier token reconnu. + + La fonction recognize est lancée avec [q = d.dfa_initial], l'état initial du + DFA, le programme à analyser [w], un mot courant vide, et un dernier état + accepté dénotant une erreur (si on ne passe par aucun état final, il s'agit + bien d'une erreur lexicale). + +*) + +let tokenize_one (d : dfa) (w: char list) : lexer_result * char list = + let rec recognize (q: dfa_state) (w: char list) + (current_token: char list) (last_accepted: lexer_result * char list) + : lexer_result * char list = + (* TODO *) + last_accepted + in + recognize d.dfa_initial w [] (LRerror, w) + +(* La fonction [tokenize_all d w] répète l'application de [tokenize_one] tant qu'on + n'est pas arrivé à la fin du fichier (token [SYM_EOF]). Encore une fois, + cette fonction vous est offerte. *) +let rec tokenize_all (d: dfa) (w: char list) : (token list * char list) = + match tokenize_one d w with + | LRerror, w -> [], w + | LRskip, w -> tokenize_all d w + | LRtoken token, w -> + let (tokens, w) = + if token = SYM_EOF + then ([], w) + else tokenize_all d w in + (token :: tokens, w) + + + +(* Fonctions d'affichage - Utile pour déboguer *) + + +let char_list_to_char_ranges s = + let rec recognize_range (cl: int list) l opt_c n = + match cl with + | [] -> (match opt_c with + None -> l + | Some c -> (c,n)::l + ) + | c::r -> (match opt_c with + | None -> recognize_range r l (Some c) 0 + | Some c' -> + if c' + n + 1 = c + then recognize_range r l (Some c') (n + 1) + else recognize_range r ((c',n)::l) (Some c) 0 + ) + in + let l = recognize_range (List.sort Stdlib.compare (List.map Char.code s)) [] None 0 in + let escape_char c = + if c = '"' then "\\\"" + else if c = '\\' then "\\\\" + else if c = '\x00' then "\\\\0" + else if c = '\t' then "\\\\t" + else if c = '\n' then "\\\\n" + else Printf.sprintf "%c" c in + List.fold_left (fun acc (c,n) -> + match n with + | 0 -> Printf.sprintf "%s%s" (escape_char (Char.chr c)) acc + | 1 -> Printf.sprintf "%s%s%s" (escape_char (Char.chr c)) (c + 1 |> Char.chr |> escape_char) acc + | _ -> Printf.sprintf "%s-%s%s" (escape_char (Char.chr c)) + (escape_char (Char.chr (c + n))) acc + ) "" l + + +(* Affichage d'un NFA *) +let nfa_to_string (n : nfa) : string = + Printf.sprintf "===== NFA\nStates : %s\nInitial states : %s\nFinal states : %s\n%s" + (String.concat " " (List.map (fun q -> string_of_int q) n.nfa_states)) + (String.concat " " (List.map (fun q -> string_of_int q) n.nfa_initial)) + (String.concat " " (List.map (fun (q,_) -> string_of_int q) n.nfa_final)) + (String.concat "" + (List.map (fun q -> + let l = n.nfa_step q in + String.concat "" + (List.map (fun (oa, q') -> + Printf.sprintf "step(%d, %s) = [%d]\n" q (match oa with Some a -> Printf.sprintf "[%s]" (string_of_char_set a) | _ -> "eps") + q' + ) l) + ) n.nfa_states)) + +let nfa_to_dot oc (n : nfa) : unit = + Printf.fprintf oc "digraph {\n"; + List.iter (fun n -> Printf.fprintf oc "N%d [shape=\"house\" color=\"red\"]\n" n) (n.nfa_initial); + List.iter (fun (q,t) -> + Printf.fprintf oc "N%d [shape=\"rectangle\", label=\"%s\"]\n" + q (match t "0" with | Some s -> string_of_symbol s | None -> "" )) n.nfa_final; + List.iter (fun q -> + List.iter (fun (cso, q') -> + match cso with + | None -> + Printf.fprintf oc "N%d -> N%d [label=\"[epsilon]\"]\n" q q' + | Some cs -> + Printf.fprintf oc "N%d -> N%d [label=\"[%s]\"]\n" q q' (char_list_to_char_ranges (Set.to_list cs)) + ) (n.nfa_step q); + ) n.nfa_states; + Printf.fprintf oc "}\n" + + +(* Affichage d'un DFA *) +let dfa_to_string (n : dfa) (alphabet: char list): string = + Printf.sprintf "===== DFA\nStates : %s\nInitial state : %s\nFinal states : [%s]\n%s" + (String.concat " " (List.map (fun q -> string_of_int_set q) n.dfa_states)) + (string_of_int_set n.dfa_initial) + (String.concat " " (List.map (fun (q,_) -> string_of_int_set q) n.dfa_final)) + (String.concat "" (List.map (fun q -> + String.concat "" (List.map (fun a -> + let l = n.dfa_step q a in + match l with + | None -> "" + | Some q' -> + if not (Set.is_empty q') then + Printf.sprintf "step(%s, %c) = %s\n" + (string_of_int_set q) + a (string_of_int_set q') + else "" + ) alphabet); + ) n.dfa_states)) + +(* Affichage graphique d'un DFA. Génère un fichier .dot que vous pouvez ensuite + convertir en pdf avec la commande 'dot fichier.dot -Tsvg -o fichier.svg' ou + bien en copiant le code DOT dans un convertisseur en ligne (par exemple : + http://proto.informatics.jax.org/prototypes/dot2svg/). *) + +let dfa_to_dot oc (n : dfa) (cl: char list): unit = + Printf.fprintf oc "digraph {\n"; + Printf.fprintf oc "N%s [shape=\"house\" color=\"red\"]\n" (string_of_int_set n.dfa_initial); + List.iter (fun (q,t) -> + Printf.fprintf oc "N%s [shape=\"rectangle\", label=\"%s\"]\n" + (string_of_int_set q) (match t "0" with | Some s -> string_of_symbol s | None -> "" )) n.dfa_final; + List.iter (fun q -> + let l = List.fold_left (fun l a -> + match n.dfa_step q a with + None -> l + | Some q' -> + match List.assoc_opt q' l with + | None -> (q', [a])::l + | Some ql -> (q', a::ql)::List.remove_assoc q' l + ) [] cl in + List.iter (fun (q', cl) -> + Printf.fprintf oc "N%s -> N%s [label=\"[%s]\"]\n" + (string_of_int_set q) + (string_of_int_set q') (char_list_to_char_ranges cl) + ) l; + ) n.dfa_states; + Printf.fprintf oc "}\n" + +let nfa_of_list_regexp l = + let (n, fs) = List.fold_left (fun (nfa, fs) (r,t) -> + let n,fs = nfa_of_regexp r fs t in + (alt_nfa nfa n, fs) + ) ({ nfa_states = []; nfa_initial = []; nfa_final = []; nfa_step = fun _ -> [] },1) + l in n + +let dfa_of_list_regexp l = + let n = nfa_of_list_regexp l in + dfa_of_nfa n + +let tokenize_list_regexp l s = + let d = dfa_of_list_regexp l in + let tokens, leftover = tokenize_all d (char_list_of_string s) in + if leftover <> [] + then Error (Printf.sprintf "Lexer failed to recognize string starting with '%s'\n" + (string_of_char_list (take 20 leftover)) + ) + else OK tokens + +let file_contents file = + let ic = open_in file in + let rec aux s () = + try + let line = input_line ic in (* read line from in_channel and discard \n *) + aux (s ^ line ^ "\n") () (* close the input channel *) + with e -> (* some unexpected exception occurs *) + close_in_noerr ic; (* emergency closing *) + s in + aux "" () + + +let tokenize_file f = + tokenize_list_regexp list_regexp (file_contents f) diff --git a/src/linear.ml b/src/linear.ml new file mode 100644 index 0000000000000000000000000000000000000000..754e9dc97b0dc9dd9224af2affd8a5ece94e2b0b --- /dev/null +++ b/src/linear.ml @@ -0,0 +1,11 @@ +open Batteries +open BatList +open Rtl +open Prog +open Utils + +type linear_fun = { + linearfunargs: reg list; + linearfunbody: rtl_instr list; + linearfuninfo: (string*reg) list; +} diff --git a/src/linear_dse.ml b/src/linear_dse.ml new file mode 100644 index 0000000000000000000000000000000000000000..c96ed7eccfa0570db8c7610cf2f670ad2522ec07 --- /dev/null +++ b/src/linear_dse.ml @@ -0,0 +1,44 @@ +open Rtl +open Linear +open Linear_liveness +open Batteries +open BatList +open Prog +open Utils +open Report +open Linear_print +open Report +open Options + +let dse_instr (ins: rtl_instr) live = + [ins] + + +let dse_fun live {linearfunargs; linearfunbody; linearfuninfo; } = + let body = + linearfunbody + |> List.mapi (fun i ins -> dse_instr ins (Hashtbl.find_default live i Set.empty)) + |> List.concat in + { linearfunargs; linearfunbody = body; linearfuninfo; } + + +let dse_prog p live = + if !Options.no_linear_dse + then p + else + List.map (fun (fname,gdef) -> + match gdef with + Gfun f -> + let live = Hashtbl.find_default live fname (Hashtbl.create 17, Hashtbl.create 17) |> snd in + let f = dse_fun live f in + (fname, Gfun f) + ) p + +let pass_linear_dse linear lives = + let linear = dse_prog linear lives in + record_compile_result "DSE"; + dump (!linear_dump >*> fun s -> s ^ "1") + (fun oc -> dump_linear_prog oc (Some lives)) linear + (fun file () -> add_to_report "linear-after-dse" "Linear after DSE" + (Code (file_contents file))); + OK linear diff --git a/src/linear_gen.ml b/src/linear_gen.ml new file mode 100644 index 0000000000000000000000000000000000000000..c12bd04588cfef6a06de11d299bd2ebcd26c09c3 --- /dev/null +++ b/src/linear_gen.ml @@ -0,0 +1,67 @@ +open Batteries +open Rtl +open Linear +open Prog +open Utils +open Report +open Linear_print +open Options +open Linear_liveness + +let succs_of_rtl_instr (i: rtl_instr) = + match i with + | Rtl.Rbranch (_, _, _, s1) -> [s1] + | Rtl.Rjmp s -> [s] + | _ -> [] + +let rec succs_of_rtl_instrs il : int list = + List.concat (List.map succs_of_rtl_instr il) + +(* effectue un tri topologique des blocs. *) +let sort_blocks (nodes: (int, rtl_instr list) Hashtbl.t) entry = + let rec add_block order n = + (* TODO *) + List.of_enum (Hashtbl.keys nodes) + in + add_block [] entry + + +(* Supprime les jumps inutiles (Jmp à un label défini juste en dessous). *) +let rec remove_useless_jumps (l: rtl_instr list) = + (* TODO *) + l + + +(* Remove labels that are never jumped to. *) +let remove_useless_labels (l: rtl_instr list) = + (* TODO *) + l + +let linear_of_rtl_fun + ({ rtlfunargs; rtlfunbody; rtlfunentry; rtlfuninfo }: rtl_fun) = + let block_order = sort_blocks rtlfunbody rtlfunentry in + let linearinstrs = + Rjmp rtlfunentry :: + List.fold_left (fun l n -> + match Hashtbl.find_option rtlfunbody n with + | None -> l + | Some li -> l @ Rlabel(n) :: li + ) [] block_order in + { linearfunargs = rtlfunargs; + linearfunbody = + linearinstrs |> remove_useless_jumps |> remove_useless_labels; + linearfuninfo = rtlfuninfo; + } + +let linear_of_rtl_gdef = function + Gfun f -> Gfun (linear_of_rtl_fun f) + +let linear_of_rtl r = + assoc_map linear_of_rtl_gdef r + +let pass_linearize rtl = + let linear = linear_of_rtl rtl in + let lives = liveness_linear_prog linear in + dump !linear_dump (fun oc -> dump_linear_prog oc (Some lives)) linear + (fun file () -> add_to_report "linear" "Linear" (Code (file_contents file))); + OK (linear, lives) diff --git a/src/linear_liveness.ml b/src/linear_liveness.ml new file mode 100644 index 0000000000000000000000000000000000000000..0a5891e75cfe8718612141f84e5e97e86f8b377c --- /dev/null +++ b/src/linear_liveness.ml @@ -0,0 +1,83 @@ +open Batteries +open BatList +open Prog +open Utils +open Linear +open Rtl + +let gen_live (i: rtl_instr) = + match i with + | Rbinop (b, rd, rs1, rs2) -> Set.of_list [rs1; rs2] + | Rprint rs + | Runop (_, _, rs) -> Set.singleton rs + | Rconst (_, _) -> Set.empty + | Rbranch (_, rs1, rs2, _) -> Set.of_list [rs1; rs2] + | Rjmp _ -> Set.empty + | Rmov (_, rs) -> Set.singleton rs + | Rret r -> Set.singleton r + | Rlabel _ -> Set.empty + +let kill_live (i: rtl_instr) = + match i with + | Rbinop (_, rd, _, _) + | Runop (_, rd,_) + | Rconst (rd, _) + | Rmov (rd,_) -> Set.singleton rd + | Rbranch (_, _, _, _) + | Rprint _ + | Rret _ + | Rjmp _ + | Rlabel _ -> Set.empty + +let linear_succs (ins: rtl_instr) i labels = + match ins with + | Rbranch(_, _, _, s1) -> [Hashtbl.find_default labels s1 0; i+1] + | Rjmp s -> [Hashtbl.find_default labels s 0] + | Rret r -> [] + | _ -> [i+1] + +let setup_labels insl = + let labels = Hashtbl.create 17 in + List.iteri (fun i ins -> + match ins with + | Rlabel l -> Hashtbl.replace labels l i + | _ -> () + ) insl; + labels + +let add_changes h k v = + let orig = Hashtbl.find_default h k Set.empty in + Hashtbl.replace h k v; + not (Set.equal v orig) + +let iter_liveness insl live_in live_out labels = + List.fold_lefti (fun changed i ins -> + + let gl = gen_live ins in + let kl = kill_live ins in + let oi = Hashtbl.find_default live_out i Set.empty in + let newin = Set.union gl (Set.diff oi kl) in + let changed = add_changes live_in i newin || changed in + let succs = linear_succs ins i labels in + let j = List.fold_left (fun j succ -> + Set.union j (Hashtbl.find_default live_in succ Set.empty) + ) Set.empty succs in + add_changes live_out i j || changed + ) false insl + +let liveness_instrs insns = + let live_in = Hashtbl.create 17 in + let live_out = Hashtbl.create 17 in + let labels = setup_labels insns in + let rec aux () = + if iter_liveness insns live_in live_out labels + then aux () + else (live_in, live_out) in + aux () + +let liveness_linear_prog lp = + let lives = Hashtbl.create 17 in + List.iter (function + (s,Gfun f) -> Hashtbl.replace lives s (liveness_instrs f.linearfunbody) + ) lp; + lives diff --git a/src/linear_print.ml b/src/linear_print.ml new file mode 100644 index 0000000000000000000000000000000000000000..78970b0330d58270fe94e0ed271d57ea13c8b262 --- /dev/null +++ b/src/linear_print.ml @@ -0,0 +1,19 @@ +open Batteries +open Rtl_print +open Linear +open Prog +open Utils + + +let dump_linear_fun oc lives lfname l = + Format.fprintf oc "%s(%s):\n" lfname + (String.concat ", " $ List.map print_reg l.linearfunargs); + let lives = match lives with + | None -> None + | Some lives -> + (Hashtbl.find_option lives lfname) + in + dump_rtl_node lfname lives oc l.linearfunbody + +let dump_linear_prog oc lives lp = + dump_prog (fun oc -> dump_linear_fun oc lives) oc lp diff --git a/src/linear_run.ml b/src/linear_run.ml new file mode 100644 index 0000000000000000000000000000000000000000..63b622a56408dea0d4fe1c4c2d84cc875e319da7 --- /dev/null +++ b/src/linear_run.ml @@ -0,0 +1,98 @@ +open Batteries +open BatList +open Prog +open Elang +open Cfg +open Elang_run +open Cfg_run +open Rtl +open Rtl_print +open Rtl_run +open Linear +open Builtins +open Utils + +let rec exec_linear_instr oc lp fname f st (i: rtl_instr) = + match i with + | Rbinop (b, rd, rs1, rs2) -> + begin match Hashtbl.find_option st.regs rs1, + Hashtbl.find_option st.regs rs2 with + | Some v1, Some v2 -> + Hashtbl.replace st.regs rd (eval_binop b v1 v2); + OK (None, st) + | _, _ -> Error (Printf.sprintf "Binop applied on undefined registers (%s and %s)" (print_reg rs1) (print_reg rs2)) + end + | Runop (u, rd, rs) -> + begin match Hashtbl.find_option st.regs rs with + | Some v -> + Hashtbl.replace st.regs rd (eval_unop u v); + OK (None, st) + | _ -> Error (Printf.sprintf "Unop applied on undefined register %s" (print_reg rs)) + end + | Rconst (rd, i) -> + Hashtbl.replace st.regs rd i; + OK (None, st) + | Rbranch (cmp, r1, r2, s1) -> + begin match Hashtbl.find_option st.regs r1, + Hashtbl.find_option st.regs r2 with + | Some v1, Some v2 -> + if eval_rtl_cmp cmp v1 v2 then exec_linear_instr_at oc lp fname f st s1 else OK (None, st) + | _, _ -> Error (Printf.sprintf "Branching on undefined registers (%s and %s)" (print_reg r1) (print_reg r2)) + end + | Rjmp s -> exec_linear_instr_at oc lp fname f st s + | Rmov (rd, rs) -> + begin match Hashtbl.find_option st.regs rs with + | Some s -> + Hashtbl.replace st.regs rd s; + OK (None, st) + | _ -> Error (Printf.sprintf "Mov on undefined register (%s)" (print_reg rs)) + end + | Rprint r -> + begin match Hashtbl.find_option st.regs r with + | Some s -> + Format.fprintf oc "%d\n" s; + OK (None, st) + | _ -> Error (Printf.sprintf "Print on undefined register (%s)" (print_reg r)) + end + | Rret r -> + begin match Hashtbl.find_option st.regs r with + | Some s -> OK (Some s, st) + | _ -> Error (Printf.sprintf "Ret on undefined register (%s)" (print_reg r)) + end + | Rlabel n -> OK (None, st) + +and exec_linear_instr_at oc lp fname ({ linearfunbody; } as f) st i = + let l = List.drop_while (fun x -> x <> Rlabel i) linearfunbody in + exec_linear_instrs oc lp fname f st l + +and exec_linear_instrs oc lp fname f st l = + List.fold_left (fun acc i -> + match acc with + | Error _ -> acc + | OK (Some v, st) -> OK (Some v, st) + | OK (None, st) -> + exec_linear_instr oc lp fname f st i + ) (OK (None, st)) l + +and exec_linear_fun oc lp st fname f params = + let regs' = Hashtbl.create 17 in + match List.iter2 (fun n v -> Hashtbl.replace regs' n v) f.linearfunargs params with + | exception Invalid_argument _ -> + Error (Format.sprintf "Linear: Called function %s with %d arguments, expected %d\n" fname + (List.length params) (List.length f.linearfunargs)) + | _ -> + let l = f.linearfunbody in + let regs_save = Hashtbl.copy st.regs in + let st' = {st with regs = regs' } in + exec_linear_instrs oc lp fname f st' l >>= fun (v,st) -> + OK(v, {st with regs = regs_save }) + +and exec_linear_prog oc lp memsize params = + let st = init_state memsize in + find_function lp "main" >>= fun f -> + let n = List.length f.linearfunargs in + let params = take n params in + exec_linear_fun oc lp st "main" f params >>= fun (v, st) -> + OK v + + diff --git a/src/ltl.ml b/src/ltl.ml new file mode 100644 index 0000000000000000000000000000000000000000..6082bfb5b45f4a311e6c8a681e20676c5509c3a9 --- /dev/null +++ b/src/ltl.ml @@ -0,0 +1,116 @@ +open Batteries +open BatList +open BatBuffer +open Elang +open Rtl +open Regalloc +open Linear +open Linear_liveness +open Prog +open Utils + +(* LTL/Risc-V registers *) +type ltl_reg = int +let reg_zero = 0 +let reg_ra = 1 +let reg_sp = 2 +let reg_gp = 3 +let reg_tp = 4 +let reg_t0 = 5 +let reg_t1 = 6 +let reg_t2 = 7 +let reg_s0 = 8 +let reg_s1 = 9 +let reg_a0 = 10 +let reg_a1 = 11 +let reg_a2 = 12 +let reg_a3 = 13 +let reg_a4 = 14 +let reg_a5 = 15 +let reg_a6 = 16 +let reg_a7 = 17 +let reg_s2 = 18 +let reg_s3 = 19 +let reg_s4 = 20 +let reg_s5 = 21 +let reg_s6 = 22 +let reg_s7 = 23 +let reg_s8 = 24 +let reg_s9 = 25 +let reg_s10 = 26 +let reg_s11 = 27 +let reg_t3 = 28 +let reg_t4 = 29 +let reg_t5 = 30 +let reg_t6 = 31 + +let reg_tmp = [reg_t0; reg_t1; reg_t2; reg_t3; reg_t4; reg_t5; reg_t6] +let reg_tmp1 = reg_t0 +let reg_tmp2 = reg_t1 +let reg_fp = reg_s0 +let reg_ret = reg_a0 + +type ltl_instr = + LAddi of ltl_reg * ltl_reg * int + | LSubi of ltl_reg * ltl_reg * int + | LStore of ltl_reg * int * ltl_reg * mem_access_size (* LStore(rd, rofs, rs, sz) : store + value in [rs] on [sz] bytes at + address [rd+rofs] *) + | LLoad of ltl_reg * ltl_reg * int * mem_access_size (* LLoad(rd, rs, rofs, sz) : load + value at address [rs+rofs] on [sz] + bytes in register [rd]. *) + | LMov of ltl_reg * ltl_reg (* LMov(rd, rs) : move value of [rs] into [rd]. + *) + | LLabel of string + | LJmp of string + | LBinop of binop * ltl_reg * ltl_reg * ltl_reg (* LBinop(b, rd, rs1, rs2) : + performs binary operation + [b] on values in registers + [rs1] and [rs2]. Stores the + result in [rd]. *) + | LUnop of unop * ltl_reg * ltl_reg (* LUnop(u,rd,rs) : performs unary + operation [u] on register [rs]. Stores + the result in [rd]. *) + | LConst of ltl_reg * int (* LConst(rd,i) : load immediate value [i] in + register [rd]. *) + | LComment of string + | LCall of string (* LCall(f) : calls function [f]. *) + | LBranch of rtl_cmp * ltl_reg * ltl_reg * string (* LBranch(cmp, rs1, rs2, + label): compares [rs1] + and [rs2] according to + comparison [cmp]. If + true, jump to [label]. *) + | LJmpr of ltl_reg (* LJmpr(r) : jumps to address in [r]. *) + | LHalt (* Stops the program. *) + +(* An LTL function is essentially a list of instructions (field [ltlfunbody]). + The other fields are mainly here for debugging and statistics : + - [ltlfunargs] gives the number of arguments that the function takes; + - [ltlfuninfo] is a mapping from source variable names to the RTL register + they're allocated in; + - [ltlregalloc] is a mapping from RTL registers to LTL locations. + *) + +type ltl_fun = + { ltlfunargs: int; + ltlfunbody: ltl_instr list; + ltlfuninfo: (string*reg) list; + ltlregalloc: (reg*loc) list; + } + + +(* Lists of caller-save and callee-save registers *) + +let caller_saved = [ + reg_a0; reg_a1; reg_a2; reg_a3; reg_a4; reg_a5; reg_a6; reg_a7; + reg_t0; reg_t1; reg_t2; reg_t3; reg_t4; reg_t5; reg_t6; reg_ra; +] + +let callee_saved = [ + reg_s0; reg_s1; reg_s2; reg_s3; reg_s4; reg_s5; reg_s6; reg_s7; + reg_s8; reg_s9; reg_s10; reg_s11; reg_sp; reg_ra +] + +(* We pass 8 arguments in registers (a0-a7). *) +let number_of_arguments_passed_in_registers = 8 +let starting_arg_register = reg_a0 diff --git a/src/ltl_debug.ml b/src/ltl_debug.ml new file mode 100644 index 0000000000000000000000000000000000000000..6e2d7753b21d0161f75ad66b400dad93b9a118b3 --- /dev/null +++ b/src/ltl_debug.ml @@ -0,0 +1,232 @@ +open Batteries +open BatList +open Batteries +open BatList +open BatBuffer +open Prog +open Elang +open Cfg +open Elang_run +open Cfg_run +open Rtl +open Rtl_run +open Linear +open Ltl +open Ltl_print +open Utils +open Builtins +open Lwt +open Yojson +open Ltl_run + + + +type dbg_cmd = + | Next + | NextBp + | Break of int + | RmBreak of int + | Init of int * int list + | Quit + +let get_typed_attribute json attr toX = + let open Yojson.Basic.Util in + try + OK (json |> member attr |> toX) + with e -> Error ( + Yojson.Basic.to_string json |> fun s -> + Format.sprintf "In get_typed_attribute\n json=%s\nattr=%s\n%s" + s + attr + (Printexc.to_string e)) + +let parse_breakpoint j = + let open Yojson.Basic.Util in + let open Utils in + get_typed_attribute j "ip" to_int >>= fun ip -> + OK ip + +let parse_init j = + let open Yojson.Basic.Util in + let open Utils in + get_typed_attribute j "memsize" to_int >>= fun memsize -> + get_typed_attribute j "params" (fun x -> x |> to_list |> filter_int) >>= fun params -> + OK (Init (memsize, params)) + +let parse_dbg_cmd j = + let open Yojson.Basic.Util in + let open Utils in + get_typed_attribute j "cmd" to_string >>= fun cmd -> + begin match cmd with + | "next" -> OK Next + | "next_bp" -> OK NextBp + | "break" -> parse_breakpoint j >>= fun ip -> OK (Break ip) + | "rmbreak" -> parse_breakpoint j >>= fun ip -> OK (RmBreak ip) + | "init" -> parse_init j + | "quit" -> OK Quit + | _ -> Error (Format.sprintf "Unknown command '%s'" cmd) + end + +let rec json_summary j = + match j with + `Assoc l -> + let ks = ["regs"; "memwrite"; "memread"; "start"; "end"; "params"] in + let l = List.filter_map (fun (k,v) -> if List.mem k ks then None + else if k = "code" then Some (k, `List []) + else Some (k, json_summary v)) l in + `Assoc l + | `List l -> `List (List.map json_summary l) + | _ -> j +let trace_regs st = + Array.fold_lefti (fun acc r v -> + (string_of_reg r, `Int v) :: acc + ) [] st.regs + |> fun l -> `Assoc l + +let make_trace ip (st: ltl_state) out () = + let m = Mem.write_log st.mem () in + let mread = Mem.read_log st.mem () in + let out = if out = "" then [] else [("output", `String (String.escaped out))] in + `Assoc ([ + ("step", `Int !(st.numstep)); + ("ip", `Int ip); + ("regs", trace_regs st); + ("memwrite", `Assoc (List.map (fun (addr,v) -> (string_of_int addr, `Int v)) m)); + ("memread", `List (List.map (fun addr -> `Int addr) mread)) + ] @ out) + +let step_until state st send_json cond = + let rec aux () = + match !state with + | Some ip -> + begin match exec_ltl_instr Format.str_formatter ip st with + OK r -> + st.numstep := !(st.numstep) + 1; + state := r; + begin match r with + Some ip -> + let o = Format.flush_str_formatter () in + make_trace ip st o () |> send_json >>= fun _ -> + if cond ip + then `Assoc [("currentstep", `Int !(st.numstep))] |> send_json + else aux () + | None -> + `Assoc [("currentstep", `Int (!(st.numstep) - 1))] |> send_json >>= fun _ -> + `Assoc [("finished", `Bool true)] |> send_json + end + | Error msg -> + let s = String.escaped (string_of_error msg) in + `Assoc [("error", `String s)] |> + send_json + end + | None -> return () + in aux () + +open Websocket +open Websocket_lwt_unix + +let json_loc (l: Regalloc.loc) : Yojson.t = + match l with + | Regalloc.Reg r -> `Assoc [("reg", `String(string_of_reg r))] + | Regalloc.Stk o -> `Assoc [("stk", `Int(o))] + +let debugger_message progname breaks state st prog rstop client : unit Lwt.t = + let open Frame in + let send msg = Connected_client.send client (Frame.create ~opcode:Opcode.Text ~content:msg ())in + let send_json j = + Logs_lwt.info + (fun m -> m "Sending %s\n" (json_summary j |> to_string)) >>= fun _ -> + let s = to_string j ^ "@" in send s + in + let rec loop () = + let react fr = + Lwt_log.debug_f "<- %s" (Frame.show fr) >>= fun () -> + match fr.opcode with + | Opcode.Text -> + begin + let msg = fr.content in + Logs.info (fun m -> m "received command '%s'\n" msg); + let open Yojson.Basic in + let j = from_string msg in + match parse_dbg_cmd j with + | OK Next -> + step_until state !st send_json (fun ip -> true) + | OK NextBp -> + step_until state !st send_json + (fun ip -> List.mem ip !breaks) + | OK (Break ip) -> + breaks := ip :: !breaks; Lwt.return_unit + | OK (RmBreak ip) -> + breaks := List.remove_all !breaks ip; Lwt.return_unit + | OK (Init (memsize, params)) -> + st := init_state memsize prog params; + breaks := []; + begin match Hashtbl.find_option !st.funs "main" with + | Some floc -> + let ip = floc.funstart in + state := Some ip; + Hashtbl.fold (fun fname { funstart; funend; funinfo; funregalloc} + (* (fstart,fend,var2reg, alloc) *) acc -> + (`Assoc [("fname",`String fname); + ("start",`Int funstart); + ("end", `Int funend); + ("vars", `Assoc (List.filter_map (fun (k,v) -> + match List.assoc_opt v funregalloc with + | None -> None + | Some l -> Some (k,json_loc l) + ) funinfo)) + ]) :: acc + ) !st.funs [] |> fun funboundaries -> + Array.fold_lefti (fun acc ip ins -> + (Format.fprintf Format.str_formatter "%a" dump_ltl_instr ins); + (string_of_int ip, `String (Format.flush_str_formatter ())) :: acc + ) [] !st.code |> fun code -> + `List ( [`Assoc [("progname", `String progname); + ("params", `List (List.map (fun x -> `Int x) params))]; + `Assoc [("funboundaries", `List funboundaries)]; + `Assoc [("code", `Assoc code)]; + make_trace ip !st "" (); + `Assoc [("currentstep", `Int !(!st.numstep))]]) + |> send_json + | None -> fail (failwith (Format.sprintf "Could not find 'main' entry point...")) + end + | OK Quit -> + Lwt.wakeup rstop (); Lwt.return_unit + | Error errmsg -> + `Assoc [("error", `String (Format.sprintf "Error while parsing %s" msg)); + ("errorMsg", `String (string_of_error errmsg)) + ] |> + send_json + end + | _ -> Lwt.return_unit + in + Websocket_lwt_unix.Connected_client.recv client >>= react >>= loop + in + Lwt.catch + loop + (fun exn -> + Lwt_log.info_f "Connection to client lost" >>= fun () -> + Lwt.fail exn) + +let debug_ltl_prog progname lp memsize params : unit= + let () = Logs.set_reporter (Logs.format_reporter ()) in + let () = Logs.set_level (Some Logs.Info) in + let st = ref (init_state memsize lp params) in + let state = ref (None) in + let breaks = ref [] in + let ctx = Lazy.force Conduit_lwt_unix.default_ctx in + let uri = "http://localhost:8080" in + let (pstop, rstop) = Lwt.task () in + let server () = + Resolver_lwt.resolve_uri ~uri:(Uri.of_string uri) Resolver_lwt_unix.system >>= fun endp -> + Conduit_lwt_unix.endp_to_server ~ctx endp >>= fun server -> + Websocket_lwt_unix.establish_server + ~ctx ~mode:server + ~check_request:(fun req -> true) + ~on_exn:(fun exn -> + match exn with + End_of_file -> Logs.info (fun m -> m "Client disconnected\n") + | _ -> Logs.err (fun m -> m "Received exception : %s" (Printexc.to_string exn)) + ) + (debugger_message progname breaks state st lp rstop) in + Lwt_main.run (Lwt.pick [server () ; pstop]) diff --git a/src/ltl_gen.ml b/src/ltl_gen.ml new file mode 100644 index 0000000000000000000000000000000000000000..aa6a9fa16cc866bdcb76848577ada490f3b5ae22 --- /dev/null +++ b/src/ltl_gen.ml @@ -0,0 +1,427 @@ +open Batteries +open Rtl +open Linear +open Ltl +open Ltl_print +open Prog +open Utils +open Regalloc +open Linear_liveness +open Report +open Options + +(* list of registers used to store arguments. [a0-a7] *) +let arg_registers = + range ~start:starting_arg_register 8 + +(* Helpers to build pseudo-instructions. + ** [push x] is compiled into [sub sp, sp, 8; sd r, 0(sp)] + ** [pop x] is compiled into [ld r, 0(sp); add sp, sp, 8] +*) + +let make_push r = + [LSubi(reg_sp, reg_sp, (Archi.wordsize ())); + LStore(reg_sp, 0, r, (archi_mas ()))] + +let make_pop r = + [LLoad(r, reg_sp, 0, (archi_mas ())); + LAddi(reg_sp, reg_sp, (Archi.wordsize ()))] + +let make_sp_sub v = + [LSubi(reg_sp, reg_sp, v)] + +let make_sp_add v = + [LAddi(reg_sp, reg_sp, v)] + +(* Moving between locations. [src] and [dst] are locations. [make_loc_mov src + dst] generates instructions so that the value in [src] ends up in [dst], + where [src] and [dst] can be registers [Reg r] or stack offsets [Stk o]. +*) +let make_loc_mov src dst = + match src, dst with + | Stk osrc , Stk odst -> + let rtmp = reg_tmp1 in + [LLoad(rtmp, reg_fp, (Archi.wordsize ()) * osrc, (archi_mas ())); + LStore(reg_fp, (Archi.wordsize ()) * odst, rtmp, (archi_mas ()))] + | Stk osrc, Reg rdst -> + [LLoad(rdst, reg_fp, (Archi.wordsize ()) * osrc, (archi_mas ()))] + | Reg rsrc, Stk ofst -> + [LStore(reg_fp, (Archi.wordsize ()) * ofst, rsrc, (archi_mas ()))] + | Reg rsrc, Reg rdst -> + [LMov(rdst,rsrc)] + +(* load_loc tmp allocation r = (l, r'). Loads the equivalent of RTL register r + in a LTL register r'. tmpis used if necessary. *) +let load_loc tmp allocation r = + match Hashtbl.find_option allocation r with + | None -> + Error (Format.sprintf "Unable to allocate RTL register r%d." r) + | Some (Stk o) -> OK ([LLoad(tmp, reg_fp, (Archi.wordsize ()) * o, (archi_mas ()))], tmp) + | Some (Reg r) -> OK ([], r) + +(* store_loc tmp allocation r = (l, r'). I want to write in RTL register r. + Tells me that I just have to write to LTL register r' and execute l. *) +let store_loc tmp allocation r = + match Hashtbl.find_option allocation r with + | None -> + Error (Format.sprintf "Unable to allocate RTL register r%d." r) + | Some (Stk o) -> OK ([LStore(reg_fp, (Archi.wordsize ()) * o, tmp, (archi_mas ()))], tmp) + | Some (Reg r) -> OK ([], r) + +(* saves registers in [to_save] on the stack at offsets [fp + 8 * o, fp + 8 * (o + - 1), fp + 8 * (o - 2)...]. Returns: + + - an association list [(reg,ofs)] (meaning register reg is saved at [fp+ofs]) + - the list of store instructions - the next offset to be written. *) +let save_caller_save to_save ofs = + List.fold_left (fun (instrs, arg_saved, ofs) reg -> + (instrs @ [LStore(reg_fp, (Archi.wordsize ()) * ofs, reg, (archi_mas ()))], + (reg,ofs)::arg_saved, ofs - 1) + ) ([], [], ofs) to_save + +(* Given a list [(reg,ofs)], loads [fp+ofs] into [reg]. *) +let restore_caller_save arg_saved = + List.map + (fun (reg, ofs) -> LLoad(reg, reg_fp, (Archi.wordsize ()) * ofs, (archi_mas ()))) + arg_saved + +let num_parameters_passed_on_stack regs = + let r = List.length regs - number_of_arguments_passed_in_registers in + Stdlib.max 0 r + + +(* Given a list or RTL registers [rargs], we want to load their values in LTL + argument registers a0-7. But while writing these registers, we may overwrite + the value of some registers before we actually read them. + + For example if [r1 -> a1] and [r2 -> a0], and we want to load [r1] in [a0] + and [r2] in [a1] (because a function call f(r1,r2) occurs), the following + would happen : + + mv a0, a1 + mv a1, a0 + + But the value in [a1] will not be the value that was originally in RTL reg + [r2]. + + Hence, we keep track of the registers like [a1] that are going to be written + before being read, and those will be saved on the stack. +*) +let overwritten_args rargs allocation = + + (* [ltl_args] contains the locations of RTL args after allocation. *) + list_map_res (fun r -> match Hashtbl.find_option allocation r with + | None -> Error (Format.sprintf + "overwritten_args: Couldn't allocate register r%d." + r) + | Some loc -> OK loc + ) rargs >>= fun ltl_args -> + + let (overwritten, read_overwritten) = + List.fold_lefti (fun (overwritten, read_overwritten) i (src: loc) -> + (* [overwritten] contains the list of registers that have been written + to. + + [read_overwritten] contains the list of registers that have been read + after being written to. *) + let read_overwritten = + match src with + | Reg rs -> if Set.mem rs overwritten + then Set.add rs read_overwritten + else read_overwritten + | Stk _ -> read_overwritten + in + let overwritten = + if i < number_of_arguments_passed_in_registers + then Set.add (starting_arg_register + i) overwritten + else overwritten + in (overwritten, read_overwritten) + ) (Set.empty,Set.empty) ltl_args in + OK read_overwritten + + + +(* [pass_parameters rargs allocation arg_saved ofs] generates code to pass + parameters in RTL registers rargs. [allocation] maps RTL registers to LTL + locations, [arg_saved] contains saved registers, and [ofs] says where, + relative to reg_fp we may save more registers if needed. *) +let pass_parameters rargs allocation arg_saved = + (* LTL locations corresponding to RTL arguments. *) + list_map_res (fun r -> match Hashtbl.find_option allocation r with + | None -> + Error (Format.sprintf + "pass_parameters: Couldn't allocate register r%d." r) + | Some loc -> OK loc + ) rargs >>= fun ltl_args -> + + (* Relocation of arguments may be necessary if, e.g. a1 must be passed as + first argument (in a0) and a0 must be passed as second argument (in a1). In + that situation, a temporary must be used. These registers (a0 and a1) would + have been saved before on the stack and the relocation information is + available in arg_saved. *) + let reloc_loc overwritten loc = + match loc with + | Stk o -> OK loc + | Reg r -> if List.mem r overwritten + then match List.assoc_opt r arg_saved with + | None -> Error (Format.sprintf "Register %s has been overwritten, \ + yet it has not been saved." + (print_reg r)) + | Some newloc -> OK (Stk newloc) + else OK loc + in + (* Iterates over the list of LTL arguments. Generates 4 things: + + - [overwritten] is the set of registers that are overwritten during + parameter passing. If a register has been overwritten, then we use its copy + on the stack; otherwise we can use it directly. + + - [instrs] is a list of instructions for the arguments passed in registers. + + - [pushes] is a list of push pseudo-instructions for every additional + argument. The two lists are built separately so that we can build [pushes] + backwards so that e.g. the 9th argument is at the top of the stack at the + end, and e.g. the 15th at higher addresses. + + - [npush] is the number of arguments that were pushed to the stack. *) + + List.fold_lefti (fun acc i (src: loc) -> + acc >>= fun (overwritten, instrs, pushes, npush) -> + reloc_loc overwritten src >>= fun src -> + let (overwritten, l,pushes, npush) = + if i < number_of_arguments_passed_in_registers + then let rd = starting_arg_register + i in + begin match src with + | Reg rs -> (rd::overwritten, [LMov(rd, rs)],[], npush) + | Stk o -> (rd::overwritten, + [LLoad(rd, reg_fp, (Archi.wordsize ()) * o, (archi_mas ()))], + [], npush) + end else + begin match src with + | Reg rs -> (overwritten, [], make_push rs@pushes, npush+1) + | Stk o -> (overwritten, [], + LLoad(reg_tmp1, reg_fp, (Archi.wordsize ()) * o, (archi_mas ())) + ::make_push reg_tmp1 @ pushes, + npush+1) + end + in + OK (overwritten, instrs@l, pushes, npush) + ) (OK ([], [], [], 0)) ltl_args >>= + fun (overwritten, instrs, pushes, npush) -> + OK (instrs@pushes, npush) + +let written_rtl_regs_instr (i: rtl_instr) = + match i with + | Rbinop (_, rd, _, _) + | Runop (_, rd, _) + | Rconst (rd, _) + | Rmov (rd, _) -> Set.singleton rd + | Rprint _ + | Rret _ + | Rlabel _ + | Rbranch (_, _, _, _) + | Rjmp _ -> Set.empty + +let read_rtl_regs_instr (i: rtl_instr) = + match i with + | Rbinop (_, _, rs1, rs2) + | Rbranch (_, rs1, rs2, _) -> Set.of_list [rs1; rs2] + + | Rprint rs + | Runop (_, _, rs) + | Rmov (_, rs) + | Rret rs -> Set.singleton rs + + | Rlabel _ + | Rconst (_, _) + | Rjmp _ -> Set.empty + +let read_rtl_regs (l: rtl_instr list) = + List.fold_left (fun acc i -> Set.union acc (read_rtl_regs_instr i)) + Set.empty l + +let written_rtl_regs (l: rtl_instr list) = + List.fold_left (fun acc i -> Set.union acc (written_rtl_regs_instr i)) + Set.empty l + +let rtl_to_ltl_registers allocation l = + Set.filter_map (fun rtlreg -> + match Hashtbl.find_option allocation rtlreg with + | Some (Stk ofs) -> None + | None -> None + | Some (Reg r) -> Some r) l + +(* Take the RTL registers used by RTL instructions in [l], apply allocation to + them. This gives a list of machine registers used by the LTL function. We + need to add also the registers that will be used for argument passing. *) + +let written_ltl_regs fname l allocation = + written_rtl_regs l |> rtl_to_ltl_registers allocation + +let caller_save live_out allocation rargs = + let live_after = live_out in + let live_after_ltl = live_after |> rtl_to_ltl_registers allocation in + overwritten_args rargs allocation >>= fun overwritten_args_tosave -> + let l = Set.union live_after_ltl overwritten_args_tosave in + OK (Set.intersect l (Set.of_list (arg_registers @ reg_tmp))) + +(* This generates LTL instructions for a given Linear/RTL instruction. In most + cases, the transformation amounts to 'loading' RTL registers in LTL locations + and emitting the straightforward corresponding LTL instructions. This uses + load_loc and store_loc, described above, a lot. The most interesting case is + call instructions. Indeed, in that case, we emit code for saving and + restoring caller-save registers before and after the call, respectively. The + registers to be saved are computed as the set of Risc-V registers marked as + caller-save (a0-a7,t0-t6) intersected with the registers that are read in the + code of the caller. (The rationale being, if we don't read this variable, + then we don't need its value to be preserved across function calls.) These + registers are saved at [fp - 8 * (curstackslot + 1)] *) +let ltl_instrs_of_linear_instr fname live_out allocation + numspilled epilogue_label ins = + let res = + match ins with + | Rbinop (b, rd, rs1, rs2) -> + load_loc reg_tmp1 allocation rs1 >>= fun (l1, r1) -> + load_loc reg_tmp2 allocation rs2 >>= fun (l2, r2) -> + store_loc reg_tmp1 allocation rd >>= fun (ld, rd) -> + OK (l1 @ l2 @ LBinop(b, rd, r1, r2) :: ld) + | Runop (u, rd, rs) -> + load_loc reg_tmp1 allocation rs >>= fun (l1,r1) -> + store_loc reg_tmp1 allocation rd >>= fun (ld, rd) -> + OK (l1 @ LUnop(u, rd, r1) :: ld) + | Rconst (rd, i) -> + store_loc reg_tmp1 allocation rd >>= fun (ld, rd) -> + OK (LConst(rd, i)::ld) + | Rbranch (cmp, rs1, rs2, s1) -> + load_loc reg_tmp1 allocation rs1 >>= fun (l1, r1) -> + load_loc reg_tmp2 allocation rs2 >>= fun (l2, r2) -> + OK (l1 @ l2 @ [LBranch(cmp, r1, r2, Format.sprintf "%s_%d" fname s1)]) + | Rjmp s -> OK [LJmp (Format.sprintf "%s_%d" fname s)] + | Rmov (rd, rs) -> + load_loc reg_tmp1 allocation rs >>= fun (ls, rs) -> + store_loc reg_tmp1 allocation rd >>= fun (ld, rd) -> + OK (ls @ LMov(rd, rs) :: ld) + | Rprint r -> + let (save_a_regs, arg_saved, ofs) = + save_caller_save + (range 32) + (- (numspilled+1)) in + let parameter_passing = + match Hashtbl.find_option allocation r with + | None -> Error (Format.sprintf "Could not find allocation for register %d\n" r) + | Some (Reg rs) -> OK [LMov(reg_a0, rs)] + | Some (Stk o) -> OK [LLoad(reg_a0, reg_fp, (Archi.wordsize ()) * o, (archi_mas ()))] + in + parameter_passing >>= fun parameter_passing -> + OK (LComment "Saving a0-a7,t0-t6" :: save_a_regs @ + LAddi(reg_sp, reg_s0, (Archi.wordsize ()) * (ofs + 1)) :: + parameter_passing @ + LCall "print" :: + LComment "Restoring a0-a7,t0-t6" :: restore_caller_save arg_saved) + + | Rret r -> + load_loc reg_tmp1 allocation r >>= fun (l,r) -> + OK (l @ [LMov (reg_ret, r) ; LJmp epilogue_label]) + | Rlabel l -> OK [LLabel (Format.sprintf "%s_%d" fname l)] + in + res >>= fun l -> + OK (LComment (Format.asprintf "#<span style=\"background: pink;\"><b>Linear instr</b>: %a #</span>" (Rtl_print.dump_rtl_instr fname (None, None) ~endl:"") ins)::l) + +(** Retrieves the location of the n-th argument (in the callee). The first 8 are + passed in a0-a7, the next are passed on the stack. *) +let retrieve_nth_arg n numcalleesave = + let thr = number_of_arguments_passed_in_registers in + if n < thr + then Reg (n + starting_arg_register) + else Stk ((numcalleesave + n-thr)) + +(* This function creates a LTL function out of a Linear function. In addition to + using machine registers instead of ideal registers, it deals with saving and + restoring callee-save registers. The function prologue consists of saving + these callee-save registers, making the frame pointer to sp, and saving space + on the stack for the variables that would reside on the stack (i.e. spilled - + they go from [s0] to [s0+curstackslot] (curstackslot is negative, and + returned by the register allocation)). The function epilogue restores sp to + the value stored in s0 (fp), restore all the callee-save registers and jumps + back to [ra]. *) +let ltl_fun_of_linear_fun linprog + (({ linearfunargs; linearfunbody; linearfuninfo }): linear_fun) fname + (live_in,live_out) (allocation, numspilled) = + List.iteri (fun i pr -> + Hashtbl.replace allocation pr (retrieve_nth_arg i 0) + ) linearfunargs; + let written_regs = Set.add reg_ra + (Set.add reg_fp + (written_ltl_regs fname linearfunbody allocation)) in + let callee_saved_regs = + Set.intersect (Set.of_list callee_saved) written_regs in + List.iteri (fun i pr -> + Hashtbl.replace allocation pr + (retrieve_nth_arg i (Set.cardinal callee_saved_regs)) + ) linearfunargs; + + let max_label = + List.fold_left (fun acc i -> + match i with + Rlabel l -> Stdlib.max l acc + | _ -> acc) + 0 linearfunbody in + let epilogue_label = Format.sprintf "%s_%d" fname (max_label + 1) in + let prologue = + List.concat (List.map make_push (Set.to_list callee_saved_regs)) @ + LMov (reg_fp, reg_sp) :: + make_sp_sub (numspilled * (Archi.wordsize ())) @ + [LComment "end prologue"] in + let epilogue = LLabel epilogue_label :: + LMov(reg_sp, reg_fp) :: + List.concat (List.map make_pop + (List.rev (Set.to_list callee_saved_regs))) @ + [LJmpr reg_ra] in + list_map_resi (fun i -> + ltl_instrs_of_linear_instr fname (Hashtbl.find_default live_out i Set.empty) + allocation numspilled epilogue_label) linearfunbody + >>= fun l -> + let instrs = List.concat l + in + OK { + ltlfunargs = List.length linearfunargs; + ltlfunbody = prologue @ instrs @ epilogue; + ltlfuninfo = linearfuninfo; + ltlregalloc = Hashtbl.bindings allocation; + } + + +let allocable_registers = Set.of_list [ + reg_s1; reg_s2; reg_s3; reg_s4; reg_s5; + reg_s6; reg_s7; reg_s8; reg_s9; reg_s10; reg_s11; + reg_t2; reg_t3; reg_t4; reg_t5; reg_t6; +] + +let ltl_prog_of_linear lp = + let lives = liveness_linear_prog lp in + let allocations = regalloc lp lives allocable_registers in + let prog = list_map_res (function + (fname, Gfun f) -> + let f_alloc = + match Hashtbl.find_option allocations fname with + | None -> (Hashtbl.create 0, 0) + | Some (rig, allocation, next_stack_slot) -> (allocation, - next_stack_slot - 1) + in + let f_lives = + match Hashtbl.find_option lives fname with + | None -> (Hashtbl.create 0, Hashtbl.create 0) + | Some x -> x + in + ltl_fun_of_linear_fun lp f fname f_lives f_alloc >>= fun f -> + OK (fname, Gfun f) + ) lp in + prog + +let pass_ltl_gen linear = + match ltl_prog_of_linear linear with + | Error msg -> record_compile_result ~error:(Some msg) "LTL"; Error msg + | OK ltl -> + record_compile_result "LTL"; + dump !ltl_dump dump_ltl_prog ltl + (fun file () -> add_to_report "ltl" "LTL" (Code (file_contents file))); + OK ltl diff --git a/src/ltl_print.ml b/src/ltl_print.ml new file mode 100644 index 0000000000000000000000000000000000000000..4c6e20482158d437b792b44a788beb58ac7524d8 --- /dev/null +++ b/src/ltl_print.ml @@ -0,0 +1,122 @@ +open Batteries +open Elang +open Ltl +open Prog +open Rtl_print +open Utils +open Regalloc + +(* Printing LTL registers, locations, instructions. *) +let string_of_reg = function + | 0 -> "zero" + | 1 -> "ra" + | 2 -> "sp" + | 3 -> "gp" + | 4 -> "tp" + | 5 -> "t0" + | 6 -> "t1" + | 7 -> "t2" + | 8 -> "s0" + | 9 -> "s1" + | 10 -> "a0" + | 11 -> "a1" + | 12 -> "a2" + | 13 -> "a3" + | 14 -> "a4" + | 15 -> "a5" + | 16 -> "a6" + | 17 -> "a7" + | 18 -> "s2" + | 19 -> "s3" + | 20 -> "s4" + | 21 -> "s5" + | 22 -> "s6" + | 23 -> "s7" + | 24 -> "s8" + | 25 -> "s9" + | 26 -> "s10" + | 27 -> "s11" + | 28 -> "t3" + | 29 -> "t4" + | 30 -> "t5" + | 31 -> "t6" + | _ -> "undefreg" + +let print_reg r = + string_of_reg r + +let print_loc loc = + match loc with + | Stk o -> Format.sprintf "stk(%d)" o + | Reg r -> print_reg r + +let print_binop (b: binop) = + match b with + | Elang.Eadd -> "add" + | Elang.Emul -> "mul" + | Elang.Emod -> "mod" + | Elang.Exor -> "xor" + | Elang.Ediv -> "div" + | Elang.Esub -> "sub" + | Elang.Eclt -> "clt" + | Elang.Ecle -> "cle" + | Elang.Ecgt -> "cgt" + | Elang.Ecge -> "cge" + | Elang.Eceq -> "ceq" + | Elang.Ecne -> "cne" + + +let print_unop (u: unop) = + match u with + | Elang.Eneg -> "neg" + +let dump_ltl_instr oc (i: ltl_instr) = + match i with + | LAddi(rd, rs, i) -> + Format.fprintf oc "%s <- addi %s, %d" (print_reg rd) (print_reg rs) i + | LSubi(rd, rs, i) -> + Format.fprintf oc "%s <- subi %s, %d" (print_reg rd) (print_reg rs) i + | LBinop(b, rd, rs1, rs2) -> + Format.fprintf oc "%s <- %s %s, %s" + (print_reg rd) (print_binop b) ( print_reg rs1) (print_reg rs2) + | LUnop(u, rd, rs) -> + Format.fprintf oc "%s <- %s %s" + (print_reg rd) (print_unop u) (print_reg rs) + | LStore(rt, i, rs, sz) -> + Format.fprintf oc "%s%s[%d] <- %s" (print_reg rt) (string_of_mem_access_size sz) i (print_reg rs) + | LLoad(rd, rt, i, sz) -> + Format.fprintf oc "%s <- %s%s[%d]" (print_reg rd) (print_reg rt) (string_of_mem_access_size sz) i + | LMov(rd, rs) -> + Format.fprintf oc "%s <- %s" (print_reg rd) (print_reg rs) + | LLabel l -> + Format.fprintf oc "%s" l + | LJmp l -> Format.fprintf oc "j %s" l + | LJmpr r -> Format.fprintf oc "jmpr %s" (print_reg r) + | LConst (rd, i) -> Format.fprintf oc "%s <- %d" (print_reg rd) i + | LComment l -> Format.fprintf oc "<span style=\"color: gray;\">; %s</span>" l + | LBranch(cmp, rs1, rs2, s) -> + Format.fprintf oc "%s(%s,%s) ? j %s" + (print_cmpop cmp) (print_reg rs1) (print_reg rs2) s + | LCall fname -> + Format.fprintf oc "call %s" fname + | LHalt -> Format.fprintf oc "halt" + +let dump_ltl_instr_list fname oc l = + List.iteri (fun i ins -> + Format.fprintf oc "%s:%d: " fname i; + dump_ltl_instr oc ins; + Format.fprintf oc "\n") l + +let dump_allocation oc fname alloc = + Format.fprintf oc "// In function %s\n" fname; + List.iter (fun (linr,ltlloc) -> + Format.fprintf oc "// LinReg %d allocated to %s\n" linr (print_loc ltlloc) + ) alloc + +let dump_ltl_fun oc fname lf = + dump_allocation oc fname lf.ltlregalloc; + Format.fprintf oc "%s:\n" fname; + dump_ltl_instr_list fname oc lf.ltlfunbody + +let dump_ltl_prog oc lp = + dump_prog dump_ltl_fun oc lp diff --git a/src/ltl_run.ml b/src/ltl_run.ml new file mode 100644 index 0000000000000000000000000000000000000000..187fd87e33b8381c75061da070cbeb72246027fc --- /dev/null +++ b/src/ltl_run.ml @@ -0,0 +1,234 @@ +open Batteries +open BatList +open Batteries +open BatList +open Prog +open Elang +open Cfg +open Elang_run +open Cfg_run +open Rtl +open Rtl_print +open Rtl_run +open Linear +open Ltl +open Utils +open Builtins + +(* To execute LTL functions, we need to place instructions in memory, in + particular because the [Jmpr] instruction jumps to an address contained in a + register. + + The [fun_location] type records for a given function: + - its starting and ending position in the code : [funstart] and [funend]; + - [funinfo] : a mapping from source variable names to RTL registers + - [funregalloc] : a mapping from RTL registers to LTL locations. + + The [ltl_state] record gives the state of a program being executed: + - [code] gives the LTL instruction at every position in the code; + - [funs] gives a mapping from function names to [fun_location]s; + - [regs] gives a mapping from LTL registers to their values; + - [mem] is a memory state; + - [numstep] is the number of steps taken in the current execution (useful for + debugging). +*) + +type fun_location = { + funstart: int; + funend: int; + funinfo : (string * int) list; + funregalloc: (int * Regalloc.loc) list +} + +type ltl_state = { + code: ltl_instr Array.t; + funs: (string, fun_location) Hashtbl.t; + regs: int array; + labels : (string, int) Hashtbl.t; + mem: Mem.t; + numstep: int ref; +} + +(* Finds the position of a label in the code. *) +let find_label (labels: (string, int) Hashtbl.t) (l: string) = + match Hashtbl.find_option labels l with + | Some ip -> OK ip + | None -> Error (Format.sprintf "Label %s not found." l) + +(* For most instructions, the next instruction to execute is the one at [ip + + 1]. *) +let next ip = OK (Some (ip + 1)) + +(* Helper function to get value of register [r] in state [st]. *) +let get_reg st r f = + f (Array.get st.regs r) + +(* Execution of one LTL instruction. + + - [oc] : the output channel where to print output of the program + - [ip] : the instruction pointer : which instruction should we execute ? + - [st] : an [ltl_state] + + Returns : + - [OK (Some ip)] : execution should continue at ip [ip]. + - [OK None] : execution is finished + - [Error msg] : something wrong happened. +*) + +let exec_ltl_instr oc ip st : (int option) res = + let open Utils in + match Array.get st.code ip with + | exception Invalid_argument _ -> Error (Format.sprintf + "Could not find next instruction to execute at ip=%d \ + [in exec_ltl_instr]" ip) + | LAddi(rd, rs, i) -> + get_reg st rs $ fun vs -> + Array.set st.regs rd (vs + i); + next ip + | LSubi(rd, rs, i) -> + get_reg st rs $ fun vs -> + Array.set st.regs rd (vs - i); + next ip + | LBinop(b, rd, rs1, rs2) -> + get_reg st rs1 $ fun vs1 -> + get_reg st rs2 $ fun vs2 -> + Array.set st.regs rd (eval_binop b vs1 vs2); + next ip + | LUnop(u, rd, rs) -> + get_reg st rs $ fun vs -> + Array.set st.regs rd (eval_unop u vs); + next ip + | LStore(rt, i, rs, sz) -> + get_reg st rt $ fun vt -> + get_reg st rs $ fun vs -> + Mem.write_bytes st.mem (vt + i) (split_bytes (size_of_mas sz) vs) >>= fun _ -> + next ip + | LLoad(rd, rt, i, sz) -> + get_reg st rt $ fun vt -> + Mem.read_bytes_as_int st.mem (vt + i) (size_of_mas sz) >>= fun (v) -> + Array.set st.regs rd v; + next ip + | LMov(rd, rs) -> + get_reg st rs $ fun vs -> + Array.set st.regs rd vs; + next ip + | LLabel l -> next ip + | LJmp l -> find_label st.labels l >>= fun n -> OK (Some n) + | LJmpr r -> + get_reg st reg_ra $ fun ra -> + OK (Some ra) + | LConst (rd, i) -> Array.set st.regs rd i; next ip + | LComment _ -> next ip + | LBranch(cmp, rs1, rs2, s) -> + get_reg st rs1 $ fun vs1 -> + get_reg st rs2 $ fun vs2 -> + let b = eval_rtl_cmp cmp vs1 vs2 in + if b + then find_label st.labels s >>= fun n -> OK (Some n) + else next ip + | LCall callee_name -> + begin match Hashtbl.find_option st.funs callee_name with + Some {funstart} -> + Array.set st.regs reg_ra (ip+1); + OK (Some funstart) + | None -> + do_builtin oc st.mem callee_name + (list_ints_desc number_of_arguments_passed_in_registers |> List.rev |> + List.map (fun i -> i + starting_arg_register) |> + List.map (fun i -> Array.get st.regs i)) >>= + fun v -> + begin match v with + | None -> () + | Some v -> Array.set st.regs reg_ret v + end; + next ip + end + | LHalt -> OK None + +(* Initialize regs [0,n[ *) +let rec init_regs n = + let regs = Array.init n (fun _ -> 0) in + regs + +let init_state memsize lp params = + let lp = (("__halt", Gfun {ltlfunargs = 0; + ltlfunbody = [LHalt]; + ltlfuninfo = []; + ltlregalloc = []; + })::lp) in + let codesize = List.fold_left (fun sz (name, def) -> + match def with + | Gfun f -> + sz + List.length f.ltlfunbody + ) 0 lp in + let code : ltl_instr Array.t = Array.init codesize (fun _ -> LHalt) in + let funs : (string, fun_location) Hashtbl.t = Hashtbl.create 17 in + let labels : (string, int) Hashtbl.t = Hashtbl.create 17 in + let mem = Mem.init memsize in + let regs = init_regs 32 in + let sp = memsize in + Array.set regs reg_sp sp; + Array.set regs reg_fp sp; + Array.set regs reg_ra 0; + + let codesize = List.fold_left (fun ofs (name, def) -> + match def with + | Gfun f -> + let funstart = ofs in + let funend = List.fold_left (fun ofs ins -> + code.(ofs) <- ins; + (* write dummy instruction in memory. *) + Mem.write_char mem ofs 0x90 >>! fun _ -> + begin match ins with + | LLabel l -> Hashtbl.replace labels l ofs + | _ -> () + end; + ofs + 1 + ) ofs f.ltlfunbody in + Hashtbl.replace funs name { + funstart ; funend; + funinfo = f.ltlfuninfo; + funregalloc = f.ltlregalloc + }; + funend + ) 0 lp + in + + let codesize = (codesize / 8 + 1) * 8 in + Array.set regs reg_gp codesize; + + (* write arguments, relative to sp *) + List.iteri (fun i p -> + if i >= number_of_arguments_passed_in_registers + then begin + let sp = Array.get regs reg_sp - (Archi.wordsize ()) in + Array.set regs reg_sp sp; + Mem.write_bytes mem sp (split_bytes (Archi.wordsize ()) p) >>! + ignore + end else + begin + Array.set regs (starting_arg_register + i) p + end + ) params; + let mem_next = ref (codesize + 8) in + Mem.write_bytes mem codesize (split_bytes (Archi.wordsize ()) !mem_next) >>! + fun _ -> + Printf.eprintf "numlabels = %d\n" (Hashtbl.length labels); + Printf.eprintf "labels = %s\n" (Hashtbl.keys labels |> List.of_enum |> String.concat ", "); + { code; funs; mem ; labels; regs ; numstep = ref 0} + + +let rec exec_ltl_at oc ip st = + match exec_ltl_instr oc ip st with + OK (Some ip) -> exec_ltl_at oc ip st + | OK None -> OK st + | Error msg -> Error msg + +let exec_ltl_prog oc lp memsize params : int option res = + let st = init_state memsize lp params in + match Hashtbl.find_option st.funs "main" with + | None -> Error (Format.sprintf "Could not find function main.") + | Some {funstart} -> + exec_ltl_at oc funstart st >>= fun st -> + OK (Some (Array.get st.regs reg_ret)) + diff --git a/src/main.ml b/src/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..92b967f912e7519179fbca97c174b70313980d05 --- /dev/null +++ b/src/main.ml @@ -0,0 +1,228 @@ +open Batteries +open BatList +open Symbols +open Parser +open Ast +open Elang +open Elang_run +open Elang_print +open Elang_gen +open Cfg +open Cfg_run +open Cfg_print +open Cfg_gen +open Cfg_constprop +open Cfg_dead_assign +open Cfg_nop_elim +open Rtl +open Rtl_run +open Rtl_print +open Rtl_gen +open Linear +open Linear_run +open Linear_print +open Linear_gen +open Linear_liveness +open Linear_dse +open Ltl +open Ltl_run +open Ltl_print +open Ltl_gen +open Ltl_debug +open Riscv +open Utils +open Archi +open Report +open Options +open Lexer_generator +open Tokenize + +let speclist = + [ + ("-show-tokens", Arg.String (fun s -> show_tokens := Some s), "Output the list of tokens recognized by the lexer."); + ("-ast-tree", Arg.String (fun s -> ast_tree := Some s), "Output DOT file for dumping the tree."); + ("-ast-dump", Arg.Set ast_dump, "Dumps the tree in textual form."); + ("-e-dump", Arg.String (fun s -> e_dump := Some s), "Output Elang file."); + ("-e-run", Arg.Set e_run, "Run Elang program."); + ("-cfg-dump", Arg.String (fun s -> cfg_dump := Some s), "Output CFG file."); + ("-cfg-run", Arg.Set cfg_run, "Run CFG program."); + ("-cfg-run-after-cp", Arg.Set cfg_run_after_cp, "Run CFG program after constant propagation."); + ("-cfg-run-after-dae", Arg.Set cfg_run_after_dae, "Run CFG program after dead assign elimination."); + ("-cfg-run-after-ne", Arg.Set cfg_run_after_ne, "Run CFG program after nop elimination."); + ("-rtl-dump", Arg.String (fun s -> rtl_dump := Some s), "Output RTL file."); + ("-rtl-run", Arg.Set rtl_run, "Run RTL program."); + ("-linear-dump", Arg.String (fun s -> linear_dump := Some s), "Output Linear file."); + ("-linear-run", Arg.Set linear_run, "Run Linear program."); + ("-linear-run-after-dse", Arg.Set linear_run_after_dse, "Run Linear program after dead store elimination."); + ("-ltl-dump", Arg.String (fun s -> ltl_dump := Some s), "Output LTL file."); + ("-ltl-run", Arg.Set ltl_run, "Run LTL program."); + ("-ltl-debug", Arg.Set ltl_debug, "Debug LTL program."); + ("-riscv-dump", Arg.String (fun s -> riscv_dump := Some s), "Output RISC-V file."); + ("-riscv-run", Arg.Set riscv_run, "Run RISC-V program."); + ("-no-dump", Arg.Set no_dump, "Do not dump anything but the .s file"); + ("-no-dot", Arg.Set no_dot, "Do not call dot on CFG dumps (default false)"); + ("-clever-regalloc", Arg.Unit (fun () -> naive_regalloc := false), "Use the graph coloring algorithm for register allocation."); + ("-naive-regalloc", Arg.Unit (fun () -> naive_regalloc := true), + "Use the naive algorithm for register allocation (all pseudo-registers go on the stack)."); + ("-no-cfg-constprop", Arg.Set no_cfg_constprop, "Disable CFG constprop"); + ("-no-cfg-dae", Arg.Set no_cfg_dae, "Disable CFG Dead Assign Elimination"); + ("-no-cfg-ne", Arg.Set no_cfg_ne, "Disable CFG Nop Elimination"); + ("-no-linear-dse", Arg.Set no_linear_dse, "Disable Linear Dead Store Elimination"); + ("-rig-dump", Arg.String (fun s -> rig_dump := Some s), + "Path to output the register interference graph"); + ("-all-run", Arg.Unit (fun () -> + e_run := true; + cfg_run := true; + cfg_run_after_cp := true; + cfg_run_after_dae := true; + cfg_run_after_ne := true; + rtl_run := true; + linear_run := true; + linear_run_after_dse := true; + ltl_run := true; + riscv_run := true; + ), "Run all intermediate languages"); + ("-heap", Arg.Set_int heapsize, "Heap size"); + ("-show", Arg.Set show, "Show Results"); + ("-m32", Arg.Unit (fun _ -> Archi.archi := A32), "32bit mode"); + ("-f", Arg.String (fun s -> input_file := Some s), "file to compile"); + ("-alloc-order-ts", Arg.Unit (fun _ -> Options.alloc_order_st := false), "Allocate t regs before s regs"); + ("-json", Arg.String (fun s -> output_json := s), "Output JSON summary"); + ("-nostart", Arg.Set nostart, "Don't output _start code."); + ("-nostats", Arg.Set nostats, "Don't output stats."); + ("-nomul", Arg.Unit (fun _ -> has_mul := false), "Target architecture without mul instruction."); + ("-lex-hand", Arg.Unit (fun _ -> Options.handwritten_lexer := true), "Use handwritten lexer generator"); + ("-lex-auto", Arg.Unit (fun _ -> Options.handwritten_lexer := false), "Use OCamlLex lexer"); + ("-linux", Arg.Unit (fun _ -> target := Linux), "emit linux syscalls"); + ("-xv6", Arg.Unit (fun _ -> target := Xv6), "emit xv6 syscalls"); + ("--", Arg.Rest (fun p -> params := int_of_string p::!params), "Run parameters.") + ] + +let set_default r v suff = + match !r with + None -> r := Some (v ^ suff) + | _ -> () + +let compile_rv basename asmfile () = + if not !Options.nostart then begin + let obj_file_prog = Filename.temp_file ~temp_dir:"/tmp" "" ".o" in + let cmdas_prog = Format.sprintf "%s -I%s -o %s %s" + (Archi.assembler ()) + (Archi.runtime_lib_include_path ()) + obj_file_prog asmfile in + let obj_file_lib = Filename.temp_file ~temp_dir:"/tmp" "" ".o" in + let cmdas_lib = Format.sprintf "%s -I%s -o %s %s" + (Archi.assembler ()) + (Archi.runtime_lib_include_path ()) + obj_file_lib (Archi.runtime_lib_path ()) in + let cmdld = Format.sprintf "%s -T %s/link.ld %s %s -o %s.exe" + (Archi.linker ()) + Config.runtime_dir + obj_file_prog obj_file_lib + basename in + Printf.printf "AS: %s\n" cmdas_prog; + Printf.printf "AS: %s\n" cmdas_lib; + Printf.printf "LD: %s\n" cmdld; + let out_as_prog = cmd_to_list cmdas_prog in + let out_as_lib = cmd_to_list cmdas_lib in + let out_ld = cmd_to_list cmdld in + let out = out_as_prog @ out_as_lib @ out_ld in + match out with + [] -> None + | _ -> Some (String.concat "\n" out) + end + else None + +let exec_rv_prog ltl basename oc rvp heapsize params = + let rvp = + match rvp with + Some rvp -> rvp + | None -> + let f = Filename.temp_file ~temp_dir:"/tmp" basename ".s" in + f + in + let error = ref None in + dump (Some rvp) (dump_riscv_prog !Archi.target) ltl (fun file () -> + error := compile_rv basename file ()); + match !error with + | Some e -> Error ("RiscV generation error:\n" ^e) + | None -> + let l = cmd_to_list (Format.sprintf "%s \"%s.exe\" %s" (Archi.qemu ()) basename + (params |> List.map string_of_int |> String.concat " " )) in + try + let all_but_last = l |> List.rev |> List.tl |> List.rev in + all_but_last |> print_list (fun oc -> Format.fprintf oc "%s") "" "\n" "" oc; + let ret = l |> List.last |> int_of_string in + OK (Some ret) + with _ -> OK None + + +let _ = + Arg.parse speclist (fun s -> ()) "Usage"; + Archi.archi := !archi; + match !input_file with + | None -> failwith "No input file specified.\n" + | Some input -> + add_to_report "Source" "Source" (Code (file_contents input)); + + match Filename.chop_suffix_opt ~suffix:".e" input with + None -> failwith + (Format.sprintf "File (%s) should end in .e" input) + | Some basename -> + params := List.rev !params; + set_default riscv_dump basename ".s"; + if not !no_dump then begin + set_default show_tokens basename ".lex"; + set_default ast_tree basename ".ast"; + set_default e_dump basename ".e.dump"; + set_default cfg_dump basename ".cfg"; + set_default rtl_dump basename ".rtl"; + set_default linear_dump basename ".linear"; + set_default rig_dump basename ".rig"; + set_default ltl_dump basename ".ltl"; + end; + + Printexc.record_backtrace true; + let compiler_res = + try + pass_tokenize input >>= fun tokens -> + pass_parse tokens >>= fun (ast, _) -> + pass_elang ast >>= fun ep -> + run "Elang" !e_run eval_eprog ep; + pass_cfg_gen ep >>= fun cfg -> + run "CFG" !cfg_run eval_cfgprog cfg; + pass_constant_propagation cfg >>= fun cfg -> + run "CFG after constant_propagation" !cfg_run_after_cp eval_cfgprog cfg; + pass_dead_assign_elimination cfg >>= fun cfg -> + run "CFG after dead_assign_elimination" !cfg_run_after_dae eval_cfgprog cfg; + pass_nop_elimination cfg >>= fun cfg -> + run "CFG after nop_elimination" !cfg_run_after_ne eval_cfgprog cfg; + pass_rtl_gen cfg >>= fun rtl -> + run "RTL" !rtl_run exec_rtl_prog rtl; + pass_linearize rtl >>= fun (linear, lives) -> + run "Linear" !linear_run exec_linear_prog linear; + pass_linear_dse linear lives >>= fun linear -> + run "Linear after DSE" !linear_run_after_dse exec_linear_prog linear; + pass_ltl_gen linear + with e -> + let emsg = Printexc.to_string e ^ "\n" ^ Printexc.get_backtrace () in + record_compile_result ~error:(Some emsg) "global"; + Error emsg + in + begin + match compiler_res with + | Error msg -> () + | OK ltl -> + run "LTL" !ltl_run (exec_ltl_prog) ltl; + (if !ltl_debug then debug_ltl_prog input ltl !heapsize !params); + dump !riscv_dump (dump_riscv_prog !Archi.target) ltl (fun file () -> + add_to_report "riscv" "RISC-V" (Code (file_contents file)); + ignore (compile_rv basename file ())); + if not !Options.nostart then begin + run "Risc-V" !riscv_run (exec_rv_prog ltl basename) !riscv_dump + end + end; + dump (Some !output_json) (fun oc p -> + Format.fprintf oc "%s\n" p + ) (json_output_string ()) (fun _ () -> ()); + make_report input report () diff --git a/src/options.ml b/src/options.ml new file mode 100644 index 0000000000000000000000000000000000000000..b55e3792623d2b5f65fdb9f184adcf0812054e57 --- /dev/null +++ b/src/options.ml @@ -0,0 +1,42 @@ + +let heapsize = ref 10000 +let show_tokens : string option ref = ref None +let ast_tree : string option ref = ref None +let ast_dump = ref false +let e_dump : string option ref = ref None +let e_run = ref false +let cfg_dump : string option ref = ref None +let cfg_run = ref false +let cfg_run_after_cp = ref false +let cfg_run_after_dae = ref false +let cfg_run_after_ne = ref false +let rtl_dump : string option ref = ref None +let rtl_run = ref false +let linear_dump : string option ref = ref None +let linear_run = ref false +let linear_run_after_dse = ref false +let ltl_dump : string option ref = ref None +let ltl_run = ref false +let ltl_debug = ref false +let riscv_dump : string option ref = ref None +let riscv_run = ref false +let show = ref false +let params : int list ref = ref [] +let input_file : string option ref = ref None +let output_json : string ref = ref "-" +let nostart = ref false +let nostats = ref false +let has_mul = ref true +let no_dump = ref false +let no_dot = ref false +let no_cfg_constprop = ref false +let no_cfg_dae = ref false +let no_cfg_ne = ref false +let no_linear_dse = ref false + +let alloc_order_st = ref true +let naive_regalloc = ref true +let rig_dump : string option ref = ref None +let handwritten_lexer = ref Config.lex_hand +let alpaga_parser = ref Config.alpaga_parser +let timeout = ref 3.0 diff --git a/src/parser.ml b/src/parser.ml new file mode 100644 index 0000000000000000000000000000000000000000..2e2c5f02499871c8a8fb311480a970dcbca55089 --- /dev/null +++ b/src/parser.ml @@ -0,0 +1,108 @@ +open Yaccparser +open Generated_parser +open Report +open Utils +open Options +open Ast +open Symbols + + +let parse = parse_S + +let to_yacc_token = function +| SYM_EOF -> Yaccparser.SYM_EOF +| SYM_IDENTIFIER(s) -> Yaccparser.SYM_IDENTIFIER s +| SYM_INTEGER(i) -> Yaccparser.SYM_INTEGER i +| SYM_VOID -> Yaccparser.SYM_VOID +| SYM_CHAR -> Yaccparser.SYM_CHAR +| SYM_INT -> Yaccparser.SYM_INT +| SYM_STRUCT -> Yaccparser.SYM_STRUCT +| SYM_SEMICOLON -> Yaccparser.SYM_SEMICOLON +| SYM_POINT -> Yaccparser.SYM_POINT +| SYM_IF -> Yaccparser.SYM_IF +| SYM_ELSE -> Yaccparser.SYM_ELSE +| SYM_PLUS -> Yaccparser.SYM_PLUS +| SYM_MINUS -> Yaccparser.SYM_MINUS +| SYM_ASTERISK -> Yaccparser.SYM_ASTERISK +| SYM_DIV -> Yaccparser.SYM_DIV +| SYM_EQUALITY -> Yaccparser.SYM_EQUALITY +| SYM_ASSIGN -> Yaccparser.SYM_ASSIGN +| SYM_LPARENTHESIS -> Yaccparser.SYM_LPARENTHESIS +| SYM_RPARENTHESIS -> Yaccparser.SYM_RPARENTHESIS +| SYM_LBRACE -> Yaccparser.SYM_LBRACE +| SYM_RBRACE -> Yaccparser.SYM_RBRACE +| SYM_WHILE -> Yaccparser.SYM_WHILE +| SYM_RETURN -> Yaccparser.SYM_RETURN +| SYM_COMMA -> Yaccparser.SYM_COMMA +| SYM_LT -> Yaccparser.SYM_LT +| SYM_LEQ -> Yaccparser.SYM_LEQ +| SYM_GT -> Yaccparser.SYM_GT +| SYM_GEQ -> Yaccparser.SYM_GEQ +| SYM_NOTEQ -> Yaccparser.SYM_NOTEQ +| SYM_MOD -> Yaccparser.SYM_MOD +| SYM_BOOL_NOT -> Yaccparser.SYM_BOOL_NOT +| SYM_BOOL_AND -> Yaccparser.SYM_BOOL_AND +| SYM_BOOL_OR -> Yaccparser.SYM_BOOL_OR +| SYM_ARROW -> Yaccparser.SYM_ARROW +| SYM_BITWISE_OR -> Yaccparser.SYM_BITWISE_OR +| SYM_BITWISE_AND -> Yaccparser.SYM_BITWISE_AND +| SYM_BIT_NOT -> Yaccparser.SYM_BIT_NOT +| SYM_XOR -> Yaccparser.SYM_XOR +| SYM_CHARACTER(c) -> Yaccparser.SYM_CHARACTER c +| SYM_STRING(s) -> Yaccparser.SYM_STRING s +| SYM_LBRACKET -> Yaccparser.SYM_LBRACKET +| SYM_RBRACKET -> Yaccparser.SYM_RBRACKET +| SYM_ALLOC -> Yaccparser.SYM_ALLOC +| SYM_PRINT -> Yaccparser.SYM_PRINT +| SYM_EXTERN -> Yaccparser.SYM_EXTERN +| SYM_INCLUDE(s) -> Yaccparser.SYM_INCLUDE s +| SYM_AMPERSAND -> Yaccparser.SYM_AMPERSAND + +let advance (l: ('a list * 'a list)) : ('a * ('a list * 'a list)) option = + let lbef, laft = l in + match laft with + [] -> None + | a::r -> Some (a, (a::lbef, r)) + +let back (l: ('a list * 'a list)) : ('a list * 'a list) option = + let lbef, laft = l in + match lbef with + [] -> None + | a::r -> Some ((r, a::laft)) + + + + +let menhir_parser (toks: (Symbols.token * Lexing.position option) list) () = + let mtoks = ref ([], toks) in + let get_tok () = + match advance !mtoks with + | None -> (Yaccparser.SYM_EOF, Lexing.dummy_pos, Lexing.dummy_pos) + | Some ((t, p), l) -> + mtoks := l; + (to_yacc_token t, Lexing.dummy_pos, Lexing.dummy_pos) + in + let mparser = MenhirLib.Convert.Simplified.traditional2revised Yaccparser.main in + match mparser get_tok with + | ast -> OK (ast, []) + | exception Yaccparser.Error -> + match back !mtoks with + | None -> Error (Printf.sprintf "Parser error while reading '???'\n") + | Some (lbef, laft) -> + Error (Printf.sprintf "Parser error while reading '%s'\n" + (String.concat " " (List.map (fun (t, _) -> string_of_symbol t) (take 20 laft))) + ) + +let parser toks () = + if !Options.alpaga_parser + then parse toks () + else menhir_parser toks () + +let pass_parse tokens = + match parser tokens () with + | Error msg -> record_compile_result ~error:(Some msg) "Parsing"; Error msg + | OK (ast, tokens) -> + record_compile_result "Parsing"; + dump !ast_tree draw_ast_tree ast (call_dot "ast" "AST"); + if !ast_dump then Format.printf "%s\n" (string_of_ast ast) else (); + OK (ast, tokens) diff --git a/src/prog.ml b/src/prog.ml new file mode 100644 index 0000000000000000000000000000000000000000..5da26745e8461b83070928a8f3647a567394b2c7 --- /dev/null +++ b/src/prog.ml @@ -0,0 +1,69 @@ +open Batteries +open Utils + +type mem_access_size = + | MAS1 + | MAS4 + | MAS8 + +let string_of_mem_access_size mas = + match mas with + | MAS1 -> "{1}" + | MAS4 -> "{4}" + | MAS8 -> "{8}" + +let mas_of_size n = + match n with + | 1 -> OK MAS1 + | 4 -> OK MAS4 + | 8 -> OK MAS8 + | _ -> Error (Printf.sprintf "Unknown memory access size for size = %d" n) + + +let size_of_mas mas = + match mas with + | MAS1 -> 1 + | MAS4 -> 4 + | MAS8 -> 8 + +let archi_mas () = + match !Archi.archi with + | A64 -> MAS8 + | A32 -> MAS4 + + +type 'a gdef = Gfun of 'a + +type 'a prog = (string * 'a gdef) list + + +let dump_gdef dump_fun oc gd = + match gd with + | (fname, Gfun f) -> + dump_fun oc fname f; + Format.fprintf oc "\n" + +let dump_prog dump_fun oc = + List.iter (dump_gdef dump_fun oc) + +type 'a state = { + env: (string, 'a) Hashtbl.t; + mem: Mem.t +} + +let init_state memsize = + { + mem = Mem.init memsize; + env = Hashtbl.create 17; + } + +let set_val env v i = + Hashtbl.replace env v i + +let get_val env v = + Hashtbl.find_option env v + +let find_function (ep: 'a prog) fname : 'a res = + match List.assoc_opt fname ep with + | Some (Gfun f) -> OK f + | _ -> Error (Format.sprintf "Unknown function %s\n" fname) diff --git a/src/regalloc.ml b/src/regalloc.ml new file mode 100644 index 0000000000000000000000000000000000000000..c68b9fdcb599dfb74185b339459873603ebc8e42 --- /dev/null +++ b/src/regalloc.ml @@ -0,0 +1,321 @@ +open Batteries +open Prog +open Linear +open Rtl +open Linear_liveness +open Utils +open Report +open Options + + + +(* Allocation de registres *) + +(* Nous allons procéder à l'allocation de registres, par coloration de graphe + d'interférences. + + Le but de l'allocateur est d'associer à chaque pseudo-registre utilisé dans + une fonction Linear, un emplacement (type [loc]). *) + +type loc = Reg of int | Stk of int + +(* Un emplacement (location en anglais) est soit un registre machine (identifié + par son numéro [r] entre 0 et 31 inclus) : [Reg r], soit un emplacement sur + la pile [Stk o] signifiant un décalage de [o] octets par rapport au pointeur + de trame présent dans le registre [s0] (aussi appelé [fp] pour frame + pointer). *) + +(* Nous vous fournissons, ci-dessous, une implémentation naïve qui évince tous + les pseudo-registres sur la pile. *) + +let regs_in_instr i = + Set.union (gen_live i) (kill_live i) + +let regs_in_instr_list (l: rtl_instr list) : reg Set.t = + List.fold_left + (fun acc i -> Set.union acc (regs_in_instr i)) + Set.empty l + +let regalloc_on_stack_fun (f: linear_fun) : ((reg, loc) Hashtbl.t * int)= + let allocation = Hashtbl.create 10 in + let regs = regs_in_instr_list f.linearfunbody in + let regs = Set.diff regs (Set.of_list f.linearfunargs) in + let next_stack_slot = + List.fold_left (fun next_stack_slot r -> + Hashtbl.replace allocation r (Stk (next_stack_slot)); + next_stack_slot - 1 + ) (-1) (Set.to_list regs) in + (allocation, next_stack_slot) + + +(* Nous allons maintenant construire un graphe d'interférence de registres + (register interference graph, ou rig). Le type d'un rig est donné par le type + OCaml [(reg, reg Set.t) Hashtbl.t], i.e. une table dont les clés sont des + registres et les valeurs sont des ensembles de registres qui "interfèrent" + avec le registre-clé. Cela correspond à la relation d'adjacence dans le + graphe d'interférence. *) + +(* La fonction [add_to_interf rig x y] ajoute [y] à la liste des registres qui + interfèrent avec [x] dans le graphe [rig]. + + On pourra utiliser la fonction [Hashtbl.modify_def] qui permet de modifier la + valeur associée à une clé. + + Par exemple, l'appel [Hashtbl.modify_def def k f rig] modifie la valeur + associée à la clé [k] dans le graphe [rig]. + + [f] est une fonction qui prend en entrée l'ancienne valeur, et qui retourne + la nouvelle valeur (type ['b -> 'b], si [rig] est de type [('a,'b) + Hashtbl.t], i.e. ['b] est le type des valeurs). + + [def] est la valeur par défaut donnée à [f] s'il n'existe pas d'ancienne + valeur pour la clé [k]. + + Attention, les interférences doivent exister dans les deux sens, i.e. si [x] + est dans la liste d'interférence de [y], alors [y] doit être dans la liste + d'interférence de [x]. + +*) + +let add_interf (rig : (reg, reg Set.t) Hashtbl.t) (x: reg) (y: reg) : unit = + (* TODO *) + () + + +(* [make_interf_live rig live] ajoute des arcs dans le graphe d'interférence + pour chaque paire de registres vivants en même temps à un point de programme. + *) +let make_interf_live + (rig: (reg, reg Set.t) Hashtbl.t) + (live : (int, reg Set.t) Hashtbl.t) : unit = + (* TODO *) + () + +(* [build_interference_graph live_out] construit, en utilisant les fonctions que + vous avez écrites, le graphe d'interférence en fonction de la vivacité des + variables à la sortie des nÅ“uds donné par [live_out]. + + Offert par la maison ! +*) +let build_interference_graph (live_out : (int, reg Set.t) Hashtbl.t) code : (reg, reg Set.t) Hashtbl.t = + let interf = Hashtbl.create 17 in + (* On ajoute un sommet pour chaque variable qui apparaît dans le programme. *) + Hashtbl.iter (fun _ s -> + Set.iter (fun v -> Hashtbl.replace interf v Set.empty) s + ) live_out; + make_interf_live interf live_out; +(* Les registres dans lesquels on écrit mais qui ne sont jamais vivants doivent être considérés comme en interférence avec tous les autres. *) + let written_regs = written_rtl_regs code in + let written_regs_never_live = + Hashtbl.fold (fun _ regset_live_together acc -> Set.diff acc regset_live_together) live_out + written_regs in + let other_regs = Hashtbl.keys interf |> Set.of_enum in + Set.iter (fun r -> + Set.iter (fun r_other -> + add_interf interf r r_other + ) other_regs + ) written_regs_never_live; + interf + +(* [remove_from_rig rig v] supprime le sommet [v] du graphe d'interférences + [rig]. *) +let remove_from_rig (rig : (reg, reg Set.t) Hashtbl.t) (v: reg) : unit = + (* TODO *) + () + + +(* Type représentant les différentes décisions qui peuvent être prises par + l'allocateur de registres. + + - [Spill r] signifie que le pseudo-registre [r] sera évincé (spillé) sur la pile. + + - [NoSpill r] signifie que le pseudo-registre [r] sera alloué dans un vrai + registre physique. +*) +type regalloc_decision = + Spill of reg + | NoSpill of reg + +(* Rappel de l'algorithme d'empilement des registres *) + +(* Une fois le graphe d'interférences construit, il nous faut parcourir ce + graphe afin de le colorer, avec [n] couleurs. On construit une pile de + [regalloc_decision]. + + Tant que le graphe n'est pas vide: + + - choisir un sommet [s] avec strictement moins de [n] voisins (ce sera le + travail de la fonction [pick_node_with_fewer_than_n_neighbors]), empiler la + décision [NoSpill s] et retirer [s] du graphe. + + - si aucun tel sommet n'existe dans le graphe, choisir un sommet [s] + correspondant à un registre que l'on évincera (ce sera le travail de la + fonction [pick_spilling_candidate]). Empiler la décision [Spill s] et retirer + [s] du graphe. + +*) + +(* [pick_node_with_fewer_than_n_neighbors rig n] choisit un nÅ“ud du graphe [rig] + possédant strictement moins de [n] voisins. Retourne [None] si aucun sommet + ne satisfait cette condition. *) +let pick_node_with_fewer_than_n_neighbors (rig : (reg, reg Set.t) Hashtbl.t) (n: int) : reg option = + (* TODO *) + None + +(* Lorsque la fonction précédente échoue (i.e. aucun sommet n'a moins de [n] + voisins), on choisit un pseudo-registre à évincer. + + Une heuristique possible consiste à évincer le pseudo-registre qui a le plus + de voisins dans le graphe [rig]. + + [pick_spilling_candidate rig] retourne donc le pseudo-registre [r] qui a le + plus de voisins dans [rig], ou [None] si [rig] est vide. *) +let pick_spilling_candidate (rig : (reg, reg Set.t) Hashtbl.t) : reg option = + (* TODO *) + None + +(* [make_stack rig stack ncolors] construit la pile, selon l'algorithme vu en + cours (slide 26 du cours "Allocation de registres" + présent sur Edunao.) *) +let rec make_stack (rig : (reg, reg Set.t) Hashtbl.t) (stack : regalloc_decision list) (ncolors: int) : regalloc_decision list = + (* TODO *) + stack + +(* Maintenant que nous avons une pile de [regalloc_decision], il est temps de + colorer notre graphe, i.e. associer une couleur (un numéro de registre + physique) à chaque pseudo-registre. Nous allons parcourir la pile et pour + chaque décision : + + -  [Spill r] : associer un emplacement sur la pile au pseudo-registre [r]. On + choisira l'emplacement [next_stack_slot]. + + - [NoSpill r] : associer une couleur (un registre) physique au + pseudo-registre [r]. On choisira une couleur qui n'est pas déjà associée à un + voisin de [r] dans [rig]. + + Cette fonction prend en entrée : + + - [allocation] : l'allocation courante, que l'on mettra à jour, et qui + permettra de trouver les couleurs qui ne sont pas déjà associées à des + voisins. + + - [rig] : le graphe d'interférence, qui permettra de connaître les voisins + d'un registre. + + - [all_colors] : l'ensemble des couleurs que l'on peut allouer. + + - [next_stack_slot] : le prochain emplacement disponible sur la pile. Cela + représentera des offsets négatifs par rapport à fp, on le mettra donc à jour + en décrémentant cette valeur de 1. + + - [decision] : une décision parmi celles empilées. + + Cette fonction met à jour [allocation] et renvoie la nouvelle valeur de + [next_stack_slot]. + +*) +let allocate (allocation: (reg, loc) Hashtbl.t) (rig: (reg, reg Set.t) Hashtbl.t) + (all_colors: int Set.t) + (next_stack_slot: int) (decision: regalloc_decision) + : int = + (* TODO *) + next_stack_slot + +(* [regalloc_fun f live_out all_colors] effectue l'allocation de registres pour + la fonction [f]. + + - [live_out] est un mapping des numéros d'instructions dans la fonction + Linear vers l'ensemble des registres vivants après cette instruction. + + - [all_colors] est l'ensemble des registres que l'on pourra utiliser. + + Cette fonction renvoie un triplet [(rig, allocation, next_stack_slot)] : + + - [rig] est le graphe d'interférences (simplement pour l'affichage) + + - [allocation] est l'allocation de registre que vous aurez construit + + - [next_stack_slot] est le prochain emplacement disponible sur la pile + (utilisé dans [ltl_gen], qui vous est fourni.) +*) +let regalloc_fun (f: linear_fun) + (live_out: (int, reg Set.t) Hashtbl.t) + (all_colors: int Set.t) : + (reg, reg Set.t) Hashtbl.t (* the RIG *) + * (reg, loc) Hashtbl.t (* the allocation *) + * int (* the next stack slot *) + = + let rig = build_interference_graph live_out f.linearfunbody in + + let allocation = Hashtbl.create 17 in + (* Les pseudo-registres qui contiennent les arguments sont traités séparément + dans [ltl_gen.ml]. On les enlève donc du graphe. *) + List.iter (fun p -> remove_from_rig rig p) f.linearfunargs; + (* On effectue une copie [g] du graphe d'interférence [rig]. En effet, comme + on va supprimer des sommets du graphe, on perd l'information + d'interférence, dont on aura besoin pour effectuer la coloration. *) + let g = Hashtbl.copy rig in + let stack = make_stack g [] (Set.cardinal all_colors) in + let next_stack_slot = + List.fold_left (fun next_stack_slot decision -> + allocate allocation rig all_colors next_stack_slot decision + ) (-1) stack in + (rig, allocation, next_stack_slot) + + +(* [dump_interf_graph fname rig] affiche les interférences associées à chaque + registre. Peut être utile pour le débogage ! Pas besoin d'inspecter cette + fonction, à moins qu'elle soit buggée... :-) *) +let dump_interf_graph oc (fname, rig, allocation) = + let colors = Array.of_list [ + "blue"; "red"; "orange"; "pink"; "green"; "purple"; + "brown"; "turquoise"; "gray"; "gold"; "darkorchid"; "bisque"; + "darkseagreen"; "cornsilk"; "burlywood"; "dodgerblue"; "antiquewhite"; "firebrick"; + "deepskyblue"; "darkolivegreen"; "hotpink"; "lightsalmon"; "magenta"; "lawngreen"; + ] in + let color_of_allocation r = + match Hashtbl.find_option allocation r with + | Some (Reg r) -> + Array.get colors (r mod Array.length colors) + | _ -> "white" + in + Format.fprintf oc "subgraph cluster_%s{\n" fname; + Format.fprintf oc "label=\"%s\";\n" fname; + Hashtbl.keys rig |> Enum.iter (fun r -> + Format.fprintf oc "%s_r%d [label=\"r%d\",style=filled,fillcolor=\"%s\"];\n" fname r r (color_of_allocation r) + ); + Hashtbl.iter + (fun i s -> + Set.iter (fun x -> + Format.fprintf oc "%s_r%d -> %s_r%d;\n" fname i fname x + ) s;) + rig; + Format.fprintf oc "}\n" + +let dump_interf_graphs oc allocations = + Format.fprintf oc "digraph RIGS {\n"; + Hashtbl.iter (fun fname (rig, allocation, next_stack_slot) -> + dump_interf_graph oc (fname, rig, allocation) + ) allocations; + Format.fprintf oc "}\n" + +(* On applique l'allocation de registres à tout le programme Linear, et on + affiche tout ça dans le rapport (la page HTML de chaque fichier). *) +let regalloc lp lives all_colors = + let allocations = Hashtbl.create 17 in + List.iter (function (fname,Gfun f) -> + begin match Hashtbl.find_option lives fname with + | Some (live_in, live_out) -> + let (rig, allocation, curstackslot) = + if !Options.naive_regalloc + then let (al, nss) = regalloc_on_stack_fun f in + (Hashtbl.create 0, al, nss) + else regalloc_fun f live_out all_colors + in + Hashtbl.replace allocations fname (rig, allocation, curstackslot) + | None -> () + end + ) lp; + dump !Options.rig_dump dump_interf_graphs allocations + (call_dot "regalloc" "Register Allocation"); + allocations diff --git a/src/report.ml b/src/report.ml new file mode 100644 index 0000000000000000000000000000000000000000..82fddb4da1531c5e29b7007a980d5cf00b188de7 --- /dev/null +++ b/src/report.ml @@ -0,0 +1,209 @@ +open Options +open Utils + +type html_node = + | Img of string + | Code of string + | Paragraph of string + | List of html_node list + +let rec print_html oc = function + Img s -> Printf.fprintf oc "<img src=\"%s\" />\n" s + | Code s -> Printf.fprintf oc "<pre>%s</pre>\n" s + | Paragraph s -> Printf.fprintf oc "<div>%s</div>\n" s + | List l -> List.iter (print_html oc) l + +type report_section = { sect_title: string; + sect_id: string; + sect_content: html_node + } + +let report = ref ([]: report_section list) + +let add_to_report id title content = + report := !report @ [{ sect_id = id; sect_title = title; sect_content = content }] + +let make_report filename report () = + let html = open_out (filename ^ ".html") in + Printf.fprintf html "\ +<html>\n\ + <head>\n\ + <link rel=\"stylesheet\" href=\"https://www.w3schools.com/w3css/4/w3.css\">\n\ + <script src=\"https://kit.fontawesome.com/1f5d81749b.js\" crossorigin=\"anonymous\"></script>\n\ + <style type=\"text/css\">\n\ + a.anchor {\n\ + display: block; \ + position: relative; \ + left: -250px; \ + visibility: hidden;\ + }\n\ + </style>\n\ + </head>\n\ + <body>\n\ +"; + Printf.fprintf html "<div \ + class=\"w3-container w3-cell\" \ + style=\"position: fixed; z-index: 1; top: 0; bottom: 0; width: 250px; overflow-y: scroll;\"\ + >\n <ul class=\"w3-ul\">\n"; + let t = Unix.time () in + let tm = Unix.localtime t in + let open Unix in + Printf.fprintf html "<li>%02d/%02d/%04d - %02dh%02d</li>" + tm.tm_mday + (tm.tm_mon + 1) + (tm.tm_year + 1900) + tm.tm_hour + tm.tm_min + ; + Printf.fprintf html " <li><a href=\"../results.html\"><i class=\"fa fa-home\"></i> Results</a></li>\n"; + List.iter + (fun { sect_id; sect_title; _ } -> + Printf.fprintf html " <li><a href=\"#%s\">%s</a></li>\n" sect_id sect_title + ) + !report; + Printf.fprintf html "</ul></div><div \ + class=\"w3-container w3-cell-row\" \ + style=\"margin-left: 250px;\"\ + ><a class=\"anchor\" id=\"top\"></a>"; + List.iter + (fun { sect_id; sect_title; sect_content } -> + Printf.fprintf html "<fieldset>\n\ + <a class=\"anchor\" id=\"%s\"></a>\n\ + <h3><a href=\"#top\">↑</a> %s</h3>\n\ + %a\n\ + </fieldset>\n" sect_id sect_title print_html sect_content + ) + !report; + Printf.fprintf html "\ +</div>\n\ +</body>\n\ +</html>"; + close_out html; + () + +let call_dot report_sectid report_secttitle file () : unit = + if not !Options.no_dot + then begin + let r = Sys.command (Format.sprintf "dot -Tsvg %s -o %s.svg" file file) in + add_to_report report_sectid report_secttitle (Img (Filename.basename file^".svg")); + ignore r + end + +(* *) + + +type run_result = { + step: string; + retval: int option; + output: string; + error: string option; + time: float; +} + +type compile_result = { + step: string; + error: string option; + data: Yojson.t +} + +type result = RunRes of run_result + | CompRes of compile_result + + +let results : result list ref = ref [] + + +let record_compile_result ?error:(error=None) ?data:(data=[]) step = + let data = if not !Options.nostats then `List data else `Null in + results := !results @ [CompRes { step; error; data}] + + +let kill pid sign = + try Unix.kill pid sign with + | Unix.Unix_error (e,f,p) -> + begin match e with + | ESRCH -> () + | _ -> Printf.printf "%s\n" ((Unix.error_message e)^"|"^f^"|"^p) + end + | e -> raise e + +let run_exn_to_error f x = + try f x with + | e -> Error (Printexc.to_string e) + +let timeout (f: 'a -> 'b res) (arg: 'a) (time: float) : ('b * string) res = + let pipe_r,pipe_w = Unix.pipe () in + (match Unix.fork () with + | 0 -> + let r = + run_exn_to_error f arg >>= fun v -> + OK (v, Format.flush_str_formatter ()) in + let oc = Unix.out_channel_of_descr pipe_w in + Marshal.to_channel oc r []; + close_out oc; + exit 0 + | pid0 -> + (match Unix.fork () with + | 0 -> Unix.sleepf time; + kill pid0 Sys.sigkill; + let oc = Unix.out_channel_of_descr pipe_w in + Marshal.to_channel oc (Error (Printf.sprintf "Timeout after %f seconds." time)) []; + close_out oc; + exit 0 + | _ -> let ic = Unix.in_channel_of_descr pipe_r in + let result = Marshal.from_channel ic in + result )) + +let run step flag eval p = + if flag then begin + let starttime = Unix.gettimeofday () in + let res = timeout + (fun (p, params) -> eval Format.str_formatter p !heapsize params) + (p, !params) + !Options.timeout in + let timerun = Unix.gettimeofday () -. starttime in + let rres = { step ; retval = None; output=""; error = None; time = timerun} in + let rres = + begin match res with + | OK (v, output) -> { rres with retval = v; output } + | Error msg -> { rres with error = Some msg } + end in + results := !results @ [RunRes rres]; + add_to_report step ("Run " ^ step) ( + Paragraph + ( + Printf.sprintf "With parameters : [%s]<br>\n" (String.concat"," (List.map string_of_int !params)) + ^ Printf.sprintf "Mem size : %d bytes<br>\n" !heapsize + ^ Printf.sprintf "Return value : %s<br>\n" (match rres.retval with | Some v -> string_of_int v | _ -> "none") + ^ Printf.sprintf "Output : <pre style=\"padding: 1em; background-color: #ccc;\">%s</pre>\n" rres.output + ^ + (match rres.error with + | Some msg -> Printf.sprintf "Error : <pre style=\"padding: 1em; background-color: #fcc;\">\n%s</pre>\n" msg + | _ -> "") + ^ Printf.sprintf "Time : %f seconds<br>\n" timerun + ) + ) + end + + +let json_output_string () = + let jstring_of_ostring o = + match o with + | None -> `Null + | Some s -> `String s + in + let j = `List (List.map (function + | RunRes { step; retval; output; error; time } -> + `Assoc [("runstep",`String step); + ("retval", match retval with Some r -> `Int r | None -> `Null); + ("output", `String output); + ("error", jstring_of_ostring error); + ("time", `Float time) + ] + | CompRes { step; error; data } -> + `Assoc [("compstep",`String step); + ("error", jstring_of_ostring error); + ("data", data) + ] + ) !results) in + (Yojson.pretty_to_string j) diff --git a/src/riscv.ml b/src/riscv.ml new file mode 100644 index 0000000000000000000000000000000000000000..c38276f44b0a8dea9de009f1daf0af7dccaebd35 --- /dev/null +++ b/src/riscv.ml @@ -0,0 +1,191 @@ +open Batteries +open BatList +open Elang +open Rtl +open Ltl +open Ltl_print +open Utils +open Prog +open Options +open Archi + +(* This file performs the translation from LTL programs to RISC-V assembly + programs. The languages are basically the same, so the only thing to do here + is to print LTL instructions in RISC-V assembly syntax. + + Another thing to do is to deal with command-line arguments. These are given + as strings and need to be converted into strings. That is the purpose of the + [riscv_load_args] function in this file. + + Finally, [riscv_prelude] gives an entry point in the program : a global + "_start" symbol is created, which points to startup code, whose job is the + following: + - initializes the global pointer (for "heap" allocation), + - sets up the stack, + - retrieves arguments, + - calls the "main" function of our program, + - prints the return value to the screen, + - and finally exits the program by issuing the appropriate system call. + +*) + +let riscv_of_cmp (cmp: rtl_cmp) = + match cmp with + | Rtl.Rclt -> "blt" + | Rtl.Rcle -> "ble" + | Rtl.Rcgt -> "bgt" + | Rtl.Rcge -> "bge" + | Rtl.Rceq -> "beq" + | Rtl.Rcne -> "bne" + +let print_binop (b: binop) = + match b with + | Elang.Eadd -> "add" + | Elang.Emul -> "mul" + | Elang.Emod -> "remu" + | Elang.Exor -> "xor" + | Elang.Ediv -> "divu" + | Elang.Esub -> "sub" + | _ -> failwith "Unexpected binop" + +let print_unop (u: unop) = + match u with + | Elang.Eneg -> "neg" + +let instrsuffix_of_size sz = + match sz with + | MAS1 -> 'b' + | MAS4 -> 'w' + | MAS8 -> 'd' + +let dump_riscv_instr oc (i: ltl_instr) = + match i with + | LAddi(rd, rs, i) -> + Format.fprintf oc "addi %s, %s, %d\n" (print_reg rd) (print_reg rs) i + | LSubi(rd, rs, i) -> + Format.fprintf oc "addi %s, %s, %d\n" (print_reg rd) (print_reg rs) (-i) + | LBinop(b, rd, rs1, rs2) -> + begin match b with + | Elang.Eclt -> + Format.fprintf oc "slt %s, %s, %s\n" + (print_reg rd) (print_reg rs1) (print_reg rs2) + | Elang.Ecgt -> + Format.fprintf oc "slt %s, %s, %s\n" + (print_reg rd) (print_reg rs2) (print_reg rs1) + | Elang.Ecle -> + (* 'rd <- rs1 <= rs2' == 'rd <- rs2 < rs1; rd <- seqz rd' *) + Format.fprintf oc "slt %s, %s, %s\n" + (print_reg rd) (print_reg rs2) (print_reg rs1); + Format.fprintf oc "seqz %s, %s\n" + (print_reg rd) (print_reg rd) + | Elang.Ecge -> + Format.fprintf oc "slt %s, %s, %s\n" + (print_reg rd) (print_reg rs1) (print_reg rs2); + Format.fprintf oc "seqz %s, %s\n" + (print_reg rd) (print_reg rd) + | Elang.Eceq -> + Format.fprintf oc "sub %s, %s, %s\n" + (print_reg rd) (print_reg rs1) (print_reg rs2); + Format.fprintf oc "seqz %s, %s\n" + (print_reg rd) (print_reg rd) + | Elang.Ecne -> + Format.fprintf oc "sub %s, %s, %s\n" + (print_reg rd) (print_reg rs1) (print_reg rs2); + Format.fprintf oc "snez %s, %s\n" + (print_reg rd) (print_reg rd) + | _ -> Format.fprintf oc "%s %s, %s, %s\n" + (print_binop b) (print_reg rd) (print_reg rs1) (print_reg rs2) + end + | LUnop(u, rd, rs) -> + Format.fprintf oc "%s %s, %s\n" + (print_unop u) (print_reg rd) (print_reg rs) + | LStore(rt, i, rs, sz) -> + let sz = instrsuffix_of_size sz in + Format.fprintf oc "s%c %s, %d(%s)\n" + sz (print_reg rs) i (print_reg rt) + | LLoad(rd, rt, i, sz) -> + let sz = (instrsuffix_of_size sz) in + Format.fprintf oc "l%c %s, %d(%s)\n" + sz (print_reg rd) i (print_reg rt) + | LMov(rd, rs) -> + Format.fprintf oc "mv %s, %s\n" (print_reg rd) (print_reg rs) + | LLabel l -> + Format.fprintf oc "%s:\n" l + | LJmp l -> Format.fprintf oc "j %s\n" l + | LJmpr r -> Format.fprintf oc "jr %s\n" (print_reg r) + | LConst (rd, i) -> Format.fprintf oc "li %s, %d\n\n" (print_reg rd) i + | LComment l -> Format.fprintf oc "# %s\n" l + | LBranch(cmp, rs1, rs2, s) -> + Format.fprintf oc "%s %s, %s, %s\n" + (riscv_of_cmp cmp) (print_reg rs1) (print_reg rs2) s + | LCall fname -> + Format.fprintf oc "jal ra, %s\n" fname + | LHalt -> Format.fprintf oc "halt\n" + +let dump_riscv_fun oc (fname , lf) = + Format.fprintf oc "%s:\n" fname; + List.iter (dump_riscv_instr oc) lf.ltlfunbody + +let riscv_load_args target oc : unit = + (match target with + | Linux -> LLoad(reg_s1, reg_sp, 0, archi_mas ()) :: (* s1 <- argc *) + LAddi(reg_s2, reg_sp, (Archi.wordsize ())) :: [] + | Xv6 -> LMov(reg_s1, reg_a0) :: + LMov(reg_s2, reg_a1) :: []) @ + LConst(reg_s3, 1) :: + LSubi(reg_sp, reg_sp, 72) :: + LLabel "Lloop" :: + LBranch(Rceq, reg_s3, reg_s1, "Lendargs") :: + LMov(reg_a0, reg_t4) :: + LAddi(reg_s4, reg_s3, 0) :: + LConst(reg_t1, (Archi.wordsize ())) :: + LBinop(Emul, reg_s4, reg_s4, reg_t1) :: + LBinop(Eadd, reg_t3, reg_s4, reg_s2) :: + LLoad(reg_a0, reg_t3, 0, archi_mas ()) :: + LCall "atoi" :: + LBinop(Esub, reg_s4, reg_fp, reg_s4) :: + LStore(reg_s4, 0, reg_a0, archi_mas ()) :: + LAddi(reg_s3, reg_s3, 1) :: + LJmp "Lloop" :: + LLabel "Lendargs" :: + LLoad(reg_a0, reg_fp, -8, archi_mas ()) :: + LLoad(reg_a1, reg_fp, -16, archi_mas ()) :: + LLoad(reg_a2, reg_fp, -24, archi_mas ()) :: + LLoad(reg_a3, reg_fp, -32, archi_mas ()) :: + LLoad(reg_a4, reg_fp, -40, archi_mas ()) :: + LLoad(reg_a5, reg_fp, -48, archi_mas ()) :: + LLoad(reg_a6, reg_fp, -56, archi_mas ()) :: + LLoad(reg_a7, reg_fp, -64, archi_mas ()) :: + [] |> + List.iter (dump_riscv_instr oc) + +let rv_store () = + Format.sprintf "s%c" (Archi.instrsuffix ()) +let rv_load () = + Format.sprintf "l%c" (Archi.instrsuffix ()) + +let riscv_prelude target oc = + Format.fprintf oc ".include \"syscall_numbers.s\"\n"; + Format.fprintf oc ".globl _start\n"; + Format.fprintf oc "_start:\n"; + Format.fprintf oc " lui gp, %%hi(_heap_start)\n"; + Format.fprintf oc " addi gp, gp, %%lo(_heap_start)\n"; + Format.fprintf oc " addi t0, gp, 8\n"; + Format.fprintf oc " %s t0, 0(gp)\n" (rv_store ()); + Format.fprintf oc " mv s0, sp\n"; + riscv_load_args target oc ; + Format.fprintf oc "jal ra, main\n"; + Format.fprintf oc "mv s0, a0\n"; + Format.fprintf oc "jal ra, println\n"; + Format.fprintf oc "mv a0, s0\n"; + Format.fprintf oc "jal ra, print_int\n"; + Format.fprintf oc "jal ra, println\n"; + Format.fprintf oc "addi a7, zero, SYSCALL_EXIT\n"; + Format.fprintf oc "ecall\n" + +let dump_riscv_prog target oc lp : unit = + (if !nostart then () else riscv_prelude target oc); + Format.fprintf oc ".global main\n"; + List.iter (function + (fname, Gfun f) -> dump_riscv_fun oc (fname,f) + ) lp diff --git a/src/rtl.ml b/src/rtl.ml new file mode 100644 index 0000000000000000000000000000000000000000..ab703a052a576fcb000cc3eb1ed68a08653d225b --- /dev/null +++ b/src/rtl.ml @@ -0,0 +1,39 @@ +open Batteries +open Elang +open Cfg + +type reg = int + +type rtl_cmp = Rclt | Rcle | Rcgt | Rcge | Rceq | Rcne + +type rtl_instr = Rbinop of binop * reg * reg * reg + | Runop of unop * reg * reg + | Rconst of reg * int + | Rbranch of rtl_cmp * reg * reg * int + | Rjmp of int + | Rmov of reg * reg + | Rret of reg + | Rlabel of int + | Rprint of reg + +type rtl_fun = { rtlfunargs: reg list; + rtlfunbody: (int, rtl_instr list) Hashtbl.t; + rtlfunentry: int; + rtlfuninfo: (string*reg) list + } + +let written_rtl_regs_instr (i: rtl_instr) = + match i with + | Rbinop (_, rd, _, _) + | Runop (_, rd, _) + | Rconst (rd, _) + | Rmov (rd, _) -> Set.singleton rd + | Rprint _ + | Rret _ + | Rlabel _ + | Rbranch (_, _, _, _) + | Rjmp _ -> Set.empty + +let written_rtl_regs (l: rtl_instr list) = + List.fold_left (fun acc i -> Set.union acc (written_rtl_regs_instr i)) + Set.empty l diff --git a/src/rtl_gen.ml b/src/rtl_gen.ml new file mode 100644 index 0000000000000000000000000000000000000000..ce1eb8f84ef214052bb074b76658d460ac7045df --- /dev/null +++ b/src/rtl_gen.ml @@ -0,0 +1,100 @@ +open Batteries +open Elang +open Cfg +open Rtl +open Prog +open Utils +open Report +open Rtl_print +open Options + +(* Une partie de la génération de RTL consiste à allouer les variables dans des + pseudo-registres RTL. + + Ces registres sont en nombre illimité donc ce problème est facile. + + Étant donnés : + - [next_reg], le premier numéro de registre disponible (pas encore alloué à + une variable) + - [var2reg], une liste d'associations dont les clés sont des variables et les + valeurs des numéros de registres + - [v] un nom de variable (de type [string]), + + [find_var (next_reg, var2reg) v] renvoie un triplet [(r, next_reg, var2reg)]: + + - [r] est le registre RTL associé à la variable [v] + - [next_reg] est le nouveau premier registre disponible + - [var2reg] est la nouvelle association nom de variable/registre. + +*) +let find_var (next_reg, var2reg) v = + match List.assoc_opt v var2reg with + | Some r -> (r, next_reg, var2reg) + | None -> (next_reg, next_reg + 1, assoc_set var2reg v next_reg) + +(* [rtl_instrs_of_cfg_expr (next_reg, var2reg) e] construit une liste + d'instructions RTL correspondant à l'évaluation d'une expression E. + + Le retour de cette fonction est un quadruplet [(r,l,next_reg,var2reg)], où : + - [r] est le registre RTL dans lequel le résultat de l'évaluation de [e] aura + été stocké + - [l] est une liste d'instructions RTL. + - [next_reg] est le nouveau premier registre disponible + - [var2reg] est la nouvelle association nom de variable/registre. +*) +let rec rtl_instrs_of_cfg_expr (next_reg, var2reg) (e: expr) = + (next_reg, [], next_reg, var2reg) + +let is_cmp_op = + function Eclt -> Some Rclt + | Ecle -> Some Rcle + | Ecgt -> Some Rcgt + | Ecge -> Some Rcge + | Eceq -> Some Rceq + | Ecne -> Some Rcne + | _ -> None + +let rtl_cmp_of_cfg_expr (e: expr) = + match e with + | Ebinop (b, e1, e2) -> + (match is_cmp_op b with + | None -> (Rcne, e, Eint 0) + | Some rop -> (rop, e1, e2)) + | _ -> (Rcne, e, Eint 0) + + +let rtl_instrs_of_cfg_node ((next_reg:int), (var2reg: (string*int) list)) (c: cfg_node) = + (* TODO *) + ([], next_reg, var2reg) + +let rtl_instrs_of_cfg_fun cfgfunname ({ cfgfunargs; cfgfunbody; cfgentry }: cfg_fun) = + let (rargs, next_reg, var2reg) = + List.fold_left (fun (rargs, next_reg, var2reg) a -> + let (r, next_reg, var2reg) = find_var (next_reg, var2reg) a in + (rargs @ [r], next_reg, var2reg) + ) + ([], 0, []) cfgfunargs + in + let rtlfunbody = Hashtbl.create 17 in + let (next_reg, var2reg) = Hashtbl.fold (fun n node (next_reg, var2reg)-> + let (l, next_reg, var2reg) = rtl_instrs_of_cfg_node (next_reg, var2reg) node in + Hashtbl.replace rtlfunbody n l; + (next_reg, var2reg) + ) cfgfunbody (next_reg, var2reg) in + { + rtlfunargs = rargs; + rtlfunentry = cfgentry; + rtlfunbody; + rtlfuninfo = var2reg; + } + +let rtl_of_gdef funname = function + Gfun f -> Gfun (rtl_instrs_of_cfg_fun funname f) + +let rtl_of_cfg cp = List.map (fun (s, gd) -> (s, rtl_of_gdef s gd)) cp + +let pass_rtl_gen cfg = + let rtl = rtl_of_cfg cfg in + dump !rtl_dump dump_rtl_prog rtl + (fun file () -> add_to_report "rtl" "RTL" (Code (file_contents file))); + OK rtl diff --git a/src/rtl_print.ml b/src/rtl_print.ml new file mode 100644 index 0000000000000000000000000000000000000000..f0b473438d9927b2ae15de2daf7975c48bb44a20 --- /dev/null +++ b/src/rtl_print.ml @@ -0,0 +1,66 @@ +open Batteries +open Elang_print +open Rtl +open Prog +open Utils + + +let print_reg r = + Format.sprintf "r%d" r + +let print_cmpop (r: rtl_cmp) = + (match r with + | Rclt -> "<" + | Rcle -> "<=" + | Rcgt -> ">" + | Rcge -> ">=" + | Rceq -> "==" + | Rcne -> "!=") + +let dump_rtl_instr name (live_in, live_out) ?(endl="\n") oc (i: rtl_instr) = + let print_node s = Format.sprintf "%s_%d" name s in + + let dump_liveness live where = + match live with + Some live -> Format.fprintf oc "// Live %s : { %s }\n" where (String.concat ", " (Set.to_list (Set.map string_of_int live))) + | None -> () + in + dump_liveness live_in "before"; + begin match i with + | Rbinop (b, rd, rs1, rs2) -> + Format.fprintf oc "%s <- %s(%s, %s)" (print_reg rd) (dump_binop b) (print_reg rs1) (print_reg rs2) + | Runop (u, rd, rs) -> + Format.fprintf oc "%s <- %s(%s)" (print_reg rd) (dump_unop u) (print_reg rs) + | Rconst (rd, i) -> + Format.fprintf oc "%s <- %d" (print_reg rd) i + | Rbranch (cmpop, r1, r2, s1) -> + Format.fprintf oc "%s %s %s ? jmp %s" (print_reg r1) (print_cmpop cmpop) (print_reg r2) (print_node s1) + | Rjmp s -> + Format.fprintf oc "jmp %s" (print_node s) + | Rmov (rd, rs) -> Format.fprintf oc "%s <- %s" (print_reg rd) (print_reg rs) + | Rret r -> Format.fprintf oc "ret %s" (print_reg r) + | Rprint r -> Format.fprintf oc "print %s" (print_reg r) + | Rlabel n -> Format.fprintf oc "%s_%d:" name n + end; + Format.fprintf oc "%s" endl; + dump_liveness live_out "after" + +let dump_rtl_node name lives = + print_listi (fun i -> + dump_rtl_instr name + (match lives with + None -> (None, None) + | Some (lin, lout) -> + Hashtbl.find_option lin i, Hashtbl.find_option lout i) + ~endl:"\n" + ) "" "" "" + +let dump_rtl_fun oc rtlfunname ({ rtlfunargs; rtlfunbody; rtlfunentry }: rtl_fun) = + Format.fprintf oc "%s(%s):\n" rtlfunname + (String.concat ", " $ List.map print_reg rtlfunargs); + Hashtbl.iter (fun n node -> + Format.fprintf oc "%s_%d:\n" rtlfunname n; + dump_rtl_node rtlfunname None oc node) rtlfunbody + +let dump_rtl_prog oc cp = + dump_prog dump_rtl_fun oc cp diff --git a/src/rtl_run.ml b/src/rtl_run.ml new file mode 100644 index 0000000000000000000000000000000000000000..f8dcde8b45e374eac882af10c37d6be30e2adc29 --- /dev/null +++ b/src/rtl_run.ml @@ -0,0 +1,122 @@ +open Batteries +open BatList +open Elang +open Cfg +open Elang_run +open Cfg_run +open Rtl +open Rtl_print +open Utils +open Builtins +open Prog + +type state = { + mem: Mem.t; + regs: (reg, int) Hashtbl.t; +} + +let init_state memsize = + { + mem = Mem.init memsize; + regs = Hashtbl.create 17 + } + +let eval_rtl_cmp = function + Rcle -> (<=) + | Rclt -> (<) + | Rcge -> (>=) + | Rcgt -> (>) + | Rceq -> (=) + | Rcne -> (<>) + +let rec exec_rtl_instr oc rp rtlfunname f st (i: rtl_instr) = + match i with + | Rbinop (b, rd, rs1, rs2) -> + begin match Hashtbl.find_option st.regs rs1, + Hashtbl.find_option st.regs rs2 with + | Some v1, Some v2 -> + Hashtbl.replace st.regs rd (eval_binop b v1 v2); + OK (None, st) + | _, _ -> Error (Printf.sprintf "Binop applied on undefined registers (%s and %s)" (print_reg rs1) (print_reg rs2)) + end + | Runop (u, rd, rs) -> + begin match Hashtbl.find_option st.regs rs with + | Some v -> + Hashtbl.replace st.regs rd (eval_unop u v); + OK (None, st) + | _ -> Error (Printf.sprintf "Unop applied on undefined register %s" (print_reg rs)) + end + | Rconst (rd, i) -> + Hashtbl.replace st.regs rd i; + OK (None, st) + | Rbranch (cmp, r1, r2, s1) -> + begin match Hashtbl.find_option st.regs r1, + Hashtbl.find_option st.regs r2 with + | Some v1, Some v2 -> + (if eval_rtl_cmp cmp v1 v2 then exec_rtl_instr_at oc rp rtlfunname f st s1 else OK (None, st)) + | _, _ -> Error (Printf.sprintf "Branching on undefined registers (%s and %s)" (print_reg r1) (print_reg r2)) + end + | Rjmp s -> exec_rtl_instr_at oc rp rtlfunname f st s + | Rmov (rd, rs) -> + begin match Hashtbl.find_option st.regs rs with + | Some s -> + Hashtbl.replace st.regs rd s; + OK (None, st) + | _ -> Error (Printf.sprintf "Mov on undefined register (%s)" (print_reg rs)) + end + | Rret r -> + begin match Hashtbl.find_option st.regs r with + | Some s -> OK (Some s, st) + | _ -> Error (Printf.sprintf "Ret on undefined register (%s)" (print_reg r)) + end + | Rprint r -> + begin match Hashtbl.find_option st.regs r with + | Some s -> + Format.fprintf oc "%d\n" s; + OK (None, st) + | _ -> Error (Printf.sprintf "Print on undefined register (%s)" (print_reg r)) + end + | Rlabel n -> OK (None, st) + +and exec_rtl_instr_at oc rp rtlfunname ({ rtlfunbody; } as f: rtl_fun) st i = + match Hashtbl.find_option rtlfunbody i with + | Some l -> exec_rtl_instrs oc rp rtlfunname f st l + | None -> Error (Printf.sprintf "Jump to undefined label (%s_%d)" rtlfunname i) + +and exec_rtl_instrs oc rp rtlfunname f st l = + List.fold_left (fun acc i -> + match acc with + | Error _ -> acc + | OK (Some v, st) -> OK (Some v, st) + | OK (None, st) -> + exec_rtl_instr oc rp rtlfunname f st i + ) (OK (None, st)) l + +and exec_rtl_fun oc rp st rtlfunname f params = + let regs' = Hashtbl.create 17 in + match List.iter2 (fun n v -> Hashtbl.replace regs' n v) f.rtlfunargs params with + | exception Invalid_argument _ -> + Error (Format.sprintf "RTL: Called function %s with %d arguments, expected %d\n" + rtlfunname + (List.length params) + (List.length f.rtlfunargs) + ) + | _ -> + match Hashtbl.find_option f.rtlfunbody f.rtlfunentry with + | None -> + Error (Printf.sprintf "Unknown node (%s_%d)" rtlfunname f.rtlfunentry) + | Some l -> + let regs_save = Hashtbl.copy st.regs in + let st' = {st with regs = regs'; } in + exec_rtl_instrs oc rp rtlfunname f st' l >>= fun (v, st) -> + OK(v, {st with regs = regs_save }) + +and exec_rtl_prog oc rp memsize params = + let st = init_state memsize in + find_function rp "main" >>= fun f -> + let n = List.length f.rtlfunargs in + let params = take n params in + exec_rtl_fun oc rp st "main" f params >>= fun (v, st) -> + OK v + + diff --git a/src/symbols.ml b/src/symbols.ml new file mode 100644 index 0000000000000000000000000000000000000000..71760ef8380d4e4fefc2f934565fab43c68fe9b4 --- /dev/null +++ b/src/symbols.ml @@ -0,0 +1,105 @@ +open Batteries + +let string_of_position pos = + let open Lexing in + Printf.sprintf "%s:%d:%d" pos.pos_fname + pos.pos_lnum (pos.pos_cnum - pos.pos_bol + 1) + + +type token = + | SYM_EOF + | SYM_IDENTIFIER of string + | SYM_INTEGER of int + | SYM_VOID + | SYM_CHAR + | SYM_INT + | SYM_STRUCT + | SYM_SEMICOLON + | SYM_POINT + | SYM_IF + | SYM_ELSE + | SYM_PLUS + | SYM_MINUS + | SYM_ASTERISK + | SYM_DIV + | SYM_EQUALITY + | SYM_ASSIGN + | SYM_LPARENTHESIS + | SYM_RPARENTHESIS + | SYM_LBRACE + | SYM_RBRACE + | SYM_WHILE + | SYM_RETURN + | SYM_COMMA + | SYM_LT + | SYM_LEQ + | SYM_GT + | SYM_GEQ + | SYM_NOTEQ + | SYM_MOD + | SYM_BOOL_NOT + | SYM_BOOL_AND + | SYM_BOOL_OR + | SYM_ARROW + | SYM_BITWISE_OR + | SYM_BITWISE_AND + | SYM_BIT_NOT + | SYM_XOR + | SYM_CHARACTER of char + | SYM_STRING of string + | SYM_LBRACKET + | SYM_RBRACKET + | SYM_ALLOC + | SYM_PRINT + | SYM_EXTERN + | SYM_INCLUDE of string + | SYM_AMPERSAND + +let string_of_symbol = function +| SYM_EOF -> "SYM_EOF" +| SYM_IDENTIFIER(s) -> Printf.sprintf "SYM_IDENTIFIER(%s)" s +| SYM_INTEGER(i) -> Printf.sprintf "SYM_INTEGER(%d)" i +| SYM_VOID -> "SYM_VOID" +| SYM_CHAR -> "SYM_CHAR" +| SYM_INT -> "SYM_INT" +| SYM_STRUCT -> "SYM_STRUCT" +| SYM_SEMICOLON -> "SYM_SEMICOLON" +| SYM_POINT -> "SYM_POINT" +| SYM_IF -> "SYM_IF" +| SYM_ELSE -> "SYM_ELSE" +| SYM_PLUS -> "SYM_PLUS" +| SYM_MINUS -> "SYM_MINUS" +| SYM_ASTERISK -> "SYM_ASTERISK" +| SYM_DIV -> "SYM_DIV" +| SYM_EQUALITY -> "SYM_EQUALITY" +| SYM_ASSIGN -> "SYM_ASSIGN" +| SYM_LPARENTHESIS -> "SYM_LPARENTHESIS" +| SYM_RPARENTHESIS -> "SYM_RPARENTHESIS" +| SYM_LBRACE -> "SYM_LBRACE" +| SYM_RBRACE -> "SYM_RBRACE" +| SYM_WHILE -> "SYM_WHILE" +| SYM_RETURN -> "SYM_RETURN" +| SYM_COMMA -> "SYM_COMMA" +| SYM_LT -> "SYM_LT" +| SYM_LEQ -> "SYM_LEQ" +| SYM_GT -> "SYM_GT" +| SYM_GEQ -> "SYM_GEQ" +| SYM_NOTEQ -> "SYM_NOTEQ" +| SYM_MOD -> "SYM_MOD" +| SYM_BOOL_NOT -> "SYM_BOOL_NOT" +| SYM_BOOL_AND -> "SYM_BOOL_AND" +| SYM_BOOL_OR -> "SYM_BOOL_OR" +| SYM_ARROW -> "SYM_ARROW" +| SYM_BITWISE_OR -> "SYM_BITWISE_OR" +| SYM_BITWISE_AND -> "SYM_BITWISE_AND" +| SYM_BIT_NOT -> "SYM_BIT_NOT" +| SYM_XOR -> "SYM_XOR" +| SYM_CHARACTER(c) -> Printf.sprintf "SYM_CHARACTER(%c)" c +| SYM_STRING(s) -> Printf.sprintf "SYM_STRING(%s)" s +| SYM_LBRACKET -> "SYM_LBRACKET" +| SYM_RBRACKET -> "SYM_RBRACKET" +| SYM_ALLOC -> "SYM_ALLOC" +| SYM_PRINT -> "SYM_PRINT" +| SYM_EXTERN -> "SYM_EXTERN" +| SYM_INCLUDE(s) -> Printf.sprintf "SYM_INCLUDE(%s)" s +| SYM_AMPERSAND -> "SYM_AMPERSAND" diff --git a/src/test_lexer.ml b/src/test_lexer.ml new file mode 100644 index 0000000000000000000000000000000000000000..72ffda45d229eb9ab198c2de6c5e57ffd349eb2b --- /dev/null +++ b/src/test_lexer.ml @@ -0,0 +1,190 @@ +open E_regexp +open Lexer_generator +open Batteries +open Utils +open Symbols + +let nfa_accepts (n: nfa) (w: char list) : bool = + let rec trav vis s = + if Set.mem s vis then vis + else let en = List.filter_map (fun (oa, n) -> if oa = None then Some n else None) (n.nfa_step s) in + List.fold_left trav (Set.add s vis) en in + let ec s = trav Set.empty s in + let ecs ls = Set.fold (fun q -> Set.union (ec q)) ls Set.empty in + + let rec walk (q: int set) (w: char list) = + let q = ecs q in + match w with + | [] -> Set.exists (fun q -> List.mem q (List.map fst n.nfa_final)) q + | c::w -> + let q' = + Set.fold Set.union (Set.map (fun q -> + (List.filter_map + (fun (cso,q') -> + match cso with + | None -> None + | Some cs -> if Set.mem c cs then Some q' else None + ) + (n.nfa_step q)) |> Set.of_list + ) q) Set.empty + + in walk q' w in + walk (Set.of_list n.nfa_initial) w + +let () = + let regexp_list = [ + (keyword_regexp "while", fun s -> Some (SYM_WHILE)); + (keyword_regexp "if", fun s -> Some (SYM_IF)); + (Cat(letter_regexp, + Star(identifier_material)), + fun s -> Some (SYM_IDENTIFIER s)); + + ] in + (* Décommentez la ligne suivante pour tester sur la vraie liste d'expressions + régulières. *) + (* let regexp_list = list_regexp in *) + List.iteri + (fun i (rg, _) -> Printf.printf "%d: %s\n" i (string_of_regexp rg)) + regexp_list; + + let nfa = nfa_of_list_regexp regexp_list in + + Printf.printf "%s\n" (nfa_to_string nfa); + + let oc = open_out "/tmp/nfa.dot" in + nfa_to_dot oc nfa; + close_out oc; + + let dfa = dfa_of_nfa nfa in + let oc = open_out "/tmp/dfa.dot" in + dfa_to_dot oc dfa alphabet; + close_out oc; + + let n = + { + nfa_states = [1; 2; 3; 4] ; + nfa_initial = [1] ; + nfa_final = [(3, fun s -> None); (4, fun s -> None)]; + nfa_step = fun q -> + match q with + | 1 -> [(Some (Set.singleton '0'), 2); (None, 3)] + | 2 -> [(Some (Set.singleton '1'), 2); (Some (Set.singleton '1'), 4)] + | 3 -> [(Some (Set.singleton '0'), 4); (None, 2)] + | 4 -> [(Some (Set.singleton '0'), 2)] + | _ -> [] + + } in + + let expect_set str s_got s_exp = + if Set.equal s_got s_exp + then Printf.printf "[OK] %s\n" str + else Printf.printf "[KO] %s : got %s, expected %s\n" str (string_of_int_set s_got) + (string_of_int_set s_exp) in + + let ec1 = epsilon_closure n 1 in + let ec2 = epsilon_closure n 2 in + let ec3 = epsilon_closure n 3 in + let ec4 = epsilon_closure n 4 in + + expect_set "epsilon_closure 1" ec1 (Set.of_list [1;2;3]); + expect_set "epsilon_closure 2" ec2 (Set.of_list [2]); + expect_set "epsilon_closure 3" ec3 (Set.of_list [2;3]); + expect_set "epsilon_closure 4" ec4 (Set.of_list [4]); + + expect_set "dfa_initial_state" (dfa_initial_state n) (Set.of_list [1;2;3]); + + let string_of_opt_tok ot = + match ot with + None -> "None" + | Some t -> Printf.sprintf "Some (%s)" (string_of_symbol t) + in + + let expect_token_option str to_got to_exp = + if to_got = to_exp + then Printf.printf "[OK] %s\n" str + else Printf.printf "[KO] %s : got %s, expected %s\n" str (string_of_opt_tok to_got) + (string_of_opt_tok to_exp) + in + + expect_token_option "min_priority 1" (min_priority [SYM_EOF; SYM_IDENTIFIER "bla"; SYM_WHILE]) (Some SYM_WHILE); + expect_token_option "min_priority 2" (min_priority [SYM_EOF; SYM_IDENTIFIER "bla"]) (Some (SYM_IDENTIFIER "bla")); + expect_token_option "min_priority 3" (min_priority [SYM_EOF; SYM_WHILE]) (Some SYM_WHILE); + + expect_token_option "min_priority 4" (min_priority []) None; + + let set_incl s1 s2 = + Set.for_all (fun s -> Set.exists (Set.equal s) s2) s1 + in + + let set_eq s1 s2 = set_incl s1 s2 && set_incl s2 s1 in + + let string_of_int_set_set s = + Set.map (fun s -> + Printf.sprintf "{%s}" (String.concat "," (Set.to_list (Set.map string_of_int s))) + ) s + |> Set.to_list + |> String.concat ", " + |> Printf.sprintf "{%s}" + in + + let expect_set_set str (set_got : int set set) (set_exp : int set set) = + if set_eq set_got set_exp + then Printf.printf "[OK] %s\n" str + else Printf.printf "[KO] %s : got %s, expected %s\n" str + (string_of_int_set_set set_got) + (string_of_int_set_set set_exp) + in + + let table = Hashtbl.create 10 in + build_dfa_table table n (dfa_initial_state n); + expect_set_set "dfa states" (Hashtbl.keys table |> Set.of_enum) (Set.of_list [Set.of_list [1;2;3]; Set.of_list [2;4]; Set.of_list [2]]); + + let expect_nfa_accepts n s b = + let r = nfa_accepts n (char_list_of_string s) in + if r = b + then Printf.printf "[OK] nfa_accepts %s = %b\n" s r + else Printf.printf "[KO] nfa_accepts %s = %b\n" s r + in + + Printf.printf "*** NFA n1 : 'hello'\n"; + let n1, f1 = nfa_of_regexp (keyword_regexp "hello") 1 (fun _ -> None) in + expect_nfa_accepts n1 "hello" true; + expect_nfa_accepts n1 "bonjour" false; + + Printf.printf "*** NFA n2 : 'bonjour'\n"; + let n2, f2 = nfa_of_regexp (keyword_regexp "bonjour") f1 (fun _ -> None) in + expect_nfa_accepts n2 "hello" false; + expect_nfa_accepts n2 "bonjour" true; + + Printf.printf "*** NFA n3 : n1 | n2\n"; + let n3 = alt_nfa n1 n2 in + expect_nfa_accepts n3 "hello" true; + expect_nfa_accepts n3 "bonjour" true; + expect_nfa_accepts n2 "buongiorno" false; + + Printf.printf "*** NFA n4 : n1 . n2 \n"; + let n4 = cat_nfa n1 n2 in + expect_nfa_accepts n4 "hello" false; + expect_nfa_accepts n4 "bonjour" false; + expect_nfa_accepts n4 "hellobonjour" true; + expect_nfa_accepts n4 "bonjourhello" false; + + Printf.printf "*** NFA n5 : n1* \n"; + let n5 = star_nfa n1 (fun _ -> None) in + expect_nfa_accepts n5 "" true; + expect_nfa_accepts n5 "hello" true; + expect_nfa_accepts n5 "hellohello" true; + expect_nfa_accepts n5 "hellobonjour" false; + + Printf.printf "*** NFA n6 : n3* \n"; + let n6 = star_nfa n3 (fun _ -> None) in + expect_nfa_accepts n6 "" true; + expect_nfa_accepts n6 "hello" true; + expect_nfa_accepts n6 "hellohello" true; + expect_nfa_accepts n6 "hellobonjour" true; + expect_nfa_accepts n6 "hellobonjourhello" true; + expect_nfa_accepts n6 "bonjourbonjourbonjourhello" true; + expect_nfa_accepts n6 "bonjlo" false; + + + ignore f2 diff --git a/src/tokenize.ml b/src/tokenize.ml new file mode 100644 index 0000000000000000000000000000000000000000..e1939cfc1a627c4da50cb08954e4ce9ed20d5136 --- /dev/null +++ b/src/tokenize.ml @@ -0,0 +1,44 @@ +open Batteries +open Lexer_generator +open Report +open Utils +open Options +open Symbols + +let tokenize_handwritten file = + Printf.printf "Handwritten lexer\n"; + Lexer_generator.tokenize_file file >>= fun tokens -> + OK (List.map (fun tok -> (tok, None)) tokens) + +let tokenize_ocamllex file = + Printf.printf "OCamlLex lexer\n"; + let ic = open_in file in + let lexbuf = Lexing.from_channel ic in + lexbuf.Lexing.lex_curr_p <- { lexbuf.Lexing.lex_curr_p with pos_fname = file }; + let rec get_symbols () = + let s = Lexer.token lexbuf in + let ss = (s, Lexing.lexeme_start_p lexbuf) in + if s = SYM_EOF + then [ss] + else ss :: get_symbols () + in + let l = get_symbols () in + close_in ic; + OK (List.map (fun (tok, pos) -> (tok, Some pos)) l) + +let tokenize file = + if !Options.handwritten_lexer + then tokenize_handwritten file + else tokenize_ocamllex file + +let pass_tokenize file = + tokenize file >>* (fun msg -> + record_compile_result ~error:(Some msg) "Lexing"; + Error msg + ) $ fun tokens -> + record_compile_result "Lexing"; + dump !show_tokens (fun oc tokens -> + List.iter (fun (tok,_) -> + Format.fprintf oc "%s\n" (string_of_symbol tok) + ) tokens) tokens (fun f () -> add_to_report "lexer" "Lexer" (Code (file_contents f))); + OK tokens diff --git a/src/utils.ml b/src/utils.ml new file mode 100644 index 0000000000000000000000000000000000000000..35479bfb29f2ae40c4c2c6aba8a764010feaa3f9 --- /dev/null +++ b/src/utils.ml @@ -0,0 +1,347 @@ +open Batteries +open BatBuffer +open BatList + +type 'a res = OK of 'a | Error of string +type ('a , 'b) sum = Inl of 'a | Inr of 'b +type ('a , 'b, 'c) trisum = Tri1 of 'a | Tri2 of 'b | Tri3 of 'c + +let string_of_error (msg: string) : string = + msg + +let sprintf msg = + let s = BatBuffer.create 17 in + msg (output_buffer s); + BatBuffer.contents s + + + +let option_to_res_bind r m f = match r with + | Some r -> f r + | None -> Error m + +let (>>) r m f = option_to_res_bind r m f + +let option_bind o f = match o with + | None -> None + | Some x -> Some (f x) + +let (>*>) o f = match o with + | None -> None + | Some x -> Some (f x) + +let error_bind r f = match r with + | OK r -> f r + | Error msg -> Error msg + +let (>>=) r f = error_bind r f + +let error_fail r f = match r with + | OK r -> f r + | Error msg -> failwith msg + +let (>>!) r f = error_fail r f + +let (>>*) r g f = match r with + | OK r -> f r + | Error msg -> g msg + +let ($) f a = f a + +let rec assoc_set (l: ('a * 'b) list) (a: 'a) (b: 'b) = + match l with + | [] -> [(a,b)] + | (k,v)::r -> if k = a then (a,b)::r + else (k,v)::(assoc_set r a b) + +let safe_array_get a i = + try Some (Array.get a i) + with Not_found -> None + +(* split_bytes n i splits an integer i into n bytes, starting with LSB *) +let rec split_bytes n i = + if n <= 0 then [] + else i mod 256 :: split_bytes (n-1) (i / 256) + + +let write_mem_bytes mem addr bl = + bl |> + List.fold_lefti (fun acc i b -> + acc >>= fun l -> + let ofs = addr+i in let v = b mod 256 in + try mem.(ofs) <- v; OK ((ofs,v)::l) + with _ -> Error (Format.sprintf "Problem when writing mem at address %d\n" ofs) + ) (OK []) + + +let write_mem_char mem addr c = write_mem_bytes mem addr [c] + +let int_of_bytes l = + List.fold_left (fun acc b -> acc * 256 + b) 0 l + +(* list [0,...,n-1] *) +let rec list_ints_inc n = + if n <= 0 then [] + else list_ints_inc (n-1) @ [n-1] + +(* list [n,...0] *) +let rec list_ints_desc n = + if n <= 0 then [0] + else n :: list_ints_desc (n-1) + +let range ?desc:(desc=false) ?start:(start=0) len = + let rec list_ints n acc = + if n <= 0 then acc else list_ints (n-1) ((n-1) :: acc) + in + let l = List.map ((+) start) (list_ints len []) in + if not desc then l else List.rev l + + +let read_mem_bytes mem addr n = + List.fold_left (fun acc i -> + acc >>= fun (lv, laddr) -> + try let v = mem.(addr+i) in OK (lv@[v], (addr+i)::laddr) + with _ -> Error (Format.sprintf "Problem when reading from mem at address %d\n" (addr+i)) + ) (OK ([],[])) (list_ints_inc n) + +let read_mem_bytes_as_int mem addr n = + read_mem_bytes mem addr n >>= fun (bl, read_list) -> + OK (int_of_bytes (rev bl), read_list) + + +let read_mem_int mem addr = + read_mem_bytes_as_int mem addr (Archi.wordsize ()) + +let read_mem_char mem addr = + read_mem_bytes mem addr 1 >>= fun bl -> + match bl with + | [a],addrl -> OK (a,addrl) + | _ -> Error (Format.sprintf "unable to read from mem at addr %d" addr) + +module Mem : sig + type t + val init : int -> t + val write_bytes : t -> int -> int list -> unit res + val write_char : t -> int -> int -> unit res + val read_bytes : t -> int -> int -> int list res + val read_bytes_as_int : t -> int -> int -> int res + val read_char : t -> int -> int res + val read_log : t -> unit -> int list + val write_log : t -> unit -> (int * int) list +end = struct + type t = int array * int list ref * (int * int) list ref + let write_bytes (m,_,wl) addr bytes = + write_mem_bytes m addr bytes >>= fun w -> + wl := w @ !wl; OK () + let write_char (m,_,wl) addr c = + write_mem_char m addr c >>= fun w -> wl := w @ !wl; OK () + let read_bytes (m,rl,_) addr len = + read_mem_bytes m addr len >>= fun (vl,addrl) -> + rl := addrl @ !rl ; OK vl + let read_bytes_as_int (m,rl,_) addr len = + read_mem_bytes_as_int m addr len >>= fun (v,addrl) -> + rl := addrl @ !rl; OK v + let read_char (m,rl,_) addr = + read_mem_char m addr >>= fun (v,addrl) -> + rl := addrl @ !rl; OK v + let init n = Array.init n (fun _ -> 0), ref [], ref [] + let read_log (_,rl,_) () = let r = !rl in rl := []; List.rev r + let write_log (_,_,wl) () = let w = !wl in wl := []; List.rev w +end + +let assoc_opti k l = + let rec aux l n = + match l with + | [] -> None + | (a,v)::_ when a = k -> Some (n, v) + | _::l -> aux l (n+1) + in + aux l 0 + +let assoc_map f = + List.map (fun (k,v) -> (k, f v)) + +let assoc_map_res f l = + List.fold_left (fun acc (k,v) -> + acc >>= fun acc -> + f k v >>= fun v -> + OK (acc@[(k,v)]) + ) (OK []) l + +let assoc_split fl fr l = + let rec aux l (accl, accr) = + match l with + | [] -> (accl, accr) + | (s, Inl x)::r -> aux r ((s, fl x)::accl, accr) + | (s, Inr x)::r -> aux r (accl, (s, fr x)::accr) + in aux l ([],[]) |> + fun (a,b) -> (List.rev a, List.rev b) + +type string_env = int ref * (int, string) Hashtbl.t + +let lookup_string_env (senv: string_env) i = + Hashtbl.find_option (snd senv) i + +let add_string_env (senv: string_env) s = + let cur = !(fst senv) in + Hashtbl.replace (snd senv) cur s; + fst senv := cur + 1; + cur + +let init_string_env () = + let i = ref 0 in + let t = Hashtbl.create 17 in + (i, t) + + + +let print_list f beg sep fin oc l = + Format.fprintf oc "%s" beg; + List.iteri (fun i x -> + if i <> 0 then Format.fprintf oc "%s" sep; + f oc x + ) l; + Format.fprintf oc "%s" fin + + +let print_listi f beg sep fin oc l = + Format.fprintf oc "%s" beg; + List.iteri (fun i x -> + if i <> 0 then Format.fprintf oc "%s" sep; + f i oc x + ) l; + Format.fprintf oc "%s" fin + +let print_option f = function + | None -> "None" + | Some o -> Format.sprintf "Some(%s)" (f o) + +let pp_list f oc l = + Format.pp_print_list ~pp_sep:(fun oc () -> Format.fprintf oc ", ") f oc l + +let pp_pair f1 f2 oc (p1,p2) = + Format.fprintf oc "(%a,%a)" f1 p1 f2 p2 + +let dump_option f oc = function + | None -> Format.fprintf oc "None" + | Some o -> Format.fprintf oc "Some(%a)" f o + + +let dump_string oc s = Format.fprintf oc "%s" s + + +let print_optint oc = function + | None -> Format.fprintf oc "None" + | Some v -> Format.fprintf oc "Some(%d)" v + +let set_concat sl = + List.fold_left (fun acc e -> Set.union acc e) Set.empty sl + +let list_map_res f l = + List.fold_left (fun acc e -> + acc >>= fun acc -> + f e >>= fun e -> + OK (acc@[e]) + ) (OK []) l + + +let list_map_resi f l = + List.fold_lefti (fun acc i e -> + acc >>= fun acc -> + f i e >>= fun e -> + OK (acc@[e]) + ) (OK []) l + +let rec list_iter_res f l = + match l with + [] -> OK () + | a::r -> + f a >>= fun _ -> + list_iter_res f r + +let assoc_err ?word:(word="item") k l = + match List.assoc_opt k l with + | Some v -> OK v + | None -> Error (Format.sprintf "%s %s not found." word k) + + +let remove_dups l : 'a list = + List.fold_left (fun acc elt -> if List.mem elt acc then acc else elt::acc) [] l + +let rec take n l = + if n = 0 then [] + else match l with + | [] -> [] + | a::r -> a::take (n-1) r + +let char_list_of_string l : char list = + String.to_list l + +let string_of_char_list cl = + String.of_list cl + +let string_of_char_set s = + string_of_char_list (Set.to_list s) + +let string_of_int_list l = + Printf.sprintf "%s" (String.concat "_" (List.map string_of_int l)) + +let string_of_int_set s = + string_of_int_list (Set.to_list s) + +let string_of_string_set v = + String.concat ", " (Set.to_list v) + +let string_of_int_int_set v = + String.concat ", " (List.map (fun (x,y) -> Printf.sprintf "(%d,%d)" x y) (Set.to_list v)) + +let string_of_int_option v = + match v with + | None -> "undef" + | Some x -> string_of_int x + + +let dump file (dumpf : _ -> 'a -> unit) (p: 'a) (additional_command: string -> unit -> unit) = + begin match file with + | None -> () + | Some file -> + let oc, close = + if file = "-" + then (Format.std_formatter, fun _ -> ()) + else + let oc = open_out file in + (Format.formatter_of_out_channel oc, fun () -> close_out oc) + in + dumpf oc p; close (); + if file <> "-" then additional_command file () + end + + +let process_output_to_list2 = fun command -> + let chan = Unix.open_process_in command in + let res = ref ([] : string list) in + let rec process_otl_aux () = + let e = input_line chan in + res := e::!res; + process_otl_aux() in + try process_otl_aux () + with End_of_file -> + let stat = Unix.close_process_in chan in (List.rev !res,stat) + +let cmd_to_list command = + let (l,_) = process_output_to_list2 command in l + +let file_contents file = + match + let ic = open_in file in + let rec aux s () = + try + let line = input_line ic in (* read line from in_channel and discard \n *) + aux (s ^ line ^ "\n") () (* close the input channel *) + with _ -> (* some unexpected exception occurs *) + close_in_noerr ic; (* emergency closing *) + s in + aux "" () + with + | exception Sys_error _ -> failwith (Printf.sprintf "Could not open file %s\n" file) + | x -> x diff --git a/src/yaccparser.mly b/src/yaccparser.mly new file mode 100644 index 0000000000000000000000000000000000000000..3c9a390a95b44e92e4168327630e1d43af1873a3 --- /dev/null +++ b/src/yaccparser.mly @@ -0,0 +1,93 @@ +%{ + (* open Symbols *) + open Ast +%} + +%token SYM_EOF +%token SYM_VOID SYM_CHAR SYM_INT SYM_STRUCT SYM_POINT SYM_BOOL_NOT SYM_BOOL_AND SYM_BOOL_OR +%token SYM_ARROW SYM_BITWISE_OR SYM_BITWISE_AND SYM_BIT_NOT SYM_XOR SYM_LBRACKET SYM_RBRACKET +%token SYM_ALLOC SYM_EXTERN SYM_AMPERSAND +%token<char> SYM_CHARACTER +%token<string> SYM_STRING +%token<string> SYM_INCLUDE +%token<string> SYM_IDENTIFIER +%token<int> SYM_INTEGER +%token SYM_PLUS SYM_MINUS SYM_ASTERISK SYM_DIV SYM_MOD +%token SYM_LPARENTHESIS SYM_RPARENTHESIS SYM_LBRACE SYM_RBRACE +%token SYM_ASSIGN SYM_SEMICOLON SYM_RETURN SYM_IF SYM_WHILE SYM_ELSE SYM_COMMA SYM_PRINT +%token SYM_EQUALITY SYM_NOTEQ SYM_LT SYM_LEQ SYM_GT SYM_GEQ + +%left SYM_EQUALITY SYM_NOTEQ +%left SYM_GEQ SYM_LEQ SYM_LT SYM_GT +%left SYM_PLUS SYM_MINUS +%left SYM_ASTERISK SYM_DIV SYM_MOD +%nonassoc UMINUS + +%start main +%type <Ast.tree> main + +%% + + main: + | fundefs SYM_EOF { Node(Tlistglobdef, $1) } + ; + fundefs: + | fundef fundefs { $1 :: $2 } + | { [] } + ; + fundef: + identifier SYM_LPARENTHESIS lparams SYM_RPARENTHESIS instr { + let fargs = $3 in + let instr = $5 in + Node (Tfundef, [$1; Node (Tfunargs, fargs) ; instr ]) + } + ; + identifier: + SYM_IDENTIFIER { StringLeaf ($1) } + ; + + integer : SYM_INTEGER { IntLeaf ($1) }; + + lparams : + identifier rest_params { Node (Targ, [$1]) :: $2 } + | { [] }; + rest_params : + SYM_COMMA identifier rest_params { + Node (Targ, [$2]) :: $3 + } + | { [] }; + instrs : + | instr instrs { $1 :: $2 } + | { [] }; + linstrs : + SYM_LBRACE instrs SYM_RBRACE { Node (Tblock, $2) }; + instr : + identifier SYM_ASSIGN expr SYM_SEMICOLON { + Node (Tassign, [Node (Tassignvar,[$1; $3])]) + } + | SYM_IF SYM_LPARENTHESIS expr SYM_RPARENTHESIS linstrs ntelse { Node (Tif, [$3; $5; $6]) } + | SYM_WHILE SYM_LPARENTHESIS expr SYM_RPARENTHESIS instr { Node( Twhile, [$3; $5]) } + | SYM_RETURN expr SYM_SEMICOLON { Node(Treturn, [$2]) } + | SYM_PRINT expr SYM_SEMICOLON { Node(Tprint, [$2]) } + | linstrs { $1 }; + ntelse : + SYM_ELSE linstrs { $2 } + | { Node(Tblock, []) }; + + expr : + | expr SYM_EQUALITY expr { Node (Tceq, [$1; $3]) } + | expr SYM_NOTEQ expr { Node (Tne, [$1; $3]) } + | expr SYM_PLUS expr { Node (Tadd, [$1; $3]) } + | expr SYM_MINUS expr { Node (Tsub, [$1; $3]) } + | expr SYM_ASTERISK expr { Node (Tmul, [$1; $3]) } + | expr SYM_DIV expr { Node (Tdiv, [$1; $3]) } + | expr SYM_MOD expr { Node (Tmod, [$1; $3]) } + | expr SYM_LT expr { Node (Tclt, [$1; $3]) } + | expr SYM_GT expr { Node (Tcgt, [$1; $3]) } + | expr SYM_LEQ expr { Node (Tcle, [$1; $3]) } + | expr SYM_GEQ expr { Node (Tcge, [$1; $3]) } + | SYM_MINUS expr %prec UMINUS { Node (Tneg, [$2])} + | integer { Node(Tint, [$1])} + | identifier { $1 } + | SYM_LPARENTHESIS expr SYM_RPARENTHESIS { $2 } + ; diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ed02546d68f4e2fac21a337cbb14cb1ee9efec79 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,20 @@ +**/*.ast +**/*.cfg +**/*.cfg0 +**/*.cfg1 +**/*.cfg2 +**/*.cfg3 +**/*.e.dump +**/*.e.html +**/*.exe +**/*.json +**/*.lex +**/*.linear +**/*.linear1 +**/*.ltl +**/*.rig +**/*.rtl +**/*.s +**/*.svg +results.html +__pycache__ \ No newline at end of file diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7f5a992327ddebee63e223a3f3eda7070950bfbf --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,20 @@ +# if make is launched with a DIR variable, pass it as the -f option to test.py +# 'make DIR=basic/mul*.e' launches all the files starting with mul in the basic directory +# otherwise, use basic/*.e as a default +FILES := $(if $(DIR),$(DIR),basic/*.e) + +OPTS := $(if $(OPTS), $(OPTS),) + +.PHONY: all +all: ../ecomp + ./test.py -f $(FILES) $(OPTS) + +expect: ../ecomp + OCAMLRUNPARAM=b ./test.py --make-expect -f $(FILES) $(OPTS) --args 1 2 3 + OCAMLRUNPARAM=b ./test.py --make-expect -f $(FILES) $(OPTS) --args 14 12 3 8 12 + for f in $(FILES); do ../ecomp -f $$f -show-tokens $$f.expect_lexer; done + + +clean: + find . -name '*.rig' -or -name '*.ltl' -or -name '*.cfg' -or -name '*.exe' -or -name '*.s' -or -name '*.rtl' -or -name '*.ast' -or -name '*.cfg0' -or -name '*.cfg1' -or -name '*.cfg2' -or -name '*.cfg3' -or -name '*.riscv' -or -name '*.dump' -or -name '*.linear1' -or -name '*.linear' -or -name '*.html' -or -name '*.svg' -or -name '*.html' -or -name '*.lex' -or -name "*.json" | xargs -I{} rm {} + rm -rf __pycache__ diff --git a/tests/array/array.e b/tests/array/array.e new file mode 100644 index 0000000000000000000000000000000000000000..3617f797c2ef2e3c0c11dc9c5c67f8dcf3e8b42d --- /dev/null +++ b/tests/array/array.e @@ -0,0 +1,6 @@ +int main(){ + int t[10]; + t[0] = 5; + t[1] = 3 + t[0]; + return t[1]; +} diff --git a/tests/array/array.e.expect_14_12_3_8_12 b/tests/array/array.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/array/array.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/array/array.e.expect_1_2_3 b/tests/array/array.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/array/array.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/array/array.e.expect_lexer b/tests/array/array.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..472e69b5d3ba5acd455927bc861f79f7235a093a --- /dev/null +++ b/tests/array/array.e.expect_lexer @@ -0,0 +1,38 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(10) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(3) +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/array2.e b/tests/array/array2.e new file mode 100644 index 0000000000000000000000000000000000000000..e5d62947c4c4f1761ebe7407eb26e11cc5f15e4d --- /dev/null +++ b/tests/array/array2.e @@ -0,0 +1,15 @@ +int main(){ + int t[10]; + int i = 0; + while(i < 10){ + t[i] = i; + i = i + 1; + } + int sum = 0; + i = 0; + while(i < 10){ + sum = sum + t[i]; + i = i + 1; + } + return sum; +} diff --git a/tests/array/array2.e.expect_14_12_3_8_12 b/tests/array/array2.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..46eb758a30a5a05a4aed05c3fb6599f4445a5a08 --- /dev/null +++ b/tests/array/array2.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 45} \ No newline at end of file diff --git a/tests/array/array2.e.expect_1_2_3 b/tests/array/array2.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..46eb758a30a5a05a4aed05c3fb6599f4445a5a08 --- /dev/null +++ b/tests/array/array2.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 45} \ No newline at end of file diff --git a/tests/array/array2.e.expect_lexer b/tests/array/array2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..828b548a9e54df1376dc4fda16c747f52629985a --- /dev/null +++ b/tests/array/array2.e.expect_lexer @@ -0,0 +1,74 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(10) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(sum) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(sum) +SYM_ASSIGN +SYM_IDENTIFIER(sum) +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(sum) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/array_pass.e b/tests/array/array_pass.e new file mode 100644 index 0000000000000000000000000000000000000000..e63c576a4ad0a2eff3a33100544a77e2c6e20557 --- /dev/null +++ b/tests/array/array_pass.e @@ -0,0 +1,9 @@ +int f(int* a, int i){ + a[1] = i; + return 0; +} +int main(){ + int t[3]; + int x = f(t,5); + return t[1]; +} diff --git a/tests/array/array_pass.e.expect_14_12_3_8_12 b/tests/array/array_pass.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..2bd92018d953185fdf4602de6784eb8d56ae2f3c --- /dev/null +++ b/tests/array/array_pass.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5} \ No newline at end of file diff --git a/tests/array/array_pass.e.expect_1_2_3 b/tests/array/array_pass.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..2bd92018d953185fdf4602de6784eb8d56ae2f3c --- /dev/null +++ b/tests/array/array_pass.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5} \ No newline at end of file diff --git a/tests/array/array_pass.e.expect_lexer b/tests/array/array_pass.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..2b275af2969d6c5dba28bfb6af539a2de7bdf921 --- /dev/null +++ b/tests/array/array_pass.e.expect_lexer @@ -0,0 +1,51 @@ +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(i) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(3) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/array_sum.e b/tests/array/array_sum.e new file mode 100644 index 0000000000000000000000000000000000000000..bebd09a2489efcb74401c1b5a7208ede44d35a0f --- /dev/null +++ b/tests/array/array_sum.e @@ -0,0 +1,6 @@ +int main(){ + int t[2]; + t[0] = 1; + t[1] = 2; + return t[0] + t[1]; +} diff --git a/tests/array/array_sum.e.expect_14_12_3_8_12 b/tests/array/array_sum.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/array/array_sum.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/array/array_sum.e.expect_1_2_3 b/tests/array/array_sum.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/array/array_sum.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/array/array_sum.e.expect_lexer b/tests/array/array_sum.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..29192015aa8028937fe08c33f0c0162e42b2a14b --- /dev/null +++ b/tests/array/array_sum.e.expect_lexer @@ -0,0 +1,38 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/sort.e b/tests/array/sort.e new file mode 100644 index 0000000000000000000000000000000000000000..9d0eff9c28a715c9458ce84c960b18ad081148fd --- /dev/null +++ b/tests/array/sort.e @@ -0,0 +1,49 @@ +int swap(int* t ,int i,int j){ + + int tmp = t[i]; + t[i] = t[j]; + t[j] = tmp; + return 0; +} +int partition(int* t, int begin, int end, int pivot){ + swap(t, pivot, end); + int j = begin; + int i = begin; + while(i <= end - 1){ + if(t[i] <= t[end]){ + swap(t, i, j); + j = j + 1; + } + i = i + 1; + } + swap(t, end, j); + return j; +} +int sort(int* t, int begin, int end){ + if (begin < end){ + int pivot = begin; + pivot = partition(t, begin, end, pivot); + sort(t, begin, pivot-1); + sort(t, pivot+1, end); + } +} +int main(){ + int t[10]; + t[0] = 5; + t[1] = 7; + t[2] = 3; + t[3] = 8; + t[4] = 11; + t[5] = 1; + t[6] = 4; + t[7] = 7; + t[8] = 2; + t[9] = 9; + sort(t,0,9); + int i = 0; + while(i < 10){ + print(t[i]); + i = i + 1; + } + return 0; +} diff --git a/tests/array/sort.e.expect_14_12_3_8_12 b/tests/array/sort.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..bd654bf2fc45c712f7557bcc0dda4a86cc94a4ff --- /dev/null +++ b/tests/array/sort.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "1\n2\n3\n4\n5\n7\n7\n8\n9\n11\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/array/sort.e.expect_1_2_3 b/tests/array/sort.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..bd654bf2fc45c712f7557bcc0dda4a86cc94a4ff --- /dev/null +++ b/tests/array/sort.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1\n2\n3\n4\n5\n7\n7\n8\n9\n11\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/array/sort.e.expect_lexer b/tests/array/sort.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..d7168b157831414121db4466aa676bfbcf0f9f24 --- /dev/null +++ b/tests/array/sort.e.expect_lexer @@ -0,0 +1,322 @@ +SYM_INT +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(tmp) +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(j) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(j) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(tmp) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(partition) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(begin) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(end) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(pivot) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(pivot) +SYM_COMMA +SYM_IDENTIFIER(end) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_IDENTIFIER(begin) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(begin) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LEQ +SYM_IDENTIFIER(end) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_LEQ +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(end) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_IDENTIFIER(j) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(end) +SYM_COMMA +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(j) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(sort) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(begin) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(end) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(begin) +SYM_LT +SYM_IDENTIFIER(end) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(pivot) +SYM_ASSIGN +SYM_IDENTIFIER(begin) +SYM_SEMICOLON +SYM_IDENTIFIER(pivot) +SYM_ASSIGN +SYM_IDENTIFIER(partition) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(begin) +SYM_COMMA +SYM_IDENTIFIER(end) +SYM_COMMA +SYM_IDENTIFIER(pivot) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(sort) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(begin) +SYM_COMMA +SYM_IDENTIFIER(pivot) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(sort) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(pivot) +SYM_PLUS +SYM_INTEGER(1) +SYM_COMMA +SYM_IDENTIFIER(end) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(10) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(3) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(4) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(11) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(5) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(6) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(4) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(7) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(8) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(9) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(9) +SYM_SEMICOLON +SYM_IDENTIFIER(sort) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INTEGER(0) +SYM_COMMA +SYM_INTEGER(9) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/structtab.e b/tests/array/structtab.e new file mode 100644 index 0000000000000000000000000000000000000000..f28c3d354c19b88c5063634ef470148f7bf18852 --- /dev/null +++ b/tests/array/structtab.e @@ -0,0 +1,10 @@ +struct S { + int t[4]; +}; + +int main(){ + struct S s; + (s.t)[0] = 1; + print_int((s.t)[0]); + return (s.t)[0]; +} diff --git a/tests/array/structtab.e.expect_14_12_3_8_12 b/tests/array/structtab.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..8858d4cccf47c58c61f15b14873ea04ff1793568 --- /dev/null +++ b/tests/array/structtab.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "1", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/array/structtab.e.expect_1_2_3 b/tests/array/structtab.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..8858d4cccf47c58c61f15b14873ea04ff1793568 --- /dev/null +++ b/tests/array/structtab.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/array/structtab.e.expect_lexer b/tests/array/structtab.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..1566d173fdc41a967b051fd8f02525da716c01e2 --- /dev/null +++ b/tests/array/structtab.e.expect_lexer @@ -0,0 +1,55 @@ +SYM_STRUCT +SYM_IDENTIFIER(S) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(4) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_STRUCT +SYM_IDENTIFIER(S) +SYM_IDENTIFIER(s) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(s) +SYM_POINT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_IDENTIFIER(print_int) +SYM_LPARENTHESIS +SYM_LPARENTHESIS +SYM_IDENTIFIER(s) +SYM_POINT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(s) +SYM_POINT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/swap.e b/tests/array/swap.e new file mode 100644 index 0000000000000000000000000000000000000000..2b86a5a790b84294d8dd1073fc4a2172a1ff9fd4 --- /dev/null +++ b/tests/array/swap.e @@ -0,0 +1,15 @@ +int swap(int* t,int i,int j){ + int tmp = t[i]; + t[i] = t[j]; + t[j] = tmp; + return 0; +} +int main(){ + int t[10]; + t[0] = 5; + t[1] = 12; + swap(t,0,1); + print(t[0]); + print(t[1]); + return 0; +} diff --git a/tests/array/swap.e.expect_14_12_3_8_12 b/tests/array/swap.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..5e0e1d8e95659264ba481f9f8365906d19a91516 --- /dev/null +++ b/tests/array/swap.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "12\n5\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/array/swap.e.expect_1_2_3 b/tests/array/swap.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..5e0e1d8e95659264ba481f9f8365906d19a91516 --- /dev/null +++ b/tests/array/swap.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "12\n5\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/array/swap.e.expect_lexer b/tests/array/swap.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..aa6f81eaa86e76a2bcf656db8fde7e0e357f667d --- /dev/null +++ b/tests/array/swap.e.expect_lexer @@ -0,0 +1,98 @@ +SYM_INT +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(tmp) +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(j) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(j) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(tmp) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(10) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INTEGER(0) +SYM_COMMA +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/1_or_3a.e b/tests/basic/1_or_3a.e new file mode 100644 index 0000000000000000000000000000000000000000..21b060753a719ec48fa8f4583e873e73987d68c2 --- /dev/null +++ b/tests/basic/1_or_3a.e @@ -0,0 +1,6 @@ +main(a){ + if(a > 12){ + a = 1; + } else { a = 3 * a; } + return a; +} diff --git a/tests/basic/1_or_3a.e.expect_14_12_3_8_12 b/tests/basic/1_or_3a.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/1_or_3a.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/1_or_3a.e.expect_1_2_3 b/tests/basic/1_or_3a.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/basic/1_or_3a.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/basic/1_or_3a.e.expect_lexer b/tests/basic/1_or_3a.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..0d5f6908dc21bfca2e29b0f15711d0128c2b970e --- /dev/null +++ b/tests/basic/1_or_3a.e.expect_lexer @@ -0,0 +1,31 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_GT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_ASTERISK +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/1_or_4.e b/tests/basic/1_or_4.e new file mode 100644 index 0000000000000000000000000000000000000000..e4b124125bec7ebb7d62d47f13de7276760342b8 --- /dev/null +++ b/tests/basic/1_or_4.e @@ -0,0 +1,16 @@ +main(a){ + if(a < 12){ + if(a < 23){ + x = 1; + } else { + x = 3; + } + } else { + if (a < 12){ + x = 2; + } else { + x = 4; + } + } + return x; +} diff --git a/tests/basic/1_or_4.e.expect_14_12_3_8_12 b/tests/basic/1_or_4.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..da50e81a3771635762245edfab77e00ab52b5332 --- /dev/null +++ b/tests/basic/1_or_4.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 4} \ No newline at end of file diff --git a/tests/basic/1_or_4.e.expect_1_2_3 b/tests/basic/1_or_4.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/1_or_4.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/1_or_4.e.expect_lexer b/tests/basic/1_or_4.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..585781dc1621bafc762d4b44b6f024fef4e4849b --- /dev/null +++ b/tests/basic/1_or_4.e.expect_lexer @@ -0,0 +1,59 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_LT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_LT +SYM_INTEGER(23) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_LT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(4) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/2xpy.e b/tests/basic/2xpy.e new file mode 100644 index 0000000000000000000000000000000000000000..bfdce0faa63fa3755dfc6a2c768b2137347ef9be --- /dev/null +++ b/tests/basic/2xpy.e @@ -0,0 +1,3 @@ +main(x,y){ + return 2 * x + y; +} diff --git a/tests/basic/2xpy.e.expect_14_12_3_8_12 b/tests/basic/2xpy.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..1cd05b5f658b129703da224fe44fb509455cab2f --- /dev/null +++ b/tests/basic/2xpy.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 40} \ No newline at end of file diff --git a/tests/basic/2xpy.e.expect_1_2_3 b/tests/basic/2xpy.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..da50e81a3771635762245edfab77e00ab52b5332 --- /dev/null +++ b/tests/basic/2xpy.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 4} \ No newline at end of file diff --git a/tests/basic/2xpy.e.expect_lexer b/tests/basic/2xpy.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..b5775c3fa5642199bb9b3fa6919eb91fcd74ebdb --- /dev/null +++ b/tests/basic/2xpy.e.expect_lexer @@ -0,0 +1,16 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(2) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/35gt12.e b/tests/basic/35gt12.e new file mode 100644 index 0000000000000000000000000000000000000000..734c694c3d7b2e411af096c35c642771e66cd22f --- /dev/null +++ b/tests/basic/35gt12.e @@ -0,0 +1,7 @@ +main(){ + a = 5 * 7; + if(a > 12){ + a = 1; + } else { a = 3 * a; } + return a; +} diff --git a/tests/basic/35gt12.e.expect_14_12_3_8_12 b/tests/basic/35gt12.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/35gt12.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/35gt12.e.expect_1_2_3 b/tests/basic/35gt12.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/35gt12.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/35gt12.e.expect_lexer b/tests/basic/35gt12.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..35656f5997e34208ee9bc34dafdf9e20f28bbe6a --- /dev/null +++ b/tests/basic/35gt12.e.expect_lexer @@ -0,0 +1,36 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_ASTERISK +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_GT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_ASTERISK +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/a_19.e b/tests/basic/a_19.e new file mode 100644 index 0000000000000000000000000000000000000000..ac932ddb462fa0e653c366a89ba1b2868f456002 --- /dev/null +++ b/tests/basic/a_19.e @@ -0,0 +1,4 @@ +main(){ +a = 3; +return (a*5)+4*(3-2); +} diff --git a/tests/basic/a_19.e.expect_14_12_3_8_12 b/tests/basic/a_19.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..41cdc3312527617536f3eb8dc095834bef47d4ef --- /dev/null +++ b/tests/basic/a_19.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 19} \ No newline at end of file diff --git a/tests/basic/a_19.e.expect_1_2_3 b/tests/basic/a_19.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..41cdc3312527617536f3eb8dc095834bef47d4ef --- /dev/null +++ b/tests/basic/a_19.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 19} \ No newline at end of file diff --git a/tests/basic/a_19.e.expect_lexer b/tests/basic/a_19.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..508fd27021da2b3609aa2c514a31cb6b684f9b26 --- /dev/null +++ b/tests/basic/a_19.e.expect_lexer @@ -0,0 +1,25 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_ASTERISK +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_PLUS +SYM_INTEGER(4) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_MINUS +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/a_simple_variable_23.e b/tests/basic/a_simple_variable_23.e new file mode 100644 index 0000000000000000000000000000000000000000..5c6d31ab6afa64f323d576dda90fa8ef0a7bdb3a --- /dev/null +++ b/tests/basic/a_simple_variable_23.e @@ -0,0 +1,4 @@ +main(){ + a_simple_variable = 8; + return a_simple_variable + 5 * 3; +} diff --git a/tests/basic/a_simple_variable_23.e.expect_14_12_3_8_12 b/tests/basic/a_simple_variable_23.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..810d9ab964ab9318fda9fcf35cf83eb5cb49d546 --- /dev/null +++ b/tests/basic/a_simple_variable_23.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23} \ No newline at end of file diff --git a/tests/basic/a_simple_variable_23.e.expect_1_2_3 b/tests/basic/a_simple_variable_23.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..810d9ab964ab9318fda9fcf35cf83eb5cb49d546 --- /dev/null +++ b/tests/basic/a_simple_variable_23.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23} \ No newline at end of file diff --git a/tests/basic/a_simple_variable_23.e.expect_lexer b/tests/basic/a_simple_variable_23.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..08afe2c5c8ec48dfb893cbcd95c1fc5f95acf220 --- /dev/null +++ b/tests/basic/a_simple_variable_23.e.expect_lexer @@ -0,0 +1,17 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a_simple_variable) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(a_simple_variable) +SYM_PLUS +SYM_INTEGER(5) +SYM_ASTERISK +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/arg-test.e b/tests/basic/arg-test.e new file mode 100644 index 0000000000000000000000000000000000000000..a265d644923b1ca6ded782d8faeb94756d90c0f6 --- /dev/null +++ b/tests/basic/arg-test.e @@ -0,0 +1,14 @@ +main(n, m){ + a = 10; + b = 20; + if (3 > n){ + x = a; + } else { + x = b; + } + return x; +} +f(x){ + n = 3; + return 3 * x; +} diff --git a/tests/basic/arg-test.e.expect_14_12_3_8_12 b/tests/basic/arg-test.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..4de51e4d38522a71a09ab4c411d09d99f1e80932 --- /dev/null +++ b/tests/basic/arg-test.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 20} \ No newline at end of file diff --git a/tests/basic/arg-test.e.expect_1_2_3 b/tests/basic/arg-test.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..b55e8e280c5e45c2be40c1a6b56defcd278107ea --- /dev/null +++ b/tests/basic/arg-test.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 10} \ No newline at end of file diff --git a/tests/basic/arg-test.e.expect_lexer b/tests/basic/arg-test.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..9b52bc75f63d36218ee2911ee012d6b22b7f74f6 --- /dev/null +++ b/tests/basic/arg-test.e.expect_lexer @@ -0,0 +1,54 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_COMMA +SYM_IDENTIFIER(m) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_INTEGER(20) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_GT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(3) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/comment++.e b/tests/basic/comment++.e new file mode 100644 index 0000000000000000000000000000000000000000..b2f50ff1e3cebaa1c3df68395f1511534cce10a1 --- /dev/null +++ b/tests/basic/comment++.e @@ -0,0 +1,5 @@ +/** /**/ +/** Commentaire ! */ +main(){ + return 23; +} diff --git a/tests/basic/comment++.e.expect_14_12_3_8_12 b/tests/basic/comment++.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..810d9ab964ab9318fda9fcf35cf83eb5cb49d546 --- /dev/null +++ b/tests/basic/comment++.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23} \ No newline at end of file diff --git a/tests/basic/comment++.e.expect_1_2_3 b/tests/basic/comment++.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..810d9ab964ab9318fda9fcf35cf83eb5cb49d546 --- /dev/null +++ b/tests/basic/comment++.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23} \ No newline at end of file diff --git a/tests/basic/comment++.e.expect_lexer b/tests/basic/comment++.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..e8177132a7ceef3df7f9fac739c9f0d9b9faa029 --- /dev/null +++ b/tests/basic/comment++.e.expect_lexer @@ -0,0 +1,9 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(23) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/comment.e b/tests/basic/comment.e new file mode 100644 index 0000000000000000000000000000000000000000..01a142dc1b75ed404c38a26c1759b0b7bf12c6eb --- /dev/null +++ b/tests/basic/comment.e @@ -0,0 +1,6 @@ +// Hello, this is a comment +main(a){ +/* a multi-line +comment*/ +return a / 2; +} diff --git a/tests/basic/comment.e.expect_14_12_3_8_12 b/tests/basic/comment.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..fde1f638d743ba12ee106e88aa76743c84363167 --- /dev/null +++ b/tests/basic/comment.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 7} \ No newline at end of file diff --git a/tests/basic/comment.e.expect_1_2_3 b/tests/basic/comment.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/basic/comment.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/comment.e.expect_lexer b/tests/basic/comment.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..f2d539572fe86e6e5f3c0d220ce08134ac0f78a1 --- /dev/null +++ b/tests/basic/comment.e.expect_lexer @@ -0,0 +1,12 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_DIV +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/dec_to_0.e b/tests/basic/dec_to_0.e new file mode 100644 index 0000000000000000000000000000000000000000..9a784f5abff2498d6d58030a370b01f7a9e72dfa --- /dev/null +++ b/tests/basic/dec_to_0.e @@ -0,0 +1,6 @@ +main(n){ + while(n > 0){ + n = n - 1; + } + return n; +} diff --git a/tests/basic/dec_to_0.e.expect_14_12_3_8_12 b/tests/basic/dec_to_0.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/basic/dec_to_0.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/dec_to_0.e.expect_1_2_3 b/tests/basic/dec_to_0.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/basic/dec_to_0.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/dec_to_0.e.expect_lexer b/tests/basic/dec_to_0.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..2223d36d3b8f6df5fb2f5a15b23fa870cada886d --- /dev/null +++ b/tests/basic/dec_to_0.e.expect_lexer @@ -0,0 +1,24 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/double.e b/tests/basic/double.e new file mode 100644 index 0000000000000000000000000000000000000000..02c6042946b5339013f8413e27a4dde8e7a1526f --- /dev/null +++ b/tests/basic/double.e @@ -0,0 +1,4 @@ +main(n){ + n = n * 2; + return n; +} diff --git a/tests/basic/double.e.expect_14_12_3_8_12 b/tests/basic/double.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..e9f03bd9e74c0ac09410036fe9b382b569b3aeb0 --- /dev/null +++ b/tests/basic/double.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 28} \ No newline at end of file diff --git a/tests/basic/double.e.expect_1_2_3 b/tests/basic/double.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..df1c5a5ba4e1647c7e3409ee9539a3583afa9bdf --- /dev/null +++ b/tests/basic/double.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/basic/double.e.expect_lexer b/tests/basic/double.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..1f829afd5b2f723498a9cbc18efc879dcfdd9bd1 --- /dev/null +++ b/tests/basic/double.e.expect_lexer @@ -0,0 +1,16 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_ASTERISK +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/fac.e b/tests/basic/fac.e new file mode 100644 index 0000000000000000000000000000000000000000..b6818fe1d06d13227493593193574a05ee66cc61 --- /dev/null +++ b/tests/basic/fac.e @@ -0,0 +1,12 @@ +main(n){ + if(n < 0) { n = 0; } + else { } + + res = 1; + while(n > 0){ + res = n * res; + n = n - 1; + } + + return res; +} diff --git a/tests/basic/fac.e.expect_14_12_3_8_12 b/tests/basic/fac.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..fa26d1e83fb28859094630973eb4f1a6280efb04 --- /dev/null +++ b/tests/basic/fac.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 87178291200} \ No newline at end of file diff --git a/tests/basic/fac.e.expect_1_2_3 b/tests/basic/fac.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/fac.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/fac.e.expect_lexer b/tests/basic/fac.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..e863166da4193c1012c3c00a6037f44c543bb5c7 --- /dev/null +++ b/tests/basic/fac.e.expect_lexer @@ -0,0 +1,49 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_LT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_ASTERISK +SYM_IDENTIFIER(res) +SYM_SEMICOLON +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(res) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/fibbetter.e b/tests/basic/fibbetter.e new file mode 100644 index 0000000000000000000000000000000000000000..0cd7891adfe1ef6af7e38abf57e7c5d1a8add89d --- /dev/null +++ b/tests/basic/fibbetter.e @@ -0,0 +1,12 @@ +main(n){ + i = 0; // t6 + j = 1; // t5 + k = 0; // t4 + while(k < n){ + tmp = i + j; + i = j; + j = tmp; + k = k + 1; + } + return i; +} diff --git a/tests/basic/fibbetter.e.expect_14_12_3_8_12 b/tests/basic/fibbetter.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..1fef2374b55b0d9496617cec0a857a07906f799f --- /dev/null +++ b/tests/basic/fibbetter.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 377} \ No newline at end of file diff --git a/tests/basic/fibbetter.e.expect_1_2_3 b/tests/basic/fibbetter.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/fibbetter.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/fibbetter.e.expect_lexer b/tests/basic/fibbetter.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..99f49ca1c33c4b29f657230ca95b7dc617742448 --- /dev/null +++ b/tests/basic/fibbetter.e.expect_lexer @@ -0,0 +1,50 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_IDENTIFIER(k) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(k) +SYM_LT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(tmp) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_IDENTIFIER(j) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(j) +SYM_SEMICOLON +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_IDENTIFIER(tmp) +SYM_SEMICOLON +SYM_IDENTIFIER(k) +SYM_ASSIGN +SYM_IDENTIFIER(k) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/gcd.e b/tests/basic/gcd.e new file mode 100644 index 0000000000000000000000000000000000000000..cfe970c57b7c72a853307fa457398bfae4769e7a --- /dev/null +++ b/tests/basic/gcd.e @@ -0,0 +1,8 @@ +main(a,b){ + while(b != 0){ + t = b; + b = a % b; + a = t; + } + return a; +} diff --git a/tests/basic/gcd.e.expect_14_12_3_8_12 b/tests/basic/gcd.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..df1c5a5ba4e1647c7e3409ee9539a3583afa9bdf --- /dev/null +++ b/tests/basic/gcd.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/basic/gcd.e.expect_1_2_3 b/tests/basic/gcd.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/gcd.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/gcd.e.expect_lexer b/tests/basic/gcd.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..d9c06123b1c9abd0938e13b24bf2585dbf654c38 --- /dev/null +++ b/tests/basic/gcd.e.expect_lexer @@ -0,0 +1,34 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_NOTEQ +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(t) +SYM_ASSIGN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_MOD +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/just_a_variable_37.e b/tests/basic/just_a_variable_37.e new file mode 100644 index 0000000000000000000000000000000000000000..51add73273ef1612c1b90276c8ad3b7fc7129f0f --- /dev/null +++ b/tests/basic/just_a_variable_37.e @@ -0,0 +1,4 @@ +main(){ + just_a_variable = 37; + return just_a_variable; +} diff --git a/tests/basic/just_a_variable_37.e.expect_14_12_3_8_12 b/tests/basic/just_a_variable_37.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..016d6cd30c8fc3fd3f0ef57bfe183aa6023661fa --- /dev/null +++ b/tests/basic/just_a_variable_37.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37} \ No newline at end of file diff --git a/tests/basic/just_a_variable_37.e.expect_1_2_3 b/tests/basic/just_a_variable_37.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..016d6cd30c8fc3fd3f0ef57bfe183aa6023661fa --- /dev/null +++ b/tests/basic/just_a_variable_37.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37} \ No newline at end of file diff --git a/tests/basic/just_a_variable_37.e.expect_lexer b/tests/basic/just_a_variable_37.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..7073c8076d32aba9a14f97777052e3e1906eea7e --- /dev/null +++ b/tests/basic/just_a_variable_37.e.expect_lexer @@ -0,0 +1,13 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(just_a_variable) +SYM_ASSIGN +SYM_INTEGER(37) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(just_a_variable) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/lexerror.e b/tests/basic/lexerror.e new file mode 100644 index 0000000000000000000000000000000000000000..dd56369989be5a3cafb3405f8056f6d6c3df2e37 --- /dev/null +++ b/tests/basic/lexerror.e @@ -0,0 +1 @@ +&$ diff --git a/tests/basic/lexerror.e.expect_lexer b/tests/basic/lexerror.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/basic/loop.e b/tests/basic/loop.e new file mode 100644 index 0000000000000000000000000000000000000000..24652c93c8907d546c77f66446068755466bedd4 --- /dev/null +++ b/tests/basic/loop.e @@ -0,0 +1,15 @@ +main(){ + i = 10; + a = 2; + res = 0; + while(i > 0){ + x = a + a; + if(a > 4){ + res = res + x; + } else { + res = res - x; + } + i = i - 1; + } + return res; +} diff --git a/tests/basic/loop.e.expect_14_12_3_8_12 b/tests/basic/loop.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..919b014322ed6e46ea283467b56f755be461e3c5 --- /dev/null +++ b/tests/basic/loop.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": -40} \ No newline at end of file diff --git a/tests/basic/loop.e.expect_1_2_3 b/tests/basic/loop.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..919b014322ed6e46ea283467b56f755be461e3c5 --- /dev/null +++ b/tests/basic/loop.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": -40} \ No newline at end of file diff --git a/tests/basic/loop.e.expect_lexer b/tests/basic/loop.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..b2b14285bdee5eb480b2cab773cfd3aa64101ef9 --- /dev/null +++ b/tests/basic/loop.e.expect_lexer @@ -0,0 +1,64 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_GT +SYM_INTEGER(4) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_MINUS +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(res) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/loop2.e b/tests/basic/loop2.e new file mode 100644 index 0000000000000000000000000000000000000000..985a3053936c14f6507c8142a5b0b59990eec3e9 --- /dev/null +++ b/tests/basic/loop2.e @@ -0,0 +1,12 @@ +main(){ + i = 20; + while(i > 0){ + if(i < 5){ + a = 5; + } else { + a = 6; + } + i = i - 1; + } + return i; +} diff --git a/tests/basic/loop2.e.expect_14_12_3_8_12 b/tests/basic/loop2.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/basic/loop2.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/loop2.e.expect_1_2_3 b/tests/basic/loop2.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/basic/loop2.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/loop2.e.expect_lexer b/tests/basic/loop2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..49c48c916d4a853a0ab850055e335a22a4361cc9 --- /dev/null +++ b/tests/basic/loop2.e.expect_lexer @@ -0,0 +1,46 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(20) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(6) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/loop3.e b/tests/basic/loop3.e new file mode 100644 index 0000000000000000000000000000000000000000..a99573b44587eb67ff019e540007894f357b019d --- /dev/null +++ b/tests/basic/loop3.e @@ -0,0 +1,14 @@ +main(){ + i = 20; + c = 8; + a = 5; + b = 0; + while(i > 0){ + if(i < 5){ + a = 4 + c; + } + b = b + a; + i = i - 1; + } + return b; +} diff --git a/tests/basic/loop3.e.expect_14_12_3_8_12 b/tests/basic/loop3.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..feb4775c473e7c8f42a997c5dc5a04ce52c73eaa --- /dev/null +++ b/tests/basic/loop3.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 128} \ No newline at end of file diff --git a/tests/basic/loop3.e.expect_1_2_3 b/tests/basic/loop3.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..feb4775c473e7c8f42a997c5dc5a04ce52c73eaa --- /dev/null +++ b/tests/basic/loop3.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 128} \ No newline at end of file diff --git a/tests/basic/loop3.e.expect_lexer b/tests/basic/loop3.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..832926e80f7a2578d0023bb9aa346ebdb15b21ea --- /dev/null +++ b/tests/basic/loop3.e.expect_lexer @@ -0,0 +1,59 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(20) +SYM_SEMICOLON +SYM_IDENTIFIER(c) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(4) +SYM_PLUS +SYM_IDENTIFIER(c) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_IDENTIFIER(b) +SYM_PLUS +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/loop4.e b/tests/basic/loop4.e new file mode 100644 index 0000000000000000000000000000000000000000..53bd91a153e7077c6e48bf7fa6799b84ce0b65a7 --- /dev/null +++ b/tests/basic/loop4.e @@ -0,0 +1,20 @@ +main(){ + i = 10; + a = 2; + res = 0; + while(i > 0){ + x = a + a; + y = 1 + x; + if(i > 4){ + res = res + x; + } else { + if (i < 2){ + res = res - y; + } else { + res = res + x - y; + } + } + i = i - 1; + } + return res; +} diff --git a/tests/basic/loop4.e.expect_14_12_3_8_12 b/tests/basic/loop4.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..4c5f6717cdc873d39fe41829359cd3390a60c009 --- /dev/null +++ b/tests/basic/loop4.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 16} \ No newline at end of file diff --git a/tests/basic/loop4.e.expect_1_2_3 b/tests/basic/loop4.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..4c5f6717cdc873d39fe41829359cd3390a60c009 --- /dev/null +++ b/tests/basic/loop4.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 16} \ No newline at end of file diff --git a/tests/basic/loop4.e.expect_lexer b/tests/basic/loop4.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..8bf2ff89ccfceec363016ef4768b3d86d644754d --- /dev/null +++ b/tests/basic/loop4.e.expect_lexer @@ -0,0 +1,89 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(4) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_MINUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_MINUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(res) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/lots-of-regs.e b/tests/basic/lots-of-regs.e new file mode 100644 index 0000000000000000000000000000000000000000..2495c7855016762430ba4f6927e798d036f0f723 --- /dev/null +++ b/tests/basic/lots-of-regs.e @@ -0,0 +1,21 @@ +main(a, b){ + x = a; + y = b; + z = a * b; + t = a + b + z; + u = z - 3; + v = x - u; + w = a * x + z - t; + i = 35; + j = i * w; + k = 8 * t + z / i; + l = 19 * k; + m = 12; + n = 12; + o = 12; + p = 12; + q = 12; + r = 12; + s = 12; + return x + y + z + t + u + v + w + i + j + k + l + m + n + o + p + q + r + s; +} diff --git a/tests/basic/lots-of-regs.e.expect_14_12_3_8_12 b/tests/basic/lots-of-regs.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..36bc30ad8e3a677ef8d97fda646b7d615463399b --- /dev/null +++ b/tests/basic/lots-of-regs.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37761} \ No newline at end of file diff --git a/tests/basic/lots-of-regs.e.expect_1_2_3 b/tests/basic/lots-of-regs.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..0f7c0dd6058a095a430101f739d92a8259ed714c --- /dev/null +++ b/tests/basic/lots-of-regs.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 858} \ No newline at end of file diff --git a/tests/basic/lots-of-regs.e.expect_lexer b/tests/basic/lots-of-regs.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..522f1b2f4a03f3850091bed481b1219bc6007af2 --- /dev/null +++ b/tests/basic/lots-of-regs.e.expect_lexer @@ -0,0 +1,144 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_ASTERISK +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(b) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_SEMICOLON +SYM_IDENTIFIER(u) +SYM_ASSIGN +SYM_IDENTIFIER(z) +SYM_MINUS +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(v) +SYM_ASSIGN +SYM_IDENTIFIER(x) +SYM_MINUS +SYM_IDENTIFIER(u) +SYM_SEMICOLON +SYM_IDENTIFIER(w) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_MINUS +SYM_IDENTIFIER(t) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(35) +SYM_SEMICOLON +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(w) +SYM_SEMICOLON +SYM_IDENTIFIER(k) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_DIV +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_IDENTIFIER(l) +SYM_ASSIGN +SYM_INTEGER(19) +SYM_ASTERISK +SYM_IDENTIFIER(k) +SYM_SEMICOLON +SYM_IDENTIFIER(m) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(o) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(p) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(q) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(r) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(s) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_PLUS +SYM_IDENTIFIER(u) +SYM_PLUS +SYM_IDENTIFIER(v) +SYM_PLUS +SYM_IDENTIFIER(w) +SYM_PLUS +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_IDENTIFIER(j) +SYM_PLUS +SYM_IDENTIFIER(k) +SYM_PLUS +SYM_IDENTIFIER(l) +SYM_PLUS +SYM_IDENTIFIER(m) +SYM_PLUS +SYM_IDENTIFIER(n) +SYM_PLUS +SYM_IDENTIFIER(o) +SYM_PLUS +SYM_IDENTIFIER(p) +SYM_PLUS +SYM_IDENTIFIER(q) +SYM_PLUS +SYM_IDENTIFIER(r) +SYM_PLUS +SYM_IDENTIFIER(s) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/muldivmod.e b/tests/basic/muldivmod.e new file mode 100644 index 0000000000000000000000000000000000000000..efa01ede530c267df1f32cc44b41dfadbbb2305d --- /dev/null +++ b/tests/basic/muldivmod.e @@ -0,0 +1,5 @@ +main(){ +i = 823333; +j = 7392; +return (i*j/7) % 10; +} diff --git a/tests/basic/muldivmod.e.expect_14_12_3_8_12 b/tests/basic/muldivmod.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/basic/muldivmod.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/basic/muldivmod.e.expect_1_2_3 b/tests/basic/muldivmod.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/basic/muldivmod.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/basic/muldivmod.e.expect_lexer b/tests/basic/muldivmod.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..483864f7e2e3594ee9d7aed022fd9e5f36205ac3 --- /dev/null +++ b/tests/basic/muldivmod.e.expect_lexer @@ -0,0 +1,25 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(823333) +SYM_SEMICOLON +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_INTEGER(7392) +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(j) +SYM_DIV +SYM_INTEGER(7) +SYM_RPARENTHESIS +SYM_MOD +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/mulmulmul.e b/tests/basic/mulmulmul.e new file mode 100644 index 0000000000000000000000000000000000000000..3af73f12e9b08509ce6075d5321632f1fb5c7c2d --- /dev/null +++ b/tests/basic/mulmulmul.e @@ -0,0 +1,3 @@ +main(){ + return 1 * (2 * (3 * 4 * (5 * 6) * 7)); +} diff --git a/tests/basic/mulmulmul.e.expect_14_12_3_8_12 b/tests/basic/mulmulmul.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..6bca38098d934670e1e51e5369182a2a6ec01cee --- /dev/null +++ b/tests/basic/mulmulmul.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5040} \ No newline at end of file diff --git a/tests/basic/mulmulmul.e.expect_1_2_3 b/tests/basic/mulmulmul.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..6bca38098d934670e1e51e5369182a2a6ec01cee --- /dev/null +++ b/tests/basic/mulmulmul.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5040} \ No newline at end of file diff --git a/tests/basic/mulmulmul.e.expect_lexer b/tests/basic/mulmulmul.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..260dd829aa287024397dfc011ed2470865255560 --- /dev/null +++ b/tests/basic/mulmulmul.e.expect_lexer @@ -0,0 +1,27 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(1) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_INTEGER(2) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_ASTERISK +SYM_INTEGER(4) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_INTEGER(5) +SYM_ASTERISK +SYM_INTEGER(6) +SYM_RPARENTHESIS +SYM_ASTERISK +SYM_INTEGER(7) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/prime.e b/tests/basic/prime.e new file mode 100644 index 0000000000000000000000000000000000000000..5a698beff93899198a03cde57d7cb39890f3ab7f --- /dev/null +++ b/tests/basic/prime.e @@ -0,0 +1,20 @@ +main(n){ + print(n); + while(n%2 == 0){ + print(2); + n = n / 2; + } + f = 3; + while ( f * f <= n ){ + if ( n % f == 0 ) { + print(f); + n = n / f; + } else { + f = f + 2; + } + } + if ( n != 1 ) { + print(n); + } + return 0; +} diff --git a/tests/basic/prime.e.expect_14_12_3_8_12 b/tests/basic/prime.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..372d54057e19aff0c25c2287e77ed03cfed94b98 --- /dev/null +++ b/tests/basic/prime.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "14\n2\n7\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/prime.e.expect_1_2_3 b/tests/basic/prime.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..eb1504dc83ea5564e4adb5e00344555cd86cc389 --- /dev/null +++ b/tests/basic/prime.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/prime.e.expect_lexer b/tests/basic/prime.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..f0bf1401e34017550e237e8b34a380941e71e584 --- /dev/null +++ b/tests/basic/prime.e.expect_lexer @@ -0,0 +1,93 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_PRINT +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MOD +SYM_INTEGER(2) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_PRINT +SYM_LPARENTHESIS +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_DIV +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(f) +SYM_ASTERISK +SYM_IDENTIFIER(f) +SYM_LEQ +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MOD +SYM_IDENTIFIER(f) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_PRINT +SYM_LPARENTHESIS +SYM_IDENTIFIER(f) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_DIV +SYM_IDENTIFIER(f) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(f) +SYM_ASSIGN +SYM_IDENTIFIER(f) +SYM_PLUS +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_NOTEQ +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_PRINT +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/print_int.e b/tests/basic/print_int.e new file mode 100644 index 0000000000000000000000000000000000000000..cab876f9a9ea9a47f2e95ab22fda738b003a04a6 --- /dev/null +++ b/tests/basic/print_int.e @@ -0,0 +1,4 @@ +main(){ + print(300); + return 0; + } diff --git a/tests/basic/print_int.e.expect_14_12_3_8_12 b/tests/basic/print_int.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..5867cb8e972a0f91df6cca403a804ced2b94c8f2 --- /dev/null +++ b/tests/basic/print_int.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "300\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/print_int.e.expect_1_2_3 b/tests/basic/print_int.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..5867cb8e972a0f91df6cca403a804ced2b94c8f2 --- /dev/null +++ b/tests/basic/print_int.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "300\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/print_int.e.expect_lexer b/tests/basic/print_int.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..e539086d34d21bb5ffe3c13f0233257524ceae40 --- /dev/null +++ b/tests/basic/print_int.e.expect_lexer @@ -0,0 +1,14 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_PRINT +SYM_LPARENTHESIS +SYM_INTEGER(300) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/range_0_10.e b/tests/basic/range_0_10.e new file mode 100644 index 0000000000000000000000000000000000000000..8985a8e6fc06e258cf5510e8a9ab2279606e04b6 --- /dev/null +++ b/tests/basic/range_0_10.e @@ -0,0 +1,8 @@ +main(n){ + if(n > 10) { n = 10; } + else { + if ( n < 0 ) { n = 0; } + else { } + } + return n; +} diff --git a/tests/basic/range_0_10.e.expect_14_12_3_8_12 b/tests/basic/range_0_10.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..b55e8e280c5e45c2be40c1a6b56defcd278107ea --- /dev/null +++ b/tests/basic/range_0_10.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 10} \ No newline at end of file diff --git a/tests/basic/range_0_10.e.expect_1_2_3 b/tests/basic/range_0_10.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/range_0_10.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/range_0_10.e.expect_lexer b/tests/basic/range_0_10.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..6683dd60ef5b8f534dbfbb9dd64ac02ed773bcc0 --- /dev/null +++ b/tests/basic/range_0_10.e.expect_lexer @@ -0,0 +1,40 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_LT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RBRACE +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/range_10_0_then_dec0.e b/tests/basic/range_10_0_then_dec0.e new file mode 100644 index 0000000000000000000000000000000000000000..4266656dc0b3e923f70b34e1e1b578ac327827fa --- /dev/null +++ b/tests/basic/range_10_0_then_dec0.e @@ -0,0 +1,11 @@ +main(n){ + if(n > 10) { n = 10; } + else { + if ( n < 0 ) { n = 0; } + else { } + } + while( n > 0){ + n=n-1; + } + return n; +} diff --git a/tests/basic/range_10_0_then_dec0.e.expect_14_12_3_8_12 b/tests/basic/range_10_0_then_dec0.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/basic/range_10_0_then_dec0.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/range_10_0_then_dec0.e.expect_1_2_3 b/tests/basic/range_10_0_then_dec0.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/basic/range_10_0_then_dec0.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/range_10_0_then_dec0.e.expect_lexer b/tests/basic/range_10_0_then_dec0.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..35a46cd21dc8f5575e31fa480636e979bf697644 --- /dev/null +++ b/tests/basic/range_10_0_then_dec0.e.expect_lexer @@ -0,0 +1,54 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_LT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RBRACE +SYM_RBRACE +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/ret0.e b/tests/basic/ret0.e new file mode 100644 index 0000000000000000000000000000000000000000..29578073c69c04397755c33b19ebd805da070f75 --- /dev/null +++ b/tests/basic/ret0.e @@ -0,0 +1,3 @@ +main(){ +return 0; +} diff --git a/tests/basic/ret0.e.expect_14_12_3_8_12 b/tests/basic/ret0.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/basic/ret0.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/ret0.e.expect_1_2_3 b/tests/basic/ret0.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/basic/ret0.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/basic/ret0.e.expect_lexer b/tests/basic/ret0.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..6623612dacf07d7be036171dedd2743f24260a2e --- /dev/null +++ b/tests/basic/ret0.e.expect_lexer @@ -0,0 +1,9 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/ret20.e b/tests/basic/ret20.e new file mode 100644 index 0000000000000000000000000000000000000000..101f1eb3dbe1c6b447d65d8a62bd7eb9ee9ec694 --- /dev/null +++ b/tests/basic/ret20.e @@ -0,0 +1,6 @@ +main(){ + x = 5; + y = x * 2; + x = 6 * x; + return x - y; +} diff --git a/tests/basic/ret20.e.expect_14_12_3_8_12 b/tests/basic/ret20.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..4de51e4d38522a71a09ab4c411d09d99f1e80932 --- /dev/null +++ b/tests/basic/ret20.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 20} \ No newline at end of file diff --git a/tests/basic/ret20.e.expect_1_2_3 b/tests/basic/ret20.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..4de51e4d38522a71a09ab4c411d09d99f1e80932 --- /dev/null +++ b/tests/basic/ret20.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 20} \ No newline at end of file diff --git a/tests/basic/ret20.e.expect_lexer b/tests/basic/ret20.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..31a0c0415aa4b7e4ee3ee9612ac4458f2af3bccf --- /dev/null +++ b/tests/basic/ret20.e.expect_lexer @@ -0,0 +1,27 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_IDENTIFIER(x) +SYM_ASTERISK +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(6) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_MINUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/ret21.e b/tests/basic/ret21.e new file mode 100644 index 0000000000000000000000000000000000000000..7c46facdbd40159d599e2a70a82fbf7a2c8c76b6 --- /dev/null +++ b/tests/basic/ret21.e @@ -0,0 +1,7 @@ +main(){ +a = 7; +if(a > 12){ +a = 1; +} else { a = 3 * a; } +return a; +} diff --git a/tests/basic/ret21.e.expect_14_12_3_8_12 b/tests/basic/ret21.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..43b8874c2b664dea974bd32fb988a477dd4e8308 --- /dev/null +++ b/tests/basic/ret21.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 21} \ No newline at end of file diff --git a/tests/basic/ret21.e.expect_1_2_3 b/tests/basic/ret21.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..43b8874c2b664dea974bd32fb988a477dd4e8308 --- /dev/null +++ b/tests/basic/ret21.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 21} \ No newline at end of file diff --git a/tests/basic/ret21.e.expect_lexer b/tests/basic/ret21.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..7f56c753ef72ae1d710fb4d470909085f8c39e57 --- /dev/null +++ b/tests/basic/ret21.e.expect_lexer @@ -0,0 +1,34 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_GT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_ASTERISK +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/ret60.e b/tests/basic/ret60.e new file mode 100644 index 0000000000000000000000000000000000000000..13d11bfb5d14cfb34903826991ea94cc36382d95 --- /dev/null +++ b/tests/basic/ret60.e @@ -0,0 +1,5 @@ +main(){ + x = 3 + 7; + y = 5 * x; + return x + y; +} diff --git a/tests/basic/ret60.e.expect_14_12_3_8_12 b/tests/basic/ret60.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..51f9f22bf4016f307a497d3cff177f01769872d5 --- /dev/null +++ b/tests/basic/ret60.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 60} \ No newline at end of file diff --git a/tests/basic/ret60.e.expect_1_2_3 b/tests/basic/ret60.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..51f9f22bf4016f307a497d3cff177f01769872d5 --- /dev/null +++ b/tests/basic/ret60.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 60} \ No newline at end of file diff --git a/tests/basic/ret60.e.expect_lexer b/tests/basic/ret60.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..ad5cee1b13d6b9274d6931fd7745b15d5635e4ca --- /dev/null +++ b/tests/basic/ret60.e.expect_lexer @@ -0,0 +1,23 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_PLUS +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/sum_ints_upto_10.e b/tests/basic/sum_ints_upto_10.e new file mode 100644 index 0000000000000000000000000000000000000000..d75b101c9e88f9dcf09548e0a39dcfe222782c75 --- /dev/null +++ b/tests/basic/sum_ints_upto_10.e @@ -0,0 +1,12 @@ +main(){ + i = 0; + while(i < 10){ + if(i == 0){ + x = 1; + } + x = x + i; + i = i + 1; + } + return x; +} + diff --git a/tests/basic/sum_ints_upto_10.e.expect_14_12_3_8_12 b/tests/basic/sum_ints_upto_10.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..3bb7e49dac8aa0cbc843b6de7e45524882031ee8 --- /dev/null +++ b/tests/basic/sum_ints_upto_10.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 46} \ No newline at end of file diff --git a/tests/basic/sum_ints_upto_10.e.expect_1_2_3 b/tests/basic/sum_ints_upto_10.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..3bb7e49dac8aa0cbc843b6de7e45524882031ee8 --- /dev/null +++ b/tests/basic/sum_ints_upto_10.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 46} \ No newline at end of file diff --git a/tests/basic/sum_ints_upto_10.e.expect_lexer b/tests/basic/sum_ints_upto_10.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..a538c527f432c8e3a71f2b3f0f331d5beff57c37 --- /dev/null +++ b/tests/basic/sum_ints_upto_10.e.expect_lexer @@ -0,0 +1,45 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/sum_ints_upto_n.e b/tests/basic/sum_ints_upto_n.e new file mode 100644 index 0000000000000000000000000000000000000000..b7570dce50ce4ae63c6637118f0bee9f75e6c134 --- /dev/null +++ b/tests/basic/sum_ints_upto_n.e @@ -0,0 +1,8 @@ +main(n){ + x = 0; + while ( n > 0 ){ + x = x + n; + n = n - 1; + } + return x; +} diff --git a/tests/basic/sum_ints_upto_n.e.expect_14_12_3_8_12 b/tests/basic/sum_ints_upto_n.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..a08d9717d65d4797ad102ce92e8b9149efd0799c --- /dev/null +++ b/tests/basic/sum_ints_upto_n.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 105} \ No newline at end of file diff --git a/tests/basic/sum_ints_upto_n.e.expect_1_2_3 b/tests/basic/sum_ints_upto_n.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/sum_ints_upto_n.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/sum_ints_upto_n.e.expect_lexer b/tests/basic/sum_ints_upto_n.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..302788f5b513f4311ab9460d354b53f38f7544bc --- /dev/null +++ b/tests/basic/sum_ints_upto_n.e.expect_lexer @@ -0,0 +1,34 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/syntaxerror1.e b/tests/basic/syntaxerror1.e new file mode 100644 index 0000000000000000000000000000000000000000..dfa1a703c7b813dd88827652fcc69b61222be289 --- /dev/null +++ b/tests/basic/syntaxerror1.e @@ -0,0 +1,4 @@ +main(){ + b = 3 a; + return b; +} diff --git a/tests/basic/syntaxerror1.e.expect_lexer b/tests/basic/syntaxerror1.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..57e0ae5aa2e0f2d96f9867501eec6c3794d38fbf --- /dev/null +++ b/tests/basic/syntaxerror1.e.expect_lexer @@ -0,0 +1,14 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/syntaxerror2.e b/tests/basic/syntaxerror2.e new file mode 100644 index 0000000000000000000000000000000000000000..93b4140b53a922ca1bc634e7d7a59cd8b3bd3a76 --- /dev/null +++ b/tests/basic/syntaxerror2.e @@ -0,0 +1,4 @@ +main(){ +a b = 3; +return c; +} diff --git a/tests/basic/syntaxerror2.e.expect_lexer b/tests/basic/syntaxerror2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..673322471a90f21ad26db0cc6d99b9994856dfcd --- /dev/null +++ b/tests/basic/syntaxerror2.e.expect_lexer @@ -0,0 +1,14 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(c) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/uninitialized.e b/tests/basic/uninitialized.e new file mode 100644 index 0000000000000000000000000000000000000000..56745772146c82fefa938648a14a73787762a6ed --- /dev/null +++ b/tests/basic/uninitialized.e @@ -0,0 +1,3 @@ +main(){ + return a+3; +} diff --git a/tests/basic/uninitialized.e.expect_14_12_3_8_12 b/tests/basic/uninitialized.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..fdcca39194253835c20ceda8eb3895b4b10e5a5e --- /dev/null +++ b/tests/basic/uninitialized.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": "Unknown variable a\n", "retval": null} \ No newline at end of file diff --git a/tests/basic/uninitialized.e.expect_1_2_3 b/tests/basic/uninitialized.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..fdcca39194253835c20ceda8eb3895b4b10e5a5e --- /dev/null +++ b/tests/basic/uninitialized.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": "Unknown variable a\n", "retval": null} \ No newline at end of file diff --git a/tests/basic/uninitialized.e.expect_lexer b/tests/basic/uninitialized.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..64839c84b6a90190f4ea4528ed49ed1a21526205 --- /dev/null +++ b/tests/basic/uninitialized.e.expect_lexer @@ -0,0 +1,11 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/useless-assigns.e b/tests/basic/useless-assigns.e new file mode 100644 index 0000000000000000000000000000000000000000..d635607874b76cba06d4518fd3bb9df14601ea91 --- /dev/null +++ b/tests/basic/useless-assigns.e @@ -0,0 +1,6 @@ +main(){ + x = 8; + y = 15; + z = 4 * x + y; + return 1; +} diff --git a/tests/basic/useless-assigns.e.expect_14_12_3_8_12 b/tests/basic/useless-assigns.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/useless-assigns.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/useless-assigns.e.expect_1_2_3 b/tests/basic/useless-assigns.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/basic/useless-assigns.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/basic/useless-assigns.e.expect_lexer b/tests/basic/useless-assigns.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..71d12f4ba5810e6c87fb0289a8f2c075f8827ae3 --- /dev/null +++ b/tests/basic/useless-assigns.e.expect_lexer @@ -0,0 +1,25 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(15) +SYM_SEMICOLON +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_INTEGER(4) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/basic/x-is-what.e b/tests/basic/x-is-what.e new file mode 100644 index 0000000000000000000000000000000000000000..738afac2f58f89899074bb65805fe22f649e79bb --- /dev/null +++ b/tests/basic/x-is-what.e @@ -0,0 +1,5 @@ +main(){ + x = 5; + x = 6; + return x; +} diff --git a/tests/basic/x-is-what.e.expect_14_12_3_8_12 b/tests/basic/x-is-what.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..0334e56678aa50466b3b300e6bd05aacdc63e69e --- /dev/null +++ b/tests/basic/x-is-what.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 6} \ No newline at end of file diff --git a/tests/basic/x-is-what.e.expect_1_2_3 b/tests/basic/x-is-what.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..0334e56678aa50466b3b300e6bd05aacdc63e69e --- /dev/null +++ b/tests/basic/x-is-what.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 6} \ No newline at end of file diff --git a/tests/basic/x-is-what.e.expect_lexer b/tests/basic/x-is-what.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..f8fc64bca0cda408dcb389efd7599ab07929a3ab --- /dev/null +++ b/tests/basic/x-is-what.e.expect_lexer @@ -0,0 +1,17 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(6) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/char/char.e b/tests/char/char.e new file mode 100644 index 0000000000000000000000000000000000000000..f52c227b94f6d3cfc9df669b094011528ea00b57 --- /dev/null +++ b/tests/char/char.e @@ -0,0 +1,5 @@ +int main(){ + char c = 'b'; + print_char(c); + return c; +} diff --git a/tests/char/char.e.expect_14_12_3_8_12 b/tests/char/char.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..aaa03baf607257601754afb35ae560c1d767059e --- /dev/null +++ b/tests/char/char.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "b", "error": null, "retval": 98} \ No newline at end of file diff --git a/tests/char/char.e.expect_1_2_3 b/tests/char/char.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..aaa03baf607257601754afb35ae560c1d767059e --- /dev/null +++ b/tests/char/char.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "b", "error": null, "retval": 98} \ No newline at end of file diff --git a/tests/char/char.e.expect_lexer b/tests/char/char.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..770eef32e5b7eb93be87cc77912c41b234a5a107 --- /dev/null +++ b/tests/char/char.e.expect_lexer @@ -0,0 +1,20 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_CHAR +SYM_IDENTIFIER(c) +SYM_ASSIGN +SYM_CHARACTER(b) +SYM_SEMICOLON +SYM_IDENTIFIER(print_char) +SYM_LPARENTHESIS +SYM_IDENTIFIER(c) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(c) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/char/char2.e b/tests/char/char2.e new file mode 100644 index 0000000000000000000000000000000000000000..0b8dba527706d8838b716ac74fb50c1ffc83b6d2 --- /dev/null +++ b/tests/char/char2.e @@ -0,0 +1,5 @@ +int main(){ + char c = 'b'; + print_char(c+1); + return c; +} diff --git a/tests/char/char2.e.expect_14_12_3_8_12 b/tests/char/char2.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..d2905722d959ee2448860a8ccbedd0279f329c97 --- /dev/null +++ b/tests/char/char2.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "c", "error": null, "retval": 98} \ No newline at end of file diff --git a/tests/char/char2.e.expect_1_2_3 b/tests/char/char2.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..d2905722d959ee2448860a8ccbedd0279f329c97 --- /dev/null +++ b/tests/char/char2.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "c", "error": null, "retval": 98} \ No newline at end of file diff --git a/tests/char/char2.e.expect_lexer b/tests/char/char2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..60571b62ac6b036714df5f7feba43a0e9f165445 --- /dev/null +++ b/tests/char/char2.e.expect_lexer @@ -0,0 +1,22 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_CHAR +SYM_IDENTIFIER(c) +SYM_ASSIGN +SYM_CHARACTER(b) +SYM_SEMICOLON +SYM_IDENTIFIER(print_char) +SYM_LPARENTHESIS +SYM_IDENTIFIER(c) +SYM_PLUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(c) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/char/char_fun.e b/tests/char/char_fun.e new file mode 100644 index 0000000000000000000000000000000000000000..a033bb7fbe6ddb5dd5177f2e779d201e87f81bc5 --- /dev/null +++ b/tests/char/char_fun.e @@ -0,0 +1,8 @@ +char f(char c){ + return c + 1; +} + +int main(){ + print_char(f('c')); + return 0; +} diff --git a/tests/char/char_fun.e.expect_14_12_3_8_12 b/tests/char/char_fun.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..f0c44f5d97843845f8f11b05376935584f544917 --- /dev/null +++ b/tests/char/char_fun.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "d", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/char/char_fun.e.expect_1_2_3 b/tests/char/char_fun.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..f0c44f5d97843845f8f11b05376935584f544917 --- /dev/null +++ b/tests/char/char_fun.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "d", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/char/char_fun.e.expect_lexer b/tests/char/char_fun.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..71a8f589c7e227826fe15e8bea3df84736137f3f --- /dev/null +++ b/tests/char/char_fun.e.expect_lexer @@ -0,0 +1,31 @@ +SYM_CHAR +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_CHAR +SYM_IDENTIFIER(c) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(c) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print_char) +SYM_LPARENTHESIS +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_CHARACTER(c) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/2apb.e b/tests/funcall/2apb.e new file mode 100644 index 0000000000000000000000000000000000000000..4ff99d0abc0119cf3adb073cc9f831c9c7ce5c05 --- /dev/null +++ b/tests/funcall/2apb.e @@ -0,0 +1,6 @@ +main(){ + return f(8,3); +} +f(a, b){ + return a + 2 * b; +} diff --git a/tests/funcall/2apb.e.expect_14_12_3_8_12 b/tests/funcall/2apb.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..e2ce8007751569ecec00e7bfdaad1980596cc9f4 --- /dev/null +++ b/tests/funcall/2apb.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 14} \ No newline at end of file diff --git a/tests/funcall/2apb.e.expect_1_2_3 b/tests/funcall/2apb.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..e2ce8007751569ecec00e7bfdaad1980596cc9f4 --- /dev/null +++ b/tests/funcall/2apb.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 14} \ No newline at end of file diff --git a/tests/funcall/2apb.e.expect_lexer b/tests/funcall/2apb.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..8197b9b54f27d4f4ea65192dd83bbd9ba99308f0 --- /dev/null +++ b/tests/funcall/2apb.e.expect_lexer @@ -0,0 +1,29 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(8) +SYM_COMMA +SYM_INTEGER(3) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_INTEGER(2) +SYM_ASTERISK +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/5args.e b/tests/funcall/5args.e new file mode 100644 index 0000000000000000000000000000000000000000..59f7469f03aa1a7c60cf374c0ffdaeb222072458 --- /dev/null +++ b/tests/funcall/5args.e @@ -0,0 +1,6 @@ +main(x, y){ + return f(x,x,y,y,x*2); +} +f(x, y, z, t, u){ + return x + y + z + t + u; +} diff --git a/tests/funcall/5args.e.expect_14_12_3_8_12 b/tests/funcall/5args.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..e9a8021a60099904d6f192b40d0dda3f401ac4ee --- /dev/null +++ b/tests/funcall/5args.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 80} \ No newline at end of file diff --git a/tests/funcall/5args.e.expect_1_2_3 b/tests/funcall/5args.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/funcall/5args.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/funcall/5args.e.expect_lexer b/tests/funcall/5args.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..aeb962429ea2b3bd1a9e5530dd1357efa516e9b5 --- /dev/null +++ b/tests/funcall/5args.e.expect_lexer @@ -0,0 +1,50 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_COMMA +SYM_IDENTIFIER(x) +SYM_ASTERISK +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_COMMA +SYM_IDENTIFIER(z) +SYM_COMMA +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(u) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_PLUS +SYM_IDENTIFIER(u) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/argswap.e b/tests/funcall/argswap.e new file mode 100644 index 0000000000000000000000000000000000000000..615371cc55c3dbe64618f33a58f4557427470bf1 --- /dev/null +++ b/tests/funcall/argswap.e @@ -0,0 +1,13 @@ +g(a,b){ + print(a); + print(b); + return (b - a); +} +f(a,b){ + print(a); + print(b); + return g(b, a); +} +main(x, y){ + return f(x, y); +} diff --git a/tests/funcall/argswap.e.expect_14_12_3_8_12 b/tests/funcall/argswap.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..38f595af3b9b89775ee2efca6d8e1d1496063200 --- /dev/null +++ b/tests/funcall/argswap.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "14\n12\n12\n14\n", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/funcall/argswap.e.expect_1_2_3 b/tests/funcall/argswap.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..e03517fa033505d7fdef39702e40d4ccf9422e76 --- /dev/null +++ b/tests/funcall/argswap.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1\n2\n2\n1\n", "error": null, "retval": -1} \ No newline at end of file diff --git a/tests/funcall/argswap.e.expect_lexer b/tests/funcall/argswap.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..2c8a87dc1d273f5d6156be905b62504276797c7b --- /dev/null +++ b/tests/funcall/argswap.e.expect_lexer @@ -0,0 +1,68 @@ +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_MINUS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/even_more_args.e b/tests/funcall/even_more_args.e new file mode 100644 index 0000000000000000000000000000000000000000..281e743167c555e3ae446cf66fa4dc6f1329fb59 --- /dev/null +++ b/tests/funcall/even_more_args.e @@ -0,0 +1,27 @@ +f(a, + b, + c, + d, + e, + f, + g, + h, + i, + j, + k, + l, + m, + n, + o, + p, + q, + r, + s, + t + ){ + return (k * (a + b * c + d * e * f + g * h * i * j) + (l + m * n) * o + p * q) * (r + s * t); +} + +main(){ + return f(1,2,3,4,5,6,7,8,9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); +} diff --git a/tests/funcall/even_more_args.e.expect_14_12_3_8_12 b/tests/funcall/even_more_args.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..1705ac5b63d7e3c645cc187264daf2b0610faa2a --- /dev/null +++ b/tests/funcall/even_more_args.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23887562} \ No newline at end of file diff --git a/tests/funcall/even_more_args.e.expect_1_2_3 b/tests/funcall/even_more_args.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..1705ac5b63d7e3c645cc187264daf2b0610faa2a --- /dev/null +++ b/tests/funcall/even_more_args.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23887562} \ No newline at end of file diff --git a/tests/funcall/even_more_args.e.expect_lexer b/tests/funcall/even_more_args.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..f29ddb98f2b94092cf4637c0a15b0668e691e092 --- /dev/null +++ b/tests/funcall/even_more_args.e.expect_lexer @@ -0,0 +1,143 @@ +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(c) +SYM_COMMA +SYM_IDENTIFIER(d) +SYM_COMMA +SYM_IDENTIFIER(e) +SYM_COMMA +SYM_IDENTIFIER(f) +SYM_COMMA +SYM_IDENTIFIER(g) +SYM_COMMA +SYM_IDENTIFIER(h) +SYM_COMMA +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_IDENTIFIER(j) +SYM_COMMA +SYM_IDENTIFIER(k) +SYM_COMMA +SYM_IDENTIFIER(l) +SYM_COMMA +SYM_IDENTIFIER(m) +SYM_COMMA +SYM_IDENTIFIER(n) +SYM_COMMA +SYM_IDENTIFIER(o) +SYM_COMMA +SYM_IDENTIFIER(p) +SYM_COMMA +SYM_IDENTIFIER(q) +SYM_COMMA +SYM_IDENTIFIER(r) +SYM_COMMA +SYM_IDENTIFIER(s) +SYM_COMMA +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(k) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(b) +SYM_ASTERISK +SYM_IDENTIFIER(c) +SYM_PLUS +SYM_IDENTIFIER(d) +SYM_ASTERISK +SYM_IDENTIFIER(e) +SYM_ASTERISK +SYM_IDENTIFIER(f) +SYM_PLUS +SYM_IDENTIFIER(g) +SYM_ASTERISK +SYM_IDENTIFIER(h) +SYM_ASTERISK +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_PLUS +SYM_LPARENTHESIS +SYM_IDENTIFIER(l) +SYM_PLUS +SYM_IDENTIFIER(m) +SYM_ASTERISK +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_ASTERISK +SYM_IDENTIFIER(o) +SYM_PLUS +SYM_IDENTIFIER(p) +SYM_ASTERISK +SYM_IDENTIFIER(q) +SYM_RPARENTHESIS +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_IDENTIFIER(r) +SYM_PLUS +SYM_IDENTIFIER(s) +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(1) +SYM_COMMA +SYM_INTEGER(2) +SYM_COMMA +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_COMMA +SYM_INTEGER(5) +SYM_COMMA +SYM_INTEGER(6) +SYM_COMMA +SYM_INTEGER(7) +SYM_COMMA +SYM_INTEGER(8) +SYM_COMMA +SYM_INTEGER(9) +SYM_COMMA +SYM_INTEGER(10) +SYM_COMMA +SYM_INTEGER(11) +SYM_COMMA +SYM_INTEGER(12) +SYM_COMMA +SYM_INTEGER(13) +SYM_COMMA +SYM_INTEGER(14) +SYM_COMMA +SYM_INTEGER(15) +SYM_COMMA +SYM_INTEGER(16) +SYM_COMMA +SYM_INTEGER(17) +SYM_COMMA +SYM_INTEGER(18) +SYM_COMMA +SYM_INTEGER(19) +SYM_COMMA +SYM_INTEGER(20) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/f+g.e b/tests/funcall/f+g.e new file mode 100644 index 0000000000000000000000000000000000000000..c88d2f105cbc52cf9a292fc57fca950325ef8d63 --- /dev/null +++ b/tests/funcall/f+g.e @@ -0,0 +1,10 @@ +f(x){ + return x + 2; +} +g(y){ + return y * 3; +} +main(){ + return f(8) + g(5); +} + diff --git a/tests/funcall/f+g.e.expect_14_12_3_8_12 b/tests/funcall/f+g.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..c24e9b82dd8efe186dc84230615b92ea22fee674 --- /dev/null +++ b/tests/funcall/f+g.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 25} \ No newline at end of file diff --git a/tests/funcall/f+g.e.expect_1_2_3 b/tests/funcall/f+g.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..c24e9b82dd8efe186dc84230615b92ea22fee674 --- /dev/null +++ b/tests/funcall/f+g.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 25} \ No newline at end of file diff --git a/tests/funcall/f+g.e.expect_lexer b/tests/funcall/f+g.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..0ebab59d733398bee18bfc43eba126ccd0270b1a --- /dev/null +++ b/tests/funcall/f+g.e.expect_lexer @@ -0,0 +1,39 @@ +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(y) +SYM_ASTERISK +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(8) +SYM_RPARENTHESIS +SYM_PLUS +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/f_3.e b/tests/funcall/f_3.e new file mode 100644 index 0000000000000000000000000000000000000000..249610c685cf29aa14d10c8c880bd71695de776a --- /dev/null +++ b/tests/funcall/f_3.e @@ -0,0 +1,6 @@ +main(){ + return f(); +} +f(){ + return 3; +} diff --git a/tests/funcall/f_3.e.expect_14_12_3_8_12 b/tests/funcall/f_3.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/funcall/f_3.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/funcall/f_3.e.expect_1_2_3 b/tests/funcall/f_3.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/funcall/f_3.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/funcall/f_3.e.expect_lexer b/tests/funcall/f_3.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..79b5dd38be2288e4af2b408552eb6e4bd647a346 --- /dev/null +++ b/tests/funcall/f_3.e.expect_lexer @@ -0,0 +1,19 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/fib.e b/tests/funcall/fib.e new file mode 100644 index 0000000000000000000000000000000000000000..085cb0f7654be22716748f46208d0ab67aceaf48 --- /dev/null +++ b/tests/funcall/fib.e @@ -0,0 +1,11 @@ +fib(n){ + if(n > 14){ return -1; } + if(n <= 2){ + return 1; + } else { + return fib(n-1) + fib(n-2); + } +} +main(n){ + return fib(n); +} diff --git a/tests/funcall/fib.e.expect_14_12_3_8_12 b/tests/funcall/fib.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..1fef2374b55b0d9496617cec0a857a07906f799f --- /dev/null +++ b/tests/funcall/fib.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 377} \ No newline at end of file diff --git a/tests/funcall/fib.e.expect_1_2_3 b/tests/funcall/fib.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/funcall/fib.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/funcall/fib.e.expect_lexer b/tests/funcall/fib.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..0782208b0513813fb2852e9bd9fc866737f735a8 --- /dev/null +++ b/tests/funcall/fib.e.expect_lexer @@ -0,0 +1,60 @@ +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(14) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_LEQ +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_PLUS +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/gcdrec.e b/tests/funcall/gcdrec.e new file mode 100644 index 0000000000000000000000000000000000000000..0352c550f00faf745024a61c2453ff759cd4fa2d --- /dev/null +++ b/tests/funcall/gcdrec.e @@ -0,0 +1,10 @@ +gcd(a,b){ + if(b == 0){ + return a; + } else { + return gcd(b, a % b); + } +} +main(a, b){ + return gcd(a,b); +} diff --git a/tests/funcall/gcdrec.e.expect_14_12_3_8_12 b/tests/funcall/gcdrec.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..df1c5a5ba4e1647c7e3409ee9539a3583afa9bdf --- /dev/null +++ b/tests/funcall/gcdrec.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/funcall/gcdrec.e.expect_1_2_3 b/tests/funcall/gcdrec.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/funcall/gcdrec.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/funcall/gcdrec.e.expect_lexer b/tests/funcall/gcdrec.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..e02c133dce7fbcd42e08c3b13089813ccf46e656 --- /dev/null +++ b/tests/funcall/gcdrec.e.expect_lexer @@ -0,0 +1,49 @@ +SYM_IDENTIFIER(gcd) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(gcd) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(a) +SYM_MOD +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(gcd) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/hanoi.e b/tests/funcall/hanoi.e new file mode 100644 index 0000000000000000000000000000000000000000..5b485dae346f5dc479845f289389bf0a9396be3c --- /dev/null +++ b/tests/funcall/hanoi.e @@ -0,0 +1,12 @@ +main(ndisque){ + return hanoi(ndisque); +} +hanoi(n) +{ + if(n > 0) + { + x = hanoi(n-1); + return 1 + 2 * x; + } + return 0; +} diff --git a/tests/funcall/hanoi.e.expect_14_12_3_8_12 b/tests/funcall/hanoi.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..7cf52b9a4706e4fab8abce3869595d4e4b3ceb36 --- /dev/null +++ b/tests/funcall/hanoi.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 16383} \ No newline at end of file diff --git a/tests/funcall/hanoi.e.expect_1_2_3 b/tests/funcall/hanoi.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/funcall/hanoi.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/funcall/hanoi.e.expect_lexer b/tests/funcall/hanoi.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..6ba0a1e080ea40b2885bd0d5fc902256e3c46a25 --- /dev/null +++ b/tests/funcall/hanoi.e.expect_lexer @@ -0,0 +1,46 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(ndisque) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(hanoi) +SYM_LPARENTHESIS +SYM_IDENTIFIER(ndisque) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(hanoi) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(hanoi) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(1) +SYM_PLUS +SYM_INTEGER(2) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/lots_of_args.e b/tests/funcall/lots_of_args.e new file mode 100644 index 0000000000000000000000000000000000000000..a8017e107afc88bf6ff4fdd077c2dd2f76dc8a97 --- /dev/null +++ b/tests/funcall/lots_of_args.e @@ -0,0 +1,17 @@ +f(a, + b, + c, + d, + e, + f, + g, + h, + i, + j + ){ + return a + b * c + d * e * f + g * h * i * j; +} + +main(){ + return f(1,2,3,4,5,6,7,8,9,10); +} diff --git a/tests/funcall/lots_of_args.e.expect_14_12_3_8_12 b/tests/funcall/lots_of_args.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..16d63e1a7da8f2cb086a0d601046966b4a6c4003 --- /dev/null +++ b/tests/funcall/lots_of_args.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5167} \ No newline at end of file diff --git a/tests/funcall/lots_of_args.e.expect_1_2_3 b/tests/funcall/lots_of_args.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..16d63e1a7da8f2cb086a0d601046966b4a6c4003 --- /dev/null +++ b/tests/funcall/lots_of_args.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5167} \ No newline at end of file diff --git a/tests/funcall/lots_of_args.e.expect_lexer b/tests/funcall/lots_of_args.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..3c28c41facaafa42df0d874122fc48663c301c80 --- /dev/null +++ b/tests/funcall/lots_of_args.e.expect_lexer @@ -0,0 +1,75 @@ +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(c) +SYM_COMMA +SYM_IDENTIFIER(d) +SYM_COMMA +SYM_IDENTIFIER(e) +SYM_COMMA +SYM_IDENTIFIER(f) +SYM_COMMA +SYM_IDENTIFIER(g) +SYM_COMMA +SYM_IDENTIFIER(h) +SYM_COMMA +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(b) +SYM_ASTERISK +SYM_IDENTIFIER(c) +SYM_PLUS +SYM_IDENTIFIER(d) +SYM_ASTERISK +SYM_IDENTIFIER(e) +SYM_ASTERISK +SYM_IDENTIFIER(f) +SYM_PLUS +SYM_IDENTIFIER(g) +SYM_ASTERISK +SYM_IDENTIFIER(h) +SYM_ASTERISK +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(j) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(1) +SYM_COMMA +SYM_INTEGER(2) +SYM_COMMA +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_COMMA +SYM_INTEGER(5) +SYM_COMMA +SYM_INTEGER(6) +SYM_COMMA +SYM_INTEGER(7) +SYM_COMMA +SYM_INTEGER(8) +SYM_COMMA +SYM_INTEGER(9) +SYM_COMMA +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/print_and_fun.e b/tests/funcall/print_and_fun.e new file mode 100644 index 0000000000000000000000000000000000000000..0c24e564c78576916578a6c30f60604e6ff9c04c --- /dev/null +++ b/tests/funcall/print_and_fun.e @@ -0,0 +1,16 @@ + +g(x){ + return x; +} + +f(a, b){ + b = g(8); + print(a); + print(b); + return 0; +} + +main(){ + f(3,4); + return 0; +} diff --git a/tests/funcall/print_and_fun.e.expect_14_12_3_8_12 b/tests/funcall/print_and_fun.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..7d935d7f4a3630ae710e34b79470872b1124e978 --- /dev/null +++ b/tests/funcall/print_and_fun.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "3\n8\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/funcall/print_and_fun.e.expect_1_2_3 b/tests/funcall/print_and_fun.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..7d935d7f4a3630ae710e34b79470872b1124e978 --- /dev/null +++ b/tests/funcall/print_and_fun.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "3\n8\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/funcall/print_and_fun.e.expect_lexer b/tests/funcall/print_and_fun.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..834218f66d791aed054dec525bb4e0e33596260b --- /dev/null +++ b/tests/funcall/print_and_fun.e.expect_lexer @@ -0,0 +1,53 @@ +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INTEGER(8) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/globals/arrayptr.e b/tests/globals/arrayptr.e new file mode 100644 index 0000000000000000000000000000000000000000..e5d1b0d96515e4114a4edb031df15643097ca15e --- /dev/null +++ b/tests/globals/arrayptr.e @@ -0,0 +1,24 @@ +struct S { + int x; + int y; + int z; +}; + +struct S *p; + +struct S t[3]; + +int main(){ + (t[0]).x = 1; + (t[0]).y = 2; + (t[0]).z = 3; + (t[1]).x = 4; + (t[1]).y = 5; + (t[1]).z = 6; + (t[2]).x = 7; + (t[2]).y = 8; + (t[2]).z = 9; + p = &(t[2]); + + return (*p).y; +} diff --git a/tests/globals/arrayptr.e.expect_14_12_3_8_12 b/tests/globals/arrayptr.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/globals/arrayptr.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/globals/arrayptr.e.expect_1_2_3 b/tests/globals/arrayptr.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/globals/arrayptr.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/globals/arrayptr.e.expect_lexer b/tests/globals/arrayptr.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..1c2e857c384ad3c3582f64a43a9a94110e617de6 --- /dev/null +++ b/tests/globals/arrayptr.e.expect_lexer @@ -0,0 +1,150 @@ +SYM_STRUCT +SYM_IDENTIFIER(S) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(z) +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_STRUCT +SYM_IDENTIFIER(S) +SYM_ASTERISK +SYM_IDENTIFIER(p) +SYM_SEMICOLON +SYM_STRUCT +SYM_IDENTIFIER(S) +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(3) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(4) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_INTEGER(6) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_INTEGER(9) +SYM_SEMICOLON +SYM_IDENTIFIER(p) +SYM_ASSIGN +SYM_AMPERSAND +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_ASTERISK +SYM_IDENTIFIER(p) +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/globals/glob.e b/tests/globals/glob.e new file mode 100644 index 0000000000000000000000000000000000000000..70cbf87a4d22df020c98d9c0f395fa5bed1dcdaa --- /dev/null +++ b/tests/globals/glob.e @@ -0,0 +1,6 @@ + +int i = 37; + +int main(){ + return i; +} diff --git a/tests/globals/glob.e.expect_14_12_3_8_12 b/tests/globals/glob.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..016d6cd30c8fc3fd3f0ef57bfe183aa6023661fa --- /dev/null +++ b/tests/globals/glob.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37} \ No newline at end of file diff --git a/tests/globals/glob.e.expect_1_2_3 b/tests/globals/glob.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..016d6cd30c8fc3fd3f0ef57bfe183aa6023661fa --- /dev/null +++ b/tests/globals/glob.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37} \ No newline at end of file diff --git a/tests/globals/glob.e.expect_lexer b/tests/globals/glob.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..c8ddec75638f834c5c254903cc233a2fe7dc07e5 --- /dev/null +++ b/tests/globals/glob.e.expect_lexer @@ -0,0 +1,15 @@ +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(37) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/globals/globarray.e b/tests/globals/globarray.e new file mode 100644 index 0000000000000000000000000000000000000000..e4c8bcdee358f8983895ce659e46686add1ea9a1 --- /dev/null +++ b/tests/globals/globarray.e @@ -0,0 +1,19 @@ + +int max = 20; +int objs[20]; + +int main(){ + int i = 0; + int sum = 0; + while (i < max){ + objs[i] = sum; + sum = sum + i; + i = i + 1; + } + i = 0; + while (i < max){ + print(objs[i]); + i = i + 1; + } + return objs[max-1]; +} diff --git a/tests/globals/globarray.e.expect_14_12_3_8_12 b/tests/globals/globarray.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..30828c15056b7ce6e95653abc818578558480a3e --- /dev/null +++ b/tests/globals/globarray.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "0\n0\n1\n3\n6\n10\n15\n21\n28\n36\n45\n55\n66\n78\n91\n105\n120\n136\n153\n171\n", "error": null, "retval": 171} \ No newline at end of file diff --git a/tests/globals/globarray.e.expect_1_2_3 b/tests/globals/globarray.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..30828c15056b7ce6e95653abc818578558480a3e --- /dev/null +++ b/tests/globals/globarray.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "0\n0\n1\n3\n6\n10\n15\n21\n28\n36\n45\n55\n66\n78\n91\n105\n120\n136\n153\n171\n", "error": null, "retval": 171} \ No newline at end of file diff --git a/tests/globals/globarray.e.expect_lexer b/tests/globals/globarray.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..23154b3ff6ab075e332a475f9419f3bd735c2877 --- /dev/null +++ b/tests/globals/globarray.e.expect_lexer @@ -0,0 +1,89 @@ +SYM_INT +SYM_IDENTIFIER(max) +SYM_ASSIGN +SYM_INTEGER(20) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_INTEGER(20) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(sum) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_IDENTIFIER(max) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(sum) +SYM_SEMICOLON +SYM_IDENTIFIER(sum) +SYM_ASSIGN +SYM_IDENTIFIER(sum) +SYM_PLUS +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_IDENTIFIER(max) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(max) +SYM_MINUS +SYM_INTEGER(1) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/globals/globtab.e b/tests/globals/globtab.e new file mode 100644 index 0000000000000000000000000000000000000000..f07a34616b54d86d533fa7820c7452b2814a8525 --- /dev/null +++ b/tests/globals/globtab.e @@ -0,0 +1,17 @@ + +struct my_struct { + int x; + int y; +}; + +struct my_struct objs[2]; + +int main(){ + int i = 0; + while (i < 2){ + (objs[i]).x = i; + (objs[i]).y = i; + i = i + 1; + } + return (objs[1]).x; +} diff --git a/tests/globals/globtab.e.expect_14_12_3_8_12 b/tests/globals/globtab.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/globals/globtab.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/globals/globtab.e.expect_1_2_3 b/tests/globals/globtab.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/globals/globtab.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/globals/globtab.e.expect_lexer b/tests/globals/globtab.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..22ef58f57df64dd0be8b134421daa329570864fb --- /dev/null +++ b/tests/globals/globtab.e.expect_lexer @@ -0,0 +1,76 @@ +SYM_STRUCT +SYM_IDENTIFIER(my_struct) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_STRUCT +SYM_IDENTIFIER(my_struct) +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_LPARENTHESIS +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/globals/globtab2.e b/tests/globals/globtab2.e new file mode 100644 index 0000000000000000000000000000000000000000..c60b2cb694fca94bf9f89bcc26daebd145f92fd1 --- /dev/null +++ b/tests/globals/globtab2.e @@ -0,0 +1,43 @@ +int IMG[64]; +int NBCOL = 8; +int NBROW = 8; + +void draw(int color, int x, int y){ + int pos = (y * NBCOL + x); + if (pos < NBCOL * NBROW){ + *(IMG + pos) = color; + } +} + +int get(int x, int y){ + int pos = (y * NBCOL + x); + if (pos < NBCOL * NBROW){ + return *(IMG + pos); + } + return -1; +} + +void draw_world(){ + int i = 0; + int j = 0; + while (j < NBROW) { + i = 0; + while (i < NBCOL) { + if(get(i, j) != 0){ + print_char('#'); + } else { + print_char(' '); + } + i = i + 1; + } + print_char('\n'); + j = j + 1; + } +} + +int main(){ + draw(0xff0000, 1, 1); + print(get(1,1)); + draw_world(); + return 0; +} diff --git a/tests/globals/globtab2.e.expect_14_12_3_8_12 b/tests/globals/globtab2.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..b09bb6fba8ce6c934aecda5bb182415bced685ed --- /dev/null +++ b/tests/globals/globtab2.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "16711680\n \n # \n \n \n \n \n \n \n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/globals/globtab2.e.expect_1_2_3 b/tests/globals/globtab2.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..b09bb6fba8ce6c934aecda5bb182415bced685ed --- /dev/null +++ b/tests/globals/globtab2.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "16711680\n \n # \n \n \n \n \n \n \n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/globals/globtab2.e.expect_lexer b/tests/globals/globtab2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..c92540d9f191142eb924c6a1c74e1f898cb2098d --- /dev/null +++ b/tests/globals/globtab2.e.expect_lexer @@ -0,0 +1,217 @@ +SYM_INT +SYM_IDENTIFIER(IMG) +SYM_LBRACKET +SYM_INTEGER(64) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(NBCOL) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(NBROW) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_VOID +SYM_IDENTIFIER(draw) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(color) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(pos) +SYM_ASSIGN +SYM_LPARENTHESIS +SYM_IDENTIFIER(y) +SYM_ASTERISK +SYM_IDENTIFIER(NBCOL) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(pos) +SYM_LT +SYM_IDENTIFIER(NBCOL) +SYM_ASTERISK +SYM_IDENTIFIER(NBROW) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_IDENTIFIER(IMG) +SYM_PLUS +SYM_IDENTIFIER(pos) +SYM_RPARENTHESIS +SYM_ASSIGN +SYM_IDENTIFIER(color) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(get) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(pos) +SYM_ASSIGN +SYM_LPARENTHESIS +SYM_IDENTIFIER(y) +SYM_ASTERISK +SYM_IDENTIFIER(NBCOL) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(pos) +SYM_LT +SYM_IDENTIFIER(NBCOL) +SYM_ASTERISK +SYM_IDENTIFIER(NBROW) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_IDENTIFIER(IMG) +SYM_PLUS +SYM_IDENTIFIER(pos) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_VOID +SYM_IDENTIFIER(draw_world) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(j) +SYM_LT +SYM_IDENTIFIER(NBROW) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_IDENTIFIER(NBCOL) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(get) +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_NOTEQ +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print_char) +SYM_LPARENTHESIS +SYM_CHARACTER(#) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(print_char) +SYM_LPARENTHESIS +SYM_CHARACTER( ) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(print_char) +SYM_LPARENTHESIS +SYM_CHARACTER( +) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_IDENTIFIER(j) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(draw) +SYM_LPARENTHESIS +SYM_INTEGER(16711680) +SYM_COMMA +SYM_INTEGER(1) +SYM_COMMA +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(get) +SYM_LPARENTHESIS +SYM_INTEGER(1) +SYM_COMMA +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(draw_world) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/invader/cep_platform.h b/tests/invader/cep_platform.h new file mode 100644 index 0000000000000000000000000000000000000000..2bf145ddeea72aacbbadca87ddd129a65dd7db0f --- /dev/null +++ b/tests/invader/cep_platform.h @@ -0,0 +1,53 @@ +#ifndef __CEP_PLATFORM_H__ +#define __CEP_PLATFORM_H__ + +// Peripherals Addresses +#define PERIPHS_BASE_ADDRESS 0x30000000 +#define REG_LEDS_ADDR (PERIPHS_BASE_ADDRESS + 0x0) +#define REG_LEDS_CTRL (PERIPHS_BASE_ADDRESS + 0x4) +#define REG_PIN_ADDR (PERIPHS_BASE_ADDRESS + 0x8) +#define REG_PUSHBUTTON_CTL_ADDR (PERIPHS_BASE_ADDRESS + 0xC) + +// VRAM addresses +#define FRAME_BUFFER_CTRL_BASE_ADDRESS 0x70000000 +#define FRAME_BUFFER_CTRL_MODE_REG (FRAME_BUFFER_CTRL_BASE_ADDRESS + 0x0) +#define FRAME_BUFFER_CTRL_ADDR_REG (FRAME_BUFFER_CTRL_BASE_ADDRESS + 0x4) +#define VRAM_OFFSET 0x80000000 + +// PLIC registers addresses +#define PLIC_PENDING_1 0x0C001000 +#define PLIC_ENABLE_1 0x0c002000 +#define PLIC_IRQ_CLAIM 0x0c200004 + +// DEPRECATED: Gestion des priorités du PLIC a été retirée de la plateforme cep dans qemu +//#define PLIC_THRESHOLD 0x0c200000 +//#define PLIC_IRQ_PRIORITY_BASE 0x0c000000 +//#define PLIC_IRQ_PRIORITY_1 0x0c000004 + +// CLINT registers addresses +#define CLINT_MSIP 0x02000000 +#define CLINT_TIMER_CMP 0x02004000 +#define CLINT_TIMER_CMP_HI 0x02004004 +#define CLINT_TIMER_CMP_LO 0x02004000 +#define CLINT_TIMER 0x0200bff8 +#define CLINT_TIMER_HI 0x0200bffc +#define CLINT_TIMER_LOW 0x0200bff8 + +// VRAM sizes +#define VRAM_WIDTH 1280 +#define VRAM_HEIGTH 720 +#define PIXEL_SIZE 4 +#define VRAM_SIZE (VRAM_WIDTH * VRAM_HEIGTH * PIXEL_SIZE) + +// Push button modes +#define REG_PUSHBUTTON_MODE_POLL 0x0 +#define REG_PUSHBUTTON_MODE_INT 0x1 + +// HDMI Modes +#define HDMI_MODE_720p_60Hz 4 +#define HDMI_MODE_1080p_60Hz 19 +#define HDMI_MODE_1080p_30Hz_blk_0 32 +#define HDMI_MODE_1080p_30Hz_blk_1 33 +#define HDMI_MODE_1080p_30Hz_blk_2 34 + +#endif // __CEP_PLATFORM_H__ diff --git a/tests/invader/constants.S b/tests/invader/constants.S new file mode 100644 index 0000000000000000000000000000000000000000..d08387c2bc7b951a95ba0dc5e4147ee7fbdbf0f4 --- /dev/null +++ b/tests/invader/constants.S @@ -0,0 +1,18 @@ +# See LICENSE for license details. + +.equ MAX_HARTS, 4 +.equ SAVE_REGS, 16 +.equ STACK_SIZE, 1024 +.equ STACK_SHIFT, 10 +.equ CONTEXT_SIZE, (SAVE_REGS * REGBYTES) + +.globl _text_start +.globl _text_end +.globl _rodata_start +.globl _rodata_end +.globl _data_start +.globl _data_end +.globl _bss_start +.globl _bss_end +.global _memory_start; +.global _memory_end; diff --git a/tests/invader/crt.S b/tests/invader/crt.S new file mode 100644 index 0000000000000000000000000000000000000000..e5a63ba69a39f0939d4bce115d795025726fdad1 --- /dev/null +++ b/tests/invader/crt.S @@ -0,0 +1 @@ +.include "crtm.S" diff --git a/tests/invader/crtm.S b/tests/invader/crtm.S new file mode 100644 index 0000000000000000000000000000000000000000..e68162cf377d3687d3ce2c9d33bea465ac1c03b0 --- /dev/null +++ b/tests/invader/crtm.S @@ -0,0 +1,75 @@ +# See LICENSE for license details. + +.include "macros.S" +.include "constants.S" + +# +# start of trap handler +# + +.section .text.init,"ax",@progbits +.globl _start + +_start: + # setup default trap vector + la t0, trap_vector + csrw mtvec, t0 + + # set up stack pointer based on hartid + la sp, stacks + STACK_SIZE + #li sp, 0x00008FF0 + + # jump to main + lw a0, 4(sp) # pass argc + addi a1, sp, 8 # pass argv + j libfemto_start_main + + .align 2 +trap_vector: + # Save registers. + addi sp, sp, -CONTEXT_SIZE + sxsp ra, 0 + sxsp a0, 1 + sxsp a1, 2 + sxsp a2, 3 + sxsp a3, 4 + sxsp a4, 5 + sxsp a5, 6 + sxsp a6, 7 + sxsp a7, 8 + sxsp t0, 9 + sxsp t1, 10 + sxsp t2, 11 + sxsp t3, 12 + sxsp t4, 13 + sxsp t5, 14 + sxsp t6, 15 + + # Invoke the handler. + mv a0, sp + csrr a1, mcause + csrr a2, mepc + jal trap_handler + + # Restore registers. + lxsp ra, 0 + lxsp a0, 1 + lxsp a1, 2 + lxsp a2, 3 + lxsp a3, 4 + lxsp a4, 5 + lxsp a5, 6 + lxsp a6, 7 + lxsp a7, 8 + lxsp t0, 9 + lxsp t1, 10 + lxsp t2, 11 + lxsp t3, 12 + lxsp t4, 13 + lxsp t5, 14 + lxsp t6, 15 + addi sp, sp, CONTEXT_SIZE + + # Return + mret + diff --git a/tests/invader/extended.lds b/tests/invader/extended.lds new file mode 100644 index 0000000000000000000000000000000000000000..a5347f423fb73d89b8c80613381dd9c68bb6cf81 --- /dev/null +++ b/tests/invader/extended.lds @@ -0,0 +1,54 @@ +OUTPUT_ARCH( "riscv" ) + +GROUP(-lgcc) + +ENTRY( _start ) + +MEMORY +{ + ram (wxa!ri) : ORIGIN = 0x1000, LENGTH = 32M +} + +PHDRS +{ + text PT_LOAD; + data PT_LOAD; + bss PT_LOAD; +} + +SECTIONS +{ + PROVIDE(_start = 0x1000); + .text : { + PROVIDE(_text_start = .); + *(.text.init) *(.text .text.*) + PROVIDE(_text_end = .); + } >ram AT>ram :text + + .rodata : { + PROVIDE(_rodata_start = .); + *(.rodata .rodata.*) + PROVIDE(_rodata_end = .); + } >ram AT>ram :text + + .data : { + . = ALIGN(4096); + PROVIDE(_data_start = .); + *(.sdata .sdata.*) *(.data .data.*) + PROVIDE(_data_end = .); + } >ram AT>ram :data + + .bss 0xc00000:{ + PROVIDE(stacks = .); + PROVIDE(_bss_start = .); + . = . + 0x400; + . = . + 0x100; + *(.sbss .sbss.*) *(.bss .bss.*) + *(COMMON) + . = . + 0x100; + PROVIDE(_bss_end = .); + } >ram AT>ram :bss + + PROVIDE(_memory_start = ORIGIN(ram)); + PROVIDE(_memory_end = ORIGIN(ram) + LENGTH(ram)); +} diff --git a/tests/invader/font.c b/tests/invader/font.c new file mode 100644 index 0000000000000000000000000000000000000000..937f6703219eac0e0bb8bc1d29914062511f6557 --- /dev/null +++ b/tests/invader/font.c @@ -0,0 +1,260 @@ +#include "font.h" + +char font8x8_basic[256][8] = { + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space) + { 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!) + { 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (") + { 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#) + { 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($) + { 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%) + { 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&) + { 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (') + { 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (() + { 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ()) + { 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*) + { 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,) + { 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.) + { 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/) + { 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0) + { 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1) + { 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2) + { 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3) + { 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4) + { 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5) + { 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6) + { 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7) + { 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8) + { 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9) + { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:) + { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;) + { 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<) + { 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=) + { 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>) + { 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?) + { 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@) + { 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A) + { 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B) + { 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C) + { 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D) + { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E) + { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F) + { 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G) + { 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H) + { 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I) + { 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J) + { 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K) + { 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L) + { 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M) + { 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N) + { 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O) + { 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P) + { 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q) + { 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R) + { 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S) + { 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T) + { 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U) + { 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V) + { 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W) + { 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X) + { 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y) + { 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z) + { 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([) + { 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\) + { 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (]) + { 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_) + { 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`) + { 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a) + { 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b) + { 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c) + { 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d) + { 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e) + { 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f) + { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g) + { 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h) + { 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i) + { 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j) + { 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k) + { 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l) + { 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m) + { 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n) + { 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o) + { 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p) + { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q) + { 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r) + { 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s) + { 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t) + { 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u) + { 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v) + { 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w) + { 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x) + { 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y) + { 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z) + { 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({) + { 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|) + { 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (}) + { 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007F + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0080 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0081 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0082 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0083 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0084 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0085 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0086 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0087 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0088 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0089 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+008A + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+008B + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+008C + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+008D + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+008E + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+008F + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0090 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0091 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0092 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0093 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0094 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0095 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0096 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0097 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0098 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0099 + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+009A + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+009B + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+009C + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+009D + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+009E + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+009F + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00A0 (no break space) + { 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00}, // U+00A1 (inverted !) + { 0x18, 0x18, 0x7E, 0x03, 0x03, 0x7E, 0x18, 0x18}, // U+00A2 (dollarcents) + { 0x1C, 0x36, 0x26, 0x0F, 0x06, 0x67, 0x3F, 0x00}, // U+00A3 (pound sterling) + { 0x00, 0x00, 0x63, 0x3E, 0x36, 0x3E, 0x63, 0x00}, // U+00A4 (currency mark) + { 0x33, 0x33, 0x1E, 0x3F, 0x0C, 0x3F, 0x0C, 0x0C}, // U+00A5 (yen) + { 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+00A6 (broken pipe) + { 0x7C, 0xC6, 0x1C, 0x36, 0x36, 0x1C, 0x33, 0x1E}, // U+00A7 (paragraph) + { 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00A8 (diaeresis) + { 0x3C, 0x42, 0x99, 0x85, 0x85, 0x99, 0x42, 0x3C}, // U+00A9 (copyright symbol) + { 0x3C, 0x36, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00}, // U+00AA (superscript a) + { 0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00}, // U+00AB (<<) + { 0x00, 0x00, 0x00, 0x3F, 0x30, 0x30, 0x00, 0x00}, // U+00AC (gun pointing left) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00AD (soft hyphen) + { 0x3C, 0x42, 0x9D, 0xA5, 0x9D, 0xA5, 0x42, 0x3C}, // U+00AE (registered symbol) + { 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00AF (macron) + { 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00B0 (degree) + { 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00}, // U+00B1 (plusminus) + { 0x1C, 0x30, 0x18, 0x0C, 0x3C, 0x00, 0x00, 0x00}, // U+00B2 (superscript 2) + { 0x1C, 0x30, 0x18, 0x30, 0x1C, 0x00, 0x00, 0x00}, // U+00B2 (superscript 3) + { 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00B2 (aigu) + { 0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x03}, // U+00B5 (mu) + { 0xFE, 0xDB, 0xDB, 0xDE, 0xD8, 0xD8, 0xD8, 0x00}, // U+00B6 (pilcrow) + { 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00}, // U+00B7 (central dot) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x1E}, // U+00B8 (cedille) + { 0x08, 0x0C, 0x08, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00B9 (superscript 1) + { 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00BA (superscript 0) + { 0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00}, // U+00BB (>>) + { 0xC3, 0x63, 0x33, 0xBD, 0xEC, 0xF6, 0xF3, 0x03}, // U+00BC (1/4) + { 0xC3, 0x63, 0x33, 0x7B, 0xCC, 0x66, 0x33, 0xF0}, // U+00BD (1/2) + { 0x03, 0xC4, 0x63, 0xB4, 0xDB, 0xAC, 0xE6, 0x80}, // U+00BE (3/4) + { 0x0C, 0x00, 0x0C, 0x06, 0x03, 0x33, 0x1E, 0x00}, // U+00BF (inverted ?) + { 0x07, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00}, // U+00C0 (A grave) + { 0x70, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00}, // U+00C1 (A aigu) + { 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00}, // U+00C2 (A circumflex) + { 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00}, // U+00C3 (A ~) + { 0x63, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x63, 0x00}, // U+00C4 (A umlaut) + { 0x0C, 0x0C, 0x00, 0x1E, 0x33, 0x3F, 0x33, 0x00}, // U+00C5 (A ring) + { 0x7C, 0x36, 0x33, 0x7F, 0x33, 0x33, 0x73, 0x00}, // U+00C6 (AE) + { 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x18, 0x30, 0x1E}, // U+00C7 (C cedille) + { 0x07, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00C8 (E grave) + { 0x38, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00C9 (E aigu) + { 0x0C, 0x12, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00CA (E circumflex) + { 0x36, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00CB (E umlaut) + { 0x07, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CC (I grave) + { 0x38, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CD (I aigu) + { 0x0C, 0x12, 0x00, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CE (I circumflex) + { 0x33, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CF (I umlaut) + { 0x3F, 0x66, 0x6F, 0x6F, 0x66, 0x66, 0x3F, 0x00}, // U+00D0 (Eth) + { 0x3F, 0x00, 0x33, 0x37, 0x3F, 0x3B, 0x33, 0x00}, // U+00D1 (N ~) + { 0x0E, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D2 (O grave) + { 0x70, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D3 (O aigu) + { 0x3C, 0x66, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D4 (O circumflex) + { 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x63, 0x3E, 0x00}, // U+00D5 (O ~) + { 0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00}, // U+00D6 (O umlaut) + { 0x00, 0x36, 0x1C, 0x08, 0x1C, 0x36, 0x00, 0x00}, // U+00D7 (multiplicative x) + { 0x5C, 0x36, 0x73, 0x7B, 0x6F, 0x36, 0x1D, 0x00}, // U+00D8 (O stroke) + { 0x0E, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00D9 (U grave) + { 0x70, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00DA (U aigu) + { 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00DB (U circumflex) + { 0x33, 0x00, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+00DC (U umlaut) + { 0x70, 0x00, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x00}, // U+00DD (Y aigu) + { 0x0F, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+00DE (Thorn) + { 0x00, 0x1E, 0x33, 0x1F, 0x33, 0x1F, 0x03, 0x03}, // U+00DF (beta) + { 0x07, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E0 (a grave) + { 0x38, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E1 (a aigu) + { 0x7E, 0xC3, 0x3C, 0x60, 0x7C, 0x66, 0xFC, 0x00}, // U+00E2 (a circumflex) + { 0x6E, 0x3B, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E3 (a ~) + { 0x33, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E4 (a umlaut) + { 0x0C, 0x0C, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E5 (a ring) + { 0x00, 0x00, 0xFE, 0x30, 0xFE, 0x33, 0xFE, 0x00}, // U+00E6 (ae) + { 0x00, 0x00, 0x1E, 0x03, 0x03, 0x1E, 0x30, 0x1C}, // U+00E7 (c cedille) + { 0x07, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00E8 (e grave) + { 0x38, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00E9 (e aigu) + { 0x7E, 0xC3, 0x3C, 0x66, 0x7E, 0x06, 0x3C, 0x00}, // U+00EA (e circumflex) + { 0x33, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00EB (e umlaut) + { 0x07, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00EC (i grave) + { 0x1C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00ED (i augu) + { 0x3E, 0x63, 0x1C, 0x18, 0x18, 0x18, 0x3C, 0x00}, // U+00EE (i circumflex) + { 0x33, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00EF (i umlaut) + { 0x1B, 0x0E, 0x1B, 0x30, 0x3E, 0x33, 0x1E, 0x00}, // U+00F0 (eth) + { 0x00, 0x1F, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x00}, // U+00F1 (n ~) + { 0x00, 0x07, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F2 (o grave) + { 0x00, 0x38, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F3 (o aigu) + { 0x1E, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F4 (o circumflex) + { 0x6E, 0x3B, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F5 (o ~) + { 0x00, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F6 (o umlaut) + { 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00}, // U+00F7 (division) + { 0x00, 0x60, 0x3C, 0x76, 0x7E, 0x6E, 0x3C, 0x06}, // U+00F8 (o stroke) + { 0x00, 0x07, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00F9 (u grave) + { 0x00, 0x38, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FA (u aigu) + { 0x1E, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FB (u circumflex) + { 0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FC (u umlaut) + { 0x00, 0x38, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+00FD (y aigu) + { 0x00, 0x00, 0x06, 0x3E, 0x66, 0x3E, 0x06, 0x00}, // U+00FE (thorn) + { 0x00, 0x33, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F} // U+00FF (y umlaut) +}; diff --git a/tests/invader/include/alloca.h b/tests/invader/include/alloca.h new file mode 100644 index 0000000000000000000000000000000000000000..2ae6a3e066639298d28c546c2acf906c4400964c --- /dev/null +++ b/tests/invader/include/alloca.h @@ -0,0 +1,3 @@ +#pragma once + +#define alloca(size) __builtin_alloca (size) diff --git a/tests/invader/include/arch/riscv/csr.h b/tests/invader/include/arch/riscv/csr.h new file mode 100644 index 0000000000000000000000000000000000000000..8bbc5f4b3c031723f598f92809a3af1f336a929c --- /dev/null +++ b/tests/invader/include/arch/riscv/csr.h @@ -0,0 +1,81 @@ +// See LICENSE for license details. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +int* csr_enum_array(); +const char** csr_name_array(); +long read_csr_enum(int csrenum); +void write_csr_enum(int csrenum, long value); + +enum { + csr_none, + csr_fflags, + csr_frm, + csr_fcsr, + csr_mcycle, + csr_minstret, + csr_mcycleh, + csr_minstreth, + csr_cycle, + csr_time, + csr_instret, + csr_cycleh, + csr_timeh, + csr_instreth, + csr_mvendorid, + csr_marchid, + csr_mimpid, + csr_mhartid, + csr_mstatus, + csr_misa, + csr_medeleg, + csr_mideleg, + csr_mie, + csr_mtvec, + csr_mcounteren, + csr_mscratch, + csr_mepc, + csr_mcause, + csr_mtval, + csr_mip, + csr_sstatus, + csr_sedeleg, + csr_sideleg, + csr_sie, + csr_stvec, + csr_scounteren, + csr_sscratch, + csr_sepc, + csr_scause, + csr_stval, + csr_sip, + csr_satp, + csr_pmpcfg0, + csr_pmpcfg1, + csr_pmpcfg2, + csr_pmpcfg3, + csr_pmpaddr0, + csr_pmpaddr1, + csr_pmpaddr2, + csr_pmpaddr3, + csr_pmpaddr4, + csr_pmpaddr5, + csr_pmpaddr6, + csr_pmpaddr7, + csr_pmpaddr8, + csr_pmpaddr9, + csr_pmpaddr10, + csr_pmpaddr11, + csr_pmpaddr12, + csr_pmpaddr13, + csr_pmpaddr14, + csr_pmpaddr15 +}; + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/arch/riscv/encoding.h b/tests/invader/include/arch/riscv/encoding.h new file mode 100644 index 0000000000000000000000000000000000000000..d592bbc72217c570ced0add5964d91dbd96eb752 --- /dev/null +++ b/tests/invader/include/arch/riscv/encoding.h @@ -0,0 +1,197 @@ +// See LICENSE for license details. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#define MSTATUS_UIE 0x00000001 +#define MSTATUS_SIE 0x00000002 +#define MSTATUS_HIE 0x00000004 +#define MSTATUS_MIE 0x00000008 +#define MSTATUS_UPIE 0x00000010 +#define MSTATUS_SPIE 0x00000020 +#define MSTATUS_HPIE 0x00000040 +#define MSTATUS_MPIE 0x00000080 +#define MSTATUS_SPP 0x00000100 +#define MSTATUS_HPP 0x00000600 +#define MSTATUS_MPP 0x00001800 +#define MSTATUS_FS 0x00006000 +#define MSTATUS_XS 0x00018000 +#define MSTATUS_MPRV 0x00020000 +#define MSTATUS_SUM 0x00040000 +#define MSTATUS_MXR 0x00080000 +#define MSTATUS_TVM 0x00100000 +#define MSTATUS_TW 0x00200000 +#define MSTATUS_TSR 0x00400000 +#define MSTATUS32_SD 0x80000000 +#define MSTATUS64_SD 0x8000000000000000 + +#define SSTATUS_UIE 0x00000001 +#define SSTATUS_SIE 0x00000002 +#define SSTATUS_UPIE 0x00000010 +#define SSTATUS_SPIE 0x00000020 +#define SSTATUS_SPP 0x00000100 +#define SSTATUS_FS 0x00006000 +#define SSTATUS_XS 0x00018000 +#define SSTATUS_SUM 0x00040000 +#define SSTATUS_MXR 0x00080000 +#define SSTATUS32_SD 0x80000000 +#define SSTATUS64_SD 0x8000000000000000 + +#define DCSR_XDEBUGVER (3U<<30) +#define DCSR_NDRESET (1<<29) +#define DCSR_FULLRESET (1<<28) +#define DCSR_EBREAKM (1<<15) +#define DCSR_EBREAKH (1<<14) +#define DCSR_EBREAKS (1<<13) +#define DCSR_EBREAKU (1<<12) +#define DCSR_STOPCYCLE (1<<10) +#define DCSR_STOPTIME (1<<9) +#define DCSR_CAUSE (7<<6) +#define DCSR_DEBUGINT (1<<5) +#define DCSR_HALT (1<<3) +#define DCSR_STEP (1<<2) +#define DCSR_PRV (3<<0) + +#define DCSR_CAUSE_NONE 0 +#define DCSR_CAUSE_SWBP 1 +#define DCSR_CAUSE_HWBP 2 +#define DCSR_CAUSE_DEBUGINT 3 +#define DCSR_CAUSE_STEP 4 +#define DCSR_CAUSE_HALT 5 + +#define MCONTROL_TYPE(xlen) (0xfULL<<((xlen)-4)) +#define MCONTROL_DMODE(xlen) (1ULL<<((xlen)-5)) +#define MCONTROL_MASKMAX(xlen) (0x3fULL<<((xlen)-11)) + +#define MCONTROL_SELECT (1<<19) +#define MCONTROL_TIMING (1<<18) +#define MCONTROL_ACTION (0x3f<<12) +#define MCONTROL_CHAIN (1<<11) +#define MCONTROL_MATCH (0xf<<7) +#define MCONTROL_M (1<<6) +#define MCONTROL_H (1<<5) +#define MCONTROL_S (1<<4) +#define MCONTROL_U (1<<3) +#define MCONTROL_EXECUTE (1<<2) +#define MCONTROL_STORE (1<<1) +#define MCONTROL_LOAD (1<<0) + +#define MCONTROL_TYPE_NONE 0 +#define MCONTROL_TYPE_MATCH 2 + +#define MCONTROL_ACTION_DEBUG_EXCEPTION 0 +#define MCONTROL_ACTION_DEBUG_MODE 1 +#define MCONTROL_ACTION_TRACE_START 2 +#define MCONTROL_ACTION_TRACE_STOP 3 +#define MCONTROL_ACTION_TRACE_EMIT 4 + +#define MCONTROL_MATCH_EQUAL 0 +#define MCONTROL_MATCH_NAPOT 1 +#define MCONTROL_MATCH_GE 2 +#define MCONTROL_MATCH_LT 3 +#define MCONTROL_MATCH_MASK_LOW 4 +#define MCONTROL_MATCH_MASK_HIGH 5 + +#define MIP_SSIP (1 << IRQ_S_SOFT) +#define MIP_HSIP (1 << IRQ_H_SOFT) +#define MIP_MSIP (1 << IRQ_M_SOFT) +#define MIP_STIP (1 << IRQ_S_TIMER) +#define MIP_HTIP (1 << IRQ_H_TIMER) +#define MIP_MTIP (1 << IRQ_M_TIMER) +#define MIP_SEIP (1 << IRQ_S_EXT) +#define MIP_HEIP (1 << IRQ_H_EXT) +#define MIP_MEIP (1 << IRQ_M_EXT) + +#define SIP_SSIP MIP_SSIP +#define SIP_STIP MIP_STIP + +#define PRV_U 0 +#define PRV_S 1 +#define PRV_H 2 +#define PRV_M 3 + +#define SPTBR32_MODE 0x80000000 +#define SPTBR32_ASID 0x7FC00000 +#define SPTBR32_PPN 0x003FFFFF +#define SPTBR64_MODE 0xF000000000000000 +#define SPTBR64_ASID 0x0FFFF00000000000 +#define SPTBR64_PPN 0x00000FFFFFFFFFFF + +#define SPTBR_MODE_OFF 0 +#define SPTBR_MODE_SV32 1 +#define SPTBR_MODE_SV39 8 +#define SPTBR_MODE_SV48 9 +#define SPTBR_MODE_SV57 10 +#define SPTBR_MODE_SV64 11 + +#define PMP_R 0x01 +#define PMP_W 0x02 +#define PMP_X 0x04 +#define PMP_A 0x18 +#define PMP_L 0x80 +#define PMP_SHIFT 2 +#define PMPCFG_COUNT 4 +#define PMPADDR_COUNT 16 + +#define PMP_OFF 0x00 +#define PMP_TOR 0x08 +#define PMP_NA4 0x10 +#define PMP_NAPOT 0x18 + +#define IRQ_S_SOFT 1 +#define IRQ_H_SOFT 2 +#define IRQ_M_SOFT 3 +#define IRQ_S_TIMER 5 +#define IRQ_H_TIMER 6 +#define IRQ_M_TIMER 7 +#define IRQ_S_EXT 9 +#define IRQ_H_EXT 10 +#define IRQ_M_EXT 11 +#define IRQ_COP 12 +#define IRQ_HOST 13 + +#define DEFAULT_RSTVEC 0x00001000 +#define CLINT_BASE 0x02000000 +#define CLINT_SIZE 0x000c0000 +#define EXT_IO_BASE 0x40000000 +#define DRAM_BASE 0x80000000 + +// page table entry (PTE) fields +#define PTE_V 0x001 // Valid +#define PTE_R 0x002 // Read +#define PTE_W 0x004 // Write +#define PTE_X 0x008 // Execute +#define PTE_U 0x010 // User +#define PTE_G 0x020 // Global +#define PTE_A 0x040 // Accessed +#define PTE_D 0x080 // Dirty +#define PTE_SOFT 0x300 // Reserved for Software + +#define PTE_PPN_SHIFT 10 + +#define PTE_TABLE(PTE) (((PTE) & (PTE_V | PTE_R | PTE_W | PTE_X)) == PTE_V) + +#ifdef __riscv + +#if __riscv_xlen == 64 +# define MSTATUS_SD MSTATUS64_SD +# define SSTATUS_SD SSTATUS64_SD +# define RISCV_PGLEVEL_BITS 9 +# define SPTBR_MODE SPTBR64_MODE +#else +# define MSTATUS_SD MSTATUS32_SD +# define SSTATUS_SD SSTATUS32_SD +# define RISCV_PGLEVEL_BITS 10 +# define SPTBR_MODE SPTBR32_MODE +#endif +#define RISCV_PGSHIFT 12 +#define RISCV_PGSIZE (1 << RISCV_PGSHIFT) + +#endif + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/arch/riscv/machine.h b/tests/invader/include/arch/riscv/machine.h new file mode 100644 index 0000000000000000000000000000000000000000..077a6c1e8a629fda3b5eefed0a24e1219c992c8b --- /dev/null +++ b/tests/invader/include/arch/riscv/machine.h @@ -0,0 +1,183 @@ +// See LICENSE for license details. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> +#include <stddef.h> + +void arch_setup(); +void exit(int status) __attribute__((noreturn)); + +#define die(str, ...) ({ \ + printf("%s:%d: " str "\n", __FILE__, __LINE__, ##__VA_ARGS__); exit(-1); }) + +#define assert(x) ({ if (!(x)) die("assertion failed: %s", #x); }) + +#define read_const_csr(reg) ({ unsigned long __tmp; \ + asm ("csrr %0, " #reg : "=r"(__tmp)); __tmp; }) + +#define read_csr(reg) ({ unsigned long __tmp; \ + asm volatile ("csrr %0, " #reg : "=r"(__tmp)); __tmp; }) + +#define write_csr(reg, val) ({ \ + asm volatile ("csrw " #reg ", %0" :: "rK"(val)); }) + +#define swap_csr(reg, val) ({ unsigned long __tmp; \ + asm volatile ("csrrw %0, " #reg ", %1" : "=r"(__tmp) : "rK"(val)); __tmp; }) + +#define set_csr(reg, bit) ({ unsigned long __tmp; \ + asm volatile ("csrrs %0, " #reg ", %1" : "=r"(__tmp) : "rK"(bit)); __tmp; }) + +#define clear_csr(reg, bit) ({ unsigned long __tmp; \ + asm volatile ("csrrc %0, " #reg ", %1" : "=r"(__tmp) : "rK"(bit)); __tmp; }) + +static inline uintptr_t get_field(uintptr_t reg, uintptr_t mask) +{ + return ((reg & mask) / (mask & ~(mask << 1))); +} + +static inline uintptr_t set_field(uintptr_t reg, uintptr_t mask, uintptr_t val) +{ + return ((reg & ~mask) | ((val * (mask & ~(mask << 1))) & mask)); +} + +static inline unsigned long rdtime() { return read_csr(time); } +static inline unsigned long rdcycle() { return read_csr(cycle); } +static inline unsigned long rdinstret() { return read_csr(instret); } +static inline int64_t misa() { return read_const_csr(misa); } +static inline int has_ext(char ext) { return misa() & (1 << (ext - 'a')); } +static inline int xlen() { return misa() < 0 ? 64 : 32; } +static inline void wfi() { asm volatile ("wfi" ::: "memory"); } + +__attribute__((noreturn)) static inline void mret() +{ + asm volatile ("mret"); + __builtin_unreachable(); +} + + +/* + * Memory + * + * TODO - improve this API to return a list of memory segments + */ + +typedef struct memory_info +{ + uintptr_t start; + uintptr_t end; +} memory_info_t; + + +/* + * memory_probe - return memory_info + */ +memory_info_t memory_probe(); + +/* + * memory_probe_range - probe a memory address range + */ +uintptr_t memory_probe_range(uintptr_t start, uintptr_t end); + + +/* + * Physical Memory Protection + * + * PMP is optional but if implememented, enforcement must be enabled by + * default, if no PMP entries are set. This means loads, stores or fetches + * from any mode besides M mode, will fail unless explicitly allowed. + * PMP must be configured irregardless of whether it is implemented. + */ + +typedef struct pmp_info +{ + int width; + int granularity; + int count; +} pmp_info_t; + +/* + * pmp_probe - return pmp_info + */ +pmp_info_t pmp_probe(); + +/* + * pmp_entry_granularity - return PMP entry width (physical memory width) + */ +int pmp_entry_width(); + +/* + * pmp_entry_granularity - return PMP entry granularity (smallest entry size) + */ +int pmp_entry_granularity(); + +/* + * pmp_entry_count - return number of PMP entries + */ +int pmp_entry_count(); + +/* + * pmp_clear_all - set PMP to disallow mode != PRV_M physical memory accesses + */ +void pmp_clear_all(); + +/* + * pmp_allow_all - set PMP to allow mode != PRV_M physical memory accesses + */ +void pmp_allow_all(); + +/* + * pmp_entry_set - set one PMP entry + * + * - n : pmp entry number + * - prot : protection (PMP_R | PMP_W | PMP_X) + * - addr : start address + * - len : power of two length + */ +int pmp_entry_set(unsigned n, uint8_t prot, uint64_t addr, uint64_t len); + + +/* + * Privileged modes + */ + +/* + * mode_set_and_jump + * + * Set mstatus.mpp, sets mepc to passed function pointer and then issues mret + * Note: the hart will continue running on the same stack + */ +static inline void mode_set_and_jump(unsigned mode, void (*fn)(void)) +{ + assert(mode <= PRV_U); + write_csr(mstatus, set_field(read_csr(mstatus), MSTATUS_MPP, mode)); + write_csr(mepc, fn); + mret(); +} + +/* + * mode_set_and_continue + * + * Set mstatus.mpp, sets mepc to instruction after mret and then issues mret + * Note: the hart will continue running on the same stack + */ +static inline void mode_set_and_continue(unsigned mode) +{ + assert(mode <= PRV_U); + write_csr(mstatus, set_field(read_csr(mstatus), MSTATUS_MPP, mode)); + asm volatile ( + "lla t0, 1f\n" + "csrw mepc, t0\n" + "mret\n" + "1:" + ::: "t0" + ); +} + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/arch/riscv/pte.h b/tests/invader/include/arch/riscv/pte.h new file mode 100644 index 0000000000000000000000000000000000000000..38d7b8d4ad7999e8d07a430be1b8e0c908a1ad8d --- /dev/null +++ b/tests/invader/include/arch/riscv/pte.h @@ -0,0 +1,121 @@ +#pragma once + +enum { + PTE_SHIFT_V = 0, + PTE_SHIFT_R = 1, + PTE_SHIFT_W = 2, + PTE_SHIFT_X = 3, + PTE_SHIFT_U = 4, + PTE_SHIFT_G = 5, + PTE_SHIFT_A = 6, + PTE_SHIFT_D = 7, + PTE_SHIFT_SW1 = 8, + PTE_SHIFT_SW2 = 9, + PTE_V = 1 << PTE_SHIFT_V, + PTE_R = 1 << PTE_SHIFT_R, + PTE_W = 1 << PTE_SHIFT_W, + PTE_X = 1 << PTE_SHIFT_X, + PTE_U = 1 << PTE_SHIFT_U, + PTE_G = 1 << PTE_SHIFT_G, + PTE_A = 1 << PTE_SHIFT_A, + PTE_D = 1 << PTE_SHIFT_D, + PTE_SW1 = 1 << PTE_SHIFT_SW1, + PTE_SW2 = 1 << PTE_SHIFT_SW2 +}; + +enum { + SV32_LEVELS = 2, + SV32_LEVEL_BITS = 10, + SV32_PTE_SIZE = 4 +}; + +union sv32_va { + uint32_t val; + struct { + uint32_t pg_off : 12; + uint32_t vpn : 20; + } va; +}; + +union sv32_pa { + uint64_t val; + struct { + uint64_t pg_off : 12; + uint64_t ppn : 22; + uint64_t rsrv : 30; + } pa; +}; + +union sv32_pte { + uint32_t val; + struct { + uint32_t flags : 10; + uint32_t ppn : 22; + } pte; +}; + +enum { + SV39_LEVELS = 3, + SV39_LEVEL_BITS = 9, + SV39_PTE_SIZE = 8 +}; + +union sv39_va { + uint64_t val; + struct { + uint64_t pg_off : 12; + uint64_t vpn : 27; + uint64_t rsrv : 25; + } va; +}; + +union sv39_pa { + uint64_t val; + struct { + uint64_t pg_off : 12; + uint64_t ppn : 44; + uint64_t rsrv : 8; + } pa; +}; + +union sv39_pte { + uint64_t val; + struct { + uint64_t flags : 10; + uint64_t ppn : 44; + uint64_t rsrv : 10; + } pte; +}; + +enum { + SV48_LEVELS = 4, + SV48_LEVEL_BITS = 9, + SV48_PTE_SIZE = 8 +}; + +union sv48_va { + uint64_t val; + struct { + uint64_t pg_off : 12; + uint64_t vpn : 36; + uint64_t rsrv : 16; + } va; +}; + +union sv48_pa { + uint64_t val; + struct { + uint64_t pg_off : 12; + uint64_t ppn : 44; + uint64_t rsrv : 8; + } pa; +}; + +union sv48_pte { + uint64_t val; + struct { + uint64_t flags : 10; + uint64_t ppn : 44; + uint64_t rsrv : 10; + } pte; +}; diff --git a/tests/invader/include/arch/riscv/trap.h b/tests/invader/include/arch/riscv/trap.h new file mode 100644 index 0000000000000000000000000000000000000000..0b33ec587ae9529285cb1f8f8ceb17249ec49741 --- /dev/null +++ b/tests/invader/include/arch/riscv/trap.h @@ -0,0 +1,51 @@ +// See LICENSE for license details. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*trap_fn)(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc); +trap_fn get_trap_fn(); +void set_trap_fn(trap_fn fn); + +const char * riscv_excp_names[16]; +const char * riscv_intr_names[16]; + +enum { + cause_misaligned_fetch = 0, + cause_fault_fetch = 1, + cause_illegal_instruction = 2, + cause_breakpoint = 3, + cause_misaligned_load = 4, + cause_fault_load = 5, + cause_misaligned_store = 6, + cause_fault_store = 7, + cause_user_ecall = 8, + cause_supervisor_ecall = 9, + cause_hypervisor_ecall = 10, + cause_machine_ecall = 11, + cause_exec_page_fault = 12, + cause_load_page_fault = 13, + cause_store_page_fault = 15 +}; + +enum { + intr_u_software = 0, + intr_s_software = 1, + intr_h_software = 2, + intr_m_software = 3, + intr_u_timer = 4, + intr_s_timer = 5, + intr_h_timer = 6, + intr_m_timer = 7, + intr_u_external = 8, + intr_s_external = 9, + intr_h_external = 10, + intr_m_external = 11, +}; + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/auxval.h b/tests/invader/include/auxval.h new file mode 100644 index 0000000000000000000000000000000000000000..de108243640d3a8179b85cffb1dd8a54b47f3b14 --- /dev/null +++ b/tests/invader/include/auxval.h @@ -0,0 +1,34 @@ +// See LICENSE for license details. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + HART0_CLOCK_FREQ = 0x00010000, + UART0_CLOCK_FREQ = 0x00011000, + UART0_BAUD_RATE = 0x00011100, + NS16550A_UART0_CTRL_ADDR = 0x00030000, + RISCV_HTIF_BASE_ADDR = 0x00050000, + SIFIVE_CLINT_CTRL_ADDR = 0x55550000, + SIFIVE_CLIC_CRTL_ADDR = 0x55550001, + SIFIVE_TEST_CTRL_ADDR = 0x55550002, + SIFIVE_UART0_CTRL_ADDR = 0x55550010, + SIFIVE_GPIO0_CTRL_ADDR = 0x55550020, + SIFIVE_SPI0_CTRL_ADDR = 0x55550030, +}; + +typedef struct auxval { + unsigned long key; + unsigned long val; +} auxval_t; + +extern auxval_t __auxv[]; + +unsigned long getauxval(unsigned long key); + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/device.h b/tests/invader/include/device.h new file mode 100644 index 0000000000000000000000000000000000000000..822ab8c3f25147bfe0bb704f32b26f1931c85957 --- /dev/null +++ b/tests/invader/include/device.h @@ -0,0 +1,39 @@ +// See LICENSE for license details. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct console_device { + void (*init)(); + int (*getchar)(); + int (*putchar)(int); +} console_device_t; + +typedef struct poweroff_device { + void (*init)(); + void (*poweroff)(int); +} poweroff_device_t; + +void register_console(console_device_t *dev); +void register_poweroff(poweroff_device_t *dev); + +extern console_device_t *console_dev; +extern poweroff_device_t *poweroff_dev; + +extern console_device_t console_none; +extern console_device_t console_htif; +extern console_device_t console_ns16550a; +extern console_device_t console_sifive_uart; +extern console_device_t console_semihost; + +extern poweroff_device_t poweroff_none; +extern poweroff_device_t poweroff_htif; +extern poweroff_device_t poweroff_sifive_test; +extern poweroff_device_t poweroff_semihost; + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/elf.h b/tests/invader/include/elf.h new file mode 100644 index 0000000000000000000000000000000000000000..abfb892a256f9a9be1b155c7ffb3ca1d7f3ee3ac --- /dev/null +++ b/tests/invader/include/elf.h @@ -0,0 +1,545 @@ +#pragma once + +#include <stdint.h> + +typedef uint32_t Elf32_Addr; +typedef uint16_t Elf32_Half; +typedef uint32_t Elf32_Off; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf32_Word; +typedef uint8_t Elf32_Byte; + +typedef uint64_t Elf64_Addr; +typedef uint16_t Elf64_Half; +typedef uint64_t Elf64_Off; +typedef int32_t Elf64_Sword; +typedef uint32_t Elf64_Word; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; +typedef uint8_t Elf64_Byte; + +enum { + AT_NULL = 0, + AT_PHDR = 3, + AT_PHENT = 4, + AT_PHNUM = 5, + AT_PAGESZ = 6, + AT_BASE = 7, + AT_FLAGS = 8, + AT_ENTRY = 9, + AT_UID = 11, + AT_EUID = 12, + AT_GID = 13, + AT_EGID = 14, + AT_CLKTCK = 17, + AT_SECURE = 23, + AT_RANDOM = 25 +}; + +typedef struct { + Elf32_Word a_type; + Elf32_Word a_val; +} Elf32_auxv; + +typedef struct { + Elf64_Word a_type; + Elf64_Word a_val; +} Elf64_auxv; + +enum { + ET_NONE = 0, + ET_REL = 1, + ET_EXEC = 2, + ET_DYN = 3, + ET_CORE = 4, + ET_LOPROC = 0xff00, + ET_HIPROC = 0xffff +}; + +enum { + EM_NONE = 0, + EM_X86_64 = 62, + EM_RISCV = 243 +}; + +enum { + EV_NONE = 0, + EV_CURRENT = 1 +}; + +enum { + EI_MAG0 = 0, + EI_MAG1 = 1, + EI_MAG2 = 2, + EI_MAG3 = 3, + EI_CLASS = 4, + EI_DATA = 5, + EI_VERSION = 6, + EI_OSABI = 7, + EI_ABIVERSION = 8, + EI_PAD = 9, + EI_NIDENT = 16 +}; + +enum { + ELFMAG0 = 0x7f, + ELFMAG1 = 'E', + ELFMAG2 = 'L', + ELFMAG3 = 'F' +}; + +enum { + ELFCLASSNONE = 0, + ELFCLASS32 = 1, + ELFCLASS64 = 2, + ELFCLASS128 = 3 +}; + +enum { + ELFDATANONE = 0, + ELFDATA2LSB = 1, + ELFDATA2MSB = 2 +}; + +enum { + ELFOSABI_SYSV = 0, + ELFOSABI_LINUX = 3, + ELFOSABI_SOLARIS = 6, + ELFOSABI_FREEBSD = 9 +}; + +enum { + ELFABIVERSION_NONE = 0 +}; + +typedef struct { + Elf32_Byte e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} Elf32_Ehdr; + +typedef struct { + Elf64_Byte e_ident[EI_NIDENT]; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} Elf64_Ehdr; + +enum { + PT_NULL = 0, + PT_LOAD = 1, + PT_DYNAMIC = 2, + PT_INTERP = 3, + PT_NOTE = 4, + PT_SHLIB = 5, + PT_PHDR = 6, + PT_TLS = 7, + PT_LOOS = 0x60000000, + PT_GNU_EH_FRAME = 0x6474e550, + PT_GNU_STACK = 0x6474e551, + PT_GNU_RELRO = 0x6474e552, + PT_HIOS = 0x6fffffff, + PT_LOPROC = 0x70000000, + PT_HIPROC = 0x7fffffff +}; + +enum { + PF_X = 0x1, + PF_W = 0x2, + PF_R = 0x4, + PF_MASKOS = 0x00FF0000, + PF_MASKPROC = 0xFF000000, +}; + +typedef struct { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr; + +typedef struct { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} Elf64_Phdr; + +enum { + SHN_UNDEF = 0, + SHN_LOPROC = 0xff00, + SHN_HIPROC = 0xff1f, + SHN_LOOS = 0xff20, + SHN_HIOS = 0xff3f, + SHN_ABS = 0xfff1, + SHN_COMMON = 0xfff2, + SHN_XINDEX = 0xffff, + SHN_HIRESERVE = 0xffff, +}; + +enum { + SHT_NULL = 0, + SHT_PROGBITS = 1, + SHT_SYMTAB = 2, + SHT_STRTAB = 3, + SHT_RELA = 4, + SHT_HASH = 5, + SHT_DYNAMIC = 6, + SHT_NOTE = 7, + SHT_NOBITS = 8, + SHT_REL = 9, + SHT_SHLIB = 10, + SHT_DYNSYM = 11, + SHT_INIT_ARRAY = 14, + SHT_FINI_ARRAY = 15, + SHT_PREINIT_ARRAY = 16, + SHT_GROUP = 17, + SHT_SYMTAB_SHNDX = 18, + SHT_LOOS = 0x60000000, + SHT_GNU_VERDEF = 0x6ffffffd, + SHT_GNU_VERNEED = 0x6ffffffe, + SHT_GNU_VERSYM = 0x6fffffff, + SHT_HIOS = 0x6fffffff, + SHT_LOPROC = 0x70000000, + SHT_HIPROC = 0x7fffffff, + SHT_LOUSER = 0x80000000, + SHT_HIUSER = 0xffffffff +}; + +enum { + SHF_WRITE = 0x1, + SHF_ALLOC = 0x2, + SHF_EXECINSTR = 0x4, + SHF_MERGE = 0x10, + SHF_STRINGS = 0x20, + SHF_INFO_LINK = 0x40, + SHF_LINK_ORDER = 0x80, + SHF_GROUP = 0x200, + SHF_TLS = 0x400, + SHF_MASKOS = 0x0F000000, + SHF_MASKPROC = 0xf0000000 +}; + +enum { + GRP_COMDAT = 0x1, + GRP_MASKOS = 0x0ff00000, + GRP_MASKPROC = 0xf0000000 +}; + +typedef struct { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} Elf32_Shdr; + +typedef struct { + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +} Elf64_Shdr; + + +typedef struct { + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +} Elf32_Nhdr; + +typedef struct { + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; +} Elf64_Nhdr; + +static inline const Elf32_Byte ELF32_ST_BIND(Elf32_Word i) { return i >> 4; } +static inline const Elf32_Byte ELF32_ST_TYPE(Elf32_Word i) { return i & 0xf; } +static inline const Elf32_Byte ELF32_ST_INFO(Elf32_Word b, Elf32_Word t) { return (b << 4) | (t & 0xf); } + +static inline const Elf32_Byte ELF64_ST_BIND(Elf32_Word i) { return i >> 4; } +static inline const Elf32_Byte ELF64_ST_TYPE(Elf32_Word i) { return i & 0xf; } +static inline const Elf32_Byte ELF64_ST_INFO(Elf32_Word b, Elf32_Word t) { return (b << 4) | (t & 0xf); } + +enum { + STB_LOCAL = 0, + STB_GLOBAL = 1, + STB_WEAK = 2, + STB_LOOS = 10, + STB_HIOS = 12, + STB_LOPROC = 13, + STB_HIPROC = 15 +}; + +enum { + STT_NOTYPE = 0, + STT_OBJECT = 1, + STT_FUNC = 2, + STT_SECTION = 3, + STT_FILE = 4, + STT_LOOS = 10, + STT_HIOS = 12, + STT_LOPROC = 13, + STT_HIPROC = 15 +}; + +enum { + STV_DEFAULT = 0, + STV_INTERNAL = 1, + STV_HIDDEN = 2, + STV_PROTECTED = 3 +}; + +typedef struct { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + Elf32_Byte st_info; + Elf32_Byte st_other; + Elf32_Half st_shndx; +} Elf32_Sym; + +typedef struct { + Elf64_Word st_name; + Elf64_Byte st_info; + Elf64_Byte st_other; + Elf64_Half st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +} Elf64_Sym; + +static inline const Elf32_Word ELF32_R_SYM(Elf32_Word i) { return i >> 8; } +static inline const Elf32_Word ELF32_R_TYPE(Elf32_Word i) { return i & 0xff; } +static inline const Elf32_Word ELF32_R_INFO(Elf32_Word s, Elf32_Word t) { return (s << 8) | (t & 0xff); } + +static inline const Elf64_Xword ELF64_R_SYM(Elf64_Xword i) { return i >> 32; } +static inline const Elf64_Xword ELF64_R_TYPE(Elf64_Xword i) { return i & 0xffffffffUL; } +static inline const Elf64_Xword ELF64_R_INFO(Elf64_Xword s, Elf64_Xword t) { return (s << 32) | (t & 0xffffffffUL); } + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; +} Elf32_Rel; + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} Elf32_Rela; + +typedef struct +{ + Elf64_Addr r_offset; + Elf64_Xword r_info; +} Elf64_Rel; + +typedef struct +{ + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; +} Elf64_Rela; + +enum { + R_X86_64_NONE = 0, + R_X86_64_64 = 1, + R_X86_64_PC32 = 2, + R_X86_64_GOT32 = 3, + R_X86_64_PLT32 = 4, + R_X86_64_COPY = 5, + R_X86_64_GLOB_DAT = 6, + R_X86_64_JUMP_SLOT = 7, + R_X86_64_RELATIVE = 8, + R_X86_64_GOTPCREL = 9, + R_X86_64_32 = 10, + R_X86_64_32S = 11, + R_X86_64_16 = 12, + R_X86_64_PC16 = 13, + R_X86_64_8 = 14, + R_X86_64_PC8 = 15, + R_X86_64_DTPMOD64 = 16, + R_X86_64_DTPOFF64 = 17, + R_X86_64_TPOFF64 = 18, + R_X86_64_TLSGD = 19, + R_X86_64_TLSLD = 20, + R_X86_64_DTPOFF32 = 21, + R_X86_64_GOTTPOFF = 22, + R_X86_64_TPOFF32 = 23, + R_X86_64_PC64 = 24, + R_X86_64_GOTOFF64 = 25, + R_X86_64_GOTPC32 = 26, + R_X86_64_SIZE32 = 32, + R_X86_64_SIZE64 = 33, + R_X86_64_GOTPC32_TLSDESC = 34, + R_X86_64_TLSDESC_CALL = 35, + R_X86_64_TLSDESC = 36, + R_X86_64_IRELATIVE = 37, + R_X86_64_RELATIVE64 = 38 +}; + +enum { + R_RISCV_NONE = 0, + R_RISCV_32 = 1, + R_RISCV_64 = 2, + R_RISCV_RELATIVE = 3, + R_RISCV_COPY = 4, + R_RISCV_JUMP_SLOT = 5, + R_RISCV_TLS_DTPMOD32 = 6, + R_RISCV_TLS_DTPMOD64 = 7, + R_RISCV_TLS_DTPREL32 = 8, + R_RISCV_TLS_DTPREL64 = 9, + R_RISCV_TLS_TPREL32 = 10, + R_RISCV_TLS_TPREL64 = 11, + R_RISCV_BRANCH = 16, + R_RISCV_JAL = 17, + R_RISCV_CALL = 18, + R_RISCV_CALL_PLT = 19, + R_RISCV_GOT_HI20 = 20, + R_RISCV_TLS_GOT_HI20 = 21, + R_RISCV_TLS_GD_HI20 = 22, + R_RISCV_PCREL_HI20 = 23, + R_RISCV_PCREL_LO12_I = 24, + R_RISCV_PCREL_LO12_S = 25, + R_RISCV_HI20 = 26, + R_RISCV_LO12_I = 27, + R_RISCV_LO12_S = 28, + R_RISCV_TPREL_HI20 = 29, + R_RISCV_TPREL_LO12_I = 30, + R_RISCV_TPREL_LO12_S = 31, + R_RISCV_TPREL_ADD = 32, + R_RISCV_ADD8 = 33, + R_RISCV_ADD16 = 34, + R_RISCV_ADD32 = 35, + R_RISCV_ADD64 = 36, + R_RISCV_SUB8 = 37, + R_RISCV_SUB16 = 38, + R_RISCV_SUB32 = 39, + R_RISCV_SUB64 = 40, + R_RISCV_GNU_VTINHERIT = 41, + R_RISCV_GNU_VTENTRY = 42, + R_RISCV_ALIGN = 43, + R_RISCV_RVC_BRANCH = 44, + R_RISCV_RVC_JUMP = 45, + R_RISCV_RVC_LUI = 46, + R_RISCV_GPREL_I = 47, + R_RISCV_GPREL_S = 48, + R_RISCV_TPREL_I = 49, + R_RISCV_TPREL_S = 50, + R_RISCV_RELAX = 51, + R_RISCV_SUB6 = 52, + R_RISCV_SET6 = 53, + R_RISCV_SET8 = 54, + R_RISCV_SET16 = 55, + R_RISCV_SET32 = 56, +}; + +enum { + EF_RISCV_RVC = 0x1, + EF_RISCV_FLOAT_ABI_SINGLE = 0x2, + EF_RISCV_FLOAT_ABI_DOUBLE = 0x4, + EF_RISCV_FLOAT_ABI_QUAD = 0x6, + EF_RISCV_RVE = 0x8 +}; + +enum { + DF_ORIGIN = 1, + DF_SYMBOLIC = 2, + DF_TEXTREL = 4, + DF_BIND_NOW = 8, + DF_STATIC_TLS = 16 +}; + +enum { + DT_NULL = 0, + DT_NEEDED = 1, + DT_PLTRELSZ = 2, + DT_PLTGOT = 3, + DT_HASH = 4, + DT_STRTAB = 5, + DT_SYMTAB = 6, + DT_RELA = 7, + DT_RELASZ = 8, + DT_RELAENT = 9, + DT_STRSZ = 10, + DT_SYMENT = 11, + DT_INIT = 12, + DT_FINI = 13, + DT_SONAME = 14, + DT_RPATH = 15, + DT_SYMBOLIC = 16, + DT_REL = 17, + DT_RELSZ = 18, + DT_RELENT = 19, + DT_PLTREL = 20, + DT_DEBUG = 21, + DT_TEXTREL = 22, + DT_JMPREL = 23, + DT_BIND_NOW = 24, + DT_INIT_ARRAY = 25, + DT_FINI_ARRAY = 26, + DT_INIT_ARRAYSZ = 27, + DT_FINI_ARRAYSZ = 28, + DT_RUNPATH = 29, + DT_FLAGS = 30, + DT_LOOS = 0x60000000, + DT_HIOS = 0x6fffffff, + DT_LOPROC = 0x70000000, + DT_HIPROC = 0x7fffffff +}; + +typedef struct { + Elf32_Sword d_tag; + union { + Elf32_Word d_val; + Elf32_Addr d_ptr; + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Sxword d_tag; + union { + Elf64_Xword d_val; + Elf64_Addr d_ptr; + } d_un; +} Elf64_Dyn; diff --git a/tests/invader/include/endian.h b/tests/invader/include/endian.h new file mode 100644 index 0000000000000000000000000000000000000000..8510f2939748b9b810ae07d8b9ef0bd62c88cd13 --- /dev/null +++ b/tests/invader/include/endian.h @@ -0,0 +1,95 @@ +#pragma once + +#define bswap16(x) __builtin_bswap16(x) +#define bswap32(x) __builtin_bswap32(x) +#define bswap64(x) __builtin_bswap64(x) + +#if __BYTE_ORDER == __LITTLE_ENDIAN +static inline uint16_t htobe16(uint16_t x) { return bswap16(x); } +static inline uint16_t htole16(uint16_t x) { return x; } +static inline uint16_t be16toh(uint16_t x) { return bswap16(x); } +static inline uint16_t le16toh(uint16_t x) { return x; } + +static inline uint32_t htobe32(uint32_t x) { return bswap32(x); } +static inline uint32_t htole32(uint32_t x) { return x; } +static inline uint32_t be32toh(uint32_t x) { return bswap32(x); } +static inline uint32_t le32toh(uint32_t x) { return x; } + +static inline uint64_t htobe64(uint64_t x) { return bswap64(x); } +static inline uint64_t htole64(uint64_t x) { return x; } +static inline uint64_t be64toh(uint64_t x) { return bswap64(x); } +static inline uint64_t le64toh(uint64_t x) { return x; } +#elif __BYTE_ORDER == __BIG_ENDIAN +static inline uint16_t htobe16(uint16_t x) { return x; } +static inline uint16_t htole16(uint16_t x) { return bswap16(x); } +static inline uint16_t be16toh(uint16_t x) { return x; } +static inline uint16_t le16toh(uint16_t x) { return bswap16(x); } + +static inline uint32_t htobe32(uint32_t x) { return x; } +static inline uint32_t htole32(uint32_t x) { return bswap32(x); } +static inline uint32_t be32toh(uint32_t x) { return x; } +static inline uint32_t le32toh(uint16_t x) { return bswap64(x); } + +static inline uint64_t htobe64(uint64_t x) { return x; } +static inline uint64_t htole64(uint64_t x) { return bswap64(x); } +static inline uint64_t be64toh(uint64_t x) { return x; } +static inline uint64_t le64toh(uint64_t x) { return bswap64(x); } +#endif + +#if __SIZE_WIDTH__ == 32 +#define _htobel htobe32 +#define _beltoh be32toh +#define _htolel htole32 +#define _leltoh le32toh +#endif + +#if __SIZE_WIDTH__ == 64 +#define _htobel htobe64 +#define _beltoh be64toh +#define _htolel htole64 +#define _leltoh le64toh +#endif + +#define htobe(X) _Generic((X), \ + short: htobe16, \ + unsigned short: htobe16, \ + int: htobe32, \ + unsigned int: htobe32, \ + long: _htobel, \ + unsigned long: _htobel, \ + long long: htobe64, \ + unsigned long long: htobe64 \ + )(X) + +#define betoh(X) _Generic((X), \ + short: be16toh, \ + unsigned short: be16toh, \ + int: be32toh, \ + unsigned int: be32toh, \ + long: _beltoh, \ + unsigned long: _beltoh, \ + long long: be64toh, \ + unsigned long long: be64toh \ + )(X) + +#define htole(X) _Generic((X), \ + short: htole16, \ + unsigned short: htole16, \ + int: htole32, \ + unsigned int: htole32, \ + long: _htolel, \ + unsigned long: _htolel, \ + long long: htole64, \ + unsigned long long: htole64 \ + )(X) + +#define letoh(X) _Generic((X), \ + short: le16toh, \ + unsigned short: le16toh, \ + int: le32toh, \ + unsigned int: le32toh, \ + long: _leltoh, \ + unsigned long: _leltoh, \ + long long: le64toh, \ + unsigned long long: le64toh \ + )(X) diff --git a/tests/invader/include/femto.h b/tests/invader/include/femto.h new file mode 100644 index 0000000000000000000000000000000000000000..aa8b4cf00d380a0321f909c8971f249316b8ddfb --- /dev/null +++ b/tests/invader/include/femto.h @@ -0,0 +1,14 @@ +// See LICENSE for license details. + +#pragma once + +#include <stdio.h> +#include <stdint.h> +#include <stddef.h> +#include <stdarg.h> +#include <stdlib.h> +#include <stdbits.h> +#include <string.h> + +#include "auxval.h" +#include "device.h" diff --git a/tests/invader/include/font.h b/tests/invader/include/font.h new file mode 100644 index 0000000000000000000000000000000000000000..58f066b5e4c9e162f153431ce2dc366e094dedfe --- /dev/null +++ b/tests/invader/include/font.h @@ -0,0 +1,28 @@ +#ifndef FONT_H +#define FONT_H +/** + * 8x8 monochrome bitmap fonts for rendering + * Author: Daniel Hepper <daniel@hepper.net> + * + * License: Public Domain + * + * Based on: + * // Summary: font8x8.h + * // 8x8 monochrome bitmap fonts for rendering + * // + * // Author: + * // Marcel Sondaar + * // International Business Machines (public domain VGA fonts) + * // + * // License: + * // Public Domain + * + * Fetched from: http://dimensionalrift.homelinux.net/combuster/mos3/?p=viewsource&file=/modules/gfx/font8_8.asm + * Fetched from github : https://github.com/dhepper/font8x8/blob/master/font8x8_basic.h + **/ + +// Constant: font8x8_basic +// Contains an 8x8 font map for unicode points U+0000 - U+007F (basic latin) +extern char font8x8_basic[256][8]; + +#endif diff --git a/tests/invader/include/libscreen.h b/tests/invader/include/libscreen.h new file mode 100644 index 0000000000000000000000000000000000000000..c222621680066fe7682cebfa7a37aa12e7964981 --- /dev/null +++ b/tests/invader/include/libscreen.h @@ -0,0 +1,69 @@ +#ifndef LIBSCREEN +#define LIBSCREEN + +typedef unsigned int uint; +#include "font.h" +#include "femto.h" + +#define CLINT_MSIP 0x02000000 +#define CLINT_TIMER_CMP 0x02004000 +#define CLINT_TIMER_CMP_HI 0x02004004 +#define CLINT_TIMER_CMP_LO 0x02004000 +#define CLINT_TIMER 0x0200bff8 +#define CLINT_TIMER_HI 0x0200bffc +#define CLINT_TIMER_LOW 0x0200bff8 + + + +volatile uint* IMG; +volatile uint *push; +volatile uint *timer; +volatile uint *timer_cmp; + +/* function to get the state of push buttons */ +uint push_button_get(void); + +// Timer options +#ifdef ENV_QEMU +#define TIMER_FREQ 10000000 // 10MHz +#define RATIO 500 +#else +#define TIMER_FREQ 100000000 // 100MHz +#define RATIO 200 +#endif + +/* function to set the timer to be reached in period*time/100 in the future */ +void timer_set(uint period, uint time); + +/* function to wait for timer zero value */ +void timer_wait(void); + +void timer_set_and_wait(uint period, uint time); + +#define NBCOL 1920 +#define NBROW 1080 + +uint fgcolor; +uint bgcolor; + +void draw(uint color, uint x, uint y); + +void clear_screen(uint color); + +void draw_bitmap(char* bitmap); + +void newline(); +void tab(); + +/* Counts the number of characters of current word. Will be used to break lines, if possible not in the middle of words. */ +uint num_characters_until_white(char* str); + +uint display_cur_x = 0; +uint display_cur_y = 0; +uint display_scale = 16; + +void display_uint(uint i); +void display_string(char* str); +void set_fg_color(uint color); +void set_bg_color(uint color); +#endif diff --git a/tests/invader/include/list.h b/tests/invader/include/list.h new file mode 100644 index 0000000000000000000000000000000000000000..5f4cc72eca0b0c2f81c58c78400d997b11b4aba4 --- /dev/null +++ b/tests/invader/include/list.h @@ -0,0 +1,495 @@ +/* + * Minimal Linux-like double-linked list helper functions + * + * Copyright (c) 2012-2016, Sven Eckelmann <sven@narfation.org> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stddef.h> + +/** + * container_of() - Calculate address of object that contains address ptr + * @ptr: pointer to member variable + * @type: type of the structure containing ptr + * @member: name of the member variable in struct @type + * + * Return: @type pointer of object containing ptr + */ + +#define container_of(ptr, type, member) __extension__ ({ \ + const __typeof__(((type *)0)->member) *__pmember = (ptr); \ + (type *)((char *)__pmember - offsetof(type, member)); }) + +/** + * struct list_head - Head and node of a double-linked list + * @prev: pointer to the previous node in the list + * @next: pointer to the next node in the list + * + * The simple double-linked list consists of a head and nodes attached to + * this head. Both node and head share the same struct type. The list_* + * functions and macros can be used to access and modify this data structure. + * + * The @prev pointer of the list head points to the last list node of the + * list and @next points to the first list node of the list. For an empty list, + * both member variables point to the head. + * + * The list nodes are usually embedded in a container structure which holds the + * actual data. Such an container object is called entry. The helper list_entry + * can be used to calculate the object address from the address of the node. + */ +struct list_head { + struct list_head *prev; + struct list_head *next; +}; + +/** + * LIST_HEAD - Declare list head and initialize it + * @head: name of the new object + */ +#define LIST_HEAD(head) \ + struct list_head head = { &(head), &(head) } + +/** + * INIT_LIST_HEAD() - Initialize empty list head + * @head: pointer to list head + * + * This can also be used to initialize a unlinked list node. + * + * A node is usually linked inside a list, will be added to a list in + * the near future or the entry containing the node will be free'd soon. + * + * But an unlinked node may be given to a function which uses list_del(_init) + * before it ends up in a previously mentioned state. The list_del(_init) on an + * initialized node is well defined and safe. But the result of a + * list_del(_init) on an uninitialized node is undefined (unrelated memory is + * modified, crashes, ...). + */ +static __inline__ void INIT_LIST_HEAD(struct list_head *head) +{ + head->next = head; + head->prev = head; +} + +/** + * list_add() - Add a list node to the beginning of the list + * @node: pointer to the new node + * @head: pointer to the head of the list + */ +static __inline__ void list_add(struct list_head *node, + struct list_head *head) +{ + struct list_head *next = head->next; + + next->prev = node; + node->next = next; + node->prev = head; + head->next = node; +} + +/** + * list_add_tail() - Add a list node to the end of the list + * @node: pointer to the new node + * @head: pointer to the head of the list + */ +static __inline__ void list_add_tail(struct list_head *node, + struct list_head *head) +{ + struct list_head *prev = head->prev; + + prev->next = node; + node->next = head; + node->prev = prev; + head->prev = node; +} + +/** + * list_add_before() - Add a list node before another node to the list + * @new_node: pointer to the new node + * @node: pointer to the reference node in the list + * + * WARNING this functionality is not available in the Linux list implementation + */ +#define list_add_before(new_node, node) \ + list_add_tail(new_node, node) + +/** + * list_add_behind() - Add a list node behind another node to the list + * @new_node: pointer to the new node + * @node: pointer to the reference node in the list + * + * WARNING this functionality is not available in the Linux list implementation + */ +#define list_add_behind(new_node, node) \ + list_add(new_node, node) + +/** + * list_del() - Remove a list node from the list + * @node: pointer to the node + * + * The node is only removed from the list. Neither the memory of the removed + * node nor the memory of the entry containing the node is free'd. The node + * has to be handled like an uninitialized node. Accessing the next or prev + * pointer of the node is not safe. + * + * Unlinked, initialized nodes are also uninitialized after list_del. + * + * LIST_POISONING can be enabled during build-time to provoke an invalid memory + * access when the memory behind the next/prev pointer is used after a list_del. + * This only works on systems which prohibit access to the predefined memory + * addresses. + */ +static __inline__ void list_del(struct list_head *node) +{ + struct list_head *next = node->next; + struct list_head *prev = node->prev; + + next->prev = prev; + prev->next = next; + +#ifdef LIST_POISONING + node->prev = (struct list_head *)(0x00100100); + node->next = (struct list_head *)(0x00200200); +#endif +} + +/** + * list_del_init() - Remove a list node from the list and reinitialize it + * @node: pointer to the node + * + * The removed node will not end up in an uninitialized state like when using + * list_del. Instead the node is initialized again to the unlinked state. + */ +static __inline__ void list_del_init(struct list_head *node) +{ + list_del(node); + INIT_LIST_HEAD(node); +} + +/** + * list_empty() - Check if list head has no nodes attached + * @head: pointer to the head of the list + * + * Return: 0 - list is not empty !0 - list is empty + */ +static __inline__ int list_empty(const struct list_head *head) +{ + return (head->next == head); +} + +/** + * list_is_singular() - Check if list head has exactly one node attached + * @head: pointer to the head of the list + * + * Return: 0 - list is not singular !0 -list has exactly one entry + */ +static __inline__ int list_is_singular(const struct list_head *head) +{ + return (!list_empty(head) && head->prev == head->next); +} + +/** + * list_splice() - Add list nodes from a list to beginning of another list + * @list: pointer to the head of the list with the node entries + * @head: pointer to the head of the list + * + * All nodes from @list are added to to the beginning of the list of @head. + * It is similar to list_add but for multiple nodes. The @list head is not + * modified and has to be initialized to be used as a valid list head/node + * again. + */ +static __inline__ void list_splice(struct list_head *list, + struct list_head *head) +{ + struct list_head *head_first = head->next; + struct list_head *list_first = list->next; + struct list_head *list_last = list->prev; + + if (list_empty(list)) + return; + + head->next = list_first; + list_first->prev = head; + + list_last->next = head_first; + head_first->prev = list_last; +} + +/** + * list_splice_tail() - Add list nodes from a list to end of another list + * @list: pointer to the head of the list with the node entries + * @head: pointer to the head of the list + * + * All nodes from @list are added to to the end of the list of @head. + * It is similar to list_add_tail but for multiple nodes. The @list head is not + * modified and has to be initialized to be used as a valid list head/node + * again. + */ +static __inline__ void list_splice_tail(struct list_head *list, + struct list_head *head) +{ + struct list_head *head_last = head->prev; + struct list_head *list_first = list->next; + struct list_head *list_last = list->prev; + + if (list_empty(list)) + return; + + head->prev = list_last; + list_last->next = head; + + list_first->prev = head_last; + head_last->next = list_first; +} + +/** + * list_splice_init() - Move list nodes from a list to beginning of another list + * @list: pointer to the head of the list with the node entries + * @head: pointer to the head of the list + * + * All nodes from @list are added to to the beginning of the list of @head. + * It is similar to list_add but for multiple nodes. + * + * The @list head will not end up in an uninitialized state like when using + * list_splice. Instead the @list is initialized again to the an empty + * list/unlinked state. + */ +static __inline__ void list_splice_init(struct list_head *list, + struct list_head *head) +{ + list_splice(list, head); + INIT_LIST_HEAD(list); +} + +/** + * list_splice_tail_init() - Move list nodes from a list to end of another list + * @list: pointer to the head of the list with the node entries + * @head: pointer to the head of the list + * + * All nodes from @list are added to to the end of the list of @head. + * It is similar to list_add_tail but for multiple nodes. + * + * The @list head will not end up in an uninitialized state like when using + * list_splice. Instead the @list is initialized again to the an empty + * list/unlinked state. + */ +static __inline__ void list_splice_tail_init(struct list_head *list, + struct list_head *head) +{ + list_splice_tail(list, head); + INIT_LIST_HEAD(list); +} + +/** + * list_cut_position() - Move beginning of a list to another list + * @head_to: pointer to the head of the list which receives nodes + * @head_from: pointer to the head of the list + * @node: pointer to the node in which defines the cutting point + * + * All entries from the beginning of the list @head_from to (including) the + * @node is moved to @head_from. + * + * @head_to is replaced when @head_from is not empty. @node must be a real + * list node from @head_from or the behavior is undefined. + */ +static __inline__ void list_cut_position(struct list_head *head_to, + struct list_head *head_from, + struct list_head *node) +{ + struct list_head *head_from_first = head_from->next; + + if (list_empty(head_from)) + return; + + if (head_from == node) { + INIT_LIST_HEAD(head_to); + return; + } + + head_from->next = node->next; + head_from->next->prev = head_from; + + head_to->prev = node; + node->next = head_to; + head_to->next = head_from_first; + head_to->next->prev = head_to; +} + +/** + * list_move() - Move a list node to the beginning of the list + * @node: pointer to the node + * @head: pointer to the head of the list + * + * The @node is removed from its old position/node and add to the beginning of + * @head + */ +static __inline__ void list_move(struct list_head *node, struct list_head *head) +{ + list_del(node); + list_add(node, head); +} + +/** + * list_move_tail() - Move a list node to the end of the list + * @node: pointer to the node + * @head: pointer to the head of the list + * + * The @node is removed from its old position/node and add to the end of @head + */ +static __inline__ void list_move_tail(struct list_head *node, + struct list_head *head) +{ + list_del(node); + list_add_tail(node, head); +} + +/** + * list_entry() - Calculate address of entry that contains list node + * @node: pointer to list node + * @type: type of the entry containing the list node + * @member: name of the list_head member variable in struct @type + * + * Return: @type pointer of entry containing node + */ +#define list_entry(node, type, member) container_of(node, type, member) + +/** + * list_first_entry() - get first entry of the list + * @head: pointer to the head of the list + * @type: type of the entry containing the list node + * @member: name of the list_head member variable in struct @type + * + * Return: @type pointer of first entry in list + */ +#define list_first_entry(head, type, member) \ + list_entry((head)->next, type, member) + +/** + * list_last_entry() - get last entry of the list + * @head: pointer to the head of the list + * @type: type of the entry containing the list node + * @member: name of the list_head member variable in struct @type + * + * Return: @type pointer of last entry in list + */ +#define list_last_entry(head, type, member) \ + list_entry((head)->prev, type, member) + +/** + * list_for_each - iterate over list nodes + * @node: list_head pointer used as iterator + * @head: pointer to the head of the list + * + * The nodes and the head of the list must must be kept unmodified while + * iterating through it. Any modifications to the the list will cause undefined + * behavior. + */ +#define list_for_each(node, head) \ + for (node = (head)->next; \ + node != (head); \ + node = node->next) + +/** + * list_for_each_entry_t - iterate over list entries + * @entry: @type pointer used as iterator + * @head: pointer to the head of the list + * @type: type of the entries containing the list nodes + * @member: name of the list_head member variable in struct @type + * + * The nodes and the head of the list must must be kept unmodified while + * iterating through it. Any modifications to the the list will cause undefined + * behavior. + * + * WARNING this functionality is not available in the Linux list implementation + */ +#define list_for_each_entry_t(entry, head, type, member) \ + for (entry = list_entry((head)->next, type, member); \ + &entry->member != (head); \ + entry = list_entry(entry->member.next, type, member)) + +/** + * list_for_each_entry - iterate over list entries + * @entry: pointer used as iterator + * @head: pointer to the head of the list + * @member: name of the list_head member variable in struct type of @entry + * + * The nodes and the head of the list must must be kept unmodified while + * iterating through it. Any modifications to the the list will cause undefined + * behavior. + */ +#define list_for_each_entry(entry, head, member) \ + list_for_each_entry_t(entry, head, __typeof__(*entry), member) + +/** + * list_for_each_safe - iterate over list nodes and allow deletes + * @node: list_head pointer used as iterator + * @safe: list_head pointer used to store info for next entry in list + * @head: pointer to the head of the list + * + * The current node (iterator) is allowed to be removed from the list. Any + * other modifications to the the list will cause undefined behavior. + */ +#define list_for_each_safe(node, safe, head) \ + for (node = (head)->next, safe = node->next; \ + node != (head); \ + node = safe, safe = node->next) + +/** + * list_for_each_entry_safe_t - iterate over list entries and allow deletes + * @entry: @type pointer used as iterator + * @safe: @type pointer used to store info for next entry in list + * @head: pointer to the head of the list + * @type: type of the entries containing the list nodes + * @member: name of the list_head member variable in struct @type + * + * The current node (iterator) is allowed to be removed from the list. Any + * other modifications to the the list will cause undefined behavior. + * + * WARNING this functionality is not available in the Linux list implementation + */ +#define list_for_each_entry_safe_t(entry, safe, head, type, member) \ + for (entry = list_entry((head)->next, type, member), \ + safe = list_entry(entry->member.next, type, member); \ + &entry->member != (head); \ + entry = safe, \ + safe = list_entry(safe->member.next, type, member)) + +/** + * list_for_each_entry_safe - iterate over list entries and allow deletes + * @entry: pointer used as iterator + * @safe: @type pointer used to store info for next entry in list + * @head: pointer to the head of the list + * @member: name of the list_head member variable in struct type of @entry + * + * The current node (iterator) is allowed to be removed from the list. Any + * other modifications to the the list will cause undefined behavior. + */ +#define list_for_each_entry_safe(entry, safe, head, member) \ + list_for_each_entry_safe_t(entry, safe, head, __typeof__(*entry), \ + member) + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/stdarg.h b/tests/invader/include/stdarg.h new file mode 100644 index 0000000000000000000000000000000000000000..7383c4ae3bf7e4134a7d7d0e7cf2328ea363b080 --- /dev/null +++ b/tests/invader/include/stdarg.h @@ -0,0 +1,8 @@ +#pragma once + +typedef __builtin_va_list va_list; + +#define va_start(v,l) __builtin_va_start(v,l) +#define va_end(v) __builtin_va_end(v) +#define va_arg(v,l) __builtin_va_arg(v,l) +#define va_copy(d,s) __builtin_va_copy(d,s) diff --git a/tests/invader/include/stdbits.h b/tests/invader/include/stdbits.h new file mode 100644 index 0000000000000000000000000000000000000000..298538137a5267fb77690bc66496d06380edda22 --- /dev/null +++ b/tests/invader/include/stdbits.h @@ -0,0 +1,63 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#define clz(val) ({ \ + int result; \ + switch(sizeof(val)) { \ + case 1: result = clz8(val); break; \ + case 2: result = clz16(val); break; \ + case 4: result = clz32(val); break; \ + case 8: result = clz64(val); break; \ + } \ + result; \ +}) + +#define ctz(val) ({ \ + int result; \ + switch(sizeof(val)) { \ + case 1: result = ctz8(val); break; \ + case 2: result = ctz16(val); break; \ + case 4: result = ctz32(val); break; \ + case 8: result = ctz64(val); break; \ + } \ + result; \ +}) + +int clz8(int8_t val); +int clz16(int16_t val); +int clz32(int32_t val); +int clz64(int64_t val); + +int ctz8(int8_t val); +int ctz16(int16_t val); +int ctz32(int32_t val); +int ctz64(int64_t val); + +static inline int ispow2(uintptr_t val) +{ + return val && !(val & (val-1)); +} + +static inline uintptr_t roundpow2(uintptr_t val) +{ + val--; + val |= val >> 1; + val |= val >> 2; + val |= val >> 4; + val |= val >> 8; + val |= val >> 16; +#if __SIZE_WIDTH__ == 64 + val |= val >> 32; +#endif + val++; + return val; +} + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/stddef.h b/tests/invader/include/stddef.h new file mode 100644 index 0000000000000000000000000000000000000000..3799f2a275a271442783bbc91e82a0caf24630dd --- /dev/null +++ b/tests/invader/include/stddef.h @@ -0,0 +1,8 @@ +#pragma once + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; +typedef __WCHAR_TYPE__ wchar_t; + +#define NULL 0L +#define offsetof(type, member) __builtin_offsetof(type, member) diff --git a/tests/invader/include/stdint.h b/tests/invader/include/stdint.h new file mode 100644 index 0000000000000000000000000000000000000000..bef5c2f2ed13727244f26a9b883e040a51c01534 --- /dev/null +++ b/tests/invader/include/stdint.h @@ -0,0 +1,52 @@ +#pragma once + +typedef __INT8_TYPE__ int8_t; +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; +typedef __INT64_TYPE__ int64_t; + +typedef __INT_FAST8_TYPE__ int_fast8_t; +typedef __INT_FAST16_TYPE__ int_fast16_t; +typedef __INT_FAST32_TYPE__ int_fast32_t; +typedef __INT_FAST64_TYPE__ int_fast64_t; + +typedef __INT_LEAST16_TYPE__ int_least16_t; +typedef __INT_LEAST32_TYPE__ int_least32_t; +typedef __INT_LEAST64_TYPE__ int_least64_t; +typedef __INT_LEAST8_TYPE__ int_least8_t; + +typedef __INTMAX_TYPE__ intmax_t; +typedef __INTPTR_TYPE__ intptr_t; + +typedef __UINT8_TYPE__ uint8_t; +typedef __UINT16_TYPE__ uint16_t; +typedef __UINT32_TYPE__ uint32_t; +typedef __UINT64_TYPE__ uint64_t; + +typedef __UINT_FAST8_TYPE__ uint_fast8_t; +typedef __UINT_FAST16_TYPE__ uint_fast16_t; +typedef __UINT_FAST32_TYPE__ uint_fast32_t; +typedef __UINT_FAST64_TYPE__ uint_fast64_t; + +typedef __UINT_LEAST8_TYPE__ uint_least8_t; +typedef __UINT_LEAST16_TYPE__ uint_least16_t; +typedef __UINT_LEAST32_TYPE__ uint_least32_t; +typedef __UINT_LEAST64_TYPE__ uint_least64_t; + +typedef __UINTMAX_TYPE__ uintmax_t; +typedef __UINTPTR_TYPE__ uintptr_t; + +#define INT8_MAX __INT8_MAX__ +#define INT16_MAX __INT16_MAX__ +#define INT32_MAX __INT32_MAX__ +#define INT64_MAX __INT64_MAX__ + +#define UINT8_MAX __UINT8_MAX__ +#define UINT16_MAX __UINT16_MAX__ +#define UINT32_MAX __UINT32_MAX__ +#define UINT64_MAX __UINT64_MAX__ + +#define INTPTR_MAX __INTPTR_MAX__ +#define UINTPTR_MAX __UINTPTR_MAX__ +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ diff --git a/tests/invader/include/stdio.h b/tests/invader/include/stdio.h new file mode 100644 index 0000000000000000000000000000000000000000..f97e6e14d655647a57e6bb310b4c9834207e05ef --- /dev/null +++ b/tests/invader/include/stdio.h @@ -0,0 +1,20 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdarg.h> +#include <stddef.h> + +int getchar(void); +int printf(const char *, ...); +int putchar(int); +int puts(const char *); +int snprintf(char *, size_t, const char *, ...); +int vprintf(const char *, va_list); +int vsnprintf(char *, size_t, const char *, va_list); + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/stdlib.h b/tests/invader/include/stdlib.h new file mode 100644 index 0000000000000000000000000000000000000000..7552a1c4cf5440d09c2bbda02506a65e879d4bd6 --- /dev/null +++ b/tests/invader/include/stdlib.h @@ -0,0 +1,17 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stddef.h> + +__attribute__((noreturn)) void abort(void); +__attribute__((noreturn)) void exit(int status); +void* malloc(size_t size); +void free(void* ptr); +void _malloc_addblock(void* addr, size_t size); + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/include/string.h b/tests/invader/include/string.h new file mode 100644 index 0000000000000000000000000000000000000000..6572d23e59556b519a1299091766d44d50737bd7 --- /dev/null +++ b/tests/invader/include/string.h @@ -0,0 +1,21 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stddef.h> + +void *memchr(const void *s, int c, size_t n); +int memcmp(const void *, const void *, size_t); +void *memcpy(void *, const void *, size_t); +void *memset(void *, int, size_t); +char *strchr(const char *s, int c); +int strcmp(const char *, const char *); +size_t strlen(const char *); +int strncmp(const char *, const char *, size_t); +char *strncpy(char *, const char *, size_t); + +#ifdef __cplusplus +} +#endif diff --git a/tests/invader/invader.e b/tests/invader/invader.e new file mode 100644 index 0000000000000000000000000000000000000000..cf0fbb4dac7d64f2df35a81f42ac1bf304b57664 --- /dev/null +++ b/tests/invader/invader.e @@ -0,0 +1,475 @@ +int push_button_get(); +void timer_set_and_wait(int period, int time); +void clear_screen(int color); +int read_pixel(int x, int y, int scale); +void write_pixel_scaling(int pixel, int x, int y, int scale); +void set_bg_color(int color); +void set_fg_color(int color); +void set_display_cur_pos(int x, int y); +void display_string(char *msg); +void set_display_scale(int s); +int scale = 4; +int TIMER_FREQ = 10000000; + +void dirty_exit(){ + int x; + *(&x+1000000000) = 42; +} + +/* Etats */ + +struct etat { + int dx; + int dy; + int etat_suivant; +}; + +struct etat etats[5]; + +void init_etat(int index, int dx, int dy, int next){ + (etats[index]).dx = dx; + (etats[index]).dy = dy; + (etats[index]).etat_suivant = next; +} + +/* Objets */ + +struct Object { + int alive; + int period; + int deadline; + int x; + int y; + int dx; + int dy; + char *pattern; + int color; + int bg[64]; /* background */ + int ax; + int ay; +}; + +struct Object object[7]; + +int NOBJ = 7; + +void init_object(int index, int alive, int period, int deadline, + int x, int y, int dx, int dy, char* pattern, int color){ + (object[index]).alive = alive; + (object[index]).period = period; + (object[index]).deadline = deadline; + (object[index]).x = x; + (object[index]).y = y; + (object[index]).dx = dx; + (object[index]).dy = dy; + (object[index]).pattern = pattern; + (object[index]).color = color; +} + +/* Sprites */ + +char sprite_sship[8]; +char sprite_laser[8]; +char sprite_alien1[8]; +char sprite_alien2[8]; +char sprite_alien3[8]; +char sprite_alien4[8]; +char sprite_alien5[8]; + +void init_sprite(char* t, char a0, char a1, char a2, char a3, + char a4, char a5, char a6, char a7){ + t[0] = a0; + t[1] = a1; + t[2] = a2; + t[3] = a3; + t[4] = a4; + t[5] = a5; + t[6] = a6; + t[7] = a7; +} + +void initialize() +{ + int i; + int dx; + int dy; + clear_screen(0x333333); + i = 0; + while(i < NOBJ) { + if (i == 1) { + /* laser */ + (object[i]).alive = 0; + (object[i]).period = 1; + } else { + /* spaceship or aliens */ + (object[i]).alive = 1; + if (i == 0){ + /* spaceship */ + (object[i]).period = 3; + } + else{ + /* aliens */ + (object[i]).period = 4; + } + } + (object[i]).deadline = 1; + if (i > 1) { + /* aliens */ + if (i > 4) { + /* alien4 or alien5 */ + (object[i]).y = 3; /* 3rd line */ + (object[i]).x = 6 + (i - 4) * 8 ; + } else { + + /* alien1, alien2 or alien3 */ + (object[i]).y = 1; /* 1st line */ + (object[i]).x = 10 + (i - 2) * 8; + } + (object[i]).dx = -1; + (object[i]).dy = 0; + } + (object[i]).ax = -1; + (object[i]).ay = -1; + + /* initialization of object background considering the last one */ + int* ptr = (object[i]).bg; + dx = 0; + while (dx < 8){ + dy = 0; + while (dy < 8){ + int p = read_pixel((((object[i]).x) * 8) + dx, + (((object[i]).y) * 8) + dy, scale); + ptr[dx*8+dy] = p; + dy = dy + 1; + } + dx = dx + 1; + } + i = i + 1; + } +} + +/* function to display the 8 pixels of a pattern line */ +void display_pattern_line(int m, int x, int y, int color) +{ + int i = 0; + + while (i < 8){ + if ((m & 1) == 1){ + write_pixel_scaling(color, x + i, y, scale); + } + m = m / 2; + i = i + 1; + } +} + +/* function to display an 8x8 object considering the last background */ +void display_pattern(char* pattern, int x, int y, int color) +{ + int i = 0; + + while(i < 8){ + display_pattern_line(pattern[i], x, y + i, color); + i = i + 1; + } +} + +/* function to display an 8x8 object (spaceship, laser or alien) */ +void display_sprite(struct Object *object) +{ + int dx; int dy; + if ((object->ax > -1 && object->ay > -1) && + (object->x != object->ax || object->y != object->ay || !(*object).alive)) + { + int* ptr = object->bg; + dx = 0; + while(dx < 8) { + dy = 0; + while(dy < 8) { + write_pixel_scaling(ptr[dx*8+dy], + ((object->ax) *8) + dx, ((object->ay) *8 ) + dy, scale); + if (!object->alive){ + ptr[dx*8 + dy] = read_pixel(((object->x) *8) + dx, + ((object->y) *8) + dy, scale); + } + dy = dy + 1; + } + dx = dx + 1; + } + } + object->ax = object->x; + object->ay = object->y; + if ((*object).alive){ + display_pattern(object->pattern, (object->x) * 8, (object->y) * 8, + object->color); + } +} + +int main(int argc, char* argv) +{ + /* declaration of local variables */ + int i; + int dx; + int dy; + int push_state; + int alien_state; + int edge_reached; + int n_aliens; + struct Object *spaceship; + struct Object *laser; + + init_etat(0, 0, 1, 1); + init_etat(1, 0, 1, 2); + init_etat(2, 1, 0, 3); + init_etat(3, 0, 1, 4); + init_etat(4, -1, 0, 1); + + init_sprite(sprite_sship, 0x00, 0x3c, 0x7e, 0xff, 0xff, 0xe7, 0xc3, 0xc3); + init_sprite(sprite_laser, 231, 231, 255, 255, 126, 60, 24, 24); + init_sprite(sprite_alien1, 0xc3, 0x3c, 0x5a, 0xff, 0xff, 0x81, 0x42, 0x24); + init_sprite(sprite_alien2, 0xc3, 0x3c, 0x5a, 0xff, 0xff, 0xa5, 0xa5, 0x5a); + init_sprite(sprite_alien3, 0x42, 0x24, 0x3c, 0x5a, 0xff, 0xbd, 0x81, 0x42); + init_sprite(sprite_alien4, 0x81, 0x42, 0x3c, 0x5a, 0x5a, 0x3c, 0x42, 0x81); + init_sprite(sprite_alien5, 0x41, 0x22, 0x3e, 0x6b, 0x49, 0x7f, 0x3e, 0x55); + /* + 0x41 .#....#. + 0x22 ..#...#. + 0x3e ..#####. + 0x6b .##.#.## + 0x49 .#..#..# + 0x7f .####### + 0x3e ..#####. + 0x55 .#.#.#.# + */ + init_object(0, 1, 3, 1, 18, 32, 0, 0, sprite_sship, 0x0000FF); /* blue spaceship */ + init_object(1, 0, 1, 1, 18, 0, 0, 0, sprite_laser, 0xffc0cb); /* white laser */ + init_object(2, 1, 4, 1, 10, 1, -1, 0, sprite_alien1, 0x00FF00); /* green alien */ + init_object(3, 1, 4, 1, 18, 1, -1, 0, sprite_alien2, 0xFF0000); /* red alien */ + init_object(4, 1, 4, 1, 26, 1, -1, 0, sprite_alien3, 0xFF00FF); /* magenta alien */ + init_object(5, 1, 4, 1, 14, 3, -1, 0, sprite_alien4, 0xFFFF00); /* yellow alien */ + init_object(6, 1, 4, 1, 22, 3, -1, 0, sprite_alien5, 0x00FFFF); /* cyan alien */ + + /* initialization stage */ + push_state = 0; /* no button pressed at beginning */ + alien_state = 0; /* state of alien in a line */ + edge_reached = 0; /* no edge reached at beginning */ + n_aliens = NOBJ - 2; /* number of displayed aliens */ + spaceship = object; /* spaceship is the first declared object */ + laser = object + 1; /* laser is the second declared object */ + + + + clear_screen(0xcccccc); + set_display_scale(8); + set_bg_color(0xcccccc); + set_fg_color(0x000000); + int started = 0; + while(!started){ + char msg[60]; + i = 0; + msg[i] = 'P'; i = i + 1; + msg[i] = 'o'; i = i + 1; + msg[i] = 'u'; i = i + 1; + msg[i] = 'r'; i = i + 1; + msg[i] = ' '; i = i + 1; + msg[i] = 'c'; i = i + 1; + msg[i] = 'o'; i = i + 1; + msg[i] = 'm'; i = i + 1; + msg[i] = 'm'; i = i + 1; + msg[i] = 'e'; i = i + 1; + msg[i] = 'n'; i = i + 1; + msg[i] = 'c'; i = i + 1; + msg[i] = 'e'; i = i + 1; + msg[i] = 'r'; i = i + 1; + msg[i] = ','; i = i + 1; + msg[i] = ' '; i = i + 1; + msg[i] = 'a'; i = i + 1; + msg[i] = 'p'; i = i + 1; + msg[i] = 'p'; i = i + 1; + msg[i] = 'u'; i = i + 1; + msg[i] = 'y'; i = i + 1; + msg[i] = 'e'; i = i + 1; + msg[i] = 'z'; i = i + 1; + msg[i] = ' '; i = i + 1; + msg[i] = 's'; i = i + 1; + msg[i] = 'u'; i = i + 1; + msg[i] = 'r'; i = i + 1; + msg[i] = ' '; i = i + 1; + msg[i] = 'H'; i = i + 1; + msg[i] = 'A'; i = i + 1; + msg[i] = 'U'; i = i + 1; + msg[i] = 'T'; i = i + 1; + msg[i] = '\n'; i = i + 1; + msg[i] = '\n'; i = i + 1; + msg[i] = 'P'; i = i + 1; + msg[i] = 'o'; i = i + 1; + msg[i] = 'u'; i = i + 1; + msg[i] = 'r'; i = i + 1; + msg[i] = ' '; i = i + 1; + msg[i] = 'q'; i = i + 1; + msg[i] = 'u'; i = i + 1; + msg[i] = 'i'; i = i + 1; + msg[i] = 't'; i = i + 1; + msg[i] = 't'; i = i + 1; + msg[i] = 'e'; i = i + 1; + msg[i] = 'r'; i = i + 1; + msg[i] = ','; i = i + 1; + msg[i] = ' '; i = i + 1; + msg[i] = 'a'; i = i + 1; + msg[i] = 'p'; i = i + 1; + msg[i] = 'p'; i = i + 1; + msg[i] = 'u'; i = i + 1; + msg[i] = 'y'; i = i + 1; + msg[i] = 'e'; i = i + 1; + msg[i] = 'z'; i = i + 1; + msg[i] = ' '; i = i + 1; + msg[i] = 's'; i = i + 1; + msg[i] = 'u'; i = i + 1; + msg[i] = 'r'; i = i + 1; + msg[i] = ' '; i = i + 1; + msg[i] = 'B'; i = i + 1; + msg[i] = 'A'; i = i + 1; + msg[i] = 'S'; i = i + 1; + msg[i] = 0; i = i + 1; + + + set_display_cur_pos(10,10); + display_string(msg); + + push_state = push_button_get(); + if (push_state & 0x4) { + started = 1; + } + if (push_state & 0x8) { + dirty_exit(); + } + } + + clear_screen(0x333333); + + initialize(); + + /* display stage */ + while(1==1) { + edge_reached=0; + + /* decrease deadline of alive objects */ + i = 0; + while (i < NOBJ) { + if ((object[i]).alive == 1){ + (object[i]).deadline = (object[i]).deadline - 1; + } + i = i + 1; + } + + /* display all alive objects */ + i = 0; + while (i < NOBJ) { + if ((object[i]).alive == 1){ + display_sprite(object + i); + } + i = i + 1; + } + + /* determine new positions of all alive objects */ + i = 0; + while(i < NOBJ) { + /* update object state when deadline is reached */ + if ((object[i]).alive == 1 && (object[i]).deadline == 0) { + /* reinitialize the object deadline to period */ + (object[i]).deadline = (object[i]).period; + /* determine new position and manage screen edges */ + (object[i]).x = (object[i]).x + (object[i]).dx; + if ((object[i]).x < 0){ + (object[i]).x = 0; + } + if ((object[i]).x > 59){ + (object[i]).x = 59; + } + (object[i]).y = (object[i]).y + (object[i]).dy; + /* test if an edge of the screen was reached by an alien */ + if (i >= 2 && ((object[i]).x == 0 || (object[i]).x == 59)){ + edge_reached = 1; + } + if (i > 1 && (object[i]).y >= spaceship->y){ + // PERDU + clear_screen(0x0000FF); /* blue screen */ + timer_set_and_wait(TIMER_FREQ, 1000); + dirty_exit(); + } + } + i = i + 1; + } + /* test if alien is hit by an alive laser */ + if (laser->alive) { + i = 2; + while(i < NOBJ) { + if ((object[i]).alive && !((laser->x > (object[i]).x + 1) || (laser->x + 1 < (object[i]).x)) && + (laser->y) == (object[i]).y) { + n_aliens = n_aliens - 1; + (object[i]).alive = 0; + laser->alive = 0; + if (n_aliens == 0) { + /* no more aliens */ + spaceship->alive = 0; + clear_screen(0xFF00); /* yellow screen */ + timer_set_and_wait(TIMER_FREQ, 1000); + push_state = 0; /* no button pressed at beginning */ + alien_state = 0; /* state of alien in a line */ + edge_reached = 0; /* no edge reached at beginning */ + n_aliens = NOBJ - 2; /* number of displayed aliens */ + spaceship = object; /* spaceship is the first declared object */ + laser = object + 1; /* laser is the second declared object */ + initialize(); + } else { + display_sprite(object + i); + display_sprite(laser); + } + } + i = i + 1; + } + } + /* when an alien reaches a screen edge, the group of aliens is moved */ + if (edge_reached) { + i = 2; + while (i < NOBJ) { + (object[i]).dx = (etats[alien_state]).dx; + (object[i]).dy = (etats[alien_state]).dy; + i = i + 1; + } + alien_state = (etats[alien_state]).etat_suivant; + } + /* laser disappears when it reaches the screen top */ + if (laser->alive && laser->y == 0) { + laser->alive = 0; + display_sprite(laser); + } + /* manage push buttons */ + push_state = push_button_get(); + + if ( (spaceship->deadline == 1) + || (n_aliens == 0)) { + spaceship->dx = 0; + if (push_state & 0x1) { // right + spaceship->dx = 1; + } + if (push_state & 0x2){ // left + spaceship->dx = -1; + } + if (push_state & 0x4) { // fire + if (!laser->alive) { + laser->alive = 1; + laser->dx = 0; + laser->dy = -1; + laser->x = spaceship->x; + laser->y = spaceship->y - 1; + laser->deadline = laser->period; + } + } + if (push_state & 0x8) { + dirty_exit(); + } + } + + timer_set_and_wait(TIMER_FREQ, 4); + } +} diff --git a/tests/invader/itoa.c b/tests/invader/itoa.c new file mode 100644 index 0000000000000000000000000000000000000000..e172978434ea4bd52d4138baa98d45495b83273e --- /dev/null +++ b/tests/invader/itoa.c @@ -0,0 +1,34 @@ +#include<stdio.h> + +char * itoa(signed int i, char* buf){ + char *s = buf + 10; + *s = '\0'; + char neg = 0; + if (i < 0) { + neg = 1; + i = - i; + } + if (i == 0){ + *--s = '0'; + return s; + } + while(i > 0){ + + *--s = (i % 10) + '0'; + i = i / 10; + } + if (neg){ + *--s = '-'; + } + return s; +} + +/* int main(){ */ +/* char buf[20] = "abcdefghijklmnopqrst"; */ +/* printf("itoa(-23467) = %s\n", itoa(-23467,buf)); */ +/* printf("itoa(1238) = %s\n", itoa(1238,buf)); */ +/* printf("itoa(0) = %s\n", itoa(0,buf)); */ +/* printf("itoa(-0) = %s\n", itoa(-0,buf)); */ + +/* return 0; */ +/* } */ diff --git a/tests/invader/libfemto.a b/tests/invader/libfemto.a new file mode 100644 index 0000000000000000000000000000000000000000..b444d6e284575d5cd280a9d8048f56eb1e91f985 Binary files /dev/null and b/tests/invader/libfemto.a differ diff --git a/tests/invader/libscreen.c b/tests/invader/libscreen.c new file mode 100644 index 0000000000000000000000000000000000000000..a0defd7b546ad0dd18590d419391e9266a7bbeac --- /dev/null +++ b/tests/invader/libscreen.c @@ -0,0 +1,218 @@ +#include "femto.h" +#include "libscreen.h" +#include "cep_platform.h" + +typedef unsigned int uint; + +volatile uint* IMG = (volatile uint*) 0x80000000; +volatile uint *push = (volatile uint *)0x30000008; +volatile uint* led = (volatile uint *)REG_LEDS_ADDR; +volatile uint *timer = (volatile uint *)CLINT_TIMER; +volatile uint *timer_hi = (volatile uint *)CLINT_TIMER_HI; +volatile uint *timer_lo = (volatile uint *)CLINT_TIMER_LOW; +volatile uint *timer_cmp = (volatile uint *)CLINT_TIMER_CMP; +volatile uint *timer_cmp_hi = (volatile uint *)CLINT_TIMER_CMP_HI; +volatile uint *timer_cmp_lo = (volatile uint *)CLINT_TIMER_CMP_LO; + + + +/* function to get the state of push buttons */ +uint push_button_get(void) +{ + uint v = (*push) >> 16; + //printf("push_button_get: @ %p, v = %x, %x\n", push, *push, v); + return v; +} + + +/* function to set the value displayed on leds */ +void led_set(uint value) +{ + + *led = value; +} + +/* function to set the timer to be reached in period*time/100 in the future */ +void timer_set(uint period, uint time) +{ + uint now = *timer; + *timer_cmp = now + ((uint)period/RATIO * time); +} + +/* function to wait for timer zero value */ +void timer_wait(void) +{ + while(*timer <= *timer_cmp); +} + +void timer_set_and_wait(uint period, uint time) +{ + timer_set(period, time); + timer_wait(); +} + +void draw(uint color, uint x, uint y){ + uint pos = (y * NBCOL + x); + if (pos < 1920 * 1080){ + *(IMG + pos) = color; + } +} + +void clear_screen(uint color){ + for(uint j = 0; j < NBROW; j++){ + for(uint i = 0; i < NBCOL; i++){ + draw(color, i, j); + } + } +} + +void draw_bitmap(char* bitmap){ + + for(uint j = 0; j < 8; j++){ + for(uint i = 0; i < 8; i++){ + uint set = (bitmap[j] & (1 << i)) >> i; + //draw pixel bitmap[j][i] + for(uint jy = 0; jy < display_scale; jy++){ + for(uint ix = 0; ix < display_scale; ix++){ + uint realx = display_cur_x + i * display_scale + ix; + uint realy = display_cur_y + j * display_scale + jy; + /* pruintf("Writing at %d, %d, color = %x\n", realx, realy, color); */ + if(set){ + draw(fgcolor, realx, realy); + } + else{ + draw(bgcolor, realx, realy); + } + } + } + } + } +} + +extern char* itoa(uint, char*); + +void newline(){ + display_cur_x = 0; + display_cur_y += display_scale*10; +} +void tab(){ + display_cur_x += display_scale*8*4; +} + +/* Counts the number of characters of current word. Will be used to break lines, if possible not in the middle of words. */ +uint num_characters_until_white(char* str){ + uint i = 0; + char c; + while(c = *str++){ + if (c == ' ' || c == '\t' || c == '\n'){ + return i; + } + if (c == '.' || c == ','){ + return i + 1; + } + i++; + } + return i; +} + + + +void display_string(char* str){ + while(*str){ + uint n = num_characters_until_white(str) + 1; + // If there's not enough space on current line for whole current word, newline + if (display_cur_x + (n-1) * display_scale * 8 > 1920){ + newline(); + } + for(uint i = 0; i < n; i++){ + char c = str[i]; + if(c == '\n'){ + newline(); + } else if (c == '\t'){ + tab(); + } else { + draw_bitmap(font8x8_basic[c]); + display_cur_x+=display_scale*8; + } + // Still, if the next character wouldn't fit on the screen, break in the middle of the word. + if (display_cur_x + display_scale * 8 > 1920){ + newline(); + } + } + str = str + n; + } +} + +void display_uint(uint i){ + char buf[10], *bu; + bu = itoa(i, buf); + display_string(bu); +} + +void set_display_scale(int s){ + display_scale = s; +} +void set_display_cur_pos(int x, int y){ + display_cur_x = x; + display_cur_y = y; +} + + +void set_fg_color(uint color){ + fgcolor = color; +} +void set_bg_color(uint color){ + bgcolor = color; +} + + + +/* function to read a pixel from a (x,y) position of video framebuffer */ +uint read_pixel(uint x, uint y, uint scale) +{ + // #SCALING + //return IMG[y * DISPLAY_WIDTH + x]; + const uint pos = y * scale * NBCOL + x * scale; + if (pos < 1920*1080) + return IMG[pos]; + return -1; +} + +/* function to write a pixel in a (x,y) position of video framebuffer */ +void write_pixel(uint pixel, uint x, uint y) +{ + const uint pos = y * NBCOL + x; + if (pos < 1920*1080) + IMG[pos] = pixel; +} + +void write_pixel_scaling(uint pixel, uint x, uint y, uint scale) +{ + uint i, j; + for (i = 0; i < scale; ++i) { + for (j = 0; j < scale; ++j) { + const uint real_y = (y * scale + i); + const uint real_x = x * scale + j; + + write_pixel(pixel, real_x, real_y); + } + } + +} + +void show_pos ( int i, int x, int y){ + /* printf("show_pos %d: @ %p, v = %x\n",x, ptr, *(int*)(ptr+20)); */ + /* printf("alive = %x\n", *(int*)(ptr+ 0 )); */ + /* printf("period = %x\n", *(int*)(ptr+ 4 )); */ + /* printf("deadline = %x\n", *(int*)(ptr+ 8 )); */ + /* printf("x = %x\n", *(int*)(ptr+ 12 )); */ + /* printf("y = %x\n", *(int*)(ptr+ 16 )); */ + /* printf("dx = %x\n", *(int*)(ptr+ 20 )); */ + /* printf("dy = %x\n", *(int*)(ptr+ 24 )); */ + /* int i; */ + /* asm("\t mv %0, sp" : "=r"(i)); */ + /* printf("sp = %x\n", i); */ + /* asm("\t mv %0, s0" : "=r"(i)); */ + /* printf("s0 = %x\n", i); */ + printf("i = %d, x = %d; y = %d\n",i, x,y); +} diff --git a/tests/invader/macros.S b/tests/invader/macros.S new file mode 100644 index 0000000000000000000000000000000000000000..d987d0c1ec596dc45e95cbf0e7a9c69d5ff614b9 --- /dev/null +++ b/tests/invader/macros.S @@ -0,0 +1,23 @@ +# See LICENSE for license details. + +.equ REGBYTES, 4 + +.macro lx a, b +lw \a, \b +.endm + +.macro sx a, b +sw \a, \b +.endm + +.macro lxsp a, b +lw \a, ((\b)*REGBYTES)(sp) +.endm + +.macro sxsp a, b +sw \a, ((\b)*REGBYTES)(sp) +.endm + +.macro .ptr a +.4byte \a +.endm diff --git a/tests/invader/setup.c b/tests/invader/setup.c new file mode 100644 index 0000000000000000000000000000000000000000..8a684ad365780ff73c6df52c38cc3c7a1d0c1412 --- /dev/null +++ b/tests/invader/setup.c @@ -0,0 +1,19 @@ +// See LICENSE for license details. + +#include "femto.h" + +auxval_t __auxv[] = { + { UART0_CLOCK_FREQ, 32000000 }, + { UART0_BAUD_RATE, 115200 }, + { SIFIVE_UART0_CTRL_ADDR, 0x10013000 }, + { SIFIVE_TEST_CTRL_ADDR, 0x100000 }, + { 0, 0 } +}; + +void arch_setup() +{ +#if defined(ENV_QEMU) + register_console(&console_sifive_uart); + register_poweroff(&poweroff_sifive_test); +#endif +} diff --git a/tests/ptr/ptr.e b/tests/ptr/ptr.e new file mode 100644 index 0000000000000000000000000000000000000000..d998f2871a0b2a67b2a233db00b3b90714ac72f1 --- /dev/null +++ b/tests/ptr/ptr.e @@ -0,0 +1,8 @@ +void f(int* z, int x, int y){ + *z = x + y; +} +int main(int x, int y){ + int z = 3; + f(&z, x, y); + return z; +} diff --git a/tests/ptr/ptr.e.expect_14_12_3_8_12 b/tests/ptr/ptr.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..91317f7cd220f36d0146c3982acb44967db89411 --- /dev/null +++ b/tests/ptr/ptr.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 26} \ No newline at end of file diff --git a/tests/ptr/ptr.e.expect_1_2_3 b/tests/ptr/ptr.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/ptr/ptr.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/ptr/ptr.e.expect_lexer b/tests/ptr/ptr.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..dc2a41e1acd3bd5b76610234d3fd8e1f6f0075de --- /dev/null +++ b/tests/ptr/ptr.e.expect_lexer @@ -0,0 +1,52 @@ +SYM_VOID +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(z) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_ASTERISK +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_AMPERSAND +SYM_IDENTIFIER(z) +SYM_COMMA +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(z) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/ptr/ptr2.e b/tests/ptr/ptr2.e new file mode 100644 index 0000000000000000000000000000000000000000..dd2921eb38b3045cc67a0843803083e3235fa224 --- /dev/null +++ b/tests/ptr/ptr2.e @@ -0,0 +1,7 @@ +int main(){ + int x = 0; + int *y = &x; + int** z = &y; + **z = 3; + return x; +} diff --git a/tests/ptr/ptr2.e.expect_14_12_3_8_12 b/tests/ptr/ptr2.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/ptr/ptr2.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/ptr/ptr2.e.expect_1_2_3 b/tests/ptr/ptr2.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/ptr/ptr2.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/ptr/ptr2.e.expect_lexer b/tests/ptr/ptr2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..a68606b7e6ff2661e6d94161bd83fd92ef74d545 --- /dev/null +++ b/tests/ptr/ptr2.e.expect_lexer @@ -0,0 +1,36 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_AMPERSAND +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_ASTERISK +SYM_ASTERISK +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_AMPERSAND +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_ASTERISK +SYM_ASTERISK +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/ptr/weird-ptr.e b/tests/ptr/weird-ptr.e new file mode 100644 index 0000000000000000000000000000000000000000..c6381bd7b5485fbbb7e542d43ed2fa850b532b23 --- /dev/null +++ b/tests/ptr/weird-ptr.e @@ -0,0 +1,11 @@ +int ignore(int * x){ + return 0; +} +int main(){ + int x = 0; + int y = 0; + ignore(&x); // force x on the stack + int* p = &y - 1; + *p = 3; + return x; +} diff --git a/tests/ptr/weird-ptr.e.expect_14_12_3_8_12 b/tests/ptr/weird-ptr.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/ptr/weird-ptr.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/ptr/weird-ptr.e.expect_1_2_3 b/tests/ptr/weird-ptr.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/ptr/weird-ptr.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/ptr/weird-ptr.e.expect_lexer b/tests/ptr/weird-ptr.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..4862f4dd9c13bc662077b45b4963c847399f9d90 --- /dev/null +++ b/tests/ptr/weird-ptr.e.expect_lexer @@ -0,0 +1,52 @@ +SYM_INT +SYM_IDENTIFIER(ignore) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_IDENTIFIER(ignore) +SYM_LPARENTHESIS +SYM_AMPERSAND +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(p) +SYM_ASSIGN +SYM_AMPERSAND +SYM_IDENTIFIER(y) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_ASTERISK +SYM_IDENTIFIER(p) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/structs/point.e b/tests/structs/point.e new file mode 100644 index 0000000000000000000000000000000000000000..af07a81a761bee6b52012a6bd49cce46a9fb6576 --- /dev/null +++ b/tests/structs/point.e @@ -0,0 +1,26 @@ +struct point { + int x; + int y; +}; + +int scalar_product(struct point p1, struct point p2){ + return p1.x * p2.x + p1.y * p2.y; +} + +int orthogonal(struct point p1, struct point p2){ + return p1.x * p2.y - p1.y * p2.x; +} + + +int main(){ + struct point p1; + struct point p2; + p1.x = 3; + p1.y = 3; + p2.x = -5; + p2.y = 4; + + print(scalar_product(p1,p2)); + return (orthogonal(p1,p2)); +} + diff --git a/tests/structs/point.e.expect_14_12_3_8_12 b/tests/structs/point.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..2e9bfe9b00974ddaaaf41c927a37b8892553413d --- /dev/null +++ b/tests/structs/point.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "-3\n", "error": null, "retval": 27} \ No newline at end of file diff --git a/tests/structs/point.e.expect_1_2_3 b/tests/structs/point.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..2e9bfe9b00974ddaaaf41c927a37b8892553413d --- /dev/null +++ b/tests/structs/point.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "-3\n", "error": null, "retval": 27} \ No newline at end of file diff --git a/tests/structs/point.e.expect_lexer b/tests/structs/point.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..62903ca1a3fe44f477850dbf377c06897158bf1f --- /dev/null +++ b/tests/structs/point.e.expect_lexer @@ -0,0 +1,131 @@ +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(scalar_product) +SYM_LPARENTHESIS +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p1) +SYM_COMMA +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASTERISK +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASTERISK +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(orthogonal) +SYM_LPARENTHESIS +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p1) +SYM_COMMA +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASTERISK +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_MINUS +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASTERISK +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p1) +SYM_SEMICOLON +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p2) +SYM_SEMICOLON +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_MINUS +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(4) +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(scalar_product) +SYM_LPARENTHESIS +SYM_IDENTIFIER(p1) +SYM_COMMA +SYM_IDENTIFIER(p2) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(orthogonal) +SYM_LPARENTHESIS +SYM_IDENTIFIER(p1) +SYM_COMMA +SYM_IDENTIFIER(p2) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/structs/struct.e b/tests/structs/struct.e new file mode 100644 index 0000000000000000000000000000000000000000..1a6c1b9aa3147f57e6413afb9ddc2aa0b3a961cc --- /dev/null +++ b/tests/structs/struct.e @@ -0,0 +1,11 @@ +struct mastruct { + int x; + int y; +}; + +int main(){ + struct mastruct S; + S.x = 12; + S.y = 3; + return (S.x + S.y); +} diff --git a/tests/structs/struct.e.expect_14_12_3_8_12 b/tests/structs/struct.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..f027ba59b2dfd707cb7cb2669cdd6f2d58f96637 --- /dev/null +++ b/tests/structs/struct.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 15} \ No newline at end of file diff --git a/tests/structs/struct.e.expect_1_2_3 b/tests/structs/struct.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..f027ba59b2dfd707cb7cb2669cdd6f2d58f96637 --- /dev/null +++ b/tests/structs/struct.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 15} \ No newline at end of file diff --git a/tests/structs/struct.e.expect_lexer b/tests/structs/struct.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..4a97a5c738b64559c9cff1565da33518f0138bea --- /dev/null +++ b/tests/structs/struct.e.expect_lexer @@ -0,0 +1,45 @@ +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_IDENTIFIER(S) +SYM_SEMICOLON +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/structs/struct2.e b/tests/structs/struct2.e new file mode 100644 index 0000000000000000000000000000000000000000..e1ae73543d9b7632f87fc0de3eb26cfbb38f39d5 --- /dev/null +++ b/tests/structs/struct2.e @@ -0,0 +1,14 @@ +struct mastruct { + int x; + int y; +}; + +int main(){ + struct mastruct S; + struct mastruct T; + S.x = 12; + S.y = 3; + T.x = 14; + T.y = 15; + return (S.x + S.y); +} diff --git a/tests/structs/struct2.e.expect_14_12_3_8_12 b/tests/structs/struct2.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..f027ba59b2dfd707cb7cb2669cdd6f2d58f96637 --- /dev/null +++ b/tests/structs/struct2.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 15} \ No newline at end of file diff --git a/tests/structs/struct2.e.expect_1_2_3 b/tests/structs/struct2.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..f027ba59b2dfd707cb7cb2669cdd6f2d58f96637 --- /dev/null +++ b/tests/structs/struct2.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 15} \ No newline at end of file diff --git a/tests/structs/struct2.e.expect_lexer b/tests/structs/struct2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..09bd6dbdfd4d99d34c4ee41db289a258e15b9e04 --- /dev/null +++ b/tests/structs/struct2.e.expect_lexer @@ -0,0 +1,61 @@ +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_IDENTIFIER(S) +SYM_SEMICOLON +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_IDENTIFIER(T) +SYM_SEMICOLON +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(T) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(14) +SYM_SEMICOLON +SYM_IDENTIFIER(T) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(15) +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/structs/structtab.e b/tests/structs/structtab.e new file mode 100644 index 0000000000000000000000000000000000000000..f28c3d354c19b88c5063634ef470148f7bf18852 --- /dev/null +++ b/tests/structs/structtab.e @@ -0,0 +1,10 @@ +struct S { + int t[4]; +}; + +int main(){ + struct S s; + (s.t)[0] = 1; + print_int((s.t)[0]); + return (s.t)[0]; +} diff --git a/tests/structs/structtab.e.expect_14_12_3_8_12 b/tests/structs/structtab.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..8858d4cccf47c58c61f15b14873ea04ff1793568 --- /dev/null +++ b/tests/structs/structtab.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "1", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/structs/structtab.e.expect_1_2_3 b/tests/structs/structtab.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..8858d4cccf47c58c61f15b14873ea04ff1793568 --- /dev/null +++ b/tests/structs/structtab.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/structs/structtab.e.expect_lexer b/tests/structs/structtab.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..1566d173fdc41a967b051fd8f02525da716c01e2 --- /dev/null +++ b/tests/structs/structtab.e.expect_lexer @@ -0,0 +1,55 @@ +SYM_STRUCT +SYM_IDENTIFIER(S) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(4) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_STRUCT +SYM_IDENTIFIER(S) +SYM_IDENTIFIER(s) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(s) +SYM_POINT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_IDENTIFIER(print_int) +SYM_LPARENTHESIS +SYM_LPARENTHESIS +SYM_IDENTIFIER(s) +SYM_POINT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(s) +SYM_POINT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/test.py b/tests/test.py new file mode 100755 index 0000000000000000000000000000000000000000..6c0c90d0ba24dde6ce60a71ecb8498b21a164f2d --- /dev/null +++ b/tests/test.py @@ -0,0 +1,439 @@ +#!/usr/bin/python3 +"""Test orchestration for ecomp""" +import argparse +import glob +from threading import Thread +import json +from subprocess import Popen, PIPE +import signal +import sys +import time +import textwrap +import difflib +from typing import List +import datetime + +# The displayer thread shows what commands are still running +class Displayer(Thread): + """A Displayer thread""" + + def __init__(self, threads): + Thread.__init__(self) + self.threads = threads + + def run(self): + width = 120 + l_running = [x for x in self.threads if x.running] + while len(l_running) > 0: + s_running = "{} threads running ".format(len(l_running)) + thrs = str(list(map(lambda x: x.filename, + l_running)))[:(width - len(s_running))] + print("\r{}({}).{}".format( + s_running, thrs, " " * (width - len(thrs) - len(s_running))), + end="") + time.sleep(1) + l_running = [x for x in self.threads if x.running] + print() + + + + +def display_verbatim(body): + "Show verbatim contents" + return '\n'.join([ + '\n'.join( + textwrap.wrap(line, + 90, + break_long_words=False, + replace_whitespace=False)) + for line in body.splitlines() if line.strip() != '' + ]) + + +def make_td(td): + "Create a TD HTML tag" + if isinstance(td, list): + text = td[0] + opts = " ".join(td[1:]) + else: + text = str(td) + opts = "" + + return "<td {}>{}</td>".format(opts, text) + +icon_ok = "<i class='fa fa-check' style='color: green;'></i>" +icon_warn = "<i class='fa fa-exclamation-circle' style='color: orange;'></i>" +icon_ko = "<i class='fa fa-times-circle' style='color:red;'></i>" + +# CommandExecutor run a command [cmd] and operates on file [f] +class CommandExecutor(Thread): + """Command Executor""" + def __init__(self, filename, cmd, args, make_expect, numcols): + Thread.__init__(self) + self.filename = filename + self.cmd = cmd + self.s = "" + self.running = True + self.stdout = "" + self.stderr = "" + self.lastcorrectstep = -1 + self.proc = None + self.args = args + self.make_expect = make_expect + self.numcols = numcols + + # run cmd and get stdout and stderr in dict + def run_capture_output_interruptible(self, cmd): + self.proc = Popen(cmd, stdout=PIPE, stderr=PIPE) + try: + self.stdout, self.stderr = self.proc.communicate() + self.proc.poll() + self.stdout = self.stdout.decode('utf8') + self.stderr = self.stderr.decode('utf8') + except: + self.stdout = (b"[]").decode('utf8') + self.stderr = "".decode('utf8') + + def stop(self): + """Stop the thread""" + if self.proc: + self.proc.kill() + + def get_test_results(self, json_file_name): + "Get test results, handle errors" + try: + with open(json_file_name, 'r') as jsonfile: + try: + return json.load(jsonfile) + except: + return [{ + 'retval': -1, + 'output': display_verbatim(self.stdout), + 'error': display_verbatim(self.stderr) + }] + except: + return [{ + 'retval': -1, + 'output': display_verbatim(self.stdout), + 'error': "No file {} generated...".format(json_file_name) + }] + + @staticmethod + def register_expect(expect_file_name, out, err, ret): + "Creates a .expect file" + with open(expect_file_name, 'w') as expectfile: + json.dump( + { + 'output': out, + 'error': err, + 'retval': ret + }, expectfile) + + @staticmethod + def check_expect(expect_file_name, out, err, ret): + "Checks a result wrt an expect file" + try: + with open(expect_file_name, 'r') as expectfile: + j = json.load(expectfile) + return j['retval'] == ret and \ + j['output'] == out and \ + j['error'] == err + except: + return None + + + def run(self): + """Actually run the test""" + self.run_capture_output_interruptible(self.cmd.split(" ")) + json_file_name = self.filename + ".json" + j = self.get_test_results(json_file_name) + self.s = "" + curcol = 0 + first_runstep = True + for _, r in enumerate(j, start=0): + if "runstep" in r: + expect_file_name = self.filename + ".expect_" + "_".join(self.args) + if first_runstep and self.make_expect: + self.register_expect(expect_file_name, r['output'], r['error'], r['retval']) + first_runstep = False + cls = "good" + test_ok = self.check_expect(expect_file_name, r['output'], r['error'], r['retval']) + if test_ok is None: + cls = "" + else: + cls = "good" if test_ok else "bad" + if cls == "good": + self.lastcorrectstep = curcol + err_str = "Error: <pre>" + r['error'] + "</pre>" if r['error'] is not None else "" + self.s += make_td([ + "{}<div name='{}' style='display:none;'>Ret = {}.<br>Output = <pre>'{}'</pre>{}<br>Time: {:.2f} seconds.</div>" + .format( + icon_ok if cls == 'good' else icon_ko, + self.filename, + r['retval'], + r['output'], + err_str, + r['time']), + "class=\"{}\"".format(cls) + ]) + "\n" + curcol += 1 + elif "compstep" in r: + + compstep_td = "" + err = r['error'] + if err is not None: + compstep_td = """ + <td class="bad" style="text-align: left;" colspan="{}">{}<div name='{}' style='display:none'>{} error:<br><pre>{}</pre></div></td> + """.format(self.numcols - curcol, + icon_ko, + self.filename, + r['compstep'], err) + elif r["compstep"] == "Parsing": + compstep_td = """ + <td class="good">{}</td> + """.format(icon_ok) + elif r["compstep"] == "Lexing": + expect_lex_file_name = self.filename + ".expect_lexer" + out_lex_file_name = self.filename[:-2] + ".lex" + try: + with open(expect_lex_file_name, "r") as expect_lex_file, \ + open(out_lex_file_name, "r") as out_lex_file: + expected_tokens = expect_lex_file.readlines() + out_tokens = out_lex_file.readlines() + diff = difflib.unified_diff( + expected_tokens, + out_tokens, + fromfile=expect_lex_file_name, + tofile=out_lex_file_name) + diff = list(diff) + if diff == []: + compstep_td = "<td class=\"good\">{}</td>".format(icon_ok) + else: + compstep_td = "<td class=\"warn\" style=\"text-align: left;\" >{}<div name='{}'>Lexing not-what-expected:<br><pre>{}</pre></div></td>".format(icon_warn, self.filename, "".join(diff)) + except: + compstep_td = "<td>No .expect_lexer file</td>" + + self.s += compstep_td + "\n" + else: + err = r['error'] + if err is not None: + self.s += """ + <td class="bad" style="text-align: left;" colspan="{}">error:<br><pre>{}</pre></td> + """.format(self.numcols - curcol, err) + "\n" + else: + self.s += """ + <td class="bad" colspan="{}">error:<br><pre>{}</pre></td> + """.format(self.numcols - curcol, r) + "\n" + + self.s = """ +<tr> + <td class="rowname"> + <a href="{}.html">{}</a> + <input class="w3-btn" id='toggle{}' type="button" onclick="toggle('{}')" value="+"/> + </td> + {} +</tr>""".format(self.filename, self.filename, + self.filename, self.filename, self.s) + "\n" + + self.running = False + + +def interrupt_handler(threads): + "Interrupt handler" + def int_handler(_sig, _frame): + "Interrupt handler" + print('You pressed Ctrl+C!') + for thr in threads: + thr.stop() + return int_handler + +def get_args(): + "Get arguments" + parser = argparse.ArgumentParser() + parser.add_argument("-f", + "--file", + help="files to compile", + default=glob.glob("*.e"), + nargs='+') + parser.add_argument("-p", + "--passes", + help="passes to execute", + nargs='+', + default=[ + "e-run", "cfg-run", "cfg-run-after-cp", + "cfg-run-after-dae", "cfg-run-after-ne", "rtl-run", + "linear-run", "linear-run-after-dse", "ltl-run", + "riscv-run" + ]) + parser.add_argument("--args", + help="args for programs", + nargs='+', + default=["14", "12", "3", "8", "12"]) + parser.add_argument("--html", help="Output HTML file", default="results.html") + parser.add_argument("-d", + "--dry-run", + help="Dry-run. Don't actually compile anything", + action="store_true") + parser.add_argument("-v", + "--verbose", + help="Verbosity level", + action="count", + default=0) + parser.add_argument("--make-expect", + help="Make .expect files for each test", + action="store_true") + args, unknown_args = parser.parse_known_args() + return args, unknown_args + +def main(): + "Main function" + args, unknown_args = get_args() + # show options + if args.verbose >= 1: + print("args.file=" + str(args.file)) + print("args.passes=" + str(args.passes)) + print("args.args=" + str(args.args)) + print("args.html=" + str(args.html)) + print("args.dry_run=" + str(args.dry_run)) + print("args.verbose=" + str(args.verbose)) + + # construct the set of commands to be launched, one per file + cmds = [] + for fname in args.file: + cmd = "../ecomp -json {f}.json -f {f} {passes} {uargs} -- {args}" + cmd = cmd.format(passes=" ".join(map(lambda s: "-" + s, args.passes)), + uargs=" ".join(unknown_args), + args=" ".join(args.args), + f=fname) + cmds.append((fname, cmd)) + + # dyr_run : simply show the commands but don't execute them + if args.dry_run: + for (_, cmd) in cmds: + print(cmd) + sys.exit() + + # The list of threads that will be launched + threads: List[Thread] = [] + + + + signal.signal(signal.SIGINT, interrupt_handler(threads)) + + for (fname, cmd) in cmds: + exec_thread = CommandExecutor(fname, cmd, + args.args, args.make_expect, + # 1 colonne pour le lexer + # 1 colonne pour le parser + len(args.passes) + 2) + threads.append(exec_thread) + exec_thread.start() + + print("Before launching displayer: {} threads".format(len(threads))) + + disp_thread = Displayer(list(threads)) + disp_thread.start() + + for thr in threads: + thr.join() + + disp_thread.join() + print("After displayer: {} threads".format(len(threads))) + print("All threads terminated!") + + res_html = open(args.html, "w") + res_html.write(""" + <html> + <head> + <link rel="stylesheet" href="w3.css"> + <script src="https://kit.fontawesome.com/1f5d81749b.js" crossorigin="anonymous"></script> + <style type="text/css"> + /* + table , table th, table td , table tr{ + border: 1px solid black; + border-collapse: collapse; + text-align: center; + } + .rowname, th { + background-color: #ccc; + } + td { + padding: 0.4em; + } + .bad{ + background-color: #f9d7dc; + } + .good{ + background-color: #c7f0d2; + } + .warn{ + background-color: orange; + } + + fieldset { + display: inline; + margin: 1em; + padding: 1em; + }*/ + </style> + <script type="text/javascript"> + function toggleVisibility(elt){ + if (elt.style.display == 'none') + elt.style.display = 'block'; + else + elt.style.display = 'none'; + } + + function toggle(name){ + var elts = document.getElementsByName(name); + console.log(elts); + for (var k = 0; k < elts.length; k++){ + toggleVisibility(elts[k]); + } + var x = document.getElementById('toggle'+name); + if (x.value == '+') x.value = '-'; + else x.value = '+'; + } + </script> + </head> + <body>""") + + now = datetime.datetime.now() + res_html.write ("{}".format(now)) + + res_html.write(""" + <table class="w3-table w3-striped w3-responsive"> + <tr><th>File</th>""") + for pass_name in ["Lexer","Parser"] + args.passes: + res_html.write("<th style='transform: rotate(180deg); writing-mode: vertical-rl;'>{}</th>\n".format(pass_name)) + res_html.write(""" + </tr> + """) + + print("Before sorting: {} threads".format(len(threads))) + threads = sorted(threads, key=lambda t: (t.lastcorrectstep, t.filename), reverse=False) + print("After sorting: {} threads".format(len(threads))) + for thr in threads: + res_html.write(thr.s) + res_html.write("\n") + res_html.write("</table>\n") + res_html.write("</body>\n") + res_html.write("</html>\n") + res_html.close() + + numtotal = len(threads) + thr_ok = [t for t in threads if t.lastcorrectstep == len(args.passes) - 1] + thr_ko = [t for t in threads if t.lastcorrectstep != len(args.passes) - 1] + + print("{}/{} OK.".format(len(thr_ok), numtotal)) + print("{}/{} KO : {}".format( + len(thr_ko), numtotal, list(map((lambda t: (t.filename, t.lastcorrectstep)), thr_ko)))) + + if args.verbose >= 1: + for thr in thr_ko + (thr_ok if args.verbose >= 2 else []): + print(thr.filename) + print("STDOUT: \n{}".format(thr.stdout)) + print("STDERR: \n{}".format(thr.stderr)) + +if __name__ == "__main__": + main() diff --git a/tests/type_basic/1_or_3a.e b/tests/type_basic/1_or_3a.e new file mode 100644 index 0000000000000000000000000000000000000000..d246ea7824b18d90dd7accf3d94ebebfd7c84eb3 --- /dev/null +++ b/tests/type_basic/1_or_3a.e @@ -0,0 +1,6 @@ +int main(int a){ + if(a > 12){ + a = 1; + } else { a = 3 * a; } + return a; +} diff --git a/tests/type_basic/1_or_3a.e.expect_14_12_3_8_12 b/tests/type_basic/1_or_3a.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/1_or_3a.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/1_or_3a.e.expect_1_2_3 b/tests/type_basic/1_or_3a.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/type_basic/1_or_3a.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/type_basic/1_or_3a.e.expect_lexer b/tests/type_basic/1_or_3a.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..b46c5846f577a7e1c8db1d853ec73e9cdff2652e --- /dev/null +++ b/tests/type_basic/1_or_3a.e.expect_lexer @@ -0,0 +1,33 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_GT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_ASTERISK +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/1_or_4.e b/tests/type_basic/1_or_4.e new file mode 100644 index 0000000000000000000000000000000000000000..de75cc85d1d0455aac906ca713f5404cab594e18 --- /dev/null +++ b/tests/type_basic/1_or_4.e @@ -0,0 +1,17 @@ +int main(int a){ + int x; + if(a < 12){ + if(a < 23){ + x = 1; + } else { + x = 3; + } + } else { + if (a < 12){ + x = 2; + } else { + x = 4; + } + } + return x; +} diff --git a/tests/type_basic/1_or_4.e.expect_14_12_3_8_12 b/tests/type_basic/1_or_4.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..da50e81a3771635762245edfab77e00ab52b5332 --- /dev/null +++ b/tests/type_basic/1_or_4.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 4} \ No newline at end of file diff --git a/tests/type_basic/1_or_4.e.expect_1_2_3 b/tests/type_basic/1_or_4.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/1_or_4.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/1_or_4.e.expect_lexer b/tests/type_basic/1_or_4.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..aee5846525a74030f33c2c56c1d3be004bd7dd10 --- /dev/null +++ b/tests/type_basic/1_or_4.e.expect_lexer @@ -0,0 +1,64 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_LT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_LT +SYM_INTEGER(23) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_LT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(4) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/2xpy.e b/tests/type_basic/2xpy.e new file mode 100644 index 0000000000000000000000000000000000000000..f458d829bdd8b4bef9bc8d6c0fa575034f4c2f21 --- /dev/null +++ b/tests/type_basic/2xpy.e @@ -0,0 +1,3 @@ +int main(int x, int y){ + return 2 * x + y; +} diff --git a/tests/type_basic/2xpy.e.expect_14_12_3_8_12 b/tests/type_basic/2xpy.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..1cd05b5f658b129703da224fe44fb509455cab2f --- /dev/null +++ b/tests/type_basic/2xpy.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 40} \ No newline at end of file diff --git a/tests/type_basic/2xpy.e.expect_1_2_3 b/tests/type_basic/2xpy.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..da50e81a3771635762245edfab77e00ab52b5332 --- /dev/null +++ b/tests/type_basic/2xpy.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 4} \ No newline at end of file diff --git a/tests/type_basic/2xpy.e.expect_lexer b/tests/type_basic/2xpy.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..25d17134ac9ee8b389f959be248e301d98b4f0f2 --- /dev/null +++ b/tests/type_basic/2xpy.e.expect_lexer @@ -0,0 +1,19 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(2) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/35gt12.e b/tests/type_basic/35gt12.e new file mode 100644 index 0000000000000000000000000000000000000000..bcf5a3496f8bb46197bf99ee25179736bf96ba26 --- /dev/null +++ b/tests/type_basic/35gt12.e @@ -0,0 +1,7 @@ +int main(){ + int a = 5 * 7; + if(a > 12){ + a = 1; + } else { a = 3 * a; } + return a; +} diff --git a/tests/type_basic/35gt12.e.expect_14_12_3_8_12 b/tests/type_basic/35gt12.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/35gt12.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/35gt12.e.expect_1_2_3 b/tests/type_basic/35gt12.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/35gt12.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/35gt12.e.expect_lexer b/tests/type_basic/35gt12.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..acf44608757d2148d114610ab6a6dd56f8655706 --- /dev/null +++ b/tests/type_basic/35gt12.e.expect_lexer @@ -0,0 +1,38 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_ASTERISK +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_GT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_ASTERISK +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/a_19.e b/tests/type_basic/a_19.e new file mode 100644 index 0000000000000000000000000000000000000000..6b87138626cc8504050656e21f76f408e6a2c3bd --- /dev/null +++ b/tests/type_basic/a_19.e @@ -0,0 +1,4 @@ +int main(){ + int a = 3; + return (a*5)+4*(3-2); +} diff --git a/tests/type_basic/a_19.e.expect_14_12_3_8_12 b/tests/type_basic/a_19.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..41cdc3312527617536f3eb8dc095834bef47d4ef --- /dev/null +++ b/tests/type_basic/a_19.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 19} \ No newline at end of file diff --git a/tests/type_basic/a_19.e.expect_1_2_3 b/tests/type_basic/a_19.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..41cdc3312527617536f3eb8dc095834bef47d4ef --- /dev/null +++ b/tests/type_basic/a_19.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 19} \ No newline at end of file diff --git a/tests/type_basic/a_19.e.expect_lexer b/tests/type_basic/a_19.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..36458353b3063a9071534ee0ca0c2d0db7a9b38b --- /dev/null +++ b/tests/type_basic/a_19.e.expect_lexer @@ -0,0 +1,27 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_ASTERISK +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_PLUS +SYM_INTEGER(4) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_MINUS +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/a_simple_variable_23.e b/tests/type_basic/a_simple_variable_23.e new file mode 100644 index 0000000000000000000000000000000000000000..3c286ec0eebbc9aaf14e62d6c322b71d22d28a42 --- /dev/null +++ b/tests/type_basic/a_simple_variable_23.e @@ -0,0 +1,4 @@ +int main(){ + int a_simple_variable = 8; + return a_simple_variable + 5 * 3; +} diff --git a/tests/type_basic/a_simple_variable_23.e.expect_14_12_3_8_12 b/tests/type_basic/a_simple_variable_23.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..810d9ab964ab9318fda9fcf35cf83eb5cb49d546 --- /dev/null +++ b/tests/type_basic/a_simple_variable_23.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23} \ No newline at end of file diff --git a/tests/type_basic/a_simple_variable_23.e.expect_1_2_3 b/tests/type_basic/a_simple_variable_23.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..810d9ab964ab9318fda9fcf35cf83eb5cb49d546 --- /dev/null +++ b/tests/type_basic/a_simple_variable_23.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23} \ No newline at end of file diff --git a/tests/type_basic/a_simple_variable_23.e.expect_lexer b/tests/type_basic/a_simple_variable_23.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..4e1e267fb8a0657bd25f5584b0df2f819a2997e9 --- /dev/null +++ b/tests/type_basic/a_simple_variable_23.e.expect_lexer @@ -0,0 +1,19 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(a_simple_variable) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(a_simple_variable) +SYM_PLUS +SYM_INTEGER(5) +SYM_ASTERISK +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/arg-test.e b/tests/type_basic/arg-test.e new file mode 100644 index 0000000000000000000000000000000000000000..84af816686b099bd04554140d10ad133c7045b90 --- /dev/null +++ b/tests/type_basic/arg-test.e @@ -0,0 +1,15 @@ +int main(int n, int m){ + int a = 10; + int b = 20; + int x; + if (3 > n){ + x = a; + } else { + x = b; + } + return x; +} +int f(int x){ + int n = 3; + return 3 * x; +} diff --git a/tests/type_basic/arg-test.e.expect_14_12_3_8_12 b/tests/type_basic/arg-test.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..4de51e4d38522a71a09ab4c411d09d99f1e80932 --- /dev/null +++ b/tests/type_basic/arg-test.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 20} \ No newline at end of file diff --git a/tests/type_basic/arg-test.e.expect_1_2_3 b/tests/type_basic/arg-test.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..b55e8e280c5e45c2be40c1a6b56defcd278107ea --- /dev/null +++ b/tests/type_basic/arg-test.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 10} \ No newline at end of file diff --git a/tests/type_basic/arg-test.e.expect_lexer b/tests/type_basic/arg-test.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..04fa61be5adca8cf1f060cc15a16bb4ca3987a18 --- /dev/null +++ b/tests/type_basic/arg-test.e.expect_lexer @@ -0,0 +1,65 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(m) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_INTEGER(20) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_GT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(3) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/comment++.e b/tests/type_basic/comment++.e new file mode 100644 index 0000000000000000000000000000000000000000..c811dfb3b0168f53a17689f7cd109803131ecf58 --- /dev/null +++ b/tests/type_basic/comment++.e @@ -0,0 +1,5 @@ +/** /**/ +/** Commentaire ! */ +int main(){ + return 23; +} diff --git a/tests/type_basic/comment++.e.expect_14_12_3_8_12 b/tests/type_basic/comment++.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..810d9ab964ab9318fda9fcf35cf83eb5cb49d546 --- /dev/null +++ b/tests/type_basic/comment++.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23} \ No newline at end of file diff --git a/tests/type_basic/comment++.e.expect_1_2_3 b/tests/type_basic/comment++.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..810d9ab964ab9318fda9fcf35cf83eb5cb49d546 --- /dev/null +++ b/tests/type_basic/comment++.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23} \ No newline at end of file diff --git a/tests/type_basic/comment++.e.expect_lexer b/tests/type_basic/comment++.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..da07d6ce028e1997a5c69db45fea29b9395f1b38 --- /dev/null +++ b/tests/type_basic/comment++.e.expect_lexer @@ -0,0 +1,10 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(23) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/comment.e b/tests/type_basic/comment.e new file mode 100644 index 0000000000000000000000000000000000000000..d89e897435cf7f6b90daf574125c172af35d7ca7 --- /dev/null +++ b/tests/type_basic/comment.e @@ -0,0 +1,6 @@ +// Hello, this is a comment +int main(int a){ +/* a multi-line +comment*/ +return a / 2; +} diff --git a/tests/type_basic/comment.e.expect_14_12_3_8_12 b/tests/type_basic/comment.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..fde1f638d743ba12ee106e88aa76743c84363167 --- /dev/null +++ b/tests/type_basic/comment.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 7} \ No newline at end of file diff --git a/tests/type_basic/comment.e.expect_1_2_3 b/tests/type_basic/comment.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/type_basic/comment.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/comment.e.expect_lexer b/tests/type_basic/comment.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..9996cf64841380b219736b95683a44f94d5f4115 --- /dev/null +++ b/tests/type_basic/comment.e.expect_lexer @@ -0,0 +1,14 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_DIV +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/dec_to_0.e b/tests/type_basic/dec_to_0.e new file mode 100644 index 0000000000000000000000000000000000000000..0b5887577c93c5cad9a3dc11df2cf16a836abc4f --- /dev/null +++ b/tests/type_basic/dec_to_0.e @@ -0,0 +1,6 @@ +int main(int n){ + while(n > 0){ + n = n - 1; + } + return n; +} diff --git a/tests/type_basic/dec_to_0.e.expect_14_12_3_8_12 b/tests/type_basic/dec_to_0.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/type_basic/dec_to_0.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/dec_to_0.e.expect_1_2_3 b/tests/type_basic/dec_to_0.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/type_basic/dec_to_0.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/dec_to_0.e.expect_lexer b/tests/type_basic/dec_to_0.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..88da258020055f86891f9f13d539290556a23ae4 --- /dev/null +++ b/tests/type_basic/dec_to_0.e.expect_lexer @@ -0,0 +1,26 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/double.e b/tests/type_basic/double.e new file mode 100644 index 0000000000000000000000000000000000000000..9cec46b83a32f0d05821ada875ddfa8cb9341274 --- /dev/null +++ b/tests/type_basic/double.e @@ -0,0 +1,4 @@ +int main(int n){ + n = n * 2; + return n; +} diff --git a/tests/type_basic/double.e.expect_14_12_3_8_12 b/tests/type_basic/double.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..e9f03bd9e74c0ac09410036fe9b382b569b3aeb0 --- /dev/null +++ b/tests/type_basic/double.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 28} \ No newline at end of file diff --git a/tests/type_basic/double.e.expect_1_2_3 b/tests/type_basic/double.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..df1c5a5ba4e1647c7e3409ee9539a3583afa9bdf --- /dev/null +++ b/tests/type_basic/double.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/type_basic/double.e.expect_lexer b/tests/type_basic/double.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..a237aec21712c83efa0c6f0db7044045e25c08e1 --- /dev/null +++ b/tests/type_basic/double.e.expect_lexer @@ -0,0 +1,18 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_ASTERISK +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/fac.e b/tests/type_basic/fac.e new file mode 100644 index 0000000000000000000000000000000000000000..2b1761eb2bdeaba6b3f42c88aaa4b932bf6653e1 --- /dev/null +++ b/tests/type_basic/fac.e @@ -0,0 +1,12 @@ +int main(int n){ + if(n < 0) { n = 0; } + else { } + + int res = 1; + while(n > 0){ + res = n * res; + n = n - 1; + } + + return res; +} diff --git a/tests/type_basic/fac.e.expect_14_12_3_8_12 b/tests/type_basic/fac.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..fa26d1e83fb28859094630973eb4f1a6280efb04 --- /dev/null +++ b/tests/type_basic/fac.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 87178291200} \ No newline at end of file diff --git a/tests/type_basic/fac.e.expect_1_2_3 b/tests/type_basic/fac.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/fac.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/fac.e.expect_lexer b/tests/type_basic/fac.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..03f393a47bc20f7677720c624cacff6274d2f74a --- /dev/null +++ b/tests/type_basic/fac.e.expect_lexer @@ -0,0 +1,52 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_LT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_ASTERISK +SYM_IDENTIFIER(res) +SYM_SEMICOLON +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(res) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/fibbetter.e b/tests/type_basic/fibbetter.e new file mode 100644 index 0000000000000000000000000000000000000000..b66019c402461f77d1cc118695d58ee830a6947a --- /dev/null +++ b/tests/type_basic/fibbetter.e @@ -0,0 +1,12 @@ +int main(int n){ + int i = 0; // t6 + int j = 1; // t5 + int k = 0; // t4 + while(k < n){ + int tmp = i + j; + i = j; + j = tmp; + k = k + 1; + } + return i; +} diff --git a/tests/type_basic/fibbetter.e.expect_14_12_3_8_12 b/tests/type_basic/fibbetter.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..1fef2374b55b0d9496617cec0a857a07906f799f --- /dev/null +++ b/tests/type_basic/fibbetter.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 377} \ No newline at end of file diff --git a/tests/type_basic/fibbetter.e.expect_1_2_3 b/tests/type_basic/fibbetter.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/fibbetter.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/fibbetter.e.expect_lexer b/tests/type_basic/fibbetter.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..d3a339b017a7571e2941cff48560c6fa4999dd95 --- /dev/null +++ b/tests/type_basic/fibbetter.e.expect_lexer @@ -0,0 +1,56 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(k) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(k) +SYM_LT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(tmp) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_IDENTIFIER(j) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(j) +SYM_SEMICOLON +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_IDENTIFIER(tmp) +SYM_SEMICOLON +SYM_IDENTIFIER(k) +SYM_ASSIGN +SYM_IDENTIFIER(k) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/gcd.e b/tests/type_basic/gcd.e new file mode 100644 index 0000000000000000000000000000000000000000..10c5b2ba50117bba9b7ea097acbd861f4534b348 --- /dev/null +++ b/tests/type_basic/gcd.e @@ -0,0 +1,9 @@ +int main(int a, int b){ + int t; + while(b != 0){ + t = b; + b = a % b; + a = t; + } + return a; +} diff --git a/tests/type_basic/gcd.e.expect_14_12_3_8_12 b/tests/type_basic/gcd.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..df1c5a5ba4e1647c7e3409ee9539a3583afa9bdf --- /dev/null +++ b/tests/type_basic/gcd.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/type_basic/gcd.e.expect_1_2_3 b/tests/type_basic/gcd.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/gcd.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/gcd.e.expect_lexer b/tests/type_basic/gcd.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..202f2a30e64f5a4df75191dbae85d3d36097aeda --- /dev/null +++ b/tests/type_basic/gcd.e.expect_lexer @@ -0,0 +1,40 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_NOTEQ +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(t) +SYM_ASSIGN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_MOD +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/just_a_variable_37.e b/tests/type_basic/just_a_variable_37.e new file mode 100644 index 0000000000000000000000000000000000000000..c7efc4fbe80e5db00893fb9f6ebe9a67a5565551 --- /dev/null +++ b/tests/type_basic/just_a_variable_37.e @@ -0,0 +1,4 @@ +int main(){ + int just_a_variable = 37; + return just_a_variable; +} diff --git a/tests/type_basic/just_a_variable_37.e.expect_14_12_3_8_12 b/tests/type_basic/just_a_variable_37.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..016d6cd30c8fc3fd3f0ef57bfe183aa6023661fa --- /dev/null +++ b/tests/type_basic/just_a_variable_37.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37} \ No newline at end of file diff --git a/tests/type_basic/just_a_variable_37.e.expect_1_2_3 b/tests/type_basic/just_a_variable_37.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..016d6cd30c8fc3fd3f0ef57bfe183aa6023661fa --- /dev/null +++ b/tests/type_basic/just_a_variable_37.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37} \ No newline at end of file diff --git a/tests/type_basic/just_a_variable_37.e.expect_lexer b/tests/type_basic/just_a_variable_37.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..d50f0b7c6060de6d60becb1bce657dafe3a06044 --- /dev/null +++ b/tests/type_basic/just_a_variable_37.e.expect_lexer @@ -0,0 +1,15 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(just_a_variable) +SYM_ASSIGN +SYM_INTEGER(37) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(just_a_variable) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/lexerror.e b/tests/type_basic/lexerror.e new file mode 100644 index 0000000000000000000000000000000000000000..dd56369989be5a3cafb3405f8056f6d6c3df2e37 --- /dev/null +++ b/tests/type_basic/lexerror.e @@ -0,0 +1 @@ +&$ diff --git a/tests/type_basic/loop.e b/tests/type_basic/loop.e new file mode 100644 index 0000000000000000000000000000000000000000..556b0045d0f87480c3e81c70afaa66f841518691 --- /dev/null +++ b/tests/type_basic/loop.e @@ -0,0 +1,15 @@ +int main(){ + int i = 10; + int a = 2; + int res = 0; + while(i > 0){ + int x = a + a; + if(a > 4){ + res = res + x; + } else { + res = res - x; + } + i = i - 1; + } + return res; +} diff --git a/tests/type_basic/loop.e.expect_14_12_3_8_12 b/tests/type_basic/loop.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..919b014322ed6e46ea283467b56f755be461e3c5 --- /dev/null +++ b/tests/type_basic/loop.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": -40} \ No newline at end of file diff --git a/tests/type_basic/loop.e.expect_1_2_3 b/tests/type_basic/loop.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..919b014322ed6e46ea283467b56f755be461e3c5 --- /dev/null +++ b/tests/type_basic/loop.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": -40} \ No newline at end of file diff --git a/tests/type_basic/loop.e.expect_lexer b/tests/type_basic/loop.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..01dbf81dcf082195313b130335cf95fb744f0fd1 --- /dev/null +++ b/tests/type_basic/loop.e.expect_lexer @@ -0,0 +1,69 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_GT +SYM_INTEGER(4) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_MINUS +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(res) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/loop2.e b/tests/type_basic/loop2.e new file mode 100644 index 0000000000000000000000000000000000000000..0f452a33d374d6a1454b38e73fc401681904662d --- /dev/null +++ b/tests/type_basic/loop2.e @@ -0,0 +1,13 @@ +int main(){ + int i = 20; + int a; + while(i > 0){ + if(i < 5){ + a = 5; + } else { + a = 6; + } + i = i - 1; + } + return i; +} diff --git a/tests/type_basic/loop2.e.expect_14_12_3_8_12 b/tests/type_basic/loop2.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/type_basic/loop2.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/loop2.e.expect_1_2_3 b/tests/type_basic/loop2.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/type_basic/loop2.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/loop2.e.expect_lexer b/tests/type_basic/loop2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..7bf5b4022603e05afc0f3beb46ea366266b05530 --- /dev/null +++ b/tests/type_basic/loop2.e.expect_lexer @@ -0,0 +1,51 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(20) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(6) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/loop3.e b/tests/type_basic/loop3.e new file mode 100644 index 0000000000000000000000000000000000000000..25756bb0d45e762968077901fd06e5855dd034c7 --- /dev/null +++ b/tests/type_basic/loop3.e @@ -0,0 +1,14 @@ +int main(){ + int i = 20; + int c = 8; + int a = 5; + int b = 0; + while(i > 0){ + if(i < 5){ + a = 4 + c; + } + b = b + a; + i = i - 1; + } + return b; +} diff --git a/tests/type_basic/loop3.e.expect_14_12_3_8_12 b/tests/type_basic/loop3.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..feb4775c473e7c8f42a997c5dc5a04ce52c73eaa --- /dev/null +++ b/tests/type_basic/loop3.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 128} \ No newline at end of file diff --git a/tests/type_basic/loop3.e.expect_1_2_3 b/tests/type_basic/loop3.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..feb4775c473e7c8f42a997c5dc5a04ce52c73eaa --- /dev/null +++ b/tests/type_basic/loop3.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 128} \ No newline at end of file diff --git a/tests/type_basic/loop3.e.expect_lexer b/tests/type_basic/loop3.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..4be870b60f4cf75881d86ef26285b6e2936c98c9 --- /dev/null +++ b/tests/type_basic/loop3.e.expect_lexer @@ -0,0 +1,64 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(20) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(c) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(4) +SYM_PLUS +SYM_IDENTIFIER(c) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_IDENTIFIER(b) +SYM_PLUS +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/loop4.e b/tests/type_basic/loop4.e new file mode 100644 index 0000000000000000000000000000000000000000..bcfb12e4a43b1746284a3cebad80d035a52a9dc0 --- /dev/null +++ b/tests/type_basic/loop4.e @@ -0,0 +1,20 @@ +int main(){ + int i = 10; + int a = 2; + int res = 0; + while(i > 0){ + int x = a + a; + int y = 1 + x; + if(i > 4){ + res = res + x; + } else { + if (i < 2){ + res = res - y; + } else { + res = res + x - y; + } + } + i = i - 1; + } + return res; +} diff --git a/tests/type_basic/loop4.e.expect_14_12_3_8_12 b/tests/type_basic/loop4.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..4c5f6717cdc873d39fe41829359cd3390a60c009 --- /dev/null +++ b/tests/type_basic/loop4.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 16} \ No newline at end of file diff --git a/tests/type_basic/loop4.e.expect_1_2_3 b/tests/type_basic/loop4.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..4c5f6717cdc873d39fe41829359cd3390a60c009 --- /dev/null +++ b/tests/type_basic/loop4.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 16} \ No newline at end of file diff --git a/tests/type_basic/loop4.e.expect_lexer b/tests/type_basic/loop4.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..d11120d1cf973ee4062cd2c29110c5cd77954fe4 --- /dev/null +++ b/tests/type_basic/loop4.e.expect_lexer @@ -0,0 +1,95 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_GT +SYM_INTEGER(4) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_MINUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(res) +SYM_ASSIGN +SYM_IDENTIFIER(res) +SYM_PLUS +SYM_IDENTIFIER(x) +SYM_MINUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(res) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/lots-of-regs.e b/tests/type_basic/lots-of-regs.e new file mode 100644 index 0000000000000000000000000000000000000000..5180cb59557a105019294d7983a9ab39a867b7c4 --- /dev/null +++ b/tests/type_basic/lots-of-regs.e @@ -0,0 +1,21 @@ +int main(int a, int b){ + int x = a; + int y = b; + int z = a * b; + int t = a + b + z; + int u = z - 3; + int v = x - u; + int w = a * x + z - t; + int i = 35; + int j = i * w; + int k = 8 * t + z / i; + int l = 19 * k; + int m = 12; + int n = 12; + int o = 12; + int p = 12; + int q = 12; + int r = 12; + int s = 12; + return x + y + z + t + u + v + w + i + j + k + l + m + n + o + p + q + r + s; +} diff --git a/tests/type_basic/lots-of-regs.e.expect_14_12_3_8_12 b/tests/type_basic/lots-of-regs.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..36bc30ad8e3a677ef8d97fda646b7d615463399b --- /dev/null +++ b/tests/type_basic/lots-of-regs.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37761} \ No newline at end of file diff --git a/tests/type_basic/lots-of-regs.e.expect_1_2_3 b/tests/type_basic/lots-of-regs.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..0f7c0dd6058a095a430101f739d92a8259ed714c --- /dev/null +++ b/tests/type_basic/lots-of-regs.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 858} \ No newline at end of file diff --git a/tests/type_basic/lots-of-regs.e.expect_lexer b/tests/type_basic/lots-of-regs.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..da9931e65584ce27bb70ec0dc09530dc2fd82622 --- /dev/null +++ b/tests/type_basic/lots-of-regs.e.expect_lexer @@ -0,0 +1,165 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_ASTERISK +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(t) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(b) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(u) +SYM_ASSIGN +SYM_IDENTIFIER(z) +SYM_MINUS +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(v) +SYM_ASSIGN +SYM_IDENTIFIER(x) +SYM_MINUS +SYM_IDENTIFIER(u) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(w) +SYM_ASSIGN +SYM_IDENTIFIER(a) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_MINUS +SYM_IDENTIFIER(t) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(35) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(w) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(k) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_DIV +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(l) +SYM_ASSIGN +SYM_INTEGER(19) +SYM_ASTERISK +SYM_IDENTIFIER(k) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(m) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(o) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(p) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(q) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(r) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(s) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_PLUS +SYM_IDENTIFIER(u) +SYM_PLUS +SYM_IDENTIFIER(v) +SYM_PLUS +SYM_IDENTIFIER(w) +SYM_PLUS +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_IDENTIFIER(j) +SYM_PLUS +SYM_IDENTIFIER(k) +SYM_PLUS +SYM_IDENTIFIER(l) +SYM_PLUS +SYM_IDENTIFIER(m) +SYM_PLUS +SYM_IDENTIFIER(n) +SYM_PLUS +SYM_IDENTIFIER(o) +SYM_PLUS +SYM_IDENTIFIER(p) +SYM_PLUS +SYM_IDENTIFIER(q) +SYM_PLUS +SYM_IDENTIFIER(r) +SYM_PLUS +SYM_IDENTIFIER(s) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/muldivmod.e b/tests/type_basic/muldivmod.e new file mode 100644 index 0000000000000000000000000000000000000000..ae50329cbd7a5cf5abc2a03b006c8ea43259b389 --- /dev/null +++ b/tests/type_basic/muldivmod.e @@ -0,0 +1,5 @@ +int main(){ + int i = 823333; + int j = 7392; + return (i*j/7) % 10; +} diff --git a/tests/type_basic/muldivmod.e.expect_14_12_3_8_12 b/tests/type_basic/muldivmod.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/type_basic/muldivmod.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/type_basic/muldivmod.e.expect_1_2_3 b/tests/type_basic/muldivmod.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/type_basic/muldivmod.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/type_basic/muldivmod.e.expect_lexer b/tests/type_basic/muldivmod.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..59eca122e6aeffbf33b9995b6f97e20495ba3677 --- /dev/null +++ b/tests/type_basic/muldivmod.e.expect_lexer @@ -0,0 +1,28 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(823333) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_INTEGER(7392) +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(j) +SYM_DIV +SYM_INTEGER(7) +SYM_RPARENTHESIS +SYM_MOD +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/mulmulmul.e b/tests/type_basic/mulmulmul.e new file mode 100644 index 0000000000000000000000000000000000000000..35404b0886f5229ae587aaea8c176afb97e4bebc --- /dev/null +++ b/tests/type_basic/mulmulmul.e @@ -0,0 +1,3 @@ +int main(){ + return 1 * (2 * (3 * 4 * (5 * 6) * 7)); +} diff --git a/tests/type_basic/mulmulmul.e.expect_14_12_3_8_12 b/tests/type_basic/mulmulmul.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..6bca38098d934670e1e51e5369182a2a6ec01cee --- /dev/null +++ b/tests/type_basic/mulmulmul.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5040} \ No newline at end of file diff --git a/tests/type_basic/mulmulmul.e.expect_1_2_3 b/tests/type_basic/mulmulmul.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..6bca38098d934670e1e51e5369182a2a6ec01cee --- /dev/null +++ b/tests/type_basic/mulmulmul.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5040} \ No newline at end of file diff --git a/tests/type_basic/mulmulmul.e.expect_lexer b/tests/type_basic/mulmulmul.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..6be78df6756bdc7aea9246114de6a552fc045082 --- /dev/null +++ b/tests/type_basic/mulmulmul.e.expect_lexer @@ -0,0 +1,28 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(1) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_INTEGER(2) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_ASTERISK +SYM_INTEGER(4) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_INTEGER(5) +SYM_ASTERISK +SYM_INTEGER(6) +SYM_RPARENTHESIS +SYM_ASTERISK +SYM_INTEGER(7) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/prime.e b/tests/type_basic/prime.e new file mode 100644 index 0000000000000000000000000000000000000000..03bb55fee3b31c6d0bf06c5301c4c9ca23b7d5d6 --- /dev/null +++ b/tests/type_basic/prime.e @@ -0,0 +1,20 @@ +int main(int n){ + print(n); + while(n%2 == 0){ + print(2); + n = n / 2; + } + int f = 3; + while ( f * f <= n ){ + if ( n % f == 0 ) { + print(f); + n = n / f; + } else { + f = f + 2; + } + } + if ( n != 1 ) { + print(n); + } + return 0; +} diff --git a/tests/type_basic/prime.e.expect_14_12_3_8_12 b/tests/type_basic/prime.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..372d54057e19aff0c25c2287e77ed03cfed94b98 --- /dev/null +++ b/tests/type_basic/prime.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "14\n2\n7\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/prime.e.expect_1_2_3 b/tests/type_basic/prime.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..eb1504dc83ea5564e4adb5e00344555cd86cc389 --- /dev/null +++ b/tests/type_basic/prime.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/prime.e.expect_lexer b/tests/type_basic/prime.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..8308731347edbe05d9c5b046c1ff5051a794e1c4 --- /dev/null +++ b/tests/type_basic/prime.e.expect_lexer @@ -0,0 +1,96 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MOD +SYM_INTEGER(2) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_DIV +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(f) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(f) +SYM_ASTERISK +SYM_IDENTIFIER(f) +SYM_LEQ +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MOD +SYM_IDENTIFIER(f) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(f) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_DIV +SYM_IDENTIFIER(f) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(f) +SYM_ASSIGN +SYM_IDENTIFIER(f) +SYM_PLUS +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_NOTEQ +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/print_int.e b/tests/type_basic/print_int.e new file mode 100644 index 0000000000000000000000000000000000000000..5f1554b844a821b594bac26d833fbb1b3c770a7c --- /dev/null +++ b/tests/type_basic/print_int.e @@ -0,0 +1,4 @@ +int main(){ + print(300); + return 0; + } diff --git a/tests/type_basic/print_int.e.expect_14_12_3_8_12 b/tests/type_basic/print_int.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..5867cb8e972a0f91df6cca403a804ced2b94c8f2 --- /dev/null +++ b/tests/type_basic/print_int.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "300\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/print_int.e.expect_1_2_3 b/tests/type_basic/print_int.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..5867cb8e972a0f91df6cca403a804ced2b94c8f2 --- /dev/null +++ b/tests/type_basic/print_int.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "300\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/print_int.e.expect_lexer b/tests/type_basic/print_int.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..07ba560c9b84beea2675c930df520aab59aa50b2 --- /dev/null +++ b/tests/type_basic/print_int.e.expect_lexer @@ -0,0 +1,15 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_INTEGER(300) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/range_0_10.e b/tests/type_basic/range_0_10.e new file mode 100644 index 0000000000000000000000000000000000000000..1f05dd11423ed65c681da3364447bae18f0f6dc5 --- /dev/null +++ b/tests/type_basic/range_0_10.e @@ -0,0 +1,8 @@ +int main(int n){ + if(n > 10) { n = 10; } + else { + if ( n < 0 ) { n = 0; } + else { } + } + return n; +} diff --git a/tests/type_basic/range_0_10.e.expect_14_12_3_8_12 b/tests/type_basic/range_0_10.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..b55e8e280c5e45c2be40c1a6b56defcd278107ea --- /dev/null +++ b/tests/type_basic/range_0_10.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 10} \ No newline at end of file diff --git a/tests/type_basic/range_0_10.e.expect_1_2_3 b/tests/type_basic/range_0_10.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/range_0_10.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/range_0_10.e.expect_lexer b/tests/type_basic/range_0_10.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..1781dd90f70d777e5fd77f15d97a8c095b96da54 --- /dev/null +++ b/tests/type_basic/range_0_10.e.expect_lexer @@ -0,0 +1,42 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_LT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RBRACE +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/range_10_0_then_dec0.e b/tests/type_basic/range_10_0_then_dec0.e new file mode 100644 index 0000000000000000000000000000000000000000..5c1dba61e3e3b0b7b85b328b7f37cb84697c6f94 --- /dev/null +++ b/tests/type_basic/range_10_0_then_dec0.e @@ -0,0 +1,11 @@ +int main(int n){ + if(n > 10) { n = 10; } + else { + if ( n < 0 ) { n = 0; } + else { } + } + while( n > 0){ + n=n-1; + } + return n; +} diff --git a/tests/type_basic/range_10_0_then_dec0.e.expect_14_12_3_8_12 b/tests/type_basic/range_10_0_then_dec0.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/type_basic/range_10_0_then_dec0.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/range_10_0_then_dec0.e.expect_1_2_3 b/tests/type_basic/range_10_0_then_dec0.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/type_basic/range_10_0_then_dec0.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/range_10_0_then_dec0.e.expect_lexer b/tests/type_basic/range_10_0_then_dec0.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..43125c4ed8cf1afece4ec74b189cf3684162a7ba --- /dev/null +++ b/tests/type_basic/range_10_0_then_dec0.e.expect_lexer @@ -0,0 +1,56 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(10) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_LT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RBRACE +SYM_RBRACE +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/ret0.e b/tests/type_basic/ret0.e new file mode 100644 index 0000000000000000000000000000000000000000..1d20be45d6ab1a490aea9a217f38e6392357ea6e --- /dev/null +++ b/tests/type_basic/ret0.e @@ -0,0 +1,3 @@ +int main(){ +return 0; +} diff --git a/tests/type_basic/ret0.e.expect_14_12_3_8_12 b/tests/type_basic/ret0.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/type_basic/ret0.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/ret0.e.expect_1_2_3 b/tests/type_basic/ret0.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..42f3b7be56a5a32dc517bc2d95cd06ba49b8acae --- /dev/null +++ b/tests/type_basic/ret0.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_basic/ret0.e.expect_lexer b/tests/type_basic/ret0.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..60561b3ded9606e64c2bfc4a6492a3c0c3884e5c --- /dev/null +++ b/tests/type_basic/ret0.e.expect_lexer @@ -0,0 +1,10 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/ret20.e b/tests/type_basic/ret20.e new file mode 100644 index 0000000000000000000000000000000000000000..ae36a900463e6c80e24e5265c650ec94f7d2e5f2 --- /dev/null +++ b/tests/type_basic/ret20.e @@ -0,0 +1,6 @@ +int main(){ + int x = 5; + int y = x * 2; + x = 6 * x; + return x - y; +} diff --git a/tests/type_basic/ret20.e.expect_14_12_3_8_12 b/tests/type_basic/ret20.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..4de51e4d38522a71a09ab4c411d09d99f1e80932 --- /dev/null +++ b/tests/type_basic/ret20.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 20} \ No newline at end of file diff --git a/tests/type_basic/ret20.e.expect_1_2_3 b/tests/type_basic/ret20.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..4de51e4d38522a71a09ab4c411d09d99f1e80932 --- /dev/null +++ b/tests/type_basic/ret20.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 20} \ No newline at end of file diff --git a/tests/type_basic/ret20.e.expect_lexer b/tests/type_basic/ret20.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..d659c80b8cae70054cf88a7329e978a594ccec3c --- /dev/null +++ b/tests/type_basic/ret20.e.expect_lexer @@ -0,0 +1,30 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_IDENTIFIER(x) +SYM_ASTERISK +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(6) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_MINUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/ret21.e b/tests/type_basic/ret21.e new file mode 100644 index 0000000000000000000000000000000000000000..f10a3264bdeb02a72c08b7042fc492a528bb18bb --- /dev/null +++ b/tests/type_basic/ret21.e @@ -0,0 +1,7 @@ +int main(){ + int a = 7; + if(a > 12){ + a = 1; + } else { a = 3 * a; } + return a; +} diff --git a/tests/type_basic/ret21.e.expect_14_12_3_8_12 b/tests/type_basic/ret21.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..43b8874c2b664dea974bd32fb988a477dd4e8308 --- /dev/null +++ b/tests/type_basic/ret21.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 21} \ No newline at end of file diff --git a/tests/type_basic/ret21.e.expect_1_2_3 b/tests/type_basic/ret21.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..43b8874c2b664dea974bd32fb988a477dd4e8308 --- /dev/null +++ b/tests/type_basic/ret21.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 21} \ No newline at end of file diff --git a/tests/type_basic/ret21.e.expect_lexer b/tests/type_basic/ret21.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..aeca8d576c554afbdcf805e10d2f96614c80fcb1 --- /dev/null +++ b/tests/type_basic/ret21.e.expect_lexer @@ -0,0 +1,36 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_GT +SYM_INTEGER(12) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_ASTERISK +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/ret60.e b/tests/type_basic/ret60.e new file mode 100644 index 0000000000000000000000000000000000000000..260814487ee7bb3f5ac64158dacd8d06423dfc54 --- /dev/null +++ b/tests/type_basic/ret60.e @@ -0,0 +1,5 @@ +int main(){ + int x = 3 + 7; + int y = 5 * x; + return x + y; +} diff --git a/tests/type_basic/ret60.e.expect_14_12_3_8_12 b/tests/type_basic/ret60.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..51f9f22bf4016f307a497d3cff177f01769872d5 --- /dev/null +++ b/tests/type_basic/ret60.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 60} \ No newline at end of file diff --git a/tests/type_basic/ret60.e.expect_1_2_3 b/tests/type_basic/ret60.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..51f9f22bf4016f307a497d3cff177f01769872d5 --- /dev/null +++ b/tests/type_basic/ret60.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 60} \ No newline at end of file diff --git a/tests/type_basic/ret60.e.expect_lexer b/tests/type_basic/ret60.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..014cbc89dca3bdfb6cf2d3c10cd93989258f7883 --- /dev/null +++ b/tests/type_basic/ret60.e.expect_lexer @@ -0,0 +1,26 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_PLUS +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/sum_ints_upto_10.e b/tests/type_basic/sum_ints_upto_10.e new file mode 100644 index 0000000000000000000000000000000000000000..80f976013dac52a83db0a3163e2cd422cae5a6c2 --- /dev/null +++ b/tests/type_basic/sum_ints_upto_10.e @@ -0,0 +1,13 @@ +int main(){ + int i = 0; + int x; + while(i < 10){ + if(i == 0){ + x = 1; + } + x = x + i; + i = i + 1; + } + return x; +} + diff --git a/tests/type_basic/sum_ints_upto_10.e.expect_14_12_3_8_12 b/tests/type_basic/sum_ints_upto_10.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..3bb7e49dac8aa0cbc843b6de7e45524882031ee8 --- /dev/null +++ b/tests/type_basic/sum_ints_upto_10.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 46} \ No newline at end of file diff --git a/tests/type_basic/sum_ints_upto_10.e.expect_1_2_3 b/tests/type_basic/sum_ints_upto_10.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..3bb7e49dac8aa0cbc843b6de7e45524882031ee8 --- /dev/null +++ b/tests/type_basic/sum_ints_upto_10.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 46} \ No newline at end of file diff --git a/tests/type_basic/sum_ints_upto_10.e.expect_lexer b/tests/type_basic/sum_ints_upto_10.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..d2420ab9814e532beebe7502cfb8f94591c5be6a --- /dev/null +++ b/tests/type_basic/sum_ints_upto_10.e.expect_lexer @@ -0,0 +1,50 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/sum_ints_upto_n.e b/tests/type_basic/sum_ints_upto_n.e new file mode 100644 index 0000000000000000000000000000000000000000..dd9da5f5099da12b2baf1d2270575f5d20c54873 --- /dev/null +++ b/tests/type_basic/sum_ints_upto_n.e @@ -0,0 +1,8 @@ +int main(int n){ + int x = 0; + while ( n > 0 ){ + x = x + n; + n = n - 1; + } + return x; +} diff --git a/tests/type_basic/sum_ints_upto_n.e.expect_14_12_3_8_12 b/tests/type_basic/sum_ints_upto_n.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..a08d9717d65d4797ad102ce92e8b9149efd0799c --- /dev/null +++ b/tests/type_basic/sum_ints_upto_n.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 105} \ No newline at end of file diff --git a/tests/type_basic/sum_ints_upto_n.e.expect_1_2_3 b/tests/type_basic/sum_ints_upto_n.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/sum_ints_upto_n.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/sum_ints_upto_n.e.expect_lexer b/tests/type_basic/sum_ints_upto_n.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..df81683ba742fbf6723e2424c1325dfbf9e4a86a --- /dev/null +++ b/tests/type_basic/sum_ints_upto_n.e.expect_lexer @@ -0,0 +1,37 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_IDENTIFIER(n) +SYM_ASSIGN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/syntaxerror1.e b/tests/type_basic/syntaxerror1.e new file mode 100644 index 0000000000000000000000000000000000000000..bcda785dacdedfebb5eb5d3079a5761524f01547 --- /dev/null +++ b/tests/type_basic/syntaxerror1.e @@ -0,0 +1,4 @@ +int main(){ + int b = 3 a; + return b; +} diff --git a/tests/type_basic/syntaxerror1.e.expect_lexer b/tests/type_basic/syntaxerror1.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..877f0e9515a81648d79c4f910a3b7e1c40c2d44e --- /dev/null +++ b/tests/type_basic/syntaxerror1.e.expect_lexer @@ -0,0 +1,16 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/syntaxerror2.e b/tests/type_basic/syntaxerror2.e new file mode 100644 index 0000000000000000000000000000000000000000..97ad20e9602d1e29bbfd18a47180ee881ecd413b --- /dev/null +++ b/tests/type_basic/syntaxerror2.e @@ -0,0 +1,4 @@ +int main(){ + int a b = 3; + return c; +} diff --git a/tests/type_basic/syntaxerror2.e.expect_lexer b/tests/type_basic/syntaxerror2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..e8d7ade4d19e0d1e8a2b308c43441339fbacfa0b --- /dev/null +++ b/tests/type_basic/syntaxerror2.e.expect_lexer @@ -0,0 +1,16 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(a) +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(c) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/type_error1.e b/tests/type_basic/type_error1.e new file mode 100644 index 0000000000000000000000000000000000000000..d1a92cf2026ece541730124d1711eac9259c77e6 --- /dev/null +++ b/tests/type_basic/type_error1.e @@ -0,0 +1,6 @@ +void f(int x){ + print(x); +} +int main(){ + return f(3); +} diff --git a/tests/type_basic/type_error1.e.expect_lexer b/tests/type_basic/type_error1.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..acdae70cdbdda5cc06a35883befbbb09eb01a06f --- /dev/null +++ b/tests/type_basic/type_error1.e.expect_lexer @@ -0,0 +1,26 @@ +SYM_VOID +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/type_error2.e b/tests/type_basic/type_error2.e new file mode 100644 index 0000000000000000000000000000000000000000..26ac483ea8804823830ac90c0c3026c5462b2c4a --- /dev/null +++ b/tests/type_basic/type_error2.e @@ -0,0 +1,7 @@ +void f(int x){ + print(x); +} +int main(){ + int x = f(3); + return x; +} diff --git a/tests/type_basic/type_error2.e.expect_lexer b/tests/type_basic/type_error2.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..49a279e52bc3bc921d706d84bf19c8c98d8c7a5e --- /dev/null +++ b/tests/type_basic/type_error2.e.expect_lexer @@ -0,0 +1,31 @@ +SYM_VOID +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/type_error3.e b/tests/type_basic/type_error3.e new file mode 100644 index 0000000000000000000000000000000000000000..666401887b249f452d2f32b3f1bd3b9ce3a941a5 --- /dev/null +++ b/tests/type_basic/type_error3.e @@ -0,0 +1,8 @@ +void f(int x){ + print(x); + return x; +} +int main(){ + int x = f(3); + return x; +} diff --git a/tests/type_basic/type_error3.e.expect_lexer b/tests/type_basic/type_error3.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..239dfef22174a674f3b7402c436a047144dd1272 --- /dev/null +++ b/tests/type_basic/type_error3.e.expect_lexer @@ -0,0 +1,34 @@ +SYM_VOID +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/type_error4.e b/tests/type_basic/type_error4.e new file mode 100644 index 0000000000000000000000000000000000000000..83e427f1426662841c885396d56487db904e2854 --- /dev/null +++ b/tests/type_basic/type_error4.e @@ -0,0 +1,6 @@ +int f(int x, int y){ + return x + y; +} +int main(){ + return f(3,4,5); +} diff --git a/tests/type_basic/type_error4.e.expect_lexer b/tests/type_basic/type_error4.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..98040396526e471ee6b5c6c7a0f32d183fad6996 --- /dev/null +++ b/tests/type_basic/type_error4.e.expect_lexer @@ -0,0 +1,33 @@ +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_COMMA +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/uninitialized.e b/tests/type_basic/uninitialized.e new file mode 100644 index 0000000000000000000000000000000000000000..97f78d3533f9c0a046b2075c103dd430665bc257 --- /dev/null +++ b/tests/type_basic/uninitialized.e @@ -0,0 +1,3 @@ +int main(){ + return a+3; +} diff --git a/tests/type_basic/uninitialized.e.expect_14_12_3_8_12 b/tests/type_basic/uninitialized.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..fdcca39194253835c20ceda8eb3895b4b10e5a5e --- /dev/null +++ b/tests/type_basic/uninitialized.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": "Unknown variable a\n", "retval": null} \ No newline at end of file diff --git a/tests/type_basic/uninitialized.e.expect_1_2_3 b/tests/type_basic/uninitialized.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..fdcca39194253835c20ceda8eb3895b4b10e5a5e --- /dev/null +++ b/tests/type_basic/uninitialized.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": "Unknown variable a\n", "retval": null} \ No newline at end of file diff --git a/tests/type_basic/uninitialized.e.expect_lexer b/tests/type_basic/uninitialized.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..29c2bad43bafe9fa837d2262cefa10370720f1ac --- /dev/null +++ b/tests/type_basic/uninitialized.e.expect_lexer @@ -0,0 +1,12 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/useless-assigns.e b/tests/type_basic/useless-assigns.e new file mode 100644 index 0000000000000000000000000000000000000000..27e8a87973956508797a24dfadca4a4b23abdc86 --- /dev/null +++ b/tests/type_basic/useless-assigns.e @@ -0,0 +1,6 @@ +int main(){ + int x = 8; + int y = 15; + int z = 4 * x + y; + return 1; +} diff --git a/tests/type_basic/useless-assigns.e.expect_14_12_3_8_12 b/tests/type_basic/useless-assigns.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/useless-assigns.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/useless-assigns.e.expect_1_2_3 b/tests/type_basic/useless-assigns.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_basic/useless-assigns.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_basic/useless-assigns.e.expect_lexer b/tests/type_basic/useless-assigns.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..09ba8e3a37a4357b1f4b2736f1a89499cd0a067c --- /dev/null +++ b/tests/type_basic/useless-assigns.e.expect_lexer @@ -0,0 +1,29 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(15) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(z) +SYM_ASSIGN +SYM_INTEGER(4) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/void-var.e b/tests/type_basic/void-var.e new file mode 100644 index 0000000000000000000000000000000000000000..70749176e7b0d90f04b7ff2fdfc05352c3cf702a --- /dev/null +++ b/tests/type_basic/void-var.e @@ -0,0 +1,4 @@ +int main(){ + void x; + return 0; +} diff --git a/tests/type_basic/void-var.e.expect_lexer b/tests/type_basic/void-var.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..fd86695a9cc840c04889925c8482b370e64ba403 --- /dev/null +++ b/tests/type_basic/void-var.e.expect_lexer @@ -0,0 +1,13 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_VOID +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_basic/x-is-what.e b/tests/type_basic/x-is-what.e new file mode 100644 index 0000000000000000000000000000000000000000..7734d64a24a6a06e2aa088a5d4a229930f1d0d6a --- /dev/null +++ b/tests/type_basic/x-is-what.e @@ -0,0 +1,5 @@ +int main(){ + int x = 5; + x = 6; + return x; +} diff --git a/tests/type_basic/x-is-what.e.expect_14_12_3_8_12 b/tests/type_basic/x-is-what.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..0334e56678aa50466b3b300e6bd05aacdc63e69e --- /dev/null +++ b/tests/type_basic/x-is-what.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 6} \ No newline at end of file diff --git a/tests/type_basic/x-is-what.e.expect_1_2_3 b/tests/type_basic/x-is-what.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..0334e56678aa50466b3b300e6bd05aacdc63e69e --- /dev/null +++ b/tests/type_basic/x-is-what.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 6} \ No newline at end of file diff --git a/tests/type_basic/x-is-what.e.expect_lexer b/tests/type_basic/x-is-what.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..6ec0d9ad9c9a7d21d035ba7121a1bc65fd05cc1d --- /dev/null +++ b/tests/type_basic/x-is-what.e.expect_lexer @@ -0,0 +1,19 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(6) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/2apb.e b/tests/type_funcall/2apb.e new file mode 100644 index 0000000000000000000000000000000000000000..47c1bbb7a7a3fddd510c54da981450fc68e6ebb3 --- /dev/null +++ b/tests/type_funcall/2apb.e @@ -0,0 +1,6 @@ +int f(int a, int b){ + return a + 2 * b; +} +int main(){ + return f(8,3); +} diff --git a/tests/type_funcall/2apb.e.expect_14_12_3_8_12 b/tests/type_funcall/2apb.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..e2ce8007751569ecec00e7bfdaad1980596cc9f4 --- /dev/null +++ b/tests/type_funcall/2apb.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 14} \ No newline at end of file diff --git a/tests/type_funcall/2apb.e.expect_1_2_3 b/tests/type_funcall/2apb.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..e2ce8007751569ecec00e7bfdaad1980596cc9f4 --- /dev/null +++ b/tests/type_funcall/2apb.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 14} \ No newline at end of file diff --git a/tests/type_funcall/2apb.e.expect_lexer b/tests/type_funcall/2apb.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..5031f5493923512ebbe0f2256f08fd73bb6bbe12 --- /dev/null +++ b/tests/type_funcall/2apb.e.expect_lexer @@ -0,0 +1,33 @@ +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_INTEGER(2) +SYM_ASTERISK +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(8) +SYM_COMMA +SYM_INTEGER(3) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/5args.e b/tests/type_funcall/5args.e new file mode 100644 index 0000000000000000000000000000000000000000..52154e21d0ea26479f7ed09a08b825d911ca901d --- /dev/null +++ b/tests/type_funcall/5args.e @@ -0,0 +1,6 @@ +int f(int x, int y, int z, int t, int u){ + return x + y + z + t + u; +} +int main(int x, int y){ + return f(x,x,y,y,x*2); +} diff --git a/tests/type_funcall/5args.e.expect_14_12_3_8_12 b/tests/type_funcall/5args.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..e9a8021a60099904d6f192b40d0dda3f401ac4ee --- /dev/null +++ b/tests/type_funcall/5args.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 80} \ No newline at end of file diff --git a/tests/type_funcall/5args.e.expect_1_2_3 b/tests/type_funcall/5args.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /dev/null +++ b/tests/type_funcall/5args.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/type_funcall/5args.e.expect_lexer b/tests/type_funcall/5args.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..e148e3b372537f23a890880ce643a3abf2c895f2 --- /dev/null +++ b/tests/type_funcall/5args.e.expect_lexer @@ -0,0 +1,59 @@ +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(z) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(u) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_PLUS +SYM_IDENTIFIER(u) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_COMMA +SYM_IDENTIFIER(x) +SYM_ASTERISK +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/argswap-simple.e b/tests/type_funcall/argswap-simple.e new file mode 100644 index 0000000000000000000000000000000000000000..7af7b6a7fbca5a4ee0ce29b45204babd5711ae29 --- /dev/null +++ b/tests/type_funcall/argswap-simple.e @@ -0,0 +1,9 @@ +int g(int a,int b){ + return (b - a); +} +int f(int a, int b){ + return g(b, a); +} +int main(int x, int y){ + return f(x, y); +} diff --git a/tests/type_funcall/argswap-simple.e.expect_14_12_3_8_12 b/tests/type_funcall/argswap-simple.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..df1c5a5ba4e1647c7e3409ee9539a3583afa9bdf --- /dev/null +++ b/tests/type_funcall/argswap-simple.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/type_funcall/argswap-simple.e.expect_1_2_3 b/tests/type_funcall/argswap-simple.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..f8d80dd35ec68fe40bb34baeb5311e940a3ebfa9 --- /dev/null +++ b/tests/type_funcall/argswap-simple.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": -1} \ No newline at end of file diff --git a/tests/type_funcall/argswap-simple.e.expect_lexer b/tests/type_funcall/argswap-simple.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..034f6bd4babb9793eafad6000d158efd3ff168dc --- /dev/null +++ b/tests/type_funcall/argswap-simple.e.expect_lexer @@ -0,0 +1,57 @@ +SYM_INT +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_MINUS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/argswap.e b/tests/type_funcall/argswap.e new file mode 100644 index 0000000000000000000000000000000000000000..00b8178cee160e8acd4105f79c02f38a17b2eb45 --- /dev/null +++ b/tests/type_funcall/argswap.e @@ -0,0 +1,13 @@ +int g(int a,int b){ + print(a); + print(b); + return (b - a); +} +int f(int a, int b){ + print(a); + print(b); + return g(b, a); +} +int main(int x, int y){ + return f(x, y); +} diff --git a/tests/type_funcall/argswap.e.expect_14_12_3_8_12 b/tests/type_funcall/argswap.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..38f595af3b9b89775ee2efca6d8e1d1496063200 --- /dev/null +++ b/tests/type_funcall/argswap.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "14\n12\n12\n14\n", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/type_funcall/argswap.e.expect_1_2_3 b/tests/type_funcall/argswap.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..e03517fa033505d7fdef39702e40d4ccf9422e76 --- /dev/null +++ b/tests/type_funcall/argswap.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1\n2\n2\n1\n", "error": null, "retval": -1} \ No newline at end of file diff --git a/tests/type_funcall/argswap.e.expect_lexer b/tests/type_funcall/argswap.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..01324217ebee2ab5dc71be5e6174552a65980a99 --- /dev/null +++ b/tests/type_funcall/argswap.e.expect_lexer @@ -0,0 +1,77 @@ +SYM_INT +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_MINUS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/even_more_args.e b/tests/type_funcall/even_more_args.e new file mode 100644 index 0000000000000000000000000000000000000000..8a9c1fefbac2bff6c16133b4a4af4ac521a040f4 --- /dev/null +++ b/tests/type_funcall/even_more_args.e @@ -0,0 +1,27 @@ +int f(int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + int i, + int j, + int k, + int l, + int m, + int n, + int o, + int p, + int q, + int r, + int s, + int t + ){ + return (k * (a + b * c + d * e * f + g * h * i * j) + (l + m * n) * o + p * q) * (r + s * t); +} + +int main(){ + return f(1,2,3,4,5,6,7,8,9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); +} diff --git a/tests/type_funcall/even_more_args.e.expect_14_12_3_8_12 b/tests/type_funcall/even_more_args.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..1705ac5b63d7e3c645cc187264daf2b0610faa2a --- /dev/null +++ b/tests/type_funcall/even_more_args.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23887562} \ No newline at end of file diff --git a/tests/type_funcall/even_more_args.e.expect_1_2_3 b/tests/type_funcall/even_more_args.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..1705ac5b63d7e3c645cc187264daf2b0610faa2a --- /dev/null +++ b/tests/type_funcall/even_more_args.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23887562} \ No newline at end of file diff --git a/tests/type_funcall/even_more_args.e.expect_lexer b/tests/type_funcall/even_more_args.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..82bef8adbe765f2650c10c2ce1fcc5978b21cda5 --- /dev/null +++ b/tests/type_funcall/even_more_args.e.expect_lexer @@ -0,0 +1,165 @@ +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(c) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(d) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(e) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(f) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(g) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(h) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(j) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(k) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(l) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(m) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(n) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(o) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(p) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(q) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(r) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(s) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(k) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(b) +SYM_ASTERISK +SYM_IDENTIFIER(c) +SYM_PLUS +SYM_IDENTIFIER(d) +SYM_ASTERISK +SYM_IDENTIFIER(e) +SYM_ASTERISK +SYM_IDENTIFIER(f) +SYM_PLUS +SYM_IDENTIFIER(g) +SYM_ASTERISK +SYM_IDENTIFIER(h) +SYM_ASTERISK +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_PLUS +SYM_LPARENTHESIS +SYM_IDENTIFIER(l) +SYM_PLUS +SYM_IDENTIFIER(m) +SYM_ASTERISK +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_ASTERISK +SYM_IDENTIFIER(o) +SYM_PLUS +SYM_IDENTIFIER(p) +SYM_ASTERISK +SYM_IDENTIFIER(q) +SYM_RPARENTHESIS +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_IDENTIFIER(r) +SYM_PLUS +SYM_IDENTIFIER(s) +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(1) +SYM_COMMA +SYM_INTEGER(2) +SYM_COMMA +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_COMMA +SYM_INTEGER(5) +SYM_COMMA +SYM_INTEGER(6) +SYM_COMMA +SYM_INTEGER(7) +SYM_COMMA +SYM_INTEGER(8) +SYM_COMMA +SYM_INTEGER(9) +SYM_COMMA +SYM_INTEGER(10) +SYM_COMMA +SYM_INTEGER(11) +SYM_COMMA +SYM_INTEGER(12) +SYM_COMMA +SYM_INTEGER(13) +SYM_COMMA +SYM_INTEGER(14) +SYM_COMMA +SYM_INTEGER(15) +SYM_COMMA +SYM_INTEGER(16) +SYM_COMMA +SYM_INTEGER(17) +SYM_COMMA +SYM_INTEGER(18) +SYM_COMMA +SYM_INTEGER(19) +SYM_COMMA +SYM_INTEGER(20) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/f+g.e b/tests/type_funcall/f+g.e new file mode 100644 index 0000000000000000000000000000000000000000..8a6f91bb4ccba3f6c8999f8e0e62289660803e10 --- /dev/null +++ b/tests/type_funcall/f+g.e @@ -0,0 +1,10 @@ +int f(int x){ + return x + 2; +} +int g(int y){ + return y * 3; +} +int main(){ + return f(8) + g(5); +} + diff --git a/tests/type_funcall/f+g.e.expect_14_12_3_8_12 b/tests/type_funcall/f+g.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..c24e9b82dd8efe186dc84230615b92ea22fee674 --- /dev/null +++ b/tests/type_funcall/f+g.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 25} \ No newline at end of file diff --git a/tests/type_funcall/f+g.e.expect_1_2_3 b/tests/type_funcall/f+g.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..c24e9b82dd8efe186dc84230615b92ea22fee674 --- /dev/null +++ b/tests/type_funcall/f+g.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 25} \ No newline at end of file diff --git a/tests/type_funcall/f+g.e.expect_lexer b/tests/type_funcall/f+g.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..cdb1ed6f18cdfc244074d35a3ed7ff2a63cdb7cc --- /dev/null +++ b/tests/type_funcall/f+g.e.expect_lexer @@ -0,0 +1,44 @@ +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(y) +SYM_ASTERISK +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(8) +SYM_RPARENTHESIS +SYM_PLUS +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/f_3.e b/tests/type_funcall/f_3.e new file mode 100644 index 0000000000000000000000000000000000000000..8dc310fbe0557f2f5b1dffe5babd7584dca4b17b --- /dev/null +++ b/tests/type_funcall/f_3.e @@ -0,0 +1,6 @@ +int f(){ + return 3; +} +int main(){ + return f(); +} diff --git a/tests/type_funcall/f_3.e.expect_14_12_3_8_12 b/tests/type_funcall/f_3.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/type_funcall/f_3.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/type_funcall/f_3.e.expect_1_2_3 b/tests/type_funcall/f_3.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /dev/null +++ b/tests/type_funcall/f_3.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/type_funcall/f_3.e.expect_lexer b/tests/type_funcall/f_3.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..642da6e4ac2ef8ce7c0ed5c000b3612b040656cd --- /dev/null +++ b/tests/type_funcall/f_3.e.expect_lexer @@ -0,0 +1,21 @@ +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/fib.e b/tests/type_funcall/fib.e new file mode 100644 index 0000000000000000000000000000000000000000..fd6aa2e2f50895c37435bfed0d7f5b836d834b4c --- /dev/null +++ b/tests/type_funcall/fib.e @@ -0,0 +1,11 @@ +int fib(int n){ + if(n > 14){ return -1; } + if(n <= 2){ + return 1; + } else { + return fib(n-1) + fib(n-2); + } +} +int main(int n){ + return fib(n); +} diff --git a/tests/type_funcall/fib.e.expect_14_12_3_8_12 b/tests/type_funcall/fib.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..1fef2374b55b0d9496617cec0a857a07906f799f --- /dev/null +++ b/tests/type_funcall/fib.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 377} \ No newline at end of file diff --git a/tests/type_funcall/fib.e.expect_1_2_3 b/tests/type_funcall/fib.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_funcall/fib.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_funcall/fib.e.expect_lexer b/tests/type_funcall/fib.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..700aacb0e050255cd7873a6660dcfdfeeaea4292 --- /dev/null +++ b/tests/type_funcall/fib.e.expect_lexer @@ -0,0 +1,64 @@ +SYM_INT +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(14) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_LEQ +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_PLUS +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/gcdrec.e b/tests/type_funcall/gcdrec.e new file mode 100644 index 0000000000000000000000000000000000000000..2eef179519dd04a0c2502c554f8f7e47b46506e9 --- /dev/null +++ b/tests/type_funcall/gcdrec.e @@ -0,0 +1,10 @@ +int gcd(int a, int b){ + if(b == 0){ + return a; + } else { + return gcd(b, a % b); + } +} +int main(int a, int b){ + return gcd(a,b); +} diff --git a/tests/type_funcall/gcdrec.e.expect_14_12_3_8_12 b/tests/type_funcall/gcdrec.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..df1c5a5ba4e1647c7e3409ee9539a3583afa9bdf --- /dev/null +++ b/tests/type_funcall/gcdrec.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/type_funcall/gcdrec.e.expect_1_2_3 b/tests/type_funcall/gcdrec.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_funcall/gcdrec.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_funcall/gcdrec.e.expect_lexer b/tests/type_funcall/gcdrec.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..7b5f13aa8d309486b8fff1ec35c276a7ae76a844 --- /dev/null +++ b/tests/type_funcall/gcdrec.e.expect_lexer @@ -0,0 +1,55 @@ +SYM_INT +SYM_IDENTIFIER(gcd) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(gcd) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(a) +SYM_MOD +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(gcd) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/hanoi.e b/tests/type_funcall/hanoi.e new file mode 100644 index 0000000000000000000000000000000000000000..c6edfbc127d58715b354a3913c394e6658f545fb --- /dev/null +++ b/tests/type_funcall/hanoi.e @@ -0,0 +1,12 @@ +int hanoi(int n) +{ + if(n > 0) + { + int x = hanoi(n-1); + return 1 + 2 * x; + } + return 0; +} +int main(int ndisque){ + return hanoi(ndisque); +} diff --git a/tests/type_funcall/hanoi.e.expect_14_12_3_8_12 b/tests/type_funcall/hanoi.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..7cf52b9a4706e4fab8abce3869595d4e4b3ceb36 --- /dev/null +++ b/tests/type_funcall/hanoi.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 16383} \ No newline at end of file diff --git a/tests/type_funcall/hanoi.e.expect_1_2_3 b/tests/type_funcall/hanoi.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /dev/null +++ b/tests/type_funcall/hanoi.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_funcall/hanoi.e.expect_lexer b/tests/type_funcall/hanoi.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..ca101e68e30473c302921ea26662598bc96bacca --- /dev/null +++ b/tests/type_funcall/hanoi.e.expect_lexer @@ -0,0 +1,51 @@ +SYM_INT +SYM_IDENTIFIER(hanoi) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(hanoi) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(1) +SYM_PLUS +SYM_INTEGER(2) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(ndisque) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(hanoi) +SYM_LPARENTHESIS +SYM_IDENTIFIER(ndisque) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/lots_of_args.e b/tests/type_funcall/lots_of_args.e new file mode 100644 index 0000000000000000000000000000000000000000..a03f3412b4a5ac82cdeba3ee2ca7521c96e1a9de --- /dev/null +++ b/tests/type_funcall/lots_of_args.e @@ -0,0 +1,17 @@ +int f(int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + int i, + int j + ){ + return a + b * c + d * e * f + g * h * i * j; +} + +int main(){ + return f(1,2,3,4,5,6,7,8,9,10); +} diff --git a/tests/type_funcall/lots_of_args.e.expect_14_12_3_8_12 b/tests/type_funcall/lots_of_args.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..16d63e1a7da8f2cb086a0d601046966b4a6c4003 --- /dev/null +++ b/tests/type_funcall/lots_of_args.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5167} \ No newline at end of file diff --git a/tests/type_funcall/lots_of_args.e.expect_1_2_3 b/tests/type_funcall/lots_of_args.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..16d63e1a7da8f2cb086a0d601046966b4a6c4003 --- /dev/null +++ b/tests/type_funcall/lots_of_args.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5167} \ No newline at end of file diff --git a/tests/type_funcall/lots_of_args.e.expect_lexer b/tests/type_funcall/lots_of_args.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..e9ed44ec07cdc4ea42cb16109b9a0a1f460d9c53 --- /dev/null +++ b/tests/type_funcall/lots_of_args.e.expect_lexer @@ -0,0 +1,87 @@ +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(c) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(d) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(e) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(f) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(g) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(h) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(b) +SYM_ASTERISK +SYM_IDENTIFIER(c) +SYM_PLUS +SYM_IDENTIFIER(d) +SYM_ASTERISK +SYM_IDENTIFIER(e) +SYM_ASTERISK +SYM_IDENTIFIER(f) +SYM_PLUS +SYM_IDENTIFIER(g) +SYM_ASTERISK +SYM_IDENTIFIER(h) +SYM_ASTERISK +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(j) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(1) +SYM_COMMA +SYM_INTEGER(2) +SYM_COMMA +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_COMMA +SYM_INTEGER(5) +SYM_COMMA +SYM_INTEGER(6) +SYM_COMMA +SYM_INTEGER(7) +SYM_COMMA +SYM_INTEGER(8) +SYM_COMMA +SYM_INTEGER(9) +SYM_COMMA +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/mutrec-hofstadter.e b/tests/type_funcall/mutrec-hofstadter.e new file mode 100644 index 0000000000000000000000000000000000000000..7e476257e5c051a9800fa88ee607a0707e7333b5 --- /dev/null +++ b/tests/type_funcall/mutrec-hofstadter.e @@ -0,0 +1,32 @@ +int m(int n); + +int f(int n) { + if (n >= 0){ + if (n == 0){ + return 1; + } else { + return n - m(f(n-1)); + } + } + return 0; +} + +int m(int n) { + if (n >= 0){ + if (n == 0){ + return 0; + } else { + return n - f(m(n-1)); + } + } + return 0; +} + +int main(int n){ + int i = 0; + while(i < n) { + print(f(i)); + i = i + 1; + } + return 0; +} diff --git a/tests/type_funcall/mutrec-hofstadter.e.expect_14_12_3_8_12 b/tests/type_funcall/mutrec-hofstadter.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..123726a93fd2b95023161ce0d1d095073aeadf46 --- /dev/null +++ b/tests/type_funcall/mutrec-hofstadter.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "1\n1\n2\n2\n3\n3\n4\n5\n5\n6\n6\n7\n8\n8\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_funcall/mutrec-hofstadter.e.expect_1_2_3 b/tests/type_funcall/mutrec-hofstadter.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..eb1504dc83ea5564e4adb5e00344555cd86cc389 --- /dev/null +++ b/tests/type_funcall/mutrec-hofstadter.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_funcall/mutrec-hofstadter.e.expect_lexer b/tests/type_funcall/mutrec-hofstadter.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..1e95da562e92f085846af9d626c98e59cf44b3f9 --- /dev/null +++ b/tests/type_funcall/mutrec-hofstadter.e.expect_lexer @@ -0,0 +1,138 @@ +SYM_INT +SYM_IDENTIFIER(m) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GEQ +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_IDENTIFIER(m) +SYM_LPARENTHESIS +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(m) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GEQ +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(m) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/mutrec.e b/tests/type_funcall/mutrec.e new file mode 100644 index 0000000000000000000000000000000000000000..6e5cb314ea7d128b6b91ae3dd30678c28f262c49 --- /dev/null +++ b/tests/type_funcall/mutrec.e @@ -0,0 +1,26 @@ +int even(int n); + +int odd(int n){ + if (n > 0) { + if (n == 1) { + return 1; + } + return even(n-1); + } + return 0; +} + +int even(int n){ + if (n >= 0) { + if (n == 0) { + return 1; + } + return odd(n-1); + } + return 0; +} + +int main(int n){ + print(even(n)); + return n; +} diff --git a/tests/type_funcall/mutrec.e.expect_14_12_3_8_12 b/tests/type_funcall/mutrec.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..c5e79f77b18cef40e21691ac36c4f958f949baee --- /dev/null +++ b/tests/type_funcall/mutrec.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "1\n", "error": null, "retval": 14} \ No newline at end of file diff --git a/tests/type_funcall/mutrec.e.expect_1_2_3 b/tests/type_funcall/mutrec.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..b856e348e51715384775956823cf979f85860da0 --- /dev/null +++ b/tests/type_funcall/mutrec.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "0\n", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/type_funcall/mutrec.e.expect_lexer b/tests/type_funcall/mutrec.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..c288508bbfeda041b0f25faab0317a5db08fa25e --- /dev/null +++ b/tests/type_funcall/mutrec.e.expect_lexer @@ -0,0 +1,103 @@ +SYM_INT +SYM_IDENTIFIER(even) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(odd) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_EQUALITY +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(even) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(even) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GEQ +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(odd) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(even) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(n) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/type_funcall/print_and_fun.e b/tests/type_funcall/print_and_fun.e new file mode 100644 index 0000000000000000000000000000000000000000..4e58317c10e80a3dfb895ce6354c090fb42b2432 --- /dev/null +++ b/tests/type_funcall/print_and_fun.e @@ -0,0 +1,16 @@ + +int g(int x){ + return x; +} + +int f(int a, int b){ + b = g(8); + print(a); + print(b); + return 0; +} + +int main(){ + f(3,4); + return 0; +} diff --git a/tests/type_funcall/print_and_fun.e.expect_14_12_3_8_12 b/tests/type_funcall/print_and_fun.e.expect_14_12_3_8_12 new file mode 100644 index 0000000000000000000000000000000000000000..7d935d7f4a3630ae710e34b79470872b1124e978 --- /dev/null +++ b/tests/type_funcall/print_and_fun.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "3\n8\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_funcall/print_and_fun.e.expect_1_2_3 b/tests/type_funcall/print_and_fun.e.expect_1_2_3 new file mode 100644 index 0000000000000000000000000000000000000000..7d935d7f4a3630ae710e34b79470872b1124e978 --- /dev/null +++ b/tests/type_funcall/print_and_fun.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "3\n8\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/type_funcall/print_and_fun.e.expect_lexer b/tests/type_funcall/print_and_fun.e.expect_lexer new file mode 100644 index 0000000000000000000000000000000000000000..5c3dd6a863982dab29b0f2874c9d54a9920eb516 --- /dev/null +++ b/tests/type_funcall/print_and_fun.e.expect_lexer @@ -0,0 +1,59 @@ +SYM_INT +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INTEGER(8) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/w3.css b/tests/w3.css new file mode 100644 index 0000000000000000000000000000000000000000..08cad907ac3643704fdd4369b5545b4b821e3760 --- /dev/null +++ b/tests/w3.css @@ -0,0 +1,235 @@ +/* W3.CSS 4.15 December 2020 by Jan Egil and Borge Refsnes */ +html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit} +/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */ +html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0} +article,aside,details,figcaption,figure,footer,header,main,menu,nav,section{display:block}summary{display:list-item} +audio,canvas,progress,video{display:inline-block}progress{vertical-align:baseline} +audio:not([controls]){display:none;height:0}[hidden],template{display:none} +a{background-color:transparent}a:active,a:hover{outline-width:0} +abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted} +b,strong{font-weight:bolder}dfn{font-style:italic}mark{background:#ff0;color:#000} +small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline} +sub{bottom:-0.25em}sup{top:-0.5em}figure{margin:1em 40px}img{border-style:none} +code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}hr{box-sizing:content-box;height:0;overflow:visible} +button,input,select,textarea,optgroup{font:inherit;margin:0}optgroup{font-weight:bold} +button,input{overflow:visible}button,select{text-transform:none} +button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button} +button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0} +button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText} +fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:.35em .625em .75em} +legend{color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto} +[type=checkbox],[type=radio]{padding:0} +[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto} +[type=search]{-webkit-appearance:textfield;outline-offset:-2px} +[type=search]::-webkit-search-decoration{-webkit-appearance:none} +::-webkit-file-upload-button{-webkit-appearance:button;font:inherit} +/* End extract */ +html,body{font-family:Verdana,sans-serif;font-size:15px;line-height:1.5}html{overflow-x:hidden} +h1{font-size:36px}h2{font-size:30px}h3{font-size:24px}h4{font-size:20px}h5{font-size:18px}h6{font-size:16px} +.w3-serif{font-family:serif}.w3-sans-serif{font-family:sans-serif}.w3-cursive{font-family:cursive}.w3-monospace{font-family:monospace} +h1,h2,h3,h4,h5,h6{font-family:"Segoe UI",Arial,sans-serif;font-weight:400;margin:10px 0}.w3-wide{letter-spacing:4px} +hr{border:0;border-top:1px solid #eee;margin:20px 0} +.w3-image{max-width:100%;height:auto}img{vertical-align:middle}a{color:inherit} +.w3-table,.w3-table-all{border-collapse:collapse;border-spacing:0;width:100%;display:table}.w3-table-all{border:1px solid #ccc} +.w3-bordered tr,.w3-table-all tr{border-bottom:1px solid #ddd}.w3-striped tbody tr:nth-child(even){background-color:#f1f1f1} +.w3-table-all tr:nth-child(odd){background-color:#fff}.w3-table-all tr:nth-child(even){background-color:#f1f1f1} +.w3-hoverable tbody tr:hover,.w3-ul.w3-hoverable li:hover{background-color:#ccc}.w3-centered tr th,.w3-centered tr td{text-align:center} +.w3-table td,.w3-table th,.w3-table-all td,.w3-table-all th{padding:8px 8px;display:table-cell;text-align:left;vertical-align:top} +.w3-table th:first-child,.w3-table td:first-child,.w3-table-all th:first-child,.w3-table-all td:first-child{padding-left:16px} +.w3-btn,.w3-button{border:none;display:inline-block;padding:8px 16px;vertical-align:middle;overflow:hidden;text-decoration:none;color:inherit;background-color:inherit;text-align:center;cursor:pointer;white-space:nowrap} +.w3-btn:hover{box-shadow:0 8px 16px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19)} +.w3-btn,.w3-button{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none} +.w3-disabled,.w3-btn:disabled,.w3-button:disabled{cursor:not-allowed;opacity:0.3}.w3-disabled *,:disabled *{pointer-events:none} +.w3-btn.w3-disabled:hover,.w3-btn:disabled:hover{box-shadow:none} +.w3-badge,.w3-tag{background-color:#000;color:#fff;display:inline-block;padding-left:8px;padding-right:8px;text-align:center}.w3-badge{border-radius:50%} +.w3-ul{list-style-type:none;padding:0;margin:0}.w3-ul li{padding:8px 16px;border-bottom:1px solid #ddd}.w3-ul li:last-child{border-bottom:none} +.w3-tooltip,.w3-display-container{position:relative}.w3-tooltip .w3-text{display:none}.w3-tooltip:hover .w3-text{display:inline-block} +.w3-ripple:active{opacity:0.5}.w3-ripple{transition:opacity 0s} +.w3-input{padding:8px;display:block;border:none;border-bottom:1px solid #ccc;width:100%} +.w3-select{padding:9px 0;width:100%;border:none;border-bottom:1px solid #ccc} +.w3-dropdown-click,.w3-dropdown-hover{position:relative;display:inline-block;cursor:pointer} +.w3-dropdown-hover:hover .w3-dropdown-content{display:block} +.w3-dropdown-hover:first-child,.w3-dropdown-click:hover{background-color:#ccc;color:#000} +.w3-dropdown-hover:hover > .w3-button:first-child,.w3-dropdown-click:hover > .w3-button:first-child{background-color:#ccc;color:#000} +.w3-dropdown-content{cursor:auto;color:#000;background-color:#fff;display:none;position:absolute;min-width:160px;margin:0;padding:0;z-index:1} +.w3-check,.w3-radio{width:24px;height:24px;position:relative;top:6px} +.w3-sidebar{height:100%;width:200px;background-color:#fff;position:fixed!important;z-index:1;overflow:auto} +.w3-bar-block .w3-dropdown-hover,.w3-bar-block .w3-dropdown-click{width:100%} +.w3-bar-block .w3-dropdown-hover .w3-dropdown-content,.w3-bar-block .w3-dropdown-click .w3-dropdown-content{min-width:100%} +.w3-bar-block .w3-dropdown-hover .w3-button,.w3-bar-block .w3-dropdown-click .w3-button{width:100%;text-align:left;padding:8px 16px} +.w3-main,#main{transition:margin-left .4s} +.w3-modal{z-index:3;display:none;padding-top:100px;position:fixed;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:rgb(0,0,0);background-color:rgba(0,0,0,0.4)} +.w3-modal-content{margin:auto;background-color:#fff;position:relative;padding:0;outline:0;width:600px} +.w3-bar{width:100%;overflow:hidden}.w3-center .w3-bar{display:inline-block;width:auto} +.w3-bar .w3-bar-item{padding:8px 16px;float:left;width:auto;border:none;display:block;outline:0} +.w3-bar .w3-dropdown-hover,.w3-bar .w3-dropdown-click{position:static;float:left} +.w3-bar .w3-button{white-space:normal} +.w3-bar-block .w3-bar-item{width:100%;display:block;padding:8px 16px;text-align:left;border:none;white-space:normal;float:none;outline:0} +.w3-bar-block.w3-center .w3-bar-item{text-align:center}.w3-block{display:block;width:100%} +.w3-responsive{display:block;overflow-x:auto} +.w3-container:after,.w3-container:before,.w3-panel:after,.w3-panel:before,.w3-row:after,.w3-row:before,.w3-row-padding:after,.w3-row-padding:before, +.w3-cell-row:before,.w3-cell-row:after,.w3-clear:after,.w3-clear:before,.w3-bar:before,.w3-bar:after{content:"";display:table;clear:both} +.w3-col,.w3-half,.w3-third,.w3-twothird,.w3-threequarter,.w3-quarter{float:left;width:100%} +.w3-col.s1{width:8.33333%}.w3-col.s2{width:16.66666%}.w3-col.s3{width:24.99999%}.w3-col.s4{width:33.33333%} +.w3-col.s5{width:41.66666%}.w3-col.s6{width:49.99999%}.w3-col.s7{width:58.33333%}.w3-col.s8{width:66.66666%} +.w3-col.s9{width:74.99999%}.w3-col.s10{width:83.33333%}.w3-col.s11{width:91.66666%}.w3-col.s12{width:99.99999%} +@media (min-width:601px){.w3-col.m1{width:8.33333%}.w3-col.m2{width:16.66666%}.w3-col.m3,.w3-quarter{width:24.99999%}.w3-col.m4,.w3-third{width:33.33333%} +.w3-col.m5{width:41.66666%}.w3-col.m6,.w3-half{width:49.99999%}.w3-col.m7{width:58.33333%}.w3-col.m8,.w3-twothird{width:66.66666%} +.w3-col.m9,.w3-threequarter{width:74.99999%}.w3-col.m10{width:83.33333%}.w3-col.m11{width:91.66666%}.w3-col.m12{width:99.99999%}} +@media (min-width:993px){.w3-col.l1{width:8.33333%}.w3-col.l2{width:16.66666%}.w3-col.l3{width:24.99999%}.w3-col.l4{width:33.33333%} +.w3-col.l5{width:41.66666%}.w3-col.l6{width:49.99999%}.w3-col.l7{width:58.33333%}.w3-col.l8{width:66.66666%} +.w3-col.l9{width:74.99999%}.w3-col.l10{width:83.33333%}.w3-col.l11{width:91.66666%}.w3-col.l12{width:99.99999%}} +.w3-rest{overflow:hidden}.w3-stretch{margin-left:-16px;margin-right:-16px} +.w3-content,.w3-auto{margin-left:auto;margin-right:auto}.w3-content{max-width:980px}.w3-auto{max-width:1140px} +.w3-cell-row{display:table;width:100%}.w3-cell{display:table-cell} +.w3-cell-top{vertical-align:top}.w3-cell-middle{vertical-align:middle}.w3-cell-bottom{vertical-align:bottom} +.w3-hide{display:none!important}.w3-show-block,.w3-show{display:block!important}.w3-show-inline-block{display:inline-block!important} +@media (max-width:1205px){.w3-auto{max-width:95%}} +@media (max-width:600px){.w3-modal-content{margin:0 10px;width:auto!important}.w3-modal{padding-top:30px} +.w3-dropdown-hover.w3-mobile .w3-dropdown-content,.w3-dropdown-click.w3-mobile .w3-dropdown-content{position:relative} +.w3-hide-small{display:none!important}.w3-mobile{display:block;width:100%!important}.w3-bar-item.w3-mobile,.w3-dropdown-hover.w3-mobile,.w3-dropdown-click.w3-mobile{text-align:center} +.w3-dropdown-hover.w3-mobile,.w3-dropdown-hover.w3-mobile .w3-btn,.w3-dropdown-hover.w3-mobile .w3-button,.w3-dropdown-click.w3-mobile,.w3-dropdown-click.w3-mobile .w3-btn,.w3-dropdown-click.w3-mobile .w3-button{width:100%}} +@media (max-width:768px){.w3-modal-content{width:500px}.w3-modal{padding-top:50px}} +@media (min-width:993px){.w3-modal-content{width:900px}.w3-hide-large{display:none!important}.w3-sidebar.w3-collapse{display:block!important}} +@media (max-width:992px) and (min-width:601px){.w3-hide-medium{display:none!important}} +@media (max-width:992px){.w3-sidebar.w3-collapse{display:none}.w3-main{margin-left:0!important;margin-right:0!important}.w3-auto{max-width:100%}} +.w3-top,.w3-bottom{position:fixed;width:100%;z-index:1}.w3-top{top:0}.w3-bottom{bottom:0} +.w3-overlay{position:fixed;display:none;width:100%;height:100%;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,0.5);z-index:2} +.w3-display-topleft{position:absolute;left:0;top:0}.w3-display-topright{position:absolute;right:0;top:0} +.w3-display-bottomleft{position:absolute;left:0;bottom:0}.w3-display-bottomright{position:absolute;right:0;bottom:0} +.w3-display-middle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%)} +.w3-display-left{position:absolute;top:50%;left:0%;transform:translate(0%,-50%);-ms-transform:translate(-0%,-50%)} +.w3-display-right{position:absolute;top:50%;right:0%;transform:translate(0%,-50%);-ms-transform:translate(0%,-50%)} +.w3-display-topmiddle{position:absolute;left:50%;top:0;transform:translate(-50%,0%);-ms-transform:translate(-50%,0%)} +.w3-display-bottommiddle{position:absolute;left:50%;bottom:0;transform:translate(-50%,0%);-ms-transform:translate(-50%,0%)} +.w3-display-container:hover .w3-display-hover{display:block}.w3-display-container:hover span.w3-display-hover{display:inline-block}.w3-display-hover{display:none} +.w3-display-position{position:absolute} +.w3-circle{border-radius:50%} +.w3-round-small{border-radius:2px}.w3-round,.w3-round-medium{border-radius:4px}.w3-round-large{border-radius:8px}.w3-round-xlarge{border-radius:16px}.w3-round-xxlarge{border-radius:32px} +.w3-row-padding,.w3-row-padding>.w3-half,.w3-row-padding>.w3-third,.w3-row-padding>.w3-twothird,.w3-row-padding>.w3-threequarter,.w3-row-padding>.w3-quarter,.w3-row-padding>.w3-col{padding:0 8px} +.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:16px;margin-bottom:16px} +.w3-code,.w3-codespan{font-family:Consolas,"courier new";font-size:16px} +.w3-code{width:auto;background-color:#fff;padding:8px 12px;border-left:4px solid #4CAF50;word-wrap:break-word} +.w3-codespan{color:crimson;background-color:#f1f1f1;padding-left:4px;padding-right:4px;font-size:110%} +.w3-card,.w3-card-2{box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)} +.w3-card-4,.w3-hover-shadow:hover{box-shadow:0 4px 10px 0 rgba(0,0,0,0.2),0 4px 20px 0 rgba(0,0,0,0.19)} +.w3-spin{animation:w3-spin 2s infinite linear}@keyframes w3-spin{0%{transform:rotate(0deg)}100%{transform:rotate(359deg)}} +.w3-animate-fading{animation:fading 10s infinite}@keyframes fading{0%{opacity:0}50%{opacity:1}100%{opacity:0}} +.w3-animate-opacity{animation:opac 0.8s}@keyframes opac{from{opacity:0} to{opacity:1}} +.w3-animate-top{position:relative;animation:animatetop 0.4s}@keyframes animatetop{from{top:-300px;opacity:0} to{top:0;opacity:1}} +.w3-animate-left{position:relative;animation:animateleft 0.4s}@keyframes animateleft{from{left:-300px;opacity:0} to{left:0;opacity:1}} +.w3-animate-right{position:relative;animation:animateright 0.4s}@keyframes animateright{from{right:-300px;opacity:0} to{right:0;opacity:1}} +.w3-animate-bottom{position:relative;animation:animatebottom 0.4s}@keyframes animatebottom{from{bottom:-300px;opacity:0} to{bottom:0;opacity:1}} +.w3-animate-zoom {animation:animatezoom 0.6s}@keyframes animatezoom{from{transform:scale(0)} to{transform:scale(1)}} +.w3-animate-input{transition:width 0.4s ease-in-out}.w3-animate-input:focus{width:100%!important} +.w3-opacity,.w3-hover-opacity:hover{opacity:0.60}.w3-opacity-off,.w3-hover-opacity-off:hover{opacity:1} +.w3-opacity-max{opacity:0.25}.w3-opacity-min{opacity:0.75} +.w3-greyscale-max,.w3-grayscale-max,.w3-hover-greyscale:hover,.w3-hover-grayscale:hover{filter:grayscale(100%)} +.w3-greyscale,.w3-grayscale{filter:grayscale(75%)}.w3-greyscale-min,.w3-grayscale-min{filter:grayscale(50%)} +.w3-sepia{filter:sepia(75%)}.w3-sepia-max,.w3-hover-sepia:hover{filter:sepia(100%)}.w3-sepia-min{filter:sepia(50%)} +.w3-tiny{font-size:10px!important}.w3-small{font-size:12px!important}.w3-medium{font-size:15px!important}.w3-large{font-size:18px!important} +.w3-xlarge{font-size:24px!important}.w3-xxlarge{font-size:36px!important}.w3-xxxlarge{font-size:48px!important}.w3-jumbo{font-size:64px!important} +.w3-left-align{text-align:left!important}.w3-right-align{text-align:right!important}.w3-justify{text-align:justify!important}.w3-center{text-align:center!important} +.w3-border-0{border:0!important}.w3-border{border:1px solid #ccc!important} +.w3-border-top{border-top:1px solid #ccc!important}.w3-border-bottom{border-bottom:1px solid #ccc!important} +.w3-border-left{border-left:1px solid #ccc!important}.w3-border-right{border-right:1px solid #ccc!important} +.w3-topbar{border-top:6px solid #ccc!important}.w3-bottombar{border-bottom:6px solid #ccc!important} +.w3-leftbar{border-left:6px solid #ccc!important}.w3-rightbar{border-right:6px solid #ccc!important} +.w3-section,.w3-code{margin-top:16px!important;margin-bottom:16px!important} +.w3-margin{margin:16px!important}.w3-margin-top{margin-top:16px!important}.w3-margin-bottom{margin-bottom:16px!important} +.w3-margin-left{margin-left:16px!important}.w3-margin-right{margin-right:16px!important} +.w3-padding-small{padding:4px 8px!important}.w3-padding{padding:8px 16px!important}.w3-padding-large{padding:12px 24px!important} +.w3-padding-16{padding-top:16px!important;padding-bottom:16px!important}.w3-padding-24{padding-top:24px!important;padding-bottom:24px!important} +.w3-padding-32{padding-top:32px!important;padding-bottom:32px!important}.w3-padding-48{padding-top:48px!important;padding-bottom:48px!important} +.w3-padding-64{padding-top:64px!important;padding-bottom:64px!important} +.w3-padding-top-64{padding-top:64px!important}.w3-padding-top-48{padding-top:48px!important} +.w3-padding-top-32{padding-top:32px!important}.w3-padding-top-24{padding-top:24px!important} +.w3-left{float:left!important}.w3-right{float:right!important} +.w3-button:hover{color:#000!important;background-color:#ccc!important} +.w3-transparent,.w3-hover-none:hover{background-color:transparent!important} +.w3-hover-none:hover{box-shadow:none!important} +/* Colors */ +.w3-amber,.w3-hover-amber:hover{color:#000!important;background-color:#ffc107!important} +.w3-aqua,.w3-hover-aqua:hover{color:#000!important;background-color:#00ffff!important} +.w3-blue,.w3-hover-blue:hover{color:#fff!important;background-color:#2196F3!important} +.w3-light-blue,.w3-hover-light-blue:hover{color:#000!important;background-color:#87CEEB!important} +.w3-brown,.w3-hover-brown:hover{color:#fff!important;background-color:#795548!important} +.w3-cyan,.w3-hover-cyan:hover{color:#000!important;background-color:#00bcd4!important} +.w3-blue-grey,.w3-hover-blue-grey:hover,.w3-blue-gray,.w3-hover-blue-gray:hover{color:#fff!important;background-color:#607d8b!important} +.w3-green,.w3-hover-green:hover{color:#fff!important;background-color:#4CAF50!important} +.w3-light-green,.w3-hover-light-green:hover{color:#000!important;background-color:#8bc34a!important} +.w3-indigo,.w3-hover-indigo:hover{color:#fff!important;background-color:#3f51b5!important} +.w3-khaki,.w3-hover-khaki:hover{color:#000!important;background-color:#f0e68c!important} +.w3-lime,.w3-hover-lime:hover{color:#000!important;background-color:#cddc39!important} +.w3-orange,.w3-hover-orange:hover{color:#000!important;background-color:#ff9800!important} +.w3-deep-orange,.w3-hover-deep-orange:hover{color:#fff!important;background-color:#ff5722!important} +.w3-pink,.w3-hover-pink:hover{color:#fff!important;background-color:#e91e63!important} +.w3-purple,.w3-hover-purple:hover{color:#fff!important;background-color:#9c27b0!important} +.w3-deep-purple,.w3-hover-deep-purple:hover{color:#fff!important;background-color:#673ab7!important} +.w3-red,.w3-hover-red:hover{color:#fff!important;background-color:#f44336!important} +.w3-sand,.w3-hover-sand:hover{color:#000!important;background-color:#fdf5e6!important} +.w3-teal,.w3-hover-teal:hover{color:#fff!important;background-color:#009688!important} +.w3-yellow,.w3-hover-yellow:hover{color:#000!important;background-color:#ffeb3b!important} +.w3-white,.w3-hover-white:hover{color:#000!important;background-color:#fff!important} +.w3-black,.w3-hover-black:hover{color:#fff!important;background-color:#000!important} +.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover{color:#000!important;background-color:#9e9e9e!important} +.w3-light-grey,.w3-hover-light-grey:hover,.w3-light-gray,.w3-hover-light-gray:hover{color:#000!important;background-color:#f1f1f1!important} +.w3-dark-grey,.w3-hover-dark-grey:hover,.w3-dark-gray,.w3-hover-dark-gray:hover{color:#fff!important;background-color:#616161!important} +.w3-pale-red,.w3-hover-pale-red:hover{color:#000!important;background-color:#ffdddd!important} +.w3-pale-green,.w3-hover-pale-green:hover{color:#000!important;background-color:#ddffdd!important} +.w3-pale-yellow,.w3-hover-pale-yellow:hover{color:#000!important;background-color:#ffffcc!important} +.w3-pale-blue,.w3-hover-pale-blue:hover{color:#000!important;background-color:#ddffff!important} +.w3-text-amber,.w3-hover-text-amber:hover{color:#ffc107!important} +.w3-text-aqua,.w3-hover-text-aqua:hover{color:#00ffff!important} +.w3-text-blue,.w3-hover-text-blue:hover{color:#2196F3!important} +.w3-text-light-blue,.w3-hover-text-light-blue:hover{color:#87CEEB!important} +.w3-text-brown,.w3-hover-text-brown:hover{color:#795548!important} +.w3-text-cyan,.w3-hover-text-cyan:hover{color:#00bcd4!important} +.w3-text-blue-grey,.w3-hover-text-blue-grey:hover,.w3-text-blue-gray,.w3-hover-text-blue-gray:hover{color:#607d8b!important} +.w3-text-green,.w3-hover-text-green:hover{color:#4CAF50!important} +.w3-text-light-green,.w3-hover-text-light-green:hover{color:#8bc34a!important} +.w3-text-indigo,.w3-hover-text-indigo:hover{color:#3f51b5!important} +.w3-text-khaki,.w3-hover-text-khaki:hover{color:#b4aa50!important} +.w3-text-lime,.w3-hover-text-lime:hover{color:#cddc39!important} +.w3-text-orange,.w3-hover-text-orange:hover{color:#ff9800!important} +.w3-text-deep-orange,.w3-hover-text-deep-orange:hover{color:#ff5722!important} +.w3-text-pink,.w3-hover-text-pink:hover{color:#e91e63!important} +.w3-text-purple,.w3-hover-text-purple:hover{color:#9c27b0!important} +.w3-text-deep-purple,.w3-hover-text-deep-purple:hover{color:#673ab7!important} +.w3-text-red,.w3-hover-text-red:hover{color:#f44336!important} +.w3-text-sand,.w3-hover-text-sand:hover{color:#fdf5e6!important} +.w3-text-teal,.w3-hover-text-teal:hover{color:#009688!important} +.w3-text-yellow,.w3-hover-text-yellow:hover{color:#d2be0e!important} +.w3-text-white,.w3-hover-text-white:hover{color:#fff!important} +.w3-text-black,.w3-hover-text-black:hover{color:#000!important} +.w3-text-grey,.w3-hover-text-grey:hover,.w3-text-gray,.w3-hover-text-gray:hover{color:#757575!important} +.w3-text-light-grey,.w3-hover-text-light-grey:hover,.w3-text-light-gray,.w3-hover-text-light-gray:hover{color:#f1f1f1!important} +.w3-text-dark-grey,.w3-hover-text-dark-grey:hover,.w3-text-dark-gray,.w3-hover-text-dark-gray:hover{color:#3a3a3a!important} +.w3-border-amber,.w3-hover-border-amber:hover{border-color:#ffc107!important} +.w3-border-aqua,.w3-hover-border-aqua:hover{border-color:#00ffff!important} +.w3-border-blue,.w3-hover-border-blue:hover{border-color:#2196F3!important} +.w3-border-light-blue,.w3-hover-border-light-blue:hover{border-color:#87CEEB!important} +.w3-border-brown,.w3-hover-border-brown:hover{border-color:#795548!important} +.w3-border-cyan,.w3-hover-border-cyan:hover{border-color:#00bcd4!important} +.w3-border-blue-grey,.w3-hover-border-blue-grey:hover,.w3-border-blue-gray,.w3-hover-border-blue-gray:hover{border-color:#607d8b!important} +.w3-border-green,.w3-hover-border-green:hover{border-color:#4CAF50!important} +.w3-border-light-green,.w3-hover-border-light-green:hover{border-color:#8bc34a!important} +.w3-border-indigo,.w3-hover-border-indigo:hover{border-color:#3f51b5!important} +.w3-border-khaki,.w3-hover-border-khaki:hover{border-color:#f0e68c!important} +.w3-border-lime,.w3-hover-border-lime:hover{border-color:#cddc39!important} +.w3-border-orange,.w3-hover-border-orange:hover{border-color:#ff9800!important} +.w3-border-deep-orange,.w3-hover-border-deep-orange:hover{border-color:#ff5722!important} +.w3-border-pink,.w3-hover-border-pink:hover{border-color:#e91e63!important} +.w3-border-purple,.w3-hover-border-purple:hover{border-color:#9c27b0!important} +.w3-border-deep-purple,.w3-hover-border-deep-purple:hover{border-color:#673ab7!important} +.w3-border-red,.w3-hover-border-red:hover{border-color:#f44336!important} +.w3-border-sand,.w3-hover-border-sand:hover{border-color:#fdf5e6!important} +.w3-border-teal,.w3-hover-border-teal:hover{border-color:#009688!important} +.w3-border-yellow,.w3-hover-border-yellow:hover{border-color:#ffeb3b!important} +.w3-border-white,.w3-hover-border-white:hover{border-color:#fff!important} +.w3-border-black,.w3-hover-border-black:hover{border-color:#000!important} +.w3-border-grey,.w3-hover-border-grey:hover,.w3-border-gray,.w3-hover-border-gray:hover{border-color:#9e9e9e!important} +.w3-border-light-grey,.w3-hover-border-light-grey:hover,.w3-border-light-gray,.w3-hover-border-light-gray:hover{border-color:#f1f1f1!important} +.w3-border-dark-grey,.w3-hover-border-dark-grey:hover,.w3-border-dark-gray,.w3-hover-border-dark-gray:hover{border-color:#616161!important} +.w3-border-pale-red,.w3-hover-border-pale-red:hover{border-color:#ffe7e7!important}.w3-border-pale-green,.w3-hover-border-pale-green:hover{border-color:#e7ffe7!important} +.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}