compostjs 0.0.4 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,1686 +1,1530 @@
1
- import { List, Record, declare, Union } from "./fable-library.2.10.1/Types";
2
- import { bool_type, unit_type, record_type, option_type, lambda_type, array_type, class_type, tuple_type, float64_type, union_type, string_type, int32_type } from "./fable-library.2.10.1/Reflection";
3
- import { max as max$$1, min as min$$1, ofArray, ofSeq, reverse } from "./fable-library.2.10.1/List";
4
- import { insert, substring, toFail, newGuid, replace, toText, printf, join } from "./fable-library.2.10.1/String";
5
- import { ofList, fold, distinct, append as append$$1, ofSeq as ofSeq$$1, map } from "./fable-library.2.10.1/Array";
6
- import { forAll, exists, head, max as max$$2, min as min$$2, skip, rangeNumber, tryHead, filter, isEmpty, map as map$$1, empty, collect, append, delay, singleton, iterate } from "./fable-library.2.10.1/Seq";
7
- import { op_EqualsBangGreater, h as h$$13, text, s as s$$19, El$$$op_Dynamic$$Z451691CD as El$0024$0024$0024op_Dynamic$0024$0024Z451691CD, op_EqualsGreater, DomNode$reflection as DomNode$0024reflection } from "./html";
8
- import { uncurry, partialApply, curry, structuralHash, equals, max, round, int32ToString, min, comparePrimitives } from "./fable-library.2.10.1/Util";
9
- import { Choice, defaultArg } from "./fable-library.2.10.1/Option";
10
- export const Color = declare(function Compost_Color(tag, name, ...fields) {
11
- this.tag = tag | 0;
12
- this.name = name;
13
- this.fields = fields;
14
- }, Union);
15
- export function Color$reflection() {
16
- return union_type("Compost.Color", [], Color, () => [["RGB", [["Item1", int32_type], ["Item2", int32_type], ["Item3", int32_type]]], ["HTML", [["Item", string_type]]]]);
17
- }
18
- export const Width = declare(function Compost_Width(tag, name, ...fields) {
19
- this.tag = tag | 0;
20
- this.name = name;
21
- this.fields = fields;
22
- }, Union);
23
- export function Width$reflection() {
24
- return union_type("Compost.Width", [], Width, () => [["Pixels", [["Item", int32_type]]]]);
25
- }
26
- export const FillStyle = declare(function Compost_FillStyle(tag, name, ...fields) {
27
- this.tag = tag | 0;
28
- this.name = name;
29
- this.fields = fields;
30
- }, Union);
31
- export function FillStyle$reflection() {
32
- return union_type("Compost.FillStyle", [], FillStyle, () => [["Solid", [["Item", tuple_type(float64_type, Color$reflection())]]], ["LinearGradient", [["Item", class_type("System.Collections.Generic.IEnumerable`1", [tuple_type(float64_type, tuple_type(float64_type, Color$reflection()))])]]]]);
33
- }
34
- export const Number$ = declare(function Compost_Number(tag, name, ...fields) {
35
- this.tag = tag | 0;
36
- this.name = name;
37
- this.fields = fields;
38
- }, Union);
39
- export function Number$$reflection() {
40
- return union_type("Compost.Number", [], Number$, () => [["Integer", [["Item", int32_type]]], ["Percentage", [["Item", float64_type]]]]);
41
- }
42
- export const HorizontalAlign = declare(function Compost_HorizontalAlign(tag, name, ...fields) {
43
- this.tag = tag | 0;
44
- this.name = name;
45
- this.fields = fields;
46
- }, Union);
47
- export function HorizontalAlign$reflection() {
48
- return union_type("Compost.HorizontalAlign", [], HorizontalAlign, () => ["Start", "Center", "End"]);
49
- }
50
- export const VerticalAlign = declare(function Compost_VerticalAlign(tag, name, ...fields) {
51
- this.tag = tag | 0;
52
- this.name = name;
53
- this.fields = fields;
54
- }, Union);
55
- export function VerticalAlign$reflection() {
56
- return union_type("Compost.VerticalAlign", [], VerticalAlign, () => ["Baseline", "Middle", "Hanging"]);
57
- }
58
- export const continuous = declare(function Compost_continuous(tag, name, ...fields) {
59
- this.tag = tag | 0;
60
- this.name = name;
61
- this.fields = fields;
62
- }, Union);
63
- export function continuous$reflection($gen$$44) {
64
- return union_type("Compost.continuous", [$gen$$44], continuous, () => [["CO", [["Item", float64_type]]]]);
65
- }
66
- export const categorical = declare(function Compost_categorical(tag, name, ...fields) {
67
- this.tag = tag | 0;
68
- this.name = name;
69
- this.fields = fields;
70
- }, Union);
71
- export function categorical$reflection($gen$$45) {
72
- return union_type("Compost.categorical", [$gen$$45], categorical, () => [["CA", [["Item", string_type]]]]);
73
- }
74
- export const Value = declare(function Compost_Value(tag, name, ...fields) {
75
- this.tag = tag | 0;
76
- this.name = name;
77
- this.fields = fields;
78
- }, Union);
79
- export function Value$reflection($gen$$46) {
80
- return union_type("Compost.Value", [$gen$$46], Value, () => [["CAR", [["Item1", categorical$reflection($gen$$46)], ["Item2", float64_type]]], ["COV", [["Item", continuous$reflection($gen$$46)]]]]);
81
- }
82
- export const Scale = declare(function Compost_Scale(tag, name, ...fields) {
83
- this.tag = tag | 0;
84
- this.name = name;
85
- this.fields = fields;
86
- }, Union);
87
- export function Scale$reflection($gen$$47) {
88
- return union_type("Compost.Scale", [$gen$$47], Scale, () => [["Continuous", [["Item1", continuous$reflection($gen$$47)], ["Item2", continuous$reflection($gen$$47)]]], ["Categorical", [["Item", array_type(categorical$reflection($gen$$47))]]]]);
89
- }
90
- export const Style = declare(function Compost_Style(StrokeColor, StrokeWidth, StrokeDashArray, Fill, Animation, Font, Cursor, FormatAxisXLabel, FormatAxisYLabel) {
91
- this.StrokeColor = StrokeColor;
92
- this.StrokeWidth = StrokeWidth;
93
- this.StrokeDashArray = StrokeDashArray;
94
- this.Fill = Fill;
95
- this.Animation = Animation;
96
- this.Font = Font;
97
- this.Cursor = Cursor;
98
- this.FormatAxisXLabel = FormatAxisXLabel;
99
- this.FormatAxisYLabel = FormatAxisYLabel;
100
- }, Record);
101
- export function Style$reflection() {
102
- return record_type("Compost.Style", [], Style, () => [["StrokeColor", tuple_type(float64_type, Color$reflection())], ["StrokeWidth", Width$reflection()], ["StrokeDashArray", class_type("System.Collections.Generic.IEnumerable`1", [Number$$reflection()])], ["Fill", FillStyle$reflection()], ["Animation", option_type(tuple_type(int32_type, string_type, lambda_type(Style$reflection(), Style$reflection())))], ["Font", string_type], ["Cursor", string_type], ["FormatAxisXLabel", lambda_type(Scale$reflection(class_type("Microsoft.FSharp.Core.CompilerServices.MeasureOne")), lambda_type(Value$reflection(class_type("Microsoft.FSharp.Core.CompilerServices.MeasureOne")), string_type))], ["FormatAxisYLabel", lambda_type(Scale$reflection(class_type("Microsoft.FSharp.Core.CompilerServices.MeasureOne")), lambda_type(Value$reflection(class_type("Microsoft.FSharp.Core.CompilerServices.MeasureOne")), string_type))]]);
103
- }
104
- export const EventHandler = declare(function Compost_EventHandler(tag, name, ...fields) {
105
- this.tag = tag | 0;
106
- this.name = name;
107
- this.fields = fields;
108
- }, Union);
109
- export function EventHandler$reflection($gen$$48, $gen$$49) {
110
- return union_type("Compost.EventHandler", [$gen$$48, $gen$$49], EventHandler, () => [["MouseMove", [["Item", lambda_type(class_type("Browser.Types.MouseEvent"), lambda_type(tuple_type(Value$reflection($gen$$48), Value$reflection($gen$$49)), unit_type))]]], ["MouseUp", [["Item", lambda_type(class_type("Browser.Types.MouseEvent"), lambda_type(tuple_type(Value$reflection($gen$$48), Value$reflection($gen$$49)), unit_type))]]], ["MouseDown", [["Item", lambda_type(class_type("Browser.Types.MouseEvent"), lambda_type(tuple_type(Value$reflection($gen$$48), Value$reflection($gen$$49)), unit_type))]]], ["Click", [["Item", lambda_type(class_type("Browser.Types.MouseEvent"), lambda_type(tuple_type(Value$reflection($gen$$48), Value$reflection($gen$$49)), unit_type))]]], ["TouchStart", [["Item", lambda_type(class_type("Browser.Types.TouchEvent"), lambda_type(tuple_type(Value$reflection($gen$$48), Value$reflection($gen$$49)), unit_type))]]], ["TouchMove", [["Item", lambda_type(class_type("Browser.Types.TouchEvent"), lambda_type(tuple_type(Value$reflection($gen$$48), Value$reflection($gen$$49)), unit_type))]]], ["TouchEnd", [["Item", lambda_type(class_type("Browser.Types.TouchEvent"), unit_type)]]], ["MouseLeave", [["Item", lambda_type(class_type("Browser.Types.MouseEvent"), unit_type)]]]]);
111
- }
112
- export const Orientation = declare(function Compost_Orientation(tag, name, ...fields) {
113
- this.tag = tag | 0;
114
- this.name = name;
115
- this.fields = fields;
116
- }, Union);
117
- export function Orientation$reflection() {
118
- return union_type("Compost.Orientation", [], Orientation, () => ["Vertical", "Horizontal"]);
119
- }
120
- export const Shape = declare(function Compost_Shape(tag, name, ...fields) {
121
- this.tag = tag | 0;
122
- this.name = name;
123
- this.fields = fields;
124
- }, Union);
125
- export function Shape$reflection($gen$$50, $gen$$51) {
126
- return union_type("Compost.Shape", [$gen$$50, $gen$$51], Shape, () => [["Style", [["Item1", lambda_type(Style$reflection(), Style$reflection())], ["Item2", Shape$reflection($gen$$50, $gen$$51)]]], ["Text", [["Item1", Value$reflection($gen$$50)], ["Item2", Value$reflection($gen$$51)], ["Item3", VerticalAlign$reflection()], ["Item4", HorizontalAlign$reflection()], ["Item5", float64_type], ["Item6", string_type]]], ["AutoScale", [["Item1", bool_type], ["Item2", bool_type], ["Item3", Shape$reflection($gen$$50, $gen$$51)]]], ["InnerScale", [["Item1", option_type(Scale$reflection($gen$$50))], ["Item2", option_type(Scale$reflection($gen$$51))], ["Item3", Shape$reflection($gen$$50, $gen$$51)]]], ["NestX", [["Item1", Value$reflection($gen$$50)], ["Item2", Value$reflection($gen$$50)], ["Item3", Shape$reflection($gen$$50, $gen$$51)]]], ["NestY", [["Item1", Value$reflection($gen$$51)], ["Item2", Value$reflection($gen$$51)], ["Item3", Shape$reflection($gen$$50, $gen$$51)]]], ["Line", [["Item", class_type("System.Collections.Generic.IEnumerable`1", [tuple_type(Value$reflection($gen$$50), Value$reflection($gen$$51))])]]], ["Bubble", [["Item1", Value$reflection($gen$$50)], ["Item2", Value$reflection($gen$$51)], ["Item3", float64_type], ["Item4", float64_type]]], ["Shape", [["Item", class_type("System.Collections.Generic.IEnumerable`1", [tuple_type(Value$reflection($gen$$50), Value$reflection($gen$$51))])]]], ["Layered", [["Item", class_type("System.Collections.Generic.IEnumerable`1", [Shape$reflection($gen$$50, $gen$$51)])]]], ["Axes", [["Item1", bool_type], ["Item2", bool_type], ["Item3", bool_type], ["Item4", bool_type], ["Item5", Shape$reflection($gen$$50, $gen$$51)]]], ["Interactive", [["Item1", class_type("System.Collections.Generic.IEnumerable`1", [EventHandler$reflection($gen$$50, $gen$$51)])], ["Item2", Shape$reflection($gen$$50, $gen$$51)]]], ["Padding", [["Item1", tuple_type(float64_type, float64_type, float64_type, float64_type)], ["Item2", Shape$reflection($gen$$50, $gen$$51)]]], ["Offset", [["Item1", tuple_type(float64_type, float64_type)], ["Item2", Shape$reflection($gen$$50, $gen$$51)]]]]);
127
- }
128
- export const Svg$002EStringBuilder = declare(function Compost_Svg_StringBuilder() {
129
- const $this$$1 = this;
130
- $this$$1.strs = new List();
131
- void null;
132
- });
133
- export function Svg$002EStringBuilder$reflection() {
134
- return class_type("Compost.Svg.StringBuilder", undefined, Svg$002EStringBuilder);
135
- }
136
- export function Svg$002EStringBuilder$$$$002Ector() {
137
- return this instanceof Svg$002EStringBuilder ? Svg$002EStringBuilder.call(this) : new Svg$002EStringBuilder();
138
- }
139
- export function Svg$002EStringBuilder$$Append$$Z721C83C5(x, s) {
140
- x.strs = new List(s, x.strs);
141
- }
142
-
143
- Svg$002EStringBuilder.prototype.toString = function () {
144
- const x$$1 = this;
145
- return join("", reverse(x$$1.strs));
146
- };
147
-
148
- export const Svg$002EPathSegment = declare(function Compost_Svg_PathSegment(tag, name, ...fields) {
149
- this.tag = tag | 0;
150
- this.name = name;
151
- this.fields = fields;
152
- }, Union);
153
- export function Svg$002EPathSegment$reflection() {
154
- return union_type("Compost.Svg.PathSegment", [], Svg$002EPathSegment, () => [["MoveTo", [["Item", tuple_type(float64_type, float64_type)]]], ["LineTo", [["Item", tuple_type(float64_type, float64_type)]]]]);
155
- }
156
- export const Svg$002ESvg = declare(function Compost_Svg_Svg(tag, name, ...fields) {
157
- this.tag = tag | 0;
158
- this.name = name;
159
- this.fields = fields;
160
- }, Union);
161
- export function Svg$002ESvg$reflection() {
162
- return union_type("Compost.Svg.Svg", [], Svg$002ESvg, () => [["Path", [["Item1", array_type(Svg$002EPathSegment$reflection())], ["Item2", string_type]]], ["Ellipse", [["Item1", tuple_type(float64_type, float64_type)], ["Item2", tuple_type(float64_type, float64_type)], ["Item3", string_type]]], ["Rect", [["Item1", tuple_type(float64_type, float64_type)], ["Item2", tuple_type(float64_type, float64_type)], ["Item3", string_type]]], ["Text", [["Item1", tuple_type(float64_type, float64_type)], ["Item2", string_type], ["Item3", float64_type], ["Item4", string_type]]], ["Combine", [["Item", array_type(Svg$002ESvg$reflection())]]], "Empty"]);
163
- }
164
- export function Svg$$$mapSvg(f, _arg1) {
165
- if (_arg1.tag === 4) {
166
- return new Svg$002ESvg(4, "Combine", map(function (_arg1$$1) {
167
- return Svg$$$mapSvg(f, _arg1$$1);
168
- }, _arg1.fields[0], Array));
169
- } else {
170
- return f(_arg1);
171
- }
172
- }
173
- export function Svg$$$formatPath(path) {
174
- const sb = Svg$002EStringBuilder$$$$002Ector();
175
- iterate(function (ps) {
176
- if (ps.tag === 1) {
177
- Svg$002EStringBuilder$$Append$$Z721C83C5(sb, "L" + ps.fields[0][0].toString() + " " + ps.fields[0][1].toString() + " ");
178
- } else {
179
- Svg$002EStringBuilder$$Append$$Z721C83C5(sb, "M" + ps.fields[0][0].toString() + " " + ps.fields[0][1].toString() + " ");
180
- }
181
- }, path);
182
- return String(sb);
183
- }
184
- export const Svg$002ERenderingContext = declare(function Compost_Svg_RenderingContext(Definitions) {
185
- this.Definitions = Definitions;
186
- }, Record);
187
- export function Svg$002ERenderingContext$reflection() {
188
- return record_type("Compost.Svg.RenderingContext", [], Svg$002ERenderingContext, () => [["Definitions", array_type(DomNode$0024reflection())]]);
189
- }
190
- export function Svg$$$renderSvg(ctx, svg$$1) {
191
- return delay(function () {
192
- switch (svg$$1.tag) {
193
- case 3:
194
- {
195
- const attrs = ofSeq(delay(function () {
196
- return append(singleton(op_EqualsGreater("style", svg$$1.fields[3])), delay(function () {
197
- return svg$$1.fields[2] === 0 ? append(singleton(op_EqualsGreater("x", svg$$1.fields[0][0].toString())), delay(function () {
198
- return singleton(op_EqualsGreater("y", svg$$1.fields[0][1].toString()));
199
- })) : append(singleton(op_EqualsGreater("x", "0")), delay(function () {
200
- return append(singleton(op_EqualsGreater("y", "0")), delay(function () {
201
- var clo1, clo2, clo3;
202
- return singleton(op_EqualsGreater("transform", (clo1 = toText(printf("translate(%f,%f) rotate(%f)")), clo2 = clo1(svg$$1.fields[0][0]), clo3 = clo2(svg$$1.fields[0][1]), clo3(svg$$1.fields[2]))));
203
- }));
204
- }));
205
- }));
206
- }));
207
- return singleton(function (arg0) {
208
- return function (arg1) {
209
- return El$0024$0024$0024op_Dynamic$0024$0024Z451691CD(arg0, arg1);
210
- };
211
- }(s$$19)("text")(attrs)(new List(text(svg$$1.fields[1]), new List())));
212
- }
213
-
214
- case 4:
215
- {
216
- return collect(function (s$$1) {
217
- return Svg$$$renderSvg(ctx, s$$1);
218
- }, svg$$1.fields[0]);
219
- }
220
-
221
- case 1:
222
- {
223
- const attrs$$1 = ofArray([op_EqualsGreater("cx", svg$$1.fields[0][0].toString()), op_EqualsGreater("cy", svg$$1.fields[0][1].toString()), op_EqualsGreater("rx", svg$$1.fields[1][0].toString()), op_EqualsGreater("ry", svg$$1.fields[1][1].toString()), op_EqualsGreater("style", svg$$1.fields[2])]);
224
- return singleton(function (arg0$$1) {
225
- return function (arg1$$1) {
226
- return El$0024$0024$0024op_Dynamic$0024$0024Z451691CD(arg0$$1, arg1$$1);
227
- };
228
- }(s$$19)("ellipse")(attrs$$1)(new List()));
229
- }
230
-
231
- case 2:
232
- {
233
- const patternInput = [min(comparePrimitives, svg$$1.fields[0][0], svg$$1.fields[1][0]), min(comparePrimitives, svg$$1.fields[0][1], svg$$1.fields[1][1])];
234
- const patternInput$$1 = [Math.abs(svg$$1.fields[0][0] - svg$$1.fields[1][0]), Math.abs(svg$$1.fields[0][1] - svg$$1.fields[1][1])];
235
- const attrs$$2 = ofArray([op_EqualsGreater("x", patternInput[0].toString()), op_EqualsGreater("y", patternInput[1].toString()), op_EqualsGreater("width", patternInput$$1[0].toString()), op_EqualsGreater("height", patternInput$$1[1].toString()), op_EqualsGreater("style", svg$$1.fields[2])]);
236
- return singleton(function (arg0$$2) {
237
- return function (arg1$$2) {
238
- return El$0024$0024$0024op_Dynamic$0024$0024Z451691CD(arg0$$2, arg1$$2);
239
- };
240
- }(s$$19)("rect")(attrs$$2)(new List()));
241
- }
242
-
243
- case 0:
244
- {
245
- const attrs$$3 = ofArray([op_EqualsGreater("d", Svg$$$formatPath(svg$$1.fields[0])), op_EqualsGreater("style", svg$$1.fields[1])]);
246
- return singleton(function (arg0$$3) {
247
- return function (arg1$$3) {
248
- return El$0024$0024$0024op_Dynamic$0024$0024Z451691CD(arg0$$3, arg1$$3);
249
- };
250
- }(s$$19)("path")(attrs$$3)(new List()));
251
- }
252
-
253
- default:
254
- {
255
- void null;
256
- return empty();
257
- }
258
- }
259
- });
260
- }
261
- export function Svg$$$formatColor(_arg1$$2) {
262
- if (_arg1$$2.tag === 1) {
263
- return _arg1$$2.fields[0];
264
- } else {
265
- const clo1$$1 = toText(printf("rgb(%d, %d, %d)"));
266
- const clo2$$1 = clo1$$1(_arg1$$2.fields[0]);
267
- const clo3$$1 = clo2$$1(_arg1$$2.fields[1]);
268
- return clo3$$1(_arg1$$2.fields[2]);
269
- }
270
- }
271
- export function Svg$$$formatNumber(_arg1$$3) {
272
- if (_arg1$$3.tag === 1) {
273
- return _arg1$$3.fields[0].toString() + "%";
274
- } else {
275
- return int32ToString(_arg1$$3.fields[0]);
276
- }
277
- }
278
- export function Svg$$$formatStyle(defs, style$$4) {
279
- var copyOfStruct, Animation, inputRecord, Animation$$1, clo1$$2, clo2$$2, clo3$$2, clo1$$3, clo2$$3, clo3$$3, arg30$$4, clo1$$4, clo2$$4, clo3$$4, arg20$$5, clo1$$6, clo2$$5, id$$1, copyOfStruct$$1, arg00$$1, clo1$$5;
280
- let patternInput$$2;
281
-
282
- if (style$$4.Animation == null) {
283
- patternInput$$2 = [style$$4, ""];
284
- } else {
285
- const ms = style$$4.Animation[0] | 0;
286
- const ease = style$$4.Animation[1];
287
- const anim = style$$4.Animation[2];
288
- const id = "anim_" + replace((copyOfStruct = newGuid(), copyOfStruct), "-", "");
289
- const fromstyle = Svg$$$formatStyle(defs, (Animation = undefined, new Style(style$$4.StrokeColor, style$$4.StrokeWidth, style$$4.StrokeDashArray, style$$4.Fill, Animation, style$$4.Font, style$$4.Cursor, style$$4.FormatAxisXLabel, style$$4.FormatAxisYLabel)));
290
- const tostyle = Svg$$$formatStyle(defs, (inputRecord = anim(style$$4), (Animation$$1 = undefined, new Style(inputRecord.StrokeColor, inputRecord.StrokeWidth, inputRecord.StrokeDashArray, inputRecord.Fill, Animation$$1, inputRecord.Font, inputRecord.Cursor, inputRecord.FormatAxisXLabel, inputRecord.FormatAxisYLabel))));
291
-
292
- const arg00 = function (arg0$$4) {
293
- return function (arg1$$4) {
294
- return El$0024$0024$0024op_Dynamic$0024$0024Z451691CD(arg0$$4, arg1$$4);
295
- };
296
- }(h$$13)("style")(new List())(new List(text((clo1$$2 = toText(printf("@keyframes %s { from { %s } to { %s } }")), clo2$$2 = clo1$$2(id), clo3$$2 = clo2$$2(fromstyle), clo3$$2(tostyle))), new List()));
297
-
298
- void defs.push(arg00);
299
- patternInput$$2 = [anim(style$$4), (clo1$$3 = toText(printf("animation: %s %dms %s; ")), clo2$$3 = clo1$$3(id), clo3$$3 = clo2$$3(ms), clo3$$3(ease))];
300
- }
301
-
302
- return patternInput$$2[1] + join("", ofSeq(delay(function () {
303
- return map$$1(function (c) {
304
- return "cursor:" + c + ";";
305
- }, patternInput$$2[0].Cursor.split(","));
306
- }))) + ("font:" + patternInput$$2[0].Font + ";") + (arg30$$4 = Svg$$$formatColor(patternInput$$2[0].StrokeColor[1]), (clo1$$4 = toText(printf("stroke-opacity:%f; stroke-width:%dpx; stroke:%s; ")), clo2$$4 = clo1$$4(patternInput$$2[0].StrokeColor[0]), clo3$$4 = clo2$$4(patternInput$$2[0].StrokeWidth.fields[0]), clo3$$4(arg30$$4))) + (isEmpty(patternInput$$2[0].StrokeDashArray) ? "" : "stroke-dasharray:" + join(",", map$$1(Svg$$$formatNumber, patternInput$$2[0].StrokeDashArray)) + ";") + (patternInput$$2[0].Fill.tag === 0 ? (arg20$$5 = Svg$$$formatColor(patternInput$$2[0].Fill.fields[0][1]), (clo1$$6 = toText(printf("fill-opacity:%f; fill:%s; ")), clo2$$5 = clo1$$6(patternInput$$2[0].Fill.fields[0][0]), clo2$$5(arg20$$5))) : (id$$1 = "gradient_" + replace((copyOfStruct$$1 = newGuid(), copyOfStruct$$1), "-", ""), ((arg00$$1 = (El$0024$0024$0024op_Dynamic$0024$0024Z451691CD(s$$19, "linearGradient"))(new List(op_EqualsGreater("id", id$$1), new List()))(ofSeq(delay(function () {
307
- return collect(function (matchValue$$2) {
308
- return singleton((El$0024$0024$0024op_Dynamic$0024$0024Z451691CD(s$$19, "stop"))(ofArray([op_EqualsGreater("offset", matchValue$$2[0].toString() + "%"), op_EqualsGreater("stop-color", Svg$$$formatColor(matchValue$$2[1][1])), op_EqualsGreater("stop-opacity", matchValue$$2[1][0].toString())]))(new List()));
309
- }, patternInput$$2[0].Fill.fields[0]);
310
- }))), (void defs.push(arg00$$1))), (clo1$$5 = toText(printf("fill:url(#%s)")), clo1$$5(id$$1)))));
311
- }
312
- export const Scales$002EScaledShape = declare(function Compost_Scales_ScaledShape(tag, name, ...fields) {
313
- this.tag = tag | 0;
314
- this.name = name;
315
- this.fields = fields;
316
- }, Union);
317
- export function Scales$002EScaledShape$reflection($gen$$63, $gen$$64) {
318
- return union_type("Compost.Scales.ScaledShape", [$gen$$63, $gen$$64], Scales$002EScaledShape, () => [["ScaledStyle", [["Item1", lambda_type(Style$reflection(), Style$reflection())], ["Item2", Scales$002EScaledShape$reflection($gen$$63, $gen$$64)]]], ["ScaledText", [["Item1", Value$reflection($gen$$63)], ["Item2", Value$reflection($gen$$64)], ["Item3", VerticalAlign$reflection()], ["Item4", HorizontalAlign$reflection()], ["Item5", float64_type], ["Item6", string_type]]], ["ScaledLine", [["Item", array_type(tuple_type(Value$reflection($gen$$63), Value$reflection($gen$$64)))]]], ["ScaledBubble", [["Item1", Value$reflection($gen$$63)], ["Item2", Value$reflection($gen$$64)], ["Item3", float64_type], ["Item4", float64_type]]], ["ScaledShape", [["Item", array_type(tuple_type(Value$reflection($gen$$63), Value$reflection($gen$$64)))]]], ["ScaledLayered", [["Item", array_type(Scales$002EScaledShape$reflection($gen$$63, $gen$$64))]]], ["ScaledInteractive", [["Item1", class_type("System.Collections.Generic.IEnumerable`1", [EventHandler$reflection($gen$$63, $gen$$64)])], ["Item2", Scale$reflection($gen$$63)], ["Item3", Scale$reflection($gen$$64)], ["Item4", Scales$002EScaledShape$reflection($gen$$63, $gen$$64)]]], ["ScaledPadding", [["Item1", tuple_type(float64_type, float64_type, float64_type, float64_type)], ["Item2", Scale$reflection($gen$$63)], ["Item3", Scale$reflection($gen$$64)], ["Item4", Scales$002EScaledShape$reflection($gen$$63, $gen$$64)]]], ["ScaledOffset", [["Item1", tuple_type(float64_type, float64_type)], ["Item2", Scales$002EScaledShape$reflection($gen$$63, $gen$$64)]]], ["ScaledNestX", [["Item1", Value$reflection($gen$$63)], ["Item2", Value$reflection($gen$$63)], ["Item3", Scale$reflection($gen$$63)], ["Item4", Scales$002EScaledShape$reflection($gen$$63, $gen$$64)]]], ["ScaledNestY", [["Item1", Value$reflection($gen$$64)], ["Item2", Value$reflection($gen$$64)], ["Item3", Scale$reflection($gen$$64)], ["Item4", Scales$002EScaledShape$reflection($gen$$63, $gen$$64)]]]]);
319
- }
320
- export function Scales$$$getExtremes(_arg1$$5) {
321
- if (_arg1$$5.tag === 1) {
322
- return [new Value(0, "CAR", _arg1$$5.fields[0][0], 0), new Value(0, "CAR", _arg1$$5.fields[0][_arg1$$5.fields[0].length - 1], 1)];
323
- } else {
324
- return [new Value(1, "COV", _arg1$$5.fields[0]), new Value(1, "COV", _arg1$$5.fields[1])];
325
- }
326
- }
327
- export function Scales$$$calculateMagnitudeAndRange(lo, hi) {
328
- const magnitude = Math.pow(10, round(Math.log10(hi - lo)));
329
- const magnitude$$1 = magnitude / 2;
330
- return [magnitude$$1, [Math.floor(lo / magnitude$$1) * magnitude$$1, Math.ceil(hi / magnitude$$1) * magnitude$$1]];
331
- }
332
- export function Scales$$$decimalPoints(range_0, range_1) {
333
- const patternInput$$5 = Scales$$$calculateMagnitudeAndRange(range_0, range_1);
334
- return max(comparePrimitives, 0, Math.ceil(-Math.log10(patternInput$$5[0])));
335
- }
336
- export function Scales$$$adjustRange(range_0$$1, range_1$$1) {
337
- return Scales$$$calculateMagnitudeAndRange(range_0$$1, range_1$$1)[1];
338
- }
339
- export function Scales$$$adjustRangeUnits(l$$2, h$$2) {
340
- const patternInput$$6 = Scales$$$adjustRange(l$$2, h$$2);
341
- return [patternInput$$6[0], patternInput$$6[1]];
342
- }
343
- export function Scales$$$toArray(s$$2) {
344
- return ofSeq$$1(s$$2, Array);
345
- }
346
- export function Scales$$$generateSteps(count, k, lo$$3, hi$$3) {
347
- const patternInput$$7 = Scales$$$calculateMagnitudeAndRange(lo$$3, hi$$3);
348
- const dividers = ofArray([0.2, 0.5, 1, 2, 5, 10, 20, 40, 50, 60, 80, 100]);
349
- let magnitudes;
350
- magnitudes = map$$1(function mapping(d) {
351
- return patternInput$$7[0] / d;
352
- }, dividers);
353
- let step;
354
- let source$$2;
355
- source$$2 = filter(function predicate(m) {
356
- return (hi$$3 - lo$$3) / m >= count;
357
- }, magnitudes);
358
- step = tryHead(source$$2);
359
- const step$$1 = defaultArg(step, patternInput$$7[0] / 100);
360
- const s$$3 = delay(function () {
361
- return collect(function (v) {
362
- return (v >= lo$$3 ? v <= hi$$3 : false) ? singleton(v) : empty();
363
- }, rangeNumber(patternInput$$7[1][0], step$$1 * k, patternInput$$7[1][1]));
364
- });
365
- return Scales$$$toArray(s$$3);
366
- }
367
- export function Scales$$$generateAxisSteps(s$$4) {
368
- if (s$$4.tag === 1) {
369
- return ofSeq$$1(delay(function () {
370
- return collect(function (matchValue$$3) {
371
- return singleton(new Value(0, "CAR", new categorical(0, "CA", matchValue$$3.fields[0]), 0.5));
372
- }, s$$4.fields[0]);
373
- }), Array);
374
- } else {
375
- const array = Scales$$$generateSteps(6, 1, s$$4.fields[0].fields[0], s$$4.fields[1].fields[0]);
376
- return map(function mapping$$1(f$$1) {
377
- return new Value(1, "COV", new continuous(0, "CO", f$$1));
378
- }, array, Array);
379
- }
380
- }
381
- export function Scales$$$generateAxisLabels(fmt, s$$6) {
382
- const sunit = s$$6;
383
-
384
- if (s$$6.tag === 1) {
385
- return ofSeq$$1(delay(function () {
386
- return collect(function (matchValue$$4) {
387
- return singleton([new Value(0, "CAR", new categorical(0, "CA", matchValue$$4.fields[0]), 0.5), fmt(sunit, new Value(0, "CAR", new categorical(0, "CA", matchValue$$4.fields[0]), 0.5))]);
388
- }, s$$6.fields[0]);
389
- }), Array);
390
- } else {
391
- const array$$1 = Scales$$$generateSteps(6, 2, s$$6.fields[0].fields[0], s$$6.fields[1].fields[0]);
392
- return map(function mapping$$2(f$$2) {
393
- return [new Value(1, "COV", new continuous(0, "CO", f$$2)), fmt(sunit, new Value(1, "COV", new continuous(0, "CO", f$$2)))];
394
- }, array$$1, Array);
395
- }
396
- }
397
- export function Scales$$$unionScales(s1, s2) {
398
- var $target$$88, h1, h2, l1, l2, v1, v2;
399
-
400
- if (s1.tag === 1) {
401
- if (s2.tag === 1) {
402
- $target$$88 = 1;
403
- v1 = s1.fields[0];
404
- v2 = s2.fields[0];
405
- } else {
406
- $target$$88 = 2;
407
- }
408
- } else if (s2.tag === 0) {
409
- $target$$88 = 0;
410
- h1 = s1.fields[1];
411
- h2 = s2.fields[1];
412
- l1 = s1.fields[0];
413
- l2 = s2.fields[0];
414
- } else {
415
- $target$$88 = 2;
416
- }
417
-
418
- switch ($target$$88) {
419
- case 0:
420
- {
421
- return new Scale(0, "Continuous", min(function ($x$$8, $y$$9) {
422
- return $x$$8.CompareTo($y$$9);
423
- }, l1, l2), max(function ($x$$10, $y$$11) {
424
- return $x$$10.CompareTo($y$$11);
425
- }, h1, h2));
426
- }
427
-
428
- case 1:
429
- {
430
- return new Scale(1, "Categorical", distinct(append$$1(v1, v2, Array), {
431
- Equals: equals,
432
- GetHashCode: structuralHash
433
- }));
434
- }
435
-
436
- case 2:
437
- {
438
- throw new Error("Cannot union continuous with categorical");
439
- }
440
- }
441
- }
442
- export function Scales$$$calculateShapeScale(vals$$1) {
443
- let scales;
444
- const state$$1 = new Choice(0, "Choice1Of3", void null);
445
- scales = fold(function folder(state, value) {
446
- var $target$$92, v$$2, v$$3, vs$$2, x$$5, x$$6, xs;
447
-
448
- if (state.tag === 1) {
449
- if (value.tag === 1) {
450
- $target$$92 = 1;
451
- v$$3 = value.fields[0].fields[0];
452
- vs$$2 = state.fields[0];
453
- } else {
454
- $target$$92 = 4;
455
- }
456
- } else if (state.tag === 2) {
457
- if (value.tag === 0) {
458
- $target$$92 = 3;
459
- x$$6 = value.fields[0].fields[0];
460
- xs = state.fields[0];
461
- } else {
462
- $target$$92 = 4;
463
- }
464
- } else if (value.tag === 0) {
465
- $target$$92 = 2;
466
- x$$5 = value.fields[0].fields[0];
467
- } else {
468
- $target$$92 = 0;
469
- v$$2 = value.fields[0].fields[0];
470
- }
471
-
472
- switch ($target$$92) {
473
- case 0:
474
- {
475
- return new Choice(1, "Choice2Of3", new List(v$$2, new List()));
476
- }
477
-
478
- case 1:
479
- {
480
- return new Choice(1, "Choice2Of3", new List(v$$3, vs$$2));
481
- }
482
-
483
- case 2:
484
- {
485
- return new Choice(2, "Choice3Of3", new List(x$$5, new List()));
486
- }
487
-
488
- case 3:
489
- {
490
- return new Choice(2, "Choice3Of3", new List(x$$6, xs));
491
- }
492
-
493
- case 4:
494
- {
495
- throw new Error("Values with mismatching scales");
496
- }
497
- }
498
- }, state$$1, vals$$1);
499
-
500
- switch (scales.tag) {
501
- case 1:
502
- {
503
- return new Scale(0, "Continuous", new continuous(0, "CO", min$$1(scales.fields[0], {
504
- Compare: comparePrimitives
505
- })), new continuous(0, "CO", max$$1(scales.fields[0], {
506
- Compare: comparePrimitives
507
- })));
508
- }
509
-
510
- case 2:
511
- {
512
- return new Scale(1, "Categorical", distinct(ofSeq$$1(delay(function () {
513
- return map$$1(function (x$$7) {
514
- return new categorical(0, "CA", x$$7);
515
- }, reverse(scales.fields[0]));
516
- }), Array), {
517
- Equals: equals,
518
- GetHashCode: structuralHash
519
- }));
520
- }
521
-
522
- default:
523
- {
524
- throw new Error("No values for calculating a scale");
525
- }
526
- }
527
- }
528
- export function Scales$$$calculateShapeScales(points$$1) {
529
- let xs$$2;
530
- xs$$2 = map(function mapping$$3(tuple) {
531
- return tuple[0];
532
- }, points$$1, Array);
533
- let ys;
534
- ys = map(function mapping$$4(tuple$$1) {
535
- return tuple$$1[1];
536
- }, points$$1, Array);
537
- return [Scales$$$calculateShapeScale(xs$$2), Scales$$$calculateShapeScale(ys)];
538
- }
539
- export function Scales$$$calculateScales(style$$6, shape) {
540
- const calculateScales = function calculateScales(shape$$2) {
541
- return Scales$$$calculateScales(style$$6, shape$$2);
542
- };
543
-
544
- switch (shape.tag) {
545
- case 4:
546
- {
547
- const patternInput$$9 = calculateScales(shape.fields[2]);
548
- return [[Scales$$$calculateShapeScale([shape.fields[0], shape.fields[1]]), patternInput$$9[0][1]], new Scales$002EScaledShape(9, "ScaledNestX", shape.fields[0], shape.fields[1], patternInput$$9[0][0], patternInput$$9[1])];
549
- }
550
-
551
- case 5:
552
- {
553
- const patternInput$$10 = calculateScales(shape.fields[2]);
554
- return [[patternInput$$10[0][0], Scales$$$calculateShapeScale([shape.fields[0], shape.fields[1]])], new Scales$002EScaledShape(10, "ScaledNestY", shape.fields[0], shape.fields[1], patternInput$$10[0][1], patternInput$$10[1])];
555
- }
556
-
557
- case 3:
558
- {
559
- const patternInput$$11 = calculateScales(shape.fields[2]);
560
- let sx$$2;
561
-
562
- if (shape.fields[0] != null) {
563
- const sx$$1 = shape.fields[0];
564
- sx$$2 = sx$$1;
565
- } else {
566
- sx$$2 = patternInput$$11[0][0];
567
- }
568
-
569
- let sy$$2;
570
-
571
- if (shape.fields[1] != null) {
572
- const sy$$1 = shape.fields[1];
573
- sy$$2 = sy$$1;
574
- } else {
575
- sy$$2 = patternInput$$11[0][1];
576
- }
577
-
578
- return [[sx$$2, sy$$2], patternInput$$11[1]];
579
- }
580
-
581
- case 2:
582
- {
583
- const patternInput$$12 = calculateScales(shape.fields[2]);
584
-
585
- const autoScale = function autoScale(_arg1$$6) {
586
- if (_arg1$$6.tag === 0) {
587
- const patternInput$$13 = Scales$$$adjustRangeUnits(_arg1$$6.fields[0].fields[0], _arg1$$6.fields[1].fields[0]);
588
- return new Scale(0, "Continuous", new continuous(0, "CO", patternInput$$13[0]), new continuous(0, "CO", patternInput$$13[1]));
589
- } else {
590
- return _arg1$$6;
591
- }
592
- };
593
-
594
- const scales$$2 = [shape.fields[0] ? autoScale(patternInput$$12[0][0]) : patternInput$$12[0][0], shape.fields[1] ? autoScale(patternInput$$12[0][1]) : patternInput$$12[0][1]];
595
- return [scales$$2, patternInput$$12[1]];
596
- }
597
-
598
- case 13:
599
- {
600
- const patternInput$$14 = calculateScales(shape.fields[1]);
601
- return [patternInput$$14[0], new Scales$002EScaledShape(8, "ScaledOffset", shape.fields[0], patternInput$$14[1])];
602
- }
603
-
604
- case 12:
605
- {
606
- const patternInput$$15 = calculateScales(shape.fields[1]);
607
- return [[patternInput$$15[0][0], patternInput$$15[0][1]], new Scales$002EScaledShape(7, "ScaledPadding", shape.fields[0], patternInput$$15[0][0], patternInput$$15[0][1], patternInput$$15[1])];
608
- }
609
-
610
- case 7:
611
- {
612
- const makeSingletonScale = function makeSingletonScale(_arg2) {
613
- if (_arg2.tag === 0) {
614
- return new Scale(1, "Categorical", [_arg2.fields[0]]);
615
- } else {
616
- return new Scale(0, "Continuous", _arg2.fields[0], _arg2.fields[0]);
617
- }
618
- };
619
-
620
- const scales$$4 = [makeSingletonScale(shape.fields[0]), makeSingletonScale(shape.fields[1])];
621
- return [scales$$4, new Scales$002EScaledShape(3, "ScaledBubble", shape.fields[0], shape.fields[1], shape.fields[2], shape.fields[3])];
622
- }
623
-
624
- case 1:
625
- {
626
- const makeSingletonScale$$1 = function makeSingletonScale$$1(_arg3) {
627
- if (_arg3.tag === 0) {
628
- return new Scale(1, "Categorical", [_arg3.fields[0]]);
629
- } else {
630
- return new Scale(0, "Continuous", _arg3.fields[0], _arg3.fields[0]);
631
- }
632
- };
633
-
634
- const scales$$5 = [makeSingletonScale$$1(shape.fields[0]), makeSingletonScale$$1(shape.fields[1])];
635
- return [scales$$5, new Scales$002EScaledShape(1, "ScaledText", shape.fields[0], shape.fields[1], shape.fields[2], shape.fields[3], shape.fields[4], shape.fields[5])];
636
- }
637
-
638
- case 6:
639
- {
640
- const line$$1 = ofSeq$$1(shape.fields[0], Array);
641
- const scales$$6 = Scales$$$calculateShapeScales(line$$1);
642
- return [scales$$6, new Scales$002EScaledShape(2, "ScaledLine", line$$1)];
643
- }
644
-
645
- case 8:
646
- {
647
- const points$$3 = ofSeq$$1(shape.fields[0], Array);
648
- const scales$$7 = Scales$$$calculateShapeScales(points$$3);
649
- return [scales$$7, new Scales$002EScaledShape(4, "ScaledShape", points$$3)];
650
- }
651
-
652
- case 10:
653
- {
654
- const patternInput$$16 = calculateScales(shape.fields[4]);
655
- const patternInput$$17 = [Scales$$$getExtremes(patternInput$$16[0][0]), Scales$$$getExtremes(patternInput$$16[0][1])];
656
-
657
- const LineStyle = function LineStyle(clr$$4, alpha, width, shape$$18) {
658
- return new Shape(0, "Style", function (s$$8) {
659
- const Fill = new FillStyle(0, "Solid", [1, new Color(1, "HTML", "transparent")]);
660
- const StrokeWidth = new Width(0, "Pixels", width);
661
- return new Style([alpha, new Color(1, "HTML", clr$$4)], StrokeWidth, s$$8.StrokeDashArray, Fill, s$$8.Animation, s$$8.Font, s$$8.Cursor, s$$8.FormatAxisXLabel, s$$8.FormatAxisYLabel);
662
- }, shape$$18);
663
- };
664
-
665
- const FontStyle = function FontStyle(style$$8, shape$$19) {
666
- return new Shape(0, "Style", function (s$$9) {
667
- const Fill$$1 = new FillStyle(0, "Solid", [1, new Color(1, "HTML", "black")]);
668
- return new Style([0, new Color(1, "HTML", "transparent")], s$$9.StrokeWidth, s$$9.StrokeDashArray, Fill$$1, s$$9.Animation, style$$8, s$$9.Cursor, s$$9.FormatAxisXLabel, s$$9.FormatAxisYLabel);
669
- }, shape$$19);
670
- };
671
-
672
- const shape$$20 = new Shape(9, "Layered", ofSeq(delay(function () {
673
- return append(map$$1(function (x$$10) {
674
- return LineStyle("#e4e4e4", 1, 1, new Shape(6, "Line", [[x$$10, patternInput$$17[1][0]], [x$$10, patternInput$$17[1][1]]]));
675
- }, Scales$$$generateAxisSteps(patternInput$$16[0][0])), delay(function () {
676
- return append(map$$1(function (y$$5) {
677
- return LineStyle("#e4e4e4", 1, 1, new Shape(6, "Line", [[patternInput$$17[0][0], y$$5], [patternInput$$17[0][1], y$$5]]));
678
- }, Scales$$$generateAxisSteps(patternInput$$16[0][1])), delay(function () {
679
- return append(shape.fields[0] ? append(singleton(LineStyle("black", 1, 2, new Shape(6, "Line", [[patternInput$$17[0][0], patternInput$$17[1][1]], [patternInput$$17[0][1], patternInput$$17[1][1]]]))), delay(function () {
680
- return collect(function (matchValue$$7) {
681
- return singleton(FontStyle("9pt sans-serif", new Shape(13, "Offset", [0, -10], new Shape(1, "Text", matchValue$$7[0], patternInput$$17[1][1], new VerticalAlign(0, "Baseline"), new HorizontalAlign(1, "Center"), 0, matchValue$$7[1]))));
682
- }, Scales$$$generateAxisLabels(style$$6.FormatAxisXLabel, patternInput$$16[0][0]));
683
- })) : empty(), delay(function () {
684
- return append(shape.fields[1] ? append(singleton(LineStyle("black", 1, 2, new Shape(6, "Line", [[patternInput$$17[0][1], patternInput$$17[1][1]], [patternInput$$17[0][1], patternInput$$17[1][0]]]))), delay(function () {
685
- return collect(function (matchValue$$8) {
686
- return singleton(FontStyle("9pt sans-serif", new Shape(13, "Offset", [10, 0], new Shape(1, "Text", patternInput$$17[0][1], matchValue$$8[0], new VerticalAlign(1, "Middle"), new HorizontalAlign(0, "Start"), 0, matchValue$$8[1]))));
687
- }, Scales$$$generateAxisLabels(style$$6.FormatAxisYLabel, patternInput$$16[0][1]));
688
- })) : empty(), delay(function () {
689
- return append(shape.fields[2] ? append(singleton(LineStyle("black", 1, 2, new Shape(6, "Line", [[patternInput$$17[0][0], patternInput$$17[1][0]], [patternInput$$17[0][1], patternInput$$17[1][0]]]))), delay(function () {
690
- return collect(function (matchValue$$9) {
691
- return singleton(FontStyle("9pt sans-serif", new Shape(13, "Offset", [0, 10], new Shape(1, "Text", matchValue$$9[0], patternInput$$17[1][0], new VerticalAlign(2, "Hanging"), new HorizontalAlign(1, "Center"), 0, matchValue$$9[1]))));
692
- }, Scales$$$generateAxisLabels(style$$6.FormatAxisXLabel, patternInput$$16[0][0]));
693
- })) : empty(), delay(function () {
694
- return append(shape.fields[3] ? append(singleton(LineStyle("black", 1, 2, new Shape(6, "Line", [[patternInput$$17[0][0], patternInput$$17[1][1]], [patternInput$$17[0][0], patternInput$$17[1][0]]]))), delay(function () {
695
- return collect(function (matchValue$$10) {
696
- return singleton(FontStyle("9pt sans-serif", new Shape(13, "Offset", [-10, 0], new Shape(1, "Text", patternInput$$17[0][0], matchValue$$10[0], new VerticalAlign(1, "Middle"), new HorizontalAlign(2, "End"), 0, matchValue$$10[1]))));
697
- }, Scales$$$generateAxisLabels(style$$6.FormatAxisYLabel, patternInput$$16[0][1]));
698
- })) : empty(), delay(function () {
699
- return singleton(shape.fields[4]);
700
- }));
701
- }));
702
- }));
703
- }));
704
- }));
705
- }));
706
- })));
707
- const padding = [shape.fields[0] ? 30 : 0, shape.fields[1] ? 50 : 0, shape.fields[2] ? 30 : 0, shape.fields[3] ? 50 : 0];
708
- return calculateScales(new Shape(12, "Padding", padding, shape$$20));
709
- }
710
-
711
- case 9:
712
- {
713
- let shapes$$1;
714
- shapes$$1 = ofSeq$$1(shape.fields[0], Array);
715
- let scaled;
716
- scaled = map(calculateScales, shapes$$1, Array);
717
- let sxs;
718
- sxs = map(function mapping$$5(tupledArg) {
719
- return tupledArg[0][0];
720
- }, scaled, Array);
721
- let sys;
722
- sys = map(function mapping$$6(tupledArg$$1) {
723
- return tupledArg$$1[0][1];
724
- }, scaled, Array);
725
- const scales$$8 = [sxs.reduce(Scales$$$unionScales), sys.reduce(Scales$$$unionScales)];
726
- return [scales$$8, new Scales$002EScaledShape(5, "ScaledLayered", map(function (tuple$$2) {
727
- return tuple$$2[1];
728
- }, scaled, Array))];
729
- }
730
-
731
- case 11:
732
- {
733
- const patternInput$$18 = calculateScales(shape.fields[1]);
734
- return [patternInput$$18[0], new Scales$002EScaledShape(6, "ScaledInteractive", shape.fields[0], patternInput$$18[0][0], patternInput$$18[0][1], patternInput$$18[1])];
735
- }
736
-
737
- default:
738
- {
739
- let patternInput$$8;
740
- const style$$7 = shape.fields[0](style$$6);
741
- patternInput$$8 = Scales$$$calculateScales(style$$7, shape.fields[1]);
742
- return [patternInput$$8[0], new Scales$002EScaledShape(0, "ScaledStyle", shape.fields[0], patternInput$$8[1])];
743
- }
744
- }
745
- }
746
- export function Projections$$$projectOne(reversed, tlv, thv, scale$$1, coord) {
747
- if (scale$$1.tag === 0) {
748
- if (coord.tag === 0) {
749
- const clo1$$8 = toFail(printf("Cannot project categorical value (%A) on a continuous scale (%A)."));
750
- const clo2$$7 = clo1$$8(coord);
751
- return clo2$$7(scale$$1);
752
- } else {
753
- if (reversed) {
754
- return thv - (coord.fields[0].fields[0] - scale$$1.fields[0].fields[0]) / (scale$$1.fields[1].fields[0] - scale$$1.fields[0].fields[0]) * (thv - tlv);
755
- } else {
756
- return tlv + (coord.fields[0].fields[0] - scale$$1.fields[0].fields[0]) / (scale$$1.fields[1].fields[0] - scale$$1.fields[0].fields[0]) * (thv - tlv);
757
- }
758
- }
759
- } else if (coord.tag === 1) {
760
- const clo1$$7 = toFail(printf("Cannot project continuous value (%A) on a categorical scale (%A)."));
761
- const clo2$$6 = clo1$$7(coord);
762
- return clo2$$6(scale$$1);
763
- } else {
764
- const size = (thv - tlv) / scale$$1.fields[0].length;
765
- let i;
766
- i = scale$$1.fields[0].findIndex(function predicate$$1(_arg1$$8) {
767
- return coord.fields[0].fields[0] === _arg1$$8.fields[0];
768
- });
769
- const i$$1 = i + coord.fields[1];
770
-
771
- if (reversed) {
772
- return thv - i$$1 * size;
773
- } else {
774
- return tlv + i$$1 * size;
775
- }
776
- }
777
- }
778
- export function Projections$$$projectOneX(a_0, a_1) {
779
- return function (scale$$2) {
780
- return function (coord$$1) {
781
- return Projections$$$projectOne(false, a_0, a_1, scale$$2, coord$$1);
782
- };
783
- };
784
- }
785
- export function Projections$$$projectOneY(a_0$$1, a_1$$1) {
786
- return function (scale$$3) {
787
- return function (coord$$2) {
788
- return Projections$$$projectOne(true, a_0$$1, a_1$$1, scale$$3, coord$$2);
789
- };
790
- };
791
- }
792
- export function Projections$$$projectInvOne(reversed$$3, l$$12, h$$8, s$$10, v$$10) {
793
- if (s$$10.tag === 1) {
794
- const size$$1 = (h$$8 - l$$12) / s$$10.fields[0].length;
795
- const i$$2 = reversed$$3 ? Math.floor((h$$8 - v$$10) / size$$1) : Math.floor((v$$10 - l$$12) / size$$1);
796
- const f$$6 = reversed$$3 ? (h$$8 - v$$10) / size$$1 - i$$2 : (v$$10 - l$$12) / size$$1 - i$$2;
797
- const i$$3 = size$$1 < 0 ? s$$10.fields[0].length + i$$2 : i$$2;
798
-
799
- if (~~i$$3 < 0 ? true : ~~i$$3 >= s$$10.fields[0].length) {
800
- return new Value(0, "CAR", new categorical(0, "CA", "<outside-of-range>"), f$$6);
801
- } else {
802
- return new Value(0, "CAR", s$$10.fields[0][~~i$$3], f$$6);
803
- }
804
- } else {
805
- if (reversed$$3) {
806
- return new Value(1, "COV", new continuous(0, "CO", s$$10.fields[1].fields[0] - (v$$10 - l$$12) / (h$$8 - l$$12) * (s$$10.fields[1].fields[0] - s$$10.fields[0].fields[0])));
807
- } else {
808
- return new Value(1, "COV", new continuous(0, "CO", s$$10.fields[0].fields[0] + (v$$10 - l$$12) / (h$$8 - l$$12) * (s$$10.fields[1].fields[0] - s$$10.fields[0].fields[0])));
809
- }
810
- }
811
- }
812
- export function Projections$$$projectInv(x1$$1, y1$$1, x2$$1, y2$$1, sx$$6, sy$$6, x$$13, y$$8) {
813
- return [Projections$$$projectInvOne(false, x1$$1, x2$$1, sx$$6, x$$13), Projections$$$projectInvOne(true, y1$$1, y2$$1, sy$$6, y$$8)];
814
- }
815
- export const Drawing$002EDrawingContext = declare(function Compost_Drawing_DrawingContext(Style, Definitions) {
816
- this.Style = Style;
817
- this.Definitions = Definitions;
818
- }, Record);
819
- export function Drawing$002EDrawingContext$reflection() {
820
- return record_type("Compost.Drawing.DrawingContext", [], Drawing$002EDrawingContext, () => [["Style", Style$reflection()], ["Definitions", array_type(DomNode$0024reflection())]]);
821
- }
822
- export function Drawing$$$hideFill(style$$9) {
823
- const Fill$$2 = new FillStyle(0, "Solid", [0, new Color(0, "RGB", 0, 0, 0)]);
824
- let Animation$$2;
825
-
826
- if (style$$9.Animation != null) {
827
- const n$$1 = style$$9.Animation[0] | 0;
828
- const f$$7 = style$$9.Animation[2];
829
- const e = style$$9.Animation[1];
830
- Animation$$2 = [n$$1, e, function ($arg$$20) {
831
- const style$$10 = f$$7($arg$$20);
832
- return Drawing$$$hideFill(style$$10);
833
- }];
834
- } else {
835
- Animation$$2 = undefined;
836
- }
837
-
838
- return new Style(style$$9.StrokeColor, style$$9.StrokeWidth, style$$9.StrokeDashArray, Fill$$2, Animation$$2, style$$9.Font, style$$9.Cursor, style$$9.FormatAxisXLabel, style$$9.FormatAxisYLabel);
839
- }
840
- export function Drawing$$$hideStroke(style$$11) {
841
- let Animation$$3;
842
-
843
- if (style$$11.Animation != null) {
844
- const n$$2 = style$$11.Animation[0] | 0;
845
- const f$$8 = style$$11.Animation[2];
846
- const e$$1 = style$$11.Animation[1];
847
- Animation$$3 = [n$$2, e$$1, function ($arg$$21) {
848
- const style$$12 = f$$8($arg$$21);
849
- return Drawing$$$hideStroke(style$$12);
850
- }];
851
- } else {
852
- Animation$$3 = undefined;
853
- }
854
-
855
- return new Style([0, style$$11.StrokeColor[1]], style$$11.StrokeWidth, style$$11.StrokeDashArray, style$$11.Fill, Animation$$3, style$$11.Font, style$$11.Cursor, style$$11.FormatAxisXLabel, style$$11.FormatAxisYLabel);
856
- }
857
- export function Drawing$$$drawShape($ctx$$1$$135, $_arg2_0$$136, $_arg2_1$$137, $_arg2_2$$138, $_arg2_3$$139, $_arg1_0$$140, $_arg1_1$$141, $shape$$23$$142) {
858
- var clo1$$9, clo2$$8;
859
-
860
- Drawing$$$drawShape: while (true) {
861
- const ctx$$1 = $ctx$$1$$135,
862
- _arg2_0 = $_arg2_0$$136,
863
- _arg2_1 = $_arg2_1$$137,
864
- _arg2_2 = $_arg2_2$$138,
865
- _arg2_3 = $_arg2_3$$139,
866
- _arg1_0 = $_arg1_0$$140,
867
- _arg1_1 = $_arg1_1$$141,
868
- shape$$23 = $shape$$23$$142;
869
-
870
- const project = function project(tupledArg$$2) {
871
- return [Projections$$$projectOneX(_arg2_0, _arg2_2)(_arg1_0)(tupledArg$$2[0]), Projections$$$projectOneY(_arg2_1, _arg2_3)(_arg1_1)(tupledArg$$2[1])];
872
- };
873
-
874
- switch (shape$$23.tag) {
875
- case 10:
876
- {
877
- const y1$0027 = Projections$$$projectOneY(_arg2_1, _arg2_3)(_arg1_1)(shape$$23.fields[0]);
878
- const y2$0027 = Projections$$$projectOneY(_arg2_1, _arg2_3)(_arg1_1)(shape$$23.fields[1]);
879
- $ctx$$1$$135 = ctx$$1;
880
- $_arg2_0$$136 = _arg2_0;
881
- $_arg2_1$$137 = y1$0027;
882
- $_arg2_2$$138 = _arg2_2;
883
- $_arg2_3$$139 = y2$0027;
884
- $_arg1_0$$140 = _arg1_0;
885
- $_arg1_1$$141 = shape$$23.fields[2];
886
- $shape$$23$$142 = shape$$23.fields[3];
887
- continue Drawing$$$drawShape;
888
- }
889
-
890
- case 8:
891
- {
892
- const arg10$0040 = _arg2_0 + shape$$23.fields[0][0];
893
- const arg11$0040 = _arg2_1 + shape$$23.fields[0][1];
894
- const arg12$0040 = _arg2_2 + shape$$23.fields[0][0];
895
- const arg13$0040 = _arg2_3 + shape$$23.fields[0][1];
896
- $ctx$$1$$135 = ctx$$1;
897
- $_arg2_0$$136 = arg10$0040;
898
- $_arg2_1$$137 = arg11$0040;
899
- $_arg2_2$$138 = arg12$0040;
900
- $_arg2_3$$139 = arg13$0040;
901
- $_arg1_0$$140 = _arg1_0;
902
- $_arg1_1$$141 = _arg1_1;
903
- $shape$$23$$142 = shape$$23.fields[1];
904
- continue Drawing$$$drawShape;
905
- }
906
-
907
- case 5:
908
- {
909
- return new Svg$002ESvg(4, "Combine", map(function (shape$$27) {
910
- return Drawing$$$drawShape(ctx$$1, _arg2_0, _arg2_1, _arg2_2, _arg2_3, _arg1_0, _arg1_1, shape$$27);
911
- }, shape$$23.fields[0], Array));
912
- }
913
-
914
- case 0:
915
- {
916
- const ctx$$2 = new Drawing$002EDrawingContext(shape$$23.fields[0](ctx$$1.Style), ctx$$1.Definitions);
917
- $ctx$$1$$135 = ctx$$2;
918
- $_arg2_0$$136 = _arg2_0;
919
- $_arg2_1$$137 = _arg2_1;
920
- $_arg2_2$$138 = _arg2_2;
921
- $_arg2_3$$139 = _arg2_3;
922
- $_arg1_0$$140 = _arg1_0;
923
- $_arg1_1$$141 = _arg1_1;
924
- $shape$$23$$142 = shape$$23.fields[1];
925
- continue Drawing$$$drawShape;
926
- }
927
-
928
- case 4:
929
- {
930
- const path$$1 = ofSeq$$1(delay(function () {
931
- return append(singleton(new Svg$002EPathSegment(0, "MoveTo", project(shape$$23.fields[0][0]))), delay(function () {
932
- return append(map$$1(function (pt$$1) {
933
- return new Svg$002EPathSegment(1, "LineTo", project(pt$$1));
934
- }, skip(1, shape$$23.fields[0])), delay(function () {
935
- return singleton(new Svg$002EPathSegment(1, "LineTo", project(shape$$23.fields[0][0])));
936
- }));
937
- }));
938
- }), Array);
939
- return new Svg$002ESvg(0, "Path", path$$1, Svg$$$formatStyle(ctx$$1.Definitions, Drawing$$$hideStroke(ctx$$1.Style)));
940
- }
941
-
942
- case 7:
943
- {
944
- const calculateNestedRange = function calculateNestedRange(rev, tupledArg$$3, ins, outs) {
945
- if (ins.tag === 1) {
946
- let pos$$1;
947
- pos$$1 = collect(function mapping$$7(v$$11) {
948
- return ofArray([Projections$$$projectOne(rev, tupledArg$$3[0], tupledArg$$3[1], outs, new Value(0, "CAR", v$$11, 0)), Projections$$$projectOne(rev, tupledArg$$3[0], tupledArg$$3[1], outs, new Value(0, "CAR", v$$11, 1))]);
949
- }, ins.fields[0]);
950
- return [min$$2(pos$$1, {
951
- Compare: comparePrimitives
952
- }), max$$2(pos$$1, {
953
- Compare: comparePrimitives
954
- })];
955
- } else {
956
- const pos = ofArray([Projections$$$projectOne(rev, tupledArg$$3[0], tupledArg$$3[1], outs, new Value(1, "COV", new continuous(0, "CO", ins.fields[0].fields[0]))), Projections$$$projectOne(rev, tupledArg$$3[0], tupledArg$$3[1], outs, new Value(1, "COV", new continuous(0, "CO", ins.fields[1].fields[0])))]);
957
- return [min$$2(pos, {
958
- Compare: comparePrimitives
959
- }), max$$2(pos, {
960
- Compare: comparePrimitives
961
- })];
962
- }
963
- };
964
-
965
- const patternInput$$19 = calculateNestedRange(false, [_arg2_0, _arg2_2], shape$$23.fields[1], _arg1_0);
966
- const patternInput$$20 = calculateNestedRange(true, [_arg2_1, _arg2_3], shape$$23.fields[2], _arg1_1);
967
- $ctx$$1$$135 = ctx$$1;
968
- $_arg2_0$$136 = patternInput$$19[0] + shape$$23.fields[0][3];
969
- $_arg2_1$$137 = patternInput$$20[0] + shape$$23.fields[0][0];
970
- $_arg2_2$$138 = patternInput$$19[1] - shape$$23.fields[0][1];
971
- $_arg2_3$$139 = patternInput$$20[1] - shape$$23.fields[0][2];
972
- $_arg1_0$$140 = shape$$23.fields[1];
973
- $_arg1_1$$141 = shape$$23.fields[2];
974
- $shape$$23$$142 = shape$$23.fields[3];
975
- continue Drawing$$$drawShape;
976
- }
977
-
978
- case 2:
979
- {
980
- let path$$2;
981
- const list = ofSeq(delay(function () {
982
- return append(singleton(new Svg$002EPathSegment(0, "MoveTo", project(head(shape$$23.fields[0])))), delay(function () {
983
- return map$$1(function (pt$$2) {
984
- return new Svg$002EPathSegment(1, "LineTo", project(pt$$2));
985
- }, skip(1, shape$$23.fields[0]));
986
- }));
987
- }));
988
- path$$2 = ofList(list, Array);
989
- return new Svg$002ESvg(0, "Path", path$$2, Svg$$$formatStyle(ctx$$1.Definitions, Drawing$$$hideFill(ctx$$1.Style)));
990
- }
991
-
992
- case 1:
993
- {
994
- const va$$2 = shape$$23.fields[2].tag === 2 ? "hanging" : shape$$23.fields[2].tag === 1 ? "middle" : "baseline";
995
- const ha$$2 = shape$$23.fields[3].tag === 1 ? "middle" : shape$$23.fields[3].tag === 2 ? "end" : "start";
996
- const xy = project([shape$$23.fields[0], shape$$23.fields[1]]);
997
- return new Svg$002ESvg(3, "Text", xy, shape$$23.fields[5], shape$$23.fields[4], (clo1$$9 = toText(printf("alignment-baseline:%s; text-anchor:%s;")), clo2$$8 = clo1$$9(va$$2), clo2$$8(ha$$2)) + Svg$$$formatStyle(ctx$$1.Definitions, ctx$$1.Style));
998
- }
999
-
1000
- case 3:
1001
- {
1002
- return new Svg$002ESvg(1, "Ellipse", project([shape$$23.fields[0], shape$$23.fields[1]]), [shape$$23.fields[2], shape$$23.fields[3]], Svg$$$formatStyle(ctx$$1.Definitions, ctx$$1.Style));
1003
- }
1004
-
1005
- case 6:
1006
- {
1007
- $ctx$$1$$135 = ctx$$1;
1008
- $_arg2_0$$136 = _arg2_0;
1009
- $_arg2_1$$137 = _arg2_1;
1010
- $_arg2_2$$138 = _arg2_2;
1011
- $_arg2_3$$139 = _arg2_3;
1012
- $_arg1_0$$140 = _arg1_0;
1013
- $_arg1_1$$141 = _arg1_1;
1014
- $shape$$23$$142 = shape$$23.fields[3];
1015
- continue Drawing$$$drawShape;
1016
- }
1017
-
1018
- default:
1019
- {
1020
- const x1$0027 = Projections$$$projectOneX(_arg2_0, _arg2_2)(_arg1_0)(shape$$23.fields[0]);
1021
- const x2$0027 = Projections$$$projectOneX(_arg2_0, _arg2_2)(_arg1_0)(shape$$23.fields[1]);
1022
- $ctx$$1$$135 = ctx$$1;
1023
- $_arg2_0$$136 = x1$0027;
1024
- $_arg2_1$$137 = _arg2_1;
1025
- $_arg2_2$$138 = x2$0027;
1026
- $_arg2_3$$139 = _arg2_3;
1027
- $_arg1_0$$140 = shape$$23.fields[2];
1028
- $_arg1_1$$141 = _arg1_1;
1029
- $shape$$23$$142 = shape$$23.fields[3];
1030
- continue Drawing$$$drawShape;
1031
- }
1032
- }
1033
-
1034
- break;
1035
- }
1036
- }
1037
- export const Events$002EMouseEventKind = declare(function Compost_Events_MouseEventKind(tag, name, ...fields) {
1038
- this.tag = tag | 0;
1039
- this.name = name;
1040
- this.fields = fields;
1041
- }, Union);
1042
- export function Events$002EMouseEventKind$reflection() {
1043
- return union_type("Compost.Events.MouseEventKind", [], Events$002EMouseEventKind, () => ["Click", "Move", "Up", "Down"]);
1044
- }
1045
- export const Events$002ETouchEventKind = declare(function Compost_Events_TouchEventKind(tag, name, ...fields) {
1046
- this.tag = tag | 0;
1047
- this.name = name;
1048
- this.fields = fields;
1049
- }, Union);
1050
- export function Events$002ETouchEventKind$reflection() {
1051
- return union_type("Compost.Events.TouchEventKind", [], Events$002ETouchEventKind, () => ["Move", "Start"]);
1052
- }
1053
- export const Events$002EInteractiveEvent = declare(function Compost_Events_InteractiveEvent(tag, name, ...fields) {
1054
- this.tag = tag | 0;
1055
- this.name = name;
1056
- this.fields = fields;
1057
- }, Union);
1058
- export function Events$002EInteractiveEvent$reflection($gen$$149, $gen$$150) {
1059
- return union_type("Compost.Events.InteractiveEvent", [$gen$$149, $gen$$150], Events$002EInteractiveEvent, () => [["MouseEvent", [["Item1", Events$002EMouseEventKind$reflection()], ["Item2", tuple_type(Value$reflection($gen$$149), Value$reflection($gen$$150))]]], ["TouchEvent", [["Item1", Events$002ETouchEventKind$reflection()], ["Item2", tuple_type(Value$reflection($gen$$149), Value$reflection($gen$$150))]]], "TouchEnd", "MouseLeave"]);
1060
- }
1061
- export function Events$$$projectEvent(area_0, area_1, area_2, area_3, scales_0, scales_1, event) {
1062
- var $target$$158, kind, x$$16, y$$11, kind$$1, x$$17, y$$12;
1063
-
1064
- if (event.tag === 1) {
1065
- if (event.fields[1][0].tag === 1) {
1066
- if (event.fields[1][1].tag === 1) {
1067
- $target$$158 = 1;
1068
- kind$$1 = event.fields[0];
1069
- x$$17 = event.fields[1][0].fields[0].fields[0];
1070
- y$$12 = event.fields[1][1].fields[0].fields[0];
1071
- } else {
1072
- $target$$158 = 2;
1073
- }
1074
- } else {
1075
- $target$$158 = 2;
1076
- }
1077
- } else if (event.tag === 2) {
1078
- $target$$158 = 3;
1079
- } else if (event.tag === 3) {
1080
- $target$$158 = 4;
1081
- } else if (event.fields[1][0].tag === 1) {
1082
- if (event.fields[1][1].tag === 1) {
1083
- $target$$158 = 0;
1084
- kind = event.fields[0];
1085
- x$$16 = event.fields[1][0].fields[0].fields[0];
1086
- y$$11 = event.fields[1][1].fields[0].fields[0];
1087
- } else {
1088
- $target$$158 = 2;
1089
- }
1090
- } else {
1091
- $target$$158 = 2;
1092
- }
1093
-
1094
- switch ($target$$158) {
1095
- case 0:
1096
- {
1097
- return new Events$002EInteractiveEvent(0, "MouseEvent", kind, Projections$$$projectInv(area_0, area_1, area_2, area_3, scales_0, scales_1, x$$16, y$$11));
1098
- }
1099
-
1100
- case 1:
1101
- {
1102
- return new Events$002EInteractiveEvent(1, "TouchEvent", kind$$1, Projections$$$projectInv(area_0, area_1, area_2, area_3, scales_0, scales_1, x$$17, y$$12));
1103
- }
1104
-
1105
- case 2:
1106
- {
1107
- throw new Error("TODO: projectEvent - not continuous");
1108
- }
1109
-
1110
- case 3:
1111
- {
1112
- return new Events$002EInteractiveEvent(2, "TouchEnd");
1113
- }
1114
-
1115
- case 4:
1116
- {
1117
- return new Events$002EInteractiveEvent(3, "MouseLeave");
1118
- }
1119
- }
1120
- }
1121
- export function Events$$$inScale(s$$11, v$$12) {
1122
- if (s$$11.tag === 1) {
1123
- if (v$$12.tag === 1) {
1124
- throw new Error("inScale: Cannot test if continuous value is in categorical scale");
1125
- } else {
1126
- return exists(function predicate$$2(y$$13) {
1127
- return equals(v$$12.fields[0], y$$13);
1128
- }, s$$11.fields[0]);
1129
- }
1130
- } else if (v$$12.tag === 0) {
1131
- throw new Error("inScale: Cannot test if categorical value is in continuous scale");
1132
- } else {
1133
- if (v$$12.fields[0].fields[0] >= min(comparePrimitives, s$$11.fields[0].fields[0], s$$11.fields[1].fields[0])) {
1134
- return v$$12.fields[0].fields[0] <= max(comparePrimitives, s$$11.fields[0].fields[0], s$$11.fields[1].fields[0]);
1135
- } else {
1136
- return false;
1137
- }
1138
- }
1139
- }
1140
- export function Events$$$inScales(sx$$10, sy$$10, event$$1) {
1141
- var $target$$165, x$$18, y$$14;
1142
-
1143
- switch (event$$1.tag) {
1144
- case 2:
1145
- $target$$165 = 1;
1146
- break;
1147
-
1148
- case 0:
1149
- $target$$165 = 2;
1150
- x$$18 = event$$1.fields[1][0];
1151
- y$$14 = event$$1.fields[1][1];
1152
- break;
1153
-
1154
- case 1:
1155
- $target$$165 = 2;
1156
- x$$18 = event$$1.fields[1][0];
1157
- y$$14 = event$$1.fields[1][1];
1158
- break;
1159
-
1160
- default:
1161
- $target$$165 = 0;
1162
- }
1163
-
1164
- switch ($target$$165) {
1165
- case 0:
1166
- {
1167
- return true;
1168
- }
1169
-
1170
- case 1:
1171
- {
1172
- return true;
1173
- }
1174
-
1175
- case 2:
1176
- {
1177
- if (Events$$$inScale(sx$$10, x$$18)) {
1178
- return Events$$$inScale(sy$$10, y$$14);
1179
- } else {
1180
- return false;
1181
- }
1182
- }
1183
- }
1184
- }
1185
- export function Events$$$triggerEvent($_arg2_0$$1$$166, $_arg2_1$$1$$167, $_arg2_2$$1$$168, $_arg2_3$$1$$169, $_arg1_0$$1$$170, $_arg1_1$$1$$171, $shape$$31$$172, $jse$$173, $event$$2$$174) {
1186
- Events$$$triggerEvent: while (true) {
1187
- const _arg2_0$$1 = $_arg2_0$$1$$166,
1188
- _arg2_1$$1 = $_arg2_1$$1$$167,
1189
- _arg2_2$$1 = $_arg2_2$$1$$168,
1190
- _arg2_3$$1 = $_arg2_3$$1$$169,
1191
- _arg1_0$$1 = $_arg1_0$$1$$170,
1192
- _arg1_1$$1 = $_arg1_1$$1$$171,
1193
- shape$$31 = $shape$$31$$172,
1194
- jse = $jse$$173,
1195
- event$$2 = $event$$2$$174;
1196
-
1197
- switch (shape$$31.tag) {
1198
- case 1:
1199
- case 3:
1200
- case 4:
1201
- {
1202
- void null;
1203
- break;
1204
- }
1205
-
1206
- case 0:
1207
- {
1208
- $_arg2_0$$1$$166 = _arg2_0$$1;
1209
- $_arg2_1$$1$$167 = _arg2_1$$1;
1210
- $_arg2_2$$1$$168 = _arg2_2$$1;
1211
- $_arg2_3$$1$$169 = _arg2_3$$1;
1212
- $_arg1_0$$1$$170 = _arg1_0$$1;
1213
- $_arg1_1$$1$$171 = _arg1_1$$1;
1214
- $shape$$31$$172 = shape$$31.fields[1];
1215
- $jse$$173 = jse;
1216
- $event$$2$$174 = event$$2;
1217
- continue Events$$$triggerEvent;
1218
- break;
1219
- }
1220
-
1221
- case 8:
1222
- {
1223
- const arg00$0040$$1 = _arg2_0$$1 + shape$$31.fields[0][0];
1224
- const arg01$0040$$1 = _arg2_1$$1 + shape$$31.fields[0][1];
1225
- const arg02$0040$$1 = _arg2_2$$1 + shape$$31.fields[0][0];
1226
- const arg03$0040$$1 = _arg2_3$$1 + shape$$31.fields[0][1];
1227
- $_arg2_0$$1$$166 = arg00$0040$$1;
1228
- $_arg2_1$$1$$167 = arg01$0040$$1;
1229
- $_arg2_2$$1$$168 = arg02$0040$$1;
1230
- $_arg2_3$$1$$169 = arg03$0040$$1;
1231
- $_arg1_0$$1$$170 = _arg1_0$$1;
1232
- $_arg1_1$$1$$171 = _arg1_1$$1;
1233
- $shape$$31$$172 = shape$$31.fields[1];
1234
- $jse$$173 = jse;
1235
- $event$$2$$174 = event$$2;
1236
- continue Events$$$triggerEvent;
1237
- break;
1238
- }
1239
-
1240
- case 9:
1241
- {
1242
- const x1$0027$$2 = Projections$$$projectOneX(_arg2_0$$1, _arg2_2$$1)(_arg1_0$$1)(shape$$31.fields[0]);
1243
- const x2$0027$$2 = Projections$$$projectOneX(_arg2_0$$1, _arg2_2$$1)(_arg1_0$$1)(shape$$31.fields[1]);
1244
- $_arg2_0$$1$$166 = x1$0027$$2;
1245
- $_arg2_1$$1$$167 = _arg2_1$$1;
1246
- $_arg2_2$$1$$168 = x2$0027$$2;
1247
- $_arg2_3$$1$$169 = _arg2_3$$1;
1248
- $_arg1_0$$1$$170 = shape$$31.fields[2];
1249
- $_arg1_1$$1$$171 = _arg1_1$$1;
1250
- $shape$$31$$172 = shape$$31.fields[3];
1251
- $jse$$173 = jse;
1252
- $event$$2$$174 = event$$2;
1253
- continue Events$$$triggerEvent;
1254
- break;
1255
- }
1256
-
1257
- case 10:
1258
- {
1259
- const y1$0027$$2 = Projections$$$projectOneY(_arg2_1$$1, _arg2_3$$1)(_arg1_1$$1)(shape$$31.fields[0]);
1260
- const y2$0027$$2 = Projections$$$projectOneY(_arg2_1$$1, _arg2_3$$1)(_arg1_1$$1)(shape$$31.fields[1]);
1261
- $_arg2_0$$1$$166 = _arg2_0$$1;
1262
- $_arg2_1$$1$$167 = y1$0027$$2;
1263
- $_arg2_2$$1$$168 = _arg2_2$$1;
1264
- $_arg2_3$$1$$169 = y2$0027$$2;
1265
- $_arg1_0$$1$$170 = _arg1_0$$1;
1266
- $_arg1_1$$1$$171 = shape$$31.fields[2];
1267
- $shape$$31$$172 = shape$$31.fields[3];
1268
- $jse$$173 = jse;
1269
- $event$$2$$174 = event$$2;
1270
- continue Events$$$triggerEvent;
1271
- break;
1272
- }
1273
-
1274
- case 7:
1275
- {
1276
- const calculateNestedRange$$1 = function calculateNestedRange$$1(rev$$1, tupledArg$$4, ins$$1, outs$$1) {
1277
- if (ins$$1.tag === 1) {
1278
- let pos$$3;
1279
- pos$$3 = collect(function mapping$$8(v$$15) {
1280
- return ofArray([Projections$$$projectOne(rev$$1, tupledArg$$4[0], tupledArg$$4[1], outs$$1, new Value(0, "CAR", v$$15, 0)), Projections$$$projectOne(rev$$1, tupledArg$$4[0], tupledArg$$4[1], outs$$1, new Value(0, "CAR", v$$15, 1))]);
1281
- }, ins$$1.fields[0]);
1282
- return [min$$2(pos$$3, {
1283
- Compare: comparePrimitives
1284
- }), max$$2(pos$$3, {
1285
- Compare: comparePrimitives
1286
- })];
1287
- } else {
1288
- const pos$$2 = ofArray([Projections$$$projectOne(rev$$1, tupledArg$$4[0], tupledArg$$4[1], outs$$1, new Value(1, "COV", new continuous(0, "CO", ins$$1.fields[0].fields[0]))), Projections$$$projectOne(rev$$1, tupledArg$$4[0], tupledArg$$4[1], outs$$1, new Value(1, "COV", new continuous(0, "CO", ins$$1.fields[1].fields[0])))]);
1289
- return [min$$2(pos$$2, {
1290
- Compare: comparePrimitives
1291
- }), max$$2(pos$$2, {
1292
- Compare: comparePrimitives
1293
- })];
1294
- }
1295
- };
1296
-
1297
- const patternInput$$21 = calculateNestedRange$$1(false, [_arg2_0$$1, _arg2_2$$1], shape$$31.fields[1], _arg1_0$$1);
1298
- const patternInput$$22 = calculateNestedRange$$1(true, [_arg2_1$$1, _arg2_3$$1], shape$$31.fields[2], _arg1_1$$1);
1299
- $_arg2_0$$1$$166 = patternInput$$21[0] + shape$$31.fields[0][3];
1300
- $_arg2_1$$1$$167 = patternInput$$22[0] + shape$$31.fields[0][0];
1301
- $_arg2_2$$1$$168 = patternInput$$21[1] - shape$$31.fields[0][1];
1302
- $_arg2_3$$1$$169 = patternInput$$22[1] - shape$$31.fields[0][2];
1303
- $_arg1_0$$1$$170 = shape$$31.fields[1];
1304
- $_arg1_1$$1$$171 = shape$$31.fields[2];
1305
- $shape$$31$$172 = shape$$31.fields[3];
1306
- $jse$$173 = jse;
1307
- $event$$2$$174 = event$$2;
1308
- continue Events$$$triggerEvent;
1309
- break;
1310
- }
1311
-
1312
- case 5:
1313
- {
1314
- for (let idx = 0; idx <= shape$$31.fields[0].length - 1; idx++) {
1315
- const shape$$37 = shape$$31.fields[0][idx];
1316
- Events$$$triggerEvent(_arg2_0$$1, _arg2_1$$1, _arg2_2$$1, _arg2_3$$1, _arg1_0$$1, _arg1_1$$1, shape$$37, jse, event$$2);
1317
- }
1318
-
1319
- break;
1320
- }
1321
-
1322
- case 6:
1323
- {
1324
- const localEvent = Events$$$projectEvent(_arg2_0$$1, _arg2_1$$1, _arg2_2$$1, _arg2_3$$1, _arg1_0$$1, _arg1_1$$1, event$$2);
1325
-
1326
- if (Events$$$inScales(_arg1_0$$1, _arg1_1$$1, localEvent)) {
1327
- iterate(function (handler) {
1328
- var $target$$180, f$$11, pt$$3, f$$12, pt$$4, f$$13, f$$14;
1329
-
1330
- if (localEvent.tag === 1) {
1331
- if (localEvent.fields[0].tag === 1) {
1332
- if (handler.tag === 4) {
1333
- $target$$180 = 1;
1334
- f$$12 = curry(2, handler.fields[0]);
1335
- pt$$4 = localEvent.fields[1];
1336
- } else {
1337
- $target$$180 = 4;
1338
- }
1339
- } else if (handler.tag === 5) {
1340
- $target$$180 = 1;
1341
- f$$12 = curry(2, handler.fields[0]);
1342
- pt$$4 = localEvent.fields[1];
1343
- } else {
1344
- $target$$180 = 4;
1345
- }
1346
- } else if (localEvent.tag === 2) {
1347
- if (handler.tag === 6) {
1348
- $target$$180 = 2;
1349
- f$$13 = handler.fields[0];
1350
- } else {
1351
- $target$$180 = 4;
1352
- }
1353
- } else if (localEvent.tag === 3) {
1354
- if (handler.tag === 7) {
1355
- $target$$180 = 3;
1356
- f$$14 = handler.fields[0];
1357
- } else {
1358
- $target$$180 = 4;
1359
- }
1360
- } else if (localEvent.fields[0].tag === 1) {
1361
- if (handler.tag === 0) {
1362
- $target$$180 = 0;
1363
- f$$11 = curry(2, handler.fields[0]);
1364
- pt$$3 = localEvent.fields[1];
1365
- } else {
1366
- $target$$180 = 4;
1367
- }
1368
- } else if (localEvent.fields[0].tag === 2) {
1369
- if (handler.tag === 1) {
1370
- $target$$180 = 0;
1371
- f$$11 = curry(2, handler.fields[0]);
1372
- pt$$3 = localEvent.fields[1];
1373
- } else {
1374
- $target$$180 = 4;
1375
- }
1376
- } else if (localEvent.fields[0].tag === 3) {
1377
- if (handler.tag === 2) {
1378
- $target$$180 = 0;
1379
- f$$11 = curry(2, handler.fields[0]);
1380
- pt$$3 = localEvent.fields[1];
1381
- } else {
1382
- $target$$180 = 4;
1383
- }
1384
- } else if (handler.tag === 3) {
1385
- $target$$180 = 0;
1386
- f$$11 = curry(2, handler.fields[0]);
1387
- pt$$3 = localEvent.fields[1];
1388
- } else {
1389
- $target$$180 = 4;
1390
- }
1391
-
1392
- switch ($target$$180) {
1393
- case 0:
1394
- {
1395
- if (!equals(jse, null)) {
1396
- jse.preventDefault();
1397
- } else {
1398
- void null;
1399
- }
1400
-
1401
- f$$11(jse)(pt$$3);
1402
- break;
1403
- }
1404
-
1405
- case 1:
1406
- {
1407
- if (!equals(jse, null)) {
1408
- jse.preventDefault();
1409
- } else {
1410
- void null;
1411
- }
1412
-
1413
- f$$12(jse)(pt$$4);
1414
- break;
1415
- }
1416
-
1417
- case 2:
1418
- {
1419
- f$$13(jse);
1420
- break;
1421
- }
1422
-
1423
- case 3:
1424
- {
1425
- f$$14(jse);
1426
- break;
1427
- }
1428
-
1429
- case 4:
1430
- {
1431
- void null;
1432
- break;
1433
- }
1434
- }
1435
- }, shape$$31.fields[0]);
1436
- } else {
1437
- void null;
1438
- }
1439
-
1440
- $_arg2_0$$1$$166 = _arg2_0$$1;
1441
- $_arg2_1$$1$$167 = _arg2_1$$1;
1442
- $_arg2_2$$1$$168 = _arg2_2$$1;
1443
- $_arg2_3$$1$$169 = _arg2_3$$1;
1444
- $_arg1_0$$1$$170 = _arg1_0$$1;
1445
- $_arg1_1$$1$$171 = _arg1_1$$1;
1446
- $shape$$31$$172 = shape$$31.fields[3];
1447
- $jse$$173 = jse;
1448
- $event$$2$$174 = event$$2;
1449
- continue Events$$$triggerEvent;
1450
- break;
1451
- }
1452
-
1453
- default:
1454
- {
1455
- void null;
1456
- }
1457
- }
1458
-
1459
- break;
1460
- }
1461
- }
1462
- export function Derived$$$StrokeColor(clr$$5, s$$12) {
1463
- return new Shape(0, "Style", function (s$$13) {
1464
- return new Style([1, new Color(1, "HTML", clr$$5)], s$$13.StrokeWidth, s$$13.StrokeDashArray, s$$13.Fill, s$$13.Animation, s$$13.Font, s$$13.Cursor, s$$13.FormatAxisXLabel, s$$13.FormatAxisYLabel);
1465
- }, s$$12);
1466
- }
1467
- export function Derived$$$FillColor(clr$$6, s$$14) {
1468
- return new Shape(0, "Style", function (s$$15) {
1469
- const Fill$$3 = new FillStyle(0, "Solid", [1, new Color(1, "HTML", clr$$6)]);
1470
- return new Style(s$$15.StrokeColor, s$$15.StrokeWidth, s$$15.StrokeDashArray, Fill$$3, s$$15.Animation, s$$15.Font, s$$15.Cursor, s$$15.FormatAxisXLabel, s$$15.FormatAxisYLabel);
1471
- }, s$$14);
1472
- }
1473
- export function Derived$$$Font(font, clr$$7, s$$16) {
1474
- return new Shape(0, "Style", function (s$$17) {
1475
- const Fill$$4 = new FillStyle(0, "Solid", [1, new Color(1, "HTML", clr$$7)]);
1476
- const StrokeColor$$1 = [0, new Color(1, "HTML", clr$$7)];
1477
- return new Style(StrokeColor$$1, s$$17.StrokeWidth, s$$17.StrokeDashArray, Fill$$4, s$$17.Animation, font, s$$17.Cursor, s$$17.FormatAxisXLabel, s$$17.FormatAxisYLabel);
1478
- }, s$$16);
1479
- }
1480
- export function Derived$$$Area(line$$3) {
1481
- const arg0$$7 = delay(function () {
1482
- const line$$4 = ofSeq$$1(line$$3, Array);
1483
- const patternInput$$23 = [line$$4[0][0], line$$4[line$$4.length - 1][0]];
1484
- return append(singleton([patternInput$$23[0], new Value(1, "COV", new continuous(0, "CO", 0))]), delay(function () {
1485
- return append(line$$4, delay(function () {
1486
- return append(singleton([patternInput$$23[1], new Value(1, "COV", new continuous(0, "CO", 0))]), delay(function () {
1487
- return singleton([patternInput$$23[0], new Value(1, "COV", new continuous(0, "CO", 0))]);
1488
- }));
1489
- }));
1490
- }));
1491
- });
1492
- return new Shape(8, "Shape", arg0$$7);
1493
- }
1494
- export function Derived$$$VArea(line$$5) {
1495
- const arg0$$8 = delay(function () {
1496
- const line$$6 = ofSeq$$1(line$$5, Array);
1497
- const patternInput$$24 = [line$$6[0][1], line$$6[line$$6.length - 1][1]];
1498
- return append(singleton([new Value(1, "COV", new continuous(0, "CO", 0)), patternInput$$24[0]]), delay(function () {
1499
- return append(line$$6, delay(function () {
1500
- return append(singleton([new Value(1, "COV", new continuous(0, "CO", 0)), patternInput$$24[1]]), delay(function () {
1501
- return singleton([new Value(1, "COV", new continuous(0, "CO", 0)), patternInput$$24[0]]);
1502
- }));
1503
- }));
1504
- }));
1505
- });
1506
- return new Shape(8, "Shape", arg0$$8);
1507
- }
1508
- export function Derived$$$VShiftedArea(offs$$1, line$$7) {
1509
- const arg0$$9 = delay(function () {
1510
- const line$$8 = ofSeq$$1(line$$7, Array);
1511
- const patternInput$$25 = [line$$8[0][1], line$$8[line$$8.length - 1][1]];
1512
- return append(singleton([new Value(1, "COV", new continuous(0, "CO", offs$$1)), patternInput$$25[0]]), delay(function () {
1513
- return append(line$$8, delay(function () {
1514
- return append(singleton([new Value(1, "COV", new continuous(0, "CO", offs$$1)), patternInput$$25[1]]), delay(function () {
1515
- return singleton([new Value(1, "COV", new continuous(0, "CO", offs$$1)), patternInput$$25[0]]);
1516
- }));
1517
- }));
1518
- }));
1519
- });
1520
- return new Shape(8, "Shape", arg0$$9);
1521
- }
1522
- export function Derived$$$Bar(x$$19, y$$15) {
1523
- const arg0$$10 = delay(function () {
1524
- return append(singleton([new Value(1, "COV", x$$19), new Value(0, "CAR", y$$15, 0)]), delay(function () {
1525
- return append(singleton([new Value(1, "COV", x$$19), new Value(0, "CAR", y$$15, 1)]), delay(function () {
1526
- return append(singleton([new Value(1, "COV", new continuous(0, "CO", 0)), new Value(0, "CAR", y$$15, 1)]), delay(function () {
1527
- return singleton([new Value(1, "COV", new continuous(0, "CO", 0)), new Value(0, "CAR", y$$15, 0)]);
1528
- }));
1529
- }));
1530
- }));
1531
- });
1532
- return new Shape(8, "Shape", arg0$$10);
1533
- }
1534
- export function Derived$$$Column(x$$20, y$$16) {
1535
- const arg0$$11 = delay(function () {
1536
- return append(singleton([new Value(0, "CAR", x$$20, 0), new Value(1, "COV", y$$16)]), delay(function () {
1537
- return append(singleton([new Value(0, "CAR", x$$20, 1), new Value(1, "COV", y$$16)]), delay(function () {
1538
- return append(singleton([new Value(0, "CAR", x$$20, 1), new Value(1, "COV", new continuous(0, "CO", 0))]), delay(function () {
1539
- return singleton([new Value(0, "CAR", x$$20, 0), new Value(1, "COV", new continuous(0, "CO", 0))]);
1540
- }));
1541
- }));
1542
- }));
1543
- });
1544
- return new Shape(8, "Shape", arg0$$11);
1545
- }
1546
- export function Compost$$$niceNumber(num, decs) {
1547
- var x$$21;
1548
- const str = num.toString();
1549
- const dot = str.indexOf(".") | 0;
1550
- const patternInput$$26 = dot === -1 ? [str, ""] : [substring(str, 0, dot), substring(str, dot + 1, min(comparePrimitives, decs, str.length - dot - 1))];
1551
- const after$$1 = patternInput$$26[1].length < decs ? patternInput$$26[1] + ofSeq$$1(delay(function () {
1552
- return map$$1(function (i$$4) {
1553
- return "0";
1554
- }, rangeNumber(1, 1, decs - patternInput$$26[1].length));
1555
- }), Array).join("") : patternInput$$26[1];
1556
- let res = patternInput$$26[0];
1557
-
1558
- if (patternInput$$26[0].length > 5) {
1559
- const inputSequence = rangeNumber(patternInput$$26[0].length - 1, -1, 0);
1560
- iterate(function (i$$5) {
1561
- const j = patternInput$$26[0].length - i$$5 | 0;
1562
-
1563
- if (i$$5 !== 0 ? j % 3 === 0 : false) {
1564
- res = insert(res, i$$5, ",");
1565
- } else {
1566
- void null;
1567
- }
1568
- }, inputSequence);
1569
- } else {
1570
- void null;
1571
- }
1572
-
1573
- if (forAll((x$$21 = "0", function (y$$17) {
1574
- return x$$21 === y$$17;
1575
- }), after$$1.split(""))) {
1576
- return res;
1577
- } else {
1578
- return res + "." + after$$1;
1579
- }
1580
- }
1581
- export function Compost$$$defaultFormat(scale$$4, value$$1) {
1582
- if (value$$1.tag === 1) {
1583
- const dec = scale$$4.tag === 0 ? Scales$$$decimalPoints(scale$$4.fields[0].fields[0], scale$$4.fields[1].fields[0]) : 0;
1584
- return Compost$$$niceNumber(round(value$$1.fields[0].fields[0], ~~dec), ~~dec);
1585
- } else {
1586
- return value$$1.fields[0].fields[0];
1587
- }
1588
- }
1589
- export const Compost$$$defstyle = (() => {
1590
- const Fill$$5 = new FillStyle(0, "Solid", [1, new Color(0, "RGB", 196, 196, 196)]);
1591
- const StrokeColor$$2 = [1, new Color(0, "RGB", 256, 0, 0)];
1592
- const StrokeDashArray = [];
1593
- const StrokeWidth$$1 = new Width(0, "Pixels", 2);
1594
- const Animation$$4 = undefined;
1595
- return new Style(StrokeColor$$2, StrokeWidth$$1, StrokeDashArray, Fill$$5, Animation$$4, "10pt sans-serif", "default", Compost$$$defaultFormat, Compost$$$defaultFormat);
1596
- })();
1597
- export function Compost$$$getRelativeLocation(el, x$$22, y$$18) {
1598
- const getOffset = function getOffset($parent$$203, $tupledArg$$5$$204) {
1599
- getOffset: while (true) {
1600
- const parent = $parent$$203,
1601
- tupledArg$$5 = $tupledArg$$5$$204;
1602
-
1603
- if (equals(parent, null)) {
1604
- return [tupledArg$$5[0], tupledArg$$5[1]];
1605
- } else {
1606
- $parent$$203 = parent.offsetParent;
1607
- $tupledArg$$5$$204 = [tupledArg$$5[0] - parent.offsetLeft, tupledArg$$5[1] - parent.offsetTop];
1608
- continue getOffset;
1609
- }
1610
-
1611
- break;
1612
- }
1613
- };
1614
-
1615
- const getParent = function getParent($parent$$1$$205) {
1616
- getParent: while (true) {
1617
- const parent$$1 = $parent$$1$$205;
1618
-
1619
- if (parent$$1.namespaceURI === "http://www.w3.org/2000/svg" ? parent$$1.tagName !== "svg" : false) {
1620
- if (!equals(parent$$1.parentElement, null)) {
1621
- $parent$$1$$205 = parent$$1.parentElement;
1622
- continue getParent;
1623
- } else {
1624
- $parent$$1$$205 = parent$$1.parentNode;
1625
- continue getParent;
1626
- }
1627
- } else if (!equals(parent$$1.offsetParent, null)) {
1628
- return parent$$1;
1629
- } else if (!equals(parent$$1.parentElement, null)) {
1630
- $parent$$1$$205 = parent$$1.parentElement;
1631
- continue getParent;
1632
- } else {
1633
- $parent$$1$$205 = parent$$1.parentNode;
1634
- continue getParent;
1635
- }
1636
-
1637
- break;
1638
- }
1639
- };
1640
-
1641
- return getOffset(getParent(el), [x$$22, y$$18]);
1642
- }
1643
- export function Compost$$$createSvg(revX, revY, width$$1, height, viz) {
1644
- const patternInput$$27 = Scales$$$calculateScales(Compost$$$defstyle, viz);
1645
- const defs$$1 = [];
1646
- let svg$$2;
1647
- const ctx$$3 = new Drawing$002EDrawingContext(Compost$$$defstyle, defs$$1);
1648
- svg$$2 = Drawing$$$drawShape(ctx$$3, 0, 0, width$$1, height, patternInput$$27[0][0], patternInput$$27[0][1], patternInput$$27[1]);
1649
-
1650
- const triggerEvent = function triggerEvent(e$$2, event$$3) {
1651
- Events$$$triggerEvent(0, 0, width$$1, height, patternInput$$27[0][0], patternInput$$27[0][1], patternInput$$27[1], e$$2, event$$3);
1652
- };
1653
-
1654
- const mouseHandler = function mouseHandler(kind$$2, el$$1, evt) {
1655
- const patternInput$$28 = Compost$$$getRelativeLocation(el$$1, evt.pageX, evt.pageY);
1656
- const arg10$$10 = new Events$002EInteractiveEvent(0, "MouseEvent", kind$$2, [new Value(1, "COV", new continuous(0, "CO", patternInput$$28[0])), new Value(1, "COV", new continuous(0, "CO", patternInput$$28[1]))]);
1657
- const clo1$$10 = partialApply(1, triggerEvent, [evt]);
1658
- clo1$$10(arg10$$10);
1659
- };
1660
-
1661
- const touchHandler = function touchHandler(kind$$3, el$$2, evt$$2) {
1662
- const touch = evt$$2.touches[0];
1663
- const patternInput$$29 = Compost$$$getRelativeLocation(el$$2, touch.pageX, touch.pageY);
1664
- const arg10$$11 = new Events$002EInteractiveEvent(1, "TouchEvent", kind$$3, [new Value(1, "COV", new continuous(0, "CO", patternInput$$29[0])), new Value(1, "COV", new continuous(0, "CO", patternInput$$29[1]))]);
1665
- const clo1$$11 = partialApply(1, triggerEvent, [evt$$2]);
1666
- clo1$$11(arg10$$11);
1667
- };
1668
-
1669
- return function (arg0$$12) {
1670
- return function (arg1$$7) {
1671
- return El$0024$0024$0024op_Dynamic$0024$0024Z451691CD(arg0$$12, arg1$$7);
1672
- };
1673
- }(h$$13)("div")(new List())(new List((El$0024$0024$0024op_Dynamic$0024$0024Z451691CD(s$$19, "svg"))(ofArray([op_EqualsGreater("style", "overflow:visible"), op_EqualsGreater("width", int32ToString(~~width$$1)), op_EqualsGreater("height", int32ToString(~~height)), op_EqualsBangGreater("click", uncurry(2, partialApply(2, mouseHandler, [new Events$002EMouseEventKind(0, "Click")]))), op_EqualsBangGreater("mousemove", uncurry(2, partialApply(2, mouseHandler, [new Events$002EMouseEventKind(1, "Move")]))), op_EqualsBangGreater("mousedown", uncurry(2, partialApply(2, mouseHandler, [new Events$002EMouseEventKind(3, "Down")]))), op_EqualsBangGreater("mouseup", uncurry(2, partialApply(2, mouseHandler, [new Events$002EMouseEventKind(2, "Up")]))), op_EqualsBangGreater("mouseleave", function (_arg1$$11, evt$$4) {
1674
- triggerEvent(evt$$4, new Events$002EInteractiveEvent(3, "MouseLeave"));
1675
- }), op_EqualsBangGreater("touchmove", uncurry(2, partialApply(2, touchHandler, [new Events$002ETouchEventKind(0, "Move")]))), op_EqualsBangGreater("touchstart", uncurry(2, partialApply(2, touchHandler, [new Events$002ETouchEventKind(1, "Start")]))), op_EqualsBangGreater("touchend", function (_arg2$$4, evt$$5) {
1676
- triggerEvent(evt$$5, new Events$002EInteractiveEvent(2, "TouchEnd"));
1677
- })]))(ofSeq(delay(function () {
1678
- const renderCtx = new Svg$002ERenderingContext(defs$$1);
1679
- let body;
1680
- const source$$7 = Svg$$$renderSvg(renderCtx, svg$$2);
1681
- body = ofSeq$$1(source$$7, Array);
1682
- return append(defs$$1, delay(function () {
1683
- return body;
1684
- }));
1685
- }))), new List()));
1686
- }
1
+ import { toString, Record, Union } from "./fable_modules/fable-library-js.4.28.0/Types.js";
2
+ import { bool_type, unit_type, record_type, option_type, lambda_type, array_type, class_type, tuple_type, float64_type, union_type, string_type, int32_type } from "./fable_modules/fable-library-js.4.28.0/Reflection.js";
3
+ import { insert, substring, toFail, split, replace, printf, toText, join } from "./fable_modules/fable-library-js.4.28.0/String.js";
4
+ import { max as max_2, min as min_2, ofArray, singleton as singleton_1, cons, empty, reverse } from "./fable_modules/fable-library-js.4.28.0/List.js";
5
+ import { findIndex, fold, append as append_1, item as item_2, map } from "./fable_modules/fable-library-js.4.28.0/Array.js";
6
+ import { curry3, uncurry2, curry2, defaultOf, comparePrimitives, safeHash, equals, max as max_1, compare, min as min_1, round, int32ToString, disposeSafe, getEnumerator } from "./fable_modules/fable-library-js.4.28.0/Util.js";
7
+ import { op_EqualsBangGreater, h as h_2, text, op_EqualsGreater, s as s_6, El_op_Dynamic_Z451691CD, DomNode_$reflection } from "./html.js";
8
+ import { forAll, exists, head, max as max_3, min as min_3, skip, toArray, filter, tryHead, isEmpty, map as map_1, empty as empty_1, collect, append, toList, singleton, delay } from "./fable_modules/fable-library-js.4.28.0/Seq.js";
9
+ import { max, min } from "./fable_modules/fable-library-js.4.28.0/Double.js";
10
+ import { newGuid } from "./fable_modules/fable-library-js.4.28.0/Guid.js";
11
+ import { defaultArg } from "./fable_modules/fable-library-js.4.28.0/Option.js";
12
+ import { rangeDouble } from "./fable_modules/fable-library-js.4.28.0/Range.js";
13
+ import { Array_distinct } from "./fable_modules/fable-library-js.4.28.0/Seq2.js";
14
+ import { FSharpChoice$3 } from "./fable_modules/fable-library-js.4.28.0/Choice.js";
15
+
16
+ export class Color extends Union {
17
+ constructor(tag, fields) {
18
+ super();
19
+ this.tag = tag;
20
+ this.fields = fields;
21
+ }
22
+ cases() {
23
+ return ["RGB", "HTML"];
24
+ }
25
+ }
26
+
27
+ export function Color_$reflection() {
28
+ return union_type("Compost.Color", [], Color, () => [[["Item1", int32_type], ["Item2", int32_type], ["Item3", int32_type]], [["Item", string_type]]]);
29
+ }
30
+
31
+ export class Width extends Union {
32
+ constructor(Item) {
33
+ super();
34
+ this.tag = 0;
35
+ this.fields = [Item];
36
+ }
37
+ cases() {
38
+ return ["Pixels"];
39
+ }
40
+ }
41
+
42
+ export function Width_$reflection() {
43
+ return union_type("Compost.Width", [], Width, () => [[["Item", int32_type]]]);
44
+ }
45
+
46
+ export class FillStyle extends Union {
47
+ constructor(tag, fields) {
48
+ super();
49
+ this.tag = tag;
50
+ this.fields = fields;
51
+ }
52
+ cases() {
53
+ return ["Solid", "LinearGradient"];
54
+ }
55
+ }
56
+
57
+ export function FillStyle_$reflection() {
58
+ return union_type("Compost.FillStyle", [], FillStyle, () => [[["Item", tuple_type(float64_type, Color_$reflection())]], [["Item", class_type("System.Collections.Generic.IEnumerable`1", [tuple_type(float64_type, tuple_type(float64_type, Color_$reflection()))])]]]);
59
+ }
60
+
61
+ export class Number$ extends Union {
62
+ constructor(tag, fields) {
63
+ super();
64
+ this.tag = tag;
65
+ this.fields = fields;
66
+ }
67
+ cases() {
68
+ return ["Integer", "Percentage"];
69
+ }
70
+ }
71
+
72
+ export function Number$_$reflection() {
73
+ return union_type("Compost.Number", [], Number$, () => [[["Item", int32_type]], [["Item", float64_type]]]);
74
+ }
75
+
76
+ export class HorizontalAlign extends Union {
77
+ constructor(tag, fields) {
78
+ super();
79
+ this.tag = tag;
80
+ this.fields = fields;
81
+ }
82
+ cases() {
83
+ return ["Start", "Center", "End"];
84
+ }
85
+ }
86
+
87
+ export function HorizontalAlign_$reflection() {
88
+ return union_type("Compost.HorizontalAlign", [], HorizontalAlign, () => [[], [], []]);
89
+ }
90
+
91
+ export class VerticalAlign extends Union {
92
+ constructor(tag, fields) {
93
+ super();
94
+ this.tag = tag;
95
+ this.fields = fields;
96
+ }
97
+ cases() {
98
+ return ["Baseline", "Middle", "Hanging"];
99
+ }
100
+ }
101
+
102
+ export function VerticalAlign_$reflection() {
103
+ return union_type("Compost.VerticalAlign", [], VerticalAlign, () => [[], [], []]);
104
+ }
105
+
106
+ export class continuous extends Union {
107
+ constructor(Item) {
108
+ super();
109
+ this.tag = 0;
110
+ this.fields = [Item];
111
+ }
112
+ cases() {
113
+ return ["CO"];
114
+ }
115
+ }
116
+
117
+ export function continuous_$reflection(gen0) {
118
+ return union_type("Compost.continuous", [gen0], continuous, () => [[["Item", float64_type]]]);
119
+ }
120
+
121
+ export class categorical extends Union {
122
+ constructor(Item) {
123
+ super();
124
+ this.tag = 0;
125
+ this.fields = [Item];
126
+ }
127
+ cases() {
128
+ return ["CA"];
129
+ }
130
+ }
131
+
132
+ export function categorical_$reflection(gen0) {
133
+ return union_type("Compost.categorical", [gen0], categorical, () => [[["Item", string_type]]]);
134
+ }
135
+
136
+ export class Value extends Union {
137
+ constructor(tag, fields) {
138
+ super();
139
+ this.tag = tag;
140
+ this.fields = fields;
141
+ }
142
+ cases() {
143
+ return ["CAR", "COV"];
144
+ }
145
+ }
146
+
147
+ export function Value_$reflection(gen0) {
148
+ return union_type("Compost.Value", [gen0], Value, () => [[["Item1", categorical_$reflection(gen0)], ["Item2", float64_type]], [["Item", continuous_$reflection(gen0)]]]);
149
+ }
150
+
151
+ export class Scale extends Union {
152
+ constructor(tag, fields) {
153
+ super();
154
+ this.tag = tag;
155
+ this.fields = fields;
156
+ }
157
+ cases() {
158
+ return ["Continuous", "Categorical"];
159
+ }
160
+ }
161
+
162
+ export function Scale_$reflection(gen0) {
163
+ return union_type("Compost.Scale", [gen0], Scale, () => [[["Item1", continuous_$reflection(gen0)], ["Item2", continuous_$reflection(gen0)]], [["Item", array_type(categorical_$reflection(gen0))]]]);
164
+ }
165
+
166
+ export class Style extends Record {
167
+ constructor(StrokeColor, StrokeWidth, StrokeDashArray, Fill, Animation, Font, Cursor, FormatAxisXLabel, FormatAxisYLabel) {
168
+ super();
169
+ this.StrokeColor = StrokeColor;
170
+ this.StrokeWidth = StrokeWidth;
171
+ this.StrokeDashArray = StrokeDashArray;
172
+ this.Fill = Fill;
173
+ this.Animation = Animation;
174
+ this.Font = Font;
175
+ this.Cursor = Cursor;
176
+ this.FormatAxisXLabel = FormatAxisXLabel;
177
+ this.FormatAxisYLabel = FormatAxisYLabel;
178
+ }
179
+ }
180
+
181
+ export function Style_$reflection() {
182
+ return record_type("Compost.Style", [], Style, () => [["StrokeColor", tuple_type(float64_type, Color_$reflection())], ["StrokeWidth", Width_$reflection()], ["StrokeDashArray", class_type("System.Collections.Generic.IEnumerable`1", [Number$_$reflection()])], ["Fill", FillStyle_$reflection()], ["Animation", option_type(tuple_type(int32_type, string_type, lambda_type(Style_$reflection(), Style_$reflection())))], ["Font", string_type], ["Cursor", string_type], ["FormatAxisXLabel", lambda_type(Scale_$reflection(class_type("Microsoft.FSharp.Core.CompilerServices.MeasureOne")), lambda_type(Value_$reflection(class_type("Microsoft.FSharp.Core.CompilerServices.MeasureOne")), string_type))], ["FormatAxisYLabel", lambda_type(Scale_$reflection(class_type("Microsoft.FSharp.Core.CompilerServices.MeasureOne")), lambda_type(Value_$reflection(class_type("Microsoft.FSharp.Core.CompilerServices.MeasureOne")), string_type))]]);
183
+ }
184
+
185
+ export class EventHandler extends Union {
186
+ constructor(tag, fields) {
187
+ super();
188
+ this.tag = tag;
189
+ this.fields = fields;
190
+ }
191
+ cases() {
192
+ return ["MouseMove", "MouseUp", "MouseDown", "Click", "TouchStart", "TouchMove", "TouchEnd", "MouseLeave"];
193
+ }
194
+ }
195
+
196
+ export function EventHandler_$reflection(gen0, gen1) {
197
+ return union_type("Compost.EventHandler", [gen0, gen1], EventHandler, () => [[["Item", lambda_type(class_type("Browser.Types.MouseEvent", undefined), lambda_type(tuple_type(Value_$reflection(gen0), Value_$reflection(gen1)), unit_type))]], [["Item", lambda_type(class_type("Browser.Types.MouseEvent", undefined), lambda_type(tuple_type(Value_$reflection(gen0), Value_$reflection(gen1)), unit_type))]], [["Item", lambda_type(class_type("Browser.Types.MouseEvent", undefined), lambda_type(tuple_type(Value_$reflection(gen0), Value_$reflection(gen1)), unit_type))]], [["Item", lambda_type(class_type("Browser.Types.MouseEvent", undefined), lambda_type(tuple_type(Value_$reflection(gen0), Value_$reflection(gen1)), unit_type))]], [["Item", lambda_type(class_type("Browser.Types.TouchEvent", undefined), lambda_type(tuple_type(Value_$reflection(gen0), Value_$reflection(gen1)), unit_type))]], [["Item", lambda_type(class_type("Browser.Types.TouchEvent", undefined), lambda_type(tuple_type(Value_$reflection(gen0), Value_$reflection(gen1)), unit_type))]], [["Item", lambda_type(class_type("Browser.Types.TouchEvent", undefined), unit_type)]], [["Item", lambda_type(class_type("Browser.Types.MouseEvent", undefined), unit_type)]]]);
198
+ }
199
+
200
+ export class Orientation extends Union {
201
+ constructor(tag, fields) {
202
+ super();
203
+ this.tag = tag;
204
+ this.fields = fields;
205
+ }
206
+ cases() {
207
+ return ["Vertical", "Horizontal"];
208
+ }
209
+ }
210
+
211
+ export function Orientation_$reflection() {
212
+ return union_type("Compost.Orientation", [], Orientation, () => [[], []]);
213
+ }
214
+
215
+ export class Shape extends Union {
216
+ constructor(tag, fields) {
217
+ super();
218
+ this.tag = tag;
219
+ this.fields = fields;
220
+ }
221
+ cases() {
222
+ return ["Style", "Text", "AutoScale", "InnerScale", "NestX", "NestY", "Line", "Bubble", "Shape", "Layered", "Axes", "Interactive", "Padding", "Offset"];
223
+ }
224
+ }
225
+
226
+ export function Shape_$reflection(gen0, gen1) {
227
+ return union_type("Compost.Shape", [gen0, gen1], Shape, () => [[["Item1", lambda_type(Style_$reflection(), Style_$reflection())], ["Item2", Shape_$reflection(gen0, gen1)]], [["Item1", Value_$reflection(gen0)], ["Item2", Value_$reflection(gen1)], ["Item3", VerticalAlign_$reflection()], ["Item4", HorizontalAlign_$reflection()], ["Item5", float64_type], ["Item6", string_type]], [["Item1", bool_type], ["Item2", bool_type], ["Item3", Shape_$reflection(gen0, gen1)]], [["Item1", option_type(Scale_$reflection(gen0))], ["Item2", option_type(Scale_$reflection(gen1))], ["Item3", Shape_$reflection(gen0, gen1)]], [["Item1", Value_$reflection(gen0)], ["Item2", Value_$reflection(gen0)], ["Item3", Shape_$reflection(gen0, gen1)]], [["Item1", Value_$reflection(gen1)], ["Item2", Value_$reflection(gen1)], ["Item3", Shape_$reflection(gen0, gen1)]], [["Item", class_type("System.Collections.Generic.IEnumerable`1", [tuple_type(Value_$reflection(gen0), Value_$reflection(gen1))])]], [["Item1", Value_$reflection(gen0)], ["Item2", Value_$reflection(gen1)], ["Item3", float64_type], ["Item4", float64_type]], [["Item", class_type("System.Collections.Generic.IEnumerable`1", [tuple_type(Value_$reflection(gen0), Value_$reflection(gen1))])]], [["Item", class_type("System.Collections.Generic.IEnumerable`1", [Shape_$reflection(gen0, gen1)])]], [["Item1", bool_type], ["Item2", bool_type], ["Item3", bool_type], ["Item4", bool_type], ["Item5", Shape_$reflection(gen0, gen1)]], [["Item1", class_type("System.Collections.Generic.IEnumerable`1", [EventHandler_$reflection(gen0, gen1)])], ["Item2", Shape_$reflection(gen0, gen1)]], [["Item1", tuple_type(float64_type, float64_type, float64_type, float64_type)], ["Item2", Shape_$reflection(gen0, gen1)]], [["Item1", tuple_type(float64_type, float64_type)], ["Item2", Shape_$reflection(gen0, gen1)]]]);
228
+ }
229
+
230
+ export class Svg_StringBuilder {
231
+ constructor() {
232
+ this.strs = empty();
233
+ }
234
+ toString() {
235
+ const x = this;
236
+ return join("", reverse(x.strs));
237
+ }
238
+ }
239
+
240
+ export function Svg_StringBuilder_$reflection() {
241
+ return class_type("Compost.Svg.StringBuilder", undefined, Svg_StringBuilder);
242
+ }
243
+
244
+ export function Svg_StringBuilder_$ctor() {
245
+ return new Svg_StringBuilder();
246
+ }
247
+
248
+ export function Svg_StringBuilder__Append_Z721C83C5(x, s) {
249
+ x.strs = cons(s, x.strs);
250
+ }
251
+
252
+ export class Svg_PathSegment extends Union {
253
+ constructor(tag, fields) {
254
+ super();
255
+ this.tag = tag;
256
+ this.fields = fields;
257
+ }
258
+ cases() {
259
+ return ["MoveTo", "LineTo"];
260
+ }
261
+ }
262
+
263
+ export function Svg_PathSegment_$reflection() {
264
+ return union_type("Compost.Svg.PathSegment", [], Svg_PathSegment, () => [[["Item", tuple_type(float64_type, float64_type)]], [["Item", tuple_type(float64_type, float64_type)]]]);
265
+ }
266
+
267
+ export class Svg_Svg extends Union {
268
+ constructor(tag, fields) {
269
+ super();
270
+ this.tag = tag;
271
+ this.fields = fields;
272
+ }
273
+ cases() {
274
+ return ["Path", "Ellipse", "Rect", "Text", "Combine", "Empty"];
275
+ }
276
+ }
277
+
278
+ export function Svg_Svg_$reflection() {
279
+ return union_type("Compost.Svg.Svg", [], Svg_Svg, () => [[["Item1", array_type(Svg_PathSegment_$reflection())], ["Item2", string_type]], [["Item1", tuple_type(float64_type, float64_type)], ["Item2", tuple_type(float64_type, float64_type)], ["Item3", string_type]], [["Item1", tuple_type(float64_type, float64_type)], ["Item2", tuple_type(float64_type, float64_type)], ["Item3", string_type]], [["Item1", tuple_type(float64_type, float64_type)], ["Item2", string_type], ["Item3", float64_type], ["Item4", string_type]], [["Item", array_type(Svg_Svg_$reflection())]], []]);
280
+ }
281
+
282
+ export function Svg_mapSvg(f, _arg) {
283
+ if (_arg.tag === 4) {
284
+ return new Svg_Svg(4, [map((_arg_1) => Svg_mapSvg(f, _arg_1), _arg.fields[0])]);
285
+ }
286
+ else {
287
+ return f(_arg);
288
+ }
289
+ }
290
+
291
+ export function Svg_formatPath(path) {
292
+ const sb = Svg_StringBuilder_$ctor();
293
+ const enumerator = getEnumerator(path);
294
+ try {
295
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
296
+ const ps = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
297
+ if (ps.tag === 1) {
298
+ Svg_StringBuilder__Append_Z721C83C5(sb, ((("L" + ps.fields[0][0].toString()) + " ") + ps.fields[0][1].toString()) + " ");
299
+ }
300
+ else {
301
+ Svg_StringBuilder__Append_Z721C83C5(sb, ((("M" + ps.fields[0][0].toString()) + " ") + ps.fields[0][1].toString()) + " ");
302
+ }
303
+ }
304
+ }
305
+ finally {
306
+ disposeSafe(enumerator);
307
+ }
308
+ return toString(sb);
309
+ }
310
+
311
+ export class Svg_RenderingContext extends Record {
312
+ constructor(Definitions) {
313
+ super();
314
+ this.Definitions = Definitions;
315
+ }
316
+ }
317
+
318
+ export function Svg_RenderingContext_$reflection() {
319
+ return record_type("Compost.Svg.RenderingContext", [], Svg_RenderingContext, () => [["Definitions", array_type(DomNode_$reflection())]]);
320
+ }
321
+
322
+ export function Svg_renderSvg(ctx, svg) {
323
+ return delay(() => {
324
+ switch (svg.tag) {
325
+ case 3: {
326
+ const y = svg.fields[0][1];
327
+ const x = svg.fields[0][0];
328
+ const rotation = svg.fields[2];
329
+ return singleton(El_op_Dynamic_Z451691CD(s_6, "text")(toList(delay(() => append(singleton(op_EqualsGreater("style", svg.fields[3])), delay(() => ((rotation === 0) ? append(singleton(op_EqualsGreater("x", x.toString())), delay(() => singleton(op_EqualsGreater("y", y.toString())))) : append(singleton(op_EqualsGreater("x", "0")), delay(() => append(singleton(op_EqualsGreater("y", "0")), delay(() => singleton(op_EqualsGreater("transform", toText(printf("translate(%f,%f) rotate(%f)"))(x)(y)(rotation)))))))))))))(singleton_1(text(svg.fields[1]))));
330
+ }
331
+ case 4:
332
+ return collect((s) => Svg_renderSvg(ctx, s), svg.fields[0]);
333
+ case 1:
334
+ return singleton(El_op_Dynamic_Z451691CD(s_6, "ellipse")(ofArray([op_EqualsGreater("cx", svg.fields[0][0].toString()), op_EqualsGreater("cy", svg.fields[0][1].toString()), op_EqualsGreater("rx", svg.fields[1][0].toString()), op_EqualsGreater("ry", svg.fields[1][1].toString()), op_EqualsGreater("style", svg.fields[2])]))(empty()));
335
+ case 2: {
336
+ const y2 = svg.fields[1][1];
337
+ const y1 = svg.fields[0][1];
338
+ const x2 = svg.fields[1][0];
339
+ const x1 = svg.fields[0][0];
340
+ const matchValue = min(x1, x2);
341
+ const matchValue_1 = min(y1, y2);
342
+ const matchValue_2 = Math.abs(x1 - x2);
343
+ const matchValue_3 = Math.abs(y1 - y2);
344
+ return singleton(El_op_Dynamic_Z451691CD(s_6, "rect")(ofArray([op_EqualsGreater("x", matchValue.toString()), op_EqualsGreater("y", matchValue_1.toString()), op_EqualsGreater("width", matchValue_2.toString()), op_EqualsGreater("height", matchValue_3.toString()), op_EqualsGreater("style", svg.fields[2])]))(empty()));
345
+ }
346
+ case 0:
347
+ return singleton(El_op_Dynamic_Z451691CD(s_6, "path")(ofArray([op_EqualsGreater("d", Svg_formatPath(svg.fields[0])), op_EqualsGreater("style", svg.fields[1])]))(empty()));
348
+ default: {
349
+ return empty_1();
350
+ }
351
+ }
352
+ });
353
+ }
354
+
355
+ export function Svg_formatColor(_arg) {
356
+ if (_arg.tag === 1) {
357
+ return _arg.fields[0];
358
+ }
359
+ else {
360
+ return toText(printf("rgb(%d, %d, %d)"))(_arg.fields[0])(_arg.fields[1])(_arg.fields[2]);
361
+ }
362
+ }
363
+
364
+ export function Svg_formatNumber(_arg) {
365
+ if (_arg.tag === 1) {
366
+ return _arg.fields[0].toString() + "%";
367
+ }
368
+ else {
369
+ return int32ToString(_arg.fields[0]);
370
+ }
371
+ }
372
+
373
+ export function Svg_formatStyle(defs, style) {
374
+ let copyOfStruct, bind$0040, patternInput_1, arg_10, matchValue_1, arg_17, id_1, copyOfStruct_1, item_1;
375
+ let patternInput;
376
+ const matchValue = style.Animation;
377
+ if (matchValue == null) {
378
+ patternInput = [style, ""];
379
+ }
380
+ else {
381
+ const ms = matchValue[0] | 0;
382
+ const ease = matchValue[1];
383
+ const anim = matchValue[2];
384
+ const id = "anim_" + replace((copyOfStruct = newGuid(), copyOfStruct), "-", "");
385
+ const fromstyle = Svg_formatStyle(defs, new Style(style.StrokeColor, style.StrokeWidth, style.StrokeDashArray, style.Fill, undefined, style.Font, style.Cursor, style.FormatAxisXLabel, style.FormatAxisYLabel));
386
+ const tostyle = Svg_formatStyle(defs, (bind$0040 = anim(style), new Style(bind$0040.StrokeColor, bind$0040.StrokeWidth, bind$0040.StrokeDashArray, bind$0040.Fill, undefined, bind$0040.Font, bind$0040.Cursor, bind$0040.FormatAxisXLabel, bind$0040.FormatAxisYLabel)));
387
+ const item = El_op_Dynamic_Z451691CD(h_2, "style")(empty())(singleton_1(text(toText(printf("@keyframes %s { from { %s } to { %s } }"))(id)(fromstyle)(tostyle))));
388
+ void (defs.push(item));
389
+ patternInput = [anim(style), toText(printf("animation: %s %dms %s; "))(id)(ms)(ease)];
390
+ }
391
+ const style_1 = patternInput[0];
392
+ return ((((patternInput[1] + join("", toList(delay(() => map_1((c) => (("cursor:" + c) + ";"), split(style_1.Cursor, [","], undefined, 0)))))) + (("font:" + style_1.Font) + ";")) + ((patternInput_1 = style_1.StrokeColor, (arg_10 = Svg_formatColor(patternInput_1[1]), toText(printf("stroke-opacity:%f; stroke-width:%dpx; stroke:%s; "))(patternInput_1[0])(style_1.StrokeWidth.fields[0])(arg_10))))) + (isEmpty(style_1.StrokeDashArray) ? "" : (("stroke-dasharray:" + join(",", map_1(Svg_formatNumber, style_1.StrokeDashArray))) + ";"))) + ((matchValue_1 = style_1.Fill, (matchValue_1.tag === 0) ? ((arg_17 = Svg_formatColor(matchValue_1.fields[0][1]), toText(printf("fill-opacity:%f; fill:%s; "))(matchValue_1.fields[0][0])(arg_17))) : ((id_1 = ("gradient_" + replace((copyOfStruct_1 = newGuid(), copyOfStruct_1), "-", "")), ((item_1 = El_op_Dynamic_Z451691CD(s_6, "linearGradient")(singleton_1(op_EqualsGreater("id", id_1)))(toList(delay(() => collect((matchValue_2) => singleton(El_op_Dynamic_Z451691CD(s_6, "stop")(ofArray([op_EqualsGreater("offset", matchValue_2[0].toString() + "%"), op_EqualsGreater("stop-color", Svg_formatColor(matchValue_2[1][1])), op_EqualsGreater("stop-opacity", matchValue_2[1][0].toString())]))(empty())), matchValue_1.fields[0])))), void (defs.push(item_1))), toText(printf("fill:url(#%s)"))(id_1))))));
393
+ }
394
+
395
+ export class Scales_ScaledShape extends Union {
396
+ constructor(tag, fields) {
397
+ super();
398
+ this.tag = tag;
399
+ this.fields = fields;
400
+ }
401
+ cases() {
402
+ return ["ScaledStyle", "ScaledText", "ScaledLine", "ScaledBubble", "ScaledShape", "ScaledLayered", "ScaledInteractive", "ScaledPadding", "ScaledOffset", "ScaledNestX", "ScaledNestY"];
403
+ }
404
+ }
405
+
406
+ export function Scales_ScaledShape_$reflection(gen0, gen1) {
407
+ return union_type("Compost.Scales.ScaledShape", [gen0, gen1], Scales_ScaledShape, () => [[["Item1", lambda_type(Style_$reflection(), Style_$reflection())], ["Item2", Scales_ScaledShape_$reflection(gen0, gen1)]], [["Item1", Value_$reflection(gen0)], ["Item2", Value_$reflection(gen1)], ["Item3", VerticalAlign_$reflection()], ["Item4", HorizontalAlign_$reflection()], ["Item5", float64_type], ["Item6", string_type]], [["Item", array_type(tuple_type(Value_$reflection(gen0), Value_$reflection(gen1)))]], [["Item1", Value_$reflection(gen0)], ["Item2", Value_$reflection(gen1)], ["Item3", float64_type], ["Item4", float64_type]], [["Item", array_type(tuple_type(Value_$reflection(gen0), Value_$reflection(gen1)))]], [["Item", array_type(Scales_ScaledShape_$reflection(gen0, gen1))]], [["Item1", class_type("System.Collections.Generic.IEnumerable`1", [EventHandler_$reflection(gen0, gen1)])], ["Item2", Scale_$reflection(gen0)], ["Item3", Scale_$reflection(gen1)], ["Item4", Scales_ScaledShape_$reflection(gen0, gen1)]], [["Item1", tuple_type(float64_type, float64_type, float64_type, float64_type)], ["Item2", Scale_$reflection(gen0)], ["Item3", Scale_$reflection(gen1)], ["Item4", Scales_ScaledShape_$reflection(gen0, gen1)]], [["Item1", tuple_type(float64_type, float64_type)], ["Item2", Scales_ScaledShape_$reflection(gen0, gen1)]], [["Item1", Value_$reflection(gen0)], ["Item2", Value_$reflection(gen0)], ["Item3", Scale_$reflection(gen0)], ["Item4", Scales_ScaledShape_$reflection(gen0, gen1)]], [["Item1", Value_$reflection(gen1)], ["Item2", Value_$reflection(gen1)], ["Item3", Scale_$reflection(gen1)], ["Item4", Scales_ScaledShape_$reflection(gen0, gen1)]]]);
408
+ }
409
+
410
+ export function Scales_getExtremes(_arg) {
411
+ if (_arg.tag === 1) {
412
+ const vals = _arg.fields[0];
413
+ return [new Value(0, [item_2(0, vals), 0]), new Value(0, [item_2(vals.length - 1, vals), 1])];
414
+ }
415
+ else {
416
+ return [new Value(1, [_arg.fields[0]]), new Value(1, [_arg.fields[1]])];
417
+ }
418
+ }
419
+
420
+ /**
421
+ * Given a range, return a new aligned range together with the magnitude
422
+ */
423
+ export function Scales_calculateMagnitudeAndRange(lo, hi) {
424
+ let arg1__1;
425
+ const magnitude_1 = ((arg1__1 = round(Math.log10(hi - lo)), Math.pow(10, arg1__1))) / 2;
426
+ return [magnitude_1, [Math.floor(lo / magnitude_1) * magnitude_1, Math.ceil(hi / magnitude_1) * magnitude_1]];
427
+ }
428
+
429
+ /**
430
+ * Get number of decimal points to show for the given range
431
+ */
432
+ export function Scales_decimalPoints(range_, range__1) {
433
+ const range = [range_, range__1];
434
+ const patternInput = Scales_calculateMagnitudeAndRange(range[0], range[1]);
435
+ return max(0, Math.ceil(-Math.log10(patternInput[0])));
436
+ }
437
+
438
+ /**
439
+ * Extend the given range to a nicely adjusted size
440
+ */
441
+ export function Scales_adjustRange(range_, range__1) {
442
+ const range = [range_, range__1];
443
+ return Scales_calculateMagnitudeAndRange(range[0], range[1])[1];
444
+ }
445
+
446
+ export function Scales_adjustRangeUnits(l, h) {
447
+ const patternInput = Scales_adjustRange(l, h);
448
+ return [patternInput[0], patternInput[1]];
449
+ }
450
+
451
+ export function Scales_toArray(s) {
452
+ return Array.from(s);
453
+ }
454
+
455
+ /**
456
+ * Generate points for a grid. Count specifies how many points to generate
457
+ * (this is minimm - the result will be up to 5x more).
458
+ */
459
+ export function Scales_generateSteps(count, k, lo, hi) {
460
+ const patternInput = Scales_calculateMagnitudeAndRange(lo, hi);
461
+ const magnitude = patternInput[0];
462
+ const step_1 = defaultArg(tryHead(filter((m) => (((hi - lo) / m) >= count), map_1((d) => (magnitude / d), [0.2, 0.5, 1, 2, 5, 10, 20, 40, 50, 60, 80, 100]))), magnitude / 100);
463
+ return Scales_toArray(delay(() => collect((v) => (((v >= lo) && (v <= hi)) ? singleton(v) : empty_1()), rangeDouble(patternInput[1][0], step_1 * k, patternInput[1][1]))));
464
+ }
465
+
466
+ export function Scales_generateAxisSteps(s) {
467
+ if (s.tag === 1) {
468
+ return toArray(delay(() => collect((matchValue) => singleton(new Value(0, [new categorical(matchValue.fields[0]), 0.5])), s.fields[0])));
469
+ }
470
+ else {
471
+ return map((f) => (new Value(1, [new continuous(f)])), Scales_generateSteps(6, 1, s.fields[0].fields[0], s.fields[1].fields[0]));
472
+ }
473
+ }
474
+
475
+ export function Scales_generateAxisLabels(fmt, s) {
476
+ const sunit = s;
477
+ if (s.tag === 1) {
478
+ return toArray(delay(() => collect((matchValue) => {
479
+ const s_1 = matchValue.fields[0];
480
+ return singleton([new Value(0, [new categorical(s_1), 0.5]), fmt(sunit, new Value(0, [new categorical(s_1), 0.5]))]);
481
+ }, s.fields[0])));
482
+ }
483
+ else {
484
+ return map((f) => [new Value(1, [new continuous(f)]), fmt(sunit, new Value(1, [new continuous(f)]))], Scales_generateSteps(6, 2, s.fields[0].fields[0], s.fields[1].fields[0]));
485
+ }
486
+ }
487
+
488
+ export function Scales_unionScales(s1, s2) {
489
+ let matchResult, h1, h2, l1, l2, v1, v2;
490
+ if (s1.tag === 1) {
491
+ if (s2.tag === 1) {
492
+ matchResult = 1;
493
+ v1 = s1.fields[0];
494
+ v2 = s2.fields[0];
495
+ }
496
+ else {
497
+ matchResult = 2;
498
+ }
499
+ }
500
+ else if (s2.tag === 0) {
501
+ matchResult = 0;
502
+ h1 = s1.fields[1];
503
+ h2 = s2.fields[1];
504
+ l1 = s1.fields[0];
505
+ l2 = s2.fields[0];
506
+ }
507
+ else {
508
+ matchResult = 2;
509
+ }
510
+ switch (matchResult) {
511
+ case 0:
512
+ return new Scale(0, [min_1(compare, l1, l2), max_1(compare, h1, h2)]);
513
+ case 1:
514
+ return new Scale(1, [Array_distinct(append_1(v1, v2), {
515
+ Equals: equals,
516
+ GetHashCode: safeHash,
517
+ })]);
518
+ default:
519
+ throw new Error("Cannot union continuous with categorical");
520
+ }
521
+ }
522
+
523
+ export function Scales_calculateShapeScale(vals) {
524
+ const scales = fold((state, value) => {
525
+ let matchResult, v, v_1, vs, x, x_1, xs;
526
+ switch (state.tag) {
527
+ case 1: {
528
+ if (value.tag === 1) {
529
+ matchResult = 1;
530
+ v_1 = value.fields[0].fields[0];
531
+ vs = state.fields[0];
532
+ }
533
+ else {
534
+ matchResult = 4;
535
+ }
536
+ break;
537
+ }
538
+ case 2: {
539
+ if (value.tag === 0) {
540
+ matchResult = 3;
541
+ x_1 = value.fields[0].fields[0];
542
+ xs = state.fields[0];
543
+ }
544
+ else {
545
+ matchResult = 4;
546
+ }
547
+ break;
548
+ }
549
+ default:
550
+ if (value.tag === 0) {
551
+ matchResult = 2;
552
+ x = value.fields[0].fields[0];
553
+ }
554
+ else {
555
+ matchResult = 0;
556
+ v = value.fields[0].fields[0];
557
+ }
558
+ }
559
+ switch (matchResult) {
560
+ case 0:
561
+ return new FSharpChoice$3(1, [singleton_1(v)]);
562
+ case 1:
563
+ return new FSharpChoice$3(1, [cons(v_1, vs)]);
564
+ case 2:
565
+ return new FSharpChoice$3(2, [singleton_1(x)]);
566
+ case 3:
567
+ return new FSharpChoice$3(2, [cons(x_1, xs)]);
568
+ default:
569
+ throw new Error("Values with mismatching scales");
570
+ }
571
+ }, new FSharpChoice$3(0, [undefined]), vals);
572
+ switch (scales.tag) {
573
+ case 1: {
574
+ const vs_1 = scales.fields[0];
575
+ return new Scale(0, [new continuous(min_2(vs_1, {
576
+ Compare: comparePrimitives,
577
+ })), new continuous(max_2(vs_1, {
578
+ Compare: comparePrimitives,
579
+ }))]);
580
+ }
581
+ case 2:
582
+ return new Scale(1, [Array_distinct(toArray(delay(() => map_1((x_4) => (new categorical(x_4)), reverse(scales.fields[0])))), {
583
+ Equals: equals,
584
+ GetHashCode: safeHash,
585
+ })]);
586
+ default:
587
+ throw new Error("No values for calculating a scale");
588
+ }
589
+ }
590
+
591
+ export function Scales_calculateShapeScales(points) {
592
+ const xs = map((tuple) => tuple[0], points);
593
+ const ys = map((tuple_1) => tuple_1[1], points);
594
+ return [Scales_calculateShapeScale(xs), Scales_calculateShapeScale(ys)];
595
+ }
596
+
597
+ export function Scales_calculateScales(style, shape) {
598
+ const calculateScales = (shape_2) => Scales_calculateScales(style, shape_2);
599
+ switch (shape.tag) {
600
+ case 4: {
601
+ const nx2 = shape.fields[1];
602
+ const nx1 = shape.fields[0];
603
+ const patternInput_1 = calculateScales(shape.fields[2]);
604
+ return [[Scales_calculateShapeScale([nx1, nx2]), patternInput_1[0][1]], new Scales_ScaledShape(9, [nx1, nx2, patternInput_1[0][0], patternInput_1[1]])];
605
+ }
606
+ case 5: {
607
+ const ny2 = shape.fields[1];
608
+ const ny1 = shape.fields[0];
609
+ const patternInput_2 = calculateScales(shape.fields[2]);
610
+ return [[patternInput_2[0][0], Scales_calculateShapeScale([ny1, ny2])], new Scales_ScaledShape(10, [ny1, ny2, patternInput_2[0][1], patternInput_2[1]])];
611
+ }
612
+ case 3: {
613
+ const sy = shape.fields[1];
614
+ const sx = shape.fields[0];
615
+ const patternInput_3 = calculateScales(shape.fields[2]);
616
+ return [[(sx != null) ? sx : patternInput_3[0][0], (sy != null) ? sy : patternInput_3[0][1]], patternInput_3[1]];
617
+ }
618
+ case 2: {
619
+ const patternInput_4 = calculateScales(shape.fields[2]);
620
+ const isy_3 = patternInput_4[0][1];
621
+ const isx_3 = patternInput_4[0][0];
622
+ const autoScale = (_arg) => {
623
+ if (_arg.tag === 0) {
624
+ const patternInput_5 = Scales_adjustRangeUnits(_arg.fields[0].fields[0], _arg.fields[1].fields[0]);
625
+ return new Scale(0, [new continuous(patternInput_5[0]), new continuous(patternInput_5[1])]);
626
+ }
627
+ else {
628
+ return _arg;
629
+ }
630
+ };
631
+ return [[shape.fields[0] ? autoScale(isx_3) : isx_3, shape.fields[1] ? autoScale(isy_3) : isy_3], patternInput_4[1]];
632
+ }
633
+ case 13: {
634
+ const patternInput_6 = calculateScales(shape.fields[1]);
635
+ return [patternInput_6[0], new Scales_ScaledShape(8, [shape.fields[0], patternInput_6[1]])];
636
+ }
637
+ case 12: {
638
+ const patternInput_7 = calculateScales(shape.fields[1]);
639
+ const sy_3 = patternInput_7[0][1];
640
+ const sx_3 = patternInput_7[0][0];
641
+ return [[sx_3, sy_3], new Scales_ScaledShape(7, [shape.fields[0], sx_3, sy_3, patternInput_7[1]])];
642
+ }
643
+ case 7: {
644
+ const y = shape.fields[1];
645
+ const x = shape.fields[0];
646
+ const makeSingletonScale = (_arg_1) => {
647
+ if (_arg_1.tag === 0) {
648
+ return new Scale(1, [[_arg_1.fields[0]]]);
649
+ }
650
+ else {
651
+ const v = _arg_1.fields[0];
652
+ return new Scale(0, [v, v]);
653
+ }
654
+ };
655
+ return [[makeSingletonScale(x), makeSingletonScale(y)], new Scales_ScaledShape(3, [x, y, shape.fields[2], shape.fields[3]])];
656
+ }
657
+ case 1: {
658
+ const y_1 = shape.fields[1];
659
+ const x_1 = shape.fields[0];
660
+ const makeSingletonScale_1 = (_arg_2) => {
661
+ if (_arg_2.tag === 0) {
662
+ return new Scale(1, [[_arg_2.fields[0]]]);
663
+ }
664
+ else {
665
+ const v_2 = _arg_2.fields[0];
666
+ return new Scale(0, [v_2, v_2]);
667
+ }
668
+ };
669
+ return [[makeSingletonScale_1(x_1), makeSingletonScale_1(y_1)], new Scales_ScaledShape(1, [x_1, y_1, shape.fields[2], shape.fields[3], shape.fields[4], shape.fields[5]])];
670
+ }
671
+ case 6: {
672
+ const line_1 = toArray(shape.fields[0]);
673
+ return [Scales_calculateShapeScales(line_1), new Scales_ScaledShape(2, [line_1])];
674
+ }
675
+ case 8: {
676
+ const points_1 = toArray(shape.fields[0]);
677
+ return [Scales_calculateShapeScales(points_1), new Scales_ScaledShape(4, [points_1])];
678
+ }
679
+ case 10: {
680
+ const showTop = shape.fields[0];
681
+ const showRight = shape.fields[1];
682
+ const showLeft = shape.fields[3];
683
+ const showBottom = shape.fields[2];
684
+ const shape_17 = shape.fields[4];
685
+ const patternInput_8 = calculateScales(shape_17);
686
+ const sy_4 = patternInput_8[0][1];
687
+ const sx_4 = patternInput_8[0][0];
688
+ const matchValue = Scales_getExtremes(sx_4);
689
+ const matchValue_1 = Scales_getExtremes(sy_4);
690
+ const ly = matchValue_1[0];
691
+ const lx = matchValue[0];
692
+ const hy = matchValue_1[1];
693
+ const hx = matchValue[1];
694
+ const LineStyle = (clr, alpha, width, shape_18) => (new Shape(0, [(s) => (new Style([alpha, new Color(1, [clr])], new Width(width), s.StrokeDashArray, new FillStyle(0, [[1, new Color(1, ["transparent"])]]), s.Animation, s.Font, s.Cursor, s.FormatAxisXLabel, s.FormatAxisYLabel)), shape_18]));
695
+ const FontStyle = (style_2, shape_19) => (new Shape(0, [(s_1) => (new Style([0, new Color(1, ["transparent"])], s_1.StrokeWidth, s_1.StrokeDashArray, new FillStyle(0, [[1, new Color(1, ["black"])]]), s_1.Animation, style_2, s_1.Cursor, s_1.FormatAxisXLabel, s_1.FormatAxisYLabel)), shape_19]));
696
+ return calculateScales(new Shape(12, [[showTop ? 30 : 0, showRight ? 50 : 0, showBottom ? 30 : 0, showLeft ? 50 : 0], new Shape(9, [toList(delay(() => append(singleton(new Shape(3, [sx_4, sy_4, new Shape(9, [toList(delay(() => append(map_1((x_2) => LineStyle("#e4e4e4", 1, 1, new Shape(6, [[[x_2, ly], [x_2, hy]]])), Scales_generateAxisSteps(sx_4)), delay(() => map_1((y_2) => LineStyle("#e4e4e4", 1, 1, new Shape(6, [[[lx, y_2], [hx, y_2]]])), Scales_generateAxisSteps(sy_4))))))])])), delay(() => append(showTop ? append(singleton(LineStyle("black", 1, 2, new Shape(6, [[[lx, hy], [hx, hy]]]))), delay(() => collect((matchValue_2) => singleton(FontStyle("9pt sans-serif", new Shape(13, [[0, -10], new Shape(1, [matchValue_2[0], hy, new VerticalAlign(0, []), new HorizontalAlign(1, []), 0, matchValue_2[1]])]))), Scales_generateAxisLabels(style.FormatAxisXLabel, sx_4)))) : empty_1(), delay(() => append(showRight ? append(singleton(LineStyle("black", 1, 2, new Shape(6, [[[hx, hy], [hx, ly]]]))), delay(() => collect((matchValue_3) => singleton(FontStyle("9pt sans-serif", new Shape(13, [[10, 0], new Shape(1, [hx, matchValue_3[0], new VerticalAlign(1, []), new HorizontalAlign(0, []), 0, matchValue_3[1]])]))), Scales_generateAxisLabels(style.FormatAxisYLabel, sy_4)))) : empty_1(), delay(() => append(showBottom ? append(singleton(LineStyle("black", 1, 2, new Shape(6, [[[lx, ly], [hx, ly]]]))), delay(() => collect((matchValue_4) => singleton(FontStyle("9pt sans-serif", new Shape(13, [[0, 10], new Shape(1, [matchValue_4[0], ly, new VerticalAlign(2, []), new HorizontalAlign(1, []), 0, matchValue_4[1]])]))), Scales_generateAxisLabels(style.FormatAxisXLabel, sx_4)))) : empty_1(), delay(() => append(showLeft ? append(singleton(LineStyle("black", 1, 2, new Shape(6, [[[lx, hy], [lx, ly]]]))), delay(() => collect((matchValue_5) => singleton(FontStyle("9pt sans-serif", new Shape(13, [[-10, 0], new Shape(1, [lx, matchValue_5[0], new VerticalAlign(1, []), new HorizontalAlign(2, []), 0, matchValue_5[1]])]))), Scales_generateAxisLabels(style.FormatAxisYLabel, sy_4)))) : empty_1(), delay(() => singleton(shape_17)))))))))))))])]));
697
+ }
698
+ case 9: {
699
+ const scaled = map(calculateScales, Array.from(shape.fields[0]));
700
+ const sxs = map((tupledArg) => tupledArg[0][0], scaled);
701
+ const sys = map((tupledArg_1) => tupledArg_1[0][1], scaled);
702
+ return [[sxs.reduce(Scales_unionScales), sys.reduce(Scales_unionScales)], new Scales_ScaledShape(5, [map((tuple) => tuple[1], scaled)])];
703
+ }
704
+ case 11: {
705
+ const patternInput_10 = calculateScales(shape.fields[1]);
706
+ const scales_8 = patternInput_10[0];
707
+ return [scales_8, new Scales_ScaledShape(6, [shape.fields[0], scales_8[0], scales_8[1], patternInput_10[1]])];
708
+ }
709
+ default: {
710
+ const f = shape.fields[0];
711
+ const patternInput = Scales_calculateScales(f(style), shape.fields[1]);
712
+ return [patternInput[0], new Scales_ScaledShape(0, [f, patternInput[1]])];
713
+ }
714
+ }
715
+ }
716
+
717
+ export function Projections_projectOne(reversed, tlv, thv, scale, coord) {
718
+ if (scale.tag === 0) {
719
+ if (coord.tag === 0) {
720
+ return toFail(printf("Cannot project categorical value (%A) on a continuous scale (%A)."))(coord)(scale);
721
+ }
722
+ else if (reversed) {
723
+ return thv - (((coord.fields[0].fields[0] - scale.fields[0].fields[0]) / (scale.fields[1].fields[0] - scale.fields[0].fields[0])) * (thv - tlv));
724
+ }
725
+ else {
726
+ return tlv + (((coord.fields[0].fields[0] - scale.fields[0].fields[0]) / (scale.fields[1].fields[0] - scale.fields[0].fields[0])) * (thv - tlv));
727
+ }
728
+ }
729
+ else if (coord.tag === 1) {
730
+ return toFail(printf("Cannot project continuous value (%A) on a categorical scale (%A)."))(coord)(scale);
731
+ }
732
+ else {
733
+ const size = (thv - tlv) / scale.fields[0].length;
734
+ const i_1 = findIndex((_arg) => (coord.fields[0].fields[0] === _arg.fields[0]), scale.fields[0]) + coord.fields[1];
735
+ if (reversed) {
736
+ return thv - (i_1 * size);
737
+ }
738
+ else {
739
+ return tlv + (i_1 * size);
740
+ }
741
+ }
742
+ }
743
+
744
+ export function Projections_projectOneX(a_, a__1) {
745
+ const a = [a_, a__1];
746
+ return (scale) => ((coord) => Projections_projectOne(false, a[0], a[1], scale, coord));
747
+ }
748
+
749
+ export function Projections_projectOneY(a_, a__1) {
750
+ const a = [a_, a__1];
751
+ return (scale) => ((coord) => Projections_projectOne(true, a[0], a[1], scale, coord));
752
+ }
753
+
754
+ export function Projections_projectInvOne(reversed, l, h, s, v) {
755
+ if (s.tag === 1) {
756
+ const cats = s.fields[0];
757
+ const size = (h - l) / cats.length;
758
+ const i = reversed ? Math.floor((h - v) / size) : Math.floor((v - l) / size);
759
+ const f = reversed ? (((h - v) / size) - i) : (((v - l) / size) - i);
760
+ const i_1 = (size < 0) ? (cats.length + i) : i;
761
+ if ((~~i_1 < 0) ? true : (~~i_1 >= cats.length)) {
762
+ return new Value(0, [new categorical("<outside-of-range>"), f]);
763
+ }
764
+ else {
765
+ return new Value(0, [item_2(~~i_1, cats), f]);
766
+ }
767
+ }
768
+ else {
769
+ const slv = s.fields[0].fields[0];
770
+ const shv = s.fields[1].fields[0];
771
+ if (reversed) {
772
+ return new Value(1, [new continuous(shv - (((v - l) / (h - l)) * (shv - slv)))]);
773
+ }
774
+ else {
775
+ return new Value(1, [new continuous(slv + (((v - l) / (h - l)) * (shv - slv)))]);
776
+ }
777
+ }
778
+ }
779
+
780
+ export function Projections_projectInv(x1, y1, x2, y2, sx, sy, x, y) {
781
+ return [Projections_projectInvOne(false, x1, x2, sx, x), Projections_projectInvOne(true, y1, y2, sy, y)];
782
+ }
783
+
784
+ export class Drawing_DrawingContext extends Record {
785
+ constructor(Style, Definitions) {
786
+ super();
787
+ this.Style = Style;
788
+ this.Definitions = Definitions;
789
+ }
790
+ }
791
+
792
+ export function Drawing_DrawingContext_$reflection() {
793
+ return record_type("Compost.Drawing.DrawingContext", [], Drawing_DrawingContext, () => [["Style", Style_$reflection()], ["Definitions", array_type(DomNode_$reflection())]]);
794
+ }
795
+
796
+ export function Drawing_hideFill(style) {
797
+ let matchValue, f;
798
+ return new Style(style.StrokeColor, style.StrokeWidth, style.StrokeDashArray, new FillStyle(0, [[0, new Color(0, [0, 0, 0])]]), (matchValue = style.Animation, (matchValue != null) ? ((f = matchValue[2], [matchValue[0], matchValue[1], (arg) => Drawing_hideFill(f(arg))])) : undefined), style.Font, style.Cursor, style.FormatAxisXLabel, style.FormatAxisYLabel);
799
+ }
800
+
801
+ export function Drawing_hideStroke(style) {
802
+ let matchValue, f;
803
+ return new Style([0, style.StrokeColor[1]], style.StrokeWidth, style.StrokeDashArray, style.Fill, (matchValue = style.Animation, (matchValue != null) ? ((f = matchValue[2], [matchValue[0], matchValue[1], (arg) => Drawing_hideStroke(f(arg))])) : undefined), style.Font, style.Cursor, style.FormatAxisXLabel, style.FormatAxisYLabel);
804
+ }
805
+
806
+ export function Drawing_drawShape(ctx_mut, area__mut, area__1_mut, area__2_mut, area__3_mut, scales__mut, scales__1_mut, shape_mut) {
807
+ Drawing_drawShape:
808
+ while (true) {
809
+ const ctx = ctx_mut, area_ = area__mut, area__1 = area__1_mut, area__2 = area__2_mut, area__3 = area__3_mut, scales_ = scales__mut, scales__1 = scales__1_mut, shape = shape_mut;
810
+ const area_1 = [area_, area__1, area__2, area__3];
811
+ const y2 = area_1[3];
812
+ const y1 = area_1[1];
813
+ const x2 = area_1[2];
814
+ const x1 = area_1[0];
815
+ const scales_1 = [scales_, scales__1];
816
+ const sy = scales_1[1];
817
+ const sx = scales_1[0];
818
+ const project = (tupledArg) => [Projections_projectOneX(x1, x2)(sx)(tupledArg[0]), Projections_projectOneY(y1, y2)(sy)(tupledArg[1])];
819
+ switch (shape.tag) {
820
+ case 10: {
821
+ ctx_mut = ctx;
822
+ area__mut = x1;
823
+ area__1_mut = Projections_projectOneY(y1, y2)(sy)(shape.fields[0]);
824
+ area__2_mut = x2;
825
+ area__3_mut = Projections_projectOneY(y1, y2)(sy)(shape.fields[1]);
826
+ scales__mut = sx;
827
+ scales__1_mut = shape.fields[2];
828
+ shape_mut = shape.fields[3];
829
+ continue Drawing_drawShape;
830
+ }
831
+ case 8: {
832
+ const dy = shape.fields[0][1];
833
+ const dx = shape.fields[0][0];
834
+ ctx_mut = ctx;
835
+ area__mut = (x1 + dx);
836
+ area__1_mut = (y1 + dy);
837
+ area__2_mut = (x2 + dx);
838
+ area__3_mut = (y2 + dy);
839
+ scales__mut = scales_1[0];
840
+ scales__1_mut = scales_1[1];
841
+ shape_mut = shape.fields[1];
842
+ continue Drawing_drawShape;
843
+ }
844
+ case 5:
845
+ return new Svg_Svg(4, [map((shape_4) => Drawing_drawShape(ctx, area_1[0], area_1[1], area_1[2], area_1[3], scales_1[0], scales_1[1], shape_4), shape.fields[0])]);
846
+ case 0: {
847
+ ctx_mut = (new Drawing_DrawingContext(shape.fields[0](ctx.Style), ctx.Definitions));
848
+ area__mut = area_1[0];
849
+ area__1_mut = area_1[1];
850
+ area__2_mut = area_1[2];
851
+ area__3_mut = area_1[3];
852
+ scales__mut = scales_1[0];
853
+ scales__1_mut = scales_1[1];
854
+ shape_mut = shape.fields[1];
855
+ continue Drawing_drawShape;
856
+ }
857
+ case 4: {
858
+ const points = shape.fields[0];
859
+ return new Svg_Svg(0, [toArray(delay(() => append(singleton(new Svg_PathSegment(0, [project(item_2(0, points))])), delay(() => append(map_1((pt) => (new Svg_PathSegment(1, [project(pt)])), skip(1, points)), delay(() => singleton(new Svg_PathSegment(1, [project(item_2(0, points))])))))))), Svg_formatStyle(ctx.Definitions, Drawing_hideStroke(ctx.Style))]);
860
+ }
861
+ case 7: {
862
+ const isy_1 = shape.fields[2];
863
+ const isx_1 = shape.fields[1];
864
+ const calculateNestedRange = (rev) => ((tupledArg_1) => ((ins) => {
865
+ const v1 = tupledArg_1[0];
866
+ const v2 = tupledArg_1[1];
867
+ return (outs) => {
868
+ if (ins.tag === 1) {
869
+ const pos_1 = collect((v) => ofArray([Projections_projectOne(rev, v1, v2, outs, new Value(0, [v, 0])), Projections_projectOne(rev, v1, v2, outs, new Value(0, [v, 1]))]), ins.fields[0]);
870
+ return [min_3(pos_1, {
871
+ Compare: comparePrimitives,
872
+ }), max_3(pos_1, {
873
+ Compare: comparePrimitives,
874
+ })];
875
+ }
876
+ else {
877
+ const pos = ofArray([Projections_projectOne(rev, v1, v2, outs, new Value(1, [new continuous(ins.fields[0].fields[0])])), Projections_projectOne(rev, v1, v2, outs, new Value(1, [new continuous(ins.fields[1].fields[0])]))]);
878
+ return [min_3(pos, {
879
+ Compare: comparePrimitives,
880
+ }), max_3(pos, {
881
+ Compare: comparePrimitives,
882
+ })];
883
+ }
884
+ };
885
+ }));
886
+ const patternInput = calculateNestedRange(false)([x1, x2])(isx_1)(sx);
887
+ const patternInput_1 = calculateNestedRange(true)([y1, y2])(isy_1)(sy);
888
+ ctx_mut = ctx;
889
+ area__mut = (patternInput[0] + shape.fields[0][3]);
890
+ area__1_mut = (patternInput_1[0] + shape.fields[0][0]);
891
+ area__2_mut = (patternInput[1] - shape.fields[0][1]);
892
+ area__3_mut = (patternInput_1[1] - shape.fields[0][2]);
893
+ scales__mut = isx_1;
894
+ scales__1_mut = isy_1;
895
+ shape_mut = shape.fields[3];
896
+ continue Drawing_drawShape;
897
+ }
898
+ case 2: {
899
+ const line = shape.fields[0];
900
+ return new Svg_Svg(0, [Array.from(delay(() => append(singleton(new Svg_PathSegment(0, [project(head(line))])), delay(() => map_1((pt_1) => (new Svg_PathSegment(1, [project(pt_1)])), skip(1, line)))))), Svg_formatStyle(ctx.Definitions, Drawing_hideFill(ctx.Style))]);
901
+ }
902
+ case 1: {
903
+ const va = shape.fields[2];
904
+ const ha = shape.fields[3];
905
+ const va_1 = (va.tag === 2) ? "hanging" : ((va.tag === 1) ? "middle" : "baseline");
906
+ const ha_1 = (ha.tag === 1) ? "middle" : ((ha.tag === 2) ? "end" : "start");
907
+ return new Svg_Svg(3, [project([shape.fields[0], shape.fields[1]]), shape.fields[5], shape.fields[4], toText(printf("alignment-baseline:%s; text-anchor:%s;"))(va_1)(ha_1) + Svg_formatStyle(ctx.Definitions, ctx.Style)]);
908
+ }
909
+ case 3:
910
+ return new Svg_Svg(1, [project([shape.fields[0], shape.fields[1]]), [shape.fields[2], shape.fields[3]], Svg_formatStyle(ctx.Definitions, ctx.Style)]);
911
+ case 6: {
912
+ ctx_mut = ctx;
913
+ area__mut = area_1[0];
914
+ area__1_mut = area_1[1];
915
+ area__2_mut = area_1[2];
916
+ area__3_mut = area_1[3];
917
+ scales__mut = scales_1[0];
918
+ scales__1_mut = scales_1[1];
919
+ shape_mut = shape.fields[3];
920
+ continue Drawing_drawShape;
921
+ }
922
+ default: {
923
+ ctx_mut = ctx;
924
+ area__mut = Projections_projectOneX(x1, x2)(sx)(shape.fields[0]);
925
+ area__1_mut = y1;
926
+ area__2_mut = Projections_projectOneX(x1, x2)(sx)(shape.fields[1]);
927
+ area__3_mut = y2;
928
+ scales__mut = shape.fields[2];
929
+ scales__1_mut = sy;
930
+ shape_mut = shape.fields[3];
931
+ continue Drawing_drawShape;
932
+ }
933
+ }
934
+ break;
935
+ }
936
+ }
937
+
938
+ export class Events_MouseEventKind extends Union {
939
+ constructor(tag, fields) {
940
+ super();
941
+ this.tag = tag;
942
+ this.fields = fields;
943
+ }
944
+ cases() {
945
+ return ["Click", "Move", "Up", "Down"];
946
+ }
947
+ }
948
+
949
+ export function Events_MouseEventKind_$reflection() {
950
+ return union_type("Compost.Events.MouseEventKind", [], Events_MouseEventKind, () => [[], [], [], []]);
951
+ }
952
+
953
+ export class Events_TouchEventKind extends Union {
954
+ constructor(tag, fields) {
955
+ super();
956
+ this.tag = tag;
957
+ this.fields = fields;
958
+ }
959
+ cases() {
960
+ return ["Move", "Start"];
961
+ }
962
+ }
963
+
964
+ export function Events_TouchEventKind_$reflection() {
965
+ return union_type("Compost.Events.TouchEventKind", [], Events_TouchEventKind, () => [[], []]);
966
+ }
967
+
968
+ export class Events_InteractiveEvent extends Union {
969
+ constructor(tag, fields) {
970
+ super();
971
+ this.tag = tag;
972
+ this.fields = fields;
973
+ }
974
+ cases() {
975
+ return ["MouseEvent", "TouchEvent", "TouchEnd", "MouseLeave"];
976
+ }
977
+ }
978
+
979
+ export function Events_InteractiveEvent_$reflection(gen0, gen1) {
980
+ return union_type("Compost.Events.InteractiveEvent", [gen0, gen1], Events_InteractiveEvent, () => [[["Item1", Events_MouseEventKind_$reflection()], ["Item2", tuple_type(Value_$reflection(gen0), Value_$reflection(gen1))]], [["Item1", Events_TouchEventKind_$reflection()], ["Item2", tuple_type(Value_$reflection(gen0), Value_$reflection(gen1))]], [], []]);
981
+ }
982
+
983
+ export function Events_projectEvent(area_, area__1, area__2, area__3, scales_, scales__1, event) {
984
+ const area = [area_, area__1, area__2, area__3];
985
+ const scales = [scales_, scales__1];
986
+ let matchResult, kind, x, y, kind_1, x_3, y_3;
987
+ switch (event.tag) {
988
+ case 1: {
989
+ if (event.fields[1][0].tag === 1) {
990
+ if (event.fields[1][1].tag === 1) {
991
+ matchResult = 1;
992
+ kind_1 = event.fields[0];
993
+ x_3 = event.fields[1][0].fields[0].fields[0];
994
+ y_3 = event.fields[1][1].fields[0].fields[0];
995
+ }
996
+ else {
997
+ matchResult = 2;
998
+ }
999
+ }
1000
+ else {
1001
+ matchResult = 2;
1002
+ }
1003
+ break;
1004
+ }
1005
+ case 2: {
1006
+ matchResult = 3;
1007
+ break;
1008
+ }
1009
+ case 3: {
1010
+ matchResult = 4;
1011
+ break;
1012
+ }
1013
+ default:
1014
+ if (event.fields[1][0].tag === 1) {
1015
+ if (event.fields[1][1].tag === 1) {
1016
+ matchResult = 0;
1017
+ kind = event.fields[0];
1018
+ x = event.fields[1][0].fields[0].fields[0];
1019
+ y = event.fields[1][1].fields[0].fields[0];
1020
+ }
1021
+ else {
1022
+ matchResult = 2;
1023
+ }
1024
+ }
1025
+ else {
1026
+ matchResult = 2;
1027
+ }
1028
+ }
1029
+ switch (matchResult) {
1030
+ case 0:
1031
+ return new Events_InteractiveEvent(0, [kind, Projections_projectInv(area[0], area[1], area[2], area[3], scales[0], scales[1], x, y)]);
1032
+ case 1:
1033
+ return new Events_InteractiveEvent(1, [kind_1, Projections_projectInv(area[0], area[1], area[2], area[3], scales[0], scales[1], x_3, y_3)]);
1034
+ case 2:
1035
+ throw new Error("TODO: projectEvent - not continuous");
1036
+ case 3:
1037
+ return new Events_InteractiveEvent(2, []);
1038
+ default:
1039
+ return new Events_InteractiveEvent(3, []);
1040
+ }
1041
+ }
1042
+
1043
+ export function Events_inScale(s, v) {
1044
+ if (s.tag === 1) {
1045
+ if (v.tag === 1) {
1046
+ throw new Error("inScale: Cannot test if continuous value is in categorical scale");
1047
+ }
1048
+ else {
1049
+ return exists((y) => equals(v.fields[0], y), s.fields[0]);
1050
+ }
1051
+ }
1052
+ else if (v.tag === 0) {
1053
+ throw new Error("inScale: Cannot test if categorical value is in continuous scale");
1054
+ }
1055
+ else if (v.fields[0].fields[0] >= min(s.fields[0].fields[0], s.fields[1].fields[0])) {
1056
+ return v.fields[0].fields[0] <= max(s.fields[0].fields[0], s.fields[1].fields[0]);
1057
+ }
1058
+ else {
1059
+ return false;
1060
+ }
1061
+ }
1062
+
1063
+ export function Events_inScales(sx, sy, event) {
1064
+ let matchResult, x, y;
1065
+ switch (event.tag) {
1066
+ case 2: {
1067
+ matchResult = 1;
1068
+ break;
1069
+ }
1070
+ case 0: {
1071
+ matchResult = 2;
1072
+ x = event.fields[1][0];
1073
+ y = event.fields[1][1];
1074
+ break;
1075
+ }
1076
+ case 1: {
1077
+ matchResult = 2;
1078
+ x = event.fields[1][0];
1079
+ y = event.fields[1][1];
1080
+ break;
1081
+ }
1082
+ default:
1083
+ matchResult = 0;
1084
+ }
1085
+ switch (matchResult) {
1086
+ case 0:
1087
+ return true;
1088
+ case 1:
1089
+ return true;
1090
+ default:
1091
+ if (Events_inScale(sx, x)) {
1092
+ return Events_inScale(sy, y);
1093
+ }
1094
+ else {
1095
+ return false;
1096
+ }
1097
+ }
1098
+ }
1099
+
1100
+ export function Events_triggerEvent(area__mut, area__1_mut, area__2_mut, area__3_mut, scales__mut, scales__1_mut, shape_mut, jse_mut, event_mut) {
1101
+ Events_triggerEvent:
1102
+ while (true) {
1103
+ const area_ = area__mut, area__1 = area__1_mut, area__2 = area__2_mut, area__3 = area__3_mut, scales_ = scales__mut, scales__1 = scales__1_mut, shape = shape_mut, jse = jse_mut, event = event_mut;
1104
+ const area_1 = [area_, area__1, area__2, area__3];
1105
+ const y2 = area_1[3];
1106
+ const y1 = area_1[1];
1107
+ const x2 = area_1[2];
1108
+ const x1 = area_1[0];
1109
+ const scales_1 = [scales_, scales__1];
1110
+ const sy = scales_1[1];
1111
+ const sx = scales_1[0];
1112
+ switch (shape.tag) {
1113
+ case 0: {
1114
+ area__mut = area_1[0];
1115
+ area__1_mut = area_1[1];
1116
+ area__2_mut = area_1[2];
1117
+ area__3_mut = area_1[3];
1118
+ scales__mut = scales_1[0];
1119
+ scales__1_mut = scales_1[1];
1120
+ shape_mut = shape.fields[1];
1121
+ jse_mut = jse;
1122
+ event_mut = event;
1123
+ continue Events_triggerEvent;
1124
+ break;
1125
+ }
1126
+ case 8: {
1127
+ const dy = shape.fields[0][1];
1128
+ const dx = shape.fields[0][0];
1129
+ area__mut = (x1 + dx);
1130
+ area__1_mut = (y1 + dy);
1131
+ area__2_mut = (x2 + dx);
1132
+ area__3_mut = (y2 + dy);
1133
+ scales__mut = scales_1[0];
1134
+ scales__1_mut = scales_1[1];
1135
+ shape_mut = shape.fields[1];
1136
+ jse_mut = jse;
1137
+ event_mut = event;
1138
+ continue Events_triggerEvent;
1139
+ break;
1140
+ }
1141
+ case 9: {
1142
+ area__mut = Projections_projectOneX(x1, x2)(sx)(shape.fields[0]);
1143
+ area__1_mut = y1;
1144
+ area__2_mut = Projections_projectOneX(x1, x2)(sx)(shape.fields[1]);
1145
+ area__3_mut = y2;
1146
+ scales__mut = shape.fields[2];
1147
+ scales__1_mut = sy;
1148
+ shape_mut = shape.fields[3];
1149
+ jse_mut = jse;
1150
+ event_mut = event;
1151
+ continue Events_triggerEvent;
1152
+ break;
1153
+ }
1154
+ case 10: {
1155
+ area__mut = x1;
1156
+ area__1_mut = Projections_projectOneY(y1, y2)(sy)(shape.fields[0]);
1157
+ area__2_mut = x2;
1158
+ area__3_mut = Projections_projectOneY(y1, y2)(sy)(shape.fields[1]);
1159
+ scales__mut = sx;
1160
+ scales__1_mut = shape.fields[2];
1161
+ shape_mut = shape.fields[3];
1162
+ jse_mut = jse;
1163
+ event_mut = event;
1164
+ continue Events_triggerEvent;
1165
+ break;
1166
+ }
1167
+ case 7: {
1168
+ const isy_1 = shape.fields[2];
1169
+ const isx_1 = shape.fields[1];
1170
+ const calculateNestedRange = (rev) => ((tupledArg) => ((ins) => {
1171
+ const v1 = tupledArg[0];
1172
+ const v2 = tupledArg[1];
1173
+ return (outs) => {
1174
+ if (ins.tag === 1) {
1175
+ const pos_1 = collect((v) => ofArray([Projections_projectOne(rev, v1, v2, outs, new Value(0, [v, 0])), Projections_projectOne(rev, v1, v2, outs, new Value(0, [v, 1]))]), ins.fields[0]);
1176
+ return [min_3(pos_1, {
1177
+ Compare: comparePrimitives,
1178
+ }), max_3(pos_1, {
1179
+ Compare: comparePrimitives,
1180
+ })];
1181
+ }
1182
+ else {
1183
+ const pos = ofArray([Projections_projectOne(rev, v1, v2, outs, new Value(1, [new continuous(ins.fields[0].fields[0])])), Projections_projectOne(rev, v1, v2, outs, new Value(1, [new continuous(ins.fields[1].fields[0])]))]);
1184
+ return [min_3(pos, {
1185
+ Compare: comparePrimitives,
1186
+ }), max_3(pos, {
1187
+ Compare: comparePrimitives,
1188
+ })];
1189
+ }
1190
+ };
1191
+ }));
1192
+ const patternInput = calculateNestedRange(false)([x1, x2])(isx_1)(sx);
1193
+ const patternInput_1 = calculateNestedRange(true)([y1, y2])(isy_1)(sy);
1194
+ area__mut = (patternInput[0] + shape.fields[0][3]);
1195
+ area__1_mut = (patternInput_1[0] + shape.fields[0][0]);
1196
+ area__2_mut = (patternInput[1] - shape.fields[0][1]);
1197
+ area__3_mut = (patternInput_1[1] - shape.fields[0][2]);
1198
+ scales__mut = isx_1;
1199
+ scales__1_mut = isy_1;
1200
+ shape_mut = shape.fields[3];
1201
+ jse_mut = jse;
1202
+ event_mut = event;
1203
+ continue Events_triggerEvent;
1204
+ break;
1205
+ }
1206
+ case 5: {
1207
+ const shapes = shape.fields[0];
1208
+ for (let idx = 0; idx <= (shapes.length - 1); idx++) {
1209
+ Events_triggerEvent(area_1[0], area_1[1], area_1[2], area_1[3], scales_1[0], scales_1[1], item_2(idx, shapes), jse, event);
1210
+ }
1211
+ break;
1212
+ }
1213
+ case 6: {
1214
+ const localEvent = Events_projectEvent(area_1[0], area_1[1], area_1[2], area_1[3], scales_1[0], scales_1[1], event);
1215
+ if (Events_inScales(scales_1[0], scales_1[1], localEvent)) {
1216
+ const enumerator = getEnumerator(shape.fields[0]);
1217
+ try {
1218
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
1219
+ const handler = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
1220
+ let matchResult, f, pt, f_1, pt_1, f_2, f_3;
1221
+ switch (localEvent.tag) {
1222
+ case 1: {
1223
+ if (localEvent.fields[0].tag === 1) {
1224
+ if (handler.tag === 4) {
1225
+ matchResult = 1;
1226
+ f_1 = curry2(handler.fields[0]);
1227
+ pt_1 = localEvent.fields[1];
1228
+ }
1229
+ else {
1230
+ matchResult = 4;
1231
+ }
1232
+ }
1233
+ else if (handler.tag === 5) {
1234
+ matchResult = 1;
1235
+ f_1 = curry2(handler.fields[0]);
1236
+ pt_1 = localEvent.fields[1];
1237
+ }
1238
+ else {
1239
+ matchResult = 4;
1240
+ }
1241
+ break;
1242
+ }
1243
+ case 2: {
1244
+ if (handler.tag === 6) {
1245
+ matchResult = 2;
1246
+ f_2 = handler.fields[0];
1247
+ }
1248
+ else {
1249
+ matchResult = 4;
1250
+ }
1251
+ break;
1252
+ }
1253
+ case 3: {
1254
+ if (handler.tag === 7) {
1255
+ matchResult = 3;
1256
+ f_3 = handler.fields[0];
1257
+ }
1258
+ else {
1259
+ matchResult = 4;
1260
+ }
1261
+ break;
1262
+ }
1263
+ default:
1264
+ switch (localEvent.fields[0].tag) {
1265
+ case 1: {
1266
+ if (handler.tag === 0) {
1267
+ matchResult = 0;
1268
+ f = curry2(handler.fields[0]);
1269
+ pt = localEvent.fields[1];
1270
+ }
1271
+ else {
1272
+ matchResult = 4;
1273
+ }
1274
+ break;
1275
+ }
1276
+ case 2: {
1277
+ if (handler.tag === 1) {
1278
+ matchResult = 0;
1279
+ f = curry2(handler.fields[0]);
1280
+ pt = localEvent.fields[1];
1281
+ }
1282
+ else {
1283
+ matchResult = 4;
1284
+ }
1285
+ break;
1286
+ }
1287
+ case 3: {
1288
+ if (handler.tag === 2) {
1289
+ matchResult = 0;
1290
+ f = curry2(handler.fields[0]);
1291
+ pt = localEvent.fields[1];
1292
+ }
1293
+ else {
1294
+ matchResult = 4;
1295
+ }
1296
+ break;
1297
+ }
1298
+ default:
1299
+ if (handler.tag === 3) {
1300
+ matchResult = 0;
1301
+ f = curry2(handler.fields[0]);
1302
+ pt = localEvent.fields[1];
1303
+ }
1304
+ else {
1305
+ matchResult = 4;
1306
+ }
1307
+ }
1308
+ }
1309
+ switch (matchResult) {
1310
+ case 0: {
1311
+ if (!equals(jse, defaultOf())) {
1312
+ jse.preventDefault();
1313
+ }
1314
+ f(jse)(pt);
1315
+ break;
1316
+ }
1317
+ case 1: {
1318
+ if (!equals(jse, defaultOf())) {
1319
+ jse.preventDefault();
1320
+ }
1321
+ f_1(jse)(pt_1);
1322
+ break;
1323
+ }
1324
+ case 2: {
1325
+ f_2(jse);
1326
+ break;
1327
+ }
1328
+ case 3: {
1329
+ f_3(jse);
1330
+ break;
1331
+ }
1332
+ }
1333
+ }
1334
+ }
1335
+ finally {
1336
+ disposeSafe(enumerator);
1337
+ }
1338
+ }
1339
+ area__mut = area_1[0];
1340
+ area__1_mut = area_1[1];
1341
+ area__2_mut = area_1[2];
1342
+ area__3_mut = area_1[3];
1343
+ scales__mut = scales_1[0];
1344
+ scales__1_mut = scales_1[1];
1345
+ shape_mut = shape.fields[3];
1346
+ jse_mut = jse;
1347
+ event_mut = event;
1348
+ continue Events_triggerEvent;
1349
+ break;
1350
+ }
1351
+ default:
1352
+ undefined;
1353
+ }
1354
+ break;
1355
+ }
1356
+ }
1357
+
1358
+ export function Derived_StrokeColor(clr, s) {
1359
+ return new Shape(0, [(s_1) => (new Style([1, new Color(1, [clr])], s_1.StrokeWidth, s_1.StrokeDashArray, s_1.Fill, s_1.Animation, s_1.Font, s_1.Cursor, s_1.FormatAxisXLabel, s_1.FormatAxisYLabel)), s]);
1360
+ }
1361
+
1362
+ export function Derived_FillColor(clr, s) {
1363
+ return new Shape(0, [(s_1) => (new Style(s_1.StrokeColor, s_1.StrokeWidth, s_1.StrokeDashArray, new FillStyle(0, [[1, new Color(1, [clr])]]), s_1.Animation, s_1.Font, s_1.Cursor, s_1.FormatAxisXLabel, s_1.FormatAxisYLabel)), s]);
1364
+ }
1365
+
1366
+ export function Derived_Font(font, clr, s) {
1367
+ return new Shape(0, [(s_1) => (new Style([0, new Color(1, [clr])], s_1.StrokeWidth, s_1.StrokeDashArray, new FillStyle(0, [[1, new Color(1, [clr])]]), s_1.Animation, font, s_1.Cursor, s_1.FormatAxisXLabel, s_1.FormatAxisYLabel)), s]);
1368
+ }
1369
+
1370
+ export function Derived_Area(line) {
1371
+ return new Shape(8, [delay(() => {
1372
+ const line_1 = Array.from(line);
1373
+ const matchValue = item_2(0, line_1)[0];
1374
+ const matchValue_1 = item_2(line_1.length - 1, line_1)[0];
1375
+ const firstX = matchValue;
1376
+ return append(singleton([firstX, new Value(1, [new continuous(0)])]), delay(() => append(line_1, delay(() => append(singleton([matchValue_1, new Value(1, [new continuous(0)])]), delay(() => singleton([firstX, new Value(1, [new continuous(0)])])))))));
1377
+ })]);
1378
+ }
1379
+
1380
+ export function Derived_VArea(line) {
1381
+ return new Shape(8, [delay(() => {
1382
+ const line_1 = Array.from(line);
1383
+ const matchValue = item_2(0, line_1)[1];
1384
+ const matchValue_1 = item_2(line_1.length - 1, line_1)[1];
1385
+ const firstY = matchValue;
1386
+ return append(singleton([new Value(1, [new continuous(0)]), firstY]), delay(() => append(line_1, delay(() => append(singleton([new Value(1, [new continuous(0)]), matchValue_1]), delay(() => singleton([new Value(1, [new continuous(0)]), firstY])))))));
1387
+ })]);
1388
+ }
1389
+
1390
+ export function Derived_VShiftedArea(offs, line) {
1391
+ return new Shape(8, [delay(() => {
1392
+ const line_1 = Array.from(line);
1393
+ const matchValue = item_2(0, line_1)[1];
1394
+ const matchValue_1 = item_2(line_1.length - 1, line_1)[1];
1395
+ const firstY = matchValue;
1396
+ return append(singleton([new Value(1, [new continuous(offs)]), firstY]), delay(() => append(line_1, delay(() => append(singleton([new Value(1, [new continuous(offs)]), matchValue_1]), delay(() => singleton([new Value(1, [new continuous(offs)]), firstY])))))));
1397
+ })]);
1398
+ }
1399
+
1400
+ export function Derived_Bar(x, y) {
1401
+ return new Shape(8, [delay(() => append(singleton([new Value(1, [x]), new Value(0, [y, 0])]), delay(() => append(singleton([new Value(1, [x]), new Value(0, [y, 1])]), delay(() => append(singleton([new Value(1, [new continuous(0)]), new Value(0, [y, 1])]), delay(() => singleton([new Value(1, [new continuous(0)]), new Value(0, [y, 0])]))))))))]);
1402
+ }
1403
+
1404
+ export function Derived_Column(x, y) {
1405
+ return new Shape(8, [delay(() => append(singleton([new Value(0, [x, 0]), new Value(1, [y])]), delay(() => append(singleton([new Value(0, [x, 1]), new Value(1, [y])]), delay(() => append(singleton([new Value(0, [x, 1]), new Value(1, [new continuous(0)])]), delay(() => singleton([new Value(0, [x, 0]), new Value(1, [new continuous(0)])]))))))))]);
1406
+ }
1407
+
1408
+ export function Compost_niceNumber(num, decs) {
1409
+ const str = toString(num);
1410
+ const dot = str.indexOf(".") | 0;
1411
+ const patternInput = (dot === -1) ? [str, ""] : [substring(str, 0, dot), substring(str, dot + 1, min(decs, (str.length - dot) - 1))];
1412
+ const before = patternInput[0];
1413
+ const after = patternInput[1];
1414
+ const after_1 = (after.length < decs) ? (after + (toArray(delay(() => map_1((i) => "0", rangeDouble(1, 1, decs - after.length)))).join(''))) : after;
1415
+ let res = before;
1416
+ if (before.length > 5) {
1417
+ const enumerator = getEnumerator(rangeDouble(before.length - 1, -1, 0));
1418
+ try {
1419
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
1420
+ const i_1 = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]() | 0;
1421
+ if ((i_1 !== 0) && (((before.length - i_1) % 3) === 0)) {
1422
+ res = insert(res, i_1, ",");
1423
+ }
1424
+ }
1425
+ }
1426
+ finally {
1427
+ disposeSafe(enumerator);
1428
+ }
1429
+ }
1430
+ if (forAll((y) => ("0" === y), after_1.split(""))) {
1431
+ return res;
1432
+ }
1433
+ else {
1434
+ return (res + ".") + after_1;
1435
+ }
1436
+ }
1437
+
1438
+ export function Compost_defaultFormat(scale, value) {
1439
+ if (value.tag === 1) {
1440
+ const dec = (scale.tag === 0) ? Scales_decimalPoints(scale.fields[0].fields[0], scale.fields[1].fields[0]) : 0;
1441
+ return Compost_niceNumber(round(value.fields[0].fields[0], ~~dec), ~~dec);
1442
+ }
1443
+ else {
1444
+ return value.fields[0].fields[0];
1445
+ }
1446
+ }
1447
+
1448
+ export const Compost_defstyle = new Style([1, new Color(0, [256, 0, 0])], new Width(2), [], new FillStyle(0, [[1, new Color(0, [196, 196, 196])]]), undefined, "10pt sans-serif", "default", Compost_defaultFormat, Compost_defaultFormat);
1449
+
1450
+ export function Compost_getRelativeLocation(el, x, y) {
1451
+ const getOffset = (parent_mut, tupledArg_mut) => {
1452
+ getOffset:
1453
+ while (true) {
1454
+ const parent = parent_mut, tupledArg = tupledArg_mut;
1455
+ const x_1 = tupledArg[0];
1456
+ const y_1 = tupledArg[1];
1457
+ if (equals(parent, defaultOf())) {
1458
+ return [x_1, y_1];
1459
+ }
1460
+ else {
1461
+ parent_mut = parent.offsetParent;
1462
+ tupledArg_mut = [x_1 - parent.offsetLeft, y_1 - parent.offsetTop];
1463
+ continue getOffset;
1464
+ }
1465
+ break;
1466
+ }
1467
+ };
1468
+ const getParent = (parent_1_mut) => {
1469
+ getParent:
1470
+ while (true) {
1471
+ const parent_1 = parent_1_mut;
1472
+ if ((parent_1.namespaceURI === "http://www.w3.org/2000/svg") && (parent_1.tagName !== "svg")) {
1473
+ if (!equals(parent_1.parentElement, defaultOf())) {
1474
+ parent_1_mut = parent_1.parentElement;
1475
+ continue getParent;
1476
+ }
1477
+ else {
1478
+ parent_1_mut = parent_1.parentNode;
1479
+ continue getParent;
1480
+ }
1481
+ }
1482
+ else if (!equals(parent_1.offsetParent, defaultOf())) {
1483
+ return parent_1;
1484
+ }
1485
+ else if (!equals(parent_1.parentElement, defaultOf())) {
1486
+ parent_1_mut = parent_1.parentElement;
1487
+ continue getParent;
1488
+ }
1489
+ else {
1490
+ parent_1_mut = parent_1.parentNode;
1491
+ continue getParent;
1492
+ }
1493
+ break;
1494
+ }
1495
+ };
1496
+ return getOffset(getParent(el), [x, y]);
1497
+ }
1498
+
1499
+ export function Compost_createSvg(revX, revY, width, height, viz) {
1500
+ const patternInput = Scales_calculateScales(Compost_defstyle, viz);
1501
+ const sy = patternInput[0][1];
1502
+ const sx = patternInput[0][0];
1503
+ const shape = patternInput[1];
1504
+ const defs = [];
1505
+ const area = [0, 0, width, height];
1506
+ const svg = Drawing_drawShape(new Drawing_DrawingContext(Compost_defstyle, defs), area[0], area[1], area[2], area[3], sx, sy, shape);
1507
+ const triggerEvent = (e, event) => {
1508
+ Events_triggerEvent(area[0], area[1], area[2], area[3], sx, sy, shape, e, event);
1509
+ };
1510
+ const mouseHandler = (kind, el, evt) => {
1511
+ const evt_1 = evt;
1512
+ const patternInput_1 = Compost_getRelativeLocation(el, evt_1.pageX, evt_1.pageY);
1513
+ triggerEvent(evt_1, new Events_InteractiveEvent(0, [kind, [new Value(1, [new continuous(patternInput_1[0])]), new Value(1, [new continuous(patternInput_1[1])])]]));
1514
+ };
1515
+ const touchHandler = (kind_1, el_1, evt_2) => {
1516
+ const evt_3 = evt_2;
1517
+ const touch = item_2(0, evt_3.touches);
1518
+ const patternInput_2 = Compost_getRelativeLocation(el_1, touch.pageX, touch.pageY);
1519
+ triggerEvent(evt_3, new Events_InteractiveEvent(1, [kind_1, [new Value(1, [new continuous(patternInput_2[0])]), new Value(1, [new continuous(patternInput_2[1])])]]));
1520
+ };
1521
+ return El_op_Dynamic_Z451691CD(h_2, "div")(empty())(singleton_1(El_op_Dynamic_Z451691CD(s_6, "svg")(ofArray([op_EqualsGreater("style", "overflow:visible"), op_EqualsGreater("width", int32ToString(~~width)), op_EqualsGreater("height", int32ToString(~~height)), op_EqualsBangGreater("click", uncurry2(curry3(mouseHandler)(new Events_MouseEventKind(0, [])))), op_EqualsBangGreater("mousemove", uncurry2(curry3(mouseHandler)(new Events_MouseEventKind(1, [])))), op_EqualsBangGreater("mousedown", uncurry2(curry3(mouseHandler)(new Events_MouseEventKind(3, [])))), op_EqualsBangGreater("mouseup", uncurry2(curry3(mouseHandler)(new Events_MouseEventKind(2, [])))), op_EqualsBangGreater("mouseleave", (_arg, evt_4) => {
1522
+ triggerEvent(evt_4, new Events_InteractiveEvent(3, []));
1523
+ }), op_EqualsBangGreater("touchmove", uncurry2(curry3(touchHandler)(new Events_TouchEventKind(0, [])))), op_EqualsBangGreater("touchstart", uncurry2(curry3(touchHandler)(new Events_TouchEventKind(1, [])))), op_EqualsBangGreater("touchend", (_arg_1, evt_5) => {
1524
+ triggerEvent(evt_5, new Events_InteractiveEvent(2, []));
1525
+ })]))(toList(delay(() => {
1526
+ const body = Array.from(Svg_renderSvg(new Svg_RenderingContext(defs), svg));
1527
+ return append(defs, delay(() => body));
1528
+ })))));
1529
+ }
1530
+