From 7c0574556a267a5a638b1ab478c4469b85f30cf4 Mon Sep 17 00:00:00 2001 From: Boris Paing Date: Tue, 30 Mar 2021 20:38:51 +0200 Subject: [PATCH] Bulles Kinetic Graphs --- README.md | 0 courbes.html | 111 + css/kg.0.2.1.css | 151 + js/kg.0.2.1.js | 7625 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 7887 insertions(+) create mode 100644 README.md create mode 100644 courbes.html create mode 100755 css/kg.0.2.1.css create mode 100755 js/kg.0.2.1.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/courbes.html b/courbes.html new file mode 100644 index 0000000..c7f0a95 --- /dev/null +++ b/courbes.html @@ -0,0 +1,111 @@ + + + + + Courbes - Kinetic Graphs + + + + + + + + +

Evolution du solde d'un individu

+ +

+ c représente le taux de croissance de la masse monétaire. +

+ +

+ Essayez de modifier c pour voir comment votre solde évoluera. +

+ +
+ +params: +- {name: c, value: 10, min: 0, max: 100} +- {name: N, value: 100} +- {name: M00, value: 1000} +- {name: a00, value: 0} + +calcs: + M01: (params.M00 * (1 + params.c / 100)) + M02: calcs.M01 * pow((1 + params.c / 100), 2) + M03: calcs.M02 * pow((1 + params.c / 100), 3) + M04: calcs.M03 * pow((1 + params.c / 100), 4) + M05: calcs.M04 * pow((1 + params.c / 100), 5) + M06: calcs.M05 * pow((1 + params.c / 100), 6) + M07: calcs.M06 * pow((1 + params.c / 100), 7) + + DU01: calcs.M01 / params.N * params.c / 100 + DU02: calcs.M02 / params.N * params.c / 100 + DU03: calcs.M03 / params.N * params.c / 100 + DU04: calcs.M04 / params.N * params.c / 100 + DU05: calcs.M05 / params.N * params.c / 100 + DU06: calcs.M06 / params.N * params.c / 100 + DU07: calcs.M07 / params.N * params.c / 100 + + a01: ((params.a00 + calcs.DU01) / calcs.DU01) + a02: ((calcs.a01 + calcs.DU02) / calcs.DU02) + a03: ((calcs.a02 + calcs.DU03) / calcs.DU03) + a04: ((calcs.a03 + calcs.DU04) / calcs.DU04) + a05: ((calcs.a04 + calcs.DU05) / calcs.DU05) + a06: ((calcs.a05 + calcs.DU06) / calcs.DU06) + a07: ((calcs.a06 + calcs.DU07) / calcs.DU07) + +layout: + OneWideGraphPlusSidebar: + graph: + xAxis: + title: Temps $(annees)$ + max: 80 + ticks: 12 + yAxis: + title: Monnaie $(DUG1)$ + max: 10 + ticks: 10 + objects: + + - Curve: + univariateFunction: + fn: (x)^(1/params.c) + ind: x + color: red + + - Point: + coordinates: [0,params.a00] + - Point: + coordinates: [1,calcs.a01] + - Point: + coordinates: [2,calcs.a02] + - Point: + coordinates: [3,calcs.a03] + - Point: + coordinates: [4,calcs.a04] + - Point: + coordinates: [5,calcs.a05] + - Point: + coordinates: [6,calcs.a06] + - Point: + coordinates: [7,calcs.a07] + sidebar: + controls: + - title: Modifier le taux de croissance + sliders: + - {param: c, label: "c"} + +
+ + + diff --git a/css/kg.0.2.1.css b/css/kg.0.2.1.css new file mode 100755 index 0000000..dd3c3d2 --- /dev/null +++ b/css/kg.0.2.1.css @@ -0,0 +1,151 @@ +@font-face{font-family:KaTeX_AMS;src:url(fonts/KaTeX_AMS-Regular.eot);src:url(fonts/KaTeX_AMS-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_AMS-Regular.woff2) format('woff2'),url(fonts/KaTeX_AMS-Regular.woff) format('woff'),url(fonts/KaTeX_AMS-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Caligraphic;src:url(fonts/KaTeX_Caligraphic-Bold.eot);src:url(fonts/KaTeX_Caligraphic-Bold.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Caligraphic-Bold.woff2) format('woff2'),url(fonts/KaTeX_Caligraphic-Bold.woff) format('woff'),url(fonts/KaTeX_Caligraphic-Bold.ttf) format('truetype');font-weight:700;font-style:normal}@font-face{font-family:KaTeX_Caligraphic;src:url(fonts/KaTeX_Caligraphic-Regular.eot);src:url(fonts/KaTeX_Caligraphic-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Caligraphic-Regular.woff2) format('woff2'),url(fonts/KaTeX_Caligraphic-Regular.woff) format('woff'),url(fonts/KaTeX_Caligraphic-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Fraktur;src:url(fonts/KaTeX_Fraktur-Bold.eot);src:url(fonts/KaTeX_Fraktur-Bold.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Fraktur-Bold.woff2) format('woff2'),url(fonts/KaTeX_Fraktur-Bold.woff) format('woff'),url(fonts/KaTeX_Fraktur-Bold.ttf) format('truetype');font-weight:700;font-style:normal}@font-face{font-family:KaTeX_Fraktur;src:url(fonts/KaTeX_Fraktur-Regular.eot);src:url(fonts/KaTeX_Fraktur-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Fraktur-Regular.woff2) format('woff2'),url(fonts/KaTeX_Fraktur-Regular.woff) format('woff'),url(fonts/KaTeX_Fraktur-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Main;src:url(fonts/KaTeX_Main-Bold.eot);src:url(fonts/KaTeX_Main-Bold.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Main-Bold.woff2) format('woff2'),url(fonts/KaTeX_Main-Bold.woff) format('woff'),url(fonts/KaTeX_Main-Bold.ttf) format('truetype');font-weight:700;font-style:normal}@font-face{font-family:KaTeX_Main;src:url(fonts/KaTeX_Main-Italic.eot);src:url(fonts/KaTeX_Main-Italic.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Main-Italic.woff2) format('woff2'),url(fonts/KaTeX_Main-Italic.woff) format('woff'),url(fonts/KaTeX_Main-Italic.ttf) format('truetype');font-weight:400;font-style:italic}@font-face{font-family:KaTeX_Main;src:url(fonts/KaTeX_Main-Regular.eot);src:url(fonts/KaTeX_Main-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Main-Regular.woff2) format('woff2'),url(fonts/KaTeX_Main-Regular.woff) format('woff'),url(fonts/KaTeX_Main-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Math;src:url(fonts/KaTeX_Math-Italic.eot);src:url(fonts/KaTeX_Math-Italic.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Math-Italic.woff2) format('woff2'),url(fonts/KaTeX_Math-Italic.woff) format('woff'),url(fonts/KaTeX_Math-Italic.ttf) format('truetype');font-weight:400;font-style:italic}@font-face{font-family:KaTeX_SansSerif;src:url(fonts/KaTeX_SansSerif-Regular.eot);src:url(fonts/KaTeX_SansSerif-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_SansSerif-Regular.woff2) format('woff2'),url(fonts/KaTeX_SansSerif-Regular.woff) format('woff'),url(fonts/KaTeX_SansSerif-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Script;src:url(fonts/KaTeX_Script-Regular.eot);src:url(fonts/KaTeX_Script-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Script-Regular.woff2) format('woff2'),url(fonts/KaTeX_Script-Regular.woff) format('woff'),url(fonts/KaTeX_Script-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Size1;src:url(fonts/KaTeX_Size1-Regular.eot);src:url(fonts/KaTeX_Size1-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Size1-Regular.woff2) format('woff2'),url(fonts/KaTeX_Size1-Regular.woff) format('woff'),url(fonts/KaTeX_Size1-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Size2;src:url(fonts/KaTeX_Size2-Regular.eot);src:url(fonts/KaTeX_Size2-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Size2-Regular.woff2) format('woff2'),url(fonts/KaTeX_Size2-Regular.woff) format('woff'),url(fonts/KaTeX_Size2-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Size3;src:url(fonts/KaTeX_Size3-Regular.eot);src:url(fonts/KaTeX_Size3-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Size3-Regular.woff2) format('woff2'),url(fonts/KaTeX_Size3-Regular.woff) format('woff'),url(fonts/KaTeX_Size3-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Size4;src:url(fonts/KaTeX_Size4-Regular.eot);src:url(fonts/KaTeX_Size4-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Size4-Regular.woff2) format('woff2'),url(fonts/KaTeX_Size4-Regular.woff) format('woff'),url(fonts/KaTeX_Size4-Regular.ttf) format('truetype');font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Typewriter;src:url(fonts/KaTeX_Typewriter-Regular.eot);src:url(fonts/KaTeX_Typewriter-Regular.eot#iefix) format('embedded-opentype'),url(fonts/KaTeX_Typewriter-Regular.woff2) format('woff2'),url(fonts/KaTeX_Typewriter-Regular.woff) format('woff'),url(fonts/KaTeX_Typewriter-Regular.ttf) format('truetype');font-weight:400;font-style:normal}.katex-display{display:block;margin:1em 0;text-align:center}.katex .base,.katex .katex-html,.katex .strut{display:inline-block}.katex-display>.katex{display:inline-block;text-align:initial}.katex{font:400 1.21em KaTeX_Main,Times New Roman,serif;line-height:1.2;white-space:nowrap;text-indent:0;text-rendering:auto}.katex *{-ms-high-contrast-adjust:none!important}.katex .katex-mathml{position:absolute;clip:rect(1px,1px,1px,1px);padding:0;border:0;height:1px;width:1px;overflow:hidden}.katex .mathrm{font-style:normal}.katex .mainit,.katex .mathit,.katex .textit{font-style:italic}.katex .mathit{font-family:KaTeX_Math}.katex .mathbf{font-family:KaTeX_Main;font-weight:700}.katex .amsrm,.katex .mathbb{font-family:KaTeX_AMS}.katex .mathcal{font-family:KaTeX_Caligraphic}.katex .mathfrak{font-family:KaTeX_Fraktur}.katex .mathtt{font-family:KaTeX_Typewriter}.katex .mathscr{font-family:KaTeX_Script}.katex .mathsf{font-family:KaTeX_SansSerif}.katex .mainit{font-family:KaTeX_Main}.katex .mord+.mop{margin-left:.16667em}.katex .mord+.mbin{margin-left:.22222em}.katex .mord+.mrel{margin-left:.27778em}.katex .mop+.mop,.katex .mop+.mord,.katex .mord+.minner{margin-left:.16667em}.katex .mop+.mrel{margin-left:.27778em}.katex .mop+.minner{margin-left:.16667em}.katex .mbin+.minner,.katex .mbin+.mop,.katex .mbin+.mopen,.katex .mbin+.mord{margin-left:.22222em}.katex .mrel+.minner,.katex .mrel+.mop,.katex .mrel+.mopen,.katex .mrel+.mord{margin-left:.27778em}.katex .mclose+.mop{margin-left:.16667em}.katex .mclose+.mbin{margin-left:.22222em}.katex .mclose+.mrel{margin-left:.27778em}.katex .mclose+.minner,.katex .minner+.mop,.katex .minner+.mord,.katex .mpunct+.mclose,.katex .mpunct+.minner,.katex .mpunct+.mop,.katex .mpunct+.mopen,.katex .mpunct+.mord,.katex .mpunct+.mpunct,.katex .mpunct+.mrel{margin-left:.16667em}.katex .minner+.mbin{margin-left:.22222em}.katex .minner+.mrel{margin-left:.27778em}.katex .minner+.minner,.katex .minner+.mopen,.katex .minner+.mpunct{margin-left:.16667em}.katex .mbin.mtight,.katex .mclose.mtight,.katex .minner.mtight,.katex .mop.mtight,.katex .mopen.mtight,.katex .mord.mtight,.katex .mpunct.mtight,.katex .mrel.mtight{margin-left:0}.katex .mclose+.mop.mtight,.katex .minner+.mop.mtight,.katex .mop+.mop.mtight,.katex .mop+.mord.mtight,.katex .mord+.mop.mtight{margin-left:.16667em}.katex .vlist-t{display:inline-table;table-layout:fixed}.katex .vlist-r{display:table-row}.katex .vlist{display:table-cell;vertical-align:bottom;position:relative}.katex .vlist>span{display:block;height:0;position:relative}.katex .vlist>span>span{display:inline-block}.katex .vlist>span>.pstrut{overflow:hidden;width:0}.katex .vlist-t2{margin-right:-2px}.katex .vlist-s{display:table-cell;vertical-align:bottom;font-size:1px;width:2px}.katex .llap>.fix,.katex .mspace,.katex .rlap>.fix,.katex .rule{display:inline-block}.katex .msupsub{text-align:left}.katex .accent>.vlist-t,.katex .mfrac>span>span,.katex .mtable .col-align-c>.vlist-t,.katex .op-limits>.vlist-t{text-align:center}.katex .mfrac .frac-line{display:inline-block;width:100%;border-bottom-style:solid}.katex .mspace.negativethinspace{margin-left:-.16667em}.katex .mspace.thinspace{width:.16667em}.katex .mspace.negativemediumspace{margin-left:-.22222em}.katex .mspace.mediumspace{width:.22222em}.katex .mspace.thickspace{width:.27778em}.katex .mspace.sixmuspace{width:.333333em}.katex .mspace.eightmuspace{width:.444444em}.katex .mspace.enspace{width:.5em}.katex .mspace.twelvemuspace{width:.666667em}.katex .mspace.quad{width:1em}.katex .mspace.qquad{width:2em}.katex .llap,.katex .rlap{width:0;position:relative}.katex .llap>.inner,.katex .rlap>.inner{position:absolute}.katex .delimcenter,.katex .katex-logo .a,.katex .katex-logo .e,.katex .op-symbol,.katex .rule,.katex .sqrt .sqrt-line,.katex .sqrt>.sqrt-sign{position:relative}.katex .llap>.inner{right:0}.katex .rlap>.inner{left:0}.katex .katex-logo .a{font-size:.75em;margin-left:-.32em;top:-.2em}.katex .katex-logo .t{margin-left:-.23em}.katex .katex-logo .e{margin-left:-.1667em;top:.2155em}.katex .katex-logo .x{margin-left:-.125em}.katex .rule{border:0 solid}.katex .overline .overline-line,.katex .sqrt .sqrt-line,.katex .underline .underline-line{width:100%;border-bottom-style:solid;display:inline-block}.katex .sqrt>.root{margin-left:.27777778em;margin-right:-.55555556em}.katex .fontsize-ensurer,.katex .sizing{display:inline-block}.katex .fontsize-ensurer.reset-size1.size1,.katex .sizing.reset-size1.size1{font-size:1em}.katex .fontsize-ensurer.reset-size1.size2,.katex .sizing.reset-size1.size2{font-size:1.2em}.katex .fontsize-ensurer.reset-size1.size3,.katex .sizing.reset-size1.size3{font-size:1.4em}.katex .fontsize-ensurer.reset-size1.size4,.katex .sizing.reset-size1.size4{font-size:1.6em}.katex .fontsize-ensurer.reset-size1.size5,.katex .sizing.reset-size1.size5{font-size:1.8em}.katex .fontsize-ensurer.reset-size1.size6,.katex .sizing.reset-size1.size6{font-size:2em}.katex .fontsize-ensurer.reset-size1.size7,.katex .sizing.reset-size1.size7{font-size:2.4em}.katex .fontsize-ensurer.reset-size1.size8,.katex .sizing.reset-size1.size8{font-size:2.88em}.katex .fontsize-ensurer.reset-size1.size9,.katex .sizing.reset-size1.size9{font-size:3.456em}.katex .fontsize-ensurer.reset-size1.size10,.katex .sizing.reset-size1.size10{font-size:4.148em}.katex .fontsize-ensurer.reset-size1.size11,.katex .sizing.reset-size1.size11{font-size:4.976em}.katex .fontsize-ensurer.reset-size2.size1,.katex .sizing.reset-size2.size1{font-size:.83333333em}.katex .fontsize-ensurer.reset-size2.size2,.katex .sizing.reset-size2.size2{font-size:1em}.katex .fontsize-ensurer.reset-size2.size3,.katex .sizing.reset-size2.size3{font-size:1.16666667em}.katex .fontsize-ensurer.reset-size2.size4,.katex .sizing.reset-size2.size4{font-size:1.33333333em}.katex .fontsize-ensurer.reset-size2.size5,.katex .sizing.reset-size2.size5{font-size:1.5em}.katex .fontsize-ensurer.reset-size2.size6,.katex .sizing.reset-size2.size6{font-size:1.66666667em}.katex .fontsize-ensurer.reset-size2.size7,.katex .sizing.reset-size2.size7{font-size:2em}.katex .fontsize-ensurer.reset-size2.size8,.katex .sizing.reset-size2.size8{font-size:2.4em}.katex .fontsize-ensurer.reset-size2.size9,.katex .sizing.reset-size2.size9{font-size:2.88em}.katex .fontsize-ensurer.reset-size2.size10,.katex .sizing.reset-size2.size10{font-size:3.45666667em}.katex .fontsize-ensurer.reset-size2.size11,.katex .sizing.reset-size2.size11{font-size:4.14666667em}.katex .fontsize-ensurer.reset-size3.size1,.katex .sizing.reset-size3.size1{font-size:.71428571em}.katex .fontsize-ensurer.reset-size3.size2,.katex .sizing.reset-size3.size2{font-size:.85714286em}.katex .fontsize-ensurer.reset-size3.size3,.katex .sizing.reset-size3.size3{font-size:1em}.katex .fontsize-ensurer.reset-size3.size4,.katex .sizing.reset-size3.size4{font-size:1.14285714em}.katex .fontsize-ensurer.reset-size3.size5,.katex .sizing.reset-size3.size5{font-size:1.28571429em}.katex .fontsize-ensurer.reset-size3.size6,.katex .sizing.reset-size3.size6{font-size:1.42857143em}.katex .fontsize-ensurer.reset-size3.size7,.katex .sizing.reset-size3.size7{font-size:1.71428571em}.katex .fontsize-ensurer.reset-size3.size8,.katex .sizing.reset-size3.size8{font-size:2.05714286em}.katex .fontsize-ensurer.reset-size3.size9,.katex .sizing.reset-size3.size9{font-size:2.46857143em}.katex .fontsize-ensurer.reset-size3.size10,.katex .sizing.reset-size3.size10{font-size:2.96285714em}.katex .fontsize-ensurer.reset-size3.size11,.katex .sizing.reset-size3.size11{font-size:3.55428571em}.katex .fontsize-ensurer.reset-size4.size1,.katex .sizing.reset-size4.size1{font-size:.625em}.katex .fontsize-ensurer.reset-size4.size2,.katex .sizing.reset-size4.size2{font-size:.75em}.katex .fontsize-ensurer.reset-size4.size3,.katex .sizing.reset-size4.size3{font-size:.875em}.katex .fontsize-ensurer.reset-size4.size4,.katex .sizing.reset-size4.size4{font-size:1em}.katex .fontsize-ensurer.reset-size4.size5,.katex .sizing.reset-size4.size5{font-size:1.125em}.katex .fontsize-ensurer.reset-size4.size6,.katex .sizing.reset-size4.size6{font-size:1.25em}.katex .fontsize-ensurer.reset-size4.size7,.katex .sizing.reset-size4.size7{font-size:1.5em}.katex .fontsize-ensurer.reset-size4.size8,.katex .sizing.reset-size4.size8{font-size:1.8em}.katex .fontsize-ensurer.reset-size4.size9,.katex .sizing.reset-size4.size9{font-size:2.16em}.katex .fontsize-ensurer.reset-size4.size10,.katex .sizing.reset-size4.size10{font-size:2.5925em}.katex .fontsize-ensurer.reset-size4.size11,.katex .sizing.reset-size4.size11{font-size:3.11em}.katex .fontsize-ensurer.reset-size5.size1,.katex .sizing.reset-size5.size1{font-size:.55555556em}.katex .fontsize-ensurer.reset-size5.size2,.katex .sizing.reset-size5.size2{font-size:.66666667em}.katex .fontsize-ensurer.reset-size5.size3,.katex .sizing.reset-size5.size3{font-size:.77777778em}.katex .fontsize-ensurer.reset-size5.size4,.katex .sizing.reset-size5.size4{font-size:.88888889em}.katex .fontsize-ensurer.reset-size5.size5,.katex .sizing.reset-size5.size5{font-size:1em}.katex .fontsize-ensurer.reset-size5.size6,.katex .sizing.reset-size5.size6{font-size:1.11111111em}.katex .fontsize-ensurer.reset-size5.size7,.katex .sizing.reset-size5.size7{font-size:1.33333333em}.katex .fontsize-ensurer.reset-size5.size8,.katex .sizing.reset-size5.size8{font-size:1.6em}.katex .fontsize-ensurer.reset-size5.size9,.katex .sizing.reset-size5.size9{font-size:1.92em}.katex .fontsize-ensurer.reset-size5.size10,.katex .sizing.reset-size5.size10{font-size:2.30444444em}.katex .fontsize-ensurer.reset-size5.size11,.katex .sizing.reset-size5.size11{font-size:2.76444444em}.katex .fontsize-ensurer.reset-size6.size1,.katex .sizing.reset-size6.size1{font-size:.5em}.katex .fontsize-ensurer.reset-size6.size2,.katex .sizing.reset-size6.size2{font-size:.6em}.katex .fontsize-ensurer.reset-size6.size3,.katex .sizing.reset-size6.size3{font-size:.7em}.katex .fontsize-ensurer.reset-size6.size4,.katex .sizing.reset-size6.size4{font-size:.8em}.katex .fontsize-ensurer.reset-size6.size5,.katex .sizing.reset-size6.size5{font-size:.9em}.katex .fontsize-ensurer.reset-size6.size6,.katex .sizing.reset-size6.size6{font-size:1em}.katex .fontsize-ensurer.reset-size6.size7,.katex .sizing.reset-size6.size7{font-size:1.2em}.katex .fontsize-ensurer.reset-size6.size8,.katex .sizing.reset-size6.size8{font-size:1.44em}.katex .fontsize-ensurer.reset-size6.size9,.katex .sizing.reset-size6.size9{font-size:1.728em}.katex .fontsize-ensurer.reset-size6.size10,.katex .sizing.reset-size6.size10{font-size:2.074em}.katex .fontsize-ensurer.reset-size6.size11,.katex .sizing.reset-size6.size11{font-size:2.488em}.katex .fontsize-ensurer.reset-size7.size1,.katex .sizing.reset-size7.size1{font-size:.41666667em}.katex .fontsize-ensurer.reset-size7.size2,.katex .sizing.reset-size7.size2{font-size:.5em}.katex .fontsize-ensurer.reset-size7.size3,.katex .sizing.reset-size7.size3{font-size:.58333333em}.katex .fontsize-ensurer.reset-size7.size4,.katex .sizing.reset-size7.size4{font-size:.66666667em}.katex .fontsize-ensurer.reset-size7.size5,.katex .sizing.reset-size7.size5{font-size:.75em}.katex .fontsize-ensurer.reset-size7.size6,.katex .sizing.reset-size7.size6{font-size:.83333333em}.katex .fontsize-ensurer.reset-size7.size7,.katex .sizing.reset-size7.size7{font-size:1em}.katex .fontsize-ensurer.reset-size7.size8,.katex .sizing.reset-size7.size8{font-size:1.2em}.katex .fontsize-ensurer.reset-size7.size9,.katex .sizing.reset-size7.size9{font-size:1.44em}.katex .fontsize-ensurer.reset-size7.size10,.katex .sizing.reset-size7.size10{font-size:1.72833333em}.katex .fontsize-ensurer.reset-size7.size11,.katex .sizing.reset-size7.size11{font-size:2.07333333em}.katex .fontsize-ensurer.reset-size8.size1,.katex .sizing.reset-size8.size1{font-size:.34722222em}.katex .fontsize-ensurer.reset-size8.size2,.katex .sizing.reset-size8.size2{font-size:.41666667em}.katex .fontsize-ensurer.reset-size8.size3,.katex .sizing.reset-size8.size3{font-size:.48611111em}.katex .fontsize-ensurer.reset-size8.size4,.katex .sizing.reset-size8.size4{font-size:.55555556em}.katex .fontsize-ensurer.reset-size8.size5,.katex .sizing.reset-size8.size5{font-size:.625em}.katex .fontsize-ensurer.reset-size8.size6,.katex .sizing.reset-size8.size6{font-size:.69444444em}.katex .fontsize-ensurer.reset-size8.size7,.katex .sizing.reset-size8.size7{font-size:.83333333em}.katex .fontsize-ensurer.reset-size8.size8,.katex .sizing.reset-size8.size8{font-size:1em}.katex .fontsize-ensurer.reset-size8.size9,.katex .sizing.reset-size8.size9{font-size:1.2em}.katex .fontsize-ensurer.reset-size8.size10,.katex .sizing.reset-size8.size10{font-size:1.44027778em}.katex .fontsize-ensurer.reset-size8.size11,.katex .sizing.reset-size8.size11{font-size:1.72777778em}.katex .fontsize-ensurer.reset-size9.size1,.katex .sizing.reset-size9.size1{font-size:.28935185em}.katex .fontsize-ensurer.reset-size9.size2,.katex .sizing.reset-size9.size2{font-size:.34722222em}.katex .fontsize-ensurer.reset-size9.size3,.katex .sizing.reset-size9.size3{font-size:.40509259em}.katex .fontsize-ensurer.reset-size9.size4,.katex .sizing.reset-size9.size4{font-size:.46296296em}.katex .fontsize-ensurer.reset-size9.size5,.katex .sizing.reset-size9.size5{font-size:.52083333em}.katex .fontsize-ensurer.reset-size9.size6,.katex .sizing.reset-size9.size6{font-size:.5787037em}.katex .fontsize-ensurer.reset-size9.size7,.katex .sizing.reset-size9.size7{font-size:.69444444em}.katex .fontsize-ensurer.reset-size9.size8,.katex .sizing.reset-size9.size8{font-size:.83333333em}.katex .fontsize-ensurer.reset-size9.size9,.katex .sizing.reset-size9.size9{font-size:1em}.katex .fontsize-ensurer.reset-size9.size10,.katex .sizing.reset-size9.size10{font-size:1.20023148em}.katex .fontsize-ensurer.reset-size9.size11,.katex .sizing.reset-size9.size11{font-size:1.43981481em}.katex .fontsize-ensurer.reset-size10.size1,.katex .sizing.reset-size10.size1{font-size:.24108004em}.katex .fontsize-ensurer.reset-size10.size2,.katex .sizing.reset-size10.size2{font-size:.28929605em}.katex .fontsize-ensurer.reset-size10.size3,.katex .sizing.reset-size10.size3{font-size:.33751205em}.katex .fontsize-ensurer.reset-size10.size4,.katex .sizing.reset-size10.size4{font-size:.38572806em}.katex .fontsize-ensurer.reset-size10.size5,.katex .sizing.reset-size10.size5{font-size:.43394407em}.katex .fontsize-ensurer.reset-size10.size6,.katex .sizing.reset-size10.size6{font-size:.48216008em}.katex .fontsize-ensurer.reset-size10.size7,.katex .sizing.reset-size10.size7{font-size:.57859209em}.katex .fontsize-ensurer.reset-size10.size8,.katex .sizing.reset-size10.size8{font-size:.69431051em}.katex .fontsize-ensurer.reset-size10.size9,.katex .sizing.reset-size10.size9{font-size:.83317261em}.katex .fontsize-ensurer.reset-size10.size10,.katex .sizing.reset-size10.size10{font-size:1em}.katex .fontsize-ensurer.reset-size10.size11,.katex .sizing.reset-size10.size11{font-size:1.19961427em}.katex .fontsize-ensurer.reset-size11.size1,.katex .sizing.reset-size11.size1{font-size:.20096463em}.katex .fontsize-ensurer.reset-size11.size2,.katex .sizing.reset-size11.size2{font-size:.24115756em}.katex .fontsize-ensurer.reset-size11.size3,.katex .sizing.reset-size11.size3{font-size:.28135048em}.katex .fontsize-ensurer.reset-size11.size4,.katex .sizing.reset-size11.size4{font-size:.32154341em}.katex .fontsize-ensurer.reset-size11.size5,.katex .sizing.reset-size11.size5{font-size:.36173633em}.katex .fontsize-ensurer.reset-size11.size6,.katex .sizing.reset-size11.size6{font-size:.40192926em}.katex .fontsize-ensurer.reset-size11.size7,.katex .sizing.reset-size11.size7{font-size:.48231511em}.katex .fontsize-ensurer.reset-size11.size8,.katex .sizing.reset-size11.size8{font-size:.57877814em}.katex .fontsize-ensurer.reset-size11.size9,.katex .sizing.reset-size11.size9{font-size:.69453376em}.katex .fontsize-ensurer.reset-size11.size10,.katex .sizing.reset-size11.size10{font-size:.83360129em}.katex .fontsize-ensurer.reset-size11.size11,.katex .sizing.reset-size11.size11{font-size:1em}.katex .delimsizing.size1{font-family:KaTeX_Size1}.katex .delimsizing.size2{font-family:KaTeX_Size2}.katex .delimsizing.size3{font-family:KaTeX_Size3}.katex .delimsizing.size4{font-family:KaTeX_Size4}.katex .delimsizing.mult .delim-size1>span{font-family:KaTeX_Size1}.katex .delimsizing.mult .delim-size4>span{font-family:KaTeX_Size4}.katex .nulldelimiter{display:inline-block;width:.12em}.katex .op-symbol.small-op{font-family:KaTeX_Size1}.katex .op-symbol.large-op{font-family:KaTeX_Size2}.katex .accent .accent-body>span{width:0}.katex .accent .accent-body.accent-vec>span{position:relative;left:.326em}.katex .mtable .vertical-separator{display:inline-block;margin:0 -.025em;border-right:.05em solid #000}.katex .mtable .arraycolsep{display:inline-block}.katex .mtable .col-align-l>.vlist-t{text-align:left}.katex .mtable .col-align-r>.vlist-t{text-align:right}.katex .stretchy{width:100%;display:block;background-repeat:no-repeat;background-position:right center;background-size:100% 100%}.katex .stretchy:after,.katex .stretchy:before{content:""}.katex .x-arrow-pad{padding:0 .5em}.katex .mover,.katex .munder,.katex .x-arrow{text-align:center}.katex .boxpad{padding:0 .3em}.katex .fbox{box-sizing:border-box;border:.04em solid #000}.katex .cancel-pad{padding:0 .2em}.katex .cancel-lap+.mbin,.katex .cancel-lap+.mord,.katex .cancel-lap+.msupsub,.katex .mbin+.cancel-lap,.katex .mord+.cancel-lap{margin-left:-.2em}.katex .sout{border-bottom-style:solid;border-bottom-width:.08em}.katex .widehat1{height:.24em;background-image:url(images/widehat1.svg)}.katex .widehat2{height:.3em;background-image:url(images/widehat2.svg)}.katex .widehat3{height:.36em;background-image:url(images/widehat3.svg)}.katex .widehat4{height:.42em;background-image:url(images/widehat4.svg)}.katex .tilde1{height:.26em;background-image:url(images/tilde1.svg)}.katex .tilde2{height:.29em;background-image:url(images/tilde2.svg)}.katex .tilde3{height:.306em;background-image:url(images/tilde3.svg)}.katex .tilde4{height:.312em;background-image:url(images/tilde4.svg)}.katex .rightarrow,.katex .xrightarrow{height:.522em;background-image:url(images/rightarrow.svg)}.katex .rightarrow{min-width:.5em}.katex .xrightarrow{min-width:.783em}.katex .leftarrow,.katex .xleftarrow{height:.522em;background-image:url(images/leftarrow.svg)}.katex .leftarrow{min-width:.5em}.katex .xleftarrow{min-width:.783em}.katex .overbrace{height:.548em;min-width:1.6em;background-image:url(images/overbrace.svg)}.katex .underbrace{height:.548em;min-width:1.6em;background-image:url(images/underbrace.svg)}.katex .leftrightarrow,.katex .xleftrightarrow{background-image:url(images/leftrightarrow.svg);height:.522em}.katex .leftrightarrow{min-width:.5em}.katex .xleftrightarrow{min-width:.783em}.katex .doublerightarrow{height:.56em;min-width:.783em;background-image:url(images/doublerightarrow.svg)}.katex .doubleleftarrow{height:.56em;min-width:.783em;background-image:url(images/doubleleftarrow.svg)}.katex .doubleleftrightarrow{height:.56em;min-width:.955em;background-image:url(images/doubleleftrightarrow.svg)}.katex .leftharpoon{height:.522em;min-width:.783em;background-image:url(images/leftharpoon.svg)}.katex .rightharpoon,.katex .xrightharpoon{background-image:url(images/rightharpoon.svg);height:.522em}.katex .rightharpoon{min-width:.5em}.katex .xrightharpoon{min-width:.783em}.katex .hookleftarrow{height:.522em;min-width:.87em;background-image:url(images/hookleftarrow.svg)}.katex .hookrightarrow{min-width:.87em;height:.522em;background-image:url(images/hookrightarrow.svg)}.katex .mapsto{height:.522em;min-width:.783em;background-image:url(images/mapsto.svg)}.katex .leftharpoondown{height:.522em;min-width:.783em;background-image:url(images/leftharpoondown.svg)}.katex .rightharpoondown,.katex .xrightharpoondown{height:.522em;background-image:url(images/rightharpoondown.svg)}.katex .rightharpoondown{min-width:.5em}.katex .xrightharpoondown{min-width:.783em}.katex .rightleftharpoons{height:.716em;min-width:.783em;background-image:url(images/rightleftharpoons.svg)}.katex .leftrightharpoons{height:.716em;min-width:.783em;background-image:url(images/leftrightharpoons.svg)}.katex .overgroup{height:.342em;min-width:.87em;background-image:url(images/overgroup.svg)}.katex .undergroup{height:.342em;min-width:.87em;background-image:url(images/undergroup.svg)}.katex .twoheadleftarrow{height:.334em;min-width:.86em;background-image:url(images/twoheadleftarrow.svg)}.katex .twoheadrightarrow{height:.334em;min-width:.86em;background-image:url(images/twoheadrightarrow.svg)}.katex .linesegment{height:.414em;min-width:.5em;background-image:url(images/linesegment.svg)}.katex .longequal{height:.334em;min-width:.5em;background-image:url(images/longequal.svg)}.katex .tofrom{height:.528em;min-width:.86em;background-image:url(images/tofrom.svg)}.katex .cancel{background:linear-gradient(to top left,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%)}.katex .bcancel{background:linear-gradient(to top right,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%)}.katex .xcancel{background:linear-gradient(to top left,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%),linear-gradient(to top right,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%)}@media screen and (min-width:0\0){.katex .bcancel,.katex .bcancel-mask,.katex .cancel,.katex .cancel-mask,.katex .mask,.katex .xcancel,.katex .xcancel-mask{background-color:transparent!important}.katex .bcancel,.katex .bcancel-mask{background-image:url(images/bcancel.svg)}.katex .cancel,.katex .cancel-mask{background-image:url(images/cancel.svg)}.katex .xcancel,.katex .xcancel-mask{background-image:url(images/xcancel.svg)}}@supports ((mask-image:none) or (-webkit-mask:none)){.katex .bcancel-mask,.katex .cancel-mask,.katex .mask,.katex .xcancel-mask{background-image:none}}@supports not ((mask-image:none) or (-webkit-mask:none)){.katex .bcancel-mask,.katex .cancel-mask,.katex .mask{background-color:transparent!important}.katex .cancel-mask{background:linear-gradient(to top left,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%)}.katex .bcancel-mask{background:linear-gradient(to top right,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%)}.katex .xcancel-mask{background-color:transparent!important;background:linear-gradient(to top left,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%),linear-gradient(to top right,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%)}}.katex .cancel-mask{mask-image:linear-gradient(to top left,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%);-webkit-mask-image:linear-gradient(to top left,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%)}.katex .bcancel-mask{mask-image:linear-gradient(to top right,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%);-webkit-mask-image:linear-gradient(to top right,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%)}.katex .xcancel-mask{mask-image:linear-gradient(to top left,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%),linear-gradient(to top right,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%);-webkit-mask-image:linear-gradient(to top left,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%),linear-gradient(to top right,rgba(0,0,0,0) 0,rgba(0,0,0,0) calc(50% - .04em - .5px),#000 calc(50% - .04em),#000 calc(50% + .04em),rgba(0,0,0,0) calc(50% + .04em + .5px),rgba(0,0,0,0) 100%)}@supports (-ms-touch-action:none){.katex .bcancel,.katex .bcancel-mask{background-color:transparent!important;background-image:url(images/bcancel.svg)}.katex .cancel,.katex .cancel-mask{background-color:transparent!important;background-image:url(images/cancel.svg)}.katex .xcancel,.katex .xcancel-mask{background-color:transparent!important;background-image:url(images/xcancel.svg)}}.katex .widehat1-mask{-webkit-mask:url(images/widehat1.svg);mask:url(images/widehat1.svg) no-repeat}.katex .widehat2-mask{-webkit-mask:url(images/widehat2.svg);mask:url(images/widehat2.svg) no-repeat}.katex .widehat3-mask{-webkit-mask:url(images/widehat3.svg);mask:url(images/widehat3.svg) no-repeat}.katex .widehat4-mask{-webkit-mask:url(images/widehat4.svg);mask:url(images/widehat4.svg) no-repeat}.katex .tilde1-mask{-webkit-mask:url(images/tilde1.svg);mask:url(images/tilde1.svg) no-repeat}.katex .tilde2-mask{-webkit-mask:url(images/tilde2.svg);mask:url(images/tilde2.svg) no-repeat}.katex .tilde3-mask{-webkit-mask:url(images/tilde3.svg);mask:url(images/tilde3.svg) no-repeat}.katex .tilde4-mask{-webkit-mask:url(images/tilde4.svg);mask:url(images/tilde4.svg) no-repeat}.katex .rightarrow-mask,.katex .xrightarrow-mask{mask:url(images/rightarrow.svg);-webkit-mask:url(images/rightarrow.svg)}.katex .leftarrow-mask,.katex .xleftarrow-mask{mask:url(images/leftarrow.svg);-webkit-mask:url(images/leftarrow.svg)}.katex .overbrace-mask{min-width:1.6em;mask:url(images/overbrace.svg);-webkit-mask:url(images/overbrace.svg)}.katex .underbrace-mask{min-width:1.6em;mask:url(images/underbrace.svg);-webkit-mask:url(images/underbrace.svg)}.katex .leftrightarrow-mask,.katex .xleftrightarrow-mask{mask:url(images/leftrightarrow.svg);-webkit-mask:url(images/leftrightarrow.svg)}.katex .doublerightarrow-mask{mask:url(images/doublerightarrow.svg);-webkit-mask:url(images/doublerightarrow.svg)}.katex .doubleleftarrow-mask{mask:url(images/doubleleftarrow.svg);-webkit-mask:url(images/doubleleftarrow.svg)}.katex .doubleleftrightarrow-mask{mask:url(images/doubleleftrightarrow.svg);-webkit-mask:url(images/doubleleftrightarrow.svg)}.katex .leftharpoon-mask,.katex .xleftharpoon-mask{mask:url(images/leftharpoon.svg);-webkit-mask:url(images/leftharpoon.svg)}.katex .rightharpoon-mask,.katex .xrightharpoon-mask{mask:url(images/rightharpoon.svg);-webkit-mask:url(images/rightharpoon.svg)}.katex .hookleftarrow-mask{mask:url(images/hookleftarrow.svg);-webkit-mask:url(images/hookleftarrow.svg)}.katex .hookrightarrow-mask{mask:url(images/hookrightarrow.svg);-webkit-mask:url(images/hookrightarrow.svg)}.katex .mapsto-mask{mask:url(images/mapsto.svg);-webkit-mask:url(images/mapsto.svg)}.katex .leftharpoondown-mask,.katex .xleftharpoondown-mask{mask:url(images/leftharpoondown.svg);-webkit-mask:url(images/leftharpoondown.svg)}.katex .rightharpoondown-mask,.katex .xrightharpoondown-mask{mask:url(images/rightharpoondown.svg);-webkit-mask:url(images/rightharpoondown.svg)}.katex .rightleftharpoons-mask{mask:url(images/rightleftharpoons.svg);-webkit-mask:url(images/rightleftharpoons.svg)}.katex .leftrightharpoons-mask{mask:url(images/leftrightharpoons.svg);-webkit-mask:url(images/leftrightharpoons.svg)}.katex .overgroup-mask{mask:url(images/overgroup.svg);-webkit-mask:url(images/overgroup.svg)}.katex .undergroup-mask{mask:url(images/undergroup.svg);-webkit-mask:url(images/undergroup.svg)}.katex .twoheadleftarrow-mask{mask:url(images/twoheadleftarrow.svg);-webkit-mask:url(images/twoheadleftarrow.svg)}.katex .twoheadrightarrow-mask{mask:url(images/twoheadrightarrow.svg);-webkit-mask:url(images/twoheadrightarrow.svg)}.katex .linesegment-mask{mask:url(images/linesegment.svg);-webkit-mask:url(images/linesegment.svg)}.katex .longequal-mask{mask:url(images/longequal.svg);-webkit-mask:url(images/longequal.svg)}.katex .tofrom-mask{mask:url(images/tofrom.svg);-webkit-mask:url(images/tofrom.svg)} + + + +body.documentation { + width: 100%; + padding-left: 20px; + max-width: 1200px; +} + +body.documentation p { + width: 1000px; +} + +div.kg-container text { + cursor: default; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +div.kg-container text::selection { + background: none; +} + +text { + font-size: 10px; +} + +input { + font-family: KaTeX_Main; +} + +.katex { + font-size: 1em +} + +.watermark { + position: fixed; + bottom: 5px; + right: 5px; + opacity: 0.5; + z-index: 99; + color: lightgray; +} + +.watermark a { + color: lightgray; +} + +.tick text { + fill: gray; +} + +.tick line { + stroke: gray; +} + +table.gameMatrix { + border-collapse: collapse; + width: 100%; +} + +table.gameMatrix tr td { + border: 2px solid #999; + padding: 1rem; + text-align: center; + font-size: 14pt; +} + +table.gameMatrix tr td.player1 { + color: #3182bd; +} + +table.gameMatrix tr td.player2 { + color: #d62728; +} + +table.gameMatrix tr td.empty { + border: 0; +} + +table.gameMatrix tr td.player1.payoff { + border-right: 0; +} + +table.gameMatrix tr td.player2.payoff { + border-left: 0; +} + +table.gameMatrix tr td.strategy { + font-weight: bolder; +} + +.kg-container:fullscreen { + background-color: white; +} + +.contents { + position: fixed; + width: 180px; + top: 10px; + left: 10px; + border-right: thin solid gray; + padding: 20px; +} + +.kgjs-title { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 36px; + position: absolute; + left: 72px; + top: 18px; + letter-spacing: 0px; + font-weight: 500; + margin-block-end: 10px; + color: #666666; +} + + +.contents-category { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 12px; + font-weight: 700; + color: #959595; + text-transform: uppercase; + letter-spacing: 1px; + margin-top: 2em; + margin-bottom: 0.5em; +} + +.contents-category a { + background: none; +} + +.contents p { + margin-left: 10px; + margin-top: 0; + margin-bottom: 0; + line-height: 1; +} + +.contents p a { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 1rem; + padding: 3px; + background: none; + color: rgb(31, 119, 180); +} + diff --git a/js/kg.0.2.1.js b/js/kg.0.2.1.js new file mode 100755 index 0000000..4c7d4ff --- /dev/null +++ b/js/kg.0.2.1.js @@ -0,0 +1,7625 @@ +(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.renderMathInElement=e()}})(function(){var e,t,n;return function e(t,n,r){function o(c,a){if(!n[c]){if(!t[c]){var u=typeof require=="function"&&require;if(!a&&u)return u(c,!0);if(i)return i(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var s=n[c]={exports:{}};t[c][0].call(s.exports,function(e){var n=t[c][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[c].exports}var i=typeof require=="function"&&require;for(var c=0;cf){s=a[f++];if(s!=s)return true}else for(;u>f;f++)if(e||f in a){if(a[f]===n)return e||f||0}return!e&&-1}}},{"./_to-index":32,"./_to-iobject":34,"./_to-length":35}],8:[function(e,t,n){var r={}.toString;t.exports=function(e){return r.call(e).slice(8,-1)}},{}],9:[function(e,t,n){var r=t.exports={version:"2.4.0"};if(typeof __e=="number")__e=r},{}],10:[function(e,t,n){var r=e("./_a-function");t.exports=function(e,t,n){r(e);if(t===undefined)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,o){return e.call(t,n,r,o)}}return function(){return e.apply(t,arguments)}}},{"./_a-function":5}],11:[function(e,t,n){t.exports=function(e){if(e==undefined)throw TypeError("Can't call method on "+e);return e}},{}],12:[function(e,t,n){t.exports=!e("./_fails")(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},{"./_fails":16}],13:[function(e,t,n){var r=e("./_is-object"),o=e("./_global").document,i=r(o)&&r(o.createElement);t.exports=function(e){return i?o.createElement(e):{}}},{"./_global":17,"./_is-object":22}],14:[function(e,t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},{}],15:[function(e,t,n){var r=e("./_global"),o=e("./_core"),i=e("./_ctx"),c=e("./_hide"),a="prototype";var u=function(e,t,n){var f=e&u.F,s=e&u.G,l=e&u.S,p=e&u.P,d=e&u.B,_=e&u.W,v=s?o:o[t]||(o[t]={}),h=v[a],b=s?r:l?r[t]:(r[t]||{})[a],y,g,x;if(s)n=t;for(y in n){g=!f&&b&&b[y]!==undefined;if(g&&y in v)continue;x=g?b[y]:n[y];v[y]=s&&typeof b[y]!="function"?n[y]:d&&g?i(x,r):_&&b[y]==x?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};t[a]=e[a];return t}(x):p&&typeof x=="function"?i(Function.call,x):x;if(p){(v.virtual||(v.virtual={}))[y]=x;if(e&u.R&&h&&!h[y])c(h,y,x)}}};u.F=1;u.G=2;u.S=4;u.P=8;u.B=16;u.W=32;u.U=64;u.R=128;t.exports=u},{"./_core":9,"./_ctx":10,"./_global":17,"./_hide":19}],16:[function(e,t,n){t.exports=function(e){try{return!!e()}catch(e){return true}}},{}],17:[function(e,t,n){var r=t.exports=typeof window!="undefined"&&window.Math==Math?window:typeof self!="undefined"&&self.Math==Math?self:Function("return this")();if(typeof __g=="number")__g=r},{}],18:[function(e,t,n){var r={}.hasOwnProperty;t.exports=function(e,t){return r.call(e,t)}},{}],19:[function(e,t,n){var r=e("./_object-dp"),o=e("./_property-desc");t.exports=e("./_descriptors")?function(e,t,n){return r.f(e,t,o(1,n))}:function(e,t,n){e[t]=n;return e}},{"./_descriptors":12,"./_object-dp":24,"./_property-desc":29}],20:[function(e,t,n){t.exports=!e("./_descriptors")&&!e("./_fails")(function(){return Object.defineProperty(e("./_dom-create")("div"),"a",{get:function(){return 7}}).a!=7})},{"./_descriptors":12,"./_dom-create":13,"./_fails":16}],21:[function(e,t,n){var r=e("./_cof");t.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return r(e)=="String"?e.split(""):Object(e)}},{"./_cof":8}],22:[function(e,t,n){t.exports=function(e){return typeof e==="object"?e!==null:typeof e==="function"}},{}],23:[function(e,t,n){"use strict";var r=e("./_object-keys"),o=e("./_object-gops"),i=e("./_object-pie"),c=e("./_to-object"),a=e("./_iobject"),u=Object.assign;t.exports=!u||e("./_fails")(function(){var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";e[n]=7;r.split("").forEach(function(e){t[e]=e});return u({},e)[n]!=7||Object.keys(u({},t)).join("")!=r})?function e(t,n){var u=c(t),f=arguments.length,s=1,l=o.f,p=i.f;while(f>s){var d=a(arguments[s++]),_=l?r(d).concat(l(d)):r(d),v=_.length,h=0,b;while(v>h)if(p.call(d,b=_[h++]))u[b]=d[b]}return u}:u},{"./_fails":16,"./_iobject":21,"./_object-gops":25,"./_object-keys":27,"./_object-pie":28,"./_to-object":36}],24:[function(e,t,n){var r=e("./_an-object"),o=e("./_ie8-dom-define"),i=e("./_to-primitive"),c=Object.defineProperty;n.f=e("./_descriptors")?Object.defineProperty:function e(t,n,a){r(t);n=i(n,true);r(a);if(o)try{return c(t,n,a)}catch(e){}if("get"in a||"set"in a)throw TypeError("Accessors not supported!");if("value"in a)t[n]=a.value;return t}},{"./_an-object":6,"./_descriptors":12,"./_ie8-dom-define":20,"./_to-primitive":37}],25:[function(e,t,n){n.f=Object.getOwnPropertySymbols},{}],26:[function(e,t,n){var r=e("./_has"),o=e("./_to-iobject"),i=e("./_array-includes")(false),c=e("./_shared-key")("IE_PROTO");t.exports=function(e,t){var n=o(e),a=0,u=[],f;for(f in n)if(f!=c)r(n,f)&&u.push(f);while(t.length>a)if(r(n,f=t[a++])){~i(u,f)||u.push(f)}return u}},{"./_array-includes":7,"./_has":18,"./_shared-key":30,"./_to-iobject":34}],27:[function(e,t,n){var r=e("./_object-keys-internal"),o=e("./_enum-bug-keys");t.exports=Object.keys||function e(t){return r(t,o)}},{"./_enum-bug-keys":14,"./_object-keys-internal":26}],28:[function(e,t,n){n.f={}.propertyIsEnumerable},{}],29:[function(e,t,n){t.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}},{}],30:[function(e,t,n){var r=e("./_shared")("keys"),o=e("./_uid");t.exports=function(e){return r[e]||(r[e]=o(e))}},{"./_shared":31,"./_uid":38}],31:[function(e,t,n){var r=e("./_global"),o="__core-js_shared__",i=r[o]||(r[o]={});t.exports=function(e){return i[e]||(i[e]={})}},{"./_global":17}],32:[function(e,t,n){var r=e("./_to-integer"),o=Math.max,i=Math.min;t.exports=function(e,t){e=r(e);return e<0?o(e+t,0):i(e,t)}},{"./_to-integer":33}],33:[function(e,t,n){var r=Math.ceil,o=Math.floor;t.exports=function(e){return isNaN(e=+e)?0:(e>0?o:r)(e)}},{}],34:[function(e,t,n){var r=e("./_iobject"),o=e("./_defined");t.exports=function(e){return r(o(e))}},{"./_defined":11,"./_iobject":21}],35:[function(e,t,n){var r=e("./_to-integer"),o=Math.min;t.exports=function(e){return e>0?o(r(e),9007199254740991):0}},{"./_to-integer":33}],36:[function(e,t,n){var r=e("./_defined");t.exports=function(e){return Object(r(e))}},{"./_defined":11}],37:[function(e,t,n){var r=e("./_is-object");t.exports=function(e,t){if(!r(e))return e;var n,o;if(t&&typeof(n=e.toString)=="function"&&!r(o=n.call(e)))return o;if(typeof(n=e.valueOf)=="function"&&!r(o=n.call(e)))return o;if(!t&&typeof(n=e.toString)=="function"&&!r(o=n.call(e)))return o;throw TypeError("Can't convert object to primitive value")}},{"./_is-object":22}],38:[function(e,t,n){var r=0,o=Math.random();t.exports=function(e){return"Symbol(".concat(e===undefined?"":e,")_",(++r+o).toString(36))}},{}],39:[function(e,t,n){var r=e("./_export");r(r.S+r.F,"Object",{assign:e("./_object-assign")})},{"./_export":15,"./_object-assign":23}]},{},[1])(1)}); + + +(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.katex=e()}})(function(){var e,t,r;return function e(t,r,a){function i(l,s){if(!r[l]){if(!t[l]){var o=typeof require=="function"&&require;if(!s&&o)return o(l,!0);if(n)return n(l,!0);var u=new Error("Cannot find module '"+l+"'");throw u.code="MODULE_NOT_FOUND",u}var f=r[l]={exports:{}};t[l][0].call(f.exports,function(e){var r=t[l][1][e];return i(r?r:e)},f,f.exports,e,t,r,a)}return r[l].exports}var n=typeof require=="function"&&require;for(var l=0;l=0;--f){a=i[f];if(a.text==="#"){if(f===0){throw new c.default("Incomplete placeholder at end of macro body",a)}a=i[--f];if(a.text==="#"){i.splice(f+1,1)}else if(/^[1-9]$/.test(a.text)){i.splice.apply(i,[f,2].concat(u[a.text-1]))}else{throw new c.default("Not a valid argument number",a)}}}}this.stack=this.stack.concat(i)}}},{key:"get",value:function e(t){this.discardedWhiteSpace=[];var r=this.nextToken();if(t){while(r.text===" "){this.discardedWhiteSpace.push(r);r=this.nextToken()}}return r}},{key:"unget",value:function e(t){this.stack.push(t);while(this.discardedWhiteSpace.length!==0){this.stack.push(this.discardedWhiteSpace.pop())}}}]);return e}();t.exports=m},{"./Lexer":26,"./ParseError":29,"./macros":44,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5,"object-assign":25}],28:[function(e,t,r){"use strict";var a=e("babel-runtime/helpers/classCallCheck");var i=u(a);var n=e("babel-runtime/helpers/createClass");var l=u(n);var s=e("./fontMetrics");var o=u(s);function u(e){return e&&e.__esModule?e:{default:e}}var f=6;var d=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]];var c=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488];var h=function e(t,r){return r.size<2?t:d[t-1][r.size-1]};var v=function(){function e(t){(0,i.default)(this,e);this.style=t.style;this.color=t.color;this.size=t.size||f;this.textSize=t.textSize||this.size;this.phantom=t.phantom;this.font=t.font;this.sizeMultiplier=c[this.size-1];this._fontMetrics=null}(0,l.default)(e,[{key:"extend",value:function t(r){var a={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font};for(var i in r){if(r.hasOwnProperty(i)){a[i]=r[i]}}return new e(a)}},{key:"havingStyle",value:function e(t){if(this.style===t){return this}else{return this.extend({style:t,size:h(this.textSize,t)})}}},{key:"havingCrampedStyle",value:function e(){return this.havingStyle(this.style.cramp())}},{key:"havingSize",value:function e(t){if(this.size===t&&this.textSize===t){return this}else{return this.extend({style:this.style.text(),size:t,textSize:t})}}},{key:"havingBaseStyle",value:function e(t){t=t||this.style.text();var r=h(f,t);if(this.size===r&&this.textSize===f&&this.style===t){return this}else{return this.extend({style:t,size:r,baseSize:f})}}},{key:"withColor",value:function e(t){return this.extend({color:t})}},{key:"withPhantom",value:function e(){return this.extend({phantom:true})}},{key:"withFont",value:function e(t){return this.extend({font:t||this.font})}},{key:"sizingClasses",value:function e(t){if(t.size!==this.size){return["sizing","reset-size"+t.size,"size"+this.size]}else{return[]}}},{key:"baseSizingClasses",value:function e(){if(this.size!==f){return["sizing","reset-size"+this.size,"size"+f]}else{return[]}}},{key:"fontMetrics",value:function e(){if(!this._fontMetrics){this._fontMetrics=o.default.getFontMetrics(this.size)}return this._fontMetrics}},{key:"getColor",value:function t(){if(this.phantom){return"transparent"}else{return e.colorMap[this.color]||this.color}}}]);return e}();v.colorMap={"katex-blue":"#6495ed","katex-orange":"#ffa500","katex-pink":"#ff00af","katex-red":"#df0030","katex-green":"#28ae7b","katex-gray":"gray","katex-purple":"#9d38bd","katex-blueA":"#ccfaff","katex-blueB":"#80f6ff","katex-blueC":"#63d9ea","katex-blueD":"#11accd","katex-blueE":"#0c7f99","katex-tealA":"#94fff5","katex-tealB":"#26edd5","katex-tealC":"#01d1c1","katex-tealD":"#01a995","katex-tealE":"#208170","katex-greenA":"#b6ffb0","katex-greenB":"#8af281","katex-greenC":"#74cf70","katex-greenD":"#1fab54","katex-greenE":"#0d923f","katex-goldA":"#ffd0a9","katex-goldB":"#ffbb71","katex-goldC":"#ff9c39","katex-goldD":"#e07d10","katex-goldE":"#a75a05","katex-redA":"#fca9a9","katex-redB":"#ff8482","katex-redC":"#f9685d","katex-redD":"#e84d39","katex-redE":"#bc2612","katex-maroonA":"#ffbde0","katex-maroonB":"#ff92c6","katex-maroonC":"#ed5fa6","katex-maroonD":"#ca337c","katex-maroonE":"#9e034e","katex-purpleA":"#ddd7ff","katex-purpleB":"#c6b9fc","katex-purpleC":"#aa87ff","katex-purpleD":"#7854ab","katex-purpleE":"#543b78","katex-mintA":"#f5f9e8","katex-mintB":"#edf2df","katex-mintC":"#e0e5cc","katex-grayA":"#f6f7f7","katex-grayB":"#f0f1f2","katex-grayC":"#e3e5e6","katex-grayD":"#d6d8da","katex-grayE":"#babec2","katex-grayF":"#888d93","katex-grayG":"#626569","katex-grayH":"#3b3e40","katex-grayI":"#21242c","katex-kaBlue":"#314453","katex-kaGreen":"#71B307"};v.BASESIZE=f;t.exports=v},{"./fontMetrics":41,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5}],29:[function(e,t,r){"use strict";var a=e("babel-runtime/helpers/classCallCheck");var i=n(a);function n(e){return e&&e.__esModule?e:{default:e}}var l=function e(t,r){(0,i.default)(this,e);var a="KaTeX parse error: "+t;var n=void 0;var l=void 0;if(r&&r.lexer&&r.start<=r.end){var s=r.lexer.input;n=r.start;l=r.end;if(n===s.length){a+=" at end of input: "}else{a+=" at position "+(n+1)+": "}var o=s.slice(n,l).replace(/[^]/g,"$&\u0332");var u=void 0;if(n>15){u="\u2026"+s.slice(n-15,n)}else{u=s.slice(0,n)}var f=void 0;if(l+15e.SUPSUB_GREEDINESS){return this.parseFunction(n)}else{throw new S.default("Got function '"+n.result+"' with no arguments "+"as "+r,a)}}else{return n.result}}},{key:"handleUnsupportedCmd",value:function e(){var t=this.nextToken.text;var r=[];for(var a=0;ai){c=this.parseFunction(d)}else{throw new S.default("Got function '"+d.result+"' as "+"argument to '"+t+"'",u)}}else{c=d.result}l.push(c);n.push(this.pos)}l.push(n);return l}},{key:"parseGroupOfType",value:function e(t,r){var a=this.mode;if(t==="original"){t=a}if(t==="color"){return this.parseColorGroup(r)}if(t==="size"){return this.parseSizeGroup(r)}this.switchMode(t);if(t==="text"){this.consumeSpaces()}var i=this.parseGroup(r);this.switchMode(a);return i}},{key:"consumeSpaces",value:function e(){while(this.nextToken.text===" "){this.consume()}}},{key:"parseStringGroup",value:function e(t,r){if(r&&this.nextToken.text!=="["){return null}var a=this.mode;this.mode="text";this.expect(r?"[":"{");var i="";var n=this.nextToken;var l=n;while(this.nextToken.text!==(r?"]":"}")){if(this.nextToken.text==="EOF"){throw new S.default("Unexpected end of input in "+t,n.range(this.nextToken,i))}l=this.nextToken;i+=l.text;this.consume()}this.mode=a;this.expect(r?"]":"}");return n.range(l,i)}},{key:"parseRegexGroup",value:function e(t,r){var a=this.mode;this.mode="text";var i=this.nextToken;var n=i;var l="";while(this.nextToken.text!=="EOF"&&t.test(l+this.nextToken.text)){n=this.nextToken;l+=n.text;this.consume()}if(l===""){throw new S.default("Invalid "+r+": '"+i.text+"'",i)}this.mode=a;return i.range(n,l)}},{key:"parseColorGroup",value:function e(t){var r=this.parseStringGroup("color",t);if(!r){return null}var a=/^(#[a-z0-9]+|[a-z]+)$/i.exec(r.text);if(!a){throw new S.default("Invalid color: '"+r.text+"'",r)}return new z(new w.default("color",a[0],this.mode),false)}},{key:"parseSizeGroup",value:function e(t){var r=void 0;if(!t&&this.nextToken.text!=="{"){r=this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size")}else{r=this.parseStringGroup("size",t)}if(!r){return null}var a=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(r.text);if(!a){throw new S.default("Invalid size: '"+r.text+"'",r)}var i={number:+(a[1]+a[2]),unit:a[3]};if(!y.default.validUnit(i)){throw new S.default("Invalid unit: '"+i.unit+"'",r)}return new z(new w.default("size",i,this.mode),false)}},{key:"parseGroup",value:function e(t){var r=this.nextToken;if(this.nextToken.text===(t?"[":"{")){this.consume();var a=this.parseExpression(false,t?"]":null);var i=this.nextToken;this.expect(t?"]":"}");if(this.mode==="text"){this.formLigatures(a)}return new z(new w.default("ordgroup",a,this.mode,r,i),false)}else{return t?null:this.parseSymbol()}}},{key:"formLigatures",value:function e(t){var r=t.length-1;for(var a=0;a=2}}]);return e}();var u=0;var f=1;var d=2;var c=3;var h=4;var v=5;var p=6;var m=7;var g=[new o(u,0,false),new o(f,0,true),new o(d,1,false),new o(c,1,true),new o(h,2,false),new o(v,2,true),new o(p,3,false),new o(m,3,true)];var y=[h,v,h,v,p,m,p,m];var b=[v,v,v,v,m,m,m,m];var x=[d,c,h,v,p,m,p,m];var w=[c,c,v,v,m,m,m,m];var k=[f,f,c,c,v,v,m,m];var S=[u,f,d,c,d,c,d,c];t.exports={DISPLAY:g[u],TEXT:g[d],SCRIPT:g[h],SCRIPTSCRIPT:g[p]}},{"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5}],34:[function(e,t,r){"use strict";var a=e("./domTree");var i=d(a);var n=e("./fontMetrics");var l=d(n);var s=e("./symbols");var o=d(s);var u=e("./utils");var f=d(u);function d(e){return e&&e.__esModule?e:{default:e}}var c=["\\imath","\\jmath","\\pounds"];var h=function e(t,r,a){if(o.default[a][t]&&o.default[a][t].replace){t=o.default[a][t].replace}return{value:t,metrics:l.default.getCharacterMetrics(t,r)}};var v=function e(t,r,a,n,l){var s=h(t,r,a);var o=s.metrics;t=s.value;var u=void 0;if(o){var f=o.italic;if(a==="text"){f=0}u=new i.default.symbolNode(t,o.height,o.depth,f,o.skew,l)}else{typeof console!=="undefined"&&console.warn("No character metrics for '"+t+"' in style '"+r+"'");u=new i.default.symbolNode(t,0,0,0,0,l)}if(n){u.maxFontSize=n.sizeMultiplier;if(n.style.isTight()){u.classes.push("mtight")}if(n.getColor()){u.style.color=n.getColor()}}return u};var p=function e(t,r,a,i){if(t==="\\"||o.default[r][t].font==="main"){return v(t,"Main-Regular",r,a,i)}else{return v(t,"AMS-Regular",r,a,i.concat(["amsrm"]))}};var m=function e(t,r,a,i,n){if(n==="mathord"){var l=g(t,r,a,i);return v(t,l.fontName,r,a,i.concat([l.fontClass]))}else if(n==="textord"){var s=o.default[r][t]&&o.default[r][t].font;if(s==="ams"){return v(t,"AMS-Regular",r,a,i.concat(["amsrm"]))}else{return v(t,"Main-Regular",r,a,i.concat(["mathrm"]))}}else{throw new Error("unexpected type: "+n+" in mathDefault")}};var g=function e(t,r,a,i){if(/[0-9]/.test(t.charAt(0))||f.default.contains(c,t)){return{fontName:"Main-Italic",fontClass:"mainit"}}else{return{fontName:"Math-Italic",fontClass:"mathit" +}}};var y=function e(t,r,a){var i=t.mode;var n=t.value;var l=["mord"];var s=r.font;if(s){var o=void 0;if(s==="mathit"||f.default.contains(c,n)){o=g(n,i,r,l)}else{o=z[s]}if(h(n,o.fontName,i).metrics){return v(n,o.fontName,i,r,l.concat([o.fontClass||s]))}else{return m(n,i,r,l,a)}}else{return m(n,i,r,l,a)}};var b=function e(t){var r=0;var a=0;var i=0;if(t.children){for(var n=0;nr){r=t.children[n].height}if(t.children[n].depth>a){a=t.children[n].depth}if(t.children[n].maxFontSize>i){i=t.children[n].maxFontSize}}}t.height=r;t.depth=a;t.maxFontSize=i};var x=function e(t,r,a){var n=new i.default.span(t,r,a);b(n);return n};var w=function e(t,r){t.children=r.concat(t.children);b(t)};var k=function e(t){var r=new i.default.documentFragment(t);b(r);return r};var S=function e(t,r,a,n){var l=void 0;var s=void 0;var o=void 0;if(r==="individualShift"){var u=t;t=[u[0]];l=-u[0].shift-u[0].elem.depth;s=l;for(o=1;o0){s+=b;d-=b}}var x=[{type:"elem",elem:i,shift:d,marginRight:p},{type:"elem",elem:a,shift:-s,marginRight:p}];if(r instanceof v.default.symbolNode){x[0].marginLeft=-r.italic+"em"}m=f.default.makeVList(x,"individualShift",null,t)}var w=N(r)||"mord";return(0,u.makeSpan)([w],[r,(0,u.makeSpan)(["msupsub"],[m])],t)};O.genfrac=function(e,t){var r=t.style;if(e.value.size==="display"){r=o.default.DISPLAY}else if(e.value.size==="text"){r=o.default.TEXT}var a=r.fracNum();var i=r.fracDen();var n=void 0;n=t.havingStyle(a);var l=L(e.value.numer,n,t);n=t.havingStyle(i);var s=L(e.value.denom,n,t);var d=void 0;var h=void 0;var v=void 0;if(e.value.hasBarLine){d=R("frac-line",t);h=d.height;v=d.height}else{d=null;h=0;v=t.fontMetrics().defaultRuleThickness}var p=void 0;var m=void 0;var g=void 0;if(r.size===o.default.DISPLAY.size){p=t.fontMetrics().num1;if(h>0){m=3*v}else{m=7*v}g=t.fontMetrics().denom1}else{if(h>0){p=t.fontMetrics().num2;m=v}else{p=t.fontMetrics().num3;m=3*v}g=t.fontMetrics().denom2}var y=void 0;if(h===0){var b=p-l.depth-(s.height-g);if(b0){C+=b;if(S=n){continue}var P=void 0;if(a>0||e.value.hskipBeforeAndAfter){P=y.default.deflt(E.pregap,d);if(P!==0){q=(0,u.makeSpan)(["arraycolsep"],[]);q.style.width=P+"em";A.push(q)}}var F=[];for(r=0;rr.height+r.depth+l){l=(l+m-r.height-r.depth)/2}var g=-(r.height+l+v)+h.height;h.style.top=g+"em";h.height-=g;h.depth+=g;var y=void 0;if(r.height===0&&r.depth===0){y=(0,u.makeSpan)()}else{y=f.default.makeVList([{type:"elem",elem:r},{type:"kern",size:l},{type:"elem",elem:p},{type:"kern",size:v}],"firstBaseline",null,t)}if(!e.value.index){return(0,u.makeSpan)(["mord","sqrt"],[h,y],t)}else{var b=t.havingStyle(o.default.SCRIPTSCRIPT);var x=L(e.value.index,b,t);var w=Math.max(h.height,y.height);var k=Math.max(h.depth,y.depth);var S=.6*(w-k);var M=f.default.makeVList([{type:"elem",elem:x}],"shift",-S,t);var z=(0,u.makeSpan)(["root"],[M]);return(0,u.makeSpan)(["mord","sqrt"],[z,h,y],t)}};function P(e,t,r){var a=T(e,t,false);var i=t.sizeMultiplier/r.sizeMultiplier;for(var n=0;n0){var m="calc(100% - "+2*s+"em) 100%";h.style.backgroundSize=m}h=f.default.makeVList([{type:"elem",elem:n},{type:"elem",elem:h}],"firstBaseline",null,t)}var g=(0,u.makeSpan)(["mord","accent"],[h],t);if(a){a.children[0]=g;a.height=Math.max(g.height,a.height);a.classes[0]="mord";return a}else{return g}};O.horizBrace=function(e,t){var r=t.style;var a=e.type==="supsub";var i=void 0;var n=void 0;if(a){if(e.value.sup){n=t.havingStyle(r.sup());i=L(e.value.sup,n,t)}else{n=t.havingStyle(r.sub());i=L(e.value.sub,n,t)}e=e.value.base}var l=L(e.value.base,t.havingBaseStyle(o.default.DISPLAY));var s=x.default.svgSpan(e,t);var d=void 0;if(e.value.isOver){d=f.default.makeVList([{type:"elem",elem:l},{type:"kern",size:.1},{type:"elem",elem:s}],"firstBaseline",null,t)}else{d=f.default.makeVList([{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:l}],"bottom",l.depth+.1+s.height,t)}if(a){var c=(0,u.makeSpan)(["mord",e.value.isOver?"mover":"munder"],[d],t);if(e.value.isOver){d=f.default.makeVList([{type:"elem",elem:c},{type:"kern",size:.2},{type:"elem",elem:i}],"firstBaseline",null,t)}else{d=f.default.makeVList([{type:"elem",elem:i},{type:"kern",size:.2},{type:"elem",elem:c}],"bottom",c.depth+.2+i.height,t)}}return(0,u.makeSpan)(["mord",e.value.isOver?"mover":"munder"],[d],t)};O.accentUnder=function(e,t){var r=L(e.value.body,t);var a=x.default.svgSpan(e,t);var i=/tilde/.test(e.value.label)?.12:0;var n=f.default.makeVList([{type:"elem",elem:a},{type:"kern",size:i},{type:"elem",elem:r}],"bottom",a.height+i,t);return(0,u.makeSpan)(["mord","accentunder"],[n],t)};O.enclose=function(e,t){var r=L(e.value.body,t);var a=e.value.label.substr(1);var i=t.sizeMultiplier;var n=void 0;var l=0;var s=0;if(a==="sout"){n=(0,u.makeSpan)(["stretchy","sout"]);n.height=t.fontMetrics().defaultRuleThickness/i;n.maxFontSize=1;s=-.5*t.fontMetrics().xHeight}else{r.classes.push(a==="fbox"?"boxpad":"cancel-pad");var o=_(e.value.body);l=a==="fbox"?.34:o?.2:0;s=r.depth+l;n=x.default.encloseSpan(r,o,a,l,t)}var d=f.default.makeVList([{type:"elem",elem:r,shift:0},{type:"elem",elem:n,shift:s}],"individualShift",null,t);if(/cancel/.test(a)){return(0,u.makeSpan)(["mord","cancel-lap"],[d],t)}else{return(0,u.makeSpan)(["mord"],[d],t)}};O.xArrow=function(e,t){var r=t.style;var a=t.havingStyle(r.sup());var i=L(e.value.body,a,t);i.classes.push("x-arrow-pad");var n=void 0;if(e.value.below){a=t.havingStyle(r.sub());n=L(e.value.below,a,t);n.classes.push("x-arrow-pad")}var l=x.default.svgSpan(e,t);var s=-t.fontMetrics().axisHeight+l.depth;var o=-t.fontMetrics().axisHeight-l.height-.111;var d=void 0;if(e.value.below){var c=-t.fontMetrics().axisHeight+n.height+l.height+.111;d=f.default.makeVList([{type:"elem",elem:i,shift:o},{type:"elem",elem:l,shift:s},{type:"elem",elem:n,shift:c}],"individualShift",null,t)}else{d=f.default.makeVList([{type:"elem",elem:i,shift:o},{type:"elem",elem:l,shift:s}],"individualShift",null,t)}return(0,u.makeSpan)(["mrel","x-arrow"],[d],t)};O.phantom=function(e,t){var r=T(e.value.value,t.withPhantom(),false);return new f.default.makeFragment(r)};O.mclass=function(e,t){var r=T(e.value.value,t,true);return(0,u.makeSpan)([e.value.mclass],r,t)};var L=function e(t,r,a){if(!t){return(0,u.makeSpan)()}if(O[t.type]){var i=O[t.type](t,r);if(a&&r.size!==a.size){i=(0,u.makeSpan)(r.sizingClasses(a),[i],r);var n=r.sizeMultiplier/a.sizeMultiplier;i.height*=n;i.depth*=n}return i}else{throw new l.default("Got group of unknown type: '"+t.type+"'")}};var F=function e(t,r){t=JSON.parse((0,i.default)(t));var a=T(t,r,true);var n=(0,u.makeSpan)(["base"],a,r);var l=(0,u.makeSpan)(["strut"]);var s=(0,u.makeSpan)(["strut","bottom"]);l.style.height=n.height+"em";s.style.height=n.height+n.depth+"em";s.style.verticalAlign=-n.depth+"em";var o=(0,u.makeSpan)(["katex-html"],[l,s,n]);o.setAttribute("aria-hidden","true");return o};t.exports=F},{"./ParseError":29,"./Style":33,"./buildCommon":34,"./delimiter":38,"./domTree":39,"./stretchy":47,"./units":50,"./utils":51,"babel-runtime/core-js/json/stringify":2}],36:[function(e,t,r){"use strict";var a=e("./buildCommon");var i=b(a);var n=e("./fontMetrics");var l=b(n);var s=e("./mathMLTree");var o=b(s);var u=e("./ParseError");var f=b(u);var d=e("./Style");var c=b(d);var h=e("./symbols");var v=b(h);var p=e("./utils");var m=b(p);var g=e("./stretchy");var y=b(g);function b(e){return e&&e.__esModule?e:{default:e}}var x=function e(t,r){if(v.default[r][t]&&v.default[r][t].replace){t=v.default[r][t].replace}return new o.default.TextNode(t)};var w=function e(t,r){var i=r.font;if(!i){return null}var n=t.mode;if(i==="mathit"){return"italic"}var s=t.value;if(m.default.contains(["\\imath","\\jmath"],s)){return null}if(v.default[n][s]&&v.default[n][s].replace){s=v.default[n][s].replace}var o=a.fontMap[i].fontName;if(l.default.getCharacterMetrics(s,o)){return a.fontMap[r.font].variant}return null};var k={};var S={mi:"italic",mn:"normal",mtext:"normal"};k.mathord=function(e,t){var r=new o.default.MathNode("mi",[x(e.value,e.mode)]);var a=w(e,t)||"italic";if(a!==S[r.type]){r.setAttribute("mathvariant",a)}return r};k.textord=function(e,t){var r=x(e.value,e.mode);var a=w(e,t)||"normal";var i=void 0;if(e.mode==="text"){i=new o.default.MathNode("mtext",[r])}else if(/[0-9]/.test(e.value)){i=new o.default.MathNode("mn",[r])}else if(e.value==="\\prime"){i=new o.default.MathNode("mo",[r])}else{i=new o.default.MathNode("mi",[r])}if(a!==S[i.type]){i.setAttribute("mathvariant",a)}return i};k.bin=function(e){var t=new o.default.MathNode("mo",[x(e.value,e.mode)]);return t};k.rel=function(e){var t=new o.default.MathNode("mo",[x(e.value,e.mode)]);return t};k.open=function(e){var t=new o.default.MathNode("mo",[x(e.value,e.mode)]);return t};k.close=function(e){var t=new o.default.MathNode("mo",[x(e.value,e.mode)]);return t};k.inner=function(e){var t=new o.default.MathNode("mo",[x(e.value,e.mode)]);return t};k.punct=function(e){var t=new o.default.MathNode("mo",[x(e.value,e.mode)]);t.setAttribute("separator","true");return t};k.ordgroup=function(e,t){var r=M(e.value,t);var a=new o.default.MathNode("mrow",r);return a};k.text=function(e,t){var r=e.value.body;var a=[];var i=null;for(var n=0;n2&&arguments[2]!==undefined?arguments[2]:false;if(!t){return new o.default.MathNode("mrow")}if(k[t.type]){var i=k[t.type](t,r);if(a){if(i.type==="mrow"&&i.children.length===1){return i.children[0]}}return i}else{throw new f.default("Got group of unknown type: '"+t.type+"'")}};var C=function e(t,r,i){var n=M(t,i);var l=new o.default.MathNode("mrow",n);var s=new o.default.MathNode("annotation",[new o.default.TextNode(r)]);s.setAttribute("encoding","application/x-tex");var u=new o.default.MathNode("semantics",[l,s]);var f=new o.default.MathNode("math",[u]);return(0,a.makeSpan)(["katex-mathml"],[f])};t.exports=C},{"./ParseError":29,"./Style":33,"./buildCommon":34,"./fontMetrics":41,"./mathMLTree":45,"./stretchy":47,"./symbols":48,"./utils":51}],37:[function(e,t,r){"use strict";var a=e("./buildHTML");var i=v(a);var n=e("./buildMathML");var l=v(n);var s=e("./buildCommon");var o=e("./Options");var u=v(o);var f=e("./Settings");var d=v(f);var c=e("./Style");var h=v(c);function v(e){return e&&e.__esModule?e:{default:e}}var p=function e(t,r,a){a=a||new d.default({});var n=h.default.TEXT;if(a.displayMode){n=h.default.DISPLAY}var o=new u.default({style:n});var f=(0,l.default)(t,r,o);var c=(0,i.default)(t,o);var v=(0,s.makeSpan)(["katex"],[f,c]);if(a.displayMode){return(0,s.makeSpan)(["katex-display"],[v])}else{return v}};t.exports=p},{"./Options":28,"./Settings":32,"./Style":33,"./buildCommon":34,"./buildHTML":35,"./buildMathML":36}],38:[function(e,t,r){"use strict";var a=e("./ParseError");var i=p(a);var n=e("./Style");var l=p(n);var s=e("./buildCommon");var o=p(s);var u=e("./fontMetrics");var f=p(u);var d=e("./symbols");var c=p(d);var h=e("./utils");var v=p(h);function p(e){return e&&e.__esModule?e:{default:e}}var m=function e(t,r){if(c.default.math[t]&&c.default.math[t].replace){return f.default.getCharacterMetrics(c.default.math[t].replace,r)}else{return f.default.getCharacterMetrics(t,r)}};var g=function e(t,r,a,i){var n=a.havingBaseStyle(r);var l=(0,s.makeSpan)((i||[]).concat(n.sizingClasses(a)),[t],a);l.delimSizeMultiplier=n.sizeMultiplier/a.sizeMultiplier;l.height*=l.delimSizeMultiplier;l.depth*=l.delimSizeMultiplier;l.maxFontSize=n.sizeMultiplier;return l};var y=function e(t,r,a){var i=r.havingBaseStyle(a);var n=(1-r.sizeMultiplier/i.sizeMultiplier)*r.fontMetrics().axisHeight;t.classes.push("delimcenter");t.style.top=n+"em";t.height-=n;t.depth+=n};var b=function e(t,r,a,i,n,l){var s=o.default.makeSymbol(t,"Main-Regular",n,i);var u=g(s,r,i,l);if(a){y(u,i,r)}return u};var x=function e(t,r,a,i){return o.default.makeSymbol(t,"Size"+r+"-Regular",a,i)};var w=function e(t,r,a,i,n,o){var u=x(t,r,n,i);var f=g((0,s.makeSpan)(["delimsizing","size"+r],[u],i),l.default.TEXT,i,o);if(a){y(f,i,l.default.TEXT)}return f};var k=function e(t,r,a){var i=void 0;if(r==="Size1-Regular"){i="delim-size1"}else if(r==="Size4-Regular"){i="delim-size4"}var n=(0,s.makeSpan)(["delimsizinginner",i],[(0,s.makeSpan)([],[o.default.makeSymbol(t,r,a)])]);return{type:"elem",elem:n}};var S=function e(t,r,a,i,n,u){var f=void 0;var d=void 0;var c=void 0;var h=void 0;f=c=h=t;d=null;var v="Size1-Regular";if(t==="\\uparrow"){c=h="\u23d0"}else if(t==="\\Uparrow"){c=h="\u2016"}else if(t==="\\downarrow"){f=c="\u23d0"}else if(t==="\\Downarrow"){f=c="\u2016"}else if(t==="\\updownarrow"){f="\\uparrow";c="\u23d0";h="\\downarrow"}else if(t==="\\Updownarrow"){f="\\Uparrow";c="\u2016";h="\\Downarrow"}else if(t==="["||t==="\\lbrack"){f="\u23a1";c="\u23a2";h="\u23a3";v="Size4-Regular"}else if(t==="]"||t==="\\rbrack"){f="\u23a4";c="\u23a5";h="\u23a6";v="Size4-Regular"}else if(t==="\\lfloor"){c=f="\u23a2";h="\u23a3";v="Size4-Regular"}else if(t==="\\lceil"){f="\u23a1";c=h="\u23a2";v="Size4-Regular"}else if(t==="\\rfloor"){c=f="\u23a5";h="\u23a6";v="Size4-Regular"}else if(t==="\\rceil"){f="\u23a4";c=h="\u23a5";v="Size4-Regular"}else if(t==="("){f="\u239b";c="\u239c";h="\u239d";v="Size4-Regular"}else if(t===")"){f="\u239e";c="\u239f";h="\u23a0";v="Size4-Regular"}else if(t==="\\{"||t==="\\lbrace"){f="\u23a7";d="\u23a8";h="\u23a9";c="\u23aa";v="Size4-Regular"}else if(t==="\\}"||t==="\\rbrace"){f="\u23ab";d="\u23ac";h="\u23ad";c="\u23aa";v="Size4-Regular"}else if(t==="\\lgroup"){f="\u23a7";h="\u23a9";c="\u23aa";v="Size4-Regular"}else if(t==="\\rgroup"){f="\u23ab";h="\u23ad";c="\u23aa";v="Size4-Regular"}else if(t==="\\lmoustache"){f="\u23a7";h="\u23ad";c="\u23aa";v="Size4-Regular"}else if(t==="\\rmoustache"){f="\u23ab";h="\u23a9";c="\u23aa";v="Size4-Regular"}else if(t==="\\surd"){f="\ue001";h="\u23b7";c="\ue000";v="Size4-Regular"}var p=m(f,v);var y=p.height+p.depth;var b=m(c,v);var x=b.height+b.depth;var w=m(h,v);var S=w.height+w.depth;var M=0;var z=1;if(d!==null){var C=m(d,v);M=C.height+C.depth;z=2}var T=y+S+M;var N=Math.ceil((r-T)/(z*x));var A=T+N*z*x;var q=i.fontMetrics().axisHeight;if(a){q*=i.sizeMultiplier}var _=A/2-q;var E=[];E.push(k(h,v,n));if(d===null){for(var O=0;O","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"];var T=[0,1.2,1.8,2.4,3];var N=function e(t,r,a,n,l){if(t==="<"||t==="\\lt"){t="\\langle"}else if(t===">"||t==="\\gt"){t="\\rangle"}if(v.default.contains(M,t)||v.default.contains(C,t)){return w(t,r,false,a,n,l)}else if(v.default.contains(z,t)){return S(t,T[r],false,a,n,l)}else{throw new i.default("Illegal delimiter: '"+t+"'")}};var A=[{type:"small",style:l.default.SCRIPTSCRIPT},{type:"small",style:l.default.SCRIPT},{type:"small",style:l.default.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}];var q=[{type:"small",style:l.default.SCRIPTSCRIPT},{type:"small",style:l.default.SCRIPT},{type:"small",style:l.default.TEXT},{type:"stack"}];var _=[{type:"small",style:l.default.SCRIPTSCRIPT},{type:"small",style:l.default.SCRIPT},{type:"small",style:l.default.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}];var E=function e(t){if(t.type==="small"){return"Main-Regular"}else if(t.type==="large"){return"Size"+t.size+"-Regular"}else if(t.type==="stack"){return"Size4-Regular"}};var O=function e(t,r,a,i){var n=Math.min(2,3-i.style.size);for(var l=n;lr){return a[l]}}return a[a.length-1]};var R=function e(t,r,a,i,n,l){if(t==="<"||t==="\\lt"){t="\\langle"}else if(t===">"||t==="\\gt"){t="\\rangle"}var s=void 0;if(v.default.contains(C,t)){s=A}else if(v.default.contains(M,t)){s=_}else{s=q}var o=O(t,r,s,i);if(o.type==="small"){return b(t,o.style,a,i,n,l)}else if(o.type==="large"){return w(t,o.size,a,i,n,l)}else if(o.type==="stack"){return S(t,r,a,i,n,l)}};var P=function e(t,r,a,i,n,l){var s=i.fontMetrics().axisHeight*i.sizeMultiplier;var o=901;var u=5/i.fontMetrics().ptPerEm;var f=Math.max(r-s,a+s);var d=Math.max(f/500*o,2*f-u);return R(t,d,true,i,n,l)};t.exports={sizedDelim:N,customSizedDelim:R,leftRightDelim:P}},{"./ParseError":29,"./Style":33,"./buildCommon":34,"./fontMetrics":41,"./symbols":48,"./utils":51}],39:[function(e,t,r){"use strict";var a=e("babel-runtime/helpers/classCallCheck");var i=d(a);var n=e("babel-runtime/helpers/createClass");var l=d(n);var s=e("./unicodeRegexes");var o=d(s);var u=e("./utils");var f=d(u);function d(e){return e&&e.__esModule?e:{default:e}}var c=function e(t){t=t.slice();for(var r=t.length-1;r>=0;r--){if(!t[r]){t.splice(r,1)}}return t.join(" ")};var h=function(){function e(t,r,a){(0,i.default)(this,e);this.classes=t||[];this.children=r||[];this.height=0;this.depth=0;this.maxFontSize=0;this.style={};this.attributes={};if(a){if(a.style.isTight()){this.classes.push("mtight")}if(a.getColor()){this.style.color=a.getColor()}}}(0,l.default)(e,[{key:"setAttribute",value:function e(t,r){this.attributes[t]=r}},{key:"tryCombine",value:function e(t){return false}},{key:"toNode",value:function e(){var t=document.createElement("span");t.className=c(this.classes);for(var r in this.style){if(Object.prototype.hasOwnProperty.call(this.style,r)){t.style[r]=this.style[r]}}for(var a in this.attributes){if(Object.prototype.hasOwnProperty.call(this.attributes,a)){t.setAttribute(a,this.attributes[a])}}for(var i=0;i";return t}}]);return e}();var v=function(){function e(t){(0,i.default)(this,e);this.children=t||[];this.height=0;this.depth=0;this.maxFontSize=0}(0,l.default)(e,[{key:"toNode",value:function e(){var t=document.createDocumentFragment();for(var r=0;r0||c(this.classes)!==c(r.classes)||this.skew!==r.skew||this.maxFontSize!==r.maxFontSize){return false}for(var a in this.style){if(this.style.hasOwnProperty(a)&&this.style[a]!==r.style[a]){return false}}for(var i in r.style){if(r.style.hasOwnProperty(i)&&this.style[i]!==r.style[i]){return false}}this.value+=r.value;this.height=Math.max(this.height,r.height);this.depth=Math.max(this.depth,r.depth);this.italic=r.italic;return true}},{key:"toNode",value:function e(){var t=document.createTextNode(this.value);var r=null;if(this.italic>0){r=document.createElement("span");r.style.marginRight=this.italic+"em"}if(this.classes.length>0){r=r||document.createElement("span");r.className=c(this.classes)}for(var a in this.style){if(this.style.hasOwnProperty(a)){r=r||document.createElement("span");r.style[a]=this.style[a]}}if(r){r.appendChild(t);return r}else{return t}}},{key:"toMarkup",value:function e(){var t=false;var r="0){a+="margin-right:"+this.italic+"em;"}for(var i in this.style){if(this.style.hasOwnProperty(i)){a+=f.default.hyphenate(i)+":"+this.style[i]+";"}}if(a){t=true;r+=' style="'+f.default.escape(a)+'"'}var n=f.default.escape(this.value);if(t){r+=">";r+=n;r+="";return r}else{return n}}}]);return e}();t.exports={span:h,documentFragment:v,symbolNode:m}},{"./unicodeRegexes":49,"./utils":51,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5}],40:[function(e,t,r){"use strict";var a=e("./ParseNode");var i=s(a);var n=e("./ParseError");var l=s(n);function s(e){return e&&e.__esModule?e:{default:e}}function o(e,t,r){var a=[];var n=[a];var s=[];while(true){var o=e.parseExpression(false,null);o=new i.default("ordgroup",o,e.mode);if(r){o=new i.default("styling",{style:r,value:[o]},e.mode)}a.push(o);var u=e.nextToken.text;if(u==="&"){e.consume()}else if(u==="\\end"){break}else if(u==="\\\\"||u==="\\cr"){var f=e.parseFunction();s.push(f.value.size);a=[];n.push(a)}else{throw new l.default("Expected & or \\\\ or \\end",e.nextToken)}}t.body=n;t.rowGaps=s;return new i.default(t.type,t,e.mode)}function u(e,r,a){if(typeof e==="string"){e=[e]}if(typeof r==="number"){r={numArgs:r}}var i={numArgs:r.numArgs||0,argTypes:r.argTypes,greediness:1,allowedInText:!!r.allowedInText,numOptionalArgs:r.numOptionalArgs||0,handler:a};for(var n=0;n0){s=2}t.value.cols[n]={type:"align",align:l,pregap:s,postgap:0}}return t});u("gathered",{},function(e){var t={type:"array",cols:[{type:"align",align:"c"}],addJot:true};t=o(e.parser,t,"display");return t})},{"./ParseError":29,"./ParseNode":30}],41:[function(e,t,r){"use strict";var a=e("./unicodeRegexes");var i=e("./fontMetricsData");var n=l(i);function l(e){return e&&e.__esModule?e:{default:e}}var s={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2]};var o={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xc6":"A","\xc7":"C","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xd0":"D","\xd1":"N","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xdd":"Y","\xde":"o","\xdf":"B","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xe6":"a","\xe7":"c","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xf0":"d","\xf1":"n","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xfd":"y","\xfe":"o","\xff":"y","\u0410":"A","\u0411":"B","\u0412":"B","\u0413":"F","\u0414":"A","\u0415":"E","\u0416":"K","\u0417":"3","\u0418":"N","\u0419":"N","\u041a":"K","\u041b":"N","\u041c":"M","\u041d":"H","\u041e":"O","\u041f":"N","\u0420":"P","\u0421":"C","\u0422":"T","\u0423":"y","\u0424":"O","\u0425":"X","\u0426":"U","\u0427":"h","\u0428":"W","\u0429":"W","\u042a":"B","\u042b":"X","\u042c":"B","\u042d":"3","\u042e":"X","\u042f":"R","\u0430":"a","\u0431":"b","\u0432":"a","\u0433":"r","\u0434":"y","\u0435":"e","\u0436":"m","\u0437":"e","\u0438":"n","\u0439":"n","\u043a":"n","\u043b":"n","\u043c":"m","\u043d":"n","\u043e":"o","\u043f":"n","\u0440":"p","\u0441":"c","\u0442":"o","\u0443":"y","\u0444":"b","\u0445":"x","\u0446":"n","\u0447":"n","\u0448":"w","\u0449":"w","\u044a":"a","\u044b":"m","\u044c":"a","\u044d":"e","\u044e":"m","\u044f":"r"};var u=function e(t,r){var i=t.charCodeAt(0);if(t[0]in o){i=o[t[0]].charCodeAt(0)}else if(a.cjkRegex.test(t[0])){i="M".charCodeAt(0)}var l=n.default[r][i];if(l){return{depth:l[0],height:l[1],italic:l[2],skew:l[3],width:l[4]}}};var f={};var d=function e(t){var r=void 0;if(t>=5){r=0}else if(t>=3){r=1}else{r=2}if(!f[r]){var a=f[r]={};for(var i in s){if(s.hasOwnProperty(i)){a[i]=s[i][r]}}a.cssEmPerMu=a.quad/18}return f[r]};t.exports={getFontMetrics:d,getCharacterMetrics:u}},{"./fontMetricsData":42,"./unicodeRegexes":49}],42:[function(e,t,r){"use strict";t.exports={"AMS-Regular":{65:[0,.68889,0,0],66:[0,.68889,0,0],67:[0,.68889,0,0],68:[0,.68889,0,0],69:[0,.68889,0,0],70:[0,.68889,0,0],71:[0,.68889,0,0],72:[0,.68889,0,0],73:[0,.68889,0,0],74:[.16667,.68889,0,0],75:[0,.68889,0,0],76:[0,.68889,0,0],77:[0,.68889,0,0],78:[0,.68889,0,0],79:[.16667,.68889,0,0],80:[0,.68889,0,0],81:[.16667,.68889,0,0],82:[0,.68889,0,0],83:[0,.68889,0,0],84:[0,.68889,0,0],85:[0,.68889,0,0],86:[0,.68889,0,0],87:[0,.68889,0,0],88:[0,.68889,0,0],89:[0,.68889,0,0],90:[0,.68889,0,0],107:[0,.68889,0,0],165:[0,.675,.025,0],174:[.15559,.69224,0,0],240:[0,.68889,0,0],295:[0,.68889,0,0],710:[0,.825,0,0],732:[0,.9,0,0],770:[0,.825,0,0],771:[0,.9,0,0],989:[.08167,.58167,0,0],1008:[0,.43056,.04028,0],8245:[0,.54986,0,0],8463:[0,.68889,0,0],8487:[0,.68889,0,0],8498:[0,.68889,0,0],8502:[0,.68889,0,0],8503:[0,.68889,0,0],8504:[0,.68889,0,0],8513:[0,.68889,0,0],8592:[-.03598,.46402,0,0],8594:[-.03598,.46402,0,0],8602:[-.13313,.36687,0,0],8603:[-.13313,.36687,0,0],8606:[.01354,.52239,0,0],8608:[.01354,.52239,0,0],8610:[.01354,.52239,0,0],8611:[.01354,.52239,0,0],8619:[0,.54986,0,0],8620:[0,.54986,0,0],8621:[-.13313,.37788,0,0],8622:[-.13313,.36687,0,0],8624:[0,.69224,0,0],8625:[0,.69224,0,0],8630:[0,.43056,0,0],8631:[0,.43056,0,0],8634:[.08198,.58198,0,0],8635:[.08198,.58198,0,0],8638:[.19444,.69224,0,0],8639:[.19444,.69224,0,0],8642:[.19444,.69224,0,0],8643:[.19444,.69224,0,0],8644:[.1808,.675,0,0],8646:[.1808,.675,0,0],8647:[.1808,.675,0,0],8648:[.19444,.69224,0,0],8649:[.1808,.675,0,0],8650:[.19444,.69224,0,0],8651:[.01354,.52239,0,0],8652:[.01354,.52239,0,0],8653:[-.13313,.36687,0,0],8654:[-.13313,.36687,0,0],8655:[-.13313,.36687,0,0],8666:[.13667,.63667,0,0],8667:[.13667,.63667,0,0],8669:[-.13313,.37788,0,0],8672:[-.064,.437,0,0],8674:[-.064,.437,0,0],8705:[0,.825,0,0],8708:[0,.68889,0,0],8709:[.08167,.58167,0,0],8717:[0,.43056,0,0],8722:[-.03598,.46402,0,0],8724:[.08198,.69224,0,0],8726:[.08167,.58167,0,0],8733:[0,.69224,0,0],8736:[0,.69224,0,0],8737:[0,.69224,0,0],8738:[.03517,.52239,0,0],8739:[.08167,.58167,0,0],8740:[.25142,.74111,0,0],8741:[.08167,.58167,0,0],8742:[.25142,.74111,0,0],8756:[0,.69224,0,0],8757:[0,.69224,0,0],8764:[-.13313,.36687,0,0],8765:[-.13313,.37788,0,0],8769:[-.13313,.36687,0,0],8770:[-.03625,.46375,0,0],8774:[.30274,.79383,0,0],8776:[-.01688,.48312,0,0],8778:[.08167,.58167,0,0],8782:[.06062,.54986,0,0],8783:[.06062,.54986,0,0],8785:[.08198,.58198,0,0],8786:[.08198,.58198,0,0],8787:[.08198,.58198,0,0],8790:[0,.69224,0,0],8791:[.22958,.72958,0,0],8796:[.08198,.91667,0,0],8806:[.25583,.75583,0,0],8807:[.25583,.75583,0,0],8808:[.25142,.75726,0,0],8809:[.25142,.75726,0,0],8812:[.25583,.75583,0,0],8814:[.20576,.70576,0,0],8815:[.20576,.70576,0,0],8816:[.30274,.79383,0,0],8817:[.30274,.79383,0,0],8818:[.22958,.72958,0,0],8819:[.22958,.72958,0,0],8822:[.1808,.675,0,0],8823:[.1808,.675,0,0],8828:[.13667,.63667,0,0],8829:[.13667,.63667,0,0],8830:[.22958,.72958,0,0],8831:[.22958,.72958,0,0],8832:[.20576,.70576,0,0],8833:[.20576,.70576,0,0],8840:[.30274,.79383,0,0],8841:[.30274,.79383,0,0],8842:[.13597,.63597,0,0],8843:[.13597,.63597,0,0],8847:[.03517,.54986,0,0],8848:[.03517,.54986,0,0],8858:[.08198,.58198,0,0],8859:[.08198,.58198,0,0],8861:[.08198,.58198,0,0],8862:[0,.675,0,0],8863:[0,.675,0,0],8864:[0,.675,0,0],8865:[0,.675,0,0],8872:[0,.69224,0,0],8873:[0,.69224,0,0],8874:[0,.69224,0,0],8876:[0,.68889,0,0],8877:[0,.68889,0,0],8878:[0,.68889,0,0],8879:[0,.68889,0,0],8882:[.03517,.54986,0,0],8883:[.03517,.54986,0,0],8884:[.13667,.63667,0,0],8885:[.13667,.63667,0,0],8888:[0,.54986,0,0],8890:[.19444,.43056,0,0],8891:[.19444,.69224,0,0],8892:[.19444,.69224,0,0],8901:[0,.54986,0,0],8903:[.08167,.58167,0,0],8905:[.08167,.58167,0,0],8906:[.08167,.58167,0,0],8907:[0,.69224,0,0],8908:[0,.69224,0,0],8909:[-.03598,.46402,0,0],8910:[0,.54986,0,0],8911:[0,.54986,0,0],8912:[.03517,.54986,0,0],8913:[.03517,.54986,0,0],8914:[0,.54986,0,0],8915:[0,.54986,0,0],8916:[0,.69224,0,0],8918:[.0391,.5391,0,0],8919:[.0391,.5391,0,0],8920:[.03517,.54986,0,0],8921:[.03517,.54986,0,0],8922:[.38569,.88569,0,0],8923:[.38569,.88569,0,0],8926:[.13667,.63667,0,0],8927:[.13667,.63667,0,0],8928:[.30274,.79383,0,0],8929:[.30274,.79383,0,0],8934:[.23222,.74111,0,0],8935:[.23222,.74111,0,0],8936:[.23222,.74111,0,0],8937:[.23222,.74111,0,0],8938:[.20576,.70576,0,0],8939:[.20576,.70576,0,0],8940:[.30274,.79383,0,0],8941:[.30274,.79383,0,0],8994:[.19444,.69224,0,0],8995:[.19444,.69224,0,0],9416:[.15559,.69224,0,0],9484:[0,.69224,0,0],9488:[0,.69224,0,0],9492:[0,.37788,0,0],9496:[0,.37788,0,0],9585:[.19444,.68889,0,0],9586:[.19444,.74111,0,0],9632:[0,.675,0,0],9633:[0,.675,0,0],9650:[0,.54986,0,0],9651:[0,.54986,0,0],9654:[.03517,.54986,0,0],9660:[0,.54986,0,0],9661:[0,.54986,0,0],9664:[.03517,.54986,0,0],9674:[.11111,.69224,0,0],9733:[.19444,.69224,0,0],10003:[0,.69224,0,0],10016:[0,.69224,0,0],10731:[.11111,.69224,0,0],10846:[.19444,.75583,0,0],10877:[.13667,.63667,0,0],10878:[.13667,.63667,0,0],10885:[.25583,.75583,0,0],10886:[.25583,.75583,0,0],10887:[.13597,.63597,0,0],10888:[.13597,.63597,0,0],10889:[.26167,.75726,0,0],10890:[.26167,.75726,0,0],10891:[.48256,.98256,0,0],10892:[.48256,.98256,0,0],10901:[.13667,.63667,0,0],10902:[.13667,.63667,0,0],10933:[.25142,.75726,0,0],10934:[.25142,.75726,0,0],10935:[.26167,.75726,0,0],10936:[.26167,.75726,0,0],10937:[.26167,.75726,0,0],10938:[.26167,.75726,0,0],10949:[.25583,.75583,0,0],10950:[.25583,.75583,0,0],10955:[.28481,.79383,0,0],10956:[.28481,.79383,0,0],57350:[.08167,.58167,0,0],57351:[.08167,.58167,0,0],57352:[.08167,.58167,0,0],57353:[0,.43056,.04028,0],57356:[.25142,.75726,0,0],57357:[.25142,.75726,0,0],57358:[.41951,.91951,0,0],57359:[.30274,.79383,0,0],57360:[.30274,.79383,0,0],57361:[.41951,.91951,0,0],57366:[.25142,.75726,0,0],57367:[.25142,.75726,0,0],57368:[.25142,.75726,0,0],57369:[.25142,.75726,0,0],57370:[.13597,.63597,0,0],57371:[.13597,.63597,0,0]},"Caligraphic-Regular":{48:[0,.43056,0,0],49:[0,.43056,0,0],50:[0,.43056,0,0],51:[.19444,.43056,0,0],52:[.19444,.43056,0,0],53:[.19444,.43056,0,0],54:[0,.64444,0,0],55:[.19444,.43056,0,0],56:[0,.64444,0,0],57:[.19444,.43056,0,0],65:[0,.68333,0,.19445],66:[0,.68333,.03041,.13889],67:[0,.68333,.05834,.13889],68:[0,.68333,.02778,.08334],69:[0,.68333,.08944,.11111],70:[0,.68333,.09931,.11111],71:[.09722,.68333,.0593,.11111],72:[0,.68333,.00965,.11111],73:[0,.68333,.07382,0],74:[.09722,.68333,.18472,.16667],75:[0,.68333,.01445,.05556],76:[0,.68333,0,.13889],77:[0,.68333,0,.13889],78:[0,.68333,.14736,.08334],79:[0,.68333,.02778,.11111],80:[0,.68333,.08222,.08334],81:[.09722,.68333,0,.11111],82:[0,.68333,0,.08334],83:[0,.68333,.075,.13889],84:[0,.68333,.25417,0],85:[0,.68333,.09931,.08334],86:[0,.68333,.08222,0],87:[0,.68333,.08222,.08334],88:[0,.68333,.14643,.13889],89:[.09722,.68333,.08222,.08334],90:[0,.68333,.07944,.13889]},"Fraktur-Regular":{33:[0,.69141,0,0],34:[0,.69141,0,0],38:[0,.69141,0,0],39:[0,.69141,0,0],40:[.24982,.74947,0,0],41:[.24982,.74947,0,0],42:[0,.62119,0,0],43:[.08319,.58283,0,0],44:[0,.10803,0,0],45:[.08319,.58283,0,0],46:[0,.10803,0,0],47:[.24982,.74947,0,0],48:[0,.47534,0,0],49:[0,.47534,0,0],50:[0,.47534,0,0],51:[.18906,.47534,0,0],52:[.18906,.47534,0,0],53:[.18906,.47534,0,0],54:[0,.69141,0,0],55:[.18906,.47534,0,0],56:[0,.69141,0,0],57:[.18906,.47534,0,0],58:[0,.47534,0,0],59:[.12604,.47534,0,0],61:[-.13099,.36866,0,0],63:[0,.69141,0,0],65:[0,.69141,0,0],66:[0,.69141,0,0],67:[0,.69141,0,0],68:[0,.69141,0,0],69:[0,.69141,0,0],70:[.12604,.69141,0,0],71:[0,.69141,0,0],72:[.06302,.69141,0,0],73:[0,.69141,0,0],74:[.12604,.69141,0,0],75:[0,.69141,0,0],76:[0,.69141,0,0],77:[0,.69141,0,0],78:[0,.69141,0,0],79:[0,.69141,0,0],80:[.18906,.69141,0,0],81:[.03781,.69141,0,0],82:[0,.69141,0,0],83:[0,.69141,0,0],84:[0,.69141,0,0],85:[0,.69141,0,0],86:[0,.69141,0,0],87:[0,.69141,0,0],88:[0,.69141,0,0],89:[.18906,.69141,0,0],90:[.12604,.69141,0,0],91:[.24982,.74947,0,0],93:[.24982,.74947,0,0],94:[0,.69141,0,0],97:[0,.47534,0,0],98:[0,.69141,0,0],99:[0,.47534,0,0],100:[0,.62119,0,0],101:[0,.47534,0,0],102:[.18906,.69141,0,0],103:[.18906,.47534,0,0],104:[.18906,.69141,0,0],105:[0,.69141,0,0],106:[0,.69141,0,0],107:[0,.69141,0,0],108:[0,.69141,0,0],109:[0,.47534,0,0],110:[0,.47534,0,0],111:[0,.47534,0,0],112:[.18906,.52396,0,0],113:[.18906,.47534,0,0],114:[0,.47534,0,0],115:[0,.47534,0,0],116:[0,.62119,0,0],117:[0,.47534,0,0],118:[0,.52396,0,0],119:[0,.52396,0,0],120:[.18906,.47534,0,0],121:[.18906,.47534,0,0],122:[.18906,.47534,0,0],8216:[0,.69141,0,0],8217:[0,.69141,0,0],58112:[0,.62119,0,0],58113:[0,.62119,0,0],58114:[.18906,.69141,0,0],58115:[.18906,.69141,0,0],58116:[.18906,.47534,0,0],58117:[0,.69141,0,0],58118:[0,.62119,0,0],58119:[0,.47534,0,0]},"Main-Bold":{33:[0,.69444,0,0],34:[0,.69444,0,0],35:[.19444,.69444,0,0],36:[.05556,.75,0,0],37:[.05556,.75,0,0],38:[0,.69444,0,0],39:[0,.69444,0,0],40:[.25,.75,0,0],41:[.25,.75,0,0],42:[0,.75,0,0],43:[.13333,.63333,0,0],44:[.19444,.15556,0,0],45:[0,.44444,0,0],46:[0,.15556,0,0],47:[.25,.75,0,0],48:[0,.64444,0,0],49:[0,.64444,0,0],50:[0,.64444,0,0],51:[0,.64444,0,0],52:[0,.64444,0,0],53:[0,.64444,0,0],54:[0,.64444,0,0],55:[0,.64444,0,0],56:[0,.64444,0,0],57:[0,.64444,0,0],58:[0,.44444,0,0],59:[.19444,.44444,0,0],60:[.08556,.58556,0,0],61:[-.10889,.39111,0,0],62:[.08556,.58556,0,0],63:[0,.69444,0,0],64:[0,.69444,0,0],65:[0,.68611,0,0],66:[0,.68611,0,0],67:[0,.68611,0,0],68:[0,.68611,0,0],69:[0,.68611,0,0],70:[0,.68611,0,0],71:[0,.68611,0,0],72:[0,.68611,0,0],73:[0,.68611,0,0],74:[0,.68611,0,0],75:[0,.68611,0,0],76:[0,.68611,0,0],77:[0,.68611,0,0],78:[0,.68611,0,0],79:[0,.68611,0,0],80:[0,.68611,0,0],81:[.19444,.68611,0,0],82:[0,.68611,0,0],83:[0,.68611,0,0],84:[0,.68611,0,0],85:[0,.68611,0,0],86:[0,.68611,.01597,0],87:[0,.68611,.01597,0],88:[0,.68611,0,0],89:[0,.68611,.02875,0],90:[0,.68611,0,0],91:[.25,.75,0,0],92:[.25,.75,0,0],93:[.25,.75,0,0],94:[0,.69444,0,0],95:[.31,.13444,.03194,0],96:[0,.69444,0,0],97:[0,.44444,0,0],98:[0,.69444,0,0],99:[0,.44444,0,0],100:[0,.69444,0,0],101:[0,.44444,0,0],102:[0,.69444,.10903,0],103:[.19444,.44444,.01597,0],104:[0,.69444,0,0],105:[0,.69444,0,0],106:[.19444,.69444,0,0],107:[0,.69444,0,0],108:[0,.69444,0,0],109:[0,.44444,0,0],110:[0,.44444,0,0],111:[0,.44444,0,0],112:[.19444,.44444,0,0],113:[.19444,.44444,0,0],114:[0,.44444,0,0],115:[0,.44444,0,0],116:[0,.63492,0,0],117:[0,.44444,0,0],118:[0,.44444,.01597,0],119:[0,.44444,.01597,0],120:[0,.44444,0,0],121:[.19444,.44444,.01597,0],122:[0,.44444,0,0],123:[.25,.75,0,0],124:[.25,.75,0,0],125:[.25,.75,0,0],126:[.35,.34444,0,0],168:[0,.69444,0,0],172:[0,.44444,0,0],175:[0,.59611,0,0],176:[0,.69444,0,0],177:[.13333,.63333,0,0],180:[0,.69444,0,0],215:[.13333,.63333,0,0],247:[.13333,.63333,0,0],305:[0,.44444,0,0],567:[.19444,.44444,0,0],710:[0,.69444,0,0],711:[0,.63194,0,0],713:[0,.59611,0,0],714:[0,.69444,0,0],715:[0,.69444,0,0],728:[0,.69444,0,0],729:[0,.69444,0,0],730:[0,.69444,0,0],732:[0,.69444,0,0],768:[0,.69444,0,0],769:[0,.69444,0,0],770:[0,.69444,0,0],771:[0,.69444,0,0],772:[0,.59611,0,0],774:[0,.69444,0,0],775:[0,.69444,0,0],776:[0,.69444,0,0],778:[0,.69444,0,0],779:[0,.69444,0,0],780:[0,.63194,0,0],824:[.19444,.69444,0,0],915:[0,.68611,0,0],916:[0,.68611,0,0],920:[0,.68611,0,0],923:[0,.68611,0,0],926:[0,.68611,0,0],928:[0,.68611,0,0],931:[0,.68611,0,0],933:[0,.68611,0,0],934:[0,.68611,0,0],936:[0,.68611,0,0],937:[0,.68611,0,0],8211:[0,.44444,.03194,0],8212:[0,.44444,.03194,0],8216:[0,.69444,0,0],8217:[0,.69444,0,0],8220:[0,.69444,0,0],8221:[0,.69444,0,0],8224:[.19444,.69444,0,0],8225:[.19444,.69444,0,0],8242:[0,.55556,0,0],8407:[0,.72444,.15486,0],8463:[0,.69444,0,0],8465:[0,.69444,0,0],8467:[0,.69444,0,0],8472:[.19444,.44444,0,0],8476:[0,.69444,0,0],8501:[0,.69444,0,0],8592:[-.10889,.39111,0,0],8593:[.19444,.69444,0,0],8594:[-.10889,.39111,0,0],8595:[.19444,.69444,0,0],8596:[-.10889,.39111,0,0],8597:[.25,.75,0,0], +8598:[.19444,.69444,0,0],8599:[.19444,.69444,0,0],8600:[.19444,.69444,0,0],8601:[.19444,.69444,0,0],8636:[-.10889,.39111,0,0],8637:[-.10889,.39111,0,0],8640:[-.10889,.39111,0,0],8641:[-.10889,.39111,0,0],8656:[-.10889,.39111,0,0],8657:[.19444,.69444,0,0],8658:[-.10889,.39111,0,0],8659:[.19444,.69444,0,0],8660:[-.10889,.39111,0,0],8661:[.25,.75,0,0],8704:[0,.69444,0,0],8706:[0,.69444,.06389,0],8707:[0,.69444,0,0],8709:[.05556,.75,0,0],8711:[0,.68611,0,0],8712:[.08556,.58556,0,0],8715:[.08556,.58556,0,0],8722:[.13333,.63333,0,0],8723:[.13333,.63333,0,0],8725:[.25,.75,0,0],8726:[.25,.75,0,0],8727:[-.02778,.47222,0,0],8728:[-.02639,.47361,0,0],8729:[-.02639,.47361,0,0],8730:[.18,.82,0,0],8733:[0,.44444,0,0],8734:[0,.44444,0,0],8736:[0,.69224,0,0],8739:[.25,.75,0,0],8741:[.25,.75,0,0],8743:[0,.55556,0,0],8744:[0,.55556,0,0],8745:[0,.55556,0,0],8746:[0,.55556,0,0],8747:[.19444,.69444,.12778,0],8764:[-.10889,.39111,0,0],8768:[.19444,.69444,0,0],8771:[.00222,.50222,0,0],8776:[.02444,.52444,0,0],8781:[.00222,.50222,0,0],8801:[.00222,.50222,0,0],8804:[.19667,.69667,0,0],8805:[.19667,.69667,0,0],8810:[.08556,.58556,0,0],8811:[.08556,.58556,0,0],8826:[.08556,.58556,0,0],8827:[.08556,.58556,0,0],8834:[.08556,.58556,0,0],8835:[.08556,.58556,0,0],8838:[.19667,.69667,0,0],8839:[.19667,.69667,0,0],8846:[0,.55556,0,0],8849:[.19667,.69667,0,0],8850:[.19667,.69667,0,0],8851:[0,.55556,0,0],8852:[0,.55556,0,0],8853:[.13333,.63333,0,0],8854:[.13333,.63333,0,0],8855:[.13333,.63333,0,0],8856:[.13333,.63333,0,0],8857:[.13333,.63333,0,0],8866:[0,.69444,0,0],8867:[0,.69444,0,0],8868:[0,.69444,0,0],8869:[0,.69444,0,0],8900:[-.02639,.47361,0,0],8901:[-.02639,.47361,0,0],8902:[-.02778,.47222,0,0],8968:[.25,.75,0,0],8969:[.25,.75,0,0],8970:[.25,.75,0,0],8971:[.25,.75,0,0],8994:[-.13889,.36111,0,0],8995:[-.13889,.36111,0,0],9651:[.19444,.69444,0,0],9657:[-.02778,.47222,0,0],9661:[.19444,.69444,0,0],9667:[-.02778,.47222,0,0],9711:[.19444,.69444,0,0],9824:[.12963,.69444,0,0],9825:[.12963,.69444,0,0],9826:[.12963,.69444,0,0],9827:[.12963,.69444,0,0],9837:[0,.75,0,0],9838:[.19444,.69444,0,0],9839:[.19444,.69444,0,0],10216:[.25,.75,0,0],10217:[.25,.75,0,0],10815:[0,.68611,0,0],10927:[.19667,.69667,0,0],10928:[.19667,.69667,0,0]},"Main-Italic":{33:[0,.69444,.12417,0],34:[0,.69444,.06961,0],35:[.19444,.69444,.06616,0],37:[.05556,.75,.13639,0],38:[0,.69444,.09694,0],39:[0,.69444,.12417,0],40:[.25,.75,.16194,0],41:[.25,.75,.03694,0],42:[0,.75,.14917,0],43:[.05667,.56167,.03694,0],44:[.19444,.10556,0,0],45:[0,.43056,.02826,0],46:[0,.10556,0,0],47:[.25,.75,.16194,0],48:[0,.64444,.13556,0],49:[0,.64444,.13556,0],50:[0,.64444,.13556,0],51:[0,.64444,.13556,0],52:[.19444,.64444,.13556,0],53:[0,.64444,.13556,0],54:[0,.64444,.13556,0],55:[.19444,.64444,.13556,0],56:[0,.64444,.13556,0],57:[0,.64444,.13556,0],58:[0,.43056,.0582,0],59:[.19444,.43056,.0582,0],61:[-.13313,.36687,.06616,0],63:[0,.69444,.1225,0],64:[0,.69444,.09597,0],65:[0,.68333,0,0],66:[0,.68333,.10257,0],67:[0,.68333,.14528,0],68:[0,.68333,.09403,0],69:[0,.68333,.12028,0],70:[0,.68333,.13305,0],71:[0,.68333,.08722,0],72:[0,.68333,.16389,0],73:[0,.68333,.15806,0],74:[0,.68333,.14028,0],75:[0,.68333,.14528,0],76:[0,.68333,0,0],77:[0,.68333,.16389,0],78:[0,.68333,.16389,0],79:[0,.68333,.09403,0],80:[0,.68333,.10257,0],81:[.19444,.68333,.09403,0],82:[0,.68333,.03868,0],83:[0,.68333,.11972,0],84:[0,.68333,.13305,0],85:[0,.68333,.16389,0],86:[0,.68333,.18361,0],87:[0,.68333,.18361,0],88:[0,.68333,.15806,0],89:[0,.68333,.19383,0],90:[0,.68333,.14528,0],91:[.25,.75,.1875,0],93:[.25,.75,.10528,0],94:[0,.69444,.06646,0],95:[.31,.12056,.09208,0],97:[0,.43056,.07671,0],98:[0,.69444,.06312,0],99:[0,.43056,.05653,0],100:[0,.69444,.10333,0],101:[0,.43056,.07514,0],102:[.19444,.69444,.21194,0],103:[.19444,.43056,.08847,0],104:[0,.69444,.07671,0],105:[0,.65536,.1019,0],106:[.19444,.65536,.14467,0],107:[0,.69444,.10764,0],108:[0,.69444,.10333,0],109:[0,.43056,.07671,0],110:[0,.43056,.07671,0],111:[0,.43056,.06312,0],112:[.19444,.43056,.06312,0],113:[.19444,.43056,.08847,0],114:[0,.43056,.10764,0],115:[0,.43056,.08208,0],116:[0,.61508,.09486,0],117:[0,.43056,.07671,0],118:[0,.43056,.10764,0],119:[0,.43056,.10764,0],120:[0,.43056,.12042,0],121:[.19444,.43056,.08847,0],122:[0,.43056,.12292,0],126:[.35,.31786,.11585,0],163:[0,.69444,0,0],305:[0,.43056,0,.02778],567:[.19444,.43056,0,.08334],768:[0,.69444,0,0],769:[0,.69444,.09694,0],770:[0,.69444,.06646,0],771:[0,.66786,.11585,0],772:[0,.56167,.10333,0],774:[0,.69444,.10806,0],775:[0,.66786,.11752,0],776:[0,.66786,.10474,0],778:[0,.69444,0,0],779:[0,.69444,.1225,0],780:[0,.62847,.08295,0],915:[0,.68333,.13305,0],916:[0,.68333,0,0],920:[0,.68333,.09403,0],923:[0,.68333,0,0],926:[0,.68333,.15294,0],928:[0,.68333,.16389,0],931:[0,.68333,.12028,0],933:[0,.68333,.11111,0],934:[0,.68333,.05986,0],936:[0,.68333,.11111,0],937:[0,.68333,.10257,0],8211:[0,.43056,.09208,0],8212:[0,.43056,.09208,0],8216:[0,.69444,.12417,0],8217:[0,.69444,.12417,0],8220:[0,.69444,.1685,0],8221:[0,.69444,.06961,0],8463:[0,.68889,0,0]},"Main-Regular":{32:[0,0,0,0],33:[0,.69444,0,0],34:[0,.69444,0,0],35:[.19444,.69444,0,0],36:[.05556,.75,0,0],37:[.05556,.75,0,0],38:[0,.69444,0,0],39:[0,.69444,0,0],40:[.25,.75,0,0],41:[.25,.75,0,0],42:[0,.75,0,0],43:[.08333,.58333,0,0],44:[.19444,.10556,0,0],45:[0,.43056,0,0],46:[0,.10556,0,0],47:[.25,.75,0,0],48:[0,.64444,0,0],49:[0,.64444,0,0],50:[0,.64444,0,0],51:[0,.64444,0,0],52:[0,.64444,0,0],53:[0,.64444,0,0],54:[0,.64444,0,0],55:[0,.64444,0,0],56:[0,.64444,0,0],57:[0,.64444,0,0],58:[0,.43056,0,0],59:[.19444,.43056,0,0],60:[.0391,.5391,0,0],61:[-.13313,.36687,0,0],62:[.0391,.5391,0,0],63:[0,.69444,0,0],64:[0,.69444,0,0],65:[0,.68333,0,0],66:[0,.68333,0,0],67:[0,.68333,0,0],68:[0,.68333,0,0],69:[0,.68333,0,0],70:[0,.68333,0,0],71:[0,.68333,0,0],72:[0,.68333,0,0],73:[0,.68333,0,0],74:[0,.68333,0,0],75:[0,.68333,0,0],76:[0,.68333,0,0],77:[0,.68333,0,0],78:[0,.68333,0,0],79:[0,.68333,0,0],80:[0,.68333,0,0],81:[.19444,.68333,0,0],82:[0,.68333,0,0],83:[0,.68333,0,0],84:[0,.68333,0,0],85:[0,.68333,0,0],86:[0,.68333,.01389,0],87:[0,.68333,.01389,0],88:[0,.68333,0,0],89:[0,.68333,.025,0],90:[0,.68333,0,0],91:[.25,.75,0,0],92:[.25,.75,0,0],93:[.25,.75,0,0],94:[0,.69444,0,0],95:[.31,.12056,.02778,0],96:[0,.69444,0,0],97:[0,.43056,0,0],98:[0,.69444,0,0],99:[0,.43056,0,0],100:[0,.69444,0,0],101:[0,.43056,0,0],102:[0,.69444,.07778,0],103:[.19444,.43056,.01389,0],104:[0,.69444,0,0],105:[0,.66786,0,0],106:[.19444,.66786,0,0],107:[0,.69444,0,0],108:[0,.69444,0,0],109:[0,.43056,0,0],110:[0,.43056,0,0],111:[0,.43056,0,0],112:[.19444,.43056,0,0],113:[.19444,.43056,0,0],114:[0,.43056,0,0],115:[0,.43056,0,0],116:[0,.61508,0,0],117:[0,.43056,0,0],118:[0,.43056,.01389,0],119:[0,.43056,.01389,0],120:[0,.43056,0,0],121:[.19444,.43056,.01389,0],122:[0,.43056,0,0],123:[.25,.75,0,0],124:[.25,.75,0,0],125:[.25,.75,0,0],126:[.35,.31786,0,0],160:[0,0,0,0],168:[0,.66786,0,0],172:[0,.43056,0,0],175:[0,.56778,0,0],176:[0,.69444,0,0],177:[.08333,.58333,0,0],180:[0,.69444,0,0],215:[.08333,.58333,0,0],247:[.08333,.58333,0,0],305:[0,.43056,0,0],567:[.19444,.43056,0,0],710:[0,.69444,0,0],711:[0,.62847,0,0],713:[0,.56778,0,0],714:[0,.69444,0,0],715:[0,.69444,0,0],728:[0,.69444,0,0],729:[0,.66786,0,0],730:[0,.69444,0,0],732:[0,.66786,0,0],768:[0,.69444,0,0],769:[0,.69444,0,0],770:[0,.69444,0,0],771:[0,.66786,0,0],772:[0,.56778,0,0],774:[0,.69444,0,0],775:[0,.66786,0,0],776:[0,.66786,0,0],778:[0,.69444,0,0],779:[0,.69444,0,0],780:[0,.62847,0,0],824:[.19444,.69444,0,0],915:[0,.68333,0,0],916:[0,.68333,0,0],920:[0,.68333,0,0],923:[0,.68333,0,0],926:[0,.68333,0,0],928:[0,.68333,0,0],931:[0,.68333,0,0],933:[0,.68333,0,0],934:[0,.68333,0,0],936:[0,.68333,0,0],937:[0,.68333,0,0],8211:[0,.43056,.02778,0],8212:[0,.43056,.02778,0],8216:[0,.69444,0,0],8217:[0,.69444,0,0],8220:[0,.69444,0,0],8221:[0,.69444,0,0],8224:[.19444,.69444,0,0],8225:[.19444,.69444,0,0],8230:[0,.12,0,0],8242:[0,.55556,0,0],8407:[0,.71444,.15382,0],8463:[0,.68889,0,0],8465:[0,.69444,0,0],8467:[0,.69444,0,.11111],8472:[.19444,.43056,0,.11111],8476:[0,.69444,0,0],8501:[0,.69444,0,0],8592:[-.13313,.36687,0,0],8593:[.19444,.69444,0,0],8594:[-.13313,.36687,0,0],8595:[.19444,.69444,0,0],8596:[-.13313,.36687,0,0],8597:[.25,.75,0,0],8598:[.19444,.69444,0,0],8599:[.19444,.69444,0,0],8600:[.19444,.69444,0,0],8601:[.19444,.69444,0,0],8614:[.011,.511,0,0],8617:[.011,.511,0,0],8618:[.011,.511,0,0],8636:[-.13313,.36687,0,0],8637:[-.13313,.36687,0,0],8640:[-.13313,.36687,0,0],8641:[-.13313,.36687,0,0],8652:[.011,.671,0,0],8656:[-.13313,.36687,0,0],8657:[.19444,.69444,0,0],8658:[-.13313,.36687,0,0],8659:[.19444,.69444,0,0],8660:[-.13313,.36687,0,0],8661:[.25,.75,0,0],8704:[0,.69444,0,0],8706:[0,.69444,.05556,.08334],8707:[0,.69444,0,0],8709:[.05556,.75,0,0],8711:[0,.68333,0,0],8712:[.0391,.5391,0,0],8715:[.0391,.5391,0,0],8722:[.08333,.58333,0,0],8723:[.08333,.58333,0,0],8725:[.25,.75,0,0],8726:[.25,.75,0,0],8727:[-.03472,.46528,0,0],8728:[-.05555,.44445,0,0],8729:[-.05555,.44445,0,0],8730:[.2,.8,0,0],8733:[0,.43056,0,0],8734:[0,.43056,0,0],8736:[0,.69224,0,0],8739:[.25,.75,0,0],8741:[.25,.75,0,0],8743:[0,.55556,0,0],8744:[0,.55556,0,0],8745:[0,.55556,0,0],8746:[0,.55556,0,0],8747:[.19444,.69444,.11111,0],8764:[-.13313,.36687,0,0],8768:[.19444,.69444,0,0],8771:[-.03625,.46375,0,0],8773:[-.022,.589,0,0],8776:[-.01688,.48312,0,0],8781:[-.03625,.46375,0,0],8784:[-.133,.67,0,0],8800:[.215,.716,0,0],8801:[-.03625,.46375,0,0],8804:[.13597,.63597,0,0],8805:[.13597,.63597,0,0],8810:[.0391,.5391,0,0],8811:[.0391,.5391,0,0],8826:[.0391,.5391,0,0],8827:[.0391,.5391,0,0],8834:[.0391,.5391,0,0],8835:[.0391,.5391,0,0],8838:[.13597,.63597,0,0],8839:[.13597,.63597,0,0],8846:[0,.55556,0,0],8849:[.13597,.63597,0,0],8850:[.13597,.63597,0,0],8851:[0,.55556,0,0],8852:[0,.55556,0,0],8853:[.08333,.58333,0,0],8854:[.08333,.58333,0,0],8855:[.08333,.58333,0,0],8856:[.08333,.58333,0,0],8857:[.08333,.58333,0,0],8866:[0,.69444,0,0],8867:[0,.69444,0,0],8868:[0,.69444,0,0],8869:[0,.69444,0,0],8872:[.249,.75,0,0],8900:[-.05555,.44445,0,0],8901:[-.05555,.44445,0,0],8902:[-.03472,.46528,0,0],8904:[.005,.505,0,0],8942:[.03,.9,0,0],8943:[-.19,.31,0,0],8945:[-.1,.82,0,0],8968:[.25,.75,0,0],8969:[.25,.75,0,0],8970:[.25,.75,0,0],8971:[.25,.75,0,0],8994:[-.14236,.35764,0,0],8995:[-.14236,.35764,0,0],9136:[.244,.744,0,0],9137:[.244,.744,0,0],9651:[.19444,.69444,0,0],9657:[-.03472,.46528,0,0],9661:[.19444,.69444,0,0],9667:[-.03472,.46528,0,0],9711:[.19444,.69444,0,0],9824:[.12963,.69444,0,0],9825:[.12963,.69444,0,0],9826:[.12963,.69444,0,0],9827:[.12963,.69444,0,0],9837:[0,.75,0,0],9838:[.19444,.69444,0,0],9839:[.19444,.69444,0,0],10216:[.25,.75,0,0],10217:[.25,.75,0,0],10222:[.244,.744,0,0],10223:[.244,.744,0,0],10229:[.011,.511,0,0],10230:[.011,.511,0,0],10231:[.011,.511,0,0],10232:[.024,.525,0,0],10233:[.024,.525,0,0],10234:[.024,.525,0,0],10236:[.011,.511,0,0],10815:[0,.68333,0,0],10927:[.13597,.63597,0,0],10928:[.13597,.63597,0,0]},"Math-BoldItalic":{47:[.19444,.69444,0,0],65:[0,.68611,0,0],66:[0,.68611,.04835,0],67:[0,.68611,.06979,0],68:[0,.68611,.03194,0],69:[0,.68611,.05451,0],70:[0,.68611,.15972,0],71:[0,.68611,0,0],72:[0,.68611,.08229,0],73:[0,.68611,.07778,0],74:[0,.68611,.10069,0],75:[0,.68611,.06979,0],76:[0,.68611,0,0],77:[0,.68611,.11424,0],78:[0,.68611,.11424,0],79:[0,.68611,.03194,0],80:[0,.68611,.15972,0],81:[.19444,.68611,0,0],82:[0,.68611,.00421,0],83:[0,.68611,.05382,0],84:[0,.68611,.15972,0],85:[0,.68611,.11424,0],86:[0,.68611,.25555,0],87:[0,.68611,.15972,0],88:[0,.68611,.07778,0],89:[0,.68611,.25555,0],90:[0,.68611,.06979,0],97:[0,.44444,0,0],98:[0,.69444,0,0],99:[0,.44444,0,0],100:[0,.69444,0,0],101:[0,.44444,0,0],102:[.19444,.69444,.11042,0],103:[.19444,.44444,.03704,0],104:[0,.69444,0,0],105:[0,.69326,0,0],106:[.19444,.69326,.0622,0],107:[0,.69444,.01852,0],108:[0,.69444,.0088,0],109:[0,.44444,0,0],110:[0,.44444,0,0],111:[0,.44444,0,0],112:[.19444,.44444,0,0],113:[.19444,.44444,.03704,0],114:[0,.44444,.03194,0],115:[0,.44444,0,0],116:[0,.63492,0,0],117:[0,.44444,0,0],118:[0,.44444,.03704,0],119:[0,.44444,.02778,0],120:[0,.44444,0,0],121:[.19444,.44444,.03704,0],122:[0,.44444,.04213,0],915:[0,.68611,.15972,0],916:[0,.68611,0,0],920:[0,.68611,.03194,0],923:[0,.68611,0,0],926:[0,.68611,.07458,0],928:[0,.68611,.08229,0],931:[0,.68611,.05451,0],933:[0,.68611,.15972,0],934:[0,.68611,0,0],936:[0,.68611,.11653,0],937:[0,.68611,.04835,0],945:[0,.44444,0,0],946:[.19444,.69444,.03403,0],947:[.19444,.44444,.06389,0],948:[0,.69444,.03819,0],949:[0,.44444,0,0],950:[.19444,.69444,.06215,0],951:[.19444,.44444,.03704,0],952:[0,.69444,.03194,0],953:[0,.44444,0,0],954:[0,.44444,0,0],955:[0,.69444,0,0],956:[.19444,.44444,0,0],957:[0,.44444,.06898,0],958:[.19444,.69444,.03021,0],959:[0,.44444,0,0],960:[0,.44444,.03704,0],961:[.19444,.44444,0,0],962:[.09722,.44444,.07917,0],963:[0,.44444,.03704,0],964:[0,.44444,.13472,0],965:[0,.44444,.03704,0],966:[.19444,.44444,0,0],967:[.19444,.44444,0,0],968:[.19444,.69444,.03704,0],969:[0,.44444,.03704,0],977:[0,.69444,0,0],981:[.19444,.69444,0,0],982:[0,.44444,.03194,0],1009:[.19444,.44444,0,0],1013:[0,.44444,0,0]},"Math-Italic":{47:[.19444,.69444,0,0],65:[0,.68333,0,.13889],66:[0,.68333,.05017,.08334],67:[0,.68333,.07153,.08334],68:[0,.68333,.02778,.05556],69:[0,.68333,.05764,.08334],70:[0,.68333,.13889,.08334],71:[0,.68333,0,.08334],72:[0,.68333,.08125,.05556],73:[0,.68333,.07847,.11111],74:[0,.68333,.09618,.16667],75:[0,.68333,.07153,.05556],76:[0,.68333,0,.02778],77:[0,.68333,.10903,.08334],78:[0,.68333,.10903,.08334],79:[0,.68333,.02778,.08334],80:[0,.68333,.13889,.08334],81:[.19444,.68333,0,.08334],82:[0,.68333,.00773,.08334],83:[0,.68333,.05764,.08334],84:[0,.68333,.13889,.08334],85:[0,.68333,.10903,.02778],86:[0,.68333,.22222,0],87:[0,.68333,.13889,0],88:[0,.68333,.07847,.08334],89:[0,.68333,.22222,0],90:[0,.68333,.07153,.08334],97:[0,.43056,0,0],98:[0,.69444,0,0],99:[0,.43056,0,.05556],100:[0,.69444,0,.16667],101:[0,.43056,0,.05556],102:[.19444,.69444,.10764,.16667],103:[.19444,.43056,.03588,.02778],104:[0,.69444,0,0],105:[0,.65952,0,0],106:[.19444,.65952,.05724,0],107:[0,.69444,.03148,0],108:[0,.69444,.01968,.08334],109:[0,.43056,0,0],110:[0,.43056,0,0],111:[0,.43056,0,.05556],112:[.19444,.43056,0,.08334],113:[.19444,.43056,.03588,.08334],114:[0,.43056,.02778,.05556],115:[0,.43056,0,.05556],116:[0,.61508,0,.08334],117:[0,.43056,0,.02778],118:[0,.43056,.03588,.02778],119:[0,.43056,.02691,.08334],120:[0,.43056,0,.02778],121:[.19444,.43056,.03588,.05556],122:[0,.43056,.04398,.05556],915:[0,.68333,.13889,.08334],916:[0,.68333,0,.16667],920:[0,.68333,.02778,.08334],923:[0,.68333,0,.16667],926:[0,.68333,.07569,.08334],928:[0,.68333,.08125,.05556],931:[0,.68333,.05764,.08334],933:[0,.68333,.13889,.05556],934:[0,.68333,0,.08334],936:[0,.68333,.11,.05556],937:[0,.68333,.05017,.08334],945:[0,.43056,.0037,.02778],946:[.19444,.69444,.05278,.08334],947:[.19444,.43056,.05556,0],948:[0,.69444,.03785,.05556],949:[0,.43056,0,.08334],950:[.19444,.69444,.07378,.08334],951:[.19444,.43056,.03588,.05556],952:[0,.69444,.02778,.08334],953:[0,.43056,0,.05556],954:[0,.43056,0,0],955:[0,.69444,0,0],956:[.19444,.43056,0,.02778],957:[0,.43056,.06366,.02778],958:[.19444,.69444,.04601,.11111],959:[0,.43056,0,.05556],960:[0,.43056,.03588,0],961:[.19444,.43056,0,.08334],962:[.09722,.43056,.07986,.08334],963:[0,.43056,.03588,0],964:[0,.43056,.1132,.02778],965:[0,.43056,.03588,.02778],966:[.19444,.43056,0,.08334],967:[.19444,.43056,0,.05556],968:[.19444,.69444,.03588,.11111],969:[0,.43056,.03588,0],977:[0,.69444,0,.08334],981:[.19444,.69444,0,.08334],982:[0,.43056,.02778,0],1009:[.19444,.43056,0,.08334],1013:[0,.43056,0,.05556]},"Math-Regular":{65:[0,.68333,0,.13889],66:[0,.68333,.05017,.08334],67:[0,.68333,.07153,.08334],68:[0,.68333,.02778,.05556],69:[0,.68333,.05764,.08334],70:[0,.68333,.13889,.08334],71:[0,.68333,0,.08334],72:[0,.68333,.08125,.05556],73:[0,.68333,.07847,.11111],74:[0,.68333,.09618,.16667],75:[0,.68333,.07153,.05556],76:[0,.68333,0,.02778],77:[0,.68333,.10903,.08334],78:[0,.68333,.10903,.08334],79:[0,.68333,.02778,.08334],80:[0,.68333,.13889,.08334],81:[.19444,.68333,0,.08334],82:[0,.68333,.00773,.08334],83:[0,.68333,.05764,.08334],84:[0,.68333,.13889,.08334],85:[0,.68333,.10903,.02778],86:[0,.68333,.22222,0],87:[0,.68333,.13889,0],88:[0,.68333,.07847,.08334],89:[0,.68333,.22222,0],90:[0,.68333,.07153,.08334],97:[0,.43056,0,0],98:[0,.69444,0,0],99:[0,.43056,0,.05556],100:[0,.69444,0,.16667],101:[0,.43056,0,.05556],102:[.19444,.69444,.10764,.16667],103:[.19444,.43056,.03588,.02778],104:[0,.69444,0,0],105:[0,.65952,0,0],106:[.19444,.65952,.05724,0],107:[0,.69444,.03148,0],108:[0,.69444,.01968,.08334],109:[0,.43056,0,0],110:[0,.43056,0,0],111:[0,.43056,0,.05556],112:[.19444,.43056,0,.08334],113:[.19444,.43056,.03588,.08334],114:[0,.43056,.02778,.05556],115:[0,.43056,0,.05556],116:[0,.61508,0,.08334],117:[0,.43056,0,.02778],118:[0,.43056,.03588,.02778],119:[0,.43056,.02691,.08334],120:[0,.43056,0,.02778],121:[.19444,.43056,.03588,.05556],122:[0,.43056,.04398,.05556],915:[0,.68333,.13889,.08334],916:[0,.68333,0,.16667],920:[0,.68333,.02778,.08334],923:[0,.68333,0,.16667],926:[0,.68333,.07569,.08334],928:[0,.68333,.08125,.05556],931:[0,.68333,.05764,.08334],933:[0,.68333,.13889,.05556],934:[0,.68333,0,.08334],936:[0,.68333,.11,.05556],937:[0,.68333,.05017,.08334],945:[0,.43056,.0037,.02778],946:[.19444,.69444,.05278,.08334],947:[.19444,.43056,.05556,0],948:[0,.69444,.03785,.05556],949:[0,.43056,0,.08334],950:[.19444,.69444,.07378,.08334],951:[.19444,.43056,.03588,.05556],952:[0,.69444,.02778,.08334],953:[0,.43056,0,.05556],954:[0,.43056,0,0],955:[0,.69444,0,0],956:[.19444,.43056,0,.02778],957:[0,.43056,.06366,.02778],958:[.19444,.69444,.04601,.11111],959:[0,.43056,0,.05556],960:[0,.43056,.03588,0],961:[.19444,.43056,0,.08334],962:[.09722,.43056,.07986,.08334],963:[0,.43056,.03588,0],964:[0,.43056,.1132,.02778],965:[0,.43056,.03588,.02778],966:[.19444,.43056,0,.08334],967:[.19444,.43056,0,.05556],968:[.19444,.69444,.03588,.11111],969:[0,.43056,.03588,0],977:[0,.69444,0,.08334],981:[.19444,.69444,0,.08334],982:[0,.43056,.02778,0],1009:[.19444,.43056,0,.08334],1013:[0,.43056,0,.05556]},"SansSerif-Regular":{33:[0,.69444,0,0],34:[0,.69444,0,0],35:[.19444,.69444,0,0],36:[.05556,.75,0,0],37:[.05556,.75,0,0],38:[0,.69444,0,0],39:[0,.69444,0,0],40:[.25,.75,0,0],41:[.25,.75,0,0],42:[0,.75,0,0],43:[.08333,.58333,0,0],44:[.125,.08333,0,0],45:[0,.44444,0,0],46:[0,.08333,0,0],47:[.25,.75,0,0],48:[0,.65556,0,0],49:[0,.65556,0,0],50:[0,.65556,0,0],51:[0,.65556,0,0],52:[0,.65556,0,0],53:[0,.65556,0,0],54:[0,.65556,0,0],55:[0,.65556,0,0],56:[0,.65556,0,0],57:[0,.65556,0,0],58:[0,.44444,0,0],59:[.125,.44444,0,0],61:[-.13,.37,0,0],63:[0,.69444,0,0],64:[0,.69444,0,0],65:[0,.69444,0,0],66:[0,.69444,0,0],67:[0,.69444,0,0],68:[0,.69444,0,0],69:[0,.69444,0,0],70:[0,.69444,0,0],71:[0,.69444,0,0],72:[0,.69444,0,0],73:[0,.69444,0,0],74:[0,.69444,0,0],75:[0,.69444,0,0],76:[0,.69444,0,0],77:[0,.69444,0,0],78:[0,.69444,0,0],79:[0,.69444,0,0],80:[0,.69444,0,0],81:[.125,.69444,0,0],82:[0,.69444,0,0],83:[0,.69444,0,0],84:[0,.69444,0,0],85:[0,.69444,0,0],86:[0,.69444,.01389,0],87:[0,.69444,.01389,0],88:[0,.69444,0,0],89:[0,.69444,.025,0],90:[0,.69444,0,0],91:[.25,.75,0,0],93:[.25,.75,0,0],94:[0,.69444,0,0],95:[.35,.09444,.02778,0],97:[0,.44444,0,0],98:[0,.69444,0,0],99:[0,.44444,0,0],100:[0,.69444,0,0],101:[0,.44444,0,0],102:[0,.69444,.06944,0],103:[.19444,.44444,.01389,0],104:[0,.69444,0,0],105:[0,.67937,0,0],106:[.19444,.67937,0,0],107:[0,.69444,0,0],108:[0,.69444,0,0],109:[0,.44444,0,0],110:[0,.44444,0,0],111:[0,.44444,0,0],112:[.19444,.44444,0,0],113:[.19444,.44444,0,0],114:[0,.44444,.01389,0],115:[0,.44444,0,0],116:[0,.57143,0,0],117:[0,.44444,0,0],118:[0,.44444,.01389,0],119:[0,.44444,.01389,0],120:[0,.44444,0,0],121:[.19444,.44444,.01389,0],122:[0,.44444,0,0],126:[.35,.32659,0,0],305:[0,.44444,0,0],567:[.19444,.44444,0,0],768:[0,.69444,0,0],769:[0,.69444,0,0],770:[0,.69444,0,0],771:[0,.67659,0,0],772:[0,.60889,0,0],774:[0,.69444,0,0],775:[0,.67937,0,0],776:[0,.67937,0,0],778:[0,.69444,0,0],779:[0,.69444,0,0],780:[0,.63194,0,0],915:[0,.69444,0,0],916:[0,.69444,0,0],920:[0,.69444,0,0],923:[0,.69444,0,0],926:[0,.69444,0,0],928:[0,.69444,0,0],931:[0,.69444,0,0],933:[0,.69444,0,0],934:[0,.69444,0,0],936:[0,.69444,0,0],937:[0,.69444,0,0],8211:[0,.44444,.02778,0],8212:[0,.44444,.02778,0],8216:[0,.69444,0,0],8217:[0,.69444,0,0],8220:[0,.69444,0,0],8221:[0,.69444,0,0]},"Script-Regular":{65:[0,.7,.22925,0],66:[0,.7,.04087,0],67:[0,.7,.1689,0],68:[0,.7,.09371,0],69:[0,.7,.18583,0],70:[0,.7,.13634,0],71:[0,.7,.17322,0],72:[0,.7,.29694,0],73:[0,.7,.19189,0],74:[.27778,.7,.19189,0],75:[0,.7,.31259,0],76:[0,.7,.19189,0],77:[0,.7,.15981,0],78:[0,.7,.3525,0],79:[0,.7,.08078,0],80:[0,.7,.08078,0],81:[0,.7,.03305,0],82:[0,.7,.06259,0],83:[0,.7,.19189,0],84:[0,.7,.29087,0],85:[0,.7,.25815,0],86:[0,.7,.27523,0],87:[0,.7,.27523,0],88:[0,.7,.26006,0],89:[0,.7,.2939,0],90:[0,.7,.24037,0]},"Size1-Regular":{40:[.35001,.85,0,0],41:[.35001,.85,0,0],47:[.35001,.85,0,0],91:[.35001,.85,0,0],92:[.35001,.85,0,0],93:[.35001,.85,0,0],123:[.35001,.85,0,0],125:[.35001,.85,0,0],710:[0,.72222,0,0],732:[0,.72222,0,0],770:[0,.72222,0,0],771:[0,.72222,0,0],8214:[-99e-5,.601,0,0],8593:[1e-5,.6,0,0],8595:[1e-5,.6,0,0],8657:[1e-5,.6,0,0],8659:[1e-5,.6,0,0],8719:[.25001,.75,0,0],8720:[.25001,.75,0,0],8721:[.25001,.75,0,0],8730:[.35001,.85,0,0],8739:[-.00599,.606,0,0],8741:[-.00599,.606,0,0],8747:[.30612,.805,.19445,0],8748:[.306,.805,.19445,0],8749:[.306,.805,.19445,0],8750:[.30612,.805,.19445,0],8896:[.25001,.75,0,0],8897:[.25001,.75,0,0],8898:[.25001,.75,0,0],8899:[.25001,.75,0,0],8968:[.35001,.85,0,0],8969:[.35001,.85,0,0],8970:[.35001,.85,0,0],8971:[.35001,.85,0,0],9168:[-99e-5,.601,0,0],10216:[.35001,.85,0,0],10217:[.35001,.85,0,0],10752:[.25001,.75,0,0],10753:[.25001,.75,0,0],10754:[.25001,.75,0,0],10756:[.25001,.75,0,0],10758:[.25001,.75,0,0]},"Size2-Regular":{40:[.65002,1.15,0,0],41:[.65002,1.15,0,0],47:[.65002,1.15,0,0],91:[.65002,1.15,0,0],92:[.65002,1.15,0,0],93:[.65002,1.15,0,0],123:[.65002,1.15,0,0],125:[.65002,1.15,0,0],710:[0,.75,0,0],732:[0,.75,0,0],770:[0,.75,0,0],771:[0,.75,0,0],8719:[.55001,1.05,0,0],8720:[.55001,1.05,0,0],8721:[.55001,1.05,0,0],8730:[.65002,1.15,0,0],8747:[.86225,1.36,.44445,0],8748:[.862,1.36,.44445,0],8749:[.862,1.36,.44445,0],8750:[.86225,1.36,.44445,0],8896:[.55001,1.05,0,0],8897:[.55001,1.05,0,0],8898:[.55001,1.05,0,0],8899:[.55001,1.05,0,0],8968:[.65002,1.15,0,0],8969:[.65002,1.15,0,0],8970:[.65002,1.15,0,0],8971:[.65002,1.15,0,0],10216:[.65002,1.15,0,0],10217:[.65002,1.15,0,0],10752:[.55001,1.05,0,0],10753:[.55001,1.05,0,0],10754:[.55001,1.05,0,0],10756:[.55001,1.05,0,0],10758:[.55001,1.05,0,0]},"Size3-Regular":{40:[.95003,1.45,0,0],41:[.95003,1.45,0,0],47:[.95003,1.45,0,0],91:[.95003,1.45,0,0],92:[.95003,1.45,0,0],93:[.95003,1.45,0,0],123:[.95003,1.45,0,0],125:[.95003,1.45,0,0],710:[0,.75,0,0],732:[0,.75,0,0],770:[0,.75,0,0],771:[0,.75,0,0],8730:[.95003,1.45,0,0],8968:[.95003,1.45,0,0],8969:[.95003,1.45,0,0],8970:[.95003,1.45,0,0],8971:[.95003,1.45,0,0],10216:[.95003,1.45,0,0],10217:[.95003,1.45,0,0]},"Size4-Regular":{40:[1.25003,1.75,0,0],41:[1.25003,1.75,0,0],47:[1.25003,1.75,0,0],91:[1.25003,1.75,0,0],92:[1.25003,1.75,0,0],93:[1.25003,1.75,0,0],123:[1.25003,1.75,0,0],125:[1.25003,1.75,0,0],710:[0,.825,0,0],732:[0,.825,0,0],770:[0,.825,0,0],771:[0,.825,0,0],8730:[1.25003,1.75,0,0],8968:[1.25003,1.75,0,0],8969:[1.25003,1.75,0,0],8970:[1.25003,1.75,0,0],8971:[1.25003,1.75,0,0],9115:[.64502,1.155,0,0],9116:[1e-5,.6,0,0],9117:[.64502,1.155,0,0],9118:[.64502,1.155,0,0],9119:[1e-5,.6,0,0],9120:[.64502,1.155,0,0],9121:[.64502,1.155,0,0],9122:[-99e-5,.601,0,0],9123:[.64502,1.155,0,0],9124:[.64502,1.155,0,0],9125:[-99e-5,.601,0,0],9126:[.64502,1.155,0,0],9127:[1e-5,.9,0,0],9128:[.65002,1.15,0,0],9129:[.90001,0,0,0],9130:[0,.3,0,0],9131:[1e-5,.9,0,0],9132:[.65002,1.15,0,0],9133:[.90001,0,0,0],9143:[.88502,.915,0,0],10216:[1.25003,1.75,0,0],10217:[1.25003,1.75,0,0],57344:[-.00499,.605,0,0],57345:[-.00499,.605,0,0],57680:[0,.12,0,0],57681:[0,.12,0,0],57682:[0,.12,0,0],57683:[0,.12,0,0]},"Typewriter-Regular":{33:[0,.61111,0,0],34:[0,.61111,0,0],35:[0,.61111,0,0],36:[.08333,.69444,0,0],37:[.08333,.69444,0,0],38:[0,.61111,0,0],39:[0,.61111,0,0],40:[.08333,.69444,0,0],41:[.08333,.69444,0,0],42:[0,.52083,0,0],43:[-.08056,.53055,0,0],44:[.13889,.125,0,0],45:[-.08056,.53055,0,0],46:[0,.125,0,0],47:[.08333,.69444,0,0],48:[0,.61111,0,0],49:[0,.61111,0,0],50:[0,.61111,0,0],51:[0,.61111,0,0],52:[0,.61111,0,0],53:[0,.61111,0,0],54:[0,.61111,0,0],55:[0,.61111,0,0],56:[0,.61111,0,0],57:[0,.61111,0,0],58:[0,.43056,0,0],59:[.13889,.43056,0,0],60:[-.05556,.55556,0,0],61:[-.19549,.41562,0,0],62:[-.05556,.55556,0,0],63:[0,.61111,0,0],64:[0,.61111,0,0],65:[0,.61111,0,0],66:[0,.61111,0,0],67:[0,.61111,0,0],68:[0,.61111,0,0],69:[0,.61111,0,0],70:[0,.61111,0,0],71:[0,.61111,0,0],72:[0,.61111,0,0],73:[0,.61111,0,0],74:[0,.61111,0,0],75:[0,.61111,0,0],76:[0,.61111,0,0],77:[0,.61111,0,0],78:[0,.61111,0,0],79:[0,.61111,0,0],80:[0,.61111,0,0],81:[.13889,.61111,0,0],82:[0,.61111,0,0],83:[0,.61111,0,0],84:[0,.61111,0,0],85:[0,.61111,0,0],86:[0,.61111,0,0],87:[0,.61111,0,0],88:[0,.61111,0,0],89:[0,.61111,0,0],90:[0,.61111,0,0],91:[.08333,.69444,0,0],92:[.08333,.69444,0,0],93:[.08333,.69444,0,0],94:[0,.61111,0,0],95:[.09514,0,0,0],96:[0,.61111,0,0],97:[0,.43056,0,0],98:[0,.61111,0,0],99:[0,.43056,0,0],100:[0,.61111,0,0],101:[0,.43056,0,0],102:[0,.61111,0,0],103:[.22222,.43056,0,0],104:[0,.61111,0,0],105:[0,.61111,0,0],106:[.22222,.61111,0,0],107:[0,.61111,0,0],108:[0,.61111,0,0],109:[0,.43056,0,0],110:[0,.43056,0,0],111:[0,.43056,0,0],112:[.22222,.43056,0,0],113:[.22222,.43056,0,0],114:[0,.43056,0,0],115:[0,.43056,0,0],116:[0,.55358,0,0],117:[0,.43056,0,0],118:[0,.43056,0,0],119:[0,.43056,0,0],120:[0,.43056,0,0],121:[.22222,.43056,0,0],122:[0,.43056,0,0],123:[.08333,.69444,0,0],124:[.08333,.69444,0,0],125:[.08333,.69444,0,0],126:[0,.61111,0,0],127:[0,.61111,0,0],305:[0,.43056,0,0],567:[.22222,.43056,0,0],768:[0,.61111,0,0],769:[0,.61111,0,0],770:[0,.61111,0,0],771:[0,.61111,0,0],772:[0,.56555,0,0],774:[0,.61111,0,0],776:[0,.61111,0,0],778:[0,.61111,0,0],780:[0,.56597,0,0],915:[0,.61111,0,0],916:[0,.61111,0,0],920:[0,.61111,0,0],923:[0,.61111,0,0],926:[0,.61111,0,0],928:[0,.61111,0,0],931:[0,.61111,0,0],933:[0,.61111,0,0],934:[0,.61111,0,0],936:[0,.61111,0,0],937:[0,.61111,0,0],2018:[0,.61111,0,0],2019:[0,.61111,0,0],8242:[0,.61111,0,0]}}},{}],43:[function(e,t,r){"use strict";var a=e("./utils");var i=u(a);var n=e("./ParseError");var l=u(n);var s=e("./ParseNode");var o=u(s);function u(e){return e&&e.__esModule?e:{default:e}}function f(e,r,a){if(typeof e==="string"){e=[e]}if(typeof r==="number"){r={numArgs:r}}var i={numArgs:r.numArgs,argTypes:r.argTypes,greediness:r.greediness===undefined?1:r.greediness,allowedInText:!!r.allowedInText,numOptionalArgs:r.numOptionalArgs||0,infix:!!r.infix,handler:a};for(var n=0;n","\\langle","\\rangle","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\\lmoustache","\\rmoustache","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];var p={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak"};f(["\\blue","\\orange","\\pink","\\red","\\green","\\gray","\\purple","\\blueA","\\blueB","\\blueC","\\blueD","\\blueE","\\tealA","\\tealB","\\tealC","\\tealD","\\tealE","\\greenA","\\greenB","\\greenC","\\greenD","\\greenE","\\goldA","\\goldB","\\goldC","\\goldD","\\goldE","\\redA","\\redB","\\redC","\\redD","\\redE","\\maroonA","\\maroonB","\\maroonC","\\maroonD","\\maroonE","\\purpleA","\\purpleB","\\purpleC","\\purpleD","\\purpleE","\\mintA","\\mintB","\\mintC","\\grayA","\\grayB","\\grayC","\\grayD","\\grayE","\\grayF","\\grayG","\\grayH","\\grayI","\\kaBlue","\\kaGreen"],{numArgs:1,allowedInText:true,greediness:3},function(e,t){var r=t[0];return{type:"color",color:"katex-"+e.funcName.slice(1),value:d(r)}});f(["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],{numArgs:0},function(e){return{type:"op",limits:false,symbol:false,body:e.funcName}});f(["\\det","\\gcd","\\inf","\\lim","\\liminf","\\limsup","\\max","\\min","\\Pr","\\sup"],{numArgs:0},function(e){return{type:"op",limits:true,symbol:false,body:e.funcName}});f(["\\int","\\iint","\\iiint","\\oint"],{numArgs:0},function(e){return{type:"op",limits:false,symbol:true,body:e.funcName}});f(["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint"],{numArgs:0},function(e){return{type:"op",limits:true,symbol:true,body:e.funcName}});f("\\mathop",{numArgs:1},function(e,t){var r=t[0];return{type:"op",limits:false,symbol:false,value:d(r)}});f(["\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac"],{numArgs:2,greediness:2 +},function(e,t){var r=t[0];var a=t[1];var i=void 0;var n=null;var l=null;var s="auto";switch(e.funcName){case"\\dfrac":case"\\frac":case"\\tfrac":i=true;break;case"\\\\atopfrac":i=false;break;case"\\dbinom":case"\\binom":case"\\tbinom":i=false;n="(";l=")";break;default:throw new Error("Unrecognized genfrac command")}switch(e.funcName){case"\\dfrac":case"\\dbinom":s="display";break;case"\\tfrac":case"\\tbinom":s="text";break}return{type:"genfrac",numer:r,denom:a,hasBarLine:i,leftDelim:n,rightDelim:l,size:s}});f(["\\llap","\\rlap"],{numArgs:1,allowedInText:true},function(e,t){var r=t[0];return{type:e.funcName.slice(1),body:r}});var m=function e(t,r){if(i.default.contains(v,t.value)){return t}else{throw new l.default("Invalid delimiter: '"+t.value+"' after '"+r.funcName+"'",t)}};f(["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],{numArgs:1},function(e,t){var r=m(t[0],e);return{type:"delimsizing",size:h[e.funcName].size,mclass:h[e.funcName].mclass,value:r.value}});f(["\\left","\\right"],{numArgs:1},function(e,t){var r=m(t[0],e);return{type:"leftright",value:r.value}});f("\\middle",{numArgs:1},function(e,t){var r=m(t[0],e);if(!e.parser.leftrightDepth){throw new l.default("\\middle without preceding \\left",r)}return{type:"middle",value:r.value}});f(["\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],0,null);f(["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],0,null);f(["\\rm","\\sf","\\tt","\\bf","\\it"],0,null);f(["\\mathrm","\\mathit","\\mathbf","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],{numArgs:1,greediness:2},function(e,t){var r=t[0];var a=e.funcName;if(a in p){a=p[a]}return{type:"font",font:a.slice(1),body:r}});f(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],{numArgs:1},function(e,t){var r=t[0];var a=!i.default.contains(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot"],e.funcName);var n=!a||i.default.contains(["\\widehat","\\widetilde"],e.funcName);return{type:"accent",label:e.funcName,isStretchy:a,isShifty:n,value:d(r),base:r}});f(["\\overbrace","\\underbrace"],{numArgs:1},function(e,t){var r=t[0];return{type:"horizBrace",label:e.funcName,isOver:/^\\over/.test(e.funcName),base:r}});f(["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\undertilde"],{numArgs:1},function(e,t){var r=t[0];return{type:"accentUnder",label:e.funcName,value:d(r),body:r}});f(["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xLongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xLongequal","\\xtofrom"],{numArgs:1,numOptionalArgs:1},function(e,t){var r=t[0];var a=t[1];return{type:"xArrow",label:e.funcName,body:a,below:r}});f(["\\cancel","\\bcancel","\\xcancel","\\sout","\\fbox"],{numArgs:1},function(e,t){var r=t[0];return{type:"enclose",label:e.funcName,body:r}});f(["\\over","\\choose","\\atop"],{numArgs:0,infix:true},function(e){var t=void 0;switch(e.funcName){case"\\over":t="\\frac";break;case"\\choose":t="\\binom";break;case"\\atop":t="\\\\atopfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",replaceWith:t,token:e.token}});f(["\\\\","\\cr"],{numArgs:0,numOptionalArgs:1,argTypes:["size"]},function(e,t){var r=t[0];return{type:"cr",size:r}});f(["\\begin","\\end"],{numArgs:1,argTypes:["text"]},function(e,t){var r=t[0];if(r.type!=="ordgroup"){throw new l.default("Invalid environment name",r)}var a="";for(var i=0;i";return t}}]);return e}();var d=function(){function e(t){(0,i.default)(this,e);this.text=t}(0,l.default)(e,[{key:"toNode",value:function e(){return document.createTextNode(this.text)}},{key:"toMarkup",value:function e(){return o.default.escape(this.text)}}]);return e}();t.exports={MathNode:f,TextNode:d}},{"./utils":51,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5}],46:[function(e,t,r){"use strict";var a=e("./Parser");var i=n(a);function n(e){return e&&e.__esModule?e:{default:e}}var l=function e(t,r){if(!(typeof t==="string"||t instanceof String)){throw new TypeError("KaTeX can only parse string typed expression")}var a=new i.default(t,r);return a.parse()};t.exports=l},{"./Parser":31}],47:[function(e,t,r){"use strict";var a=e("./buildCommon");var i=e("./mathMLTree");var n=e("./utils");var l={widehat:"^",widetilde:"~",undertilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23b5",overbrace:"\u23de",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21d2",xRightarrow:"\u21d2",overleftharpoon:"\u21bc",xleftharpoonup:"\u21bc",overrightharpoon:"\u21c0",xrightharpoonup:"\u21c0",xLeftarrow:"\u21d0",xLeftrightarrow:"\u21d4",xhookleftarrow:"\u21a9",xhookrightarrow:"\u21aa",xmapsto:"\u21a6",xrightharpoondown:"\u21c1",xleftharpoondown:"\u21bd",xrightleftharpoons:"\u21cc",xleftrightharpoons:"\u21cb",xtwoheadleftarrow:"\u219e",xtwoheadrightarrow:"\u21a0",xLongequal:"=",xtofrom:"\u21c4"};var s=function e(t){var r=new i.MathNode("mo",[new i.TextNode(l[t.substr(1)])]);r.setAttribute("stretchy","true");return r};var o={overleftarrow:[.522,0,"leftarrow"],underleftarrow:[.522,0,"leftarrow"],xleftarrow:[.261,.261,"leftarrow"],overrightarrow:[.522,0,"rightarrow"],underrightarrow:[.522,0,"rightarrow"],xrightarrow:[.261,.261,"rightarrow"],overbrace:[.548,0,"overbrace"],underbrace:[.548,0,"underbrace"],overleftrightarrow:[.522,0,"leftrightarrow"],underleftrightarrow:[.522,0,"leftrightarrow"],xleftrightarrow:[.261,.261,"leftrightarrow"],Overrightarrow:[.56,0,"doublerightarrow"],xLeftarrow:[.28,.28,"doubleleftarrow"],xRightarrow:[.28,.28,"doublerightarrow"],xLeftrightarrow:[.28,.28,"doubleleftrightarrow"],overleftharpoon:[.522,0,"leftharpoon"],overrightharpoon:[.522,0,"rightharpoon"],xleftharpoonup:[.261,.261,"leftharpoon"],xrightharpoonup:[.261,.261,"rightharpoon"],xhookleftarrow:[.261,.261,"hookleftarrow"],xhookrightarrow:[.261,.261,"hookrightarrow"],overlinesegment:[.414,0,"linesegment"],underlinesegment:[.414,0,"linesegment"],xmapsto:[.261,.261,"mapsto"],xrightharpoondown:[.261,.261,"rightharpoondown"],xleftharpoondown:[.261,.261,"leftharpoondown"],xrightleftharpoons:[.358,.358,"rightleftharpoons"],xleftrightharpoons:[.358,.358,"leftrightharpoons"],overgroup:[.342,0,"overgroup"],undergroup:[.342,0,"undergroup"],xtwoheadleftarrow:[.167,.167,"twoheadleftarrow"],xtwoheadrightarrow:[.167,.167,"twoheadrightarrow"],xLongequal:[.167,.167,"longequal"],xtofrom:[.264,.264,"tofrom"]};var u=function e(t,r){var i=t.value.label.substr(1);var l=0;var s=0;var u=["stretchy"];var f="";if(n.contains(["widehat","widetilde","undertilde"],i)){var d=t.value.value.length;if(d>5){l=.312;f=(i==="widehat"?"widehat":"tilde")+"4"}else{var c=[1,1,2,2,3,3][d];if(i==="widehat"){l=[0,.24,.3,.3,.36,.36][d];f="widehat"+c}else{l=[0,.26,.3,.3,.34,.34][d];f="tilde"+c}}}else{var h=o[i];l=h[0];s=h[1];f=h[2];if(i.substr(0,1)==="x"){u.push("x-arrow")}}var v=void 0;if(r.color){u.push(f);u.push("mask");u.push(f+"-mask");v=a.makeSpan(u,[],r);v.style.backgroundColor=r.getColor()}else{u.push(f);v=a.makeSpan(u,[],r)}v.height=l;v.depth=s;v.maxFontSize=1;return v};var f=function e(t,r,i,n,l){var s=a.makeSpan(["stretchy",i],[],l);if(l.color){if(i==="fbox"){s.style.borderColor=l.getColor()}else{s.classes[2]=i+"-mask";s.style.backgroundColor=l.getColor()}}s.height=t.height+t.depth+2*n;s.style.height=s.height+"em";if(/cancel/.test(i)&&r){s.maxFontSize=1.2}else{s.maxFontSize=1}return s};t.exports={encloseSpan:f,mathMLnode:s,svgSpan:u}},{"./buildCommon":34,"./mathMLTree":45,"./utils":51}],48:[function(e,t,r){"use strict";t.exports={math:{},text:{}};function a(e,r,a,i,n,l){t.exports[e][n]={font:r,group:a,replace:i};if(l){t.exports[e][i]=t.exports[e][n]}}var i="math";var n="text";var l="main";var s="ams";var o="accent";var u="bin";var f="close";var d="inner";var c="mathord";var h="op";var v="open";var p="punct";var m="rel";var g="spacing";var y="textord";a(i,l,m,"\u2261","\\equiv");a(i,l,m,"\u227a","\\prec");a(i,l,m,"\u227b","\\succ");a(i,l,m,"\u223c","\\sim");a(i,l,m,"\u22a5","\\perp");a(i,l,m,"\u2aaf","\\preceq");a(i,l,m,"\u2ab0","\\succeq");a(i,l,m,"\u2243","\\simeq");a(i,l,m,"\u2223","\\mid");a(i,l,m,"\u226a","\\ll");a(i,l,m,"\u226b","\\gg");a(i,l,m,"\u224d","\\asymp");a(i,l,m,"\u2225","\\parallel");a(i,l,m,"\u22c8","\\bowtie");a(i,l,m,"\u2323","\\smile");a(i,l,m,"\u2291","\\sqsubseteq");a(i,l,m,"\u2292","\\sqsupseteq");a(i,l,m,"\u2250","\\doteq");a(i,l,m,"\u2322","\\frown");a(i,l,m,"\u220b","\\ni");a(i,l,m,"\u221d","\\propto");a(i,l,m,"\u22a2","\\vdash");a(i,l,m,"\u22a3","\\dashv");a(i,l,m,"\u220b","\\owns");a(i,l,p,".","\\ldotp");a(i,l,p,"\u22c5","\\cdotp");a(i,l,y,"#","\\#");a(n,l,y,"#","\\#");a(i,l,y,"&","\\&");a(n,l,y,"&","\\&");a(i,l,y,"\u2135","\\aleph");a(i,l,y,"\u2200","\\forall");a(i,l,y,"\u210f","\\hbar");a(i,l,y,"\u2203","\\exists");a(i,l,y,"\u2207","\\nabla");a(i,l,y,"\u266d","\\flat");a(i,l,y,"\u2113","\\ell");a(i,l,y,"\u266e","\\natural");a(i,l,y,"\u2663","\\clubsuit");a(i,l,y,"\u2118","\\wp");a(i,l,y,"\u266f","\\sharp");a(i,l,y,"\u2662","\\diamondsuit");a(i,l,y,"\u211c","\\Re");a(i,l,y,"\u2661","\\heartsuit");a(i,l,y,"\u2111","\\Im");a(i,l,y,"\u2660","\\spadesuit");a(i,l,y,"\u2020","\\dag");a(n,l,y,"\u2020","\\dag");a(n,l,y,"\u2020","\\textdagger");a(i,l,y,"\u2021","\\ddag");a(n,l,y,"\u2021","\\ddag");a(n,l,y,"\u2020","\\textdaggerdbl");a(i,l,f,"\u23b1","\\rmoustache");a(i,l,v,"\u23b0","\\lmoustache");a(i,l,f,"\u27ef","\\rgroup");a(i,l,v,"\u27ee","\\lgroup");a(i,l,u,"\u2213","\\mp");a(i,l,u,"\u2296","\\ominus");a(i,l,u,"\u228e","\\uplus");a(i,l,u,"\u2293","\\sqcap");a(i,l,u,"\u2217","\\ast");a(i,l,u,"\u2294","\\sqcup");a(i,l,u,"\u25ef","\\bigcirc");a(i,l,u,"\u2219","\\bullet");a(i,l,u,"\u2021","\\ddagger");a(i,l,u,"\u2240","\\wr");a(i,l,u,"\u2a3f","\\amalg");a(i,l,m,"\u27f5","\\longleftarrow");a(i,l,m,"\u21d0","\\Leftarrow");a(i,l,m,"\u27f8","\\Longleftarrow");a(i,l,m,"\u27f6","\\longrightarrow");a(i,l,m,"\u21d2","\\Rightarrow");a(i,l,m,"\u27f9","\\Longrightarrow");a(i,l,m,"\u2194","\\leftrightarrow");a(i,l,m,"\u27f7","\\longleftrightarrow");a(i,l,m,"\u21d4","\\Leftrightarrow");a(i,l,m,"\u27fa","\\Longleftrightarrow");a(i,l,m,"\u21a6","\\mapsto");a(i,l,m,"\u27fc","\\longmapsto");a(i,l,m,"\u2197","\\nearrow");a(i,l,m,"\u21a9","\\hookleftarrow");a(i,l,m,"\u21aa","\\hookrightarrow");a(i,l,m,"\u2198","\\searrow");a(i,l,m,"\u21bc","\\leftharpoonup");a(i,l,m,"\u21c0","\\rightharpoonup");a(i,l,m,"\u2199","\\swarrow");a(i,l,m,"\u21bd","\\leftharpoondown");a(i,l,m,"\u21c1","\\rightharpoondown");a(i,l,m,"\u2196","\\nwarrow");a(i,l,m,"\u21cc","\\rightleftharpoons");a(i,s,m,"\u226e","\\nless");a(i,s,m,"\ue010","\\nleqslant");a(i,s,m,"\ue011","\\nleqq");a(i,s,m,"\u2a87","\\lneq");a(i,s,m,"\u2268","\\lneqq");a(i,s,m,"\ue00c","\\lvertneqq");a(i,s,m,"\u22e6","\\lnsim");a(i,s,m,"\u2a89","\\lnapprox");a(i,s,m,"\u2280","\\nprec");a(i,s,m,"\u22e0","\\npreceq");a(i,s,m,"\u22e8","\\precnsim");a(i,s,m,"\u2ab9","\\precnapprox");a(i,s,m,"\u2241","\\nsim");a(i,s,m,"\ue006","\\nshortmid");a(i,s,m,"\u2224","\\nmid");a(i,s,m,"\u22ac","\\nvdash");a(i,s,m,"\u22ad","\\nvDash");a(i,s,m,"\u22ea","\\ntriangleleft");a(i,s,m,"\u22ec","\\ntrianglelefteq");a(i,s,m,"\u228a","\\subsetneq");a(i,s,m,"\ue01a","\\varsubsetneq");a(i,s,m,"\u2acb","\\subsetneqq");a(i,s,m,"\ue017","\\varsubsetneqq");a(i,s,m,"\u226f","\\ngtr");a(i,s,m,"\ue00f","\\ngeqslant");a(i,s,m,"\ue00e","\\ngeqq");a(i,s,m,"\u2a88","\\gneq");a(i,s,m,"\u2269","\\gneqq");a(i,s,m,"\ue00d","\\gvertneqq");a(i,s,m,"\u22e7","\\gnsim");a(i,s,m,"\u2a8a","\\gnapprox");a(i,s,m,"\u2281","\\nsucc");a(i,s,m,"\u22e1","\\nsucceq");a(i,s,m,"\u22e9","\\succnsim");a(i,s,m,"\u2aba","\\succnapprox");a(i,s,m,"\u2246","\\ncong");a(i,s,m,"\ue007","\\nshortparallel");a(i,s,m,"\u2226","\\nparallel");a(i,s,m,"\u22af","\\nVDash");a(i,s,m,"\u22eb","\\ntriangleright");a(i,s,m,"\u22ed","\\ntrianglerighteq");a(i,s,m,"\ue018","\\nsupseteqq");a(i,s,m,"\u228b","\\supsetneq");a(i,s,m,"\ue01b","\\varsupsetneq");a(i,s,m,"\u2acc","\\supsetneqq");a(i,s,m,"\ue019","\\varsupsetneqq");a(i,s,m,"\u22ae","\\nVdash");a(i,s,m,"\u2ab5","\\precneqq");a(i,s,m,"\u2ab6","\\succneqq");a(i,s,m,"\ue016","\\nsubseteqq");a(i,s,u,"\u22b4","\\unlhd");a(i,s,u,"\u22b5","\\unrhd");a(i,s,m,"\u219a","\\nleftarrow");a(i,s,m,"\u219b","\\nrightarrow");a(i,s,m,"\u21cd","\\nLeftarrow");a(i,s,m,"\u21cf","\\nRightarrow");a(i,s,m,"\u21ae","\\nleftrightarrow");a(i,s,m,"\u21ce","\\nLeftrightarrow");a(i,s,m,"\u25b3","\\vartriangle");a(i,s,y,"\u210f","\\hslash");a(i,s,y,"\u25bd","\\triangledown");a(i,s,y,"\u25ca","\\lozenge");a(i,s,y,"\u24c8","\\circledS");a(i,s,y,"\xae","\\circledR");a(n,s,y,"\xae","\\circledR");a(i,s,y,"\u2221","\\measuredangle");a(i,s,y,"\u2204","\\nexists");a(i,s,y,"\u2127","\\mho");a(i,s,y,"\u2132","\\Finv");a(i,s,y,"\u2141","\\Game");a(i,s,y,"k","\\Bbbk");a(i,s,y,"\u2035","\\backprime");a(i,s,y,"\u25b2","\\blacktriangle");a(i,s,y,"\u25bc","\\blacktriangledown");a(i,s,y,"\u25a0","\\blacksquare");a(i,s,y,"\u29eb","\\blacklozenge");a(i,s,y,"\u2605","\\bigstar");a(i,s,y,"\u2222","\\sphericalangle");a(i,s,y,"\u2201","\\complement");a(i,s,y,"\xf0","\\eth");a(i,s,y,"\u2571","\\diagup");a(i,s,y,"\u2572","\\diagdown");a(i,s,y,"\u25a1","\\square");a(i,s,y,"\u25a1","\\Box");a(i,s,y,"\u25ca","\\Diamond");a(i,s,y,"\xa5","\\yen");a(i,s,y,"\u2713","\\checkmark");a(n,s,y,"\u2713","\\checkmark");a(i,s,y,"\u2136","\\beth");a(i,s,y,"\u2138","\\daleth");a(i,s,y,"\u2137","\\gimel");a(i,s,y,"\u03dd","\\digamma");a(i,s,y,"\u03f0","\\varkappa");a(i,s,v,"\u250c","\\ulcorner");a(i,s,f,"\u2510","\\urcorner");a(i,s,v,"\u2514","\\llcorner");a(i,s,f,"\u2518","\\lrcorner");a(i,s,m,"\u2266","\\leqq");a(i,s,m,"\u2a7d","\\leqslant");a(i,s,m,"\u2a95","\\eqslantless");a(i,s,m,"\u2272","\\lesssim");a(i,s,m,"\u2a85","\\lessapprox");a(i,s,m,"\u224a","\\approxeq");a(i,s,u,"\u22d6","\\lessdot");a(i,s,m,"\u22d8","\\lll");a(i,s,m,"\u2276","\\lessgtr");a(i,s,m,"\u22da","\\lesseqgtr");a(i,s,m,"\u2a8b","\\lesseqqgtr");a(i,s,m,"\u2251","\\doteqdot");a(i,s,m,"\u2253","\\risingdotseq");a(i,s,m,"\u2252","\\fallingdotseq");a(i,s,m,"\u223d","\\backsim");a(i,s,m,"\u22cd","\\backsimeq");a(i,s,m,"\u2ac5","\\subseteqq");a(i,s,m,"\u22d0","\\Subset");a(i,s,m,"\u228f","\\sqsubset");a(i,s,m,"\u227c","\\preccurlyeq");a(i,s,m,"\u22de","\\curlyeqprec");a(i,s,m,"\u227e","\\precsim");a(i,s,m,"\u2ab7","\\precapprox");a(i,s,m,"\u22b2","\\vartriangleleft");a(i,s,m,"\u22b4","\\trianglelefteq");a(i,s,m,"\u22a8","\\vDash");a(i,s,m,"\u22aa","\\Vvdash");a(i,s,m,"\u2323","\\smallsmile");a(i,s,m,"\u2322","\\smallfrown");a(i,s,m,"\u224f","\\bumpeq");a(i,s,m,"\u224e","\\Bumpeq");a(i,s,m,"\u2267","\\geqq");a(i,s,m,"\u2a7e","\\geqslant");a(i,s,m,"\u2a96","\\eqslantgtr");a(i,s,m,"\u2273","\\gtrsim");a(i,s,m,"\u2a86","\\gtrapprox");a(i,s,u,"\u22d7","\\gtrdot");a(i,s,m,"\u22d9","\\ggg");a(i,s,m,"\u2277","\\gtrless");a(i,s,m,"\u22db","\\gtreqless");a(i,s,m,"\u2a8c","\\gtreqqless");a(i,s,m,"\u2256","\\eqcirc");a(i,s,m,"\u2257","\\circeq");a(i,s,m,"\u225c","\\triangleq");a(i,s,m,"\u223c","\\thicksim");a(i,s,m,"\u2248","\\thickapprox");a(i,s,m,"\u2ac6","\\supseteqq");a(i,s,m,"\u22d1","\\Supset");a(i,s,m,"\u2290","\\sqsupset");a(i,s,m,"\u227d","\\succcurlyeq");a(i,s,m,"\u22df","\\curlyeqsucc");a(i,s,m,"\u227f","\\succsim");a(i,s,m,"\u2ab8","\\succapprox");a(i,s,m,"\u22b3","\\vartriangleright");a(i,s,m,"\u22b5","\\trianglerighteq");a(i,s,m,"\u22a9","\\Vdash");a(i,s,m,"\u2223","\\shortmid");a(i,s,m,"\u2225","\\shortparallel");a(i,s,m,"\u226c","\\between");a(i,s,m,"\u22d4","\\pitchfork");a(i,s,m,"\u221d","\\varpropto");a(i,s,m,"\u25c0","\\blacktriangleleft");a(i,s,m,"\u2234","\\therefore");a(i,s,m,"\u220d","\\backepsilon");a(i,s,m,"\u25b6","\\blacktriangleright");a(i,s,m,"\u2235","\\because");a(i,s,m,"\u22d8","\\llless");a(i,s,m,"\u22d9","\\gggtr");a(i,s,u,"\u22b2","\\lhd");a(i,s,u,"\u22b3","\\rhd");a(i,s,m,"\u2242","\\eqsim");a(i,l,m,"\u22c8","\\Join");a(i,s,m,"\u2251","\\Doteq");a(i,s,u,"\u2214","\\dotplus");a(i,s,u,"\u2216","\\smallsetminus");a(i,s,u,"\u22d2","\\Cap");a(i,s,u,"\u22d3","\\Cup");a(i,s,u,"\u2a5e","\\doublebarwedge");a(i,s,u,"\u229f","\\boxminus");a(i,s,u,"\u229e","\\boxplus");a(i,s,u,"\u22c7","\\divideontimes");a(i,s,u,"\u22c9","\\ltimes");a(i,s,u,"\u22ca","\\rtimes");a(i,s,u,"\u22cb","\\leftthreetimes");a(i,s,u,"\u22cc","\\rightthreetimes");a(i,s,u,"\u22cf","\\curlywedge");a(i,s,u,"\u22ce","\\curlyvee");a(i,s,u,"\u229d","\\circleddash");a(i,s,u,"\u229b","\\circledast");a(i,s,u,"\u22c5","\\centerdot");a(i,s,u,"\u22ba","\\intercal");a(i,s,u,"\u22d2","\\doublecap");a(i,s,u,"\u22d3","\\doublecup");a(i,s,u,"\u22a0","\\boxtimes");a(i,s,m,"\u21e2","\\dashrightarrow");a(i,s,m,"\u21e0","\\dashleftarrow");a(i,s,m,"\u21c7","\\leftleftarrows");a(i,s,m,"\u21c6","\\leftrightarrows");a(i,s,m,"\u21da","\\Lleftarrow");a(i,s,m,"\u219e","\\twoheadleftarrow");a(i,s,m,"\u21a2","\\leftarrowtail");a(i,s,m,"\u21ab","\\looparrowleft");a(i,s,m,"\u21cb","\\leftrightharpoons");a(i,s,m,"\u21b6","\\curvearrowleft");a(i,s,m,"\u21ba","\\circlearrowleft");a(i,s,m,"\u21b0","\\Lsh");a(i,s,m,"\u21c8","\\upuparrows");a(i,s,m,"\u21bf","\\upharpoonleft");a(i,s,m,"\u21c3","\\downharpoonleft");a(i,s,m,"\u22b8","\\multimap");a(i,s,m,"\u21ad","\\leftrightsquigarrow");a(i,s,m,"\u21c9","\\rightrightarrows");a(i,s,m,"\u21c4","\\rightleftarrows");a(i,s,m,"\u21a0","\\twoheadrightarrow");a(i,s,m,"\u21a3","\\rightarrowtail");a(i,s,m,"\u21ac","\\looparrowright");a(i,s,m,"\u21b7","\\curvearrowright");a(i,s,m,"\u21bb","\\circlearrowright");a(i,s,m,"\u21b1","\\Rsh");a(i,s,m,"\u21ca","\\downdownarrows");a(i,s,m,"\u21be","\\upharpoonright");a(i,s,m,"\u21c2","\\downharpoonright");a(i,s,m,"\u21dd","\\rightsquigarrow");a(i,s,m,"\u21dd","\\leadsto");a(i,s,m,"\u21db","\\Rrightarrow");a(i,s,m,"\u21be","\\restriction");a(i,l,y,"\u2018","`");a(i,l,y,"$","\\$");a(n,l,y,"$","\\$");a(n,l,y,"$","\\textdollar");a(i,l,y,"%","\\%");a(n,l,y,"%","\\%");a(i,l,y,"_","\\_");a(n,l,y,"_","\\_");a(n,l,y,"_","\\textunderscore");a(i,l,y,"\u2220","\\angle");a(i,l,y,"\u221e","\\infty");a(i,l,y,"\u2032","\\prime");a(i,l,y,"\u25b3","\\triangle");a(i,l,y,"\u0393","\\Gamma",true);a(i,l,y,"\u0394","\\Delta",true);a(i,l,y,"\u0398","\\Theta",true);a(i,l,y,"\u039b","\\Lambda",true);a(i,l,y,"\u039e","\\Xi",true);a(i,l,y,"\u03a0","\\Pi",true);a(i,l,y,"\u03a3","\\Sigma",true);a(i,l,y,"\u03a5","\\Upsilon",true);a(i,l,y,"\u03a6","\\Phi",true);a(i,l,y,"\u03a8","\\Psi",true);a(i,l,y,"\u03a9","\\Omega",true);a(i,l,y,"\xac","\\neg");a(i,l,y,"\xac","\\lnot");a(i,l,y,"\u22a4","\\top");a(i,l,y,"\u22a5","\\bot");a(i,l,y,"\u2205","\\emptyset");a(i,s,y,"\u2205","\\varnothing");a(i,l,c,"\u03b1","\\alpha",true);a(i,l,c,"\u03b2","\\beta",true);a(i,l,c,"\u03b3","\\gamma",true);a(i,l,c,"\u03b4","\\delta",true);a(i,l,c,"\u03f5","\\epsilon",true);a(i,l,c,"\u03b6","\\zeta",true);a(i,l,c,"\u03b7","\\eta",true);a(i,l,c,"\u03b8","\\theta",true);a(i,l,c,"\u03b9","\\iota",true);a(i,l,c,"\u03ba","\\kappa",true);a(i,l,c,"\u03bb","\\lambda",true);a(i,l,c,"\u03bc","\\mu",true);a(i,l,c,"\u03bd","\\nu",true);a(i,l,c,"\u03be","\\xi",true);a(i,l,c,"\u03bf","\\omicron",true);a(i,l,c,"\u03c0","\\pi",true);a(i,l,c,"\u03c1","\\rho",true);a(i,l,c,"\u03c3","\\sigma",true);a(i,l,c,"\u03c4","\\tau",true);a(i,l,c,"\u03c5","\\upsilon",true);a(i,l,c,"\u03d5","\\phi",true);a(i,l,c,"\u03c7","\\chi",true);a(i,l,c,"\u03c8","\\psi",true);a(i,l,c,"\u03c9","\\omega",true);a(i,l,c,"\u03b5","\\varepsilon",true);a(i,l,c,"\u03d1","\\vartheta",true);a(i,l,c,"\u03d6","\\varpi",true);a(i,l,c,"\u03f1","\\varrho",true);a(i,l,c,"\u03c2","\\varsigma",true);a(i,l,c,"\u03c6","\\varphi",true);a(i,l,u,"\u2217","*");a(i,l,u,"+","+");a(i,l,u,"\u2212","-");a(i,l,u,"\u22c5","\\cdot");a(i,l,u,"\u2218","\\circ");a(i,l,u,"\xf7","\\div");a(i,l,u,"\xb1","\\pm");a(i,l,u,"\xd7","\\times");a(i,l,u,"\u2229","\\cap");a(i,l,u,"\u222a","\\cup");a(i,l,u,"\u2216","\\setminus");a(i,l,u,"\u2227","\\land");a(i,l,u,"\u2228","\\lor");a(i,l,u,"\u2227","\\wedge");a(i,l,u,"\u2228","\\vee");a(i,l,y,"\u221a","\\surd");a(i,l,v,"(","(");a(i,l,v,"[","[");a(i,l,v,"\u27e8","\\langle");a(i,l,v,"\u2223","\\lvert");a(i,l,v,"\u2225","\\lVert");a(i,l,f,")",")");a(i,l,f,"]","]");a(i,l,f,"?","?");a(i,l,f,"!","!");a(i,l,f,"\u27e9","\\rangle");a(i,l,f,"\u2223","\\rvert");a(i,l,f,"\u2225","\\rVert");a(i,l,m,"=","=");a(i,l,m,"<","<");a(i,l,m,">",">");a(i,l,m,":",":");a(i,l,m,"\u2248","\\approx");a(i,l,m,"\u2245","\\cong");a(i,l,m,"\u2265","\\ge");a(i,l,m,"\u2265","\\geq");a(i,l,m,"\u2190","\\gets");a(i,l,m,">","\\gt");a(i,l,m,"\u2208","\\in");a(i,l,m,"\u2209","\\notin");a(i,l,m,"\u2282","\\subset");a(i,l,m,"\u2283","\\supset");a(i,l,m,"\u2286","\\subseteq");a(i,l,m,"\u2287","\\supseteq");a(i,s,m,"\u2288","\\nsubseteq");a(i,s,m,"\u2289","\\nsupseteq");a(i,l,m,"\u22a8","\\models");a(i,l,m,"\u2190","\\leftarrow");a(i,l,m,"\u2264","\\le");a(i,l,m,"\u2264","\\leq");a(i,l,m,"<","\\lt");a(i,l,m,"\u2260","\\ne");a(i,l,m,"\u2260","\\neq");a(i,l,m,"\u2192","\\rightarrow");a(i,l,m,"\u2192","\\to");a(i,s,m,"\u2271","\\ngeq");a(i,s,m,"\u2270","\\nleq");a(i,l,g,null,"\\!");a(i,l,g,"\xa0","\\ ");a(i,l,g,"\xa0","~");a(i,l,g,null,"\\,");a(i,l,g,null,"\\:");a(i,l,g,null,"\\;");a(i,l,g,null,"\\enspace");a(i,l,g,null,"\\qquad");a(i,l,g,null,"\\quad");a(i,l,g,"\xa0","\\space");a(i,l,p,",",",");a(i,l,p,";",";");a(i,l,p,":","\\colon");a(i,s,u,"\u22bc","\\barwedge");a(i,s,u,"\u22bb","\\veebar");a(i,l,u,"\u2299","\\odot");a(i,l,u,"\u2295","\\oplus");a(i,l,u,"\u2297","\\otimes");a(i,l,y,"\u2202","\\partial");a(i,l,u,"\u2298","\\oslash");a(i,s,u,"\u229a","\\circledcirc");a(i,s,u,"\u22a1","\\boxdot");a(i,l,u,"\u25b3","\\bigtriangleup");a(i,l,u,"\u25bd","\\bigtriangledown");a(i,l,u,"\u2020","\\dagger");a(i,l,u,"\u22c4","\\diamond");a(i,l,u,"\u22c6","\\star");a(i,l,u,"\u25c3","\\triangleleft");a(i,l,u,"\u25b9","\\triangleright");a(i,l,v,"{","\\{");a(n,l,y,"{","\\{");a(n,l,y,"{","\\textbraceleft");a(i,l,f,"}","\\}");a(n,l,y,"}","\\}");a(n,l,y,"}","\\textbraceright");a(i,l,v,"{","\\lbrace");a(i,l,f,"}","\\rbrace");a(i,l,v,"[","\\lbrack");a(i,l,f,"]","\\rbrack");a(n,l,y,"<","\\textless");a(n,l,y,">","\\textgreater");a(i,l,v,"\u230a","\\lfloor");a(i,l,f,"\u230b","\\rfloor");a(i,l,v,"\u2308","\\lceil");a(i,l,f,"\u2309","\\rceil");a(i,l,y,"\\","\\backslash");a(i,l,y,"\u2223","|");a(i,l,y,"\u2223","\\vert");a(n,l,y,"|","\\textbar");a(i,l,y,"\u2225","\\|");a(i,l,y,"\u2225","\\Vert");a(n,l,y,"\u2225","\\textbardbl");a(i,l,m,"\u2191","\\uparrow");a(i,l,m,"\u21d1","\\Uparrow");a(i,l,m,"\u2193","\\downarrow");a(i,l,m,"\u21d3","\\Downarrow");a(i,l,m,"\u2195","\\updownarrow");a(i,l,m,"\u21d5","\\Updownarrow");a(i,l,h,"\u2210","\\coprod");a(i,l,h,"\u22c1","\\bigvee");a(i,l,h,"\u22c0","\\bigwedge");a(i,l,h,"\u2a04","\\biguplus");a(i,l,h,"\u22c2","\\bigcap");a(i,l,h,"\u22c3","\\bigcup");a(i,l,h,"\u222b","\\int");a(i,l,h,"\u222b","\\intop");a(i,l,h,"\u222c","\\iint");a(i,l,h,"\u222d","\\iiint");a(i,l,h,"\u220f","\\prod");a(i,l,h,"\u2211","\\sum");a(i,l,h,"\u2a02","\\bigotimes");a(i,l,h,"\u2a01","\\bigoplus");a(i,l,h,"\u2a00","\\bigodot");a(i,l,h,"\u222e","\\oint");a(i,l,h,"\u2a06","\\bigsqcup");a(i,l,h,"\u222b","\\smallint");a(n,l,d,"\u2026","\\textellipsis");a(i,l,d,"\u2026","\\mathellipsis");a(n,l,d,"\u2026","\\ldots");a(i,l,d,"\u2026","\\ldots");a(i,l,d,"\u22ef","\\cdots");a(i,l,d,"\u22f1","\\ddots");a(i,l,y,"\u22ee","\\vdots");a(i,l,o,"\xb4","\\acute");a(i,l,o,"`","\\grave");a(i,l,o,"\xa8","\\ddot");a(i,l,o,"~","\\tilde");a(i,l,o,"\xaf","\\bar");a(i,l,o,"\u02d8","\\breve");a(i,l,o,"\u02c7","\\check");a(i,l,o,"^","\\hat");a(i,l,o,"\u20d7","\\vec");a(i,l,o,"\u02d9","\\dot");a(i,l,c,"\u0131","\\imath");a(i,l,c,"\u0237","\\jmath");a(n,l,y,"\u2013","--");a(n,l,y,"\u2013","\\textendash");a(n,l,y,"\u2014","---");a(n,l,y,"\u2014","\\textemdash");a(n,l,y,"\u2018","`");a(n,l,y,"\u2018","\\textquoteleft");a(n,l,y,"\u2019","'");a(n,l,y,"\u2019","\\textquoteright");a(n,l,y,"\u201c","``");a(n,l,y,"\u201c","\\textquotedblleft");a(n,l,y,"\u201d","''");a(n,l,y,"\u201d","\\textquotedblright");a(i,l,y,"\xb0","\\degree");a(n,l,y,"\xb0","\\degree");a(i,l,c,"\xa3","\\pounds");a(i,l,c,"\xa3","\\mathsterling");a(n,l,c,"\xa3","\\pounds");a(n,l,c,"\xa3","\\textsterling");a(i,s,y,"\u2720","\\maltese");a(n,s,y,"\u2720","\\maltese");a(n,l,g,"\xa0","\\ ");a(n,l,g,"\xa0"," ");a(n,l,g,"\xa0","~");var b='0123456789/@."';for(var x=0;x":">","<":"<",'"':""","'":"'"};var f=/[&><"']/g;function d(e){return u[e]}function c(e){return(""+e).replace(f,d)}var h=void 0;if(typeof document!=="undefined"){var v=document.createElement("span");if("textContent"in v){h=function e(t,r){t.textContent=r}}else{h=function e(t,r){t.innerText=r}}}function p(e){h(e,"")}t.exports={contains:n,deflt:l,escape:c,hyphenate:o,indexOf:i,setTextContent:h,clearNode:p}},{}]},{},[1])(1)}); + + +// https://d3js.org v5.9.7 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.d3=t.d3||{})}(this,function(t){"use strict";function n(t,n){return tn?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>>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>>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(;++a1)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=e)for(r=i=e;++ae&&(r=e),i=e)for(r=i=e;++ae&&(r=e),i0)return[t];if((r=n0)for(t=Math.ceil(t/a),n=Math.floor(n/a),o=new Array(i=Math.ceil(n-t+1));++u=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=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=e)for(r=e;++or&&(r=e)}else for(;++o=e)for(r=e;++or&&(r=e);return r}function T(t){for(var n,e,r,i=t.length,o=-1,a=0;++o=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=e)for(r=e;++oe&&(r=e)}else for(;++o=e)for(r=e;++oe&&(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=0&&(n=t.slice(e+1),t=t.slice(0,e)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})),a=-1,u=o.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++a0)for(var e,r,i=new Array(e),o=0;o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),V.hasOwnProperty(n)?{space:V[n],local:t}:t}function W(t){var n=$(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===G&&n.documentElement.namespaceURI===G?n.createElement(t):n.createElementNS(e,t)}})(n)}function Z(){}function Q(t){return null==t?Z:function(){return this.querySelector(t)}}function J(){return[]}function K(t){return null==t?J:function(){return this.querySelectorAll(t)}}function tt(t){return function(){return this.matches(t)}}function nt(t){return new Array(t.length)}function et(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}et.prototype={constructor:et,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 rt="$";function it(t,n,e,r,i,o){for(var a,u=0,c=n.length,f=o.length;un?1:t>=n?0:NaN}function ut(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ct(t,n){return t.style.getPropertyValue(n)||ut(t).getComputedStyle(t,null).getPropertyValue(n)}function ft(t){return t.trim().split(/^|\s+/)}function st(t){return t.classList||new lt(t)}function lt(t){this._node=t,this._names=ft(t.getAttribute("class")||"")}function ht(t,n){for(var e=st(t),r=-1,i=n.length;++r=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var wt={};(t.event=null,"undefined"!=typeof document)&&("onmouseenter"in document.documentElement||(wt={mouseenter:"mouseover",mouseleave:"mouseout"}));function Mt(t,n,e){return t=Nt(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function Nt(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 At(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;r=x&&(x=m+1);!(b=y[x])&&++x=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=at);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?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)):ct(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=ft(t+"");if(arguments.length<2){for(var r=st(this.node()),i=-1,o=e.length;++i=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?Tt:At,null==e&&(e=!1),r=0;r>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):(n=rn.exec(t))?dn(parseInt(n[1],16)):(n=on.exec(t))?new yn(n[1],n[2],n[3],1):(n=an.exec(t))?new yn(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=un.exec(t))?pn(n[1],n[2],n[3],n[4]):(n=cn.exec(t))?pn(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=fn.exec(t))?bn(n[1],n[2]/100,n[3]/100,1):(n=sn.exec(t))?bn(n[1],n[2]/100,n[3]/100,n[4]):ln.hasOwnProperty(t)?dn(ln[t]):"transparent"===t?new yn(NaN,NaN,NaN,0):null}function dn(t){return new yn(t>>16&255,t>>8&255,255&t,1)}function pn(t,n,e,r){return r<=0&&(t=n=e=NaN),new yn(t,n,e,r)}function vn(t){return t instanceof Jt||(t=hn(t)),t?new yn((t=t.rgb()).r,t.g,t.b,t.opacity):new yn}function gn(t,n,e,r){return 1===arguments.length?vn(t):new yn(t,n,e,null==r?1:r)}function yn(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function _n(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function bn(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new xn(t,n,e,r)}function mn(t,n,e,r){return 1===arguments.length?function(t){if(t instanceof xn)return new xn(t.h,t.s,t.l,t.opacity);if(t instanceof Jt||(t=hn(t)),!t)return new xn;if(t instanceof xn)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*(e0&&c<1?0:a,new xn(a,u,c,t.opacity)}(t):new xn(t,n,e,null==r?1:r)}function xn(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function wn(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}Zt(Jt,hn,{displayable:function(){return this.rgb().displayable()},hex:function(){return this.rgb().hex()},toString:function(){return this.rgb()+""}}),Zt(yn,gn,Qt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new yn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new yn(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:function(){return"#"+_n(this.r)+_n(this.g)+_n(this.b)},toString:function(){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+")")}})),Zt(xn,mn,Qt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new xn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new xn(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 yn(wn(t>=240?t-240:t+120,i,r),wn(t,i,r),wn(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}}));var Mn=Math.PI/180,Nn=180/Math.PI,An=.96422,Tn=1,Sn=.82521,kn=4/29,En=6/29,Cn=3*En*En,Pn=En*En*En;function zn(t){if(t instanceof Dn)return new Dn(t.l,t.a,t.b,t.opacity);if(t instanceof Fn)return In(t);t instanceof yn||(t=vn(t));var n,e,r=On(t.r),i=On(t.g),o=On(t.b),a=qn((.2225045*r+.7168786*i+.0606169*o)/Tn);return r===i&&i===o?n=e=a:(n=qn((.4360747*r+.3850649*i+.1430804*o)/An),e=qn((.0139322*r+.0971045*i+.7141733*o)/Sn)),new Dn(116*a-16,500*(n-a),200*(a-e),t.opacity)}function Rn(t,n,e,r){return 1===arguments.length?zn(t):new Dn(t,n,e,null==r?1:r)}function Dn(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function qn(t){return t>Pn?Math.pow(t,1/3):t/Cn+kn}function Ln(t){return t>En?t*t*t:Cn*(t-kn)}function Un(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function On(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Bn(t){if(t instanceof Fn)return new Fn(t.h,t.c,t.l,t.opacity);if(t instanceof Dn||(t=zn(t)),0===t.a&&0===t.b)return new Fn(NaN,0=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=r180||e<-180?e-360*Math.round(e/360):e):ee(isNaN(t)?n:t)}function oe(t){return 1==(t=+t)?ae: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):ee(isNaN(n)?e:n)}}function ae(t,n){var e=n-t;return e?re(t,e):ee(isNaN(t)?n:t)}Zt(Jn,Qn,Qt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new Jn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new Jn(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*Mn,n=+this.l,e=isNaN(this.s)?0:this.s*n*(1-n),r=Math.cos(t),i=Math.sin(t);return new yn(255*(n+e*(jn*r+Hn*i)),255*(n+e*(Xn*r+Gn*i)),255*(n+e*(Vn*r)),this.opacity)}}));var ue=function t(n){var e=oe(n);function r(t,n){var r=e((t=gn(t)).r,(n=gn(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=ae(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 ce(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;eo&&(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:de(e,r)})),o=ge.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:de(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:de(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:de(t,e)},{i:u-2,x:de(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=0&&n._call.call(null,t),n=n._next;--Ve}function ur(){Je=(Qe=tr.now())+Ke,Ve=$e=0;try{ar()}finally{Ve=0,function(){var t,n,e=Xe,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:Xe=n);Ge=t,fr(r)}(),Je=0}}function cr(){var t=tr.now(),n=t-Qe;n>Ze&&(Ke-=n,Qe=t)}function fr(t){Ve||($e&&($e=clearTimeout($e)),t-Je>24?(t<1/0&&($e=setTimeout(ur,t-tr.now()-Ke)),We&&(We=clearInterval(We))):(We||(Qe=tr.now(),We=setInterval(cr,Ze)),Ve=1,nr(ur)))}function sr(t,n,e){var r=new ir;return n=null==n?0:+n,r.restart(function(e){r.stop(),t(e+n)},n,e),r}ir.prototype=or.prototype={constructor:ir,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?er():+e)+(null==n?0:+n),this._next||Ge===this||(Ge?Ge._next=this:Xe=this,Ge=this),this._call=t,this._time=e,fr()},stop:function(){this._call&&(this._call=null,this._time=1/0,fr())}};var lr=I("start","end","cancel","interrupt"),hr=[],dr=0,pr=1,vr=2,gr=3,yr=4,_r=5,br=6;function mr(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!==pr)return u();for(f in i)if((h=i[f]).name===e.name){if(h.state===gr)return sr(o);h.state===yr?(h.state=br,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[f]):+fdr)throw new Error("too late; already scheduled");return e}function wr(t,n){var e=Mr(t,n);if(e.state>gr)throw new Error("too late; already running");return e}function Mr(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Nr(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>vr&&e.state<_r,e.state=br,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 Ar(t,n,e){var r=t._id;return t.each(function(){var t=wr(this,r);(t.value||(t.value={}))[n]=e.apply(this,arguments)}),function(t){return Mr(t,r).value[n]}}function Tr(t,n){var e;return("number"==typeof n?de:n instanceof hn?ue:(e=hn(n))?(n=e,ue):ye)(t,n)}var Sr=Pt.prototype.constructor;function kr(t){return function(){this.style.removeProperty(t)}}var Er=0;function Cr(t,n,e,r){this._groups=t,this._parents=n,this._name=e,this._id=r}function Pr(t){return Pt().transition(t)}function zr(){return++Er}var Rr=Pt.prototype;function Dr(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}function qr(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}Cr.prototype=Pr.prototype={constructor:Cr,select:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=Q(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?xr:wr;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=$(t),r="transform"===e?Ee:Tr;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,Ar(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=$(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+="")?ke:Tr;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=ct(this,t),a=(this.style.removeProperty(t),ct(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,kr(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=ct(this,t),u=e(this),c=u+"";return null==u&&(this.style.removeProperty(t),c=u=ct(this,t)),a===c?null:a===r&&c===i?o:(i=c,o=n(r=a,u))}}(t,r,Ar(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var c=wr(this,t),f=c.on,s=null==c.value[a]?o||(o=kr(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=ct(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}}(Ar(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},remove:function(){return this.on("end.remove",(t=this._id,function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}));var t},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=Mr(this.node(),e).tween,o=0,a=i.length;o0&&(r=o-p),M<0?h=d-v:M>0&&(a=u-v),x=gi,L.attr("cursor",wi.selection),B());break;default:return}pi()},!0).on("keyup.brush",function(){switch(t.event.keyCode){case 16:P&&(y=_=P=!1,B());break;case 18:x===_i&&(w<0?s=l:w>0&&(r=o),M<0?h=d:M>0&&(a=u),x=yi,B());break;case 32:x===gi&&(t.event.altKey?(w&&(s=l-p*w,r=o+p*w),M&&(h=d-v*M,a=u+v*M),x=_i):(w<0?s=l:w>0&&(r=o),M<0?h=d:M>0&&(a=u),x=yi),L.attr("cursor",wi[m]),B());break;default:return}pi()},!0).on("mousemove.brush",O,!0).on("mouseup.brush",Y,!0);It(t.event.view)}di(),Nr(b),c.call(b),D.start()}function O(){var t=Ot(b);!P||y||_||(Math.abs(t[0]-R[0])>Math.abs(t[1]-R[1])?_=!0:y=!0),R=t,g=!0,pi(),B()}function B(){var t;switch(p=R[0]-z[0],v=R[1]-z[1],x){case gi:case vi:w&&(p=Math.max(S-r,Math.min(E-s,p)),o=r+p,l=s+p),M&&(v=Math.max(k-a,Math.min(C-h,v)),u=a+v,d=h+v);break;case yi:w<0?(p=Math.max(S-r,Math.min(E-r,p)),o=r+p,l=s):w>0&&(p=Math.max(S-s,Math.min(E-s,p)),o=r,l=s+p),M<0?(v=Math.max(k-a,Math.min(C-a,v)),u=a+v,d=h):M>0&&(v=Math.max(k-h,Math.min(C-h,v)),u=a,d=h+v);break;case _i:w&&(o=Math.max(S,Math.min(E,r-p*w)),l=Math.max(S,Math.min(E,s+p*w))),M&&(u=Math.max(k,Math.min(C,a-v*M)),d=Math.max(k,Math.min(C,h+v*M)))}l1e-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((Fi-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;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%Ii+Ii),l>ji?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>=Fi)+","+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 Qi(){}function Ji(t,n){var e=new Qi;if(t instanceof Qi)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(;++ir!=d>r&&e<(h-f)*(r-s)/(d-s)+f&&(i=-i)}return i}function lo(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 ho(){}var po=[[],[[[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 vo(){var t=1,n=1,e=M,r=u;function i(t){var n=e(t);if(Array.isArray(n))n=n.slice().sort(uo);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,po[f<<1].forEach(p);for(;++o=r,po[c|f<<1].forEach(p);po[f<<0].forEach(p);for(;++u=r,s=e[u*t]>=r,po[f<<1|s<<2].forEach(p);++o=r,l=s,s=e[u*t+o+1]>=r,po[c|f<<1|s<<2|l<<3].forEach(p);po[f|s<<3].forEach(p)}o=-1,s=e[u*t]>=r,po[s<<2].forEach(p);for(;++o=r,po[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]}}po[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];++n0?o.push([t]):u.push(t)}),u.forEach(function(t){for(var n,e=0,r=o.length;e0&&a0&&u0&&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)?co(ao.call(t)):co(t),i):e},i.smooth=function(t){return arguments.length?(r=t?u:ho,i):r===u},i}function go(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=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 yo(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=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 _o(t){return t[0]}function bo(t){return t[1]}function mo(){return 1}var xo={},wo={},Mo=34,No=10,Ao=13;function To(t){return new Function("d","return {"+t.map(function(t,n){return JSON.stringify(t)+": d["+n+"]"}).join(",")+"}")}function So(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 ko(t,n){var e=t+"",r=e.length;return r9999?"+"+ko(n,6):ko(n,4))+"-"+ko(t.getUTCMonth()+1,2)+"-"+ko(t.getUTCDate(),2)+(o?"T"+ko(e,2)+":"+ko(r,2)+":"+ko(i,2)+"."+ko(o,3)+"Z":i?"T"+ko(e,2)+":"+ko(r,2)+":"+ko(i,2)+"Z":r||e?"T"+ko(e,2)+":"+ko(r,2)+"Z":"")}function Co(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 wo;if(f)return f=!1,xo;var n,r,i=a;if(t.charCodeAt(i)===Mo){for(;a++=o?c=!0:(r=t.charCodeAt(a++))===No?f=!0:r===Ao&&(f=!0,t.charCodeAt(a)===No&&++a),t.slice(i+1,n-1).replace(/""/g,'"')}for(;a=(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 ia(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function oa(t){return t[0]}function aa(t){return t[1]}function ua(t,n,e){var r=new ca(null==n?oa:n,null==e?aa:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function ca(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 fa(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var sa=ua.prototype=ca.prototype;function la(t){return t.x+t.vx}function ha(t){return t.y+t.vy}function da(t){return t.index}function pa(t,n){var e=t.get(n);if(!e)throw new Error("missing: "+n);return e}function va(t){return t.x}function ga(t){return t.y}sa.copy=function(){var t,n,e=new ca(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=fa(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]=fa(n));return e},sa.add=function(t){var n=+this._x.call(null,t),e=+this._y.call(null,t);return ra(this.cover(n,e),n,e,t)},sa.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;es&&(s=r),il&&(l=i));if(c>s||f>l)return this;for(this.cover(c,f).cover(s,l),e=0;et||t>=i||r>n||n>=o;)switch(u=(nh||(o=c.y0)>d||(a=c.x1)=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=(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)},sa.removeAll=function(t){for(var n=0,e=t.length;n1?r[0]+r.slice(2):r,+t.slice(e+1)]}function ma(t){return(t=ba(Math.abs(t)))?t[1]:NaN}var xa,wa=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Ma(t){return new Na(t)}function Na(t){if(!(n=wa.exec(t)))throw new Error("invalid format: "+t);var n;this.fill=n[1]||" ",this.align=n[2]||">",this.sign=n[3]||"-",this.symbol=n[4]||"",this.zero=!!n[5],this.width=n[6]&&+n[6],this.comma=!!n[7],this.precision=n[8]&&+n[8].slice(1),this.trim=!!n[9],this.type=n[10]||""}function Aa(t,n){var e=ba(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")}Ma.prototype=Na.prototype,Na.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Ta={"%":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 Aa(100*t,n)},r:Aa,s:function(t,n){var e=ba(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(xa=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")+ba(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 Sa(t){return t}var ka,Ea=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Ca(t){var n,e,r=t.grouping&&t.thousands?(n=t.grouping,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)}):Sa,i=t.currency,o=t.decimal,a=t.numerals?function(t){return function(n){return n.replace(/[0-9]/g,function(n){return t[+n]})}}(t.numerals):Sa,u=t.percent||"%";function c(t){var n=(t=Ma(t)).fill,e=t.align,c=t.sign,f=t.symbol,s=t.zero,l=t.width,h=t.comma,d=t.precision,p=t.trim,v=t.type;"n"===v?(h=!0,v="g"):Ta[v]||(null==d&&(d=12),p=!0,v="g"),(s||"0"===n&&"="===e)&&(s=!0,n="0",e="=");var g="$"===f?i[0]:"#"===f&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",y="$"===f?i[1]:/[%p]/.test(v)?u:"",_=Ta[v],b=/[defgprs%]/.test(v);function m(t){var i,u,f,m=g,x=y;if("c"===v)x=_(t)+x,t="";else{var w=(t=+t)<0;if(t=_(Math.abs(t),d),p&&(t=function(t){t:for(var n,e=t.length,r=1,i=-1;r0){if(!+t[r])break t;i=0}}return i>0?t.slice(0,i)+t.slice(n+1):t}(t)),w&&0==+t&&(w=!1),m=(w?"("===c?c:"-":"-"===c||"("===c?"":c)+m,x=("s"===v?Ea[8+xa/3]:"")+x+(w&&"("===c?")":""),b)for(i=-1,u=t.length;++i(f=t.charCodeAt(i))||f>57){x=(46===f?o+t.slice(i+1):t.slice(i))+x,t=t.slice(0,i);break}}h&&!s&&(t=r(t,1/0));var M=m.length+t.length+x.length,N=M>1)+m+t+x+N.slice(M);break;default:t=N+m+t+x}return a(t)}return d=null==d?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,d)):Math.max(0,Math.min(20,d)),m.toString=function(){return t+""},m}return{format:c,formatPrefix:function(t,n){var e=c(((t=Ma(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(ma(n)/3))),i=Math.pow(10,-r),o=Ea[8+r/3];return function(t){return e(i*t)+o}}}}function Pa(n){return ka=Ca(n),t.format=ka.format,t.formatPrefix=ka.formatPrefix,ka}function za(t){return Math.max(0,-ma(Math.abs(t)))}function Ra(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(ma(n)/3)))-ma(Math.abs(t)))}function Da(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,ma(n)-ma(t))+1}function qa(){return new La}function La(){this.reset()}Pa({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),La.prototype={constructor:La,reset:function(){this.s=this.t=0},add:function(t){Oa(Ua,t,this.t),Oa(this,Ua.s,this.s),this.s?this.t+=Ua.t:this.s=Ua.t},valueOf:function(){return this.s}};var Ua=new La;function Oa(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var Ba=1e-6,Ya=1e-12,Fa=Math.PI,Ia=Fa/2,ja=Fa/4,Ha=2*Fa,Xa=180/Fa,Ga=Fa/180,Va=Math.abs,$a=Math.atan,Wa=Math.atan2,Za=Math.cos,Qa=Math.ceil,Ja=Math.exp,Ka=Math.log,tu=Math.pow,nu=Math.sin,eu=Math.sign||function(t){return t>0?1:t<0?-1:0},ru=Math.sqrt,iu=Math.tan;function ou(t){return t>1?0:t<-1?Fa:Math.acos(t)}function au(t){return t>1?Ia:t<-1?-Ia:Math.asin(t)}function uu(t){return(t=nu(t/2))*t}function cu(){}function fu(t,n){t&&lu.hasOwnProperty(t.type)&&lu[t.type](t,n)}var su={Feature:function(t,n){fu(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r=0?1:-1,i=r*e,o=Za(n=(n*=Ga)/2+ja),a=nu(n),u=bu*a,c=_u*o+u*Za(i),f=u*r*nu(i);mu.add(Wa(f,c)),yu=t,_u=o,bu=a}function Su(t){return[Wa(t[1],t[0]),au(t[2])]}function ku(t){var n=t[0],e=t[1],r=Za(e);return[r*Za(n),r*nu(n),nu(e)]}function Eu(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Cu(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 Pu(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function zu(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Ru(t){var n=ru(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var Du,qu,Lu,Uu,Ou,Bu,Yu,Fu,Iu,ju,Hu,Xu,Gu,Vu,$u,Wu,Zu,Qu,Ju,Ku,tc,nc,ec,rc,ic,oc,ac=qa(),uc={point:cc,lineStart:sc,lineEnd:lc,polygonStart:function(){uc.point=hc,uc.lineStart=dc,uc.lineEnd=pc,ac.reset(),wu.polygonStart()},polygonEnd:function(){wu.polygonEnd(),uc.point=cc,uc.lineStart=sc,uc.lineEnd=lc,mu<0?(Du=-(Lu=180),qu=-(Uu=90)):ac>Ba?Uu=90:ac<-Ba&&(qu=-90),ju[0]=Du,ju[1]=Lu},sphere:function(){Du=-(Lu=180),qu=-(Uu=90)}};function cc(t,n){Iu.push(ju=[Du=t,Lu=t]),nUu&&(Uu=n)}function fc(t,n){var e=ku([t*Ga,n*Ga]);if(Fu){var r=Cu(Fu,e),i=Cu([r[1],-r[0],0],r);Ru(i),i=Su(i);var o,a=t-Ou,u=a>0?1:-1,c=i[0]*Xa*u,f=Va(a)>180;f^(u*OuUu&&(Uu=o):f^(u*Ou<(c=(c+360)%360-180)&&cUu&&(Uu=n)),f?tvc(Du,Lu)&&(Lu=t):vc(t,Lu)>vc(Du,Lu)&&(Du=t):Lu>=Du?(tLu&&(Lu=t)):t>Ou?vc(Du,t)>vc(Du,Lu)&&(Lu=t):vc(t,Lu)>vc(Du,Lu)&&(Du=t)}else Iu.push(ju=[Du=t,Lu=t]);nUu&&(Uu=n),Fu=e,Ou=t}function sc(){uc.point=fc}function lc(){ju[0]=Du,ju[1]=Lu,uc.point=cc,Fu=null}function hc(t,n){if(Fu){var e=t-Ou;ac.add(Va(e)>180?e+(e>0?360:-360):e)}else Bu=t,Yu=n;wu.point(t,n),fc(t,n)}function dc(){wu.lineStart()}function pc(){hc(Bu,Yu),wu.lineEnd(),Va(ac)>Ba&&(Du=-(Lu=180)),ju[0]=Du,ju[1]=Lu,Fu=null}function vc(t,n){return(n-=t)<0?n+360:n}function gc(t,n){return t[0]-n[0]}function yc(t,n){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nFa?t+Math.round(-t/Ha)*Ha:t,n]}function zc(t,n,e){return(t%=Ha)?n||e?Cc(Dc(t),qc(n,e)):Dc(t):n||e?qc(n,e):Pc}function Rc(t){return function(n,e){return[(n+=t)>Fa?n-Ha:n<-Fa?n+Ha:n,e]}}function Dc(t){var n=Rc(t);return n.invert=Rc(-t),n}function qc(t,n){var e=Za(t),r=nu(t),i=Za(n),o=nu(n);function a(t,n){var a=Za(n),u=Za(t)*a,c=nu(t)*a,f=nu(n),s=f*e+u*r;return[Wa(c*i-s*o,u*e-f*r),au(s*i+c*o)]}return a.invert=function(t,n){var a=Za(n),u=Za(t)*a,c=nu(t)*a,f=nu(n),s=f*i-c*o;return[Wa(c*i+f*o,u*e+s*r),au(s*e-u*r)]},a}function Lc(t){function n(n){return(n=t(n[0]*Ga,n[1]*Ga))[0]*=Xa,n[1]*=Xa,n}return t=zc(t[0]*Ga,t[1]*Ga,t.length>2?t[2]*Ga:0),n.invert=function(n){return(n=t.invert(n[0]*Ga,n[1]*Ga))[0]*=Xa,n[1]*=Xa,n},n}function Uc(t,n,e,r,i,o){if(e){var a=Za(n),u=nu(n),c=r*e;null==i?(i=n+r*Ha,o=n-c/2):(i=Oc(a,i),o=Oc(a,o),(r>0?io)&&(i+=r*Ha));for(var f,s=i;r>0?s>o:s1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function Yc(t,n){return Va(t[0]-n[0])=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=0?1:-1,A=N*M,T=A>Fa,S=v*x;if(Hc.add(Wa(S*N*nu(A),g*w+S*Za(A))),a+=T?M+N*Ha:M,T^d>=e^b>=e){var k=Cu(ku(h),ku(_));Ru(k);var E=Cu(o,k);Ru(E);var C=(T^M>=0?-1:1)*au(E[2]);(r>C||r===C&&(k[0]||k[1]))&&(u+=T^M>=0?1:-1)}}return(a<-Ba||a0){for(l||(i.polygonStart(),l=!0),i.lineStart(),t=0;t1&&2&c&&h.push(h.pop().concat(h.shift())),a.push(h.filter($c))}return h}}function $c(t){return t.length>1}function Wc(t,n){return((t=t.x)[0]<0?t[1]-Ia-Ba:Ia-t[1])-((n=n.x)[0]<0?n[1]-Ia-Ba:Ia-n[1])}var Zc=Vc(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?Fa:-Fa,c=Va(o-e);Va(c-Fa)0?Ia:-Ia),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&c>=Fa&&(Va(e-i)Ba?$a((nu(n)*(o=Za(r))*nu(e)-nu(r)*(i=Za(n))*nu(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*Ia,r.point(-Fa,i),r.point(0,i),r.point(Fa,i),r.point(Fa,0),r.point(Fa,-i),r.point(0,-i),r.point(-Fa,-i),r.point(-Fa,0),r.point(-Fa,i);else if(Va(t[0]-n[0])>Ba){var o=t[0]0,i=Va(n)>Ba;function o(t,e){return Za(t)*Za(e)>n}function a(t,e,r){var i=[1,0,0],o=Cu(ku(t),ku(e)),a=Eu(o,o),u=o[0],c=a-u*u;if(!c)return!r&&t;var f=n*a/c,s=-n*u/c,l=Cu(i,o),h=zu(i,f);Pu(h,zu(o,s));var d=l,p=Eu(h,d),v=Eu(d,d),g=p*p-v*(Eu(h,h)-1);if(!(g<0)){var y=ru(g),_=zu(d,(-p-y)/v);if(Pu(_,h),_=Su(_),!r)return _;var b,m=t[0],x=e[0],w=t[1],M=e[1];x0^_[1]<(Va(_[0]-m)Fa^(m<=_[0]&&_[0]<=x)){var T=zu(d,(-p+y)/v);return Pu(T,h),[_,Su(T)]}}}function u(n,e){var i=r?t:Fa-t,o=0;return n<-i?o|=1:n>i&&(o|=2),e<-i?o|=4:e>i&&(o|=8),o}return Vc(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?Fa:-Fa),h):0;if(!n&&(f=c=v)&&t.lineStart(),v!==c&&(!(d=a(n,p))||Yc(n,d)||Yc(p,d))&&(p[0]+=Ba,p[1]+=Ba,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&&Yc(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){Uc(o,t,e,i,n,r)},r?[0,-t]:[-Fa,t-Fa])}var Jc=1e9,Kc=-Jc;function tf(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 Va(r[0]-t)0?0:3:Va(r[0]-e)0?2:1:Va(r[1]-n)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=Bc(),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;er&&(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&&Ic(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(Kc,Math.min(Jc,p)),v=Math.max(Kc,Math.min(Jc,v))],m=[o=Math.max(Kc,Math.min(Jc,o)),a=Math.max(Kc,Math.min(Jc,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(a0){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(a0)){if(a/=h,h<0){if(a0){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(a0&&(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 nf,ef,rf,of=qa(),af={sphere:cu,point:cu,lineStart:function(){af.point=cf,af.lineEnd=uf},lineEnd:cu,polygonStart:cu,polygonEnd:cu};function uf(){af.point=af.lineEnd=cu}function cf(t,n){nf=t*=Ga,ef=nu(n*=Ga),rf=Za(n),af.point=ff}function ff(t,n){t*=Ga;var e=nu(n*=Ga),r=Za(n),i=Va(t-nf),o=Za(i),a=r*nu(i),u=rf*e-ef*r*o,c=ef*e+rf*r*o;of.add(Wa(ru(a*a+u*u),c)),nf=t,ef=e,rf=r}function sf(t){return of.reset(),pu(t,af),+of}var lf=[null,null],hf={type:"LineString",coordinates:lf};function df(t,n){return lf[0]=t,lf[1]=n,sf(hf)}var pf={Feature:function(t,n){return gf(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r0&&(i=df(t[o],t[o-1]))>0&&e<=i&&r<=i&&(e+r-i)*(1-Math.pow((e-r)/i,2))Ba}).map(c)).concat(g(Qa(o/d)*d,i,d).filter(function(t){return Va(t%v)>Ba}).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=wf(o,i,90),f=Mf(n,t,y),s=wf(u,a,90),l=Mf(r,e,y),_):y},_.extentMajor([[-180,-90+Ba],[180,90-Ba]]).extentMinor([[-180,-80-Ba],[180,80+Ba]])}function Af(t){return t}var Tf,Sf,kf,Ef,Cf=qa(),Pf=qa(),zf={point:cu,lineStart:cu,lineEnd:cu,polygonStart:function(){zf.lineStart=Rf,zf.lineEnd=Lf},polygonEnd:function(){zf.lineStart=zf.lineEnd=zf.point=cu,Cf.add(Va(Pf)),Pf.reset()},result:function(){var t=Cf/2;return Cf.reset(),t}};function Rf(){zf.point=Df}function Df(t,n){zf.point=qf,Tf=kf=t,Sf=Ef=n}function qf(t,n){Pf.add(Ef*t-kf*n),kf=t,Ef=n}function Lf(){qf(Tf,Sf)}var Uf=1/0,Of=Uf,Bf=-Uf,Yf=Bf,Ff={point:function(t,n){tBf&&(Bf=t);nYf&&(Yf=n)},lineStart:cu,lineEnd:cu,polygonStart:cu,polygonEnd:cu,result:function(){var t=[[Uf,Of],[Bf,Yf]];return Bf=Yf=-(Of=Uf=1/0),t}};var If,jf,Hf,Xf,Gf=0,Vf=0,$f=0,Wf=0,Zf=0,Qf=0,Jf=0,Kf=0,ts=0,ns={point:es,lineStart:rs,lineEnd:as,polygonStart:function(){ns.lineStart=us,ns.lineEnd=cs},polygonEnd:function(){ns.point=es,ns.lineStart=rs,ns.lineEnd=as},result:function(){var t=ts?[Jf/ts,Kf/ts]:Qf?[Wf/Qf,Zf/Qf]:$f?[Gf/$f,Vf/$f]:[NaN,NaN];return Gf=Vf=$f=Wf=Zf=Qf=Jf=Kf=ts=0,t}};function es(t,n){Gf+=t,Vf+=n,++$f}function rs(){ns.point=is}function is(t,n){ns.point=os,es(Hf=t,Xf=n)}function os(t,n){var e=t-Hf,r=n-Xf,i=ru(e*e+r*r);Wf+=i*(Hf+t)/2,Zf+=i*(Xf+n)/2,Qf+=i,es(Hf=t,Xf=n)}function as(){ns.point=es}function us(){ns.point=fs}function cs(){ss(If,jf)}function fs(t,n){ns.point=ss,es(If=Hf=t,jf=Xf=n)}function ss(t,n){var e=t-Hf,r=n-Xf,i=ru(e*e+r*r);Wf+=i*(Hf+t)/2,Zf+=i*(Xf+n)/2,Qf+=i,Jf+=(i=Xf*t-Hf*n)*(Hf+t),Kf+=i*(Xf+n),ts+=3*i,es(Hf=t,Xf=n)}function ls(t){this._context=t}ls.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,Ha)}},result:cu};var hs,ds,ps,vs,gs,ys=qa(),_s={point:cu,lineStart:function(){_s.point=bs},lineEnd:function(){hs&&ms(ds,ps),_s.point=cu},polygonStart:function(){hs=!0},polygonEnd:function(){hs=null},result:function(){var t=+ys;return ys.reset(),t}};function bs(t,n){_s.point=ms,ds=vs=t,ps=gs=n}function ms(t,n){vs-=t,gs-=n,ys.add(ru(vs*vs+gs*gs)),vs=t,gs=n}function xs(){this._string=[]}function ws(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Ms(t){return function(n){var e=new Ns;for(var r in t)e[r]=t[r];return e.stream=n,e}}function Ns(){}function As(t,n,e){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),pu(e,t.stream(Ff)),n(Ff.result()),null!=r&&t.clipExtent(r),t}function Ts(t,n,e){return As(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 Ss(t,n,e){return Ts(t,[[0,0],n],e)}function ks(t,n,e){return As(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 Es(t,n,e){return As(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)}xs.prototype={_radius:4.5,_circle:ws(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=ws(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}},Ns.prototype={constructor:Ns,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 Cs=16,Ps=Za(30*Ga);function zs(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=ru(m*m+x*x+w*w),N=au(w/=M),A=Va(Va(w)-1)n||Va((y*E+_*C)/b-.5)>.3||a*h+u*d+c*p2?t[2]%360*Ga:0,S()):[g*Xa,y*Xa,_*Xa]},A.angle=function(t){return arguments.length?(b=t%360*Ga,S()):b*Xa},A.precision=function(t){return arguments.length?(a=zs(u,N=t*t),k()):ru(N)},A.fitExtent=function(t,n){return Ts(A,t,n)},A.fitSize=function(t,n){return Ss(A,t,n)},A.fitWidth=function(t,n){return ks(A,t,n)},A.fitHeight=function(t,n){return Es(A,t,n)},function(){return n=t.apply(this,arguments),A.invert=n.invert&&T,S()}}function Us(t){var n=0,e=Fa/3,r=Ls(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*Ga,e=t[1]*Ga):[n*Xa,e*Xa]},i}function Os(t,n){var e=nu(t),r=(e+nu(n))/2;if(Va(r)0?n<-Ia+Ba&&(n=-Ia+Ba):n>Ia-Ba&&(n=Ia-Ba);var e=i/tu(Vs(n),r);return[e*nu(r*t),i-e*Za(r*t)]}return o.invert=function(t,n){var e=i-n,o=eu(r)*ru(t*t+e*e);return[Wa(t,Va(e))/r*eu(e),2*$a(tu(i/o,1/r))-Ia]},o}function Ws(t,n){return[t,n]}function Zs(t,n){var e=Za(t),r=t===n?nu(t):(e-Za(n))/(n-t),i=e/r+t;if(Va(r)=0;)n+=e[r].value;else n=1;t.value=n}function dl(t,n){var e,r,i,o,a,u=new yl(t),c=+t.value&&(u.value=t.value),f=[u];for(null==n&&(n=pl);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 yl(i[o])),r.parent=e,r.depth=e.depth+1;return u.eachBefore(gl)}function pl(t){return t.children}function vl(t){t.data=t.data.data}function gl(t){var n=0;do{t.height=n}while((t=t.parent)&&t.height<++n)}function yl(t){this.data=t,this.depth=this.height=0,this.parent=null}el.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*(Qs+Js*i+o*(Ks+tl*i))-n)/(Qs+3*Js*i+o*(7*Ks+9*tl*i)))*r)*i*i,!(Va(e)Ba&&--i>0);return[t/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r]},al.invert=Is(au),ul.invert=Is(function(t){return 2*$a(t)}),cl.invert=function(t,n){return[-n,2*$a(Ja(t))-Ia]},yl.prototype=dl.prototype={constructor:yl,count:function(){return this.eachAfter(hl)},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=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 dl(this).eachBefore(vl)}};var _l=Array.prototype.slice;function bl(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}(_l.call(t))).length,o=[];r0&&e*e>r*r+i*i}function Ml(t,n){for(var e=0;e(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 kl(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 El(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 Cl(t){this._=t,this.next=null,this.previous=null}function Pl(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;Sl(e,n,r=t[2]),n=new Cl(n),e=new Cl(e),r=new Cl(r),n.next=r.previous=e,e.next=n.previous=r,r.next=e.previous=n;t:for(u=3;uh&&(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:c1?n:1)},e}(Kl);var eh=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;++l1?n:1)},e}(Kl);function rh(t,n){return t[0]-n[0]||t[1]-n[1]}function ih(t){for(var n,e,r,i=t.length,o=[0,1],a=2,u=2;u1&&(n=t[o[a-2]],e=t[o[a-1]],r=t[u],(e[0]-n[0])*(r[1]-n[1])-(e[1]-n[1])*(r[0]-n[0])<=0);)--a;o[a++]=u}return o.slice(0,a)}function oh(){return Math.random()}var ah=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}(oh),uh=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}(oh),ch=function t(n){function e(){var t=uh.source(n).apply(this,arguments);return function(){return Math.exp(t())}}return e.source=t,e}(oh),fh=function t(n){function e(t){return function(){for(var e=0,r=0;rr&&(n=e,e=r,r=n),function(t){return Math.max(e,Math.min(r,t))}}function Ah(t,n,e){var r=t[0],i=t[1],o=n[0],a=n[1];return i2?Th:Ah,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),de)))(e)))},l.domain=function(t){return arguments.length?(a=vh.call(t,mh),f===wh||(f=Nh(a)),s()):a.slice()},l.range=function(t){return arguments.length?(u=gh.call(t),s()):u.slice()},l.rangeRound=function(t){return u=gh.call(t),c=be,s()},l.clamp=function(t){return arguments.length?(f=t?Nh(a):wh,l):f!==wh},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 Eh(t,n){return kh()(t,n)}function Ch(n,e,r,i){var o,a=w(n,e,r);switch((i=Ma(null==i?",f":i)).type){case"s":var u=Math.max(Math.abs(n),Math.abs(e));return null!=i.precision||isNaN(o=Ra(a,u))||(i.precision=o),t.formatPrefix(i,u);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=Da(a,Math.max(Math.abs(n),Math.abs(e))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=za(a))||(i.precision=o-2*("%"===i.type))}return t.format(i)}function Ph(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 Ch(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 c0?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 zh(t,n){var e,r=0,i=(t=t.slice()).length-1,o=t[r],a=t[i];return a0){for(;hc)break;v.push(l)}}else for(;h=1;--s)if(!((l=f*s)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*a0))return u;do{u.push(a=new Date(+e)),n(e,o),t(e)}while(a=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 $h.setTime(+n),Wh.setTime(+r),t($h),t(Wh),Math.floor(e($h,Wh))},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 Qh=Zh(function(){},function(t,n){t.setTime(+t+n)},function(t,n){return n-t});Qh.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?Zh(function(n){n.setTime(Math.floor(n/t)*t)},function(n,e){n.setTime(+n+e*t)},function(n,e){return(e-n)/t}):Qh:null};var Jh=Qh.range,Kh=6e4,td=6048e5,nd=Zh(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()}),ed=nd.range,rd=Zh(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds())},function(t,n){t.setTime(+t+n*Kh)},function(t,n){return(n-t)/Kh},function(t){return t.getMinutes()}),id=rd.range,od=Zh(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()-t.getMinutes()*Kh)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getHours()}),ad=od.range,ud=Zh(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())*Kh)/864e5},function(t){return t.getDate()-1}),cd=ud.range;function fd(t){return Zh(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())*Kh)/td})}var sd=fd(0),ld=fd(1),hd=fd(2),dd=fd(3),pd=fd(4),vd=fd(5),gd=fd(6),yd=sd.range,_d=ld.range,bd=hd.range,md=dd.range,xd=pd.range,wd=vd.range,Md=gd.range,Nd=Zh(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()}),Ad=Nd.range,Td=Zh(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()});Td.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Zh(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 Sd=Td.range,kd=Zh(function(t){t.setUTCSeconds(0,0)},function(t,n){t.setTime(+t+n*Kh)},function(t,n){return(n-t)/Kh},function(t){return t.getUTCMinutes()}),Ed=kd.range,Cd=Zh(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()}),Pd=Cd.range,zd=Zh(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}),Rd=zd.range;function Dd(t){return Zh(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)/td})}var qd=Dd(0),Ld=Dd(1),Ud=Dd(2),Od=Dd(3),Bd=Dd(4),Yd=Dd(5),Fd=Dd(6),Id=qd.range,jd=Ld.range,Hd=Ud.range,Xd=Od.range,Gd=Bd.range,Vd=Yd.range,$d=Fd.range,Wd=Zh(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()}),Zd=Wd.range,Qd=Zh(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()});Qd.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Zh(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 Jd=Qd.range;function Kd(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 tp(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 np(t){return{y:t,m:0,d:1,H:0,M:0,S:0,L:0}}function ep(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=sp(i),s=lp(i),l=sp(o),h=lp(o),d=sp(a),p=lp(a),v=sp(u),g=lp(u),y=sp(c),_=lp(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:Pp,e:Pp,f:Lp,H:zp,I:Rp,j:Dp,L:qp,m:Up,M:Op,p:function(t){return i[+(t.getHours()>=12)]},Q:hv,s:dv,S:Bp,u:Yp,U:Fp,V:Ip,w:jp,W:Hp,x:null,X:null,y:Xp,Y:Gp,Z:Vp,"%":lv},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:$p,e:$p,f:Kp,H:Wp,I:Zp,j:Qp,L:Jp,m:tv,M:nv,p:function(t){return i[+(t.getUTCHours()>=12)]},Q:hv,s:dv,S:ev,u:rv,U:iv,V:ov,w:av,W:uv,x:null,X:null,y:cv,Y:fv,Z:sv,"%":lv},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:xp,e:xp,f:Sp,H:Mp,I:Mp,j:wp,L:Tp,m:mp,M:Np,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:Ep,s:Cp,S:Ap,u:dp,U:pp,V:vp,w:hp,W:gp,x:function(t,n,r){return N(t,e,n,r)},X:function(t,n,e){return N(t,r,n,e)},y:_p,Y:yp,Z:bp,"%":kp};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));++u53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=tp(np(o.y))).getUTCDay(),r=i>4||0===i?Ld.ceil(r):Ld(r),r=zd.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(np(o.y))).getDay(),r=i>4||0===i?ld.ceil(r):ld(r),r=ud.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?tp(np(o.y)).getUTCDay():n(np(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,tp(o)):n(o)}}function N(t,n,e,r){for(var i,o,a=0,u=n.length,c=e.length;a=c)return-1;if(37===(i=n.charCodeAt(a++))){if(i=n.charAt(a++),!(o=x[i in ip?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+="",Kd);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,tp);return n.toString=function(){return t},n}}}var rp,ip={"-":"",_:" ",0:"0"},op=/^\s*\d+/,ap=/^%/,up=/[\\^$*+?|[\]().{}]/g;function cp(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o68?1900:2e3),e+r[0].length):-1}function bp(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 mp(t,n,e){var r=op.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function xp(t,n,e){var r=op.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function wp(t,n,e){var r=op.exec(n.slice(e,e+3));return r?(t.m=0,t.d=+r[0],e+r[0].length):-1}function Mp(t,n,e){var r=op.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function Np(t,n,e){var r=op.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function Ap(t,n,e){var r=op.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function Tp(t,n,e){var r=op.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function Sp(t,n,e){var r=op.exec(n.slice(e,e+6));return r?(t.L=Math.floor(r[0]/1e3),e+r[0].length):-1}function kp(t,n,e){var r=ap.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function Ep(t,n,e){var r=op.exec(n.slice(e));return r?(t.Q=+r[0],e+r[0].length):-1}function Cp(t,n,e){var r=op.exec(n.slice(e));return r?(t.Q=1e3*+r[0],e+r[0].length):-1}function Pp(t,n){return cp(t.getDate(),n,2)}function zp(t,n){return cp(t.getHours(),n,2)}function Rp(t,n){return cp(t.getHours()%12||12,n,2)}function Dp(t,n){return cp(1+ud.count(Td(t),t),n,3)}function qp(t,n){return cp(t.getMilliseconds(),n,3)}function Lp(t,n){return qp(t,n)+"000"}function Up(t,n){return cp(t.getMonth()+1,n,2)}function Op(t,n){return cp(t.getMinutes(),n,2)}function Bp(t,n){return cp(t.getSeconds(),n,2)}function Yp(t){var n=t.getDay();return 0===n?7:n}function Fp(t,n){return cp(sd.count(Td(t),t),n,2)}function Ip(t,n){var e=t.getDay();return t=e>=4||0===e?pd(t):pd.ceil(t),cp(pd.count(Td(t),t)+(4===Td(t).getDay()),n,2)}function jp(t){return t.getDay()}function Hp(t,n){return cp(ld.count(Td(t),t),n,2)}function Xp(t,n){return cp(t.getFullYear()%100,n,2)}function Gp(t,n){return cp(t.getFullYear()%1e4,n,4)}function Vp(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+cp(n/60|0,"0",2)+cp(n%60,"0",2)}function $p(t,n){return cp(t.getUTCDate(),n,2)}function Wp(t,n){return cp(t.getUTCHours(),n,2)}function Zp(t,n){return cp(t.getUTCHours()%12||12,n,2)}function Qp(t,n){return cp(1+zd.count(Qd(t),t),n,3)}function Jp(t,n){return cp(t.getUTCMilliseconds(),n,3)}function Kp(t,n){return Jp(t,n)+"000"}function tv(t,n){return cp(t.getUTCMonth()+1,n,2)}function nv(t,n){return cp(t.getUTCMinutes(),n,2)}function ev(t,n){return cp(t.getUTCSeconds(),n,2)}function rv(t){var n=t.getUTCDay();return 0===n?7:n}function iv(t,n){return cp(qd.count(Qd(t),t),n,2)}function ov(t,n){var e=t.getUTCDay();return t=e>=4||0===e?Bd(t):Bd.ceil(t),cp(Bd.count(Qd(t),t)+(4===Qd(t).getUTCDay()),n,2)}function av(t){return t.getUTCDay()}function uv(t,n){return cp(Ld.count(Qd(t),t),n,2)}function cv(t,n){return cp(t.getUTCFullYear()%100,n,2)}function fv(t,n){return cp(t.getUTCFullYear()%1e4,n,4)}function sv(){return"+0000"}function lv(){return"%"}function hv(t){return+t}function dv(t){return Math.floor(+t/1e3)}function pv(n){return rp=ep(n),t.timeFormat=rp.format,t.timeParse=rp.parse,t.utcFormat=rp.utcFormat,t.utcParse=rp.utcParse,rp}pv({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 vv=Date.prototype.toISOString?function(t){return t.toISOString()}:t.utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");var gv=+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"),yv=1e3,_v=60*yv,bv=60*_v,mv=24*bv,xv=7*mv,wv=30*mv,Mv=365*mv;function Nv(t){return new Date(t)}function Av(t){return t instanceof Date?+t:+new Date(+t)}function Tv(t,n,r,i,o,a,u,c,f){var s=Eh(wh,wh),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,yv],[u,5,5*yv],[u,15,15*yv],[u,30,30*yv],[a,1,_v],[a,5,5*_v],[a,15,15*_v],[a,30,30*_v],[o,1,bv],[o,3,3*bv],[o,6,6*bv],[o,12,12*bv],[i,1,mv],[i,2,2*mv],[r,1,xv],[n,1,wv],[n,3,3*wv],[t,1,Mv]];function M(e){return(u(e)=1?ly:t<=-1?-ly:Math.asin(t)}function py(t){return t.innerRadius}function vy(t){return t.outerRadius}function gy(t){return t.startAngle}function yy(t){return t.endAngle}function _y(t){return t&&t.padAngle}function by(t,n,e,r,i,o,a){var u=t-e,c=n-r,f=(a?o:-o)/cy(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)*cy(oy(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 my(t){this._context=t}function xy(t){return new my(t)}function wy(t){return t[0]}function My(t){return t[1]}function Ny(){var t=wy,n=My,e=ny(!0),r=null,i=xy,o=null;function a(a){var u,c,f,s=a.length,l=!1;for(null==r&&(o=i(f=Xi())),u=0;u<=s;++u)!(u=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 Ny().defined(i).curve(a).context(o)}return c.x=function(e){return arguments.length?(t="function"==typeof e?e:ny(+e),n=null,c):t},c.x0=function(n){return arguments.length?(t="function"==typeof n?n:ny(+n),c):t},c.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:ny(+t),c):n},c.y=function(t){return arguments.length?(e="function"==typeof t?t:ny(+t),r=null,c):e},c.y0=function(t){return arguments.length?(e="function"==typeof t?t:ny(+t),c):e},c.y1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:ny(+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:ny(!!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 Ty(t,n){return nt?1:n>=t?0:NaN}function Sy(t){return t}my.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 ky=Cy(xy);function Ey(t){this._curve=t}function Cy(t){function n(n){return new Ey(t(n))}return n._curve=t,n}function Py(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(Cy(t)):n()._curve},t}function zy(){return Py(Ny().curve(ky))}function Ry(){var t=Ay().curve(ky),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 Py(e())},delete t.lineX0,t.lineEndAngle=function(){return Py(r())},delete t.lineX1,t.lineInnerRadius=function(){return Py(i())},delete t.lineY0,t.lineOuterRadius=function(){return Py(o())},delete t.lineY1,t.curve=function(t){return arguments.length?n(Cy(t)):n()._curve},t}function Dy(t,n){return[(n=+n)*Math.cos(t-=Math.PI/2),n*Math.sin(t)]}Ey.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 qy=Array.prototype.slice;function Ly(t){return t.source}function Uy(t){return t.target}function Oy(t){var n=Ly,e=Uy,r=wy,i=My,o=null;function a(){var a,u=qy.call(arguments),c=n.apply(this,u),f=e.apply(this,u);if(o||(o=a=Xi()),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:ny(+t),a):r},a.y=function(t){return arguments.length?(i="function"==typeof t?t:ny(+t),a):i},a.context=function(t){return arguments.length?(o=null==t?null:t,a):o},a}function By(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n=(n+r)/2,e,n,i,r,i)}function Yy(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n,e=(e+i)/2,r,e,r,i)}function Fy(t,n,e,r,i){var o=Dy(n,e),a=Dy(n,e=(e+i)/2),u=Dy(r,e),c=Dy(r,i);t.moveTo(o[0],o[1]),t.bezierCurveTo(a[0],a[1],u[0],u[1],c[0],c[1])}var Iy={draw:function(t,n){var e=Math.sqrt(n/sy);t.moveTo(e,0),t.arc(0,0,e,0,hy)}},jy={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()}},Hy=Math.sqrt(1/3),Xy=2*Hy,Gy={draw:function(t,n){var e=Math.sqrt(n/Xy),r=e*Hy;t.moveTo(0,-e),t.lineTo(r,0),t.lineTo(0,e),t.lineTo(-r,0),t.closePath()}},Vy=Math.sin(sy/10)/Math.sin(7*sy/10),$y=Math.sin(hy/10)*Vy,Wy=-Math.cos(hy/10)*Vy,Zy={draw:function(t,n){var e=Math.sqrt(.8908130915292852*n),r=$y*e,i=Wy*e;t.moveTo(0,-e),t.lineTo(r,i);for(var o=1;o<5;++o){var a=hy*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()}},Qy={draw:function(t,n){var e=Math.sqrt(n),r=-e/2;t.rect(r,r,e,e)}},Jy=Math.sqrt(3),Ky={draw:function(t,n){var e=-Math.sqrt(n/(3*Jy));t.moveTo(0,2*e),t.lineTo(-Jy*e,-e),t.lineTo(Jy*e,-e),t.closePath()}},t_=Math.sqrt(3)/2,n_=1/Math.sqrt(12),e_=3*(n_/2+1),r_={draw:function(t,n){var e=Math.sqrt(n/e_),r=e/2,i=e*n_,o=r,a=e*n_+e,u=-o,c=a;t.moveTo(r,i),t.lineTo(o,a),t.lineTo(u,c),t.lineTo(-.5*r-t_*i,t_*r+-.5*i),t.lineTo(-.5*o-t_*a,t_*o+-.5*a),t.lineTo(-.5*u-t_*c,t_*u+-.5*c),t.lineTo(-.5*r+t_*i,-.5*i-t_*r),t.lineTo(-.5*o+t_*a,-.5*a-t_*o),t.lineTo(-.5*u+t_*c,-.5*c-t_*u),t.closePath()}},i_=[Iy,jy,Gy,Qy,Zy,Ky,r_];function o_(){}function a_(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 u_(t){this._context=t}function c_(t){this._context=t}function f_(t){this._context=t}function s_(t,n){this._basis=new u_(t),this._beta=n}u_.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:a_(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:a_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},c_.prototype={areaStart:o_,areaEnd:o_,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:a_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},f_.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:a_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},s_.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 l_=function t(n){function e(t){return 1===n?new u_(t):new s_(t,n)}return e.beta=function(n){return t(+n)},e}(.85);function h_(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 d_(t,n){this._context=t,this._k=(1-n)/6}d_.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:h_(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:h_(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 d_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function v_(t,n){this._context=t,this._k=(1-n)/6}v_.prototype={areaStart:o_,areaEnd:o_,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:h_(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 g_=function t(n){function e(t){return new v_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function y_(t,n){this._context=t,this._k=(1-n)/6}y_.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:h_(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 __=function t(n){function e(t){return new y_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function b_(t,n,e){var r=t._x1,i=t._y1,o=t._x2,a=t._y2;if(t._l01_a>fy){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>fy){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 m_(t,n){this._context=t,this._alpha=n}m_.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:b_(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 x_=function t(n){function e(t){return n?new m_(t,n):new d_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function w_(t,n){this._context=t,this._alpha=n}w_.prototype={areaStart:o_,areaEnd:o_,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:b_(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 M_=function t(n){function e(t){return n?new w_(t,n):new v_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function N_(t,n){this._context=t,this._alpha=n}N_.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:b_(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 A_=function t(n){function e(t){return n?new N_(t,n):new y_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function T_(t){this._context=t}function S_(t){return t<0?-1:1}function k_(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(S_(o)+S_(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(u))||0}function E_(t,n){var e=t._x1-t._x0;return e?(3*(t._y1-t._y0)/e-n)/2:n}function C_(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 P_(t){this._context=t}function z_(t){this._context=new R_(t)}function R_(t){this._context=t}function D_(t){this._context=t}function q_(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=0;--n)i[n]=(a[n]-i[n+1])/o[n];for(o[r-1]=(t[r]+i[r-1])/2,n=0;n1)for(var e,r,i,o=1,a=t[n[0]],u=a.length;o=0;)e[n]=n;return e}function B_(t,n){return t[n]}function Y_(t){var n=t.map(F_);return O_(t).sort(function(t,e){return n[t]-n[e]})}function F_(t){for(var n,e=-1,r=0,i=t.length,o=-1/0;++eo&&(o=n,r=e);return r}function I_(t){var n=t.map(j_);return O_(t).sort(function(t,e){return n[t]-n[e]})}function j_(t){for(var n,e=0,r=-1,i=t.length;++r0)){if(o/=h,h<0){if(o0){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(o0)){if(o/=d,d<0){if(o0){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(o0||l<1)||(s>0&&(t[0]=[c+s*h,f+s*d]),l<1&&(t[1]=[c+l*h,f+l*d]),!0)}}}}}function eb(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=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]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]=r)return}else c=[n,a*n+u];o=[r,a*r+u]}else{if(c){if(c[0]=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}},V_.prototype={constructor:V_,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=Q_(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&&(W_(this,e),e=(t=e).U),e.C=!1,r.C=!0,Z_(this,r)):(i=r.L)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.L&&(Z_(this,e),e=(t=e).U),e.C=!1,r.C=!0,W_(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?Q_(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,W_(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,Z_(this,n),n=i.R),n.C=i.C,i.C=n.R.C=!1,W_(this,i),t=this._;break}}else if((n=i.L).C&&(n.C=!1,i.C=!0,Z_(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,W_(this,n),n=i.L),n.C=i.C,i.C=n.L.C=!1,Z_(this,i),t=this._;break}n.C=!0,t=i,i=i.U}while(!t.C);t&&(t.C=!1)}}};var ab,ub=[];function cb(){$_(this),this.x=this.y=this.arc=this.site=this.cy=null}function fb(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>=-Nb)){var d=c*c+f*f,p=s*s+l*l,v=(l*d-f*p)/h,g=(c*p-s*d)/h,y=ub.pop()||new cb;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=xb._;b;)if(y.yMb)u=u.L;else{if(!((i=o-_b(u,a))>Mb)){r>-Mb?(n=u.P,e=u):i>-Mb?(n=u,e=u.N):n=e=u;break}if(!u.R){n=u;break}u=u.R}!function(t){mb[t.index]={site:t,halfedges:[]}}(t);var c=db(t);if(bb.insert(n,c),n||e){if(n===e)return sb(n),e=db(n.site),bb.insert(c,e),c.edge=e.edge=J_(n.site,c.site),fb(n),void fb(e);if(e){sb(n),sb(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];tb(e.edge,f,p,m),c.edge=J_(f,t,null,m),e.edge=J_(t,p,null,m),fb(n),fb(e)}else c.edge=J_(n.site,c.site)}}function yb(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 _b(t,n){var e=t.N;if(e)return yb(e,n);var r=t.site;return r[1]===n?r[0]:1/0}var bb,mb,xb,wb,Mb=1e-6,Nb=1e-12;function Ab(t,n){return n[1]-t[1]||n[0]-t[0]}function Tb(t,n){var e,r,i,o=t.sort(Ab).pop();for(wb=[],mb=new Array(t.length),bb=new V_,xb=new V_;;)if(i=ab,o&&(!i||o[1]Mb||Math.abs(i[0][1]-i[1][1])>Mb)||delete wb[o]}(a,u,c,f),function(t,n,e,r){var i,o,a,u,c,f,s,l,h,d,p,v,g=mb.length,y=!0;for(i=0;iMb||Math.abs(v-h)>Mb)&&(c.splice(u,0,wb.push(K_(a,d,Math.abs(p-t)Mb?[t,Math.abs(l-t)Mb?[Math.abs(h-r)Mb?[e,Math.abs(l-e)Mb?[Math.abs(h-n)=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;lr?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}Pb.prototype=Eb.prototype,t.version="5.9.7",t.bisect=i,t.bisectRight=i,t.bisectLeft=o,t.ascending=n,t.bisector=e,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;rt?1:n>=t?0:NaN},t.deviation=f,t.extent=s,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;ol;)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=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=Ji(),v=a();++lr.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,no,eo),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.set=oo,t.map=Ji,t.keys=function(t){var n=[];for(var e in t)n.push(e);return n},t.values=function(t){var n=[];for(var e in t)n.push(t[e]);return n},t.entries=function(t){var n=[];for(var e in t)n.push({key:e,value:t[e]});return n},t.color=hn,t.rgb=gn,t.hsl=mn,t.lab=Rn,t.hcl=Yn,t.lch=function(t,n,e,r){return 1===arguments.length?Bn(t):new Fn(e,n,t,null==r?1:r)},t.gray=function(t,n){return new Dn(t,0,0,null==n?1:n)},t.cubehelix=Qn,t.contours=vo,t.contourDensity=function(){var t=_o,n=bo,e=mo,r=960,i=500,o=20,a=2,u=3*o,c=r+2*u>>a,f=i+2*u>>a,s=co(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=0&&h>a),yo({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),go({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),yo({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),go({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),yo({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 vo().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:co(+n),l):t},l.y=function(t){return arguments.length?(n="function"==typeof t?t:co(+t),l):n},l.weight=function(t){return arguments.length?(e="function"==typeof t?t:co(+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<=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)?co(ao.call(t)):co(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.dispatch=I,t.drag=function(){var n,e,r,i,o=Gt,a=Vt,u=$t,c=Wt,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),Ot,this,arguments);u&&(zt(t.event.view).on("mousemove.drag",v,!0).on("mouseup.drag",g,!0),It(t.event.view),Yt(),r=!1,n=t.event.clientX,e=t.event.clientY,u("start"))}}function v(){if(Ft(),!r){var i=t.event.clientX-n,o=t.event.clientY-e;r=i*i+o*o>h}f.mouse("drag")}function g(){zt(t.event.view).on("mousemove.drag mouseup.drag",null),jt(t.event.view,r),Ft(),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;nc+d||if+d||ou.index){var p=c-a.x-a.vx,v=f-a.y-a.vy,g=p*p+v*v;gt.r&&(t.r=t[n].r)}function u(){if(n){var r,i,o=n.length;for(e=new Array(o),r=0;r=a)){(t.data!==n||t.next)&&(0===s&&(d+=(s=ea())*s),0===l&&(d+=(l=ea())*l),d1?(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;f1?(f.on(t,e),n):f.on(t)}}},t.forceX=function(t){var n,e,r,i=na(.1);function o(t){for(var i,o=0,a=n.length;ovc(r[0],r[1])&&(r[1]=i[1]),vc(i[0],r[1])>vc(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=vc(r[1],i[0]))>a&&(a=u,Du=i[0],Lu=r[1])}return Iu=ju=null,Du===1/0||qu===1/0?[[NaN,NaN],[NaN,NaN]]:[[Du,qu],[Lu,Uu]]},t.geoCentroid=function(t){Hu=Xu=Gu=Vu=$u=Wu=Zu=Qu=Ju=Ku=tc=0,pu(t,_c);var n=Ju,e=Ku,r=tc,i=n*n+e*e+r*r;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;++e2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90]).scale(159.155)},t.geoTransverseMercatorRaw=cl,t.geoRotation=Lc,t.geoStream=pu,t.geoTransform=function(t){return{stream:Ms(t)}},t.cluster=function(){var t=fl,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(sl,0)/t.length}(e),n.y=function(t){return 1+t.reduce(ll,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.hierarchy=dl,t.pack=function(){var t=null,n=1,e=1,r=Rl;function i(i){return i.x=n/2,i.y=e/2,t?i.eachBefore(Ll(t)).eachAfter(Ul(r,.5)).eachBefore(Ol(1)):i.eachBefore(Ll(ql)).eachAfter(Ul(Rl,1)).eachAfter(Ul(r,i.r/Math.min(n,e))).eachBefore(Ol(Math.min(n,e)/(2*i.r))),i}return i.radius=function(n){return arguments.length?(t=null==(e=n)?null:zl(e),i):t;var e},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:Dl(+t),i):r},i},t.packSiblings=function(t){return Pl(t),t},t.packEnclose=bl,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&&Yl(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;a0)throw new Error("cycle");return o}return e.id=function(n){return arguments.length?(t=zl(n),e):t},e.parentId=function(t){return arguments.length?(n=zl(t),e):n},e},t.tree=function(){var t=Gl,n=1,e=1,r=null;function i(i){var c=function(t){for(var n,e,r,i,o,a=new Ql(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 Ql(r[i],i)),e.parent=n;return(a.parent=new Ql(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.xs.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=$l(u),o=Vl(o),u&&o;)c=Vl(c),(a=$l(a)).a=n,(i=u.z+l-o.z-f+t(u._,o._))>0&&(Wl(Zl(u,n,r),n,i),f+=i,s+=i),l+=u.m,f+=o.m,h+=c.m,s+=a.m;u&&!$l(a)&&(a.t=u,a.m+=l-s),o&&!Vl(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=nh,n=!1,e=1,r=1,i=[0],o=Rl,a=Rl,u=Rl,c=Rl,f=Rl;function s(t){return t.x0=t.y0=0,t.x1=e,t.y1=r,t.eachBefore(l),i=[0],n&&t.eachBefore(Bl),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=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>>1;f[v]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=Yl,t.treemapSlice=Jl,t.treemapSliceDice=function(t,n,e,r,i){(1&t.depth?Jl:Yl)(t,n,e,r,i)},t.treemapSquarify=nh,t.treemapResquarify=eh,t.interpolate=_e,t.interpolateArray=le,t.interpolateBasis=te,t.interpolateBasisClosed=ne,t.interpolateDate=he,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.interpolateHue=function(t,n){var e=ie(+t,+n);return function(t){var n=e(t);return n-360*Math.floor(n/360)}},t.interpolateNumber=de,t.interpolateObject=pe,t.interpolateRound=be,t.interpolateString=ye,t.interpolateTransformCss=ke,t.interpolateTransformSvg=Ee,t.interpolateZoom=qe,t.interpolateRgb=ue,t.interpolateRgbBasis=fe,t.interpolateRgbBasisClosed=se,t.interpolateHsl=Ue,t.interpolateHslLong=Oe,t.interpolateLab=function(t,n){var e=ae((t=Rn(t)).l,(n=Rn(n)).l),r=ae(t.a,n.a),i=ae(t.b,n.b),o=ae(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.interpolateHcl=Ye,t.interpolateHclLong=Fe,t.interpolateCubehelix=je,t.interpolateCubehelixLong=He,t.piecewise=function(t,n){for(var e=0,r=n.length-1,i=n[0],o=new Array(r<0?0:r);e=0;--n)f.push(t[r[o[n]][2]]);for(n=+u;nu!=f>u&&a<(c-e)*(u-r)/(f-r)+e&&(s=!s),c=e,f=r;return s},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;++r0?a[n-1]:r[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)},hh.apply(Ph(c),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=gh.call(t),o=Math.min(e.length,r.length-1),a):e.slice()},a.range=function(t){return arguments.length?(r=gh.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)},hh.apply(a,arguments)},t.scaleTime=function(){return hh.apply(Tv(Td,Nd,sd,ud,od,rd,nd,Qh,t.timeFormat).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)},t.scaleUtc=function(){return hh.apply(Tv(Qd,Wd,qd,zd,Cd,kd,nd,Qh,t.utcFormat).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},t.scaleSequential=function t(){var n=Ph(Sv()(wh));return n.copy=function(){return kv(n,t())},dh.apply(n,arguments)},t.scaleSequentialLog=function t(){var n=Bh(Sv()).domain([1,10]);return n.copy=function(){return kv(n,t()).base(n.base())},dh.apply(n,arguments)},t.scaleSequentialPow=Ev,t.scaleSequentialSqrt=function(){return Ev.apply(null,arguments).exponent(.5)},t.scaleSequentialSymlog=function t(){var n=Ih(Sv());return n.copy=function(){return kv(n,t()).constant(n.constant())},dh.apply(n,arguments)},t.scaleSequentialQuantile=function t(){var e=[],r=wh;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;i1)&&(t-=Math.floor(t));var n=Math.abs(t-.5);return Gg.h=360*t-100,Gg.s=1.5-1.5*n,Gg.l=.8-.9*n,Gg+""},t.interpolateWarm=Hg,t.interpolateCool=Xg,t.interpolateSinebow=function(t){var n;return t=(.5-t)*Math.PI,Vg.r=255*(n=Math.sin(t))*n,Vg.g=255*(n=Math.sin(t+$g))*n,Vg.b=255*(n=Math.sin(t+Wg))*n,Vg+""},t.interpolateViridis=Qg,t.interpolateMagma=Jg,t.interpolateInferno=Kg,t.interpolatePlasma=ty,t.create=function(t){return zt(W(t).call(document.documentElement))},t.creator=W,t.local=Dt,t.matcher=tt,t.mouse=Ot,t.namespace=$,t.namespaces=V,t.clientPoint=Ut,t.select=zt,t.selectAll=function(t){return"string"==typeof t?new Ct([document.querySelectorAll(t)],[document.documentElement]):new Ct([null==t?[]:t],Et)},t.selection=Pt,t.selector=Q,t.selectorAll=K,t.style=ct,t.touch=Bt,t.touches=function(t,n){null==n&&(n=Lt().touches);for(var e=0,r=n?n.length:0,i=new Array(r);ed;if(u||(u=c=Xi()),hfy)if(v>hy-fy)u.moveTo(h*iy(d),h*uy(d)),u.arc(0,0,h,d,p,!g),l>fy&&(u.moveTo(l*iy(p),l*uy(p)),u.arc(0,0,l,p,d,g));else{var y,_,b=d,m=p,x=d,w=p,M=v,N=v,A=a.apply(this,arguments)/2,T=A>fy&&(r?+r.apply(this,arguments):cy(l*l+h*h)),S=ay(ey(h-l)/2,+e.apply(this,arguments)),k=S,E=S;if(T>fy){var C=dy(T/l*uy(A)),P=dy(T/h*uy(A));(M-=2*C)>fy?(x+=C*=g?1:-1,w-=C):(M=0,x=w=(d+p)/2),(N-=2*P)>fy?(b+=P*=g?1:-1,m-=P):(N=0,b=m=(d+p)/2)}var z=h*iy(b),R=h*uy(b),D=l*iy(w),q=l*uy(w);if(S>fy){var L,U=h*iy(m),O=h*uy(m),B=l*iy(x),Y=l*uy(x);if(v1?0:s<-1?sy:Math.acos(s))/2),G=cy(L[0]*L[0]+L[1]*L[1]);k=ay(S,(l-G)/(X-1)),E=ay(S,(h-G)/(X+1))}}N>fy?E>fy?(y=by(B,Y,z,R,h,E,g),_=by(U,O,D,q,h,E,g),u.moveTo(y.cx+y.x01,y.cy+y.y01),Efy&&M>fy?k>fy?(y=by(D,q,U,O,l,-k,g),_=by(z,R,B,Y,l,-k,g),u.lineTo(y.cx+y.x01,y.cy+y.y01),k0&&(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;u0?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:ny(+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:ny(+t),a):r},a.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:ny(+t),a):i},a.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:ny(+t),a):o},a},t.areaRadial=Ry,t.radialArea=Ry,t.lineRadial=zy,t.radialLine=zy,t.pointRadial=Dy,t.linkHorizontal=function(){return Oy(By)},t.linkVertical=function(){return Oy(Yy)},t.linkRadial=function(){var t=Oy(Fy);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t},t.symbol=function(){var t=ny(Iy),n=ny(64),e=null;function r(){var r;if(e||(e=r=Xi()),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:ny(n),r):t},r.size=function(t){return arguments.length?(n="function"==typeof t?t:ny(+t),r):n},r.context=function(t){return arguments.length?(e=null==t?null:t,r):e},r},t.symbols=i_,t.symbolCircle=Iy,t.symbolCross=jy,t.symbolDiamond=Gy,t.symbolSquare=Qy,t.symbolStar=Zy,t.symbolTriangle=Ky,t.symbolWye=r_,t.curveBasisClosed=function(t){return new c_(t)},t.curveBasisOpen=function(t){return new f_(t)},t.curveBasis=function(t){return new u_(t)},t.curveBundle=l_,t.curveCardinalClosed=g_,t.curveCardinalOpen=__,t.curveCardinal=p_,t.curveCatmullRomClosed=M_,t.curveCatmullRomOpen=A_,t.curveCatmullRom=x_,t.curveLinearClosed=function(t){return new T_(t)},t.curveLinear=xy,t.curveMonotoneX=function(t){return new P_(t)},t.curveMonotoneY=function(t){return new z_(t)},t.curveNatural=function(t){return new D_(t)},t.curveStep=function(t){return new L_(t,.5)},t.curveStepAfter=function(t){return new L_(t,1)},t.curveStepBefore=function(t){return new L_(t,0)},t.stack=function(){var t=ny([]),n=O_,e=U_,r=B_;function i(i){var o,a,u=t.apply(this,arguments),c=i.length,f=u.length,s=new Array(f);for(o=0;o0){for(var e,r,i,o=0,a=t[0].length;o0)for(var e,r,i,o,a,u,c=0,f=t[n[0]].length;c=0?(r[0]=o,r[1]=o+=i):i<0?(r[1]=a,r[0]=a+=i):r[0]=o},t.stackOffsetNone=U_,t.stackOffsetSilhouette=function(t,n){if((e=t.length)>0){for(var e,r=0,i=t[n[0]],o=i.length;r0&&(r=(e=t[n[0]]).length)>0){for(var e,r,i,o=0,a=1;apr&&e.name===n)return new Cr([[t]],si,n,+r);return null},t.interrupt=Nr,t.voronoi=function(){var t=X_,n=G_,e=null;function r(r){return new Tb(r.map(function(e,i){var o=[Math.round(t(e,i,r)/Mb)*Mb,Math.round(n(e,i,r)/Mb)*Mb];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:H_(+n),r):t},r.y=function(t){return arguments.length?(n="function"==typeof t?t:H_(+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.zoom=function(){var n,e,r=Db,i=qb,o=Bb,a=Ub,u=Ob,c=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],s=250,l=qe,h=[],d=I("start","zoom","end"),p=500,v=150,g=0;function y(t){t.property("__zoom",Lb).on("wheel.zoom",N).on("mousedown.zoom",A).on("dblclick.zoom",T).filter(u).on("touchstart.zoom",S).on("touchmove.zoom",k).on("touchend.zoom touchcancel.zoom",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(t,n){return(n=Math.max(c[0],Math.min(c[1],n)))===t.k?t:new Eb(n,t.x,t.y)}function b(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 Eb(t.k,r,i)}function m(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function x(t,n,e){t.on("start.zoom",function(){w(this,arguments).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).end()}).tween("zoom",function(){var t=arguments,r=w(this,t),o=i.apply(this,t),a=e||m(o),u=Math.max(o[1][0]-o[0][0],o[1][1]-o[0][1]),c=this.__zoom,f="function"==typeof n?n.apply(this,t):n,s=l(c.invert(a).concat(u/c.k),f.invert(a).concat(u/f.k));return function(t){if(1===t)t=f;else{var n=s(t),e=u/n[2];t=new Eb(e,a[0]-n[0]*e,a[1]-n[1]*e)}r.zoom(null,t)}})}function w(t,n){for(var e,r=0,i=h.length;rg}n.zoom("mouse",o(b(n.that.__zoom,n.mouse[0]=Ot(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),Rb(),n.end()},!0),a=Ot(this),u=t.event.clientX,c=t.event.clientY;It(t.event.view),zb(),n.mouse=[a,this.__zoom.invert(a)],Nr(this),n.start()}}function T(){if(r.apply(this,arguments)){var n=this.__zoom,e=Ot(this),a=n.invert(e),u=n.k*(t.event.shiftKey?.5:2),c=o(b(_(n,u),e,a),i.apply(this,arguments),f);Rb(),s>0?zt(this).transition().duration(s).call(x,c,e):zt(this).call(y.transform,c)}}function S(){if(r.apply(this,arguments)){var e,i,o,a,u=w(this,arguments),c=t.event.changedTouches,f=c.length;for(zb(),i=0;i + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.math=t():e.math=t()}(this,function(){return n={},i.m=r=[function(e,t,r){"use strict";r.d(t,"a",function(){return n}),r.d(t,"b",function(){return i}),r.d(t,"c",function(){return o});r(2);var a=r(3);function n(r,n,i,e){function t(e){var t=Object(a.j)(e,n.map(o));return function(e,t,r){if(!t.filter(function(e){return!function(e){return e&&"?"===e[0]}(e)}).every(function(e){return void 0!==r[e]})){var n=t.filter(function(e){return void 0===r[e]});throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map(function(e){return'"'.concat(e,'"')}).join(", "),"."))}}(r,n,e),i(t)}return t.isFactory=!0,t.fn=r,t.dependencies=n.slice().sort(),e&&(t.meta=e),t}function i(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function o(e){return e&&"?"===e[0]?e.slice(1):e}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){return"number"==typeof e}function a(e){return e&&!0===e.constructor.prototype.isBigNumber||!1}function o(e){return e&&"object"===n(e)&&!0===Object.getPrototypeOf(e).isComplex||!1}function s(e){return e&&"object"===n(e)&&!0===Object.getPrototypeOf(e).isFraction||!1}function u(e){return e&&!0===e.constructor.prototype.isUnit||!1}function c(e){return"string"==typeof e}r.d(t,"y",function(){return i}),r.d(t,"e",function(){return a}),r.d(t,"j",function(){return o}),r.d(t,"o",function(){return s}),r.d(t,"L",function(){return u}),r.d(t,"I",function(){return c}),r.d(t,"b",function(){return f}),r.d(t,"v",function(){return l}),r.d(t,"i",function(){return p}),r.d(t,"n",function(){return m}),r.d(t,"H",function(){return h}),r.d(t,"D",function(){return d}),r.d(t,"t",function(){return y}),r.d(t,"g",function(){return g}),r.d(t,"G",function(){return v}),r.d(t,"s",function(){return b}),r.d(t,"p",function(){return x}),r.d(t,"m",function(){return w}),r.d(t,"F",function(){return N}),r.d(t,"z",function(){return O}),r.d(t,"x",function(){return M}),r.d(t,"K",function(){return E}),r.d(t,"a",function(){return j}),r.d(t,"c",function(){return S}),r.d(t,"d",function(){return A}),r.d(t,"f",function(){return C}),r.d(t,"k",function(){return T}),r.d(t,"l",function(){return _}),r.d(t,"q",function(){return I}),r.d(t,"r",function(){return B}),r.d(t,"u",function(){return q}),r.d(t,"w",function(){return k}),r.d(t,"A",function(){return z}),r.d(t,"B",function(){return D}),r.d(t,"C",function(){return R}),r.d(t,"E",function(){return P}),r.d(t,"J",function(){return F}),r.d(t,"h",function(){return U}),r.d(t,"M",function(){return L});var f=Array.isArray;function l(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function p(e){return Array.isArray(e)||l(e)}function m(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function h(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function d(e){return e&&!0===e.constructor.prototype.isRange||!1}function y(e){return e&&!0===e.constructor.prototype.isIndex||!1}function g(e){return"boolean"==typeof e}function v(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function b(e){return e&&!0===e.constructor.prototype.isHelp||!1}function x(e){return"function"==typeof e}function w(e){return e instanceof Date}function N(e){return e instanceof RegExp}function O(e){return!(!e||"object"!==n(e)||e.constructor!==Object||o(e)||s(e))}function M(e){return null===e}function E(e){return void 0===e}function j(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function S(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function A(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function C(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function T(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function _(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function I(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function B(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function q(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function k(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function z(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function D(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function R(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function P(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function F(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function U(e){return e&&!0===e.constructor.prototype.isChain||!1}function L(e){var t=n(e);return"object"===t?null===e?"null":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":a(e)?"BigNumber":o(e)?"Complex":s(e)?"Fraction":l(e)?"Matrix":u(e)?"Unit":y(e)?"Index":d(e)?"Range":v(e)?"ResultSet":k(e)?e.type:U(e)?"Chain":b(e)?"Help":"Object":"function"===t?"Function":t}},function(e,t,r){"use strict";r.d(t,"a",function(){return s}),r.d(t,"r",function(){return c}),r.d(t,"s",function(){return f}),r.d(t,"o",function(){return l}),r.d(t,"n",function(){return p}),r.d(t,"p",function(){return m}),r.d(t,"q",function(){return h}),r.d(t,"e",function(){return d}),r.d(t,"m",function(){return y}),r.d(t,"f",function(){return g}),r.d(t,"c",function(){return v}),r.d(t,"d",function(){return b}),r.d(t,"k",function(){return x}),r.d(t,"i",function(){return w}),r.d(t,"g",function(){return N}),r.d(t,"h",function(){return O}),r.d(t,"l",function(){return M}),r.d(t,"j",function(){return E}),r.d(t,"b",function(){return j});var n=r(4),i=r(1),a=r(5),u=r(6),o=r(10);function s(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function c(e,t){if(0===t.length){if(Array.isArray(e))throw new u.a(e.length,0)}else!function e(t,r,n){var i,a=t.length;if(a!==r[n])throw new u.a(a,r[n]);if(n")}(e,t,0)}function f(e,t){if(!Object(i.y)(e)||!Object(n.i)(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&t<=e)throw new o.a(e,t)}function l(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach(function(e){if(!Object(i.y)(e)||!Object(n.i)(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Object(a.d)(t)+")")}),function e(t,r,n,i){var a;var o;var s=t.length;var u=r[n];var c=Math.min(s,u);t.length=u;if(ni.length||n-a+1>i.length;)i.push(0);else for(var o=0<=n?n:Math.abs(a);i.length-1=i)return d(e,t);var s=o.coefficients,u=o.exponent;s.lengtht&&5<=n.splice(t,n.length-t)[0]){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function v(e){for(var t=[],r=0;r/g,">")}function m(e,t){if(!Object(n.I)(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Object(n.M)(e)+", index: 0)");if(!Object(n.I)(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Object(n.M)(t)+", index: 1)");return e===t?0:t=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}r.d(t,"a",function(){return n}),(n.prototype=new RangeError).constructor=RangeError,n.prototype.name="IndexError",n.prototype.isIndexError=!0},function(r,i,e){var a; +/** + * @license Fraction.js v4.0.12 09/09/2015 + * http://www.xarg.org/2014/03/rational-numbers-in-javascript/ + * + * Copyright (c) 2015, Robert Eisele (robert@xarg.org) + * Dual licensed under the MIT or GPL Version 2 licenses. + **/ +/** + * @license Fraction.js v4.0.12 09/09/2015 + * http://www.xarg.org/2014/03/rational-numbers-in-javascript/ + * + * Copyright (c) 2015, Robert Eisele (robert@xarg.org) + * Dual licensed under the MIT or GPL Version 2 licenses. + **/ +!function(){"use strict";var d={s:1,n:0,d:1};function e(t){function e(){var e=Error.apply(this,arguments);e.name=this.name=t,this.stack=e.stack,this.message=e.message}function r(){}return r.prototype=Error.prototype,e.prototype=new r,e}var y=c.DivisionByZero=e("DivisionByZero"),t=c.InvalidParameter=e("InvalidParameter");function g(e,t){return isNaN(e=parseInt(e,10))&&v(),e*t}function v(){throw new t}var n=function(e,t){var r,n=0,i=1,a=1,o=0,s=0,u=0,c=1,f=1,l=0,p=1,m=1,h=1;if(null==e);else if(void 0!==t)a=(n=e)*(i=t);else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,i=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(i=e[1])):v(),a=n*i;break;case"number":if(e<0&&(e=-(a=e)),e%1==0)n=e;else if(0>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}(0,n,i),o=-1===this.s?"-":"";if(o+=r/n|0,r%=n,(r*=10)&&(o+="."),i){for(var s=a;s--;)o+=r/n|0,r%=n,r*=10;o+="(";for(s=i;s--;)o+=r/n|0,r%=n,r*=10;o+=")"}else for(s=e;r&&s--;)o+=r/n|0,r%=n,r*=10;return o}},void 0===(a=function(){return c}.apply(i,[]))||(r.exports=a)}()},function(e,t){e.exports=function t(e,r){"use strict";function n(e){return t.insensitive&&(""+e).toLowerCase()||""+e}var i,a,o=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,u=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,c=/^0x[0-9a-f]+$/i,f=/^0/,l=n(e).replace(s,"")||"",p=n(r).replace(s,"")||"",m=l.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=p.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(l.match(c),16)||1!==m.length&&l.match(u)&&Date.parse(l),y=parseInt(p.match(c),16)||d&&p.match(u)&&Date.parse(p)||null;if(y){if(d=i+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(t=G(e[0]),function(e){return t(e[0])&&1===e.length}):2===e.length?(t=G(e[0]),n=G(e[1]),function(e){return t(e[0])&&n(e[1])&&2===e.length}):(r=e.map(G),function(e){for(var t=0;tl?(n=new TypeError("Too many arguments in function "+o+" (expected: "+l+", actual: "+r.length+")")).data={category:"tooManyArgs",fn:o,index:r.length,expectedLength:l}:(n=new TypeError('Arguments of type "'+r.join(", ")+'" do not match any of the defined signatures of function '+o+".")).data={category:"mismatch",actual:r.map(p)},n}function g(e){for(var t=999,r=0;r>>=1;return(e+r)/t}},m.exports.resetGlobal=function(){Math.random=t},l(Math.random(),i)}).call(this,t(20))},function(t,De,Re){var Pe;!function(){"use strict";var l,T,o,s=9e15,d=1e9,y="0123456789abcdef",n="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",i="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",u={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-s,maxE:s,crypto:!1},b=!0,c="[DecimalError] ",g=c+"Invalid argument: ",a=c+"Precision limit exceeded",f=c+"crypto unavailable",_=Math.floor,v=Math.pow,p=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,m=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,h=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,x=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,I=1e7,B=7,w=n.length-1,N=i.length-1,O={name:"[object Decimal]"};function M(e){var t,r,n,i=e.length-1,a="",o=e[0];if(0r-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}O.absoluteValue=O.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),D(e)},O.ceil=function(){return D(new this.constructor(this),this.e+1,2)},O.comparedTo=O.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;ts[t]^u<0?1:-1;return n===i?0:ithis.d.length-2},O.isNaN=function(){return!this.s},O.isNegative=O.isNeg=function(){return this.s<0},O.isPositive=O.isPos=function(){return 0t&&(t=this.e+1)):t=NaN,t},O.round=function(){var e=this.constructor;return D(new e(this),this.e+1,e.rounding)},O.sine=O.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+B,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return W(e,2,t,t);r=16<(r=1.4*Math.sqrt(n))?16:0|r,t=t.times(1/Y(5,r)),t=W(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,X(n,r)),n.precision=e,n.rounding=t,D(2=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=H(u,s,r,n),e.s<0?new u(1).div(i):D(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t=i.toExpPos):(E(e,1,d),void 0===t?t=i.rounding:E(t,0,8),C(n=D(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},O.toSignificantDigits=O.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(E(e,1,d),void 0===t?t=r.rounding:E(t,0,8)),D(new r(this),e,t)},O.toString=function(){var e=this,t=e.constructor,r=C(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},O.truncated=O.trunc=function(){return D(new this.constructor(this),this.e+1,1)},O.valueOf=O.toJSON=function(){var e=this,t=e.constructor,r=C(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var A=function(e,t,r,n,i,a){var o,s,u,c,f,l,p,m,h,d,y,g,v,b,x,w,N,O,M,E,j=e.constructor,S=e.s==t.s?1:-1,A=e.d,C=t.d;if(!(A&&A[0]&&C&&C[0]))return new j(e.s&&t.s&&(A?!C||A[0]!=C[0]:C)?A&&0==A[0]||!C?0*S:S/0:NaN);for(s=a?(f=1,e.e-t.e):(a=I,f=B,_(e.e/f)-_(t.e/f)),M=C.length,N=A.length,d=(h=new j(S)).d=[],u=0;C[u]==(A[u]||0);u++);if(C[u]>(A[u]||0)&&s--,null==r?(b=r=j.precision,n=j.rounding):b=i?r+(e.e-t.e)+1:r,b<0)d.push(1),l=!0;else{if(b=b/f+2|0,u=0,1==M){for(C=C[c=0],b++;(u=a/2&&++O;c=0,(o=k(C,y,M,g))<0?(v=y[0],M!=g&&(v=v*a+(y[1]||0)),1<(c=v/O|0)?(a<=c&&(c=a-1),1==(o=k(p=q(C,c,a),y,m=p.length,g=y.length))&&(c--,z(p,Mt[i]?1:-1;break}return a}function z(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]m.maxE?(e.d=null,e.e=NaN):e.ee.constructor.maxE?(e.d=null,e.e=NaN):e.ei-1;)l[r]=0,r||(++a,l.unshift(1));for(u=l.length;!l[u-1];--u);for(o=0,f="";ou)for(a-=u;a--;)f+="0";else at)return e.length=t,!0}function K(e){return new this(e).abs()}function ee(e){return new this(e).acos()}function te(e){return new this(e).acosh()}function re(e,t){return new this(e).plus(t)}function ne(e){return new this(e).asin()}function ie(e){return new this(e).asinh()}function ae(e){return new this(e).atan()}function oe(e){return new this(e).atanh()}function se(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?F(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=F(this,a,1).times(.5)).s=e.s:r=t.s<0?(this.precision=a,this.rounding=1,r=this.atan(A(e,t,a,1)),t=F(this,a,1),this.precision=n,this.rounding=i,e.s<0?r.minus(t):r.plus(t)):this.atan(A(e,t,a,1)):(r=F(this,a,1).times(0a.maxE?(i.e=NaN,i.d=null):e.e=e.length&&o.slice(0,e.length)===e&&(s+=u[c[t]],o=o.slice(e.length,o.length),r=!0)}),r||(s+=o.slice(0,1),o=o.slice(1,o.length))};o;)f();return s}},function(e,t){function r(){}r.prototype={on:function(e,t,r){var n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:t,ctx:r}),this},once:function(e,t,r){var n=this;function i(){n.off(e,i),t.apply(r,arguments)}return i._=t,this.on(e,i,r)},emit:function(e){for(var t=[].slice.call(arguments,1),r=((this.e||(this.e={}))[e]||[]).slice(),n=0,i=r.length;n15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new r(e)}},{from:"number",to:"Complex",convert:function(e){return n||f(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||f(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return n||f(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||l(e);var t=new i(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(t){r||c(t);try{return new r(t)}catch(e){throw new Error('Cannot convert "'+t+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(t){i||l(t);try{return new i(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(t){n||f(t);try{return new n(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return r||c(e),new r(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||l(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return t||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new t(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],a});function c(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function f(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function l(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var p=[],m=Object(s.a)("ResultSet",p,function(){function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return t.prototype.type="ResultSet",t.prototype.isResultSet=!0,t.prototype.valueOf=function(){return this.entries},t.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},t.fromJSON=function(e){return new t(e.entries)},t},{isClass:!0}),h=r(16),d=r.n(h),y=["?on","config"],g=Object(s.a)("BigNumber",y,function(e){var t=e.on,r=e.config,n=d.a.clone({precision:r.precision});return n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})}),n},{isClass:!0}),v=r(9),b=r.n(v);function x(e){return(x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var w=[],N=Object(s.a)("Complex",w,function(){return b.a.prototype.type="Complex",b.a.prototype.isComplex=!0,b.a.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},b.a.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},b.a.prototype.format=function(e){var t=this.im,r=this.re,n=Object(j.h)(this.re,e),i=Object(j.h)(this.im,e),a=Object(ie.y)(e)?e:e?e.precision:null;if(null!==a){var o=Math.pow(10,-a);Math.abs(r/t)t.re?1:e.ret.im?1:e.imn[a]&&(n[a]=t[a],i=!0);i&&s(e,n,r)}return(m.prototype=new t).createDenseMatrix=function(e,t){return new m(e,t)},m.prototype.type="DenseMatrix",m.prototype.isDenseMatrix=!0,m.prototype.getDataType=function(){return Object(I.h)(this._data,ie.M)},m.prototype.storage=function(){return"dense"},m.prototype.datatype=function(){return this._datatype},m.prototype.create=function(e,t){return new m(e,t)},m.prototype.subset=function(e,t,r){switch(arguments.length){case 1:return function(e,t){if(!Object(ie.t)(t))throw new TypeError("Invalid index");{if(t.isScalar())return e.get(t.min());var r=t.size();if(r.length!==e._size.length)throw new D.a(r.length,e._size.length);for(var n=t.min(),i=t.max(),a=0,o=e._size.length;a");var c=t.max().map(function(e){return e+1});l(e,c,n);var f=a.length;!function r(n,i,a,o,s){var e=s===o-1;var t=i.dimension(s);e?t.forEach(function(e,t){Object(I.s)(e),n[e]=a[t[0]]}):t.forEach(function(e,t){Object(I.s)(e),r(n[e],i,a[t[0]],o,s+1)})}(e._data,t,r,f,0)}return e}(this,e,t,r);default:throw new SyntaxError("Wrong number of arguments")}},m.prototype.get=function(e){if(!Object(ie.b)(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new D.a(e.length,this._size.length);for(var t=0;t=n.length)throw new R.a(t,n.length);return Object(ie.v)(e)?e.create(L(e.valueOf(),t,r)):L(e,t,r)}function L(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r");for(var c=t.min()[0],f=t.min()[1],l=i[0],p=i[1],m=0;m "+(this._values?Object(J.d)(this._values[u],e):"X")}return i},E.prototype.toString=function(){return Object(J.d)(this.toArray())},E.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},E.prototype.diagonal=function(e){if(e){if(Object(ie.e)(e)&&(e=e.toNumber()),!Object(ie.y)(e)||!Object(j.i)(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=0=n.length)throw new R.a(t,n.length);return Object(ie.v)(e)?e.create(jt(e.valueOf(),t,r)):jt(e,t,r)}})});function jt(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;rc)for(s-=c;s--;)u+="0";else s>1,f[m]&=1)}return f.reverse()}function Qr(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?Jr(t):t.eq(n)?Jr(e):e.isFinite()&&t.isFinite()?Yr(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function Kr(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function en(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var tn="number, number";function rn(e,t){if(!Object(j.i)(e)||!Object(j.i)(t))throw new Error("Integers expected in function bitAnd");return e&t}function nn(e){if(!Object(j.i)(e))throw new Error("Integer expected in function bitNot");return~e}function an(e,t){if(!Object(j.i)(e)||!Object(j.i)(t))throw new Error("Integers expected in function bitOr");return e|t}function on(e,t){if(!Object(j.i)(e)||!Object(j.i)(t))throw new Error("Integers expected in function bitXor");return e^t}function sn(e,t){if(!Object(j.i)(e)||!Object(j.i)(t))throw new Error("Integers expected in function leftShift");return e<>t}function cn(e,t){if(!Object(j.i)(e)||!Object(j.i)(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}rn.signature=tn,nn.signature="number",cn.signature=un.signature=sn.signature=on.signature=an.signature=tn;var fn=["typed","matrix","equalScalar"],ln=Object(s.a)("bitAnd",fn,function(e){var t=e.typed,r=e.matrix,n=e.equalScalar,i=nr({typed:t,equalScalar:n}),a=ar({typed:t,equalScalar:n}),o=sr({typed:t,equalScalar:n}),s=Xt({typed:t}),u=Kt({typed:t}),c=t("bitAnd",{"number, number":rn,"BigNumber, BigNumber":Vr,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,c,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,c,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,c,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,c)},"Array, Array":function(e,t){return c(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return c(r(e),t)},"Matrix, Array":function(e,t){return c(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,c,!1)},"DenseMatrix, any":function(e,t){return u(e,t,c,!1)},"any, SparseMatrix":function(e,t){return o(t,e,c,!0)},"any, DenseMatrix":function(e,t){return u(t,e,c,!0)},"Array, any":function(e,t){return u(r(e),t,c,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,c,!0).valueOf()}});return c}),pn=["typed"],mn=Object(s.a)("bitNot",pn,function(e){var t=(0,e.typed)("bitNot",{number:nn,BigNumber:Jr,"Array | Matrix":function(e){return oe(e,t)}});return t}),hn=["typed","matrix","equalScalar","DenseMatrix"],dn=Object(s.a)("bitOr",hn,function(e){var t=e.typed,r=e.matrix,n=e.equalScalar,i=e.DenseMatrix,a=Gt({typed:t}),o=Vt({typed:t,equalScalar:n}),s=Wt({typed:t,DenseMatrix:i}),u=Xt({typed:t}),c=Kt({typed:t}),f=t("bitOr",{"number, number":an,"BigNumber, BigNumber":Wr,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,f)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,f,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,f,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,f)},"Array, Array":function(e,t){return f(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return f(r(e),t)},"Matrix, Array":function(e,t){return f(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,f,!1)},"DenseMatrix, any":function(e,t){return c(e,t,f,!1)},"any, SparseMatrix":function(e,t){return s(t,e,f,!0)},"any, DenseMatrix":function(e,t){return c(t,e,f,!0)},"Array, any":function(e,t){return c(r(e),t,f,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,f,!0).valueOf()}});return f}),yn=["typed","DenseMatrix"],gn=Object(s.a)("algorithm07",yn,function(e){var O=e.typed,M=e.DenseMatrix;return function(e,t,r){var n=e._size,i=e._datatype,a=t._size,o=t._datatype;if(n.length!==a.length)throw new D.a(n.length,a.length);if(n[0]!==a[0]||n[1]!==a[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+a+")");var s,u,c,f=n[0],l=n[1],p=0,m=r;"string"==typeof i&&i===o&&(s=i,p=O.convert(0,s),m=O.find(r,[s,s]));var h=[];for(u=0;un)return e.substring(0,n);if(e.lengtha)for(var u=a-1,c=o.length;un&&(n=t[a],r=[a])}return r}});function da(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=2>=1,i=o(i,i);return n}function l(e,t){return r(f(e.valueOf(),t))}});function ka(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function za(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Da="Number of decimals in function round must be an integer",Ra="round",Pa=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],Fa=Object(s.a)(Ra,Pa,function(e){var t=e.typed,r=e.matrix,n=e.equalScalar,i=e.zeros,a=e.BigNumber,o=e.DenseMatrix,s=sr({typed:t,equalScalar:n}),u=br({typed:t,DenseMatrix:o}),c=Kt({typed:t}),f=t(Ra,function(t){for(var e=1;et.re)return 1;if(e.ret.im)return 1;if(e.imt.length?1:e.length=e.length)throw new Error("k out of bounds");for(var n=0;n=e&&(c(o.value,0)||r(o.key,o.value,this)),(o=n.extractMinimum())&&a.push(o);for(var s=0;se[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(r)}});function u(e,t){for(var r=[],n=0;n)'),t+this.index.toHTML(e)},n.prototype._toTex=function(e){var t=this.object.toTex(e);return i(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},n.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},n.fromJSON=function(e){return new n(e.object,e.index)},n},{isClass:!0,isNode:!0}),Hc=["Node"],$c=Object(s.a)("ArrayNode",Hc,function(e){var t=e.Node;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(ie.w))throw new TypeError("Array containing Nodes expected");function t(){throw new Error("Property `ArrayNode.nodes` is deprecated, use `ArrayNode.items` instead")}Object.defineProperty(this,"nodes",{get:t,set:t})}return(n.prototype=new t).type="ArrayNode",n.prototype.isArrayNode=!0,n.prototype._compile=function(t,r){var e=Object(I.m)(this.items,function(e){return e._compile(t,r)});if("Array"===t.config.matrix)return function(t,r,n){return Object(I.m)(e,function(e){return e(t,r,n)})};var i=t.matrix;return function(t,r,n){return i(Object(I.m)(e,function(e){return e(t,r,n)}))}},n.prototype.forEach=function(e){for(var t=0;t['+this.items.map(function(e){return e.toHTML(t)}).join(',')+']'},n.prototype._toTex=function(t){var r="\\begin{bmatrix}";return this.items.forEach(function(e){e.items?r+=e.items.map(function(e){return e.toTex(t)}).join("&"):r+=e.toTex(t),r+="\\\\"}),r+="\\end{bmatrix}"},n},{isClass:!0,isNode:!0});function Gc(e){return(Gc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var Zc=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Vc(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i)'),t+r+'='+n},i.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return a(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},i},{isClass:!0,isNode:!0}),Qc=["ResultSet","Node"],Kc=Object(s.a)("BlockNode",Qc,function(e){var o=e.ResultSet,t=e.Node;function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map(function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!Object(ie.w)(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}})}return(a.prototype=new t).type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(t,r){var e=Object(I.m)(this.blocks,function(e){return{evaluate:e.node._compile(t,r),visible:e.visible}});return function(r,n,i){var a=[];return Object(I.f)(e,function(e){var t=e.evaluate(r,n,i);e.visible&&a.push(t)}),new o(a)}},a.prototype.forEach=function(e){for(var t=0;t;')}).join('
')},a.prototype._toTex=function(t){return this.blocks.map(function(e){return e.node.toTex(t)+(e.visible?"":";")}).join("\\;\\;\n")},a},{isClass:!0,isNode:!0}),ef=["Node"],tf=Object(s.a)("ConditionalNode",ef,function(e){var t=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Object(ie.w)(e))throw new TypeError("Parameter condition must be a Node");if(!Object(ie.w)(t))throw new TypeError("Parameter trueExpr must be a Node");if(!Object(ie.w)(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}return(n.prototype=new t).type="ConditionalNode",n.prototype.isConditionalNode=!0,n.prototype._compile=function(e,t){var n=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,r){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(Object(ie.e)(e))return!e.isZero();if(Object(ie.j)(e))return!(!e.re&&!e.im);if(Object(ie.L)(e))return!!e.value}if(null!=e)throw new TypeError('Unsupported type of condition "'+Object(ie.M)(e)+'"');return!1}(n(e,t,r))?i(e,t,r):a(e,t,r)}},n.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},n.prototype.clone=function(){return new n(this.condition,this.trueExpr,this.falseExpr)},n.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Vc(this,t),n=this.condition.toString(e),i=Vc(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Vc(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Vc(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s},n.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},n.fromJSON=function(e){return new n(e.condition,e.trueExpr,e.falseExpr)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Vc(this,t),n=this.condition.toHTML(e),i=Vc(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=Vc(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=Vc(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='('+s+')'),n+'?'+a+':'+s},n.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},n},{isClass:!0,isNode:!0}),rf=r(17),nf=r.n(rf),af={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},of={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},sf={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(of.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(of.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(of.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(of.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(of.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(of.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(of.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(of.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(of.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(of.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(of.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(of.bitAnd,"${args[1]}\\right)")},bitNot:{1:of.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(of.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(of.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(of.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(of.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(of.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(of.and,"${args[1]}\\right)")},not:{1:of.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(of.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(of.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(of.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(of.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(of.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(of.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(of.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(of.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(of.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(of.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(of.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(of.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(of.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(af.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},uf={deg:"^\\circ"};function cf(e){return nf()(e,{preserveFormatting:!0})}function ff(e,t){return(t=void 0!==t&&t)?Object(ae.f)(uf,e)?uf[e]:"\\mathrm{"+cf(e)+"}":Object(ae.f)(af,e)?af[e]:cf(e)}var lf=["Node"],pf=Object(s.a)("ConstantNode",lf,function(e){var t=e.Node;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(2===arguments.length)throw new SyntaxError("new ConstantNode(valueStr, valueType) is not supported anymore since math v4.0.0. Use new ConstantNode(value) instead, where value is a non-stringified value.");this.value=e}return(r.prototype=new t).type="ConstantNode",r.prototype.isConstantNode=!0,r.prototype._compile=function(e,t){var r=this.value;return function(){return r}},r.prototype.forEach=function(e){},r.prototype.map=function(e){return this.clone()},r.prototype.clone=function(){return new r(this.value)},r.prototype._toString=function(e){return Object(J.d)(this.value,e)},r.prototype.toHTML=function(e){var t=this._toString(e);switch(Object(ie.M)(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},r.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},r.fromJSON=function(e){return new r(e.value)},r.prototype._toTex=function(e){var t=this._toString(e);switch(Object(ie.M)(this.value)){case"string":return"\\mathtt{"+cf(t)+"}";case"number":case"BigNumber":var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},r},{isClass:!0,isNode:!0}),mf=["typed","Node"],hf=Object(s.a)("FunctionAssignmentNode",mf,function(e){var f=e.typed,t=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Object(ie.w)(r))throw new TypeError('Node expected for parameter "expr"');if(e in qc)throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map(function(e){return e&&e.name||e}),this.types=t.map(function(e){return e&&e.type||"any"}),this.expr=r}function a(e,t){var r=Vc(e,t),n=Vc(e.expr,t);return"all"===t||null!==n&&n<=r}return(n.prototype=new t).type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,t){var r=Object.create(t);Object(I.f)(this.params,function(e){r[e]=!0});var a=this.expr._compile(e,r),o=this.name,s=this.params,u=Object(I.k)(this.types,","),c=o+"("+Object(I.k)(this.params,", ")+")";return function(r,n,i){var e={};e[u]=function(){for(var e=Object.create(n),t=0;t'+Object(J.c)(this.params[n])+"");var i=this.expr.toHTML(e);return a(this,t)&&(i='('+i+')'),''+Object(J.c)(this.name)+'('+r.join(',')+')='+i},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return a(this,t)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(ff).join(",")+"\\right):="+r},n},{isClass:!0,isNode:!0}),df=["Index"],yf=Object(s.a)("index",df,function(e){var a=e.Index;return function(){for(var e=[],t=0,r=arguments.length;t.'+Object(J.c)(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(t){var e=this.dimensions.map(function(e){return e.toTex(t)});return this.dotNotation?"."+this.getObjectProperty():"_{"+e.join(",")+"}"},i},{isClass:!0,isNode:!0});function xf(e){return(xf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var wf=["Node"],Nf=Object(s.a)("ObjectNode",wf,function(e){var t=e.Node;function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=t||{},t&&("object"!==xf(t)||!Object.keys(t).every(function(e){return Object(ie.w)(t[e])})))throw new TypeError("Object containing Nodes expected")}return(n.prototype=new t).type="ObjectNode",n.prototype.isObjectNode=!0,n.prototype._compile=function(e,t){var a={};for(var r in this.properties)if(Object(ae.f)(this.properties,r)){var n=Object(J.e)(r),i=JSON.parse(n);if(!Li(this.properties,i))throw new Error('No access to property "'+i+'"');a[i]=this.properties[r]._compile(e,t)}return function(e,t,r){var n={};for(var i in a)Object(ae.f)(a,i)&&(n[i]=a[i](e,t,r));return n}},n.prototype.forEach=function(e){for(var t in this.properties)Object(ae.f)(this.properties,t)&&e(this.properties[t],"properties["+Object(J.e)(t)+"]",this)},n.prototype.map=function(e){var t={};for(var r in this.properties)Object(ae.f)(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],"properties["+Object(J.e)(r)+"]",this)));return new n(t)},n.prototype.clone=function(){var e={};for(var t in this.properties)Object(ae.f)(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)},n.prototype._toString=function(e){var t=[];for(var r in this.properties)Object(ae.f)(this.properties,r)&&t.push(Object(J.e)(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"},n.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},n.fromJSON=function(e){return new n(e.properties)},n.prototype.toHTML=function(e){var t=[];for(var r in this.properties)Object(ae.f)(this.properties,r)&&t.push(''+Object(J.c)(r)+':'+this.properties[r].toHTML(e));return'{'+t.join(',')+'}'},n.prototype._toTex=function(e){var t=[];for(var r in this.properties)Object(ae.f)(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},n},{isClass:!0,isNode:!0}),Of=["Node"],Mf=Object(s.a)("OperatorNode",Of,function(e){var t=e.Node;function i(e,t,r,n){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(r)||!r.every(ie.w))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===n,this.op=e,this.fn=t,this.args=r||[]}function m(i,a,e,t,r){var n,o=Vc(i,a),s=Jc(i,a);if("all"===a||2)'),"right"===a?''+Object(J.c)(this.op)+""+o:o+''+Object(J.c)(this.op)+""}if(2===n.length){var s=n[0].toHTML(r),u=n[1].toHTML(r);return i[0]&&(s='('+s+')'),i[1]&&(u='('+u+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?s+''+u:s+''+Object(J.c)(this.op)+""+u}var c=n.map(function(e,t){return e=e.toHTML(r),i[t]&&(e='('+e+')'),e});return 2'):c.join(''+Object(J.c)(this.op)+""):''+Object(J.c)(this.fn)+'('+c.join(',')+')'},i.prototype._toTex=function(r){var e=r&&r.parenthesis?r.parenthesis:"keep",t=r&&r.implicit?r.implicit:"hide",n=this.args,i=m(this,e,t,n,!0),a=of[this.fn];if(a=void 0===a?this.op:a,1===n.length){var o=Jc(this,e),s=n[0].toTex(r);return i[0]&&(s="\\left(".concat(s,"\\right)")),"right"===o?a+s:s+a}if(2===n.length){var u=n[0],c=u.toTex(r);i[0]&&(c="\\left(".concat(c,"\\right)"));var f,l=n[1].toTex(r);switch(i[1]&&(l="\\left(".concat(l,"\\right)")),f="keep"===e?u.getIdentifier():u.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return a+"{"+c+"}{"+l+"}";case"OperatorNode:pow":switch(c="{"+c+"}",l="{"+l+"}",f){case"ConditionalNode":case"OperatorNode:divide":c="\\left(".concat(c,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===t)return c+"~"+l}return c+a+l}if(2('+this.content.toHTML(e)+')':this.content.toHTML(e)},r.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},r},{isClass:!0,isNode:!0}),Sf=["Node"],Af=Object(s.a)("RangeNode",Sf,function(e){var t=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Object(ie.w)(e))throw new TypeError("Node expected");if(!Object(ie.w)(t))throw new TypeError("Node expected");if(r&&!Object(ie.w)(r))throw new TypeError("Node expected");if(3('+n+')'),t=n,this.step){var i=this.step.toHTML(e);r.step&&(i='('+i+')'),t+=':'+i}var a=this.end.toHTML(e);return r.end&&(a='('+a+')'),t+=':'+a},n.prototype._toTex=function(e){var t=o(this,e&&e.parenthesis?e.parenthesis:"keep"),r=this.start.toTex(e);if(t.start&&(r="\\left(".concat(r,"\\right)")),this.step){var n=this.step.toTex(e);t.step&&(n="\\left(".concat(n,"\\right)")),r+=":"+n}var i=this.end.toTex(e);return t.end&&(i="\\left(".concat(i,"\\right)")),r+=":"+i},n},{isClass:!0,isNode:!0}),Cf=["Node"],Tf=Object(s.a)("RelationalNode",Cf,function(e){var t=e.Node;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return(i.prototype=new t).type="RelationalNode",i.prototype.isRelationalNode=!0,i.prototype._compile=function(o,t){var s=this,u=this.params.map(function(e){return e._compile(o,t)});return function(e,t,r){for(var n,i=u[0](e,t,r),a=0;a",smallerEq:"<=",largerEq:">="},r=e[0],o=0;o('+e.toHTML(n)+')':e.toHTML(n)}),t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},r=e[0],o=0;o'+Object(J.c)(t[this.conditionals[o]])+""+e[o+1];return r},i.prototype._toTex=function(n){for(var i=n&&n.parenthesis?n.parenthesis:"keep",a=Vc(this,i),e=this.params.map(function(e,t){var r=Vc(e,i);return"all"===i||null!==r&&r<=a?"\\left("+e.toTex(n)+"\right)":e.toTex(n)}),t=e[0],r=0;r'+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},r.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},r.fromJSON=function(e){return new r(e.name)},r.prototype._toTex=function(e){var t=!1;void 0===n[this.name]&&s(this.name)&&(t=!0);var r=ff(this.name,t);return"\\"===r[0]?r:" "+r},r},{isClass:!0,isNode:!0});function Bf(e){return(Bf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function qf(){return(qf=Object.assign||function(e){for(var t=1;t'+Object(J.c)(this.fn)+'('+e.join(',')+')'};var r=y.prototype.toTex;return y.prototype.toTex=function(e){var t;return e&&"object"===Bf(e.handler)&&Object(ae.f)(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:r.call(this,e)},y.prototype._toTex=function(t){var e,r,n=this.args.map(function(e){return e.toTex(t)});switch(sf[this.name]&&(e=sf[this.name]),!i[this.name]||"function"!=typeof i[this.name].toTex&&"object"!==Bf(i[this.name].toTex)&&"string"!=typeof i[this.name].toTex||(e=i[this.name].toTex),Bf(e)){case"function":r=e(this,t);break;case"string":r=o(e,this,t);break;case"object":switch(Bf(e[n.length])){case"function":r=e[n.length](this,t);break;case"string":r=o(e[n.length],this,t)}}return void 0!==r?r:o("\\mathrm{${name}}\\left(${args}\\right)",this,t)},y.prototype.getIdentifier=function(){return this.type+":"+this.name},y},{isClass:!0,isNode:!0});function Df(){return(Df=Object.assign||function(e){for(var t=1;t":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},O={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},M={true:!0,false:!1,null:null,undefined:void 0},E=["NaN","Infinity"];function j(e,t){return e.expression.substr(e.index,t)}function S(e){return j(e,1)}function A(e){e.index++}function C(e){return e.expression.charAt(e.index-1)}function T(e){return e.expression.charAt(e.index+1)}function _(e){for(e.tokenType=w.NULL,e.token="",e.comment="";x.isWhitespace(S(e),e.nestingLevel);)A(e);if("#"===S(e))for(;"\n"!==S(e)&&""!==S(e);)e.comment+=S(e),A(e);if(""!==S(e)){if("\n"===S(e)&&!e.nestingLevel)return e.tokenType=w.DELIMITER,e.token=S(e),void A(e);var t=S(e),r=j(e,2),n=j(e,3);if(3===n.length&&N[n])return e.tokenType=w.DELIMITER,e.token=n,A(e),A(e),void A(e);if(2===r.length&&N[r])return e.tokenType=w.DELIMITER,e.token=r,A(e),void A(e);if(N[t])return e.tokenType=w.DELIMITER,e.token=t,void A(e);if(x.isDigitDot(t)){if(e.tokenType=w.NUMBER,"."===S(e))e.token+=S(e),A(e),x.isDigit(S(e))||(e.tokenType=w.DELIMITER);else{for(;x.isDigit(S(e));)e.token+=S(e),A(e);x.isDecimalMark(S(e),T(e))&&(e.token+=S(e),A(e))}for(;x.isDigit(S(e));)e.token+=S(e),A(e);if("E"===S(e)||"e"===S(e))if(x.isDigit(T(e))||"-"===T(e)||"+"===T(e)){if(e.token+=S(e),A(e),"+"!==S(e)&&"-"!==S(e)||(e.token+=S(e),A(e)),!x.isDigit(S(e)))throw re(e,'Digit expected, got "'+S(e)+'"');for(;x.isDigit(S(e));)e.token+=S(e),A(e);if(x.isDecimalMark(S(e),T(e)))throw re(e,'Digit expected, got "'+S(e)+'"')}else if("."===T(e))throw A(e),re(e,'Digit expected, got "'+S(e)+'"')}else{if(!x.isAlpha(S(e),C(e),T(e))){for(e.tokenType=w.UNKNOWN;""!==S(e);)e.token+=S(e),A(e);throw re(e,'Syntax error in part "'+e.token+'"')}for(;x.isAlpha(S(e),C(e),T(e))||x.isDigit(S(e));)e.token+=S(e),A(e);Object(ae.f)(O,e.token)?e.tokenType=w.DELIMITER:e.tokenType=w.SYMBOL}}else e.tokenType=w.DELIMITER}function I(e){for(;_(e),"\n"===e.token;);}function B(e){e.nestingLevel++}function q(e){e.nestingLevel--}function k(e,t){var r={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:w.NULL,nestingLevel:0,conditionalLevel:null};Df(r,{expression:e,extraNodes:t}),_(r);var n=function(e){var t,r,n=[];""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=z(e)).comment=e.comment);for(;"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),_(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=z(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return 0":"larger","<=":"smallerEq",">=":"largerEq"};Object(ae.f)(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),I(e),t.push(H(e))}return 1===t.length?t[0]:2===t.length?new y(r[0].name,r[0].fn,t):new v(r.map(function(e){return e.fn}),t)}function H(e){var t,r,n,i;t=$(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Object(ae.f)(a,e.token);)n=a[r=e.token],I(e),i=[t,$(e)],t=new y(r,n,i);return t}function $(e){var t,r,n,i;t=G(e);for(var a={to:"to",in:"to"};Object(ae.f)(a,e.token);)n=a[r=e.token],I(e),t="in"===r&&""===e.token?new y("*","multiply",[t,new b("in")],!0):(i=[t,G(e)],new y(r,n,i));return t}function G(e){var t,r=[];if(t=":"===e.token?new l(1):Z(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)I(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new b("end")):r.push(Z(e));t=3===r.length?new n(r[0],r[2],r[1]):new n(r[0],r[1])}return t}function Z(e){var t,r,n,i;t=V(e);for(var a={"+":"add","-":"subtract"};Object(ae.f)(a,e.token);)n=a[r=e.token],I(e),i=[t,V(e)],t=new y(r,n,i);return t}function V(e){var t,r,n,i;r=t=J(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Object(ae.f)(a,e.token);)i=a[n=e.token],I(e),r=J(e),t=new y(n,i,[t,r]);return t}function J(e){var t,r;for(r=t=W(e);e.tokenType===w.SYMBOL||"in"===e.token&&Object(ie.l)(t)||!(e.tokenType!==w.NUMBER||Object(ie.l)(r)||Object(ie.B)(r)&&"!"!==r.op)||"("===e.token;)r=W(e),t=new y("*","multiply",[t,r],!0);return t}function W(e){for(var t=Y(e),r=t,n=[];"/"===e.token&&Object(ie.l)(r);){if(n.push(Df({},e)),I(e),e.tokenType!==w.NUMBER){Df(e,n.pop());break}if(n.push(Df({},e)),I(e),e.tokenType!==w.SYMBOL&&"("!==e.token){n.pop(),Df(e,n.pop());break}Df(e,n.pop()),n.pop(),r=Y(e),t=new y("/","divide",[t,r])}return t}function Y(e){var t,r,n,i={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Object(ae.f)(i,e.token)?(n=i[e.token],t=e.token,I(e),r=[Y(e)],new y(t,n,r)):function(e){var t,r,n,i;t=function(e){var t,r,n;t=function(e){var t=[];if(e.tokenType===w.SYMBOL&&Object(ae.f)(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(_(e),"("===e.token){if(t=[],B(e),_(e),")"!==e.token)for(t.push(z(e));","===e.token;)_(e),t.push(z(e));if(")"!==e.token)throw re(e,"Parenthesis ) expected");q(e),_(e)}return new r(t)}return function(e){var t,r;if(e.tokenType===w.SYMBOL||e.tokenType===w.DELIMITER&&e.token in O)return r=e.token,_(e),t=Object(ae.f)(M,r)?new l(M[r]):-1!==E.indexOf(r)?new l(s(r,"number")):new b(r),t=X(e,t);return function(e){var t,r;return'"'!==e.token?function(e){var t,r;return"'"!==e.token?function(e){var t,r,n,i;if("["!==e.token)return function(e){if("{"!==e.token)return function(e){var t;return e.tokenType!==w.NUMBER?function(e){var t;if("("!==e.token)return function(e){throw""===e.token?re(e,"Unexpected end of expression"):re(e,"Value expected")}(e);if(B(e),_(e),t=z(e),")"===e.token)return q(e),_(e),t=new g(t),t=X(e,t);throw re(e,"Parenthesis ) expected")}(e):(t=e.token,_(e),new l(s(t,u.number)))}(e);var t;B(e);var r={};do{if(_(e),"}"!==e.token){if('"'===e.token)t=Q(e);else if("'"===e.token)t=K(e);else{if(e.tokenType!==w.SYMBOL)throw re(e,"Symbol or string expected as object key");t=e.token,_(e)}if(":"!==e.token)throw re(e,"Colon : expected after object key");_(e),r[t]=z(e)}}while(","===e.token);if("}"!==e.token)throw re(e,"Comma , or bracket } expected after object value");q(e),_(e);var n=new d(r);return n=X(e,n)}(e);if(B(e),_(e),"]"!==e.token){var a=ee(e);if(";"===e.token){for(n=1,r=[a];";"===e.token;)_(e),r[n]=ee(e),n++;if("]"!==e.token)throw re(e,"End of matrix ] expected");q(e),_(e),i=r[0].items.length;for(var o=1;oi))for(var l=s[c+1];f=D?A[q+m]-=y:0!==A[q+m]&&(A[q+m]=A[B+m]+Z)}for(g=$;g1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:Cl,eval:Cl,help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:Il,var:Il,acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:Al,typeof:Al,numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},ql=["typed","mathWithTransform","Help"],kl=Object(s.a)("help",ql,function(e){var t=e.typed,a=e.mathWithTransform,o=e.Help;return t("help",{any:function(e){var t,r=e;if("string"!=typeof e)for(t in a)if(Object(ae.f)(a,t)&&e===a[t]){r=t;break}var n=Fi(Bl,r);if(n)return new o(n);var i="function"==typeof r?r.name:r;throw new Error('No documentation found on "'+i+'"')}})}),zl=["typed","Chain"],Dl=Object(s.a)("chain",zl,function(e){var t=e.typed,r=e.Chain;return t("chain",{"":function(){return new r},any:function(e){return new r(e)}})}),Rl=["typed","matrix","subtract","multiply","unaryMinus","lup"],Pl=Object(s.a)("det",Rl,function(e){var t=e.typed,n=e.matrix,f=e.subtract,l=e.multiply,p=e.unaryMinus,m=e.lup;return t("det",{any:function(e){return Object(ae.a)(e)},"Array | Matrix":function(e){var t;switch((t=Object(ie.v)(e)?e.size():Array.isArray(e)?(e=n(e)).size():[]).length){case 0:return Object(ae.a)(e);case 1:if(1===t[0])return Object(ae.a)(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Object(J.d)(t)+")");case 2:var r=t[0];if(r===t[1])return function(e,t){{if(1===t)return Object(ae.a)(e[0][0]);if(2===t)return f(l(e[0][0],e[1][1]),l(e[1][0],e[0][1]));for(var r=m(e),n=r.U[0][0],i=1;ip&&(p=M(c[n][l]),m=n),n++;if(0===p)throw Error("Cannot calculate inverse, determinant is zero");(n=m)!==l&&(s=c[l],c[l]=c[n],c[n]=s,s=f[l],f[l]=f[n],f[n]=s);var h=c[l],d=f[l];for(n=0;nh)throw new Error("computing square root of matrix: iterative method could not converge")}while(d>1;return yp(e,r)*yp(1+r,t)}function gp(e,t){if(!Object(j.i)(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!Object(j.i)(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(e");if(2!==o.length)throw SyntaxError("Could not parse rule: "+n);n={l:o[0],r:o[1]};case"object":if(i={l:T(c(n.l)),r:T(c(n.r))},n.context&&(i.evaluate=n.context),n.evaluate&&(i.evaluate=c(n.evaluate)),M(i.l)){var s=A(i.l),u=new v("_p"+I++);i.expanded={},i.expanded.l=s([i.l.clone(),u]),E(i.expanded.l),j(i.expanded.l),i.expanded.r=s([i.r,u])}break;case"function":i=n;break;default:throw TypeError("Unsupported type of rule: "+a)}t.push(i)}return t}(t);for(var i=w(e,r),a={},o=(i=T(i)).toString({parenthesis:"all"});!a[o];){a[o]=!0;for(var s=I=0;s=i.flowLevel;switch(H(r,n,i.indent,t,function(e){return function(e,t){var n,i;for(n=0,i=e.implicitTypes.length;n"+V(r,i.indent)+Z(L(function(t,n){var e,i,r=/(\n+)([^\n]*)/g,o=function(){var e=t.indexOf("\n");return e=-1!==e?e:t.length,r.lastIndex=e,z(t.slice(0,e),n)}(),a="\n"===t[0]||" "===t[0];for(;i=r.exec(t);){var s=i[1],c=i[2];e=" "===c[0],o+=s+(a||e||""===c?"":"\n")+z(c,n),a=e}return o}(r,t),e));case $:return'"'+function(e){for(var t,n,i,r="",o=0;ot&&o tag resolver accepts not "'+c+'" style');i=s.represent[c](t,c)}e.dump=i}return!0}return!1}function Q(e,t,n,i,r,o){e.tag=null,e.dump=n,J(e,n,!1)||J(e,n,!0);var a=p.call(e.dump);i&&(i=e.flowLevel<0||e.flowLevel>t);var s,c,u="[object Object]"===a||"[object Array]"===a;if(u&&(c=-1!==(s=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||c||2!==e.indent&&0 "+e.dump)}return!0}function X(e,t){var n,i,r=[],o=[];for(function e(t,n,i){var r,o,a;if(null!==t&&"object"==typeof t)if(-1!==(o=n.indexOf(t)))-1===i.indexOf(o)&&i.push(o);else if(n.push(t),Array.isArray(t))for(o=0,a=t.length;ot)&&0!==i)N(e,"bad indentation of a sequence entry");else if(e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndentt)&&($(e,t,b,!0,r)&&(m?d=e.result:h=e.result),m||(U(e,l,p,f,d,h,o,a),f=d=h=null),Y(e,!0,-1),s=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==s)N(e,"bad indentation of a mapping entry");else if(e.lineIndentl&&(l=e.lineIndent),j(o))p++;else{if(e.lineIndent>10),56320+(c-65536&1023)),e.position++}else N(e,"unknown escape sequence");n=i=e.position}else j(s)?(L(e,n,i,!0),B(e,Y(e,!1,t)),n=i=e.position):e.position===e.lineStart&&R(e)?N(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}N(e,"unexpected end of the stream within a double quoted scalar")}(e,p)?m=!0:!function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!I(i)&&!O(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&N(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),e.anchorMap.hasOwnProperty(n)||N(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Y(e,!0,-1),!0}(e)?function(e,t,n){var i,r,o,a,s,c,u,l,p=e.kind,f=e.result;if(I(l=e.input.charCodeAt(e.position))||O(l)||35===l||38===l||42===l||33===l||124===l||62===l||39===l||34===l||37===l||64===l||96===l)return!1;if((63===l||45===l)&&(I(i=e.input.charCodeAt(e.position+1))||n&&O(i)))return!1;for(e.kind="scalar",e.result="",r=o=e.position,a=!1;0!==l;){if(58===l){if(I(i=e.input.charCodeAt(e.position+1))||n&&O(i))break}else if(35===l){if(I(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&R(e)||n&&O(l))break;if(j(l)){if(s=e.line,c=e.lineStart,u=e.lineIndent,Y(e,!1,-1),e.lineIndent>=t){a=!0,l=e.input.charCodeAt(e.position);continue}e.position=o,e.line=s,e.lineStart=c,e.lineIndent=u;break}}a&&(L(e,r,o,!1),B(e,e.line-s),r=o=e.position,a=!1),S(l)||(o=e.position+1),l=e.input.charCodeAt(++e.position)}return L(e,r,o,!1),!!e.result||(e.kind=p,e.result=f,!1)}(e,p,x===n)&&(m=!0,null===e.tag&&(e.tag="?")):(m=!0,null===e.tag&&null===e.anchor||N(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===d&&(m=s&&P(e,f))),null!==e.tag&&"!"!==e.tag)if("?"===e.tag){for(c=0,u=e.implicitTypes.length;c tag; it should be "'+l.kind+'", not "'+e.kind+'"'),l.resolve(e.result)?(e.result=l.construct(e.result),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):N(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):N(e,"unknown tag !<"+e.tag+">");return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||m}function H(e){var t,n,i,r,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};0!==(r=e.input.charCodeAt(e.position))&&(Y(e,!0,-1),r=e.input.charCodeAt(e.position),!(0t/2-1){n=" ... ",i+=5;break}for(r="",o=this.position;ot/2-1){r=" ... ",o-=5;break}return a=this.buffer.slice(i,o),s.repeat(" ",e)+n+a+r+"\n"+s.repeat(" ",e+this.position-i+n.length)+"^"},i.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(n+=":\n"+t),n},t.exports=i},{"./common":2}],7:[function(e,t,n){"use strict";var i=e("./common"),r=e("./exception"),o=e("./type");function a(e,t,i){var r=[];return e.include.forEach(function(e){i=a(e,t,i)}),e[t].forEach(function(n){i.forEach(function(e,t){e.tag===n.tag&&e.kind===n.kind&&r.push(t)}),i.push(n)}),i.filter(function(e,t){return-1===r.indexOf(t)})}function s(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach(function(e){if(e.loadKind&&"scalar"!==e.loadKind)throw new r("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=a(this,"implicit",[]),this.compiledExplicit=a(this,"explicit",[]),this.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{}};function i(e){n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e>16&255),s.push(a>>8&255),s.push(255&a)),a=a<<6|o.indexOf(i.charAt(t));return 0==(n=r%4*6)?(s.push(a>>16&255),s.push(a>>8&255),s.push(255&a)):18==n?(s.push(a>>10&255),s.push(a>>2&255)):12==n&&s.push(a>>4&255),c?c.from?c.from(s):new c(s):s},predicate:function(e){return c&&c.isBuffer(e)},represent:function(e){var t,n,i="",r=0,o=e.length,a=u;for(t=0;t>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]),r=(r<<8)+e[t];return 0==(n=o%3)?(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]):2==n?(i+=a[r>>10&63],i+=a[r>>4&63],i+=a[r<<2&63],i+=a[64]):1==n&&(i+=a[r>>2&63],i+=a[r<<4&63],i+=a[64],i+=a[64]),i}})},{"../type":13}],15:[function(e,t,n){"use strict";var i=e("../type");t.exports=new i("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})},{"../type":13}],16:[function(e,t,n){"use strict";var i=e("../common"),r=e("../type"),o=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var a=/^[-+]?[0-9]+e/;t.exports=new r("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!o.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n,i,r;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,r=[],0<="+-".indexOf(t[0])&&(t=t.slice(1)),".inf"===t?1==n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:0<=t.indexOf(":")?(t.split(":").forEach(function(e){r.unshift(parseFloat(e,10))}),t=0,i=1,r.forEach(function(e){t+=e*i,i*=60}),n*t):n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||i.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(e))return"-0.0";return n=e.toString(10),a.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"})},{"../common":2,"../type":13}],17:[function(e,t,n){"use strict";var i=e("../common"),r=e("../type");t.exports=new r("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i,r,o=e.length,a=0,s=!1;if(!o)return!1;if("-"!==(t=e[a])&&"+"!==t||(t=e[++a]),"0"===t){if(a+1===o)return!0;if("b"===(t=e[++a])){for(a++;a +'use strict'; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var KG; +(function (KG) { + /* + + from underscorejs + + Copyright (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative + Reporters & Editors + + 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.*/ + // I adapted these functions from the amazing underscorejs library. + function isObject(obj) { + var type = typeof obj; + return type === 'function' || type === 'object' && !!obj; + } + function allKeys(obj) { + if (!isObject(obj)) + return []; + var keys = []; + for (var key in obj) + keys.push(key); + return keys; + } + KG.allKeys = allKeys; + function defaults(obj, def) { + if (def == null || obj == null) + return obj; + var keys = allKeys(def), l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (obj[key] === void 0) + obj[key] = def[key]; + } + return obj; + } + // End of underscorejs functions + function setDefaults(def, defaultValues) { + def = defaults(def, defaultValues); + return def; + } + KG.setDefaults = setDefaults; + function setProperties(def, name, props) { + def[name] = (def[name] || []).concat(props); + return def; + } + KG.setProperties = setProperties; +})(KG || (KG = {})); +/// +var KGAuthor; +(function (KGAuthor) { + function extractTypeAndDef(def) { + if (def.hasOwnProperty('type')) { + return def; + } + else { + def.type = Object.keys(def)[0]; + def.def = def[def.type]; + return def; + } + } + KGAuthor.extractTypeAndDef = extractTypeAndDef; + function parse(data, parsedData) { + data.forEach(function (obj) { + if (KGAuthor.hasOwnProperty(obj.type)) { + parsedData = new KGAuthor[obj.type](obj.def).parse(parsedData); + } + else { + console.log("Sorry, there's no ", obj.type, " object type in KGAuthor. Maybe you have a typo?"); + } + }); + return parsedData; + } + KGAuthor.parse = parse; + function getDefinitionProperty(def) { + if (typeof def == 'string') { + if (def.match(/[\*/+-]/)) { + return '(' + def + ')'; + } + else { + return def; + } + } + else { + return def; + } + } + KGAuthor.getDefinitionProperty = getDefinitionProperty; + function getPropertyAsString(def) { + var d = def; + if (typeof d == 'number') { + return d.toString(); + } + else { + return "(" + d.toString() + ")"; + } + } + KGAuthor.getPropertyAsString = getPropertyAsString; + function getParameterName(str) { + if (typeof str == 'string') { + return str.replace('params.', ''); + } + else { + return str; + } + } + KGAuthor.getParameterName = getParameterName; + function negativeDef(def) { + return (typeof def == 'number') ? (-1) * def : "(-" + getDefinitionProperty(def) + ")"; + } + KGAuthor.negativeDef = negativeDef; + function binaryFunction(def1, def2, fn) { + if (typeof def1 == 'number' && typeof def2 == 'number') { + switch (fn) { + case "+": + return def1 + def2; + case "-": + return def1 - def2; + case "/": + return def1 / def2; + case "*": + return def1 * def2; + case "^": + return Math.pow(def1, def2); + } + } + else { + return "(" + getDefinitionProperty(def1) + fn + getDefinitionProperty(def2) + ")"; + } + } + KGAuthor.binaryFunction = binaryFunction; + function addDefs(def1, def2) { + if (def1 == 0) { + return def2; + } + if (def2 == 0) { + return def1; + } + return binaryFunction(def1, def2, '+'); + } + KGAuthor.addDefs = addDefs; + function subtractDefs(def1, def2) { + if (def2 == 0) { + return def1; + } + return binaryFunction(def1, def2, '-'); + } + KGAuthor.subtractDefs = subtractDefs; + function divideDefs(def1, def2) { + if (def1 == 0) { + return 0; + } + if (def2 == 1) { + return def1; + } + return binaryFunction(def1, def2, '/'); + } + KGAuthor.divideDefs = divideDefs; + function invertDef(def) { + return binaryFunction(1, def, '/'); + } + KGAuthor.invertDef = invertDef; + function multiplyDefs(def1, def2) { + if (def1 == 0 || def2 == 0) { + return 0; + } + if (def1 == 1) { + return def2; + } + if (def2 == 1) { + return def1; + } + return binaryFunction(def1, def2, '*'); + } + KGAuthor.multiplyDefs = multiplyDefs; + function averageDefs(def1, def2, weight) { + weight = weight || 0.5; + return addDefs(multiplyDefs(weight, def1), multiplyDefs(subtractDefs(1, weight), def2)); + } + KGAuthor.averageDefs = averageDefs; + function squareDef(def) { + return binaryFunction(def, def, '*'); + } + KGAuthor.squareDef = squareDef; + function sqrtDef(def) { + return 'Math.sqrt(' + def + ')'; + } + KGAuthor.sqrtDef = sqrtDef; + function raiseDefToDef(def1, def2) { + return binaryFunction(def1, def2, '^'); + } + KGAuthor.raiseDefToDef = raiseDefToDef; + function paramName(def) { + if (typeof (def) == 'string') { + return def.replace('params.', ''); + } + else { + return def; + } + } + KGAuthor.paramName = paramName; + function curvesFromFunctions(fns, def, graph) { + return fns.map(function (fn) { + var curveDef = copyJSON(def); + if (curveDef.hasOwnProperty('min')) { + fn.min = curveDef.min; + } + if (curveDef.hasOwnProperty('max')) { + fn.max = curveDef.max; + } + if (fn.hasOwnProperty('show')) { + curveDef.show = fn.show; + } + if (fn.hasOwnProperty('parametric')) { + curveDef.parametricFunction = fn; + } + else { + curveDef.univariateFunction = fn; + } + //console.log('creating curve from def', curveDef); + return new KGAuthor.Curve(curveDef, graph); + }); + } + KGAuthor.curvesFromFunctions = curvesFromFunctions; + // allow author to set fill color either by "color" attribute or "fill" attribute + function setFillColor(def) { + if (def.open) { + def.fill = 'white'; + return KG.setDefaults(def, { + color: def.stroke, + stroke: def.color + }); + } + return KG.setDefaults(def, { + color: def.fill, + fill: def.color + }); + } + KGAuthor.setFillColor = setFillColor; + // allow author to set stroke color either by "color" attribute or "stroke" attribute + function setStrokeColor(def) { + return KG.setDefaults(def, { + color: def.stroke, + stroke: def.color + }); + } + KGAuthor.setStrokeColor = setStrokeColor; + // create a fresh copy of a JSON object + function copyJSON(def) { + return JSON.parse(JSON.stringify(def)); + } + KGAuthor.copyJSON = copyJSON; + function replaceVariable(target, search, replacement) { + return "(" + target.split(search).join(replacement) + ")"; + } + KGAuthor.replaceVariable = replaceVariable; + // allow author to specify a function using a single string rather than a function object + function parseFn(def, authorName, codeName) { + if (!def.hasOwnProperty(codeName) && def.hasOwnProperty(authorName)) { + def[codeName] = { + fn: def[authorName], + ind: (def[authorName].indexOf('(y)') > -1) ? 'y' : 'x', + min: def.min, + max: def.max, + samplePoints: def[authorName].samplePoints + }; + } + } + KGAuthor.parseFn = parseFn; + // allow author to set a fill color rather than a fill object + function parseFill(def, attr) { + var v = def[attr]; + if (typeof v == 'string') { + def[attr] = { fill: v }; + } + if (typeof v == 'boolean' && v) { + var fillColor = def.hasOwnProperty('fill') ? def.fill : def.color; + def[attr] = { fill: fillColor }; + } + } + KGAuthor.parseFill = parseFill; + // inherit properties from a parent + function inheritFromParent(props, parent, child) { + props.forEach(function (prop) { + if (parent.hasOwnProperty(prop) && !child.hasOwnProperty(prop)) { + child[prop] = parent[prop]; + } + }); + } + KGAuthor.inheritFromParent = inheritFromParent; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var AuthoringObject = /** @class */ (function () { + function AuthoringObject(def) { + this.def = def; + this.name = def.name; + this.subObjects = []; + } + AuthoringObject.prototype.parseSelf = function (parsedData) { + return parsedData; + }; + AuthoringObject.prototype.parse = function (parsedData) { + this.subObjects.forEach(function (obj) { + parsedData = obj.parse(parsedData); + }); + delete this.subObjects; + parsedData = this.parseSelf(parsedData); + return parsedData; + }; + AuthoringObject.prototype.addSecondGraph = function (graph2) { + var def = this.def; + if (def.hasOwnProperty('yScale2Name')) { + def.xScale2Name = graph2.xScale.name; + def.yScale2Name = graph2.yScale.name; + } + this.subObjects.forEach(function (obj) { + obj.addSecondGraph(graph2); + }); + }; + return AuthoringObject; + }()); + KGAuthor.AuthoringObject = AuthoringObject; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Schema = /** @class */ (function (_super) { + __extends(Schema, _super); + function Schema(def) { + var _this = this; + var palette = { + blue: 'd3.schemeCategory10[0]', + orange: 'd3.schemeCategory10[1]', + green: 'd3.schemeCategory10[2]', + red: 'd3.schemeCategory10[3]', + purple: 'd3.schemeCategory10[4]', + brown: 'd3.schemeCategory10[5]', + magenta: 'd3.schemeCategory10[6]', + grey: 'd3.schemeCategory10[7]', + gray: 'd3.schemeCategory10[7]', + olive: 'd3.schemeCategory10[8]' //#637939 + }; + for (var color in def.colors) { + var colorName = def.colors[color]; + if (palette.hasOwnProperty(colorName)) { + def.colors[color] = palette[colorName]; + } + } + def.colors = KG.setDefaults(def.colors || {}, palette); + _this = _super.call(this, def) || this; + _this.colors = def.colors; + return _this; + } + Schema.prototype.parseSelf = function (parsedData) { + var colors = this.colors; + parsedData.colors = KG.setDefaults(parsedData.colors || {}, colors); + return parsedData; + }; + return Schema; + }(KGAuthor.AuthoringObject)); + KGAuthor.Schema = Schema; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Layout = /** @class */ (function (_super) { + __extends(Layout, _super); + function Layout(def) { + var _this = _super.call(this, def) || this; + _this.aspectRatio = 2; + _this.nosvg = false; + return _this; + } + Layout.prototype.parseSelf = function (parsedData) { + parsedData.aspectRatio = this.aspectRatio; + parsedData.nosvg = this.nosvg; + return parsedData; + }; + return Layout; + }(KGAuthor.AuthoringObject)); + KGAuthor.Layout = Layout; + var SquareLayout = /** @class */ (function (_super) { + __extends(SquareLayout, _super); + // creates a square layout (aspect ratio of 1) within the main body of the text + // to make a square graph, the ratio of width to height should be 0.82 + function SquareLayout(def) { + var _this = _super.call(this, def) || this; + _this.aspectRatio = 1.22; + return _this; + } + return SquareLayout; + }(Layout)); + KGAuthor.SquareLayout = SquareLayout; + var WideRectangleLayout = /** @class */ (function (_super) { + __extends(WideRectangleLayout, _super); + // creates a rectangle, twice as wide as it is high, within the main body of the text + // to make a square graph, the ratio of width to height should be 0.41 + function WideRectangleLayout(def) { + var _this = _super.call(this, def) || this; + _this.aspectRatio = 2.44; + return _this; + } + return WideRectangleLayout; + }(Layout)); + KGAuthor.WideRectangleLayout = WideRectangleLayout; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var HTMLLayout = /** @class */ (function (_super) { + __extends(HTMLLayout, _super); + function HTMLLayout(def) { + var _this = _super.call(this, def) || this; + var l = _this; + l.nosvg = true; + var divDef = { "html": def['html'] }; + l.subObjects.push(new KGAuthor.Div(divDef)); + return _this; + } + return HTMLLayout; + }(KGAuthor.Layout)); + KGAuthor.HTMLLayout = HTMLLayout; + var HTMLPlusSidebarLayout = /** @class */ (function (_super) { + __extends(HTMLPlusSidebarLayout, _super); + function HTMLPlusSidebarLayout(def) { + var _this = _super.call(this, def) || this; + var l = _this; + l.nosvg = true; + var sidebarDef = def['sidebar']; + l.subObjects.push(new KGAuthor.Sidebar(sidebarDef)); + return _this; + } + return HTMLPlusSidebarLayout; + }(HTMLLayout)); + KGAuthor.HTMLPlusSidebarLayout = HTMLPlusSidebarLayout; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var OneGraph = /** @class */ (function (_super) { + __extends(OneGraph, _super); + function OneGraph(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var graphDef = def['graph']; + graphDef.position = { + "x": 0.15, + "y": 0.025, + "width": 0.74, + "height": 0.9 + }; + l.subObjects.push(new KGAuthor.Graph(graphDef)); + return _this; + } + return OneGraph; + }(KGAuthor.SquareLayout)); + KGAuthor.OneGraph = OneGraph; + var OneWideGraph = /** @class */ (function (_super) { + __extends(OneWideGraph, _super); + function OneWideGraph(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var graphDef = def['graph']; + graphDef.position = { + "x": 0.15, + "y": 0.025, + "width": 0.74, + "height": 0.9 + }; + l.subObjects.push(new KGAuthor.Graph(graphDef)); + return _this; + } + return OneWideGraph; + }(KGAuthor.WideRectangleLayout)); + KGAuthor.OneWideGraph = OneWideGraph; + var OneGraphPlusSidebar = /** @class */ (function (_super) { + __extends(OneGraphPlusSidebar, _super); + function OneGraphPlusSidebar(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var graphDef = def['graph'], sidebarDef = def['sidebar']; + graphDef.position = { + "x": 0.15, + "y": 0.025, + "width": 0.738, + "height": 0.9 + }; + l.subObjects.push(new KGAuthor.Graph(graphDef)); + l.subObjects.push(new KGAuthor.Sidebar(sidebarDef)); + return _this; + } + return OneGraphPlusSidebar; + }(KGAuthor.SquareLayout)); + KGAuthor.OneGraphPlusSidebar = OneGraphPlusSidebar; + var OneWideGraphPlusSidebar = /** @class */ (function (_super) { + __extends(OneWideGraphPlusSidebar, _super); + function OneWideGraphPlusSidebar(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var graphDef = def['graph'], sidebarDef = def['sidebar']; + graphDef.position = { + "x": 0.15, + "y": 0.025, + "width": 0.738, + "height": 0.9 + }; + l.subObjects.push(new KGAuthor.Graph(graphDef)); + l.subObjects.push(new KGAuthor.Sidebar(sidebarDef)); + return _this; + } + return OneWideGraphPlusSidebar; + }(KGAuthor.WideRectangleLayout)); + KGAuthor.OneWideGraphPlusSidebar = OneWideGraphPlusSidebar; + var OneGraphPlusSidebarRoom200 = /** @class */ (function (_super) { + __extends(OneGraphPlusSidebarRoom200, _super); + function OneGraphPlusSidebarRoom200(def) { + var _this = _super.call(this, def) || this; + _this.aspectRatio = 2; + return _this; + } + return OneGraphPlusSidebarRoom200; + }(OneGraphPlusSidebar)); + KGAuthor.OneGraphPlusSidebarRoom200 = OneGraphPlusSidebarRoom200; + var GeoGebraPlusSidebar = /** @class */ (function (_super) { + __extends(GeoGebraPlusSidebar, _super); + function GeoGebraPlusSidebar(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var ggbAppletDef = def['ggbApplet'], sidebarDef = def['sidebar']; + ggbAppletDef.position = { + "x": 0.15, + "y": 0.025, + "width": 0.738, + "height": 0.9 + }; + l.subObjects.push(new KGAuthor.GeoGebraContainer(ggbAppletDef)); + l.subObjects.push(new KGAuthor.Sidebar(sidebarDef)); + return _this; + } + return GeoGebraPlusSidebar; + }(KGAuthor.SquareLayout)); + KGAuthor.GeoGebraPlusSidebar = GeoGebraPlusSidebar; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var TwoHorizontalGraphs = /** @class */ (function (_super) { + __extends(TwoHorizontalGraphs, _super); + function TwoHorizontalGraphs(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var leftGraphDef = def['leftGraph'], rightGraphDef = def['rightGraph']; + var leftX = 0.15, rightX = 0.65, topY = 0.1, bottomY = 0.9, width = 0.3, controlHeight = 0.25; + var includeControls = false; + console.log('layout: ', l); + if (def.hasOwnProperty('leftControls')) { + l.subObjects.push(new KGAuthor.DivContainer({ + position: { + x: leftX, + y: bottomY, + width: width, + height: controlHeight + }, + children: [ + { + type: "Controls", + def: def['leftControls'] + } + ] + })); + includeControls = true; + } + if (def.hasOwnProperty('rightControls')) { + l.subObjects.push(new KGAuthor.DivContainer({ + position: { + x: rightX, + y: bottomY, + width: width, + height: controlHeight + }, + children: [ + { + type: "Controls", + def: def['rightControls'] + } + ] + })); + includeControls = true; + } + var graphHeight = includeControls ? 0.5 : 0.9; + _this.aspectRatio = includeControls ? 2 : 4; + leftGraphDef.position = { + x: leftX, + y: topY, + width: width, + height: graphHeight + }; + l.subObjects.push(new KGAuthor.Graph(leftGraphDef)); + rightGraphDef.position = { + "x": rightX, + "y": topY, + "width": width, + "height": graphHeight + }; + l.subObjects.push(new KGAuthor.Graph(rightGraphDef)); + return _this; + } + return TwoHorizontalGraphs; + }(KGAuthor.Layout)); + KGAuthor.TwoHorizontalGraphs = TwoHorizontalGraphs; + var TwoHorizontalGraphsPlusSidebar = /** @class */ (function (_super) { + __extends(TwoHorizontalGraphsPlusSidebar, _super); + function TwoHorizontalGraphsPlusSidebar(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var leftGraphDef = def['leftGraph'], rightGraphDef = def['rightGraph'], sidebarDef = def['sidebar']; + var leftX = 0.1, rightX = 0.6, topY = 0.025, bottomY = 1.2, width = 0.369, graphHeight = 0.9, controlHeight = 0.3; + leftGraphDef.position = { + "x": leftX, + "y": topY, + "width": width, + "height": graphHeight + }; + rightGraphDef.position = { + "x": rightX, + "y": topY, + "width": width, + "height": graphHeight + }; + var leftGraph = new KGAuthor.Graph(leftGraphDef), rightGraph = new KGAuthor.Graph(rightGraphDef), sidebar = new KGAuthor.Sidebar(sidebarDef); + l.subObjects.push(leftGraph); + l.subObjects.push(rightGraph); + l.subObjects.push(sidebar); + if (def.hasOwnProperty('leftControls')) { + var leftControlsContainer = { + position: { + x: leftX, + y: bottomY, + width: width, + height: controlHeight + }, + children: [ + { + type: "Controls", + def: def['leftControls'] + } + ] + }; + l.subObjects.push(new KGAuthor.DivContainer(leftControlsContainer)); + } + if (def.hasOwnProperty('rightControls')) { + var rightControlsContainer = { + position: { + x: rightX, + y: bottomY, + width: width, + height: controlHeight + }, + children: [ + { + type: "Controls", + def: def['rightControls'] + } + ] + }; + l.subObjects.push(new KGAuthor.DivContainer(rightControlsContainer)); + } + return _this; + } + return TwoHorizontalGraphsPlusSidebar; + }(KGAuthor.WideRectangleLayout)); + KGAuthor.TwoHorizontalGraphsPlusSidebar = TwoHorizontalGraphsPlusSidebar; + var MathboxPlusGraph = /** @class */ (function (_super) { + __extends(MathboxPlusGraph, _super); + function MathboxPlusGraph(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var mathboxDef = def['mathbox'], graphDef = def['graph']; + mathboxDef.position = { + "x": 0.05, + "y": 0.025, + "width": 0.45, + "height": 0.9 + }; + graphDef.position = { + "x": 0.6, + "y": 0.2, + "width": 0.3, + "height": 0.6 + }; + l.subObjects.push(new KGAuthor.Mathbox(mathboxDef)); + l.subObjects.push(new KGAuthor.Graph(graphDef)); + return _this; + } + return MathboxPlusGraph; + }(KGAuthor.Layout)); + KGAuthor.MathboxPlusGraph = MathboxPlusGraph; + var GameMatrixPlusGraph = /** @class */ (function (_super) { + __extends(GameMatrixPlusGraph, _super); + function GameMatrixPlusGraph(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var graphDef = def['graph']; + var gameDivDef = { + position: { + x: 0.05, + y: 0.1, + width: 0.35, + height: 0.7 + }, + children: [ + { + type: "GameMatrix", + def: def.game + } + ] + }; + graphDef.position = { + x: 0.6, + y: 0.1, + width: 0.35, + height: 0.7 + }; + l.subObjects.push(new KGAuthor.DivContainer(gameDivDef)); + l.subObjects.push(new KGAuthor.Graph(graphDef)); + return _this; + } + return GameMatrixPlusGraph; + }(KGAuthor.Layout)); + KGAuthor.GameMatrixPlusGraph = GameMatrixPlusGraph; + var GeoGebraPlusGraph = /** @class */ (function (_super) { + __extends(GeoGebraPlusGraph, _super); + function GeoGebraPlusGraph(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var ggbAppletDef = def['ggbApplet'], graphDef = def['graph']; + ggbAppletDef.position = { + "x": 0.05, + "y": 0.025, + "width": 0.45, + "height": 0.9 + }; + graphDef.position = { + "x": 0.6, + "y": 0.2, + "width": 0.3, + "height": 0.6 + }; + l.subObjects.push(new KGAuthor.GeoGebraContainer(ggbAppletDef)); + l.subObjects.push(new KGAuthor.Graph(graphDef)); + return _this; + } + return GeoGebraPlusGraph; + }(KGAuthor.Layout)); + KGAuthor.GeoGebraPlusGraph = GeoGebraPlusGraph; + var GeoGebraPlusGraphPlusSidebar = /** @class */ (function (_super) { + __extends(GeoGebraPlusGraphPlusSidebar, _super); + function GeoGebraPlusGraphPlusSidebar(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var ggbAppletDef = def['ggbApplet'], graphDef = def['graph'], sidebarDef = def['sidebar']; + ggbAppletDef.position = { + "x": 0.1, + "y": 0.025, + "width": 0.369, + "height": 0.9 + }; + graphDef.position = { + "x": 0.6, + "y": 0.025, + "width": 0.369, + "height": 0.9 + }; + l.subObjects.push(new KGAuthor.GeoGebraContainer(ggbAppletDef)); + l.subObjects.push(new KGAuthor.Graph(graphDef)); + l.subObjects.push(new KGAuthor.Sidebar(sidebarDef)); + return _this; + } + return GeoGebraPlusGraphPlusSidebar; + }(KGAuthor.WideRectangleLayout)); + KGAuthor.GeoGebraPlusGraphPlusSidebar = GeoGebraPlusGraphPlusSidebar; + var MathboxPlusGraphPlusSidebar = /** @class */ (function (_super) { + __extends(MathboxPlusGraphPlusSidebar, _super); + function MathboxPlusGraphPlusSidebar(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var mathboxDef = def['mathbox'], graphDef = def['graph'], sidebarDef = def['sidebar']; + mathboxDef.position = { + "x": 0.025, + "y": 0.025, + "width": 0.444, + "height": 0.95 + }; + graphDef.position = { + "x": 0.6, + "y": 0.025, + "width": 0.369, + "height": 0.9 + }; + l.subObjects.push(new KGAuthor.MathboxContainer(mathboxDef)); + l.subObjects.push(new KGAuthor.Graph(graphDef)); + l.subObjects.push(new KGAuthor.Sidebar(sidebarDef)); + return _this; + } + return MathboxPlusGraphPlusSidebar; + }(KGAuthor.WideRectangleLayout)); + KGAuthor.MathboxPlusGraphPlusSidebar = MathboxPlusGraphPlusSidebar; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var ThreeHorizontalGraphs = /** @class */ (function (_super) { + __extends(ThreeHorizontalGraphs, _super); + function ThreeHorizontalGraphs(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var leftGraphDef = def['leftGraph'], middleGraphDef = def['middleGraph'], rightGraphDef = def['rightGraph']; + var leftX = 0.05, middleX = 0.35, rightX = 0.65, topY = 0.025, bottomY = 0.65, width = 0.25, controlHeight = 0.3; + var includeControls = false; + console.log('layout: ', l); + if (def.hasOwnProperty('leftControls')) { + l.subObjects.push(new KGAuthor.DivContainer({ + position: { + x: leftX, + y: bottomY, + width: width, + height: controlHeight + }, + children: [ + { + type: "Controls", + def: def['leftControls'] + } + ] + })); + includeControls = true; + } + if (def.hasOwnProperty('middleControls')) { + l.subObjects.push(new KGAuthor.DivContainer({ + position: { + x: middleX, + y: bottomY, + width: width, + height: controlHeight + }, + children: [ + { + type: "Controls", + def: def['middleControls'] + } + ] + })); + includeControls = true; + } + if (def.hasOwnProperty('rightControls')) { + l.subObjects.push(new KGAuthor.DivContainer({ + position: { + x: rightX, + y: bottomY, + width: width, + height: controlHeight + }, + children: [ + { + type: "Controls", + def: def['rightControls'] + } + ] + })); + includeControls = true; + } + var graphHeight = includeControls ? 0.5 : 0.9; + _this.aspectRatio = includeControls ? 2 : 4; + leftGraphDef.position = { + x: leftX, + y: topY, + width: width, + height: graphHeight + }; + l.subObjects.push(new KGAuthor.Graph(leftGraphDef)); + middleGraphDef.position = { + "x": middleX, + "y": topY, + "width": width, + "height": graphHeight + }; + l.subObjects.push(new KGAuthor.Graph(middleGraphDef)); + rightGraphDef.position = { + "x": rightX, + "y": topY, + "width": width, + "height": graphHeight + }; + l.subObjects.push(new KGAuthor.Graph(rightGraphDef)); + return _this; + } + return ThreeHorizontalGraphs; + }(KGAuthor.Layout)); + KGAuthor.ThreeHorizontalGraphs = ThreeHorizontalGraphs; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var TwoVerticalGraphs = /** @class */ (function (_super) { + __extends(TwoVerticalGraphs, _super); + function TwoVerticalGraphs(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var topGraphDef = def['topGraph'], bottomGraphDef = def['bottomGraph']; + topGraphDef.position = { + "x": 0.15, + "y": 0.025, + "width": 0.8, + "height": 0.4 + }; + bottomGraphDef.position = { + "x": 0.15, + "y": 0.525, + "width": 0.8, + "height": 0.4 + }; + var topGraph = new KGAuthor.Graph(topGraphDef), bottomGraph = new KGAuthor.Graph(bottomGraphDef); + topGraph.subObjects.forEach(function (obj) { obj.addSecondGraph(bottomGraph); }); + bottomGraph.subObjects.forEach(function (obj) { obj.addSecondGraph(topGraph); }); + l.subObjects.push(topGraph); + l.subObjects.push(bottomGraph); + return _this; + } + return TwoVerticalGraphs; + }(KGAuthor.SquareLayout)); + KGAuthor.TwoVerticalGraphs = TwoVerticalGraphs; + var TwoVerticalGraphsPlusSidebar = /** @class */ (function (_super) { + __extends(TwoVerticalGraphsPlusSidebar, _super); + function TwoVerticalGraphsPlusSidebar(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var topGraphDef = def['topGraph'], bottomGraphDef = def['bottomGraph'], sidebarDef = def['sidebar']; + topGraphDef.position = { + "x": 0.15, + "y": 0.025, + "width": 0.738, + "height": 0.4 + }; + bottomGraphDef.position = { + "x": 0.15, + "y": 0.525, + "width": 0.738, + "height": 0.4 + }; + var topGraph = new KGAuthor.Graph(topGraphDef), bottomGraph = new KGAuthor.Graph(bottomGraphDef), sidebar = new KGAuthor.Sidebar(sidebarDef); + topGraph.subObjects.forEach(function (obj) { obj.addSecondGraph(bottomGraph); }); + bottomGraph.subObjects.forEach(function (obj) { obj.addSecondGraph(topGraph); }); + l.subObjects.push(topGraph); + l.subObjects.push(bottomGraph); + l.subObjects.push(sidebar); + return _this; + } + return TwoVerticalGraphsPlusSidebar; + }(KGAuthor.SquareLayout)); + KGAuthor.TwoVerticalGraphsPlusSidebar = TwoVerticalGraphsPlusSidebar; + var TwoVerticalGraphsRoom200 = /** @class */ (function (_super) { + __extends(TwoVerticalGraphsRoom200, _super); + function TwoVerticalGraphsRoom200(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var topGraphDef = def['topGraph'], bottomGraphDef = def['bottomGraph']; + topGraphDef.position = { + "x": 0.1, + "y": 0, + "width": 0.85, + "height": 0.4 + }; + bottomGraphDef.position = { + "x": 0.1, + "y": 0.62, + "width": 0.85, + "height": 0.38 + }; + var topGraph = new KGAuthor.Graph(topGraphDef), bottomGraph = new KGAuthor.Graph(bottomGraphDef); + topGraph.subObjects.forEach(function (obj) { obj.addSecondGraph(bottomGraph); }); + bottomGraph.subObjects.forEach(function (obj) { obj.addSecondGraph(topGraph); }); + l.subObjects.push(topGraph); + l.subObjects.push(bottomGraph); + l.aspectRatio = 1.3; + return _this; + } + return TwoVerticalGraphsRoom200; + }(KGAuthor.Layout)); + KGAuthor.TwoVerticalGraphsRoom200 = TwoVerticalGraphsRoom200; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var SquarePlusTwoVerticalGraphs = /** @class */ (function (_super) { + __extends(SquarePlusTwoVerticalGraphs, _super); + function SquarePlusTwoVerticalGraphs(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var bigGraphDef = def['bigGraph'], topGraphDef = def['topGraph'], bottomGraphDef = def['bottomGraph']; + bigGraphDef.position = { + "x": 0.05, + "y": 0.025, + "width": 0.5, + "height": 0.9 + }; + topGraphDef.position = { + "x": 0.6, + "y": 0.025, + "width": 0.35, + "height": 0.4 + }; + bottomGraphDef.position = { + "x": 0.6, + "y": 0.525, + "width": 0.35, + "height": 0.4 + }; + l.subObjects.push(new KGAuthor.Graph(bigGraphDef)); + l.subObjects.push(new KGAuthor.Graph(topGraphDef)); + l.subObjects.push(new KGAuthor.Graph(bottomGraphDef)); + return _this; + } + return SquarePlusTwoVerticalGraphs; + }(KGAuthor.Layout)); + KGAuthor.SquarePlusTwoVerticalGraphs = SquarePlusTwoVerticalGraphs; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var FourGraphs = /** @class */ (function (_super) { + __extends(FourGraphs, _super); + function FourGraphs(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var topLeftGraphDef = def['topLeftGraph'], bottomLeftGraphDef = def['bottomLeftGraph'], topRightGraphDef = def['topRightGraph'], bottomRightGraphDef = def['bottomRightGraph']; + var leftX = 0.05, rightX = 0.55, topY = 0.025, bottomY = 0.525; + topLeftGraphDef.position = { + "x": leftX, + "y": topY, + "width": 0.4, + "height": 0.4 + }; + bottomLeftGraphDef.position = { + "x": leftX, + "y": bottomY, + "width": 0.4, + "height": 0.4 + }; + topRightGraphDef.position = { + "x": rightX, + "y": topY, + "width": 0.4, + "height": 0.4 + }; + bottomRightGraphDef.position = { + "x": rightX, + "y": bottomY, + "width": 0.4, + "height": 0.4 + }; + l.subObjects.push(new KGAuthor.Graph(topLeftGraphDef)); + l.subObjects.push(new KGAuthor.Graph(bottomLeftGraphDef)); + l.subObjects.push(new KGAuthor.Graph(topRightGraphDef)); + l.subObjects.push(new KGAuthor.Graph(bottomRightGraphDef)); + return _this; + } + return FourGraphs; + }(KGAuthor.Layout)); + KGAuthor.FourGraphs = FourGraphs; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var GameMatrixLayout = /** @class */ (function (_super) { + __extends(GameMatrixLayout, _super); + function GameMatrixLayout(def) { + var _this = _super.call(this, def) || this; + var l = _this; + l.nosvg = true; + l.subObjects.push(new KGAuthor.GameMatrix(def.gameMatrix)); + return _this; + } + return GameMatrixLayout; + }(KGAuthor.Layout)); + KGAuthor.GameMatrixLayout = GameMatrixLayout; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Scale = /** @class */ (function (_super) { + __extends(Scale, _super); + function Scale(def) { + var _this = this; + KG.setDefaults(def, { + intercept: 0 + }); + _this = _super.call(this, def) || this; + _this.min = def.domainMin; + _this.max = def.domainMax; + _this.intercept = def.intercept; + return _this; + } + Scale.prototype.parseSelf = function (parsedData) { + parsedData.scales.push(this.def); + return parsedData; + }; + return Scale; + }(KGAuthor.AuthoringObject)); + KGAuthor.Scale = Scale; + var PositionedObject = /** @class */ (function (_super) { + __extends(PositionedObject, _super); + function PositionedObject(def) { + var _this = this; + KG.setDefaults(def, { xAxis: {}, yAxis: {} }); + KG.setDefaults(def.xAxis, { min: 0, max: 10, title: '', orient: 'bottom' }); + KG.setDefaults(def.yAxis, { min: 0, max: 10, title: '', orient: 'left' }); + _this = _super.call(this, def) || this; + var po = _this, xMin = def.xAxis.min, xMax = def.xAxis.max, xLog = def.xAxis.log, yMin = def.yAxis.min, yMax = def.yAxis.max, yLog = def.yAxis.log, leftEdge = def.position.x, rightEdge = KGAuthor.addDefs(def.position.x, def.position.width), bottomEdge = KGAuthor.addDefs(def.position.y, def.position.height), topEdge = def.position.y; + po.xScale = new Scale({ + "name": KG.randomString(10), + "axis": "x", + "domainMin": xMin, + "domainMax": xMax, + "rangeMin": leftEdge, + "rangeMax": rightEdge, + "log": xLog + }); + po.yScale = new Scale({ + "name": KG.randomString(10), + "axis": "y", + "domainMin": yMin, + "domainMax": yMax, + "rangeMin": bottomEdge, + "rangeMax": topEdge, + "log": yLog + }); + po.subObjects = [po.xScale, po.yScale]; + return _this; + } + return PositionedObject; + }(KGAuthor.AuthoringObject)); + KGAuthor.PositionedObject = PositionedObject; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Graph = /** @class */ (function (_super) { + __extends(Graph, _super); + function Graph(def) { + var _this = this; + def = KG.setDefaults(def, { objects: [] }); + _this = _super.call(this, def) || this; + var g = _this; + //axes need to update when the other one's domain changes + def.xAxis.otherMin = def.yAxis.min; + def.xAxis.otherMax = def.yAxis.max; + def.yAxis.otherMin = def.xAxis.min; + def.yAxis.otherMax = def.xAxis.max; + g.clipPath = new KGAuthor.ClipPath({ + "name": KG.randomString(10), + "paths": [new KGAuthor.Rectangle({ + x1: def.xAxis.min, + x2: def.xAxis.max, + y1: def.yAxis.min, + y2: def.yAxis.max, + inDef: true + }, g)] + }, g); + g.subObjects.push(g.clipPath); + g.def.objects.unshift({ + type: 'Axis', + def: g.def.xAxis + }); + g.def.objects.unshift({ + type: 'Axis', + def: g.def.yAxis + }); + g.def.objects.forEach(function (obj) { + obj = KGAuthor.extractTypeAndDef(obj); + g.subObjects.push(new KGAuthor[obj.type](obj.def, g)); + }); + console.log(g); + return _this; + } + Graph.prototype.getMarkerName = function (lookup) { + var g = this; + var name = '', found = false; + // look to see if there is already a marker of that name and type + g.subObjects.forEach(function (obj) { + if (obj.hasOwnProperty('color') && obj['color'] == lookup.color && obj.hasOwnProperty('markerType') && obj['markerType'] == lookup.markerType) { + name = obj.name; + found = true; + } + }); + // if there is, return its name + if (found) { + return name; + } + // otherwise create a new marker, add to the graph's subobjects, and return the new marker's name + else { + var newMarker = new KGAuthor[lookup.markerType]({ color: lookup.color }); + g.subObjects.push(newMarker); + return newMarker.name; + } + }; + Graph.prototype.getEndArrowName = function (color) { + return this.getMarkerName({ + markerType: 'EndArrow', + color: color + }); + }; + Graph.prototype.getStartArrowName = function (color) { + return this.getMarkerName({ + markerType: 'StartArrow', + color: color + }); + }; + return Graph; + }(KGAuthor.PositionedObject)); + KGAuthor.Graph = Graph; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var GeoGebraContainer = /** @class */ (function (_super) { + __extends(GeoGebraContainer, _super); + function GeoGebraContainer(def) { + var _this = this; + def.xAxis = { min: 0, max: 1 }; + def.yAxis = { min: 0, max: 1 }; + _this = _super.call(this, def) || this; + var ggb = _this; + def.xScaleName = ggb.xScale.name; + def.yScaleName = ggb.yScale.name; + ggb.subObjects.push(new KGAuthor.GeoGebraApplet(def)); + return _this; + } + return GeoGebraContainer; + }(KGAuthor.PositionedObject)); + KGAuthor.GeoGebraContainer = GeoGebraContainer; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var MathboxContainer = /** @class */ (function (_super) { + __extends(MathboxContainer, _super); + function MathboxContainer(def) { + var _this = this; + // the container, as a div, must have an x and y axis of its own. + // so we must first push down the author's specified x, y, and z axes down to be objects + def.objects.push({ + "type": "MathboxXAxis", + "def": def.xAxis + }); + def.objects.push({ + "type": "MathboxYAxis", + "def": def.yAxis + }); + def.objects.push({ + "type": "MathboxZAxis", + "def": def.zAxis + }); + delete def.zAxis; + def.xAxis = { min: 0, max: 1 }; + def.yAxis = { min: 0, max: 1 }; + _this = _super.call(this, def) || this; + var mb = _this; + def.xScaleName = mb.xScale.name; + def.yScaleName = mb.yScale.name; + mb.subObjects.push(new KGAuthor.Mathbox(def)); + return _this; + } + return MathboxContainer; + }(KGAuthor.PositionedObject)); + KGAuthor.MathboxContainer = MathboxContainer; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var DivContainer = /** @class */ (function (_super) { + __extends(DivContainer, _super); + function DivContainer(def) { + var _this = this; + def.xAxis = { min: 0, max: 1 }; + def.yAxis = { min: 0, max: 1 }; + _this = _super.call(this, def) || this; + var dc = _this; + dc.subObjects.push(new KGAuthor.PositionedDiv(def, dc)); + return _this; + } + return DivContainer; + }(KGAuthor.PositionedObject)); + KGAuthor.DivContainer = DivContainer; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var GraphObjectGenerator = /** @class */ (function (_super) { + __extends(GraphObjectGenerator, _super); + function GraphObjectGenerator(def, graph) { + var _this = _super.call(this, def) || this; + if (graph) { + _this.def.xScaleName = graph.xScale.name; + _this.def.yScaleName = graph.yScale.name; + if (!def.inDef) { + _this.def.clipPathName = def.clipPathName || graph.clipPath.name; + } + } + _this.subObjects = []; + return _this; + } + GraphObjectGenerator.prototype.extractCoordinates = function (coordinatesKey, xKey, yKey) { + coordinatesKey = coordinatesKey || 'coordinates'; + xKey = xKey || 'x'; + yKey = yKey || 'y'; + var obj = this, def = this.def; + if (def.hasOwnProperty(coordinatesKey) && def[coordinatesKey] != undefined) { + def[xKey] = def[coordinatesKey][0].toString(); + def[yKey] = def[coordinatesKey][1].toString(); + delete def[coordinatesKey]; + } + obj[xKey] = def[xKey].toString(); + obj[yKey] = def[yKey].toString(); + }; + return GraphObjectGenerator; + }(KGAuthor.AuthoringObject)); + KGAuthor.GraphObjectGenerator = GraphObjectGenerator; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var DefObject = /** @class */ (function (_super) { + __extends(DefObject, _super); + function DefObject(def, graph) { + var _this = this; + def.inDef = true; + _this = _super.call(this, def, graph) || this; + return _this; + } + DefObject.prototype.parseSelf = function (parsedData) { + delete this.def.clipPathName; + parsedData.clipPaths.push(this.def); + return parsedData; + }; + return DefObject; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.DefObject = DefObject; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var ClipPath = /** @class */ (function (_super) { + __extends(ClipPath, _super); + function ClipPath() { + return _super !== null && _super.apply(this, arguments) || this; + } + ClipPath.prototype.parseSelf = function (parsedData) { + delete this.def.clipPathName; + parsedData.clipPaths.push(this.def); + return parsedData; + }; + return ClipPath; + }(KGAuthor.DefObject)); + KGAuthor.ClipPath = ClipPath; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Marker = /** @class */ (function (_super) { + __extends(Marker, _super); + function Marker(def, graph) { + var _this = _super.call(this, def, graph) || this; + _this.maskPath = def.maskPath; + return _this; + } + Marker.prototype.parseSelf = function (parsedData) { + parsedData.markers.push(this.def); + return parsedData; + }; + return Marker; + }(KGAuthor.DefObject)); + KGAuthor.Marker = Marker; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var ArrowDef = /** @class */ (function (_super) { + __extends(ArrowDef, _super); + function ArrowDef(def, graph) { + var _this = this; + def.name = KG.randomString(10); + _this = _super.call(this, def, graph) || this; + _this.color = def.color; + _this.arrowPath = def.arrowPath; + return _this; + } + return ArrowDef; + }(KGAuthor.Marker)); + KGAuthor.ArrowDef = ArrowDef; + var StartArrow = /** @class */ (function (_super) { + __extends(StartArrow, _super); + function StartArrow(def, graph) { + var _this = this; + def.refX = 2; + def.maskPath = "M10,1 L10,12 L0,7 L0,5 L10,1"; + def.arrowPath = "M11,2 L11,11 L2,6 L11,2"; + _this = _super.call(this, def, graph) || this; + _this.markerType = 'StartArrow'; + return _this; + } + return StartArrow; + }(ArrowDef)); + KGAuthor.StartArrow = StartArrow; + var EndArrow = /** @class */ (function (_super) { + __extends(EndArrow, _super); + function EndArrow(def, graph) { + var _this = this; + def.refX = 11; + def.maskPath = "M3,1 L3,12 L12,7 L12,5 L3,1"; + def.arrowPath = "M2,2 L2,11 L10,6 L2,2"; + _this = _super.call(this, def, graph) || this; + _this.markerType = 'EndArrow'; + return _this; + } + return EndArrow; + }(ArrowDef)); + KGAuthor.EndArrow = EndArrow; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var GraphObject = /** @class */ (function (_super) { + __extends(GraphObject, _super); + function GraphObject(def, graph) { + var _this = this; + if (def.hasOwnProperty('clipPaths')) { + def.clipPathName = KG.randomString(10); + } + KG.setDefaults(def, { + name: KG.randomString(10) + }); + _this = _super.call(this, def, graph) || this; + var g = _this; + if (def.hasOwnProperty('color')) { + g.color = def.color; + } + if (def.hasOwnProperty("clipPaths")) { + var clipPathObjects = def.clipPaths.map(function (shape) { + var shapeType = Object.keys(shape)[0]; + var shapeDef = shape[shapeType]; + shapeDef.inDef = true; + return new KGAuthor[shapeType](shapeDef, graph); + }); + g.subObjects.push(new KGAuthor.ClipPath({ name: def.clipPathName, paths: clipPathObjects }, graph)); + } + return _this; + } + GraphObject.prototype.parseSelf = function (parsedData) { + parsedData.layers[this.layer].push(this); + return parsedData; + }; + return GraphObject; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.GraphObject = GraphObject; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Axis = /** @class */ (function (_super) { + __extends(Axis, _super); + function Axis(def, graph) { + var _this = _super.call(this, def, graph) || this; + var a = _this; + a.type = 'Axis'; + a.layer = 2; + if (def.hasOwnProperty('title') && ("" != def.title)) { + if (def.orient == 'bottom') { + a.subObjects.push(new KGAuthor.Label({ + text: "\\text{" + def.title + "}", + x: KGAuthor.averageDefs(graph.xScale.min, graph.xScale.max), + y: graph.yScale.min, + yPixelOffset: -40 + }, graph)); + } + else if (def.orient == 'left') { + a.subObjects.push(new KGAuthor.Label({ + text: "\\text{" + def.title + "}", + x: graph.xScale.min, + y: KGAuthor.averageDefs(graph.yScale.min, graph.yScale.max), + xPixelOffset: -50, + rotate: 90 + }, graph)); + } + else if (def.orient == 'top') { + a.subObjects.push(new KGAuthor.Label({ + text: "\\text{" + def.title + "}", + x: KGAuthor.averageDefs(graph.xScale.min, graph.xScale.max), + y: graph.yScale.min, + yPixelOffset: 40 + }, graph)); + } + else { + a.subObjects.push(new KGAuthor.Label({ + text: "\\text{" + def.title + "}", + x: graph.xScale.max, + y: KGAuthor.averageDefs(graph.yScale.min, graph.yScale.max), + xPixelOffset: 50, + rotate: 270 + }, graph)); + } + } + return _this; + } + return Axis; + }(KGAuthor.GraphObject)); + KGAuthor.Axis = Axis; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Grid = /** @class */ (function (_super) { + __extends(Grid, _super); + function Grid(def, graph) { + var _this = this; + def = def || {}; + _this = _super.call(this, def, graph) || this; + KG.setDefaults(def, { + strokeWidth: 1, + stroke: 'lightgrey', + lineStyle: 'dotted', + layer: 0, + xStep: 1, + yStep: 1 + }); + var g = _this; + g.subObjects = []; + for (var i = 0; i < 10; i++) { + var x = KGAuthor.multiplyDefs(i, def.xStep), y = KGAuthor.multiplyDefs(i, def.yStep); + var gxDef = KGAuthor.copyJSON(def), gyDef = KGAuthor.copyJSON(def); + gxDef.a = [x, graph.yScale.min]; + gxDef.b = [x, graph.yScale.max]; + gyDef.a = [graph.xScale.min, y]; + gyDef.b = [graph.xScale.max, y]; + g.subObjects.push(new KGAuthor.Segment(gxDef, graph)); + g.subObjects.push(new KGAuthor.Segment(gyDef, graph)); + } + return _this; + } + return Grid; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.Grid = Grid; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Curve = /** @class */ (function (_super) { + __extends(Curve, _super); + function Curve(def, graph) { + var _this = this; + def = KGAuthor.setStrokeColor(def); + KGAuthor.parseFn(def, 'fn', 'univariateFunction'); + _this = _super.call(this, def, graph) || this; + var c = _this; + c.type = 'Curve'; + c.layer = def.layer || 1; + c.pts = def.pts || []; + if (def.hasOwnProperty('areaBelow')) { + KG.setDefaults(def.areaBelow, { + color: def.color + }); + KGAuthor.parseFill(def, 'areaBelow'); + KG.setDefaults(def.areaBelow, def.univariateFunction); + KGAuthor.parseFn(def.areaBelow, 'fn', 'univariateFunction1'); + c.subObjects.push(new KGAuthor.Area(def.areaBelow, graph)); + } + if (def.hasOwnProperty('areaAbove')) { + KG.setDefaults(def.areaBelow, { + color: def.color + }); + KGAuthor.parseFill(def, 'areaAbove'); + KG.setDefaults(def.areaAbove, def.univariateFunction); + KGAuthor.parseFn(def.areaBelow, 'fn', 'univariateFunction1'); + def.areaAbove.above = true; + c.subObjects.push(new KGAuthor.Area(def.areaAbove, graph)); + } + if (def.hasOwnProperty('label')) { + var labelDef = KGAuthor.copyJSON(def); + delete labelDef.label; + labelDef = KG.setDefaults(labelDef, def.label); + labelDef = KG.setDefaults(labelDef, { + fontSize: 12, + color: def.color + }); + if (def.hasOwnProperty('univariateFunction')) { + if (labelDef.hasOwnProperty('x') && def.univariateFunction.ind != 'y') { + labelDef.coordinates = [labelDef.x, c.yOfX(labelDef.x)]; + c.subObjects.push(new KGAuthor.Label(labelDef, graph)); + } + else if (labelDef.hasOwnProperty('y') && def.univariateFunction.ind != 'x') { + labelDef.coordinates = [c.xOfY(labelDef.y), labelDef.y]; + c.subObjects.push(new KGAuthor.Label(labelDef, graph)); + } + } + if (def.hasOwnProperty('parametricFunction')) { + if (labelDef.hasOwnProperty('t')) { + labelDef.coordinates = c.xyOfT(labelDef.t); + c.subObjects.push(new KGAuthor.Label(labelDef, graph)); + } + } + } + return _this; + } + Curve.prototype.yOfX = function (x) { + return "(" + KGAuthor.replaceVariable(this.def.univariateFunction.fn, '(x)', "(" + x + ")") + ")"; + }; + Curve.prototype.xOfY = function (y) { + var c = this; + if (c.def.univariateFunction.hasOwnProperty('yFn')) { + return "(" + KGAuthor.replaceVariable(c.def.univariateFunction.yFn, '(y)', "(" + y + ")") + ")"; + } + else { + return "(" + KGAuthor.replaceVariable(c.def.univariateFunction.fn, '(y)', "(" + y + ")") + ")"; + } + }; + Curve.prototype.xyOfT = function (t) { + return [ + KGAuthor.replaceVariable(this.def.parametricFunction.xFunction, '(t)', "(" + t + ")"), + KGAuthor.replaceVariable(this.def.parametricFunction.yFunction, '(t)', "(" + t + ")") + ]; + }; + Curve.prototype.parseSelf = function (parsedData) { + var c = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + parsedData.calcs[c.name] = parsedData.calcs[c.name] || {}; + c.pts.forEach(function (p) { + if (p.hasOwnProperty('x')) { + parsedData.calcs[c.name][p['name']] = { + x: p['x'], + y: c.yOfX(p['x']) + }; + } + if (p.hasOwnProperty('y')) { + parsedData.calcs[c.name][p['name']] = { + x: c.xOfY(p['y']), + y: p['y'] + }; + } + }); + return parsedData; + }; + return Curve; + }(KGAuthor.GraphObject)); + KGAuthor.Curve = Curve; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Line = /** @class */ (function (_super) { + __extends(Line, _super); + function Line(def, graph) { + var _this = this; + KG.setDefaults(def, { + color: 'colors.orange' + }); + // may define line with two points + var xIntercept = def.xIntercept, yIntercept = def.yIntercept, slope = def.slope, invSlope = def.invSlope; + if (def.hasOwnProperty('point') && def.hasOwnProperty('point2')) { + // still need to handle infinite case + slope = KGAuthor.divideDefs(KGAuthor.subtractDefs(def.point[1], def.point2[1]), KGAuthor.subtractDefs(def.point[0], def.point2[0])); + yIntercept = KGAuthor.subtractDefs(def.point[1], KGAuthor.multiplyDefs(slope, def.point[0])); + invSlope = KGAuthor.divideDefs(KGAuthor.subtractDefs(def.point[0], def.point2[0]), KGAuthor.subtractDefs(def.point[1], def.point2[1])); + xIntercept = KGAuthor.subtractDefs(def.point[0], KGAuthor.multiplyDefs(invSlope, def.point[1])); + } + else if (def.hasOwnProperty('xIntercept') && def.hasOwnProperty('yIntercept')) { + slope = KGAuthor.negativeDef(KGAuthor.divideDefs(def.yIntercept, def.xIntercept)); + invSlope = KGAuthor.negativeDef(KGAuthor.divideDefs(def.xIntercept, def.yIntercept)); + } + else if (def.hasOwnProperty('point') && def.hasOwnProperty('yIntercept')) { + slope = KGAuthor.divideDefs(KGAuthor.subtractDefs(def.point[1], def.yIntercept), def.point[0]); + invSlope = KGAuthor.divideDefs(def.point[0], KGAuthor.subtractDefs(def.point[1], def.yIntercept)); + xIntercept = KGAuthor.negativeDef(KGAuthor.multiplyDefs(yIntercept, invSlope)); + } + else if (def.hasOwnProperty('slope') && def.hasOwnProperty('yIntercept')) { + invSlope = KGAuthor.invertDef(def.slope); + xIntercept = KGAuthor.negativeDef(KGAuthor.divideDefs(yIntercept, slope)); + } + else if (def.hasOwnProperty('invSlope') && def.hasOwnProperty('xIntercept')) { + slope = KGAuthor.invertDef(def.invSlope); + yIntercept = KGAuthor.negativeDef(KGAuthor.divideDefs(xIntercept, invSlope)); + } + else if (def.hasOwnProperty('invSlope') && def.hasOwnProperty('yIntercept')) { + slope = KGAuthor.invertDef(def.invSlope); + } + else if (def.hasOwnProperty('slope') && def.hasOwnProperty('point')) { + invSlope = KGAuthor.invertDef(def.slope); + xIntercept = KGAuthor.subtractDefs(def.point[0], KGAuthor.divideDefs(def.point[1], def.slope)); + yIntercept = KGAuthor.subtractDefs(def.point[1], KGAuthor.multiplyDefs(def.point[0], def.slope)); + } + else if (def.hasOwnProperty('invSlope') && def.hasOwnProperty('point')) { + slope = KGAuthor.invertDef(def.invSlope); + xIntercept = KGAuthor.subtractDefs(def.point[0], KGAuthor.divideDefs(def.point[1], slope)); + yIntercept = KGAuthor.subtractDefs(def.point[1], KGAuthor.multiplyDefs(def.point[0], slope)); + } + else if (def.hasOwnProperty('slope')) { + invSlope = KGAuthor.invertDef(def.slope); + xIntercept = 0; + yIntercept = 0; + } + else if (def.hasOwnProperty('yIntercept')) { + invSlope = Infinity; + xIntercept = null; + yIntercept = def.yIntercept; + slope = 0; + } + else if (def.hasOwnProperty('xIntercept')) { + invSlope = 0; + xIntercept = def.xIntercept; + yIntercept = null; + slope = Infinity; + } + else { + xIntercept = 0; + yIntercept = 0; + slope = KGAuthor.divideDefs(def.point[1], def.point[0]); + invSlope = KGAuthor.divideDefs(def.point[0], def.point[1]); + } + def.univariateFunction = { + fn: yIntercept + " + (" + slope + ")*(x)", + yFn: xIntercept + " + (" + invSlope + ")*(y)", + ind: "((" + invSlope + " == 0) ? 'y' : 'x')", + samplePoints: 2 + }; + if (def.hasOwnProperty('min')) { + def.univariateFunction.min = def.min; + delete def.min; + } + if (def.hasOwnProperty('max')) { + def.univariateFunction.max = def.max; + delete def.max; + } + _this = _super.call(this, def, graph) || this; + _this.xIntercept = xIntercept; + _this.yIntercept = yIntercept; + _this.slope = slope; + _this.invSlope = invSlope; + return _this; + } + Line.prototype.parseSelf = function (parsedData) { + var l = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + var d = { + slope: l.slope.toString(), + invSlope: l.invSlope.toString() + }; + if (l.xIntercept) { + d.xIntercept = l.xIntercept.toString(); + } + if (l.yIntercept) { + d.yIntercept = l.yIntercept.toString(); + } + if (!l.xIntercept) { + d.fixedPoint = "((" + d.yIntercept + ")/(1 - " + l.slope.toString() + "))"; + } + else if (!l.yIntercept) { + d.fixedPoint = "((" + d.xIntercept + ")/(1 - " + l.invSlope.toString() + "))"; + } + else { + d.fixedPoint = "(" + d.invSlope + " == 0 ? (" + d.xIntercept + ")/(1 - " + l.invSlope.toString() + ") : (" + d.yIntercept + ")/(1 - " + l.slope.toString() + "))"; + } + parsedData.calcs[l.name] = KG.setDefaults(parsedData.calcs[l.name] || {}, d); + return parsedData; + }; + return Line; + }(KGAuthor.Curve)); + KGAuthor.Line = Line; + function lineIntersection(l1, l2) { + var x = KGAuthor.divideDefs(KGAuthor.addDefs(l1.xIntercept, KGAuthor.multiplyDefs(l1.invSlope, l2.yIntercept)), KGAuthor.subtractDefs("1", KGAuthor.multiplyDefs(l1.invSlope, l2.slope))); + var y = l2.yOfX(x); + return [x, y]; + } + KGAuthor.lineIntersection = lineIntersection; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Ellipse = /** @class */ (function (_super) { + __extends(Ellipse, _super); + function Ellipse(def, graph) { + var _this = this; + KG.setDefaults(def, { + color: 'colors.blue', + opacity: 0.2, + rx: 1, + ry: def.rx + }); + def = KGAuthor.setFillColor(def); + def = KGAuthor.setStrokeColor(def); + _this = _super.call(this, def, graph) || this; + var c = _this; + c.type = 'Circle'; + c.layer = def.layer || 0; + // may define the center using 'coordinates' or 'center' or 'c': + if (def.hasOwnProperty('c')) { + c.extractCoordinates('c'); + } + else if (def.hasOwnProperty('center')) { + c.extractCoordinates('center'); + } + else { + c.extractCoordinates(); + } + if (def.hasOwnProperty('draggable') && def.draggable == true && !def.hasOwnProperty('drag')) { + def.drag = []; + if (def.x == "params." + KGAuthor.paramName(def.x)) { + def.drag.push({ horizontal: KGAuthor.paramName(def.x) }); + } + if (def.y == "params." + KGAuthor.paramName(def.y)) { + def.drag.push({ vertical: KGAuthor.paramName(def.y) }); + } + } + if (def.hasOwnProperty('label')) { + var labelDef = KGAuthor.copyJSON(def); + delete labelDef.label; + labelDef = KG.setDefaults(labelDef, def.label); + labelDef = KG.setDefaults(labelDef, { + fontSize: 10, + color: def.color, + bgcolor: null + }); + c.subObjects.push(new KGAuthor.Label(labelDef, graph)); + } + return _this; + } + return Ellipse; + }(KGAuthor.GraphObject)); + KGAuthor.Ellipse = Ellipse; + var Circle = /** @class */ (function (_super) { + __extends(Circle, _super); + function Circle(def, graph) { + var _this = this; + if (def.hasOwnProperty('radius')) { + def.r = def.radius; + delete def.radius; + } + if (def.hasOwnProperty('r')) { + def.rx = def.r; + def.ry = def.r; + } + _this = _super.call(this, def, graph) || this; + return _this; + } + return Circle; + }(Ellipse)); + KGAuthor.Circle = Circle; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Point = /** @class */ (function (_super) { + __extends(Point, _super); + function Point(def, graph) { + var _this = this; + KG.setDefaults(def, { + color: 'colors.blue' + }); + def = KGAuthor.setFillColor(def); + _this = _super.call(this, def, graph) || this; + var p = _this; + p.type = 'Point'; + p.layer = 3; + p.extractCoordinates(); + if (def.hasOwnProperty('draggable') && def.draggable == true && !def.hasOwnProperty('drag')) { + def.drag = []; + if (def.x == "params." + KGAuthor.paramName(def.x)) { + def.drag.push({ horizontal: KGAuthor.paramName(def.x) }); + } + if (def.y == "params." + KGAuthor.paramName(def.y)) { + def.drag.push({ vertical: KGAuthor.paramName(def.y) }); + } + } + if (def.hasOwnProperty('label')) { + var labelDef = KGAuthor.copyJSON(def); + delete labelDef.label; + labelDef = KG.setDefaults(labelDef, def.label); + labelDef = KG.setDefaults(labelDef, { + fontSize: 10, + position: 'bl', + color: def.color, + bgcolor: null + }); + p.subObjects.push(new KGAuthor.Label(labelDef, graph)); + } + if (def.hasOwnProperty('droplines')) { + if (def.droplines.hasOwnProperty('vertical')) { + var verticalDroplineDef = KGAuthor.copyJSON(def); + // only drag vertical droplines horizontally + if (verticalDroplineDef.hasOwnProperty('drag')) { + verticalDroplineDef.drag = verticalDroplineDef.drag.filter(function (value, index, arr) { return ((value.directions == 'x') || value.hasOwnProperty('horizontal')); }); + } + if (def.droplines.hasOwnProperty('top')) { + verticalDroplineDef.y = graph.yScale.max; + var xTopAxisLabelDef = KGAuthor.copyJSON(verticalDroplineDef); + xTopAxisLabelDef.y = 'OPPAXIS'; + KG.setDefaults(xTopAxisLabelDef, { + text: def.droplines.top, + fontSize: 10 + }); + p.subObjects.push(new KGAuthor.Label(xTopAxisLabelDef, graph)); + } + p.subObjects.push(new KGAuthor.VerticalDropline(verticalDroplineDef, graph)); + var xAxisLabelDef = KGAuthor.copyJSON(verticalDroplineDef); + xAxisLabelDef.y = 'AXIS'; + KG.setDefaults(xAxisLabelDef, { + text: def.droplines.vertical, + fontSize: 10 + }); + p.subObjects.push(new KGAuthor.Label(xAxisLabelDef, graph)); + } + if (def.droplines.hasOwnProperty('horizontal')) { + var horizontalDroplineDef = KGAuthor.copyJSON(def); + // only drag horizontal droplines vertically + if (horizontalDroplineDef.hasOwnProperty('drag')) { + horizontalDroplineDef.drag = horizontalDroplineDef.drag.filter(function (value, index, arr) { return ((value.directions == 'y') || value.hasOwnProperty('vertical')); }); + } + p.subObjects.push(new KGAuthor.HorizontalDropline(horizontalDroplineDef, graph)); + var yAxisLabelDef = KGAuthor.copyJSON(horizontalDroplineDef); + yAxisLabelDef.x = 'AXIS'; + KG.setDefaults(yAxisLabelDef, { + text: def.droplines.horizontal, + fontSize: 10 + }); + p.subObjects.push(new KGAuthor.Label(yAxisLabelDef, graph)); + } + } + return _this; + } + return Point; + }(KGAuthor.GraphObject)); + KGAuthor.Point = Point; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Segment = /** @class */ (function (_super) { + __extends(Segment, _super); + function Segment(def, graph) { + var _this = this; + def = KGAuthor.setStrokeColor(def); + if (def.hasOwnProperty('startArrow')) { + def.startArrowName = graph.getStartArrowName(def.color); + } + if (def.hasOwnProperty('endArrow')) { + def.endArrowName = graph.getEndArrowName(def.color); + } + _this = _super.call(this, def, graph) || this; + var s = _this; + s.type = 'Segment'; + s.layer = 1; + s.extractCoordinates('a', 'x1', 'y1'); + s.extractCoordinates('b', 'x2', 'y2'); + if (def.hasOwnProperty('label')) { + var labelDef = KGAuthor.copyJSON(def); + delete labelDef.label; + labelDef = KG.setDefaults(labelDef, def.label); + labelDef = KG.setDefaults(labelDef, { + fontSize: 12, + color: def.color, + location: 0.5 + }); + labelDef.coordinates = [ + KGAuthor.averageDefs(s.x1, s.x2, labelDef.location), + KGAuthor.averageDefs(s.y1, s.y2, labelDef.location) + ]; + s.subObjects.push(new KGAuthor.Label(labelDef, graph)); + } + return _this; + } + return Segment; + }(KGAuthor.GraphObject)); + KGAuthor.Segment = Segment; + var CrossGraphSegment = /** @class */ (function (_super) { + __extends(CrossGraphSegment, _super); + function CrossGraphSegment(def, graph) { + var _this = this; + def.xScale2Name = ''; + _this = _super.call(this, def, graph) || this; + return _this; + } + return CrossGraphSegment; + }(Segment)); + KGAuthor.CrossGraphSegment = CrossGraphSegment; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Arrow = /** @class */ (function (_super) { + __extends(Arrow, _super); + function Arrow(def, graph) { + var _this = this; + def.endArrow = true; + if (def.hasOwnProperty('double')) { + def.startArrow = def.double; + } + if (def.hasOwnProperty('trim')) { + def.a = [KGAuthor.averageDefs(def.end[0], def.begin[0], def.trim), KGAuthor.averageDefs(def.end[1], def.begin[1], def.trim)]; + def.b = [KGAuthor.averageDefs(def.begin[0], def.end[0], def.trim), KGAuthor.averageDefs(def.begin[1], def.end[1], def.trim)]; + } + else { + def.a = def.begin; + def.b = def.end; + } + _this = _super.call(this, def, graph) || this; + return _this; + } + return Arrow; + }(KGAuthor.Segment)); + KGAuthor.Arrow = Arrow; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Dropline = /** @class */ (function (_super) { + __extends(Dropline, _super); + function Dropline(def, graph) { + var _this = this; + def.lineStyle = 'dotted'; + delete def.label; + _this = _super.call(this, def, graph) || this; + return _this; + } + return Dropline; + }(KGAuthor.Segment)); + KGAuthor.Dropline = Dropline; + var VerticalDropline = /** @class */ (function (_super) { + __extends(VerticalDropline, _super); + function VerticalDropline(def, graph) { + var _this = this; + def.a = [def.x, graph.xScale.intercept]; + def.b = [def.x, def.y]; + _this = _super.call(this, def, graph) || this; + return _this; + } + return VerticalDropline; + }(Dropline)); + KGAuthor.VerticalDropline = VerticalDropline; + var CrossGraphVerticalDropline = /** @class */ (function (_super) { + __extends(CrossGraphVerticalDropline, _super); + function CrossGraphVerticalDropline(def, graph) { + var _this = this; + def.xScale2Name = ''; + _this = _super.call(this, def, graph) || this; + return _this; + } + return CrossGraphVerticalDropline; + }(VerticalDropline)); + KGAuthor.CrossGraphVerticalDropline = CrossGraphVerticalDropline; + var HorizontalDropline = /** @class */ (function (_super) { + __extends(HorizontalDropline, _super); + function HorizontalDropline(def, graph) { + var _this = this; + def.a = [graph.yScale.intercept, def.y]; + def.b = [def.x, def.y]; + _this = _super.call(this, def, graph) || this; + return _this; + } + return HorizontalDropline; + }(Dropline)); + KGAuthor.HorizontalDropline = HorizontalDropline; + var CrossGraphHorizontalDropline = /** @class */ (function (_super) { + __extends(CrossGraphHorizontalDropline, _super); + function CrossGraphHorizontalDropline(def, graph) { + var _this = this; + def.xScale2Name = ''; + _this = _super.call(this, def, graph) || this; + return _this; + } + return CrossGraphHorizontalDropline; + }(HorizontalDropline)); + KGAuthor.CrossGraphHorizontalDropline = CrossGraphHorizontalDropline; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Area = /** @class */ (function (_super) { + __extends(Area, _super); + function Area(def, graph) { + var _this = this; + KG.setDefaults(def, { + color: 'colors.blue', + opacity: 0.2 + }); + def = KGAuthor.setFillColor(def); + KGAuthor.parseFn(def, 'fn', 'univariateFunction1'); + KGAuthor.parseFn(def, 'fn1', 'univariateFunction1'); + KGAuthor.parseFn(def, 'fn2', 'univariateFunction2'); + _this = _super.call(this, def, graph) || this; + _this.type = 'Area'; + _this.layer = def.layer || 0; + return _this; + } + return Area; + }(KGAuthor.GraphObject)); + KGAuthor.Area = Area; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Rectangle = /** @class */ (function (_super) { + __extends(Rectangle, _super); + function Rectangle(def, graph) { + var _this = this; + KGAuthor.setFillColor(def); + _this = _super.call(this, def, graph) || this; + var rect = _this; + rect.type = 'Rectangle'; + rect.layer = def.layer || 0; + rect.extractCoordinates('a', 'x1', 'y1'); + rect.extractCoordinates('b', 'x2', 'y2'); + if (def.hasOwnProperty('label')) { + var labelDef = KGAuthor.copyJSON(def); + delete labelDef.label; + labelDef = KG.setDefaults(labelDef, def.label); + labelDef = KG.setDefaults(labelDef, { + fontSize: 10, + color: def.color, + bgcolor: null, + x: KGAuthor.averageDefs(rect['x1'], rect['x2']), + y: KGAuthor.averageDefs(rect['y1'], rect['y2']) + }); + rect.subObjects.push(new KGAuthor.Label(labelDef, graph)); + } + return _this; + } + return Rectangle; + }(KGAuthor.GraphObject)); + KGAuthor.Rectangle = Rectangle; + var Overlap = /** @class */ (function (_super) { + __extends(Overlap, _super); + function Overlap(def, graph) { + var _this = this; + var shape1name = KG.randomString(10), shape2name = KG.randomString(10); + def = KGAuthor.setFillColor(def); + KG.setDefaults(def, { + x1: graph.def.xAxis.min, + x2: graph.def.xAxis.max, + y1: graph.def.yAxis.min, + y2: graph.def.yAxis.max, + clipPathName: shape1name, + clipPathName2: shape2name + }); + _this = _super.call(this, def, graph) || this; + var r = _this; + var clipPathObjects = def.shapes.map(function (shape) { + var shapeType = Object.keys(shape)[0]; + var shapeDef = shape[shapeType]; + shapeDef.inDef = true; + return new KGAuthor[shapeType](shapeDef, graph); + }); + // As of now this does at most two; can make more recursive in the future but this handles 80% of the use cases + r.subObjects.push(new KGAuthor.ClipPath({ name: shape1name, paths: [clipPathObjects[0]] }, graph)); + r.subObjects.push(new KGAuthor.ClipPath({ name: shape2name, paths: [clipPathObjects[1]] }, graph)); + return _this; + } + return Overlap; + }(Rectangle)); + KGAuthor.Overlap = Overlap; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Contour = /** @class */ (function (_super) { + __extends(Contour, _super); + function Contour(def, graph) { + var _this = this; + def = KGAuthor.setStrokeColor(def); + _this = _super.call(this, def, graph) || this; + var c = _this; + c.type = 'Contour'; + c.layer = def.layer || 1; + if (def.hasOwnProperty('coordinates')) { + c.extractCoordinates(); + } + if (!def.hasOwnProperty('level')) { + def.level = def.fn.replace('(x)', "(" + def.x + ")").replace('(y)', "(" + def.y + ")"); + } + return _this; + } + return Contour; + }(KGAuthor.GraphObject)); + KGAuthor.Contour = Contour; + var ContourMap = /** @class */ (function (_super) { + __extends(ContourMap, _super); + function ContourMap(def, graph) { + var _this = this; + KG.setDefaults(def, { + color: "grey", + strokeWidth: 0.5 + }); + _this = _super.call(this, def, graph) || this; + var m = _this; + m.type = 'ContourMap'; + m.layer = def.layer || 1; + m.subObjects = def.levels.map(function (level) { + var contourDef = KGAuthor.copyJSON(def); + delete contourDef.levels; + contourDef.level = level; + return new Contour(contourDef, graph); + }); + console.log('contours: ', m.subObjects); + return _this; + } + return ContourMap; + }(KGAuthor.GraphObject)); + KGAuthor.ContourMap = ContourMap; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var AngleMarker = /** @class */ (function (_super) { + __extends(AngleMarker, _super); + function AngleMarker(def, graph) { + var _this = this; + KG.setDefaults(def, { + name: 'angle', + color: 'colors.grey', + point: [0, 0], + radians: false, + start: 0, + r: KGAuthor.multiplyDefs(0.05, KGAuthor.subtractDefs(graph.def.xAxis.max, graph.def.xAxis.min)), + strokeWidth: 0.75 + }); + def = KGAuthor.setStrokeColor(def); + if (def.hasOwnProperty("measure")) { + def.end = KGAuthor.addDefs(def.start, def.measure); + } + else { + def.measure = KGAuthor.subtractDefs(def.end, def.start); + } + // convert to radians unless already radians + var start = def.radians ? def.start : KGAuthor.multiplyDefs(def.start, 0.01745329252), measure = def.radians ? def.measure : KGAuthor.multiplyDefs(def.measure, 0.01745329252), end = def.radians ? def.end : KGAuthor.multiplyDefs(def.end, 0.01745329252), mid = KGAuthor.addDefs(start, KGAuthor.multiplyDefs(0.5, measure)); + def.parametricFunction = { + xFunction: KGAuthor.addDefs(def.point[0], KGAuthor.multiplyDefs(def.r, "cos(t)")), + yFunction: KGAuthor.addDefs(def.point[1], KGAuthor.multiplyDefs(def.r, "sin(t)")), + min: start, + max: end + }; + _this = _super.call(this, def, graph) || this; + var dm = _this; + dm.measureDegrees = def.radians ? KGAuthor.multiplyDefs(def.measure, 57.2957795131) : def.measure; + dm.measureRadians = KGAuthor.divideDefs(measure, Math.PI); + var labelDef = KG.setDefaults(def.label || {}, { + x: KGAuthor.addDefs(def.point[0], KGAuthor.multiplyDefs(KGAuthor.multiplyDefs(1.7, def.r), "cos(" + mid + ")")), + y: KGAuthor.addDefs(def.point[1], KGAuthor.multiplyDefs(KGAuthor.multiplyDefs(1.7, def.r), "sin(" + mid + ")")), + fontSize: 8, + color: def.stroke, + bgcolor: "none", + radians: false + }); + var labelTextRadians = "`${calcs." + dm.name + ".measureRadians.toFixed(2)}\\\\pi`", labelTextDegrees = "`${calcs." + dm.name + ".measureDegrees.toFixed(0)}^{\\\\circ}`"; + labelDef.text = labelDef.hasOwnProperty('text') ? def.label.text : labelDef.radians ? labelTextRadians : labelTextDegrees; + dm.subObjects.push(new KGAuthor.Label(labelDef, graph)); + return _this; + } + AngleMarker.prototype.parseSelf = function (parsedData) { + var dm = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + parsedData.calcs[dm.name] = { + measureDegrees: dm.measureDegrees.toString(), + measureRadians: dm.measureRadians.toString() + }; + return parsedData; + }; + return AngleMarker; + }(KGAuthor.Curve)); + KGAuthor.AngleMarker = AngleMarker; + var Angle = /** @class */ (function (_super) { + __extends(Angle, _super); + function Angle(def, graph) { + var _this = this; + var A = new KGAuthor.Point(def.pointA, graph), B = new KGAuthor.Point(def.pointB, graph), C = new KGAuthor.Point(def.pointC, graph); + def.start = "atan2(" + A.y + " - " + B.y + "," + A.x + " - " + B.x + ")"; + def.end = "atan2(" + C.y + " - " + B.y + "," + C.x + " - " + B.x + ")"; + def.point = [B.x, B.y]; + def.radians = true; + KG.setDefaults(def, { + label: { + radians: false + } + }); + _this = _super.call(this, def, graph) || this; + var a = _this; + a.subObjects.push(A); + a.subObjects.push(B); + a.subObjects.push(C); + if (def.showSegments) { + var ABdef = KGAuthor.copyJSON(def), CBdef = KGAuthor.copyJSON(def); + ABdef.a = [B.x, B.y]; + ABdef.b = [A.x, A.y]; + delete ABdef.label; + a.subObjects.push(new KGAuthor.Segment(ABdef, graph)); + CBdef.a = [B.x, B.y]; + CBdef.b = [C.x, C.y]; + delete CBdef.label; + a.subObjects.push(new KGAuthor.Segment(CBdef, graph)); + } + return _this; + } + return Angle; + }(AngleMarker)); + KGAuthor.Angle = Angle; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var MathboxObject = /** @class */ (function (_super) { + __extends(MathboxObject, _super); + function MathboxObject(def) { + var _this = _super.call(this, def) || this; + _this.mb = def.mb; + return _this; + } + return MathboxObject; + }(KGAuthor.AuthoringObject)); + KGAuthor.MathboxObject = MathboxObject; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var MathboxAxis = /** @class */ (function (_super) { + __extends(MathboxAxis, _super); + function MathboxAxis(def) { + var _this = _super.call(this, def) || this; + var a = _this; + a.type = 'MathboxAxis'; + a.mb.addObject({ + "type": "MathboxLabel", + "def": { + "x": 50, + "y": 0, + "z": 0, + "text": "Good 1" + } + }); + return _this; + } + return MathboxAxis; + }(KGAuthor.MathboxObject)); + KGAuthor.MathboxAxis = MathboxAxis; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var MathboxPoint = /** @class */ (function (_super) { + __extends(MathboxPoint, _super); + function MathboxPoint(def) { + var _this = _super.call(this, def) || this; + var a = _this; + a.type = 'MathboxPoint'; + return _this; + } + return MathboxPoint; + }(KGAuthor.MathboxObject)); + KGAuthor.MathboxPoint = MathboxPoint; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var MathboxLine = /** @class */ (function (_super) { + __extends(MathboxLine, _super); + function MathboxLine(def) { + var _this = _super.call(this, def) || this; + var a = _this; + a.type = 'MathboxAxis'; + return _this; + } + return MathboxLine; + }(KGAuthor.MathboxObject)); + KGAuthor.MathboxLine = MathboxLine; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var MathboxArea = /** @class */ (function (_super) { + __extends(MathboxArea, _super); + function MathboxArea(def) { + var _this = _super.call(this, def) || this; + var a = _this; + a.type = 'MathboxAxis'; + return _this; + } + return MathboxArea; + }(KGAuthor.MathboxObject)); + KGAuthor.MathboxArea = MathboxArea; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var DivObject = /** @class */ (function (_super) { + __extends(DivObject, _super); + function DivObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + DivObject.prototype.parseSelf = function (parsedData) { + parsedData.divs.push(this); + return parsedData; + }; + return DivObject; + }(KGAuthor.GraphObject)); + KGAuthor.DivObject = DivObject; + var Div = /** @class */ (function (_super) { + __extends(Div, _super); + function Div(def) { + var _this = _super.call(this, def) || this; + _this.type = "Div"; + return _this; + } + return Div; + }(DivObject)); + KGAuthor.Div = Div; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var PositionedDiv = /** @class */ (function (_super) { + __extends(PositionedDiv, _super); + function PositionedDiv(def, divContainer) { + var _this = this; + delete def.xAxis; + delete def.yAxis; + def.xScaleName = divContainer.xScale.name; + def.yScaleName = divContainer.yScale.name; + _this = _super.call(this, def) || this; + _this.type = 'PositionedDiv'; + return _this; + } + return PositionedDiv; + }(KGAuthor.DivObject)); + KGAuthor.PositionedDiv = PositionedDiv; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Label = /** @class */ (function (_super) { + __extends(Label, _super); + function Label(def, graph) { + var _this = this; + if (def.hasOwnProperty('position')) { + if (def.position.toLowerCase() == 'bl') { + def.xPixelOffset = 5; + def.yPixelOffset = 10; + def.align = 'left'; + } + if (def.position.toLowerCase() == 'tl') { + def.xPixelOffset = 5; + def.yPixelOffset = -12; + def.align = 'left'; + } + if (def.position.toLowerCase() == 'tr') { + def.xPixelOffset = -5; + def.yPixelOffset = -12; + def.align = 'right'; + } + if (def.position.toLowerCase() == 'br') { + def.xPixelOffset = -5; + def.yPixelOffset = 10; + def.align = 'right'; + } + if (def.position.toLowerCase() == 'tr') { + def.xPixelOffset = -5; + def.yPixelOffset = -12; + def.align = 'right'; + } + if (def.position.toLowerCase() == 't') { + def.yPixelOffset = -15; + } + if (def.position.toLowerCase() == 'b') { + def.yPixelOffset = 12; + } + if (def.position.toLowerCase() == 'l') { + def.xPixelOffset = -8; + def.align = 'right'; + } + if (def.position.toLowerCase() == 'r') { + def.xPixelOffset = 8; + def.align = 'left'; + } + } + _this = _super.call(this, def, graph) || this; + _this.type = 'Label'; + _this.extractCoordinates(); + return _this; + } + return Label; + }(KGAuthor.DivObject)); + KGAuthor.Label = Label; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Sidebar = /** @class */ (function (_super) { + __extends(Sidebar, _super); + function Sidebar(def) { + var _this = _super.call(this, def) || this; + _this.type = 'Sidebar'; + return _this; + } + return Sidebar; + }(KGAuthor.DivObject)); + KGAuthor.Sidebar = Sidebar; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Controls = /** @class */ (function (_super) { + __extends(Controls, _super); + function Controls(def) { + var _this = _super.call(this, def) || this; + _this.type = 'Controls'; + return _this; + } + return Controls; + }(KGAuthor.DivObject)); + KGAuthor.Controls = Controls; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var GameMatrix = /** @class */ (function (_super) { + __extends(GameMatrix, _super); + function GameMatrix(def) { + var _this = _super.call(this, def) || this; + _this.type = 'GameMatrix'; + return _this; + } + return GameMatrix; + }(KGAuthor.DivObject)); + KGAuthor.GameMatrix = GameMatrix; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var GeoGebraApplet = /** @class */ (function (_super) { + __extends(GeoGebraApplet, _super); + function GeoGebraApplet(def) { + var _this = _super.call(this, def) || this; + _this.type = 'GeoGebraApplet'; + return _this; + } + return GeoGebraApplet; + }(KGAuthor.DivObject)); + KGAuthor.GeoGebraApplet = GeoGebraApplet; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var Mathbox = /** @class */ (function (_super) { + __extends(Mathbox, _super); + function Mathbox(def) { + var _this = _super.call(this, def) || this; + var mb = _this; + mb.type = 'Mathbox'; + def.objects.forEach(function (mbo) { mbo.def.mb = mb; }); + return _this; + } + Mathbox.prototype.addObject = function (mbo) { + this.def.objects.push(mbo); + return this; + }; + return Mathbox; + }(KGAuthor.DivObject)); + KGAuthor.Mathbox = Mathbox; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconSchema = /** @class */ (function (_super) { + __extends(EconSchema, _super); + function EconSchema(def) { + var _this = this; + def.colors = KG.setDefaults(def.colors || {}, { + // consumer theory + utility: 'purple', + mrs: 'blue', + dispreferred: 'red', + preferred: 'purple', + offer: 'blue', + incomeOffer: 'orange', + demand: 'blue', + budget: 'green', + costlier: 'red', + endowment: 'grey', + incEffect: 'orange', + subEffect: 'red', + // producer theory + production: 'blue', + marginalCost: 'orange', + marginalRevenue: 'olive', + supply: 'orange', + shortRun: 'red', + longRun: 'orange', + profit: 'green', + loss: 'red', + // equilibrium + price: 'grey', + paretoLens: "'#ffff99'", + equilibriumPrice: 'green', + // macro + consumption: 'blue', + depreciation: "red", + savings: "green", + tax: 'red' + }); + _this = _super.call(this, def) || this; + return _this; + } + return EconSchema; + }(KGAuthor.Schema)); + KGAuthor.EconSchema = EconSchema; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var BowlesHallidaySchema = /** @class */ (function (_super) { + __extends(BowlesHallidaySchema, _super); + function BowlesHallidaySchema(def) { + var _this = this; + // create color scheme here; I took these from the spreadsheet + var purple = "'#3f007d'", blue = "'#084081'", green = "'#005824'"; + // define any overrides to the defined Econ schema here + def.colors = { + // consumer theory + demand: purple, + supply: blue, + equilibriumPrice: green + }; + _this = _super.call(this, def) || this; + return _this; + } + return BowlesHallidaySchema; + }(KGAuthor.EconSchema)); + KGAuthor.BowlesHallidaySchema = BowlesHallidaySchema; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EdgeworthBoxPlusSidebar = /** @class */ (function (_super) { + __extends(EdgeworthBoxPlusSidebar, _super); + function EdgeworthBoxPlusSidebar(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var agentA = def['agentA'], agentB = def['agentB'], sidebarDef = def['sidebar']; + var width = 0.738, height = 0.9; + if (def.totalGood1 > def.totalGood2) { + height = def.totalGood2 * height / def.totalGood1; + } + if (def.totalGood2 > def.totalGood1) { + height = def.totalGood1 * width / def.totalGood2; + } + agentA.position = { + "x": 0.15, + "y": 0.05, + "width": width, + "height": height + }; + agentB.position = { + "x": 0.15 + width, + "y": 0.05 + height, + "width": -1 * width, + "height": -1 * height + }; + agentA.xAxis.max = agentB.xAxis.max = def.totalGood1; + agentA.yAxis.max = agentB.yAxis.max = def.totalGood2; + agentB.xAxis.orient = 'top'; + agentB.yAxis.orient = 'right'; + l.subObjects.push(new KGAuthor.Graph(agentA)); + l.subObjects.push(new KGAuthor.Graph(agentB)); + l.subObjects.push(new KGAuthor.Sidebar(sidebarDef)); + return _this; + } + return EdgeworthBoxPlusSidebar; + }(KGAuthor.SquareLayout)); + KGAuthor.EdgeworthBoxPlusSidebar = EdgeworthBoxPlusSidebar; + var EdgeworthBoxPlusTwoGraphsPlusSidebar = /** @class */ (function (_super) { + __extends(EdgeworthBoxPlusTwoGraphsPlusSidebar, _super); + function EdgeworthBoxPlusTwoGraphsPlusSidebar(def) { + var _this = _super.call(this, def) || this; + var l = _this; + var agentA = def['agentA'], agentB = def['agentB'], graph1 = def['graph1'], graph2 = def['graph2'], sidebarDef = def['sidebar']; + var width = 0.738, height = 0.9; + if (def.totalGood1 > def.totalGood2) { + height = def.totalGood2 * height / def.totalGood1; + } + if (def.totalGood2 > def.totalGood1) { + height = def.totalGood1 * width / def.totalGood2; + } + agentA.position = { + "x": 0.15, + "y": 0.05, + "width": width, + "height": height + }; + agentB.position = { + "x": 0.15 + width, + "y": 0.05 + height, + "width": -1 * width, + "height": -1 * height + }; + graph1.position = { + "x": 0.1, + "y": height + 0.15, + "width": 0.35, + "height": 0.85 - height + }; + graph2.position = { + "x": 0.6, + "y": height + 0.15, + "width": 0.35, + "height": 0.85 - height + }; + agentA.xAxis.max = agentB.xAxis.max = def.totalGood1; + agentA.yAxis.max = agentB.yAxis.max = def.totalGood2; + agentB.xAxis.orient = 'top'; + agentB.yAxis.orient = 'right'; + l.subObjects.push(new KGAuthor.Graph(agentB)); + l.subObjects.push(new KGAuthor.Graph(agentA)); + l.subObjects.push(new KGAuthor.Graph(graph1)); + l.subObjects.push(new KGAuthor.Graph(graph2)); + l.subObjects.push(new KGAuthor.Sidebar(sidebarDef)); + return _this; + } + return EdgeworthBoxPlusTwoGraphsPlusSidebar; + }(KGAuthor.SquareLayout)); + KGAuthor.EdgeworthBoxPlusTwoGraphsPlusSidebar = EdgeworthBoxPlusTwoGraphsPlusSidebar; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconMultivariateFunction = /** @class */ (function (_super) { + __extends(EconMultivariateFunction, _super); + function EconMultivariateFunction(def) { + var _this = this; + KG.setDefaults(def, { + name: KG.randomString(10) + }); + _this = _super.call(this, def) || this; + var fn = _this; + fn.interpolation = 'curveMonotoneX'; + if (def.hasOwnProperty('alpha')) { + fn.alpha = def.alpha; + fn.exponents = def.exponents || [def.alpha, KGAuthor.subtractDefs(1, def.alpha)]; + fn.coefficients = def.coefficients || [def.alpha, KGAuthor.subtractDefs(1, def.alpha)]; + } + else if (def.hasOwnProperty('exponents')) { + fn.exponents = def.exponents; + fn.alpha = KGAuthor.divideDefs(fn.exponents[0], KGAuthor.addDefs(fn.exponents[0], fn.exponents[1])); + fn.coefficients = def.coefficients; + } + else if (def.hasOwnProperty('coefficients')) { + fn.exponents = def.coefficients; + fn.coefficients = def.coefficients; + fn.alpha = KGAuthor.divideDefs(fn.coefficients[0], KGAuthor.addDefs(fn.coefficients[0], fn.coefficients[1])); + } + return _this; + } + EconMultivariateFunction.prototype.value = function (x) { + return null; + }; + EconMultivariateFunction.prototype.extractLevel = function (def) { + var u = this; + if (def.hasOwnProperty('level') && def.level != undefined) { + return KGAuthor.getDefinitionProperty(def.level); + } + else if (def.hasOwnProperty('point') && def.point != undefined) { + return u.value(def.point); + } + else if (def.hasOwnProperty('budgetLine')) { + var bl = new KGAuthor.EconBudgetLine(def.budgetLine, null); + return u.value(u.optimalBundle(bl)); + } + }; + EconMultivariateFunction.prototype.levelSet = function (def) { + return []; + }; + EconMultivariateFunction.prototype.levelCurve = function (def, graph) { + def.interpolation = this.interpolation; + return KGAuthor.curvesFromFunctions(this.levelSet(def), def, graph); + }; + EconMultivariateFunction.prototype.levelCurveSlope = function (x) { + return null; + }; + EconMultivariateFunction.prototype.areaBelowLevelCurve = function (def, graph) { + var fn = this; + fn.fillBelowRect = null; + def.interpolation = fn.interpolation; + var fns = fn.levelSet(def); + var objs = []; + fns.forEach(function (fn) { + var areaDef = KGAuthor.copyJSON(def); + areaDef.univariateFunction1 = fn; + objs.push(new KGAuthor.Area(areaDef, graph)); + }); + if (fn.fillBelowRect) { + fn.fillBelowRect.show = def.show; + fn.fillBelowRect.fill = def.fill; + objs.push(new KGAuthor.Rectangle(fn.fillBelowRect, graph)); + } + return objs; + }; + EconMultivariateFunction.prototype.areaAboveLevelCurve = function (def, graph) { + var fn = this; + fn.fillAboveRect = null; + def.interpolation = fn.interpolation; + var fns = fn.levelSet(def); + var objs = []; + fns.forEach(function (fn) { + var areaDef = KGAuthor.copyJSON(def); + areaDef.univariateFunction1 = fn; + areaDef.above = true; + objs.push(new KGAuthor.Area(areaDef, graph)); + }); + if (fn.fillAboveRect) { + fn.fillAboveRect.show = def.show; + fn.fillAboveRect.fill = def.fill; + fn.fillAboveRect.inDef = true; + objs.push(new KGAuthor.Rectangle(fn.fillAboveRect, graph)); + } + var clipPathName = def.hasOwnProperty('name') ? def.name + "_above" : KG.randomString(10); + return [ + new KGAuthor.Rectangle({ + clipPathName: clipPathName, + x1: graph.def.xAxis.min, + x2: graph.def.xAxis.max, + y1: graph.def.yAxis.min, + y2: graph.def.yAxis.max, + fill: def.fill, + show: def.show + }, graph), + new KGAuthor.ClipPath({ + "name": clipPathName, + "paths": objs + }, graph) + ]; + }; + EconMultivariateFunction.prototype.lowestCostBundle = function (level, prices) { + return []; // defined at the subclass level + }; + /* Optimization with an exogenous income */ + EconMultivariateFunction.prototype.cornerCondition = function (budgetLine) { + return 'false'; + }; + EconMultivariateFunction.prototype.lagrangeBundle = function (budgetLine) { + return []; + }; + EconMultivariateFunction.prototype.optimalBundle = function (budgetLine) { + return []; + }; + EconMultivariateFunction.prototype.quantityDemanded = function (budgetLine, good) { + return this.optimalBundle(budgetLine)[good - 1]; + }; + EconMultivariateFunction.prototype.priceOfferFunction = function (budgetLine, good, min, max, graph) { + var u = this; + var blDef; + if (budgetLine.hasOwnProperty('point') && budgetLine.point != undefined) { + min = 0.01; + max = 0.99; + blDef = { + p1: '(t)', + p2: '1 - (t)', + m: budgetLine.point[0] + "*(t) + " + budgetLine.point[1] + "*(1-(t))" + }; + } + else { + blDef = (good == 1) ? { p1: '(t)', p2: budgetLine.p2, m: budgetLine.m } : { + p1: budgetLine.p1, + p2: '(t)', + m: budgetLine.m + }; + } + var optimalBundle = u.optimalBundle(new KGAuthor.EconBudgetLine(blDef, graph)); + return [ + { + xFunction: optimalBundle[0], + yFunction: optimalBundle[1], + min: min, + max: max, + samplePoints: 100, + parametric: true + } + ]; + }; + EconMultivariateFunction.prototype.priceOfferCurve = function (budgetLine, good, min, max, def, graph) { + var u = this; + def.interpolation = 'curveMonotoneX'; + return KGAuthor.curvesFromFunctions(u.priceOfferFunction(budgetLine, good, min, max, graph), def, graph); + }; + EconMultivariateFunction.prototype.demandFunction = function (budgetLine, good, graph) { + var u = this, blDef = (good == 1) ? { p1: '(y)', p2: budgetLine.p2, m: budgetLine.m } : { + p1: budgetLine.p1, + p2: '(y)', + m: budgetLine.m + }; + return [ + { + "fn": u.quantityDemanded(new KGAuthor.EconBudgetLine(blDef, graph), good), + "ind": "y", + "samplePoints": 30 + } + ]; + }; + EconMultivariateFunction.prototype.demandCurve = function (budgetLine, good, def, graph) { + var u = this; + def.interpolation = 'curveMonotoneX'; + return KGAuthor.curvesFromFunctions(u.demandFunction(budgetLine, good, graph), def, graph); + }; + /* Net demand and supply from an endowment */ + EconMultivariateFunction.prototype.endowmentDemandFunction = function (budgetLine, good, graph) { + var u = this; + var netDemand = '', netSupply = '', grossDemand = ''; + var x1 = budgetLine.point[0], x2 = budgetLine.point[1]; + if (good == 2) { + var optimalBundle = u.optimalBundle(new KGAuthor.EconBudgetLine({ + p1: budgetLine.p1, + p2: '(y)', + m: "(" + x1 + "*" + budgetLine.p1 + " + " + x2 + "*(y))" + }, graph)); + grossDemand = optimalBundle[1]; + netDemand = KGAuthor.subtractDefs(grossDemand, x2); + netSupply = KGAuthor.subtractDefs(x2, grossDemand); + } + else { + var optimalBundle = u.optimalBundle(new KGAuthor.EconBudgetLine({ + p1: '(y)', + p2: budgetLine.p2, + m: "(" + x1 + "*(y) + " + x2 + "*" + budgetLine.p2 + ")" + }, graph)); + grossDemand = optimalBundle[0]; + netDemand = KGAuthor.subtractDefs(grossDemand, x1); + netSupply = KGAuthor.subtractDefs(x1, grossDemand); + } + return { + grossDemand: [ + { + fn: grossDemand, + ind: 'y' + } + ], + netDemand: [ + { + fn: netDemand, + ind: 'y' + } + ], + netSupply: [ + { + fn: netSupply, + ind: 'y' + } + ] + }; + }; + EconMultivariateFunction.prototype.grossDemandCurve = function (budgetLine, good, def, graph) { + var u = this; + def.interpolation = 'curveMonotoneX'; + return KGAuthor.curvesFromFunctions(u.endowmentDemandFunction(budgetLine, good, graph).grossDemand, def, graph); + }; + EconMultivariateFunction.prototype.netDemandCurve = function (budgetLine, good, def, graph) { + var u = this; + def.interpolation = 'curveMonotoneX'; + return KGAuthor.curvesFromFunctions(u.endowmentDemandFunction(budgetLine, good, graph).netDemand, def, graph); + }; + EconMultivariateFunction.prototype.netSupplyCurve = function (budgetLine, good, def, graph) { + var u = this; + def.interpolation = 'curveMonotoneX'; + return KGAuthor.curvesFromFunctions(u.endowmentDemandFunction(budgetLine, good, graph).netSupply, def, graph); + }; + EconMultivariateFunction.prototype.indirectUtility = function (income, prices) { + return this.extractLevel({ budgetLine: { p1: prices[0], p2: prices[1], m: income } }); + }; + EconMultivariateFunction.prototype.expenditure = function (level, prices) { + var b = this.lowestCostBundle(level, prices); + return KGAuthor.addDefs(KGAuthor.multiplyDefs(b[0], prices[0]), KGAuthor.multiplyDefs(b[1], prices[1])); + }; + EconMultivariateFunction.prototype.laborRequirement = function (level, capital) { + // defined at subclass level + }; + return EconMultivariateFunction; + }(KGAuthor.AuthoringObject)); + KGAuthor.EconMultivariateFunction = EconMultivariateFunction; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var CobbDouglasFunction = /** @class */ (function (_super) { + __extends(CobbDouglasFunction, _super); + function CobbDouglasFunction() { + return _super !== null && _super.apply(this, arguments) || this; + } + CobbDouglasFunction.prototype.value = function (x) { + var e = this.exponents, scalar = this.coefficients.length == 1 ? this.coefficients[0] : 1; + return "(" + scalar + "*(" + x[0] + ")^(" + e[0] + "))*((" + x[1] + ")^(" + e[1] + "))"; + }; + CobbDouglasFunction.prototype.levelSet = function (def) { + var e = this.exponents, scalar = this.coefficients.length == 1 ? this.coefficients[0] : 1, level = KGAuthor.divideDefs(this.extractLevel(def), scalar), xMin = "(" + level + ")^(1/(" + e[0] + " + " + e[1] + "))", yMin = "(" + level + ")^(1/(" + e[0] + " + " + e[1] + "))"; + this.fillBelowRect = { + x1: 0, + x2: xMin, + y1: 0, + y2: yMin, + show: def.show + }; + return [ + { + "fn": "((" + level + ")/(y)^(" + e[1] + "))^(1/(" + e[0] + "))", + "ind": "y", + "min": yMin, + "samplePoints": 30 + }, + { + "fn": "((" + level + ")/(x)^(" + e[0] + "))^(1/(" + e[1] + "))", + "ind": "x", + "min": xMin, + "samplePoints": 30 + } + ]; + }; + CobbDouglasFunction.prototype.levelCurveSlope = function (x) { + var c = this.coefficients; + return KGAuthor.negativeDef(KGAuthor.divideDefs(KGAuthor.multiplyDefs(c[0], x[1]), KGAuthor.multiplyDefs(c[1], x[0]))); + }; + CobbDouglasFunction.prototype.optimalBundle = function (budgetLine) { + var a = this.alpha; + return [KGAuthor.multiplyDefs(a, budgetLine.xIntercept), KGAuthor.multiplyDefs(KGAuthor.subtractDefs(1, a), budgetLine.yIntercept)]; + }; + CobbDouglasFunction.prototype.lowestCostBundle = function (level, prices) { + var e = this.exponents, ratio = KGAuthor.multiplyDefs(KGAuthor.divideDefs(prices[0], prices[1]), KGAuthor.divideDefs(e[1], e[0])), scale = KGAuthor.addDefs(e[0], e[1]), scaledLevel = KGAuthor.raiseDefToDef(level, KGAuthor.divideDefs(1, scale)); + return [ + KGAuthor.divideDefs(scaledLevel, KGAuthor.raiseDefToDef(ratio, KGAuthor.divideDefs(e[1], scale))), + KGAuthor.multiplyDefs(scaledLevel, KGAuthor.raiseDefToDef(ratio, KGAuthor.divideDefs(e[0], scale))) + ]; + }; + CobbDouglasFunction.prototype.laborRequirement = function (level, capital) { + var e = this.exponents; + return "((" + level + ")/(" + capital + ")^(" + e[1] + "))^(1/(" + e[0] + "))"; + }; + return CobbDouglasFunction; + }(KGAuthor.EconMultivariateFunction)); + KGAuthor.CobbDouglasFunction = CobbDouglasFunction; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var MinFunction = /** @class */ (function (_super) { + __extends(MinFunction, _super); + function MinFunction(def) { + var _this = _super.call(this, def) || this; + var fn = _this; + fn.interpolation = 'curveLinear'; + if (def.hasOwnProperty('alpha')) { + fn.coefficients = [KGAuthor.divideDefs(0.5, def.alpha), KGAuthor.divideDefs(0.5, KGAuthor.subtractDefs(1, def.alpha))]; + } + return _this; + } + MinFunction.prototype.value = function (x) { + var c = this.coefficients; + console.log('foo'); + return "(min((" + x[0] + ")*(" + c[0] + "),(" + x[1] + ")*(" + c[1] + ")))"; + }; + MinFunction.prototype.levelSet = function (def) { + var c = this.coefficients, level = def.level || this.value(def.point), xMin = KGAuthor.divideDefs(level, c[0]), yMin = KGAuthor.divideDefs(level, c[1]); + this.fillBelowRect = { + x1: 0, + x2: xMin, + y1: 0, + y2: yMin, + show: def.show + }; + return [ + { + "fn": KGAuthor.divideDefs(level, c[1]), + "ind": "x", + "min": xMin, + "samplePoints": 2 + }, { + "fn": KGAuthor.divideDefs(level, c[0]), + "ind": "y", + "min": yMin, + "samplePoints": 2 + } + ]; + }; + MinFunction.prototype.optimalBundle = function (budgetLine) { + var good1perBundle = KGAuthor.invertDef(this.coefficients[0]), good2perBundle = KGAuthor.invertDef(this.coefficients[1]), bundles = KGAuthor.divideDefs(budgetLine.m, KGAuthor.addDefs(KGAuthor.multiplyDefs(budgetLine.p1, good1perBundle), KGAuthor.multiplyDefs(budgetLine.p2, good2perBundle))); + return [KGAuthor.multiplyDefs(good1perBundle, bundles), KGAuthor.multiplyDefs(good2perBundle, bundles)]; + }; + MinFunction.prototype.lowestCostBundle = function (level, prices) { + var a = this.coefficients[0], b = this.coefficients[1]; + return [ + KGAuthor.divideDefs(level, a), + KGAuthor.divideDefs(level, b) + ]; + }; + return MinFunction; + }(KGAuthor.EconMultivariateFunction)); + KGAuthor.MinFunction = MinFunction; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var LinearFunction = /** @class */ (function (_super) { + __extends(LinearFunction, _super); + function LinearFunction(def) { + var _this = _super.call(this, def) || this; + var fn = _this; + _this.interpolation = 'curveLinear'; + if (def.hasOwnProperty('alpha')) { + fn.coefficients = [def.alpha, KGAuthor.subtractDefs(1, def.alpha)]; + } + return _this; + } + LinearFunction.prototype.value = function (x) { + var c = this.coefficients; + return "((" + x[0] + ")*(" + c[0] + ")+(" + x[1] + ")*(" + c[1] + "))"; + }; + LinearFunction.prototype.levelSet = function (def) { + var c = this.coefficients, level = def.level || this.value(def.point); + return [ + { + "fn": "(" + level + " - (" + c[0] + ")*(x))/(" + c[1] + ")", + "ind": "x", + "samplePoints": 2 + } + ]; + }; + return LinearFunction; + }(KGAuthor.EconMultivariateFunction)); + KGAuthor.LinearFunction = LinearFunction; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var CESFunction = /** @class */ (function (_super) { + __extends(CESFunction, _super); + function CESFunction(def) { + var _this = _super.call(this, def) || this; + var fn = _this; + fn.interpolation = 'curveMonotoneX'; + if (def.hasOwnProperty('r')) { + fn.r = def.r; + fn.s = KGAuthor.divideDefs(1, KGAuthor.subtractDefs(1, def.r)); + } + else if (def.hasOwnProperty('s')) { + fn.s = def.s; + fn.r = KGAuthor.subtractDefs(1, KGAuthor.divideDefs(1, def.s)); + } + return _this; + } + CESFunction.prototype.value = function (x) { + var c = this.coefficients, r = this.r; + return KGAuthor.raiseDefToDef(KGAuthor.addDefs(KGAuthor.multiplyDefs(c[0], KGAuthor.raiseDefToDef(x[0], r)), KGAuthor.multiplyDefs(c[1], KGAuthor.raiseDefToDef(x[1], r))), KGAuthor.divideDefs(1, r)); + }; + CESFunction.prototype.levelSet = function (def) { + var u = this, a = KGAuthor.getDefinitionProperty(u.alpha), r = KGAuthor.getDefinitionProperty(u.r), b = KGAuthor.subtractDefs(1, u.alpha), level = this.extractLevel(def); + this.fillBelowRect = { + x1: 0, + x2: level, + y1: 0, + y2: level, + show: def.show + }; + return [ + { + fn: "((" + level + "^" + r + " - " + a + "*(x)^" + r + ")/" + b + ")^(1/" + r + ")", + ind: "x", + min: level + }, + { + fn: "((" + level + "^" + r + " - " + b + "*(y)^" + r + ")/" + a + ")^(1/" + r + ")", + ind: "y", + min: level + } + ]; + }; + // see http://www.gamsworld.org/mpsge/debreu/ces.pdf + CESFunction.prototype.optimalBundle = function (budgetLine) { + var s = this.s, oneMinusS = KGAuthor.subtractDefs(1, s), a = this.alpha, oneMinusA = KGAuthor.subtractDefs(1, a), theta = KGAuthor.divideDefs(budgetLine.m, KGAuthor.addDefs(KGAuthor.multiplyDefs(KGAuthor.raiseDefToDef(a, s), KGAuthor.raiseDefToDef(budgetLine.p1, oneMinusS)), KGAuthor.multiplyDefs(KGAuthor.raiseDefToDef(oneMinusA, s), KGAuthor.raiseDefToDef(budgetLine.p2, oneMinusS)))), optimalX1 = KGAuthor.multiplyDefs(KGAuthor.raiseDefToDef(KGAuthor.divideDefs(a, budgetLine.p1), s), theta), optimalX2 = KGAuthor.multiplyDefs(KGAuthor.raiseDefToDef(KGAuthor.divideDefs(oneMinusA, budgetLine.p2), s), theta); + return [optimalX1, optimalX2]; + }; + CESFunction.prototype.denominator = function (p1, p2) { + var a1 = this.alpha, a2 = KGAuthor.subtractDefs(1, a1), r = this.r, pOverA1 = KGAuthor.divideDefs(p1, a1), pOverA2 = KGAuthor.divideDefs(p2, a2), oneOverR = KGAuthor.divideDefs(1, r), rOverRminusOne = KGAuthor.divideDefs(r, KGAuthor.subtractDefs(r, 1)); + return KGAuthor.raiseDefToDef(KGAuthor.addDefs(KGAuthor.multiplyDefs(a1, KGAuthor.raiseDefToDef(pOverA1, rOverRminusOne)), KGAuthor.multiplyDefs(a2, KGAuthor.raiseDefToDef(pOverA2, rOverRminusOne))), oneOverR); + }; + // see http://personal.stthomas.edu/csmarcott/ec418/ces_cost_minimization.pdf + CESFunction.prototype.lowestCostBundle = function (level, prices) { + var a1 = this.alpha, a2 = KGAuthor.subtractDefs(1, a1), p1 = prices[0], p2 = prices[1], r = this.r, pOverA1 = KGAuthor.divideDefs(p1, a1), pOverA2 = KGAuthor.divideDefs(p2, a2), oneOverRminusOne = KGAuthor.divideDefs(1, KGAuthor.subtractDefs(r, 1)), denominator = this.denominator(p1, p2), numerator1 = KGAuthor.raiseDefToDef(pOverA1, oneOverRminusOne), numerator2 = KGAuthor.raiseDefToDef(pOverA2, oneOverRminusOne); + return [ + KGAuthor.divideDefs(KGAuthor.multiplyDefs(level, numerator1), denominator), + KGAuthor.divideDefs(KGAuthor.multiplyDefs(level, numerator2), denominator) + ]; + }; + return CESFunction; + }(KGAuthor.EconMultivariateFunction)); + KGAuthor.CESFunction = CESFunction; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var ConcaveFunction = /** @class */ (function (_super) { + __extends(ConcaveFunction, _super); + function ConcaveFunction() { + return _super !== null && _super.apply(this, arguments) || this; + } + ConcaveFunction.prototype.value = function (x) { + var c = this.coefficients; + return "(" + c[0] + ")*(" + x[0] + ")^2+(" + c[1] + ")*(" + x[1] + ")^2"; + }; + ConcaveFunction.prototype.levelSet = function (def) { + var c = this.coefficients, level = def.level || this.value(def.point), max = "((" + level + ")/(" + c[0] + "+" + c[1] + "))^(0.5)"; + this.fillAboveRect = { + x1: max, + x2: 50, + y1: max, + y2: 50, + show: def.show + }; + return [ + { + "fn": "((" + level + "-(" + c[1] + ")*(y)*(y))/(" + c[0] + "))^(0.5)", + "ind": "y", + "min": 0, + "max": max, + "samplePoints": 30 + }, + { + "fn": "((" + level + "-(" + c[0] + ")*(x)*(x))/(" + c[1] + "))^(0.5)", + "ind": "x", + "min": 0, + "max": max, + "samplePoints": 30 + } + ]; + }; + return ConcaveFunction; + }(KGAuthor.EconMultivariateFunction)); + KGAuthor.ConcaveFunction = ConcaveFunction; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var QuasilinearFunction = /** @class */ (function (_super) { + __extends(QuasilinearFunction, _super); + function QuasilinearFunction() { + return _super !== null && _super.apply(this, arguments) || this; + } + QuasilinearFunction.prototype.value = function (x) { + var c = this.coefficients; + return "(" + c[0] + "*log(" + x[0] + ")+" + x[1] + ")"; + }; + QuasilinearFunction.prototype.levelSet = function (def) { + var c = this.coefficients, level = this.extractLevel(def); + return [ + { + "fn": "((" + level + ")-(" + c[0] + ")*log((x)))", + "ind": "x", + "samplePoints": 100 + } + ]; + }; + QuasilinearFunction.prototype.cornerCondition = function (budgetLine) { + return "(" + this.lagrangeBundle(budgetLine)[1] + " < 0)"; + }; + QuasilinearFunction.prototype.lagrangeBundle = function (budgetLine) { + var c = this.coefficients; + return [KGAuthor.divideDefs(KGAuthor.multiplyDefs(c[0], budgetLine.p2), budgetLine.p1), KGAuthor.subtractDefs(budgetLine.yIntercept, c[0])]; + }; + QuasilinearFunction.prototype.optimalBundle = function (budgetLine) { + var lagr = this.lagrangeBundle(budgetLine), cornerCondition = this.cornerCondition(budgetLine); + return ["(" + cornerCondition + " ? " + budgetLine.xIntercept + " : " + lagr[0] + ")", "(" + cornerCondition + " ? 0 : " + lagr[1] + ")"]; + }; + return QuasilinearFunction; + }(KGAuthor.EconMultivariateFunction)); + KGAuthor.QuasilinearFunction = QuasilinearFunction; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + function extractBudgetLine(def, graph) { + if (def.hasOwnProperty('budgetLineObject')) { + return def.budgetLineObject; + } + if (def.hasOwnProperty('budgetLine')) { + var budgetDef = JSON.parse(JSON.stringify(def.budgetLine)); + budgetDef.show = budgetDef.show || def.show; + if (!budgetDef.hasOwnProperty('m')) { + if (def.hasOwnProperty('point') && def.point.length == 2) { + budgetDef.point = def.point; + } + if (def.hasOwnProperty('coordinates') && def.coordinates.length == 2) { + budgetDef.point = def.coordinates; + } + if (def.hasOwnProperty('x') && def.hasOwnProperty('y')) { + budgetDef.x = def.x; + budgetDef.y = def.y; + } + } + budgetDef.color = budgetDef.color || def.color; + return new EconBudgetLine(budgetDef, graph); + } + //console.log('tried to instantiate a budget line without either a budget line def or object') + } + KGAuthor.extractBudgetLine = extractBudgetLine; + var EconBudgetLine = /** @class */ (function (_super) { + __extends(EconBudgetLine, _super); + function EconBudgetLine(def, graph) { + var _this = this; + def = KGAuthor.setStrokeColor(def); + def.name = def.name || 'BL' + KG.randomString(5); + // may define income either by income m or value of endowment point + if (!def.hasOwnProperty('m')) { + if (def.hasOwnProperty('x') && def.hasOwnProperty('y')) { + def.point = [def.x, def.y]; + } + if (def.hasOwnProperty('point') && def.point.length == 2) { + def.m = KGAuthor.addDefs(KGAuthor.multiplyDefs(def.p1, def.point[0]), KGAuthor.multiplyDefs(def.p2, def.point[1])); + } + } + var xIntercept = KGAuthor.divideDefs(def.m, def.p1), yIntercept = KGAuthor.divideDefs(def.m, def.p2), priceRatio = KGAuthor.divideDefs(def.p1, def.p2), endowment = { x: def.x, y: def.y }; + console.log('xIntercept', xIntercept); + if (def.inMap) { + def.strokeWidth = 1; + def.lineStyle = 'dotted'; + def.layer = 0; + def.handles = false; + def.draggable = false; + } + KG.setDefaults(def, { + a: ["calcs." + def.name + ".xIntercept", 0], + b: [0, "calcs." + def.name + ".yIntercept"], + color: 'colors.budget', + strokeWidth: 2, + lineStyle: 'solid', + buyOnly: false, + sellOnly: false + }); + if (def.sellOnly) { + def.a = [def.x, def.y]; + } + if (def.buyOnly) { + def.b = [def.x, def.y]; + } + if (def.draggable && typeof (def.m) == 'string') { + def.drag = [{ + 'directions': 'xy', + 'param': KGAuthor.paramName(def.m), + 'expression': KGAuthor.addDefs(KGAuthor.multiplyDefs('drag.x', def.p1), KGAuthor.multiplyDefs('drag.y', def.p2)) + }]; + } + if (!def.inMap) { + def.label = KG.setDefaults(def.label || {}, { + text: "BL", + location: def.sellOnly ? 0.1 : 0.9 + }); + } + _this = _super.call(this, def, graph) || this; + var bl = _this; + bl.p1 = def.p1; + bl.p2 = def.p2; + bl.m = def.m; + bl.xIntercept = xIntercept; + bl.yIntercept = yIntercept; + bl.priceRatio = priceRatio; + bl.point = def.point; + bl.endowment = endowment; + if (graph) { + var subObjects = bl.subObjects; + var xInterceptPointDef = { + coordinates: ["calcs." + bl.name + ".xIntercept", 0], + fill: def.stroke, + r: 4 + }; + if (def.draggable && typeof (def.p1) == 'string') { + xInterceptPointDef['drag'] = [{ + directions: 'x', + param: KGAuthor.paramName(def.p1), + expression: KGAuthor.divideDefs("calcs." + bl.name + ".m", 'drag.x') + }]; + } + if (def.hasOwnProperty('xInterceptLabel')) { + xInterceptPointDef['droplines'] = { + vertical: def.xInterceptLabel + }; + } + bl.xInterceptPoint = new KGAuthor.Point(xInterceptPointDef, graph); + var yInterceptPointDef = { + coordinates: [0, "calcs." + bl.name + ".yIntercept"], + fill: def.stroke, + r: 4 + }; + if (def.draggable && typeof (def.p2) == 'string') { + yInterceptPointDef['drag'] = [{ + directions: 'y', + param: KGAuthor.paramName(def.p2), + expression: KGAuthor.divideDefs('calcs.' + bl.name + '.m', 'drag.y') + }]; + } + if (def.hasOwnProperty('yInterceptLabel')) { + yInterceptPointDef['droplines'] = { + horizontal: def.yInterceptLabel + }; + } + bl.yInterceptPoint = new KGAuthor.Point(yInterceptPointDef, graph); + bl.budgetSetArea = new KGAuthor.Area({ + fill: "colors.budget", + univariateFunction1: { + fn: "calcs." + bl.name + ".yIntercept - calcs." + bl.name + ".priceRatio*(x)", + samplePoints: 2, + max: "calcs." + bl.name + ".xIntercept" + }, + show: def.set + }, graph); + bl.costlierArea = new KGAuthor.Area({ + fill: "colors.costlier", + univariateFunction1: { + fn: "calcs." + bl.name + ".yIntercept - calcs." + bl.name + ".priceRatio*(x)", + samplePoints: 2 + }, + show: def.costlier, + above: true + }, graph); + if (def.handles) { + subObjects.push(bl.xInterceptPoint); + subObjects.push(bl.yInterceptPoint); + } + if (def.set) { + subObjects.push(bl.budgetSetArea); + } + if (def.costlier) { + subObjects.push(bl.costlierArea); + } + } + return _this; + } + EconBudgetLine.prototype.cost = function (bundle) { + var c = "((" + this.p1 + ")*(" + bundle.x + ") + (" + this.p2 + ")*(" + bundle.y + "))"; + //console.log(c); + return c; + }; + EconBudgetLine.prototype.parseSelf = function (parsedData) { + var bl = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + parsedData.calcs[bl.name] = { + xIntercept: bl.xIntercept.toString(), + yIntercept: bl.yIntercept.toString(), + m: bl.m.toString(), + p1: bl.p1.toString(), + p2: bl.p2.toString(), + priceRatio: bl.priceRatio.toString(), + endowment: bl.endowment.toString() + }; + return parsedData; + }; + return EconBudgetLine; + }(KGAuthor.Segment)); + KGAuthor.EconBudgetLine = EconBudgetLine; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + function getUtilityFunction(def) { + if (def != undefined) { + def = KGAuthor.extractTypeAndDef(def); + if (def.type == 'CobbDouglas') { + return new KGAuthor.CobbDouglasFunction(def.def); + } + else if (def.type == 'Substitutes' || def.type == 'PerfectSubstitutes') { + return new KGAuthor.LinearFunction(def.def); + } + else if (def.type == 'Complements' || def.type == 'PerfectComplements') { + return new KGAuthor.MinFunction(def.def); + } + else if (def.type == 'Concave') { + return new KGAuthor.ConcaveFunction(def.def); + } + else if (def.type == 'Quasilinear') { + return new KGAuthor.QuasilinearFunction(def.def); + } + else if (def.type == 'CESFunction' || def.type == 'CES') { + return new KGAuthor.CESFunction(def.def); + } + } + } + KGAuthor.getUtilityFunction = getUtilityFunction; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + function extractIndifferenceCurve(def, graph) { + if (def.hasOwnProperty('indifferenceCurveObject')) { + return def.indifferenceCurveObject; + } + if (def.hasOwnProperty('indifferenceCurve')) { + var indifferenceCurveDef = KGAuthor.copyJSON(def.indifferenceCurve); + indifferenceCurveDef.show = indifferenceCurveDef.show || def.show; + indifferenceCurveDef.name = def.name + "_IC"; + return new EconIndifferenceCurve(indifferenceCurveDef, graph); + } + console.log('tried to instantiate a budget line without either a budget line def or object'); + } + KGAuthor.extractIndifferenceCurve = extractIndifferenceCurve; + var EconIndifferenceCurve = /** @class */ (function (_super) { + __extends(EconIndifferenceCurve, _super); + function EconIndifferenceCurve(def, graph) { + var _this = this; + if (def.inMap) { + def.strokeWidth = 1; + def.color = 'lightgrey'; + def.layer = 0; + } + KG.setDefaults(def, { + strokeWidth: 2, + color: 'colors.utility', + layer: 1, + showPreferred: false, + showDispreferred: false, + inMap: false, + showMapLevels: false + }); + if (def.inMap) { + if (def.showMapLevels) { + def.label = KG.setDefaults(def.label || {}, { + fontSize: 8, + x: KGAuthor.multiplyDefs(0.98, graph.xScale.max), + text: def.level + ".toFixed(0)", + color: def.color, + bgcolor: null + }); + } + } + else { + def.label = KG.setDefaults(def.label || {}, { + x: KGAuthor.multiplyDefs(0.95, graph.xScale.max), + text: "U", + color: def.color, + bgcolor: null, + position: 'bl' + }); + } + _this = _super.call(this, def, graph) || this; + var curve = _this; + var utilityFunction = KGAuthor.extractUtilityFunction(def); + curve.utilityFunction = utilityFunction; + curve.subObjects = curve.subObjects.concat(utilityFunction.levelCurve(def, graph)); + if (!def.inMap) { + if (!!def.showPreferred) { + var preferredDef = KGAuthor.copyJSON(def); + preferredDef.fill = def.color || 'colors.preferred'; + preferredDef.show = def.showPreferred; + curve.subObjects = curve.subObjects.concat(utilityFunction.areaAboveLevelCurve(preferredDef, graph)); + } + if (!!def.showDispreferred) { + var dispreferredDef = KGAuthor.copyJSON(def); + dispreferredDef.fill = 'colors.dispreferred'; + dispreferredDef.show = def.showDispreferred; + curve.subObjects = curve.subObjects.concat(utilityFunction.areaBelowLevelCurve(dispreferredDef, graph)); + } + } + return _this; + } + return EconIndifferenceCurve; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.EconIndifferenceCurve = EconIndifferenceCurve; + var EconIndifferenceMap = /** @class */ (function (_super) { + __extends(EconIndifferenceMap, _super); + function EconIndifferenceMap(def, graph) { + var _this = _super.call(this, def, graph) || this; + _this.subObjects = def.levels.map(function (level) { + var icDef = KGAuthor.copyJSON(def); + icDef.inMap = true; + delete icDef.levels; + if (Array.isArray(level)) { + icDef.point = level; + } + else { + icDef.level = level; + } + return new EconIndifferenceCurve(icDef, graph); + }); + return _this; + } + return EconIndifferenceMap; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.EconIndifferenceMap = EconIndifferenceMap; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + function extractUtilityFunction(def) { + return def.utilityFunctionObject || KGAuthor.getUtilityFunction(def.utilityFunction); + } + KGAuthor.extractUtilityFunction = extractUtilityFunction; + var EconBundle = /** @class */ (function (_super) { + __extends(EconBundle, _super); + function EconBundle(def, graph) { + var _this = this; + KG.setDefaults(def, { + label: { text: 'X' }, + droplines: { + vertical: "x_1", + horizontal: "x_2" + }, + color: "colors.utility" + }); + KGAuthor.setFillColor(def); + _this = _super.call(this, def, graph) || this; + var bundle = _this; + bundle.budgetLine = KGAuthor.extractBudgetLine(def, graph); + if (bundle.budgetLine) { + bundle.subObjects.push(bundle.budgetLine); + } + bundle.utilityFunction = extractUtilityFunction(def); + if (bundle.utilityFunction) { + bundle.subObjects.push(bundle.utilityFunction); + if (def.hasOwnProperty('indifferenceCurve')) { + def.indifferenceCurve.level = "calcs." + bundle.name + ".level"; + def.indifferenceCurve.utilityFunction = def.utilityFunction; + bundle.subObjects.push(KGAuthor.extractIndifferenceCurve(def, graph)); + } + } + return _this; + } + EconBundle.prototype.parseSelf = function (parsedData) { + var bundle = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + parsedData.calcs[bundle.name] = { + x: bundle.x, + y: bundle.y, + level: bundle.utilityFunction ? bundle.utilityFunction.value([bundle.x, bundle.y]) : '', + cost: bundle.budgetLine ? bundle.budgetLine.cost(bundle) : '', + mrs: bundle.utilityFunction ? KGAuthor.negativeDef(bundle.utilityFunction.levelCurveSlope([bundle.x, bundle.y])) : '' + }; + return parsedData; + }; + return EconBundle; + }(KGAuthor.Point)); + KGAuthor.EconBundle = EconBundle; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconOptimalBundle = /** @class */ (function (_super) { + __extends(EconOptimalBundle, _super); + function EconOptimalBundle(def, graph) { + var _this = this; + var bl = KGAuthor.extractBudgetLine(def, graph), u = KGAuthor.extractUtilityFunction(def), coords = u.optimalBundle(bl); + KG.setDefaults(def, { + coordinates: coords, + label: { text: 'X^*' }, + color: bl.color, + droplines: { + vertical: "x_1^*", + horizontal: "x_2^*" + }, + indifferenceCurve: {} + }); + console.log('coords: ', coords); + if (bl.hasOwnProperty('endowment')) { + if (bl.def.sellOnly) { + def.show = "(" + (def.show || true) + " && (" + coords[0] + " < " + bl.endowment.x + "))"; + } + if (bl.def.buyOnly) { + def.show = "(" + (def.show || true) + " && (" + coords[0] + " > " + bl.endowment.x + "))"; + } + } + def.budgetLineObject = bl; + _this = _super.call(this, def, graph) || this; + _this.level = u.value(coords); + return _this; + } + return EconOptimalBundle; + }(KGAuthor.EconBundle)); + KGAuthor.EconOptimalBundle = EconOptimalBundle; + var EconLagrangeBundle = /** @class */ (function (_super) { + __extends(EconLagrangeBundle, _super); + function EconLagrangeBundle(def, graph) { + var _this = this; + if (def.hasOwnProperty('utilityFunction') && def.hasOwnProperty('budgetLine')) { + var u = KGAuthor.getUtilityFunction(def.utilityFunction), bl = new KGAuthor.EconBudgetLine(def.budgetLine, graph); + KG.setDefaults(def, { + coordinates: u.lagrangeBundle(bl), + color: 'colors.incomeOffer', + show: u.cornerCondition(bl), + label: { text: 'X^*_L' } + }); + } + else { + console.log('oops, need to define an EconOptimalBundle with a utility function and budget line.'); + } + _this = _super.call(this, def, graph) || this; + return _this; + } + return EconLagrangeBundle; + }(EconOptimalBundle)); + KGAuthor.EconLagrangeBundle = EconLagrangeBundle; + var LowestCostBundle = /** @class */ (function (_super) { + __extends(LowestCostBundle, _super); + function LowestCostBundle(def, graph) { + var _this = this; + var u = KGAuthor.extractUtilityFunction(def), p1 = def.prices[0], p2 = def.prices[1], m = u.expenditure(def.level, def.prices); + delete def.prices; + delete def.level; + def.budgetLine = KG.setDefaults(def.budgetLine || {}, { + p1: p1, + p2: p2, + m: m + }); + _this = _super.call(this, def, graph) || this; + return _this; + } + return LowestCostBundle; + }(EconOptimalBundle)); + KGAuthor.LowestCostBundle = LowestCostBundle; + var EconSlutskyBundle = /** @class */ (function (_super) { + __extends(EconSlutskyBundle, _super); + function EconSlutskyBundle(def, graph) { + var _this = this; + var bl = KGAuthor.extractBudgetLine(def, graph), u = KGAuthor.extractUtilityFunction(def); + def.budgetLine = def.budgetLine || {}; + if (def.hasOwnProperty('p1')) { + def.budgetLine.p1 = def.p1; + delete def.budgetLine.m; + } + if (def.hasOwnProperty('p2')) { + def.budgetLine.p2 = def.p2; + delete def.budgetLine.m; + } + def.budgetLine.label = KG.setDefaults(def.budgetLine.label || {}, { + text: "BL_D" + }); + def.budgetLine.point = u.optimalBundle(bl); + delete def.budgetLineObject; + _this = _super.call(this, def, graph) || this; + return _this; + } + return EconSlutskyBundle; + }(EconOptimalBundle)); + KGAuthor.EconSlutskyBundle = EconSlutskyBundle; + var EconHicksBundle = /** @class */ (function (_super) { + __extends(EconHicksBundle, _super); + function EconHicksBundle(def, graph) { + var _this = this; + var bl = KGAuthor.extractBudgetLine(def, graph), u = KGAuthor.extractUtilityFunction(def), p1 = def.hasOwnProperty('p1') ? def.p1 : def.budgetLine.p1, p2 = def.hasOwnProperty('p2') ? def.p2 : def.budgetLine.p2, level = u.value(u.optimalBundle(bl)); + def.budgetLine.p1 = p1; + def.budgetLine.p2 = p2; + def.budgetLine.m = u.expenditure(level, [p1, p2]); + def.budgetLine.label = KG.setDefaults(def.budgetLine.label || {}, { + text: "BL_C" + }); + def.coordinates = u.lowestCostBundle(level, [p1, p2]); + delete def.budgetLineObject; + _this = _super.call(this, def, graph) || this; + return _this; + } + return EconHicksBundle; + }(EconOptimalBundle)); + KGAuthor.EconHicksBundle = EconHicksBundle; + var EconShortRunProductionBundle = /** @class */ (function (_super) { + __extends(EconShortRunProductionBundle, _super); + function EconShortRunProductionBundle(def, graph) { + var _this = this; + var u = KGAuthor.extractUtilityFunction(def), p1 = def.prices[0], p2 = def.prices[1]; + def.coordinates = [u.laborRequirement(def.level, def.capital), def.capital]; + def.budgetLine = KG.setDefaults(def.budgetLine || {}, { + p1: p1, + p2: p2 + }); + def.budgetLine.label = KG.setDefaults(def.budgetLine.label || {}, { + text: "c_s(y)" + }); + delete def.budgetLineObject; + _this = _super.call(this, def, graph) || this; + return _this; + } + return EconShortRunProductionBundle; + }(KGAuthor.EconBundle)); + KGAuthor.EconShortRunProductionBundle = EconShortRunProductionBundle; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconDemandCurve = /** @class */ (function (_super) { + __extends(EconDemandCurve, _super); + function EconDemandCurve(def, graph) { + var _this = this; + var u = KGAuthor.getUtilityFunction(def.utilityFunction), bl = new KGAuthor.EconBudgetLine(def.budgetLine, graph); + KG.setDefaults(def, { + stroke: 'colors.demand', + strokeWidth: 2 + }); + _this = _super.call(this, def, graph) || this; + _this.subObjects = u.demandCurve(bl, def.good, def, graph); + return _this; + } + return EconDemandCurve; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.EconDemandCurve = EconDemandCurve; + var EconDemandPoint = /** @class */ (function (_super) { + __extends(EconDemandPoint, _super); + function EconDemandPoint(def, graph) { + var _this = this; + if (def.hasOwnProperty('utilityFunction') && def.hasOwnProperty('budgetLine')) { + var u = KGAuthor.getUtilityFunction(def.utilityFunction), bl = new KGAuthor.EconBudgetLine(def.budgetLine, graph); + KG.setDefaults(def, { + coordinates: [u.quantityDemanded(bl, def.good), bl['p' + def.good]], + fill: 'colors.demand', + label: { text: "x_" + def.good + "(p_" + def.good + "|p_" + (3 - def.good) + ",m)" }, + droplines: { vertical: "x_" + def.good + "^*" } + }); + } + else { + console.log('oops, need to define an EconOptimalBundle with a utility function and budget line.'); + } + _this = _super.call(this, def, graph) || this; + return _this; + } + return EconDemandPoint; + }(KGAuthor.Point)); + KGAuthor.EconDemandPoint = EconDemandPoint; + var EconNetDemandCurve = /** @class */ (function (_super) { + __extends(EconNetDemandCurve, _super); + function EconNetDemandCurve(def, graph) { + var _this = this; + var u = KGAuthor.getUtilityFunction(def.utilityFunction), bl = new KGAuthor.EconBudgetLine(def.budgetLine, graph); + KG.setDefaults(def, { + color: 'colors.demand', + strokeWidth: 2 + }); + _this = _super.call(this, def, graph) || this; + _this.subObjects = u.netDemandCurve(bl, def.good, def, graph); + return _this; + } + return EconNetDemandCurve; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.EconNetDemandCurve = EconNetDemandCurve; + var EconNetDemandPoint = /** @class */ (function (_super) { + __extends(EconNetDemandPoint, _super); + function EconNetDemandPoint(def, graph) { + var _this = this; + if (def.hasOwnProperty('utilityFunction') && def.hasOwnProperty('budgetLine')) { + var u = KGAuthor.getUtilityFunction(def.utilityFunction), bl = new KGAuthor.EconBudgetLine(def.budgetLine, graph); + KG.setDefaults(def, { + coordinates: [KGAuthor.subtractDefs(u.quantityDemanded(bl, def.good), bl.point[def.good - 1]), bl['p' + def.good]], + fill: 'colors.demand', + label: { text: "d_" + def.good + "(p_" + def.good + "|p_" + (3 - def.good) + ")" }, + droplines: { vertical: "d_" + def.good + "^*" } + }); + } + else { + console.log('oops, need to define an EconOptimalBundle with a utility function and budget line.'); + } + _this = _super.call(this, def, graph) || this; + return _this; + } + return EconNetDemandPoint; + }(KGAuthor.Point)); + KGAuthor.EconNetDemandPoint = EconNetDemandPoint; + var EconNetSupplyCurve = /** @class */ (function (_super) { + __extends(EconNetSupplyCurve, _super); + function EconNetSupplyCurve(def, graph) { + var _this = this; + var u = KGAuthor.getUtilityFunction(def.utilityFunction), bl = new KGAuthor.EconBudgetLine(def.budgetLine, graph); + KG.setDefaults(def, { + color: 'colors.supply', + strokeWidth: 2 + }); + _this = _super.call(this, def, graph) || this; + _this.subObjects = u.netSupplyCurve(bl, def.good, def, graph); + return _this; + } + return EconNetSupplyCurve; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.EconNetSupplyCurve = EconNetSupplyCurve; + var EconNetSupplyPoint = /** @class */ (function (_super) { + __extends(EconNetSupplyPoint, _super); + function EconNetSupplyPoint(def, graph) { + var _this = this; + if (def.hasOwnProperty('utilityFunction') && def.hasOwnProperty('budgetLine')) { + var u = KGAuthor.getUtilityFunction(def.utilityFunction), bl = new KGAuthor.EconBudgetLine(def.budgetLine, graph); + KG.setDefaults(def, { + coordinates: [KGAuthor.subtractDefs(bl.point[def.good - 1], u.quantityDemanded(bl, def.good)), bl['p' + def.good]], + fill: 'colors.supply', + label: { text: "s_" + def.good + "(p_" + def.good + "|p_" + (3 - def.good) + ")" }, + droplines: { vertical: "s_" + def.good + "^*" } + }); + } + else { + console.log('oops, need to define an EconOptimalBundle with a utility function and budget line.'); + } + _this = _super.call(this, def, graph) || this; + return _this; + } + return EconNetSupplyPoint; + }(KGAuthor.Point)); + KGAuthor.EconNetSupplyPoint = EconNetSupplyPoint; + var EconPriceOfferCurve = /** @class */ (function (_super) { + __extends(EconPriceOfferCurve, _super); + function EconPriceOfferCurve(def, graph) { + var _this = this; + var u = KGAuthor.getUtilityFunction(def.utilityFunction), bl = new KGAuthor.EconBudgetLine(def.budgetLine, graph); + KG.setDefaults(def, { + stroke: 'colors.offer', + strokeWidth: 2 + }); + _this = _super.call(this, def, graph) || this; + _this.subObjects = u.priceOfferCurve(bl, def.good, def.min, def.max, def, graph); + return _this; + } + return EconPriceOfferCurve; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.EconPriceOfferCurve = EconPriceOfferCurve; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconOneInputProductionFunction = /** @class */ (function (_super) { + __extends(EconOneInputProductionFunction, _super); + function EconOneInputProductionFunction(def, graph) { + var _this = this; + KG.setDefaults(def, { + coefficient: 1, + exponent: 0.5, + wage: 1, + price: 1 + }); + _this = _super.call(this, def) || this; + var f = _this; + f.coefficient = def.coefficient; + f.exponent = def.exponent; + f.wage = def.wage; + f.price = def.price; + // if y(L) = AL^b, L(y) = [A^(-1/b)] * y^[1/b] + f.laborRequirementExponent = KGAuthor.invertDef(def.exponent); + f.laborRequirementCoefficient = KGAuthor.raiseDefToDef(def.coefficient, KGAuthor.negativeDef(f.laborRequirementExponent)); + // if f(L) = AL^b, f'(L) = [bA] * L^[b-1] + f.marginalProductExponent = KGAuthor.subtractDefs(def.exponent, 1); + f.marginalProductCoefficient = KGAuthor.multiplyDefs(def.exponent, def.coefficient); + // if c(y) = wL(y) = w*LRC * y^LRE, c'(y) = [w*LRC*LRE] * y^[LRE - 1] + f.marginalCostCoefficient = KGAuthor.multiplyDefs(def.wage, KGAuthor.multiplyDefs(f.laborRequirementExponent, f.laborRequirementCoefficient)); + f.marginalCostExponent = KGAuthor.subtractDefs(f.laborRequirementExponent, 1); + // if c'(y) = MCC * y^MCE, y*(p) = MCC^(-1/MCE) * p^(1/MCE) + f.outputSupplyCoefficient = KGAuthor.raiseDefToDef(f.marginalCostCoefficient, KGAuthor.negativeDef(KGAuthor.invertDef(f.marginalCostExponent))); + f.outputSupplyExponent = KGAuthor.invertDef(f.marginalCostExponent); + // if MRPL = [p * MPC] * L^MPE, L*(w) = (p*MPC)^(-1/MPE) * w^(1/MPE) + f.laborDemandCoefficient = KGAuthor.raiseDefToDef(KGAuthor.multiplyDefs(f.price, f.marginalProductCoefficient), KGAuthor.negativeDef(KGAuthor.invertDef(f.marginalProductExponent))); + f.laborDemandExponent = KGAuthor.invertDef(f.marginalProductExponent); + return _this; + } + // output produced by L units of olabor + EconOneInputProductionFunction.prototype.f = function (L) { + var f = this; + return KGAuthor.multiplyDefs(f.coefficient, KGAuthor.raiseDefToDef(L, f.exponent)); + }; + // labor required to produce y units of output + EconOneInputProductionFunction.prototype.laborRequirement = function (y) { + var f = this; + return KGAuthor.multiplyDefs(f.laborRequirementCoefficient, KGAuthor.raiseDefToDef(y, f.laborRequirementExponent)); + }; + // marginal product of labor + EconOneInputProductionFunction.prototype.MPL = function (L) { + var f = this; + return KGAuthor.multiplyDefs(f.marginalProductCoefficient, KGAuthor.raiseDefToDef(L, f.marginalProductExponent)); + }; + // marginal revenue product of labor is price times MPL + EconOneInputProductionFunction.prototype.MRPL = function (L) { + var f = this; + return KGAuthor.multiplyDefs(f.price, f.MPL(L)); + }; + // cost is wage times labor requirement + EconOneInputProductionFunction.prototype.cost = function (y) { + var f = this; + return KGAuthor.multiplyDefs(f.wage, f.laborRequirement(y)); + }; + EconOneInputProductionFunction.prototype.marginalCost = function (y) { + var f = this; + return KGAuthor.multiplyDefs(f.marginalCostCoefficient, KGAuthor.raiseDefToDef(y, f.marginalCostExponent)); + }; + // labor demand + EconOneInputProductionFunction.prototype.laborDemand = function (w) { + var f = this; + return KGAuthor.multiplyDefs(f.laborDemandCoefficient, KGAuthor.raiseDefToDef(w, f.laborDemandExponent)); + }; + // optimal output + EconOneInputProductionFunction.prototype.optimalOutput = function (p) { + var f = this; + return KGAuthor.multiplyDefs(f.outputSupplyCoefficient, KGAuthor.raiseDefToDef(p, f.outputSupplyCoefficient)); + }; + EconOneInputProductionFunction.prototype.parseSelf = function (parsedData) { + var ppf = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + parsedData.calcs[ppf.name] = { + coefficient: ppf.coefficient, + exponent: ppf.exponent, + curve: ppf.f('(x)') + }; + return parsedData; + }; + return EconOneInputProductionFunction; + }(KGAuthor.AuthoringObject)); + KGAuthor.EconOneInputProductionFunction = EconOneInputProductionFunction; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconLinearDemand = /** @class */ (function (_super) { + __extends(EconLinearDemand, _super); + function EconLinearDemand(def, graph) { + var _this = this; + def = KGAuthor.setStrokeColor(def); + KG.setDefaults(def, { + name: "demand", + point: [0, def.yIntercept], + slope: 0, + color: 'colors.demand', + strokeWidth: 2, + lineStyle: 'solid', + pts: [] + }); + if (def.draggable && typeof (def.xIntercept) == 'string') { + def.drag = [{ + 'directions': 'x', + 'param': KGAuthor.paramName(def.xIntercept), + 'expression': KGAuthor.addDefs(def.xIntercept, 'drag.dx') + }]; + } + else if (def.draggable && typeof (def.yIntercept) == 'string') { + def.drag = [{ + 'directions': 'y', + 'param': KGAuthor.paramName(def.yIntercept), + 'expression': KGAuthor.addDefs(def.yIntercept, 'drag.dy') + }]; + } + def.max = def.xIntercept; + if (def.hasOwnProperty("price")) { + def.pts.push({ + name: "PQ", + y: def.price + }); + } + if (def.hasOwnProperty("surplus")) { + if (!def.hasOwnProperty("price") && def.surplus.hasOwnProperty("quantity")) { + def.pts.push({ + name: "PQ", + x: def.surplus.quantity + }); + } + } + _this = _super.call(this, def, graph) || this; + var ld = _this; + if (graph) { + var subObjects = ld.subObjects; + var xInterceptPointDef = { + coordinates: [ld.xIntercept, 0], + color: def.color, + r: 4 + }; + if (def.draggable && typeof (ld.xIntercept) == 'string') { + xInterceptPointDef['drag'] = [{ + directions: 'x', + param: KGAuthor.paramName(ld.xIntercept), + expression: KGAuthor.addDefs(ld.xIntercept, 'drag.dx') + }]; + } + if (def.hasOwnProperty('xInterceptLabel')) { + xInterceptPointDef['droplines'] = { + vertical: def.xInterceptLabel + }; + } + ld.xInterceptPoint = new KGAuthor.Point(xInterceptPointDef, graph); + var yInterceptPointDef = { + coordinates: [0, ld.yIntercept], + color: def.color, + r: 4 + }; + if (def.draggable && typeof (ld.yIntercept) == 'string') { + yInterceptPointDef['drag'] = [{ + directions: 'y', + param: KGAuthor.paramName(ld.invSlope), + expression: KGAuthor.negativeDef(KGAuthor.divideDefs(ld.xIntercept, 'drag.y')) + }]; + } + if (def.hasOwnProperty('yInterceptLabel')) { + yInterceptPointDef['droplines'] = { + horizontal: def.yInterceptLabel + }; + } + ld.yInterceptPoint = new KGAuthor.Point(yInterceptPointDef, graph); + if (def.handles) { + subObjects.push(ld.xInterceptPoint); + subObjects.push(ld.yInterceptPoint); + } + if (def.hasOwnProperty('marginalRevenue')) { + var marginalRevenueDef = KG.setDefaults(def.marginalRevenue || {}, { + "color": "colors.marginalRevenue", + "yIntercept": ld.yIntercept, + "slope": KGAuthor.multiplyDefs(2, ld.slope), + "label": { + "text": "MR", + "x": KGAuthor.multiplyDefs(0.6, ld.xIntercept) + } + }); + ld.marginalRevenue = new KGAuthor.Line(marginalRevenueDef, graph); + ld.subObjects.push(ld.marginalRevenue); + } + if (def.hasOwnProperty('surplus')) { + var surplusDef = KG.setDefaults(def.surplus || {}, { + "fill": "colors.demand" + }); + var price = def.price || "calcs." + ld.name + ".PQ.y", quantity = surplusDef.quantity || "calcs." + ld.name + ".PQ.x"; + surplusDef.univariateFunction1 = { + fn: ld.def.univariateFunction.fn, + min: 0, + max: quantity, + samplePoints: 2 + }; + surplusDef.univariateFunction2 = { + fn: price, + min: 0, + max: quantity, + samplePoints: 2 + }; + ld.subObjects.push(new KGAuthor.Area(surplusDef, graph)); + } + } + return _this; + } + return EconLinearDemand; + }(KGAuthor.Line)); + KGAuthor.EconLinearDemand = EconLinearDemand; + var EconCompetitiveDemand = /** @class */ (function (_super) { + __extends(EconCompetitiveDemand, _super); + function EconCompetitiveDemand() { + return _super !== null && _super.apply(this, arguments) || this; + } + return EconCompetitiveDemand; + }(EconLinearDemand)); + KGAuthor.EconCompetitiveDemand = EconCompetitiveDemand; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconLinearSupply = /** @class */ (function (_super) { + __extends(EconLinearSupply, _super); + function EconLinearSupply(def, graph) { + var _this = this; + def = KGAuthor.setStrokeColor(def); + KG.setDefaults(def, { + name: 'supply', + color: 'colors.supply', + strokeWidth: 2, + lineStyle: 'solid', + pts: [] + }); + if (def.draggable && typeof (def.slope) == 'string') { + def.drag = [{ + 'directions': 'xy', + 'param': KGAuthor.paramName(def.slope), + 'expression': KGAuthor.divideDefs(KGAuthor.subtractDefs('drag.y', def.yIntercept), 'drag.x') + }]; + } + else if (def.draggable && typeof (def.invSlope) == 'string') { + def.drag = [{ + 'directions': 'xy', + 'param': KGAuthor.paramName(def.invSlope), + 'expression': KGAuthor.divideDefs('drag.x', KGAuthor.subtractDefs('drag.y', def.yIntercept)) + }]; + } + else if (def.draggable && typeof (def.yIntercept) == 'string') { + def.drag = [{ + 'directions': 'y', + 'param': KGAuthor.paramName(def.yIntercept), + 'expression': KGAuthor.addDefs(def.yIntercept, 'drag.dy') + }]; + } + if (def.hasOwnProperty("price")) { + def.pts.push({ + name: "PQ", + y: def.price + }); + } + _this = _super.call(this, def, graph) || this; + var ls = _this; + if (graph) { + var subObjects = ls.subObjects; + var yInterceptPointDef = { + coordinates: [0, ls.yIntercept], + color: def.color, + r: 4 + }; + if (def.draggable && typeof (ls.yIntercept) == 'string') { + yInterceptPointDef['drag'] = [{ + directions: 'y', + param: KGAuthor.paramName(ls.yIntercept), + expression: KGAuthor.addDefs(ls.yIntercept, 'drag.dy') + }]; + } + if (def.hasOwnProperty('yInterceptLabel')) { + yInterceptPointDef['droplines'] = { + horizontal: def.yInterceptLabel + }; + } + ls.yInterceptPoint = new KGAuthor.Point(yInterceptPointDef, graph); + if (def.handles) { + subObjects.push(ls.yInterceptPoint); + } + if (def.hasOwnProperty('surplus')) { + var surplusDef = KG.setDefaults(def.surplus || {}, { + "fill": "colors.supply" + }); + var price = def.price || "calcs." + ls.name + ".PQ.y", quantity = surplusDef.quantity || "calcs." + ls.name + ".PQ.x"; + surplusDef.univariateFunction1 = { + fn: ls.def.univariateFunction.fn, + min: 0, + max: quantity, + samplePoints: 2 + }; + surplusDef.univariateFunction2 = { + fn: price, + min: 0, + max: quantity, + samplePoints: 2 + }; + ls.subObjects.push(new KGAuthor.Area(surplusDef, graph)); + } + } + return _this; + } + return EconLinearSupply; + }(KGAuthor.Line)); + KGAuthor.EconLinearSupply = EconLinearSupply; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconLinearEquilibrium = /** @class */ (function (_super) { + __extends(EconLinearEquilibrium, _super); + function EconLinearEquilibrium(def, graph) { + var _this = this; + KG.setDefaults(def, { + name: 'equilibrium', + showCS: false, + showPS: false + }); + _this = _super.call(this, def, graph) || this; + var le = _this; + def.demand.price = "calcs." + le.name + ".P"; + def.supply.price = "calcs." + le.name + ".P"; + le.demand = new KGAuthor.EconLinearDemand(def.demand, graph); + le.supply = new KGAuthor.EconLinearSupply(def.supply, graph); + le.subObjects.push(_this.demand); + le.subObjects.push(_this.supply); + var eq = KGAuthor.lineIntersection(le.demand, le.supply); + le.Q = eq[0]; + le.P = eq[1]; + if (graph) { + if (def.hasOwnProperty('equilibrium')) { + def.equilibrium = KG.setDefaults(def.equilibrium, { + "color": "colors.equilibriumPrice", + "x": le.Q, + "y": le.P, + "droplines": { + "vertical": "Q^*", + "horizontal": "P^*" + } + }); + le.subObjects.push(new KGAuthor.Point(def.equilibrium, graph)); + } + } + return _this; + } + EconLinearEquilibrium.prototype.parseSelf = function (parsedData) { + var le = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + parsedData.calcs[le.name] = { + Q: le.Q.toString(), + P: le.P.toString() + }; + return parsedData; + }; + return EconLinearEquilibrium; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.EconLinearEquilibrium = EconLinearEquilibrium; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconPPF = /** @class */ (function (_super) { + __extends(EconPPF, _super); + function EconPPF(def, graph) { + var _this = this; + def = KGAuthor.setStrokeColor(def); + KG.setDefaults(def, { + name: 'ppf', + color: 'colors.supply', + strokeWidth: 2, + lineStyle: 'solid', + labor: 100, + L1: 50, + p1: 1, + p2: 1, + max1: 100, + max2: 100, + curvature: 0.5 + }); + if (def.linear) { + def.curvature = 1; + } + var fn1coeff = KGAuthor.divideDefs(def.max1, KGAuthor.raiseDefToDef(def.labor, def.curvature)), fn2coeff = KGAuthor.divideDefs(def.max2, KGAuthor.raiseDefToDef(def.labor, def.curvature)); + var fn1 = new KGAuthor.EconOneInputProductionFunction({ + name: def.name + '_prodFn1', + coefficient: fn1coeff, + exponent: def.curvature + }), fn2 = new KGAuthor.EconOneInputProductionFunction({ + name: def.name + '_prodFn2', + coefficient: fn2coeff, + exponent: def.curvature + }); + def.parametricFunction = { + xFunction: fn1.f("(t)"), + yFunction: fn2.f(KGAuthor.subtractDefs(def.labor, "(t)")), + max: def.labor + }; + if (def.draggable) { + var dragLaborRequirement = KGAuthor.addDefs(fn1.laborRequirement('drag.x'), fn2.laborRequirement('drag.y')); + def.drag = [{ + 'directions': 'xy', + 'param': KGAuthor.paramName(def.max1), + 'expression': fn1.f(dragLaborRequirement) + }, + { + 'directions': 'xy', + 'param': KGAuthor.paramName(def.max2), + 'expression': fn2.f(dragLaborRequirement) + }]; + } + _this = _super.call(this, def, graph) || this; + var ppf = _this; + ppf.labor = def.labor; + ppf.prodFn1 = fn1; + ppf.prodFn2 = fn2; + ppf.subObjects.push(fn1); + ppf.subObjects.push(fn2); + ppf.L1 = def.L1; + ppf.L2 = KGAuthor.subtractDefs(def.labor, def.L1); + ppf.y1 = ppf.prodFn1.f(ppf.L1); + ppf.y2 = ppf.prodFn2.f(ppf.L2); + var coefficientRatio = KGAuthor.divideDefs(def.max2, def.max1), laborRatio = KGAuthor.divideDefs(ppf.L2, def.L1), priceRatio = KGAuthor.divideDefs(def.p1, def.p2); + if (def.curvature == 1) { + ppf.mrt = coefficientRatio; + ppf.optimalL1 = "((" + coefficientRatio + " > " + priceRatio + ") ? 0 : " + ppf.labor + ")"; + ppf.optimalL1 = "((" + coefficientRatio + " > " + priceRatio + ") ? " + ppf.labor + " : 0)"; + } + else { + ppf.mrt = KGAuthor.multiplyDefs(coefficientRatio, KGAuthor.raiseDefToDef(laborRatio, KGAuthor.subtractDefs(def.curvature, 1))); + var theta = KGAuthor.raiseDefToDef(KGAuthor.divideDefs(coefficientRatio, priceRatio), KGAuthor.invertDef(KGAuthor.subtractDefs(def.curvature, 1))); + ppf.optimalL1 = KGAuthor.multiplyDefs(KGAuthor.divideDefs(theta, KGAuthor.addDefs(1, theta)), ppf.labor); + ppf.optimalL2 = KGAuthor.multiplyDefs(KGAuthor.divideDefs(1, KGAuthor.addDefs(1, theta)), ppf.labor); + } + ppf.optimaly1 = ppf.prodFn1.f(ppf.optimalL1); + ppf.optimaly2 = ppf.prodFn2.f(ppf.optimalL2); + if (graph) { + var subObjects = ppf.subObjects; + var xInterceptPointDef = { + coordinates: [def.max1, 0], + fill: def.stroke, + r: 4 + }; + if (def.draggable && typeof (def.max1) == 'string') { + xInterceptPointDef['drag'] = [{ + directions: 'x', + param: KGAuthor.paramName(def.max1), + expression: KGAuthor.addDefs(def.max1, 'drag.dx') + }]; + } + if (def.hasOwnProperty('xInterceptLabel')) { + xInterceptPointDef['droplines'] = { + vertical: def.xInterceptLabel + }; + } + ppf.xInterceptPoint = new KGAuthor.Point(xInterceptPointDef, graph); + var yInterceptPointDef = { + coordinates: [0, def.max2], + fill: def.stroke, + r: 4 + }; + if (def.draggable && typeof (def.max2) == 'string') { + yInterceptPointDef['drag'] = [{ + directions: 'y', + param: KGAuthor.paramName(def.max2), + expression: KGAuthor.addDefs(def.max2, 'drag.dy') + }]; + } + if (def.hasOwnProperty('yInterceptLabel')) { + yInterceptPointDef['droplines'] = { + horizontal: def.yInterceptLabel + }; + } + ppf.yInterceptPoint = new KGAuthor.Point(yInterceptPointDef, graph); + if (def.handles) { + subObjects.push(ppf.xInterceptPoint); + subObjects.push(ppf.yInterceptPoint); + } + } + return _this; + } + EconPPF.prototype.parseSelf = function (parsedData) { + var ppf = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + parsedData.calcs[ppf.name] = { + L1: ppf.L1, + L2: ppf.L2, + y1: ppf.y1, + y2: ppf.y2, + optimalL1: ppf.optimalL1, + optimalL2: ppf.optimalL2, + optimaly1: ppf.optimaly1, + optimaly2: ppf.optimaly2, + mrt: ppf.mrt + }; + return parsedData; + }; + return EconPPF; + }(KGAuthor.Curve)); + KGAuthor.EconPPF = EconPPF; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconLinearMC = /** @class */ (function (_super) { + __extends(EconLinearMC, _super); + function EconLinearMC(def, graph) { + return _super.call(this, def, graph) || this; + } + return EconLinearMC; + }(KGAuthor.EconLinearSupply)); + KGAuthor.EconLinearMC = EconLinearMC; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconLinearMonopoly = /** @class */ (function (_super) { + __extends(EconLinearMonopoly, _super); + function EconLinearMonopoly(def, graph) { + var _this = this; + KG.setDefaults(def, { + name: 'monopoly', + showCS: false, + showPS: false, + showProfit: false + }); + _this = _super.call(this, def, graph) || this; + var lm = _this; + def.demand.price = "calcs." + lm.name + ".P"; + def.cost.price = "calcs." + lm.name + ".P"; + if (def.cost.hasOwnProperty('surplus')) { + def.cost.surplus.quantity = "calcs." + lm.name + ".Q"; + } + lm.demand = new KGAuthor.EconLinearDemand(def.demand, graph); + lm.cost = new KGAuthor.EconLinearMC(def.cost, graph); + var intersectMRMC = KGAuthor.lineIntersection(lm.demand.marginalRevenue, lm.cost); + lm.Q = intersectMRMC[0]; + lm.P = lm.demand.yOfX(lm.Q); + lm.MRMC = + lm.subObjects.push(_this.demand); + lm.subObjects.push(_this.cost); + if (graph) { + } + return _this; + } + EconLinearMonopoly.prototype.parseSelf = function (parsedData) { + var lm = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + parsedData.calcs[lm.name] = { + Q: lm.Q.toString(), + P: lm.P.toString() + }; + return parsedData; + }; + return EconLinearMonopoly; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.EconLinearMonopoly = EconLinearMonopoly; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var ExchangeEquilibriumBundle = /** @class */ (function (_super) { + __extends(ExchangeEquilibriumBundle, _super); + function ExchangeEquilibriumBundle(def, graph) { + var _this = this; + var agentA = new KGAuthor.EconBundle(def.agentA, graph), agentB = new KGAuthor.EconBundle(def.agentB, graph); + var p; + if (def.agentA.utilityFunction.type == 'CobbDouglas' && def.agentB.utilityFunction.type == 'CobbDouglas') { + var alphaW2 = function (agent) { + return KGAuthor.multiplyDefs(agent.y, agent.utilityFunction.alpha); + }, oneMinusAlphaW1 = function (agent) { + return KGAuthor.multiplyDefs(agent.x, KGAuthor.subtractDefs(1, agent.utilityFunction.alpha)); + }; + p = KGAuthor.divideDefs(KGAuthor.addDefs(alphaW2(agentA), alphaW2(agentB)), KGAuthor.addDefs(oneMinusAlphaW1(agentA), oneMinusAlphaW1(agentB))); + } + else { + console.log("We're just handling Edgeworth equilibrium with Cobb-Douglas so far..."); + } + KG.setDefaults(def, { + label: { text: 'E' }, + color: "colors.budget" + }); + def.utilityFunctionObject = agentA.utilityFunction; + def.budgetLine = { + p1: p, + p2: 1, + point: [agentA.x, agentA.y] + }; + _this = _super.call(this, def, graph) || this; + return _this; + } + return ExchangeEquilibriumBundle; + }(KGAuthor.EconOptimalBundle)); + KGAuthor.ExchangeEquilibriumBundle = ExchangeEquilibriumBundle; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconContractCurve = /** @class */ (function (_super) { + __extends(EconContractCurve, _super); + function EconContractCurve(def, graph) { + var _this = this; + var a = def.a, b = def.b, ab = KGAuthor.multiplyDefs(a, b), aMinusABtimesX = KGAuthor.multiplyDefs(KGAuthor.subtractDefs(a, ab), def.totalGood1), bMinusABtimesY = KGAuthor.multiplyDefs(KGAuthor.subtractDefs(b, ab), def.totalGood2), bMinusA = KGAuthor.subtractDefs(b, a), fnString = bMinusABtimesY + "*(x)/(" + aMinusABtimesX + " + " + bMinusA + "*(x))"; + def.univariateFunction = { fn: fnString }; + KG.setDefaults(def, { + interpolation: 'curveMonotoneX', + color: 'colors.budget' + }); + _this = _super.call(this, def, graph) || this; + _this.fnString = fnString; + return _this; + } + EconContractCurve.prototype.parseSelf = function (parsedData) { + var cc = this; + parsedData = _super.prototype.parseSelf.call(this, parsedData); + parsedData.calcs['cc'] = cc.fnString; + return parsedData; + }; + return EconContractCurve; + }(KGAuthor.Curve)); + KGAuthor.EconContractCurve = EconContractCurve; +})(KGAuthor || (KGAuthor = {})); +/// +var KGAuthor; +(function (KGAuthor) { + var EconParetoLens = /** @class */ (function (_super) { + __extends(EconParetoLens, _super); + function EconParetoLens(def, graph) { + var _this = _super.call(this, def, graph) || this; + _this.subObjects.push(new KGAuthor.Rectangle({ + clipPathName: def.bundleA + "_IC_above", + clipPathName2: def.bundleB + "_IC_above", + x1: graph.def.xAxis.min, + x2: graph.def.xAxis.max, + y1: graph.def.yAxis.min, + y2: graph.def.yAxis.max, + fill: "colors.paretoLens", + opacity: "0.2", + show: def.show + }, graph)); + return _this; + } + return EconParetoLens; + }(KGAuthor.GraphObjectGenerator)); + KGAuthor.EconParetoLens = EconParetoLens; +})(KGAuthor || (KGAuthor = {})); +/// +/* SCHEMAS */ +/// +/// +/* LAYOUTS */ +/// +/* FUNCTIONAL FORMS */ +/// +/// +/// +/// +/// +/// +/// +/* MICRO */ +/* Consumer Theory */ +/// +/// +/// +/// +/// +/// +/* Producer Theory */ +/// +/* Equilibrium */ +/// +/// +/// +/// +/* Monopoly */ +/// +/// +/* Exchange */ +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +var KG; +(function (KG) { + var Model = /** @class */ (function () { + function Model(parsedData) { + var model = this; + model.params = parsedData.params.map(function (def) { + return new KG.Param(def); + }); + model.calcs = parsedData.calcs; + model.colors = parsedData.colors; + model.restrictions = (parsedData.restrictions || []).map(function (def) { + return new KG.Restriction(def); + }); + model.updateListeners = []; + model.currentParamValues = model.evalParams(); + model.evalCalcs(); + model.currentColors = model.evalObject(model.colors); + } + Model.prototype.addUpdateListener = function (updateListener) { + this.updateListeners.push(updateListener); + return this; + }; + Model.prototype.evalParams = function () { + var p = {}; + this.params.forEach(function (param) { + p[param.name] = param.value; + }); + return p; + }; + // evaluates the calcs object; then re-evaluates to capture calcs that depend on other calcs + Model.prototype.evalCalcs = function () { + var model = this; + // clear calculatios so old values aren't used; + model.currentCalcValues = {}; + // generate as many calculations from params as possible + model.currentCalcValues = model.evalObject(model.calcs, true); + // calculate values based on other calculations (up to a depth of 5) + for (var i = 0; i < 5; i++) { + for (var calcName in model.currentCalcValues) { + if (typeof model.calcs[calcName] == 'object') { + model.currentCalcValues[calcName] = model.evalObject(model.calcs[calcName], true); + } + else if (isNaN(model.currentCalcValues[calcName]) && typeof model.calcs[calcName] == 'string') { + model.currentCalcValues[calcName] = model.evaluate(model.calcs[calcName], true); + } + } + } + return model.currentCalcValues; + }; + Model.prototype.evalObject = function (obj, onlyJSMath) { + var model = this; + var newObj = {}; + for (var stringOrObj in obj) { + var def = obj[stringOrObj]; + if (typeof def === 'string') { + newObj[stringOrObj] = model.evaluate(def, onlyJSMath); + } + else { + newObj[stringOrObj] = model.evalObject(def, onlyJSMath); + } + } + return newObj; + }; + // the model serves as a model, and can evaluate expressions within the context of that model + // if onlyJSMath is selected, it will only try to evaluate using JSMath; this is especially important for calculations. + Model.prototype.evaluate = function (name, onlyJSMath) { + var model = this; + // don't just evaluate numbers + if (!isNaN(parseFloat(name))) { + //console.log('interpreted ', name, 'as a number.'); + return parseFloat(name); + } + // collect current values in a scope object + var params = model.currentParamValues, calcs = model.currentCalcValues, colors = model.currentColors; + // try to evaluate using mathjs + try { + var compiledMath = math.compile(name); + var result = compiledMath.evaluate({ + params: params, + calcs: calcs, + colors: colors + }); + //console.log('parsed', name, 'as a pure math expression with value', result); + return result; + } + catch (err) { + // if that doesn't work, try to evaluate using native js eval + //console.log('unable to parse', name, 'as a pure math function, trying general eval'); + if (onlyJSMath) { + return name; + } + else { + try { + var result = eval(name); + //console.log('parsed', name, 'as an expression with value', result); + return result; + } + catch (err) { + //console.log('unable to parse', name, 'as a valid expression; generates error:', err.message); + return name; + } + } + } + }; + // This is a utility for exporting currently used colors for use in LaTex documents. + Model.prototype.latexColors = function () { + var result = '%% econ colors %%\n', model = this; + for (var color in model.colors) { + result += "\\definecolor{" + color + "}{HTML}{" + model.evaluate(model.colors[color]).replace('#', '') + "}\n"; + } + console.log(result); + }; + Model.prototype.getParam = function (paramName) { + var params = this.params; + for (var i = 0; i < params.length; i++) { + if (params[i].name == paramName) { + return params[i]; + } + } + }; + // method exposed to viewObjects to allow them to try to change a parameter + Model.prototype.updateParam = function (name, newValue) { + var model = this, param = model.getParam(name); + var oldValue = param.value; + param.update(newValue); + // if param has changed, check to make sure the change is val + if (oldValue != param.value) { + //restrictions aren't working right now + var valid_1 = true; + model.restrictions.forEach(function (r) { + if (!r.valid(model)) { + valid_1 = false; + } + }); + if (valid_1) { + model.update(false); + } + else { + param.update(oldValue); + } + model.update(false); + } + }; + // method exposed to viewObjects to allow them to toggle a binary param + Model.prototype.toggleParam = function (name) { + var currentValue = this.getParam(name).value; + this.updateParam(name, !currentValue); + }; + // method exposed to viewObjects to allow them to cycle a discrete param + // increments by 1 if below max value, otherwise sets to zero + Model.prototype.cycleParam = function (name) { + var param = this.getParam(name); + this.updateParam(name, param.value < param.max ? param.value++ : 0); + }; + Model.prototype.update = function (force) { + var model = this; + model.currentParamValues = model.evalParams(); + model.evalCalcs(); + console.log('calcs', model.currentCalcValues); + model.currentColors = model.evalObject(model.colors); + model.updateListeners.forEach(function (listener) { + listener.update(force); + }); + }; + return Model; + }()); + KG.Model = Model; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Param = /** @class */ (function () { + function Param(def) { + function decimalPlaces(numAsString) { + var match = ('' + numAsString).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); + if (!match) { + return 0; + } + return Math.max(0, + // Number of digits right of decimal point. + (match[1] ? match[1].length : 0) + // Adjust for scientific notation. + - (match[2] ? +match[2] : 0)); + } + KG.setDefaults(def, { min: 0, max: 10, round: 1, label: '' }); + this.name = def.name; + this.label = def.label; + if (typeof def.value == 'boolean') { + this.value = +def.value; + this.min = 0; + this.max = 100; + this.round = 1; + } + else { + this.value = parseFloat(def.value); + this.min = parseFloat(def.min); + this.max = parseFloat(def.max); + this.round = parseFloat(def.round); + this.precision = parseInt(def.precision) || decimalPlaces(this.round.toString()); + } + } + // Receives an instruction to update the parameter to a new value + // Updates to the closest rounded value to the desired newValue within accepted range + Param.prototype.update = function (newValue) { + var param = this; + if (newValue < param.min) { + param.value = param.min; + } + else if (newValue > param.max) { + param.value = param.max; + } + else { + param.value = Math.round(newValue / param.round) * param.round; + } + return param.value; + }; + // Displays current value of the parameter to desired precision + // If no precision is given, uses the implied precision given by the rounding parameter + Param.prototype.formatted = function (precision) { + precision = precision || this.precision; + return d3.format("." + precision + "f")(this.value); + }; + return Param; + }()); + KG.Param = Param; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Restriction = /** @class */ (function () { + function Restriction(def) { + this.expression = def.expression; + this.type = def.type; + this.min = def.min; + this.max = def.max; + } + Restriction.prototype.valid = function (model) { + var r = this, value = model.evaluate(r.expression), min = model.evaluate(r.min), max = model.evaluate(r.max); + // restrictions aren't working right now + return true; + //return (value >= min && value <= max); + }; + return Restriction; + }()); + KG.Restriction = Restriction; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + function randomString(length) { + var text = "KGID_"; + var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + for (var i = 0; i < length; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return text; + } + KG.randomString = randomString; + var UpdateListener = /** @class */ (function () { + function UpdateListener(def) { + def.constants = (def.constants || []).concat(['model', 'updatables', 'name']); + var ul = this; + ul.def = def; + def.constants.forEach(function (c) { + ul[c] = isNaN(parseFloat(def[c])) ? def[c] : +def[c]; + }); + ul.id = randomString(10); + ul.model.addUpdateListener(this); + } + UpdateListener.prototype.updateArray = function (a) { + var u = this; + return a.map(function (d) { + if (Array.isArray(d)) { + return u.updateArray(d); + } + else { + var initialValue = d; + var newValue = u.model.evaluate(d); + if (initialValue != newValue) { + u.hasChanged = true; + } + return newValue; + } + }); + }; + UpdateListener.prototype.updateDef = function (name) { + var u = this; + if (u.def.hasOwnProperty(name)) { + var d = u.def[name], initialValue = u[name]; + if (Array.isArray(d)) { + u[name] = u.updateArray(d); + } + else { + var newValue = u.model.evaluate(d); + if (initialValue != newValue) { + u.hasChanged = true; + u[name] = newValue; + } + } + //console.log(u.constructor['name'],name,'changed from',initialValue,'to',u[name]); + } + return u; + }; + UpdateListener.prototype.update = function (force) { + var u = this; + u.hasChanged = !!force; + if (u.hasOwnProperty('updatables') && u.updatables != undefined) { + u.updatables.forEach(function (name) { + u.updateDef(name); + }); + } + return u; + }; + return UpdateListener; + }()); + KG.UpdateListener = UpdateListener; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var MathFunction = /** @class */ (function (_super) { + __extends(MathFunction, _super); + function MathFunction(def) { + var _this = this; + KG.setDefaults(def, { + samplePoints: 50 + }); + KG.setProperties(def, 'constants', ['samplePoints']); + KG.setProperties(def, 'updatables', ['min', 'max']); + _this = _super.call(this, def) || this; + return _this; + } + MathFunction.prototype.updateFunctionString = function (str, scope) { + function getCalc(o, s) { + s = s.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties + s = s.replace(/^\./, ''); // strip a leading dot + var a = s.split('.'); + for (var i = 0, n = a.length; i < n; ++i) { + var k = a[i]; + if (k in o) { + o = o[k]; + } + else { + return; + } + } + return o; + } + str = str.toString(); + if (str.indexOf('null') > -1 || str.indexOf('Infinity') > -1) { + return null; + } + var re = /((calcs|params).[.\w]*)+/g; + var references = str.match(re); + if (references) { + references.forEach(function (name) { + str = KGAuthor.replaceVariable(str, name, getCalc(scope, name)); + }); + } + //console.log('updated function to ',str); + return str; + }; + return MathFunction; + }(KG.UpdateListener)); + KG.MathFunction = MathFunction; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var MathFunction = KG.MathFunction; + var UnivariateFunction = /** @class */ (function (_super) { + __extends(UnivariateFunction, _super); + function UnivariateFunction(def) { + var _this = this; + KG.setDefaults(def, { + ind: 'x' + }); + KG.setProperties(def, 'constants', ['fn', 'yFn']); + KG.setProperties(def, 'updatables', ['ind', 'min', 'max']); + _this = _super.call(this, def) || this; + _this.fnStringDef = def.fn; + _this.fnZStringDef = def.fnZ; + _this.yFnStringDef = def.yFn; + _this.yFnZStringDef = def.yFnZ; + return _this; + } + UnivariateFunction.prototype.evaluate = function (input, z) { + var fn = this; + if (z) { + if (fn.hasOwnProperty('yzCompiledFunction') && fn.ind == 'y') { + return fn.yzCompiledFunction.evaluate({ y: input }); + } + else if (fn.hasOwnProperty('zCompiledFunction') && fn.ind == 'y') { + return fn.zCompiledFunction.evaluate({ y: input }); + } + else if (fn.hasOwnProperty('zCompiledFunction')) { + return fn.zCompiledFunction.evaluate({ x: input }); + } + } + else { + if (fn.hasOwnProperty('yCompiledFunction') && fn.ind == 'y') { + return fn.yCompiledFunction.evaluate({ y: input }); + } + else if (fn.hasOwnProperty('compiledFunction') && fn.ind == 'y') { + return fn.compiledFunction.evaluate({ y: input }); + } + else if (fn.hasOwnProperty('compiledFunction')) { + return fn.compiledFunction.evaluate({ x: input }); + } + } + }; + UnivariateFunction.prototype.generateData = function (min, max) { + var fn = this, data = []; + if (undefined != fn.min) { + min = fn.min; + } + if (undefined != fn.max) { + max = fn.max; + } + for (var i = 0; i < fn.samplePoints + 1; i++) { + var a = i / fn.samplePoints, input = a * min + (1 - a) * max, output = fn.evaluate(input); + if (!isNaN(output) && output != Infinity && output != -Infinity) { + data.push((fn.ind == 'x') ? { x: input, y: output } : { x: output, y: input }); + } + } + this.data = data; + return data; + }; + UnivariateFunction.prototype.mathboxFn = function () { + var fn = this; + return function (emit, x) { + var y = fn.evaluate(x), z = fn.evaluate(x, true); + if (y <= 50 && z <= 50) { + emit(y, z, x); + } + }; + }; + UnivariateFunction.prototype.update = function (force) { + var fn = _super.prototype.update.call(this, force); + //console.log('updating; currently ', fn.fnString); + fn.scope = { + params: fn.model.currentParamValues, + calcs: fn.model.currentCalcValues, + colors: fn.model.currentColors + }; + var originalString = fn.fnString; + if (originalString != fn.updateFunctionString(fn.fnStringDef, fn.scope)) { + fn.hasChanged = true; + fn.fnString = fn.updateFunctionString(fn.fnStringDef, fn.scope); + fn.compiledFunction = math.compile(fn.fnString); + } + if (fn.def.hasOwnProperty('yFn')) { + if (fn.yFnString != fn.updateFunctionString(fn.yFnStringDef, fn.scope)) { + fn.hasChanged = true; + fn.yFnString = fn.updateFunctionString(fn.yFnStringDef, fn.scope); + fn.yCompiledFunction = math.compile(fn.yFnString); + } + } + if (fn.def.hasOwnProperty('fnZ')) { + if (fn.fnZString != fn.updateFunctionString(fn.fnZStringDef, fn.scope)) { + fn.hasChanged = true; + fn.fnZString = fn.updateFunctionString(fn.fnZStringDef, fn.scope); + fn.zCompiledFunction = math.compile(fn.fnZString); + } + } + if (fn.def.hasOwnProperty('yFnZ')) { + if (fn.yFnZString != fn.updateFunctionString(fn.yFnZStringDef, fn.scope)) { + fn.hasChanged = true; + fn.yFnZString = fn.updateFunctionString(fn.yFnZStringDef, fn.scope); + fn.yzCompiledFunction = math.compile(fn.yFnZString); + } + } + return fn; + }; + return UnivariateFunction; + }(MathFunction)); + KG.UnivariateFunction = UnivariateFunction; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var ParametricFunction = /** @class */ (function (_super) { + __extends(ParametricFunction, _super); + function ParametricFunction(def) { + var _this = this; + KG.setDefaults(def, { + min: 0, + max: 10 + }); + _this = _super.call(this, def) || this; + _this.xFunctionStringDef = def.xFunction; + _this.yFunctionStringDef = def.yFunction; + return _this; + } + ParametricFunction.prototype.evaluate = function (input) { + var fn = this; + fn.scope = fn.scope || { params: fn.model.currentParamValues }; + fn.scope.t = input; + return { x: fn.xCompiledFunction.evaluate(fn.scope), y: fn.yCompiledFunction.evaluate(fn.scope) }; + }; + ParametricFunction.prototype.generateData = function (min, max) { + var fn = this, data = []; + if (undefined != fn.min) { + min = fn.min; + } + if (undefined != fn.max) { + max = fn.max; + } + for (var i = 0; i < fn.samplePoints + 1; i++) { + var a = i / fn.samplePoints, input = a * min + (1 - a) * max, output = fn.evaluate(input); + if (!isNaN(output.x) && output.x != Infinity && output.x != -Infinity && !isNaN(output.y) && output.y != Infinity && output.y != -Infinity) { + data.push(output); + } + } + this.data = data; + return data; + }; + ParametricFunction.prototype.update = function (force) { + var fn = _super.prototype.update.call(this, force); + //console.log('updating; currently ', fn.fnString); + fn.scope = { + params: fn.model.currentParamValues, + calcs: fn.model.currentCalcValues, + colors: fn.model.currentColors + }; + var originalXFunctionString = fn.xFunctionString; + if (originalXFunctionString != fn.updateFunctionString(fn.xFunctionStringDef, fn.scope)) { + fn.hasChanged = true; + fn.xFunctionString = fn.updateFunctionString(fn.xFunctionStringDef, fn.scope); + fn.xCompiledFunction = math.compile(fn.xFunctionString); + } + var originalYFunctionString = fn.yFunctionString; + if (originalYFunctionString != fn.updateFunctionString(fn.yFunctionStringDef, fn.scope)) { + fn.hasChanged = true; + fn.yFunctionString = fn.updateFunctionString(fn.yFunctionStringDef, fn.scope); + fn.yCompiledFunction = math.compile(fn.yFunctionString); + } + return fn; + }; + return ParametricFunction; + }(KG.MathFunction)); + KG.ParametricFunction = ParametricFunction; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var MathFunction = KG.MathFunction; + var MultivariateFunction = /** @class */ (function (_super) { + __extends(MultivariateFunction, _super); + function MultivariateFunction(def) { + var _this = this; + def.samplePoints = 100; + KG.setProperties(def, 'constants', ['fn']); + _this = _super.call(this, def) || this; + _this.fnStringDef = def.fn; + _this.domainConditionStringDef = def.domainCondition; + return _this; + } + MultivariateFunction.prototype.inDomain = function (x, y, z) { + var fn = this; + if (fn.hasOwnProperty('compiledDomainCondition')) { + return fn.compiledDomainCondition.evaluate({ x: x, y: y, z: z }); + } + else { + return true; + } + }; + MultivariateFunction.prototype.evaluate = function (x, y) { + var fn = this; + if (fn.hasOwnProperty('compiledFunction')) { + var z = fn.compiledFunction.evaluate({ x: x, y: y }); + if (fn.inDomain(x, y, z)) { + return z; + } + } + }; + MultivariateFunction.prototype.mathboxFn = function () { + var fn = this; + return function (emit, x, y) { + emit(y, fn.evaluate(x, y), x); + }; + }; + MultivariateFunction.prototype.contour = function (level, xScale, yScale) { + var fn = this; + var xMax = xScale.domainMax, yMax = yScale.domainMax; + var n = 110, m = 110, values = new Array(n * m); + for (var j = 0.5, k = 0; j < m; ++j) { + for (var i = 0.5; i < n; ++i, ++k) { + var x = i * xMax * 1.1 / n, y = j * yMax * 1.1 / m; + values[k] = fn.evaluate(x, y); + } + } + var transform = function (_a) { + var type = _a.type, value = _a.value, coordinates = _a.coordinates; + return { + type: type, value: value, coordinates: coordinates.map(function (rings) { + return rings.map(function (points) { + return points.map(function (_a) { + var x = _a[0], y = _a[1]; + return ([xScale.scale(x * xMax / 100), yScale.scale(y * yMax / 100)]); + }); + }); + }) + }; + }; + var p = d3.geoPath(); + // Compute the contour polygons at log-spaced intervals; returns an array of MultiPolygon. + var contourLine = d3.contours().size([n, m]).contour(values, level); + return p(transform(contourLine)); + }; + MultivariateFunction.prototype.update = function (force) { + var fn = _super.prototype.update.call(this, force); + //console.log('updating; currently ', fn.fnString); + fn.scope = { + params: fn.model.currentParamValues, + calcs: fn.model.currentCalcValues, + colors: fn.model.currentColors + }; + var originalString = fn.fnString, originalDomainCondition = fn.domainConditionString; + if (originalString != fn.updateFunctionString(fn.fnStringDef, fn.scope)) { + fn.hasChanged = true; + fn.fnString = fn.updateFunctionString(fn.fnStringDef, fn.scope); + fn.compiledFunction = math.compile(fn.fnString); + } + if (fn.domainConditionStringDef != undefined) { + if (originalDomainCondition != fn.updateFunctionString(fn.domainConditionStringDef, fn.scope)) { + fn.hasChanged = true; + fn.domainConditionString = fn.updateFunctionString(fn.domainConditionStringDef, fn.scope); + fn.compiledDomainCondition = math.compile(fn.domainConditionString); + } + } + return fn; + }; + return MultivariateFunction; + }(MathFunction)); + KG.MultivariateFunction = MultivariateFunction; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + /* + + A listener is defined by a param and an expression. + When the interactionHandler senses a change, it generates a scope of the current state of the model. + The listener then determines the current value of its expression within the context of that scope, + and sends a signal to the model to update its param. + + */ + var Listener = /** @class */ (function (_super) { + __extends(Listener, _super); + function Listener(def) { + var _this = this; + KG.setProperties(def, 'updatables', ['expression']); + KG.setProperties(def, 'constants', ['param']); + _this = _super.call(this, def) || this; + return _this; + } + Listener.prototype.onChange = function (scope) { + var l = this, compiledMath = math.compile(l.expression); + var parsedMath = compiledMath.evaluate(scope); + l.model.updateParam(l.param, parsedMath); + }; + return Listener; + }(KG.UpdateListener)); + KG.Listener = Listener; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + /* + + A DragListener is a special kind of Listener that listens for drag events. + In addition to a param and an expression, it has properties for whether it is draggable + and, if so, in which directions it is draggable. + + */ + var DragListener = /** @class */ (function (_super) { + __extends(DragListener, _super); + function DragListener(def) { + var _this = this; + if (def.hasOwnProperty('vertical')) { + def.directions = 'y'; + def.param = def.vertical; + def.expression = "params." + def.vertical + " + drag.dy"; + } + if (def.hasOwnProperty('horizontal')) { + def.directions = 'x'; + def.param = def.horizontal; + def.expression = "params." + def.horizontal + " + drag.dx"; + } + KG.setDefaults(def, { + directions: "xy" + }); + KG.setProperties(def, 'updatables', ['draggable', 'directions']); + _this = _super.call(this, def) || this; + return _this; + } + DragListener.prototype.update = function (force) { + var dl = _super.prototype.update.call(this, force); + if (!dl.def.hasOwnProperty('draggable')) { + dl.draggable = (dl.directions.length > 0); + } + return dl; + }; + return DragListener; + }(KG.Listener)); + KG.DragListener = DragListener; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var ClickListener = /** @class */ (function (_super) { + __extends(ClickListener, _super); + function ClickListener(def) { + return _super.call(this, def) || this; + } + return ClickListener; + }(KG.Listener)); + KG.ClickListener = ClickListener; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var InteractionHandler = /** @class */ (function (_super) { + __extends(InteractionHandler, _super); + function InteractionHandler(def) { + var _this = this; + KG.setDefaults(def, { dragListeners: [], clickListeners: [] }); + KG.setProperties(def, 'constants', ["viewObject", "dragListeners", "clickListeners"]); + _this = _super.call(this, def) || this; + _this.update(true); + _this.scope = { params: {}, calcs: {}, colors: {}, drag: {} }; + return _this; + } + InteractionHandler.prototype.update = function (force) { + var ih = _super.prototype.update.call(this, force); + // first update dragListeners + if (ih.hasChanged && ih.hasOwnProperty('dragListeners') && (ih.element != undefined)) { + var xDrag_1 = false, yDrag_1 = false; + ih.dragListeners.forEach(function (dul) { + dul.update(force); + if (dul.directions == "x") { + xDrag_1 = true; + } + else if (dul.directions == "y") { + yDrag_1 = true; + } + else if (dul.directions == "xy") { + xDrag_1 = true; + yDrag_1 = true; + } + }); + ih.element.style("pointer-events", (xDrag_1 || yDrag_1) ? "all" : "none"); + ih.element.style("cursor", (xDrag_1 && yDrag_1) ? "move" : xDrag_1 ? "ew-resize" : "ns-resize"); + } + return ih; + }; + InteractionHandler.prototype.addTrigger = function (element) { + var handler = this; + handler.element = element; + // add click listeners + if (handler.clickListeners.length > 0) { + element.on("click", function () { + if (d3.event.defaultPrevented) + return; //dragged) + handler.scope.params = handler.model.currentParamValues; + handler.scope.calcs = handler.model.currentCalcValues; + handler.scope.colors = handler.model.currentColors; + handler.clickListeners.forEach(function (d) { + d.onChange(handler.scope); + }); + }); + } + // add drag listeners + if (handler.dragListeners.length > 0) { + element.call(d3.drag() + .on('start', function () { + handler.scope.params = handler.model.currentParamValues; + handler.scope.calcs = handler.model.currentCalcValues; + handler.scope.colors = handler.model.currentColors; + handler.scope.drag.x0 = handler.viewObject.xScale.scale.invert(d3.event.x); + handler.scope.drag.y0 = handler.viewObject.yScale.scale.invert(d3.event.y); + }) + .on('drag', function () { + var drag = handler.scope.drag; + drag.x = handler.viewObject.xScale.scale.invert(d3.event.x); + drag.y = handler.viewObject.yScale.scale.invert(d3.event.y); + drag.dx = drag.x - drag.x0; + drag.dy = drag.y - drag.y0; + handler.dragListeners.forEach(function (d) { + d.onChange(handler.scope); + }); + }) + .on('end', function () { + //handler.element.style("cursor","default"); + })); + } + handler.update(true); + }; + return InteractionHandler; + }(KG.UpdateListener)); + KG.InteractionHandler = InteractionHandler; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + KG.viewData = {}; + function addView(name, def) { + KG.viewData[name] = def; + } + KG.addView = addView; + var View = /** @class */ (function () { + function View(div, data) { + this.render(data, div); + } + View.prototype.parse = function (data, div) { + data.schema = data.schema || "Schema"; + data.params = (data.params || []).map(function (paramData) { + // allow author to override initial parameter values by specifying them as div attributes + if (div.hasAttribute(paramData.name)) { + paramData.value = div.getAttribute(paramData.name); + } + // convert numerical params from strings to numbers + paramData.value = isNaN(+paramData.value) ? paramData.value : +paramData.value; + return paramData; + }); + var parsedData = { + aspectRatio: data.aspectRatio || 1, + params: data.params || [], + calcs: data.calcs || {}, + colors: data.colors || {}, + restrictions: data.restrictions, + clipPaths: data.clipPaths || [], + markers: data.markers || [], + scales: data.scales || [{ + name: 'x', + axis: 'x', + rangeMin: 0, + rangeMax: 1, + domainMin: 0, + domainMax: 1 + }, + { + name: 'y', + axis: 'y', + rangeMin: 0, + rangeMax: 1, + domainMin: 0, + domainMax: 1 + }], + layers: data.layers || [[], [], [], []], + divs: data.divs || [] + }; + data.objects = data.objects || []; + if (data.hasOwnProperty('layout')) { + if (data.layout.hasOwnProperty('type')) { + data.objects.push(data.layout); + } + else { + var layoutType = Object.keys(data.layout)[0], layoutDef = data.layout[layoutType]; + data.objects.push({ type: layoutType, def: layoutDef }); + } + } + if (data.hasOwnProperty('schema')) { + data.objects.push({ type: data.schema, def: {} }); + } + return KGAuthor.parse(data.objects, parsedData); + }; + View.prototype.render = function (data, div) { + var view = this; + var parsedData = view.parse(data, div); + div.innerHTML = ""; + view.aspectRatio = parsedData.aspectRatio || 1; + view.model = new KG.Model(parsedData); + // create scales + view.scales = parsedData.scales.map(function (def) { + def.model = view.model; + return new KG.Scale(def); + }); + // create the div for the view + view.div = d3.select(div) + .style('position', 'relative'); + // create the SVG element for the view + if (!parsedData.nosvg) { + view.svg = view.div.append('svg') + .style('overflow', 'visible') + .style('pointer-events', 'none'); + } + view.addViewObjects(parsedData); + view.parsedData = parsedData; + console.log('parsedData: ', parsedData); + }; + // add view information (model, layer, scales) to an object + View.prototype.addViewToDef = function (def, layer) { + var view = this; + function getScale(name) { + var result = null; + view.scales.forEach(function (scale) { + if (scale.name == name) { + result = scale; + } + }); + return result; + } + def.model = view.model; + def.layer = layer; + def.xScale = getScale(def['xScaleName']); + def.yScale = getScale(def['yScaleName']); + if (def.hasOwnProperty('xScale2Name')) { + def.xScale2 = getScale(def['xScale2Name']); + def.yScale2 = getScale(def['yScale2Name']); + } + return def; + }; + // create view objects + View.prototype.addViewObjects = function (data) { + var view = this; + var defURLS = {}; + if (view.svg) { + var defLayer_1 = view.svg.append('defs'); + // create ClipPaths, generate their URLs, and add their paths to the SVG defs element. + if (data.clipPaths.length > 0) { + data.clipPaths.forEach(function (def) { + var clipPathURL = KG.randomString(10); + var clipPathLayer = defLayer_1.append('clipPath').attr('id', clipPathURL); + def.paths.forEach(function (td) { + td.def.inDef = true; + new KG[td.type](view.addViewToDef(td.def, clipPathLayer)); + }); + defURLS[def.name] = clipPathURL; + }); + } + // create Markers, generate their URLs, and add their paths to the SVG defs element. + if (data.markers.length > 0) { + data.markers.forEach(function (def) { + var markerURL = KG.randomString(10); + def.url = markerURL; + defURLS[def.name] = markerURL; + var markerLayer = defLayer_1.append('marker') + .attr('id', markerURL) + .attr("refX", def.refX) + .attr("refY", 6) + .attr("markerWidth", 13) + .attr("markerHeight", 13) + .attr("orient", "auto") + .attr("markerUnits", "userSpaceOnUse"); + view.addViewToDef(def, markerLayer); + new KG.Marker(def); + }); + } + // add layers of objects + data.layers.forEach(function (layerTds) { + if (layerTds.length > 0) { + var layer_1 = view.svg.append('g'); + layerTds.forEach(function (td) { + var def = td.def; + if (def.hasOwnProperty('clipPathName')) { + def.clipPath = defURLS[def['clipPathName']]; + } + if (def.hasOwnProperty('clipPathName2')) { + def.clipPath2 = defURLS[def['clipPathName2']]; + } + if (def.hasOwnProperty('startArrowName')) { + def.startArrow = defURLS[def['startArrowName']]; + } + if (def.hasOwnProperty('endArrowName')) { + def.endArrow = defURLS[def['endArrowName']]; + } + def = view.addViewToDef(def, layer_1); + new KG[td.type](def); + }); + } + }); + } + // add divs + if (data.divs.length > 0) { + data.divs.forEach(function (td) { + var def = view.addViewToDef(td.def, view.div), newDiv = new KG[td.type](def); + if (td.type == 'Sidebar') { + view.sidebar = newDiv; + } + }); + } + view.updateDimensions(); + }; + // update dimensions, either when first rendering or when the window is resized + View.prototype.updateDimensions = function () { + var view = this; + // read the client width of the enclosing div and calculate the height using the aspectRatio + var width = view.div.node().clientWidth; + if (view.sidebar) { + if (width > view.sidebar.triggerWidth) { + view.sidebar.positionRight(width); + width = width * 77 / 126; // make width of graph the same width as main Tufte column + } + else { + view.sidebar.positionBelow(); + } + } + var height = width / view.aspectRatio; + // set the height of the div + view.div.style.height = height + 'px'; + if (view.svg) { + // set the dimensions of the svg + view.svg.style('width', width); + view.svg.style('height', height); + } + // adjust all of the scales to be proportional to the new dimensions + view.scales.forEach(function (scale) { + scale.updateDimensions(width, height); + }); + // once the scales are updated, update the coordinates of all view objects + view.model.update(true); + }; + return View; + }()); + KG.View = View; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Scale = /** @class */ (function (_super) { + __extends(Scale, _super); + function Scale(def) { + var _this = this; + KG.setDefaults(def, { + log: false + }); + def.constants = ['rangeMin', 'rangeMax', 'axis', 'name']; + def.updatables = ['domainMin', 'domainMax']; + _this = _super.call(this, def) || this; + _this.scale = def.log ? d3.scaleLog() : d3.scaleLinear(); + _this.update(true); + return _this; + } + Scale.prototype.update = function (force) { + var s = _super.prototype.update.call(this, force); + if (s.extent != undefined) { + var rangeMin = s.rangeMin * s.extent, rangeMax = s.rangeMax * s.extent; + s.scale.domain([s.domainMin, s.domainMax]); + s.scale.range([rangeMin, rangeMax]); + } + return s; + }; + Scale.prototype.updateDimensions = function (width, height) { + var s = this; + s.extent = (s.axis == 'x') ? width : height; + return s.update(true); + }; + return Scale; + }(KG.UpdateListener)); + KG.Scale = Scale; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var ViewObject = /** @class */ (function (_super) { + __extends(ViewObject, _super); + function ViewObject(def) { + var _this = this; + KG.setDefaults(def, { + alwaysUpdate: false, + interactive: true, + fill: 'colors.blue', + fillOpacity: 0.2, + stroke: 'colors.blue', + strokeWidth: 1, + stokeOpacity: 1, + show: true, + inDef: false, + lineStyle: 'solid' + }); + KG.setProperties(def, 'updatables', ['fill', 'stroke', 'strokeWidth', 'opacity', 'strokeOpacity', 'show', 'lineStyle']); + KG.setProperties(def, 'constants', ['xScale', 'yScale', 'clipPath', 'clipPath2', 'interactive', 'alwaysUpdate', 'inDef']); + KG.setProperties(def, 'colorAttributes', ['stroke', 'fill', 'color']); + if (def.inDef) { + def.show = true; + } + ; + _this = _super.call(this, def) || this; + var vo = _this; + def.colorAttributes.forEach(function (attr) { + var c = def[attr]; + if (vo.model.colors.hasOwnProperty(c)) { + def[attr] = vo.model.colors[c]; + } + }); + // the interaction handler manages drag and hover events + if (def.interactive) { + def.drag = def.drag || []; + var dragListeners = def.drag.map(function (dragDef) { + dragDef.model = vo.model; + return new KG.DragListener(dragDef); + }); + def.click = def.click || []; + var clickListeners = def.click.map(function (clickDef) { + clickDef.model = vo.model; + return new KG.ClickListener(clickDef); + }); + vo.interactionHandler = new KG.InteractionHandler({ + viewObject: vo, + model: vo.model, + dragListeners: dragListeners, + clickListeners: clickListeners + }); + } + // the draw method creates the DOM elements for the view object + // the update method updates their attributes + if (def.hasOwnProperty('layer')) { + vo.draw(def.layer).update(true).init(); + } + return _this; + } + ViewObject.prototype.init = function () { + return this; //defined at subclass level + }; + ViewObject.prototype.addClipPathAndArrows = function () { + var vo = this; + if (vo.hasOwnProperty('clipPath') && vo.clipPath != undefined) { + vo.rootElement.attr('clip-path', "url(#" + vo.clipPath + ")"); + } + if (vo.hasOwnProperty('clipPath2') && vo.clipPath2 != undefined) { + vo.rootElement2.attr('clip-path', "url(#" + vo.clipPath2 + ")"); + } + if (vo.hasOwnProperty('endArrow') && vo.endArrow != undefined) { + vo.markedElement.attr("marker-end", "url(#" + vo.endArrow + ")"); + } + if (vo.hasOwnProperty('startArrow') && vo.endArrow != undefined) { + vo.markedElement.attr("marker-start", "url(#" + vo.startArrow + ")"); + } + return vo; + }; + ViewObject.prototype.addInteraction = function () { + var vo = this; + vo.interactionHandler.addTrigger(vo.rootElement); + return vo; + }; + ViewObject.prototype.draw = function (layer, inDef) { + return this; + }; + ViewObject.prototype.redraw = function () { + return this; + }; + ViewObject.prototype.drawStroke = function (el) { + var vo = this; + el.attr('stroke', vo.stroke); + el.attr('stroke-width', vo.strokeWidth); + el.style('stroke-opacity', vo.strokeOpacity); + if (vo.lineStyle == 'dashed') { + el.style('stroke-dashArray', '10,10'); + } + if (vo.lineStyle == 'dotted') { + el.style('stroke-dashArray', '1,2'); + } + }; + ViewObject.prototype.drawFill = function (el) { + var vo = this; + el.style('fill', vo.fill); + el.style('fill-opacity', vo.opacity); + }; + ViewObject.prototype.displayElement = function (show) { + var vo = this; + if (vo.hasOwnProperty('rootElement')) { + vo.rootElement.style('display', show ? null : 'none'); + } + }; + ViewObject.prototype.onGraph = function () { + var vo = this; + if (vo.hasOwnProperty('x')) { + if (vo.x < vo.xScale.domainMin || vo.x > vo.xScale.domainMax) { + return false; + } + } + if (vo.hasOwnProperty('y')) { + if (vo.y < vo.yScale.domainMin || vo.y > vo.yScale.domainMax) { + return false; + } + } + return true; + }; + ViewObject.prototype.update = function (force) { + var vo = _super.prototype.update.call(this, force); + if ((vo.show && vo.onGraph()) || vo.inDef) { + vo.displayElement(true); + if (vo.hasChanged) { + vo.redraw(); + } + } + else { + vo.displayElement(false); + } + return vo; + }; + return ViewObject; + }(KG.UpdateListener)); + KG.ViewObject = ViewObject; +})(KG || (KG = {})); +var KG; +(function (KG) { + var Marker = /** @class */ (function (_super) { + __extends(Marker, _super); + function Marker(def) { + var _this = this; + KG.setProperties(def, 'constants', ['maskPath', 'arrowPath']); + KG.setProperties(def, 'updatables', ['color']); + _this = _super.call(this, def) || this; + return _this; + } + Marker.prototype.draw = function (layer) { + var m = this; + layer.append("svg:path") + .attr("d", m.maskPath) + .attr("fill", "white"); + m.arrowElement = layer.append("svg:path") + .attr("d", m.arrowPath); + return m; + }; + Marker.prototype.redraw = function () { + var m = this; + m.arrowElement.attr("fill", m.color); + return m; + }; + return Marker; + }(KG.ViewObject)); + KG.Marker = Marker; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Segment = /** @class */ (function (_super) { + __extends(Segment, _super); + function Segment(def) { + var _this = this; + KG.setDefaults(def, { + xScale2: def.xScale, + yScale2: def.yScale, + strokeWidth: 2 + }); + KG.setProperties(def, 'constants', ['xScale2', 'yScale2', 'startArrow', 'endArrow']); + KG.setProperties(def, 'updatables', ['x1', 'y1', 'x2', 'y2']); + _this = _super.call(this, def) || this; + return _this; + } + // create SVG elements + Segment.prototype.draw = function (layer) { + var segment = this; + segment.rootElement = layer.append('g'); + segment.dragLine = segment.rootElement.append('line').attr('stroke-width', '20px').style('stroke-opacity', 0); + segment.line = segment.rootElement.append('line'); + segment.markedElement = segment.line; + return segment.addClipPathAndArrows().addInteraction(); + }; + // update properties + Segment.prototype.redraw = function () { + var segment = this; + var x1 = segment.xScale.scale(segment.x1), x2 = segment.xScale.scale(segment.x2), y1 = segment.yScale2.scale(segment.y1), y2 = segment.yScale2.scale(segment.y2); + segment.dragLine + .attr("x1", x1) + .attr("y1", y1) + .attr("x2", x2) + .attr("y2", y2); + segment.line + .attr("x1", x1) + .attr("y1", y1) + .attr("x2", x2) + .attr("y2", y2); + segment.drawStroke(segment.line); + return segment; + }; + return Segment; + }(KG.ViewObject)); + KG.Segment = Segment; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Curve = /** @class */ (function (_super) { + __extends(Curve, _super); + function Curve(def) { + var _this = this; + var univariateFunction, parametricFunction; + KG.setDefaults(def, { + interpolation: 'curveBasis', + strokeWidth: 2 + }); + KG.setProperties(def, 'constants', ['interpolation']); + if (def.hasOwnProperty('univariateFunction')) { + def.univariateFunction.model = def.model; + univariateFunction = new KG.UnivariateFunction(def.univariateFunction); + KG.setProperties(def, 'updatables', []); + } + else if (def.hasOwnProperty('parametricFunction')) { + def.parametricFunction.model = def.model; + parametricFunction = new KG.ParametricFunction(def.parametricFunction); + KG.setProperties(def, 'updatables', []); + } + _this = _super.call(this, def) || this; + var curve = _this; + if (def.hasOwnProperty('univariateFunction')) { + curve.univariateFunction = univariateFunction; + } + else if (def.hasOwnProperty('parametricFunction')) { + def.parametricFunction.model = def.model; + curve.parametricFunction = parametricFunction; + } + return _this; + } + // create SVG elements + Curve.prototype.draw = function (layer) { + var curve = this; + curve.dataLine = d3.line() + .curve(d3[curve.interpolation]) + .x(function (d) { + return curve.xScale.scale(d.x); + }) + .y(function (d) { + return curve.yScale.scale(d.y); + }); + curve.rootElement = layer.append('g'); + curve.dragPath = curve.rootElement.append('path').attr('stroke-width', '20px').style('stroke-opacity', 0).style('fill', 'none'); + curve.path = curve.rootElement.append('path').style('fill', 'none'); + return curve.addClipPathAndArrows().addInteraction(); + }; + // update properties + Curve.prototype.redraw = function () { + var curve = this; + if (curve.hasOwnProperty('univariateFunction')) { + var fn = curve.univariateFunction, scale = fn.ind == 'y' ? curve.yScale : curve.xScale; + fn.generateData(scale.domainMin, scale.domainMax); + curve.dragPath.data([fn.data]).attr('d', curve.dataLine); + curve.path.data([fn.data]).attr('d', curve.dataLine); + } + if (curve.hasOwnProperty('parametricFunction')) { + var fn = curve.parametricFunction; + fn.generateData(); + curve.dragPath.data([fn.data]).attr('d', curve.dataLine); + curve.path.data([fn.data]).attr('d', curve.dataLine); + } + curve.drawStroke(curve.path); + return curve; + }; + // update self and functions + Curve.prototype.update = function (force) { + var curve = _super.prototype.update.call(this, force); + if (!curve.hasChanged) { + if (curve.hasOwnProperty('univariateFunction')) { + if (curve.univariateFunction.hasChanged) { + curve.redraw(); + } + } + if (curve.hasOwnProperty('parametricFunction')) { + if (curve.parametricFunction.hasChanged) { + curve.redraw(); + } + } + } + return curve; + }; + return Curve; + }(KG.ViewObject)); + KG.Curve = Curve; +})(KG || (KG = {})); +var KG; +(function (KG) { + var Axis = /** @class */ (function (_super) { + __extends(Axis, _super); + function Axis(def) { + var _this = this; + KG.setDefaults(def, { + ticks: 5, + intercept: 0 + }); + KG.setProperties(def, 'constants', ['orient']); + KG.setProperties(def, 'updatables', ['ticks', 'intercept', 'label', 'min', 'max', 'otherMin', 'otherMax']); + _this = _super.call(this, def) || this; + return _this; + } + Axis.prototype.draw = function (layer) { + var a = this; + a.rootElement = layer.append('g').attr('class', 'axis'); + return a; + }; + Axis.prototype.redraw = function () { + var a = this; + switch (a.orient) { + case 'bottom': + a.rootElement.attr('transform', "translate(0, " + a.yScale.scale(a.intercept) + ")"); + a.rootElement.call(d3.axisBottom(a.xScale.scale).ticks(a.ticks)); + return a; + case 'left': + a.rootElement.attr('transform', "translate(" + a.xScale.scale(a.intercept) + ",0)"); + a.rootElement.call(d3.axisLeft(a.yScale.scale).ticks(a.ticks)); + return a; + case 'top': + a.rootElement.attr('transform', "translate(0, " + a.yScale.scale(a.intercept) + ")"); + a.rootElement.call(d3.axisTop(a.xScale.scale).ticks(a.ticks)); + return a; + case 'right': + a.rootElement.attr('transform', "translate(" + a.xScale.scale(a.intercept) + ",0)"); + a.rootElement.call(d3.axisRight(a.yScale.scale).ticks(a.ticks)); + return a; + } + return a; + }; + return Axis; + }(KG.ViewObject)); + KG.Axis = Axis; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Point = /** @class */ (function (_super) { + __extends(Point, _super); + function Point(def) { + var _this = this; + KG.setDefaults(def, { + fill: 'colors.blue', + opacity: 1, + stroke: 'white', + strokeWidth: 1, + strokeOpacity: 1, + r: 6 + }); + KG.setProperties(def, 'updatables', ['x', 'y', 'r']); + _this = _super.call(this, def) || this; + return _this; + } + // create SVG elements + Point.prototype.draw = function (layer) { + var p = this; + p.rootElement = layer.append('g'); // SVG group + p.dragCircle = p.rootElement.append('circle').style('fill-opacity', 0).attr('r', 20); + p.circle = p.rootElement.append('circle'); + //p.addClipPathAndArrows() + return p.addInteraction(); + }; + // update properties + Point.prototype.redraw = function () { + var p = this; + p.rootElement.attr('transform', "translate(" + p.xScale.scale(p.x) + " " + p.yScale.scale(p.y) + ")"); + p.circle.attr('r', p.r); + p.circle.style('fill', p.fill); + p.circle.style('fill-opacity', p.opacity); + p.circle.style('stroke', p.stroke); + p.circle.style('stroke-width', p.strokeWidth + "px"); + p.circle.style('stroke-opacity', p.strokeOpacity); + return p; + }; + return Point; + }(KG.ViewObject)); + KG.Point = Point; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Ellipse = /** @class */ (function (_super) { + __extends(Ellipse, _super); + function Ellipse(def) { + var _this = this; + KG.setDefaults(def, { + fill: 'colors.blue', + opacity: 1, + stroke: 'colors.blue', + strokeWidth: 1, + strokeOpacity: 1, + rx: 1, + ry: 1 + }); + KG.setProperties(def, 'updatables', ['x', 'y', 'rx', 'ry']); + _this = _super.call(this, def) || this; + return _this; + } + // create SVG elements + Ellipse.prototype.draw = function (layer) { + var c = this; + c.rootElement = layer.append('ellipse'); + return c.addClipPathAndArrows().addInteraction(); + }; + // update properties + Ellipse.prototype.redraw = function () { + var c = this; + c.rootElement.attr('cx', c.xScale.scale(c.x)); + c.rootElement.attr('cy', c.yScale.scale(c.y)); + c.rootElement.attr('rx', Math.abs(c.xScale.scale(c.rx) - c.xScale.scale(0))); + c.rootElement.attr('ry', Math.abs(c.yScale.scale(c.ry) - c.yScale.scale(0))); + c.drawFill(c.rootElement); + c.drawStroke(c.rootElement); + return c; + }; + return Ellipse; + }(KG.ViewObject)); + KG.Ellipse = Ellipse; + var Circle = /** @class */ (function (_super) { + __extends(Circle, _super); + function Circle(def) { + return _super.call(this, def) || this; + } + return Circle; + }(Ellipse)); + KG.Circle = Circle; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Rectangle = /** @class */ (function (_super) { + __extends(Rectangle, _super); + function Rectangle(def) { + var _this = this; + KG.setDefaults(def, { + opacity: 0.2, + stroke: "none" + }); + KG.setProperties(def, 'updatables', ['x1', 'x2', 'y1', 'y2']); + _this = _super.call(this, def) || this; + return _this; + } + // create SVG elements + Rectangle.prototype.draw = function (layer) { + var rect = this; + if (rect.inDef) { + rect.rootElement = layer; + } + else { + rect.rootElement = layer.append('g'); + } + rect.rootElement2 = rect.rootElement.append('rect'); + //rect.interactionHandler.addTrigger(rect.rootElement); + return rect.addClipPathAndArrows().addInteraction(); + }; + // update properties + Rectangle.prototype.redraw = function () { + var rect = this; + var x1 = rect.xScale.scale(rect.x1); + var y1 = rect.yScale.scale(rect.y1); + var x2 = rect.xScale.scale(rect.x2); + var y2 = rect.yScale.scale(rect.y2); + rect.rootElement2 + .attr('x', Math.min(x1, x2)) + .attr('y', Math.min(y1, y2)) + .attr('width', Math.abs(x2 - x1)) + .attr('height', Math.abs(y2 - y1)) + .style('fill', rect.fill) + .style('fill-opacity', rect.opacity) + .style('stroke', rect.stroke) + .style('stroke-width', rect.strokeWidth + "px") + .style('stroke-opacity', rect.strokeOpacity); + return rect; + }; + return Rectangle; + }(KG.ViewObject)); + KG.Rectangle = Rectangle; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Area = /** @class */ (function (_super) { + __extends(Area, _super); + function Area(def) { + var _this = this; + var minValue = def.univariateFunction1.ind == 'x' ? def.yScale.domainMin : def.xScale.domainMin; + var maxValue = def.univariateFunction1.ind == 'x' ? def.yScale.domainMax : def.xScale.domainMax; + KG.setDefaults(def, { + interpolation: 'curveBasis', + ind: 'x', + fill: 'lightsteelblue', + opacity: 0.2, + univariateFunction2: { + "fn": ((def.above && !def.useTopScale) || (!def.above && def.useTopScale)) ? maxValue : minValue, + "ind": def.univariateFunction1['ind'], + "min": def.univariateFunction1['min'], + "max": def.univariateFunction1['max'], + "samplePoints": def.univariateFunction1['samplePoints'] + } + }); + KG.setProperties(def, 'constants', ['interpolation']); + def.univariateFunction1.model = def.model; + def.univariateFunction2.model = def.model; + // need to initialize the functions before the area, so they exist when it's time to draw the area + var univariateFunction1 = new KG.UnivariateFunction(def.univariateFunction1), univariateFunction2 = new KG.UnivariateFunction(def.univariateFunction2); + _this = _super.call(this, def) || this; + _this.univariateFunction1 = univariateFunction1; + _this.univariateFunction2 = univariateFunction2; + return _this; + } + // create SVG elements + Area.prototype.draw = function (layer) { + var ab = this; + ab.rootElement = layer.append('path'); + ab.areaShape = d3.area() + .x0(function (d) { + return ab.xScale.scale(d[0].x); + }) + .y0(function (d) { + return ab.yScale.scale(d[0].y); + }) + .x1(function (d) { + return ab.xScale.scale(d[1].x); + }) + .y1(function (d) { + return ab.yScale.scale(d[1].y); + }); + ab.areaPath = ab.rootElement; + return ab.addClipPathAndArrows(); + }; + // update properties + Area.prototype.redraw = function () { + var area = this; + if (area.univariateFunction1 != undefined && area.univariateFunction2 != undefined) { + var fn1 = area.univariateFunction1, fn2 = area.univariateFunction2, scale = fn1.ind == 'y' ? area.yScale : area.xScale; + fn1.generateData(scale.domainMin, scale.domainMax); + fn2.generateData(scale.domainMin, scale.domainMax); + area.areaPath + .data([d3.zip(fn1.data, fn2.data)]) + .attr('d', area.areaShape); + area.drawFill(area.areaPath); + } + else { + //console.log('area functions undefined') + } + return area; + }; + // update self and functions + Area.prototype.update = function (force) { + var area = _super.prototype.update.call(this, force); + if (!area.hasChanged) { + if (area.univariateFunction1.hasChanged || area.univariateFunction2.hasChanged) { + area.redraw(); + } + } + return area; + }; + return Area; + }(KG.ViewObject)); + KG.Area = Area; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var GeoGebraObject = /** @class */ (function (_super) { + __extends(GeoGebraObject, _super); + function GeoGebraObject(def) { + var _this = this; + KG.setDefaults(def, { + color: '#999999', + lineThickness: 1, + lineStyle: 0 + }); + KG.setProperties(def, 'constants', ['command', 'color', 'lineThickness', 'lineStyle']); + _this = _super.call(this, def) || this; + return _this; + } + GeoGebraObject.prototype.establishGGB = function (applet) { + // from https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb + function hexToRgb(hex) { + var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); + return result ? { + r: parseInt(result[1], 16), + g: parseInt(result[2], 16), + b: parseInt(result[3], 16) + } : null; + } + var obj = this; + //console.log('sending commands to applet', applet); + // set command + var command = obj.name + " = " + obj.command; + //console.log('sending command ', obj.name + " = " + obj.command); + applet.evalCommand(command); + if (obj.hasOwnProperty('opacity')) { + applet.setFilling(obj.opacity); + } + var color = hexToRgb(obj.color); + //console.log('sending command setColor(', obj.name, ', ', color.r, ',', color.g, ', ', color.b, ')'); + applet.setColor(obj.name, color.r, color.g, color.b); + //console.log('sending command setLineThickness(', obj.name, ', ', obj.lineThickness, ')') + applet.evalCommand('SetLineThickness[' + obj.name + ', ' + obj.lineThickness + ']'); + //console.log('sending command setLineStyle(', obj.name, ', ', obj.lineStyle, ')') + applet.setLineStyle(obj.name, obj.lineStyle); + }; + return GeoGebraObject; + }(KG.ViewObject)); + KG.GeoGebraObject = GeoGebraObject; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Contour = /** @class */ (function (_super) { + __extends(Contour, _super); + function Contour(def) { + var _this = this; + KG.setDefaults(def, { + opacity: 0.2, + stroke: "grey", + fillAbove: "none", + fillBelow: "none", + strokeOpacity: 1 + }); + KG.setProperties(def, 'colorAttributes', ['fillAbove', 'fillBelow']); + KG.setProperties(def, 'updatables', ['level', 'fillBelow', 'fillAbove']); + _this = _super.call(this, def) || this; + // used for shading area above + _this.fn = new KG.MultivariateFunction({ + fn: def.fn, + model: def.model + }).update(true); + // used for shading area below + _this.negativeFn = new KG.MultivariateFunction({ + fn: "-1*(" + def.fn + ")", + model: def.model + }).update(true); + return _this; + } + Contour.prototype.draw = function (layer) { + var c = this; + c.rootElement = layer.append('g'); + c.negativePath = c.rootElement.append('path'); + c.path = c.rootElement.append('path'); + return c.addClipPathAndArrows(); + }; + Contour.prototype.redraw = function () { + var c = this; + if (undefined != c.fn) { + c.path.attr("d", c.fn.contour(c.level, c.xScale, c.yScale)); + c.path.style('fill', c.fillAbove); + c.path.style('fill-opacity', c.opacity); + c.path.style('stroke', c.stroke); + c.path.style('stroke-width', c.strokeWidth); + c.path.style('stroke-opacity', c.strokeOpacity); + c.negativePath.attr("d", c.negativeFn.contour(-1 * c.level, c.xScale, c.yScale)); + c.negativePath.style('fill', c.fillBelow); + c.negativePath.style('fill-opacity', c.opacity); + } + return c; + }; + // update self and functions + Contour.prototype.update = function (force) { + var c = _super.prototype.update.call(this, force); + if (!c.hasChanged) { + if (c.fn.hasChanged) { + c.redraw(); + } + } + return c; + }; + return Contour; + }(KG.ViewObject)); + KG.Contour = Contour; + var ContourMap = /** @class */ (function (_super) { + __extends(ContourMap, _super); + function ContourMap(def) { + return _super.call(this, def) || this; + } + return ContourMap; + }(KG.ViewObject)); + KG.ContourMap = ContourMap; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var DivObject = /** @class */ (function (_super) { + __extends(DivObject, _super); + function DivObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + DivObject.prototype.redraw = function () { + var div = this; + var width = Math.abs(div.xScale.scale(1) - div.xScale.scale(0)), height = Math.abs(div.yScale.scale(1) - div.yScale.scale(0)); + div.rootElement.style('left', div.xScale.scale(0) + 'px'); + div.rootElement.style('top', div.yScale.scale(1) + 'px'); + div.rootElement.style('width', width + 'px'); + div.rootElement.style('height', height + 'px'); + return div; + }; + return DivObject; + }(KG.ViewObject)); + KG.DivObject = DivObject; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var PositionedDiv = /** @class */ (function (_super) { + __extends(PositionedDiv, _super); + function PositionedDiv() { + return _super !== null && _super.apply(this, arguments) || this; + } + PositionedDiv.prototype.draw = function (layer) { + var div = this; + div.rootElement = layer.append('div'); + div.rootElement.style('position', 'absolute'); + if (div.def.hasOwnProperty('children')) { + div.def['children'].forEach(function (child) { + child.def.layer = div.rootElement; + child.def.model = div.model; + new KG[child.type](child.def); + }); + } + return div; + }; + PositionedDiv.prototype.redraw = function () { + var div = this; + var width = Math.abs(div.xScale.scale(1) - div.xScale.scale(0)), height = Math.abs(div.yScale.scale(1) - div.yScale.scale(0)); + div.rootElement.style('left', div.xScale.scale(0) + 'px'); + div.rootElement.style('top', div.yScale.scale(1) + 'px'); + div.rootElement.style('width', width + 'px'); + div.rootElement.style('height', height + 'px'); + return div; + }; + return PositionedDiv; + }(KG.DivObject)); + KG.PositionedDiv = PositionedDiv; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Div = /** @class */ (function (_super) { + __extends(Div, _super); + function Div(def) { + var _this = this; + //establish property defaults + KG.setDefaults(def, { + xPixelOffset: 0, + yPixelOffset: 0, + fontSize: 12 + }); + // define constant and updatable properties + KG.setProperties(def, 'constants', ['fontSize']); + KG.setProperties(def, 'updatables', ['html']); + _this = _super.call(this, def) || this; + return _this; + } + // create div for text + Div.prototype.draw = function (layer) { + var div = this; + div.rootElement = layer.append('div') + .style('font-size', div.fontSize + 'pt') + .style('padding-top', '10px') + .style('padding-bottom', '10px'); + return div; + }; + // update properties + Div.prototype.redraw = function () { + var div = this; + if (div.show) { + div.rootElement.html(div.html); + renderMathInElement(div.rootElement.node(), { + delimiters: [ + { left: "$$", right: "$$", display: true }, + { left: "\\[", right: "\\]", display: true }, + { left: "$", right: "$", display: false }, + { left: "\\(", right: "\\)", display: false } + ] + }); + } + else { + div.rootElement.html(null); + } + return div; + }; + return Div; + }(KG.DivObject)); + KG.Div = Div; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var ParamControl = /** @class */ (function (_super) { + __extends(ParamControl, _super); + function ParamControl(def) { + var _this = this; + // establish property defaults + KG.setDefaults(def, { + value: 'params.' + def.param, + alwaysUpdate: true + }); + // define constant and updatable properties + KG.setProperties(def, 'constants', ['param']); + KG.setProperties(def, 'updatables', ['label', 'value']); + _this = _super.call(this, def) || this; + return _this; + } + return ParamControl; + }(KG.DivObject)); + KG.ParamControl = ParamControl; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Slider = /** @class */ (function (_super) { + __extends(Slider, _super); + function Slider(def) { + var _this = this; + // establish property defaults + KG.setDefaults(def, { + noAxis: false + }); + // define constant and updatable properties + KG.setProperties(def, 'constants', ['noAxis']); + _this = _super.call(this, def) || this; + return _this; + } + Slider.prototype.draw = function (layer) { + var slider = this; + slider.rootElement = layer.append('tr'); + var param = slider.model.getParam(slider.param); + slider.labelElement = slider.rootElement.append('td') + .style('font-size', '14pt') + .style('text-align', 'right'); + function inputUpdate() { + slider.model.updateParam(slider.param, +this.value); + } + slider.numberInput = slider.rootElement.append('td').append('input') + .attr('type', 'number') + .attr('min', param.min) + .attr('max', param.max) + .attr('step', param.round) + .style('font-size', '14pt') + .style('border', 'none') + .style('background', 'none') + .style('padding-left', '5px') + .style('font-family', 'KaTeX_Main') + .style('width', '100%'); + slider.numberInput.on("blur", inputUpdate); + slider.numberInput.on("click", inputUpdate); + slider.numberInput.on("keyup", function () { + if (event['keyCode'] == 13) { + slider.model.updateParam(slider.param, +this.value); + } + }); + slider.rangeInput = slider.rootElement.append('td').append('input') + .attr('type', 'range') + .attr('min', param.min) + .attr('max', param.max) + .attr('step', param.round) + .style('width', '100%'); + slider.rangeInput.on("input", inputUpdate); + return slider; + }; + // update properties + Slider.prototype.redraw = function () { + var slider = this; + katex.render(slider.label + " = ", slider.labelElement.node()); + slider.numberInput.property('value', slider.value.toFixed(slider.model.getParam(slider.param).precision)); + slider.rangeInput.property('value', slider.value); + return slider; + }; + return Slider; + }(KG.ParamControl)); + KG.Slider = Slider; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Checkbox = /** @class */ (function (_super) { + __extends(Checkbox, _super); + function Checkbox() { + return _super !== null && _super.apply(this, arguments) || this; + } + Checkbox.prototype.draw = function (layer) { + var checkbox = this; + checkbox.rootElement = layer.append('div').append('label'); + checkbox.inputElement = checkbox.rootElement.append('input'); + checkbox.inputElement + .attr('type', 'checkbox'); + checkbox.inputElement.on("change", function () { + checkbox.model.toggleParam(checkbox.param); + }); + checkbox.labelElement = checkbox.rootElement.append('span'); + checkbox.labelElement.style('padding-left', '10px'); + return checkbox; + }; + Checkbox.prototype.redraw = function () { + var checkbox = this; + checkbox.inputElement.property('checked', Boolean(checkbox.value)); + katex.render(checkbox.label, checkbox.labelElement.node()); + return checkbox; + }; + return Checkbox; + }(KG.ParamControl)); + KG.Checkbox = Checkbox; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Radio = /** @class */ (function (_super) { + __extends(Radio, _super); + function Radio(def) { + var _this = this; + KG.setProperties(def, 'updatables', ['optionValue']); + _this = _super.call(this, def) || this; + return _this; + } + Radio.prototype.draw = function (layer) { + var radio = this; + radio.rootElement = layer.append('div').append('label'); + radio.inputElement = radio.rootElement.append('input'); + radio.inputElement + .attr('type', 'radio') + .attr('name', 'r_' + radio.param) + .attr('value', radio.optionValue); + radio.inputElement.on("change", function () { + radio.model.updateParam(radio.param, radio.optionValue); + }); + radio.labelElement = radio.rootElement.append('span'); + radio.labelElement.style('padding-left', '10px'); + return radio; + }; + Radio.prototype.redraw = function () { + var radio = this; + radio.inputElement.property('checked', radio.value == radio.optionValue); + katex.render(radio.label, radio.labelElement.node()); + return radio; + }; + return Radio; + }(KG.ParamControl)); + KG.Radio = Radio; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Controls = /** @class */ (function (_super) { + __extends(Controls, _super); + function Controls(def) { + var _this = this; + KG.setDefaults(def, { + title: '', + description: '', + sliders: [], + checkboxes: [], + radios: [], + divs: [] + }); + KG.setProperties(def, 'constants', ['sliders', 'checkboxes', 'radios', 'divs']); + KG.setProperties(def, 'updatables', ['title', 'description']); + _this = _super.call(this, def) || this; + return _this; + } + // create div for text + Controls.prototype.draw = function (layer) { + var controls = this; + controls.rootElement = layer.append('div'); + controls.titleElement = controls.rootElement.append('p').style('width', '100%').style('font-size', '10pt').style('margin-bottom', 10); + controls.rootElement.append('hr'); + controls.descriptionElement = controls.rootElement.append('div'); + var sliderTable = controls.rootElement.append('table').style('padding', '10px').style('width', '100%'); + controls.sliders.forEach(function (slider) { + new KG.Slider({ layer: sliderTable, param: slider.param, label: slider.label, model: controls.model }); + }); + controls.checkboxes.forEach(function (checkbox) { + checkbox = KG.setDefaults(checkbox, { + layer: controls.rootElement, + model: controls.model + }); + new KG.Checkbox(checkbox); + }); + controls.radios.forEach(function (radio) { + radio = KG.setDefaults(radio, { + layer: controls.rootElement, + model: controls.model + }); + new KG.Radio(radio); + }); + controls.divs.forEach(function (div) { + div = KG.setDefaults(div, { + layer: controls.rootElement, + model: controls.model, + fontSize: 14 + }); + new KG.Div(div); + }); + return controls; + }; + // update properties + Controls.prototype.redraw = function () { + var controls = this; + if (controls.title.length > 0) { + controls.titleElement.text(controls.title.toUpperCase()); + } + controls.descriptionElement.text(controls.description); + return controls; + }; + return Controls; + }(KG.DivObject)); + KG.Controls = Controls; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var GameMatrix = /** @class */ (function (_super) { + __extends(GameMatrix, _super); + function GameMatrix(def) { + var _this = this; + KG.setDefaults(def, { + players: ["Player 1", "Player 2"] + }); + KG.setProperties(def, 'constants', ['players', 'strategies']); + KG.setProperties(def, 'updatables', ['payoffs']); + _this = _super.call(this, def) || this; + return _this; + } + // create div for text + GameMatrix.prototype.draw = function (layer) { + var gameMatrix = this; + var numStrategies1 = gameMatrix.strategies[0].length, numStrategies2 = gameMatrix.strategies[1].length; + gameMatrix.rootElement = layer.append('div'); + var table = gameMatrix.rootElement.append('table').attr('class', 'gameMatrix'); + var topRow = table.append('tr'); + topRow.append('td').attr('colspan', '2').attr('class', 'empty'); + topRow.append('td') + .attr('colspan', numStrategies2 * 2) + .attr('class', 'player2 strategy empty') + .text(gameMatrix.players[1]); + var secondRow = table.append('tr'); + secondRow.append('td').attr('colspan', '2').attr('class', 'empty'); + gameMatrix.strategies[1].forEach(function (s) { + secondRow.append('td').attr('colspan', '2').attr('class', 'player2 strategy').text(s); + }); + gameMatrix.payoffNodes = []; + for (var i = 0; i < numStrategies1; i++) { + var row = table.append('tr'); + var payoffRow = []; + if (i == 0) { + row.append('td') + .attr('rowSpan', numStrategies1) + .attr('class', 'player1 strategy empty') + .text(gameMatrix.players[0]); + } + row.append('td').text(gameMatrix.strategies[0][i]).attr('class', 'player1 strategy'); + for (var j = 0; j < numStrategies2; j++) { + var payoff1 = row.append('td').attr('class', 'player1 payoff'); + var payoff2 = row.append('td').attr('class', 'player2 payoff'); + payoffRow.push([payoff1, payoff2]); + } + gameMatrix.payoffNodes.push(payoffRow); + } + return gameMatrix; + }; + GameMatrix.prototype.redraw = function () { + var gameMatrix = this; + var strategies1 = gameMatrix.strategies[0], strategies2 = gameMatrix.strategies[1]; + var numStrategies1 = strategies1.length, numStrategies2 = strategies2.length; + for (var i = 0; i < numStrategies1; i++) { + for (var j = 0; j < numStrategies2; j++) { + var cell = gameMatrix.payoffNodes[i][j]; + katex.render(gameMatrix.payoffs[i][j][0].toString(), cell[0].node()); + katex.render(gameMatrix.payoffs[i][j][1].toString(), cell[1].node()); + } + } + return gameMatrix; + }; + return GameMatrix; + }(KG.DivObject)); + KG.GameMatrix = GameMatrix; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var GeoGebraApplet = /** @class */ (function (_super) { + __extends(GeoGebraApplet, _super); + function GeoGebraApplet(def) { + var _this = this; + KG.setDefaults(def, { + params: [], + objects: [], + axisLabels: [] + }); + def.params.forEach(function (param) { + def[param] = 'params.' + param; + }); + KG.setProperties(def, 'updatables', def.params); + KG.setProperties(def, 'constants', ['axes', 'params']); + _this = _super.call(this, def) || this; + var div = _this; + div.objects = def.objects.map(function (objDef) { + objDef.model = def.model; + return new KG.GeoGebraObject(objDef); + }); + //console.log('created GGB javascript object ', this) + div.axesEstablished = false; + return _this; + } + // create div for text + GeoGebraApplet.prototype.draw = function (layer) { + var div = _super.prototype.draw.call(this, layer); + var id = KG.randomString(10); + div.rootElement.append('div').attr('id', id); + var applet = new GGBApplet({ + allowStyleBar: true, + perspective: "T", + borderColor: "#FFFFFF", + dataParamId: id + }, true); + applet.setHTML5Codebase('../../../../GeoGebra/HTML5/5.0/web3d/'); + applet.inject(id); + return div; + }; + GeoGebraApplet.prototype.establishGGB = function (width, height) { + var div = this; + //console.log('called establishGGB'); + if (undefined != document['ggbApplet']) { + //console.log('applet exists'); + div.applet = document['ggbApplet']; + div.params.forEach(function (p) { + var establishParamCommand = p + " = " + div.model.currentParamValues[p]; + //console.log('setting param using command ', establishParamCommand); + div.applet.evalCommand(establishParamCommand); + }); + div.objects.forEach(function (obj) { + obj.establishGGB(div.applet); + }); + div.updateGGB(div.applet, width, height); + } + else { + //console.log('applet does not exist') + } + }; + GeoGebraApplet.prototype.updateGGB = function (applet, width, height) { + var div = this; + console.log('called updateGGB'); + if (undefined != applet) { + //console.log('applet exists'); + //console.log('setting width to ', width); + applet.setWidth(width); + //console.log('setting height to ', height); + applet.setHeight(height); + if (div.axes.length == 3) { + //console.log('setting coordinate system ', div.axes[0].min, div.axes[0].max, div.axes[1].min, div.axes[1].max, div.axes[2].min, div.axes[2].max) + applet.setCoordSystem(div.axes[0].min, div.axes[0].max, div.axes[1].min, div.axes[1].max, div.axes[2].min, div.axes[2].max); + //console.log('setting axis steps ', div.axes[0].step, div.axes[1].step, div.axes[2].step); + applet.setAxisSteps(3, div.axes[0].step, div.axes[1].step, div.axes[2].step); + //console.log('setting axis labels ', div.axes[0].label, div.axes[1].label, div.axes[2].label); + applet.setAxisLabels(3, div.axes[0].label, div.axes[1].label, div.axes[2].label); + applet.setColor('xAxis', 0, 0, 0); + applet.setColor('yAxis', 0, 0, 0); + applet.setColor('zAxis', 0, 0, 0); + } + else { + applet.setCoordSystem(div.axes[0].scale.domainMin, div.axes[0].scale.domainMax, div.axes[1].scale.domainMin, div.axes[1].scale.domainMax); + applet.setAxisSteps(2, div.axes[0].step, div.axes[1].step); + applet.setAxisLabels(2, div.axes[0].label, div.axes[1].label); + applet.setColor('xAxis', 0, 0, 0); + applet.setColor('yAxis', 0, 0, 0); + } + if (div.hasOwnProperty('params')) { + div.params.forEach(function (param) { + applet.setValue(param, div[param]); + }); + } + } + else { + //console.log('applet does not exist') + } + }; + // update properties + GeoGebraApplet.prototype.redraw = function () { + var div = _super.prototype.redraw.call(this); + var width = Math.abs(div.xScale.scale(1) - div.xScale.scale(0)), height = Math.abs(div.yScale.scale(1) - div.yScale.scale(0)); + var checkExist = setInterval(function () { + if (undefined != div.applet) { + div.updateGGB(div.applet, width, height); + clearInterval(checkExist); + } + else { + div.establishGGB(width, height); + } + }, 100); // check every 100ms + return div; + }; + return GeoGebraApplet; + }(KG.PositionedDiv)); + KG.GeoGebraApplet = GeoGebraApplet; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Mathbox = /** @class */ (function (_super) { + __extends(Mathbox, _super); + function Mathbox(def) { + var _this = this; + KG.setDefaults(def, { + objects: [] + }); + _this = _super.call(this, def) || this; + var mb = _this; + mb.objectDefs = def.objects; + mb.objects = []; + mb.objectDefs.forEach(function (td) { + td.def.mathbox = mb; + td.def.model = mb.model; + mb.objects.push(new KG[td.type](td.def)); + }); + console.log('created mathbox', mb); + return _this; + } + Mathbox.prototype.initMathbox = function () { + var mb = this; + mb.mathbox = mathBox({ + plugins: ['core', 'controls', 'cursor', 'mathbox'], + controls: { klass: THREE.OrbitControls }, + element: mb.rootElement.node() + }); + if (mb.mathbox.fallback) + throw "WebGL not supported"; + mb.three = mb.mathbox.three; + mb.three.renderer.setClearColor(new THREE.Color(0xFFFFFF), 1.0); + mb.mathbox.camera({ proxy: true, position: [-3, 1, 1], eulerOrder: "yzx" }); + mb.mathboxView = mb.mathbox.cartesian({ scale: [0.9, 0.9, 0.9] }); + mb.mathboxView.grid({ axes: [1, 3], width: 2, divideX: 10, divideY: 10, opacity: 0.3 }); + mb.xAxis.redraw(); + mb.yAxis.redraw(); + mb.zAxis.redraw(); + mb.objects.forEach(function (o) { o.draw().update(); }); + return mb; + }; + // create mb for mathbox + Mathbox.prototype.draw = function (layer) { + console.log('creating mathbox container'); + var mb = this; + mb.rootElement = layer.append('div').style('position', 'absolute'); + return mb; + }; + Mathbox.prototype.redraw = function () { + var mb = _super.prototype.redraw.call(this); + console.log('called redraw'); + if (mb.mathbox == undefined && mb.rootElement.node().clientWidth > 10 && mb.zAxis != undefined) { + mb.initMathbox(); + } + else { + return mb; + } + return mb; + }; + return Mathbox; + }(KG.PositionedDiv)); + KG.Mathbox = Mathbox; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Sidebar = /** @class */ (function (_super) { + __extends(Sidebar, _super); + function Sidebar(def) { + var _this = this; + KG.setDefaults(def, { + controls: [], + triggerWidth: 563 + }); + KG.setProperties(def, 'constants', ['controls', 'triggerWidth']); + _this = _super.call(this, def) || this; + return _this; + } + Sidebar.prototype.positionRight = function (width) { + var sidebar = this; + sidebar.rootElement + .style('position', 'absolute') + .style('left', width * 847 / 1260 + 'px') + .style('top', '0px') + .style('width', width * 385 / 1260 + 'px'); + }; + Sidebar.prototype.positionBelow = function () { + var sidebar = this; + sidebar.rootElement + .style('position', null) + .style('left', null) + .style('width', null) + .style('padding-top', '40px'); + }; + Sidebar.prototype.draw = function (layer) { + var sidebar = this; + sidebar.rootElement = layer.append('div').style('position', 'absolute'); + sidebar.controls.forEach(function (controlsDef) { + controlsDef.layer = sidebar.rootElement; + controlsDef.model = sidebar.model; + new KG.Controls(controlsDef); + }); + return sidebar; + }; + return Sidebar; + }(KG.ViewObject)); + KG.Sidebar = Sidebar; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var Label = /** @class */ (function (_super) { + __extends(Label, _super); + function Label(def) { + var _this = this; + var xAxisReversed = (def.xScale.rangeMin > def.xScale.rangeMax), yAxisReversed = (def.yScale.rangeMin < def.yScale.rangeMax); + var xOffset = xAxisReversed ? 3 : -3, yOffset = yAxisReversed ? 14 : -14; + if (def.x == 'AXIS') { + def.x = 0; + def.align = xAxisReversed ? 'left' : 'right'; + def.xPixelOffset = xOffset; + } + if (def.x == 'OPPAXIS') { + def.x = def.xScale.domainMax; + def.align = xAxisReversed ? 'right' : 'left'; + def.xPixelOffset = -xOffset; + } + if (def.y == 'AXIS') { + def.y = 0; + def.yPixelOffset = yOffset; + } + if (def.y == 'OPPAXIS') { + def.y = def.yScale.domainMax; + def.yPixelOffset = -yOffset; + } + //establish property defaults + KG.setDefaults(def, { + xPixelOffset: 0, + yPixelOffset: 0, + fontSize: 12, + align: 'center', + valign: 'middle', + rotate: 0, + color: 'black', + bgcolor: 'white' + }); + // define constant and updatable properties + KG.setProperties(def, 'constants', ['xPixelOffset', 'yPixelOffset', 'fontSize']); + KG.setProperties(def, 'updatables', ['x', 'y', 'text', 'align', 'valign', 'rotate', 'color', 'bgcolor']); + _this = _super.call(this, def) || this; + return _this; + } + // create div for text + Label.prototype.draw = function (layer) { + var label = this; + label.rootElement = layer.append('div') + .attr('class', 'draggable') + .style('position', 'absolute') + .style('font-size', label.fontSize + 'pt') + .style('text-align', 'center') + .style('padding-left', '3px') + .style('padding-right', '3px'); + return label.addInteraction(); + }; + // update properties + Label.prototype.redraw = function () { + var label = this; + label.rootElement.style('color', label.color).style('background-color', label.bgcolor); + var x = label.xScale.scale(label.x) + (+label.xPixelOffset), y = label.yScale.scale(label.y) - (+label.yPixelOffset); + if (undefined != label.text) { + //console.log('drawing label with text ',label.text); + try { + katex.render(label.text.toString(), label.rootElement.node()); + } + catch (e) { + console.log("Error rendering KaTeX: ", label.text); + } + } + label.rootElement.style('left', x + 'px'); + label.rootElement.style('top', y + 'px'); + var width = label.rootElement.node().clientWidth, height = label.rootElement.node().clientHeight; + // Set left pixel margin; default to centered on x coordinate + var alignDelta = width * 0.5; + if (label.align == 'left') { + alignDelta = 0; + } + else if (label.align == 'right') { + // move left by half the width of the div if right aligned + alignDelta = width; + } + label.rootElement.style('left', (x - alignDelta) + 'px'); + // Set top pixel margin; default to centered on y coordinate + var vAlignDelta = height * 0.5; + // Default to centered on x coordinate + if (label.valign == 'top') { + vAlignDelta = 0; + } + else if (label.valign == 'bottom') { + vAlignDelta = height; + } + label.rootElement.style('top', (y - vAlignDelta) + 'px'); + var rotate = "rotate(-" + label.rotate + "deg)"; + label.rootElement.style('-webkit-transform', rotate) + .style('transform', rotate); + return label; + }; + return Label; + }(KG.ViewObject)); + KG.Label = Label; +})(KG || (KG = {})); +/// +var KG; +(function (KG) { + var MathboxObject = /** @class */ (function (_super) { + __extends(MathboxObject, _super); + function MathboxObject(def) { + var _this = this; + KG.setProperties(def, 'constants', ['mathbox']); + _this = _super.call(this, def) || this; + return _this; + } + MathboxObject.prototype.onGraph = function () { + return true; // we won't check yet to see if it's on the graph... + }; + MathboxObject.prototype.displayElement = function (show) { + var mbo = this; + if (mbo.hasOwnProperty("mo")) { + this.mo.set("visible", show); + } + }; + return MathboxObject; + }(KG.ViewObject)); + KG.MathboxObject = MathboxObject; +})(KG || (KG = {})); +var KG; +(function (KG) { + var MathboxAxis = /** @class */ (function (_super) { + __extends(MathboxAxis, _super); + function MathboxAxis(def) { + var _this = this; + KG.setDefaults(def, { + ticks: 5, + min: 0, + max: 10 + }); + KG.setProperties(def, 'constants', ['axisNumber', 'ticks']); + KG.setProperties(def, 'updatables', ['ticks', 'label', 'min', 'max']); + _this = _super.call(this, def) || this; + return _this; + } + MathboxAxis.prototype.redraw = function () { + var a = this; + console.log(a); + var view = a.mathbox.mathboxView; + if (view == undefined) { + return a; + } + view.set("range", [[a.mathbox.yAxis.min, a.mathbox.yAxis.max], [a.mathbox.zAxis.min, a.mathbox.zAxis.max], [a.mathbox.xAxis.min, a.mathbox.xAxis.max]]); + var axis = view.axis({ axis: a.axisNumber, width: 8, detail: 40, color: "black" }); + var scale = view.scale({ axis: a.axisNumber, divide: a.ticks, nice: true, zero: true }); + var ticks = view.ticks({ width: 5, size: 15, color: "black", zBias: 2 }); + var format = view.format({ digits: 2, font: "KaTeX_Main", style: "normal", source: scale }); + var ticklabel = view.label({ color: "black", zIndex: 1, offset: [0, 0], points: scale, text: format }); + return a; + }; + return MathboxAxis; + }(KG.MathboxObject)); + KG.MathboxAxis = MathboxAxis; + var MathboxXAxis = /** @class */ (function (_super) { + __extends(MathboxXAxis, _super); + function MathboxXAxis(def) { + var _this = this; + def.axisNumber = 3; + _this = _super.call(this, def) || this; + var xAxis = _this; + xAxis.mathbox.xAxis = xAxis; + return _this; + } + return MathboxXAxis; + }(MathboxAxis)); + KG.MathboxXAxis = MathboxXAxis; + var MathboxYAxis = /** @class */ (function (_super) { + __extends(MathboxYAxis, _super); + function MathboxYAxis(def) { + var _this = this; + def.axisNumber = 1; + _this = _super.call(this, def) || this; + var yAxis = _this; + yAxis.mathbox.yAxis = yAxis; + return _this; + } + return MathboxYAxis; + }(MathboxAxis)); + KG.MathboxYAxis = MathboxYAxis; + var MathboxZAxis = /** @class */ (function (_super) { + __extends(MathboxZAxis, _super); + function MathboxZAxis(def) { + var _this = this; + def.axisNumber = 2; + _this = _super.call(this, def) || this; + var zAxis = _this; + zAxis.mathbox.zAxis = zAxis; + return _this; + } + return MathboxZAxis; + }(MathboxAxis)); + KG.MathboxZAxis = MathboxZAxis; +})(KG || (KG = {})); +var KG; +(function (KG) { + var MathboxPoint = /** @class */ (function (_super) { + __extends(MathboxPoint, _super); + function MathboxPoint(def) { + var _this = this; + KG.setDefaults(def, { + x: 0, + y: 0, + z: 0 + }); + KG.setProperties(def, 'updatables', ['x', 'y', 'z']); + _this = _super.call(this, def) || this; + return _this; + } + MathboxPoint.prototype.draw = function () { + var p = this; + p.pointData = p.mathbox.mathboxView.array({ + width: 1, + channels: 3 + }); + p.mo = p.mathbox.mathboxView.point({ + size: 20, + points: p.pointData, + zIndex: 4 + }); + return p; + }; + MathboxPoint.prototype.redraw = function () { + var p = this; + p.pointData.set("data", [[p.y, p.z, p.x]]); + p.mo.set("color", p.stroke); + return p; + }; + return MathboxPoint; + }(KG.MathboxObject)); + KG.MathboxPoint = MathboxPoint; +})(KG || (KG = {})); +var KG; +(function (KG) { + var MathboxCurve = /** @class */ (function (_super) { + __extends(MathboxCurve, _super); + function MathboxCurve(def) { + var _this = this; + KG.setDefaults(def, { + text: "#666666", + strokeWidth: 10 + }); + _this = _super.call(this, def) || this; + def.fn = KG.setDefaults(def.fn, { + model: def.model, + samplePoints: 100 + }); + _this.fn = new KG.UnivariateFunction(def.fn).update(true); + return _this; + } + MathboxCurve.prototype.draw = function () { + var c = this; + c.curveData = c.mathbox.mathboxView.interval({ + axis: 1, + channels: 3, + width: c.fn.samplePoints + }); + c.mo = c.mathbox.mathboxView.line({ + points: c.curveData, + zIndex: 3 + }); + return c; + }; + MathboxCurve.prototype.redraw = function () { + var c = this; + console.log(c); + c.curveData.set("expr", c.fn.mathboxFn()); + c.mo.set("color", c.stroke); + c.mo.set("width", c.strokeWidth); + return c; + }; + return MathboxCurve; + }(KG.MathboxObject)); + KG.MathboxCurve = MathboxCurve; +})(KG || (KG = {})); +var KG; +(function (KG) { + var MathboxSurface = /** @class */ (function (_super) { + __extends(MathboxSurface, _super); + function MathboxSurface(def) { + var _this = this; + KG.setDefaults(def, { + fill: "#666666", + strokeWidth: 10, + opacity: 0.2 + }); + _this = _super.call(this, def) || this; + def.fn = KG.setDefaults(def.fn, { + model: def.model, + samplePoints: 100 + }); + _this.fn = new KG.MultivariateFunction(def.fn).update(true); + return _this; + } + MathboxSurface.prototype.draw = function () { + var s = this; + s.surfaceData = s.mathbox.mathboxView.area({ + axes: [1, 3], + channels: 3, + width: s.fn.samplePoints, + height: s.fn.samplePoints + }); + s.mo = s.mathbox.mathboxView.surface({ + points: s.surfaceData, + shaded: false, + fill: true, + lineX: false, + lineY: false, + width: 0, + zIndex: 2 + }); + return s; + }; + MathboxSurface.prototype.redraw = function () { + var c = this; + console.log(c); + c.surfaceData.set("expr", c.fn.mathboxFn()); + c.mo.set("color", c.fill); + c.mo.set("opacity", c.opacity); + return c; + }; + return MathboxSurface; + }(KG.MathboxObject)); + KG.MathboxSurface = MathboxSurface; +})(KG || (KG = {})); +var KG; +(function (KG) { + var MathboxLabel = /** @class */ (function (_super) { + __extends(MathboxLabel, _super); + function MathboxLabel(def) { + var _this = this; + KG.setDefaults(def, { + text: "foo" + }); + KG.setProperties(def, 'updatables', ['text']); + _this = _super.call(this, def) || this; + return _this; + } + MathboxLabel.prototype.draw = function () { + var l = this; + l.pointData = l.mathbox.mathboxView.array({ + width: 1, + channels: 3 + }); + l.labelData = l.mathbox.mathboxView.format({ + font: "KaTeX_Main", + style: "normal" + }); + l.mo = l.mathbox.mathboxView.label({ + points: l.pointData, + zIndex: 4, + text: l.labelData + }); + return l; + }; + MathboxLabel.prototype.redraw = function () { + var l = _super.prototype.redraw.call(this); + l.labelData.set("data", [l.text]); + return l; + }; + return MathboxLabel; + }(KG.MathboxPoint)); + KG.MathboxLabel = MathboxLabel; +})(KG || (KG = {})); +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +// this file provides the interface with the overall web page +var views = []; +// initialize the diagram from divs with class kg-container +window.addEventListener("load", function () { + var viewDivs = document.getElementsByClassName('kg-container'); + var _loop_1 = function (i) { + var d = viewDivs[i], src = d.getAttribute('src'); + if (d.innerHTML.indexOf('svg') > -1) { + //console.log('already loaded'); + } + else { + // if there is no src attribute + if (!src) { + console.log('loading yaml'); + var j = void 0; + try { + // read inner HTML of div as YAML + var y = jsyaml.safeLoad(d.innerHTML); + // convert it to JSON, un-escaping HTML <, >, and & signs + j = JSON.parse(JSON.stringify(y).replace(/>/g, '>').replace(/</g, '<').replace(/&/g, '&')); + } + catch (e) { + console.log('Error reading YAML: ', e.message); + } + finally { + views.push(new KG.View(d, j)); + } + } + // first look to see if there's a definition in the KG.viewData object + else if (KG['viewData'].hasOwnProperty(src)) { + viewDivs[i].innerHTML = ""; + views.push(new KG.View(viewDivs[i], KG['viewData'][src])); + } + else { + // then look to see if the src is available by a URL + d3.json(src + "?update=true").then(function (data) { + if (!data) { + viewDivs[i].innerHTML = "

oops, " + src + " doesn't seem to exist.

"; + } + else { + viewDivs[i].innerHTML = ""; + views.push(new KG.View(viewDivs[i], data)); + } + }); + } + d.classList.add('kg-loaded'); + } + }; + // for each div, fetch the JSON definition and create a View object with that div and data + for (var i = 0; i < viewDivs.length; i++) { + _loop_1(i); + } +}); +// if the window changes size, update the dimensions of the containers +window.onresize = function () { + views.forEach(function (c) { + c.updateDimensions(); + }); +}; + +