-
Notifications
You must be signed in to change notification settings - Fork 0
/
vega2.js.map
227 lines (227 loc) · 547 KB
/
vega2.js.map
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
{
"version": 3,
"sources": [
"node_modules/browserify/node_modules/browser-pack/_prelude.js",
"index",
"node_modules/browserify/node_modules/browser-resolve/empty.js",
"node_modules/browserify/node_modules/process/browser.js",
"node_modules/datalib/src/aggregate/aggregator.js",
"node_modules/datalib/src/aggregate/collector.js",
"node_modules/datalib/src/aggregate/groupby.js",
"node_modules/datalib/src/aggregate/measures.js",
"node_modules/datalib/src/bins/bins.js",
"node_modules/datalib/src/bins/histogram.js",
"node_modules/datalib/src/generate.js",
"node_modules/datalib/src/import/formats/dsv.js",
"node_modules/datalib/src/import/formats/index.js",
"node_modules/datalib/src/import/formats/json.js",
"node_modules/datalib/src/import/formats/topojson.js",
"node_modules/datalib/src/import/formats/treejson.js",
"node_modules/datalib/src/import/load.js",
"node_modules/datalib/src/import/read.js",
"node_modules/datalib/src/import/readers.js",
"node_modules/datalib/src/import/type.js",
"node_modules/datalib/src/index.js",
"node_modules/datalib/src/print.js",
"node_modules/datalib/src/stats.js",
"node_modules/datalib/src/template.js",
"node_modules/datalib/src/time-units.js",
"node_modules/datalib/src/util.js",
"node_modules/heap/index.js",
"node_modules/heap/lib/heap.js",
"src/core/HeadlessView.js",
"src/core/Model.js",
"src/core/View.js",
"src/dataflow/Collector.js",
"src/dataflow/Datasource.js",
"src/dataflow/Graph.js",
"src/dataflow/Node.js",
"src/dataflow/Signal.js",
"src/dataflow/changeset.js",
"src/dataflow/tuple.js",
"src/expression/codegen.js",
"src/expression/constants.js",
"src/expression/functions.js",
"src/expression/index.js",
"src/expression/parser.js",
"src/parse/axes.js",
"src/parse/background.js",
"src/parse/data.js",
"src/parse/events.js",
"src/parse/expr.js",
"src/parse/interactors.js",
"src/parse/legends.js",
"src/parse/mark.js",
"src/parse/marks.js",
"src/parse/modify.js",
"src/parse/padding.js",
"src/parse/predicates.js",
"src/parse/properties.js",
"src/parse/signals.js",
"src/parse/spec.js",
"src/parse/streams.js",
"src/parse/transforms.js",
"src/render/canvas/Handler.js",
"src/render/canvas/Renderer.js",
"src/render/canvas/index.js",
"src/render/canvas/marks.js",
"src/render/canvas/path.js",
"src/render/svg-headless/Renderer.js",
"src/render/svg-headless/index.js",
"src/render/svg-headless/svg.js",
"src/render/svg/Handler.js",
"src/render/svg/Renderer.js",
"src/render/svg/marks.js",
"src/scene/Bounder.js",
"src/scene/Builder.js",
"src/scene/Encoder.js",
"src/scene/GroupBuilder.js",
"src/scene/Item.js",
"src/scene/Scale.js",
"src/scene/Transition.js",
"src/scene/axis.js",
"src/scene/legend.js",
"src/scene/visit.js",
"src/transforms/Aggregate.js",
"src/transforms/BatchTransform.js",
"src/transforms/Bin.js",
"src/transforms/Cross.js",
"src/transforms/Facet.js",
"src/transforms/Facetor.js",
"src/transforms/Filter.js",
"src/transforms/Fold.js",
"src/transforms/Force.js",
"src/transforms/Formula.js",
"src/transforms/Geo.js",
"src/transforms/GeoPath.js",
"src/transforms/LinkPath.js",
"src/transforms/Parameter.js",
"src/transforms/Pie.js",
"src/transforms/Sort.js",
"src/transforms/Stack.js",
"src/transforms/Transform.js",
"src/transforms/Treemap.js",
"src/transforms/Zip.js",
"src/transforms/index.js",
"src/util/Bounds.js",
"src/util/Gradient.js",
"src/util/boundscalc.js",
"src/util/config.js",
"src/util/constants.js",
"src/util/debug.js"
],
"names": [],
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrBA;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3SA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AClBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACveA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AClMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC7TA;AACA;;ACDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACnGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACrYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACj0EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACv6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC/SA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC9JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AC/KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AChPA;AACA;AACA;AACA;;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AC3uBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACzCA;AACA;AACA;AACA;;;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACpbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACzIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AClTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9RA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACtYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACjjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC9hBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC7GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACvFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC/DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACjTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA",
"file": "generated.js",
"sourceRoot": "",
"sourcesContent": [
"(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})",
"module.exports = {\n core: {\n View: require('./src/core/View')\n },\n dataflow: {\n changeset: require('./src/dataflow/changeset'),\n Datasource: require('./src/dataflow/Datasource'),\n Graph: require('./src/dataflow/Graph'),\n Node: require('./src/dataflow/Node')\n },\n parse: {\n spec: require('./src/parse/spec')\n },\n scene: {\n Builder: require('./src/scene/Builder'),\n GroupBuilder: require('./src/scene/GroupBuilder')\n },\n transforms: require('./src/transforms/index'),\n config: require('./src/util/config'),\n util: require('datalib'),\n Bounds: require(\"./src/util/Bounds\")\n};",
null,
"// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n draining = true;\n var currentQueue;\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n var i = -1;\n while (++i < len) {\n currentQueue[i]();\n }\n len = queue.length;\n }\n draining = false;\n}\nprocess.nextTick = function (fun) {\n queue.push(fun);\n if (!draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\n// TODO(shtylman)\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n",
"var util = require('../util'),\n Measures = require('./measures'),\n Collector = require('./collector');\n\nfunction Aggregator() {\n this._cells = {};\n this._aggr = [];\n this._stream = false;\n}\n\nvar Flags = Aggregator.Flags = {\n ADD_CELL: 1,\n MOD_CELL: 2\n};\n\nvar proto = Aggregator.prototype;\n\n// Parameters\n\nproto.stream = function(v) {\n if (v == null) return this._stream;\n this._stream = !!v;\n this._aggr = [];\n return this;\n};\n\n// key accessor to use for streaming removes\nproto.key = function(key) {\n if (key == null) return this._key;\n this._key = util.$(key);\n return this;\n};\n\n// Input: array of objects of the form\n// {name: string, get: function}\nproto.groupby = function(dims) {\n this._dims = util.array(dims).map(function(d, i) {\n d = util.isString(d) ? {name: d, get: util.$(d)}\n : util.isFunction(d) ? {name: util.name(d) || d.name || ('_' + i), get: d}\n : (d.name && util.isFunction(d.get)) ? d : null;\n if (d == null) throw 'Invalid groupby argument: ' + d;\n return d;\n });\n return this.clear();\n};\n\n// Input: array of objects of the form\n// {name: string, ops: [string, ...]}\nproto.summarize = function(fields) {\n fields = summarize_args(fields);\n this._count = true;\n var aggr = (this._aggr = []),\n m, f, i, j, op, as, get;\n\n for (i=0; i<fields.length; ++i) {\n for (j=0, m=[], f=fields[i]; j<f.ops.length; ++j) {\n op = f.ops[j];\n if (op !== 'count') this._count = false;\n as = (f.as && f.as[j]) || (op + (f.name==='*' ? '' : '_'+f.name));\n m.push(Measures[op](as));\n }\n get = f.get && util.$(f.get) ||\n (f.name === '*' ? util.identity : util.$(f.name));\n aggr.push({\n name: f.name,\n measures: Measures.create(\n m,\n this._stream, // streaming remove flag\n get, // input tuple getter\n this._assign) // output tuple setter\n });\n }\n return this.clear();\n};\n\n// Convenience method to summarize by count\nproto.count = function() {\n return this.summarize({'*':'count'});\n};\n\n// Override to perform custom tuple value assignment\nproto._assign = function(object, name, value) {\n object[name] = value;\n};\n\nfunction summarize_args(fields) {\n if (util.isArray(fields)) { return fields; }\n if (fields == null) { return []; }\n var a = [], name, ops;\n for (name in fields) {\n ops = util.array(fields[name]);\n a.push({name: name, ops: ops});\n }\n return a;\n}\n\n// Cell Management\n\nproto.clear = function() {\n return (this._cells = {}, this);\n};\n\nproto._cellkey = function(x) {\n var d = this._dims,\n n = d.length, i,\n k = String(d[0].get(x));\n for (i=1; i<n; ++i) {\n k += '|' + d[i].get(x);\n }\n return k;\n};\n\nproto._cell = function(x) {\n var key = this._dims.length ? this._cellkey(x) : '';\n return this._cells[key] || (this._cells[key] = this._newcell(x));\n};\n\nproto._newcell = function(x) {\n var cell = {\n num: 0,\n tuple: this._newtuple(x),\n flag: Flags.ADD_CELL,\n aggs: {}\n };\n\n var aggr = this._aggr, i;\n for (i=0; i<aggr.length; ++i) {\n cell.aggs[aggr[i].name] = new aggr[i].measures(cell, cell.tuple);\n }\n if (cell.collect) {\n cell.data = new Collector(this._key);\n }\n return cell;\n};\n\nproto._newtuple = function(x) {\n var dims = this._dims,\n t = {}, i, n;\n for (i=0, n=dims.length; i<n; ++i) {\n t[dims[i].name] = dims[i].get(x);\n }\n return this._ingest(t);\n};\n\n// Override to perform custom tuple ingestion\nproto._ingest = util.identity;\n\n// Process Tuples\n\nproto._add = function(x) {\n var cell = this._cell(x),\n aggr = this._aggr, i;\n\n cell.num += 1;\n if (!this._count) { // skip if count-only\n if (cell.collect) cell.data.add(x);\n for (i=0; i<aggr.length; ++i) {\n cell.aggs[aggr[i].name].add(x);\n }\n }\n cell.flag |= Flags.MOD_CELL;\n};\n\nproto._rem = function(x) {\n var cell = this._cell(x),\n aggr = this._aggr, i;\n\n cell.num -= 1;\n if (!this._count) { // skip if count-only\n if (cell.collect) cell.data.rem(x);\n for (i=0; i<aggr.length; ++i) {\n cell.aggs[aggr[i].name].rem(x);\n }\n }\n cell.flag |= Flags.MOD_CELL;\n};\n\nproto._mod = function(curr, prev) {\n var cell0 = this._cell(prev),\n cell1 = this._cell(curr),\n aggr = this._aggr, i;\n\n if (cell0 !== cell1) {\n cell0.num -= 1;\n cell1.num += 1;\n if (cell0.collect) cell0.data.rem(prev);\n if (cell1.collect) cell1.data.add(curr);\n } else if (cell0.collect && !util.isObject(curr)) {\n cell0.data.rem(prev);\n cell0.data.add(curr);\n }\n\n for (i=0; i<aggr.length; ++i) {\n cell0.aggs[aggr[i].name].rem(prev);\n cell1.aggs[aggr[i].name].add(curr);\n }\n cell0.flag |= Flags.MOD_CELL;\n cell1.flag |= Flags.MOD_CELL;\n};\n\nproto.result = function() {\n var result = [],\n aggr = this._aggr,\n cell, i, k;\n\n for (k in this._cells) {\n cell = this._cells[k];\n if (cell.num > 0) {\n // consolidate collector values\n if (cell.collect) {\n cell.data.values();\n }\n // update tuple properties\n for (i=0; i<aggr.length; ++i) {\n cell.aggs[aggr[i].name].set();\n }\n // add output tuple\n result.push(cell.tuple);\n } else {\n delete this._cells[k];\n }\n cell.flag = 0;\n }\n\n this._rems = false;\n return result;\n};\n\nproto.changes = function() {\n var changes = {add:[], rem:[], mod:[]},\n aggr = this._aggr,\n cell, flag, i, k;\n\n for (k in this._cells) {\n cell = this._cells[k];\n flag = cell.flag;\n\n // consolidate collector values\n if (cell.collect) {\n cell.data.values();\n }\n\n // update tuple properties\n for (i=0; i<aggr.length; ++i) {\n cell.aggs[aggr[i].name].set();\n }\n\n // organize output tuples\n if (cell.num <= 0) {\n changes.rem.push(cell.tuple);\n delete this._cells[k];\n } else if (flag & Flags.ADD_CELL) {\n changes.add.push(cell.tuple);\n } else if (flag & Flags.MOD_CELL) {\n changes.mod.push(cell.tuple);\n }\n\n cell.flag = 0;\n }\n\n this._rems = false;\n return changes;\n};\n\nproto.execute = function(input) {\n return this.clear().insert(input).result();\n};\n\nproto.insert = function(input) {\n this._consolidate();\n for (var i=0; i<input.length; ++i) {\n this._add(input[i]);\n }\n return this;\n};\n\nproto.remove = function(input) {\n if (!this._stream) {\n throw 'Aggregator not configured for streaming removes.' +\n ' Call stream(true) prior to calling summarize.';\n }\n for (var i=0; i<input.length; ++i) {\n this._rem(input[i]);\n }\n this._rems = true;\n return this;\n};\n\n// consolidate removals\nproto._consolidate = function() {\n if (!this._rems) return;\n for (var k in this._cells) {\n if (this._cells[k].collect) {\n this._cells[k].data.values();\n }\n }\n this._rems = false;\n};\n\nmodule.exports = Aggregator;",
"var util = require('../util');\nvar stats = require('../stats');\n\nvar REM = '__dl_rem__';\n\nfunction Collector(key) {\n this._add = [];\n this._rem = [];\n this._key = key || null;\n this._last = null;\n}\n\nvar proto = Collector.prototype;\n\nproto.add = function(v) {\n this._add.push(v);\n};\n\nproto.rem = function(v) {\n this._rem.push(v);\n};\n\nproto.values = function() {\n this._get = null;\n if (this._rem.length === 0) return this._add;\n\n var a = this._add,\n r = this._rem,\n k = this._key,\n x = Array(a.length - r.length),\n i, j, n, m;\n\n if (!util.isObject(r[0])) {\n // processing raw values\n m = stats.count.map(r);\n for (i=0, j=0, n=a.length; i<n; ++i) {\n if (m[a[i]] > 0) {\n m[a[i]] -= 1;\n } else {\n x[j++] = a[i];\n }\n }\n } else if (k) {\n // has unique key field, so use that\n m = util.toMap(r, k);\n for (i=0, j=0, n=a.length; i<n; ++i) {\n if (!m.hasOwnProperty(k(a[i]))) { x[j++] = a[i]; }\n }\n } else {\n // no unique key, mark tuples directly\n for (i=0, n=r.length; i<n; ++i) {\n r[i][REM] = 1;\n }\n for (i=0, j=0, n=a.length; i<n; ++i) {\n if (!a[i][REM]) { x[j++] = a[i]; }\n }\n for (i=0, n=r.length; i<n; ++i) {\n delete r[i][REM];\n }\n }\n\n this._rem = [];\n return (this._add = x);\n};\n\n// memoizing statistics methods\n\nproto.extent = function(get) {\n if (this._get !== get || !this._ext) {\n var v = this.values(),\n i = stats.extent.index(v, get);\n this._ext = [v[i[0]], v[i[1]]];\n this._get = get; \n }\n return this._ext;\n};\n\nproto.argmin = function(get) {\n return this.extent(get)[0];\n};\n\nproto.argmax = function(get) {\n return this.extent(get)[1];\n};\n\nproto.min = function(get) {\n var m = this.extent(get)[0];\n return m ? get(m) : +Infinity;\n};\n\nproto.max = function(get) {\n var m = this.extent(get)[1];\n return m ? get(m) : -Infinity;\n};\n\nproto.quartile = function(get) {\n if (this._get !== get || !this._q) {\n this._q = stats.quartile(this.values(), get);\n this._get = get; \n }\n return this._q;\n};\n\nproto.q1 = function(get) {\n return this.quartile(get)[0];\n};\n\nproto.q2 = function(get) {\n return this.quartile(get)[1];\n};\n\nproto.q3 = function(get) {\n return this.quartile(get)[2];\n};\n\nmodule.exports = Collector;\n",
"var util = require('../util');\nvar Aggregator = require('./aggregator');\n\nmodule.exports = function() {\n // flatten arguments into a single array\n var args = [].reduce.call(arguments, function(a, x) {\n return a.concat(util.array(x));\n }, []);\n // create and return an aggregator\n return new Aggregator()\n .groupby(args)\n .summarize({'*':'values'});\n};\n",
"var util = require('../util');\n\nvar types = {\n 'values': measure({\n name: 'values',\n init: 'cell.collect = true;',\n set: 'cell.data.values()', idx: -1\n }),\n 'count': measure({\n name: 'count',\n set: 'cell.num'\n }),\n 'missing': measure({\n name: 'missing',\n set: 'this.missing'\n }),\n 'valid': measure({\n name: 'valid',\n set: 'this.valid'\n }),\n 'sum': measure({\n name: 'sum',\n init: 'this.sum = 0;',\n add: 'this.sum += v;',\n rem: 'this.sum -= v;',\n set: 'this.sum'\n }),\n 'mean': measure({\n name: 'mean',\n init: 'this.mean = 0;',\n add: 'var d = v - this.mean; this.mean += d / this.valid;',\n rem: 'var d = v - this.mean; this.mean -= this.valid ? d / this.valid : this.mean;',\n set: 'this.mean'\n }),\n 'average': measure({\n name: 'average',\n set: 'this.mean',\n req: ['mean'], idx: 1\n }),\n 'variance': measure({\n name: 'variance',\n init: 'this.dev = 0;',\n add: 'this.dev += d * (v - this.mean);',\n rem: 'this.dev -= d * (v - this.mean);',\n set: 'this.valid > 1 ? this.dev / (this.valid-1) : 0',\n req: ['mean'], idx: 1\n }),\n 'variancep': measure({\n name: 'variancep',\n set: 'this.valid > 1 ? this.dev / this.valid : 0',\n req: ['variance'], idx: 2\n }),\n 'stdev': measure({\n name: 'stdev',\n set: 'this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : 0',\n req: ['variance'], idx: 2\n }),\n 'stdevp': measure({\n name: 'stdevp',\n set: 'this.valid > 1 ? Math.sqrt(this.dev / this.valid) : 0',\n req: ['variance'], idx: 2\n }),\n 'median': measure({\n name: 'median',\n set: 'cell.data.q2(this.get)',\n req: ['values'], idx: 3\n }),\n 'q1': measure({\n name: 'q1',\n set: 'cell.data.q1(this.get)',\n req: ['values'], idx: 3\n }),\n 'q3': measure({\n name: 'q3',\n set: 'cell.data.q3(this.get)',\n req: ['values'], idx: 3\n }),\n 'distinct': measure({\n name: 'distinct',\n set: 'this.distinct(cell.data.values(), this.get)',\n req: ['values'], idx: 3\n }),\n 'argmin': measure({\n name: 'argmin',\n add: 'if (v < this.min) this.argmin = t;',\n rem: 'if (v <= this.min) this.argmin = null;',\n set: 'this.argmin = this.argmin || cell.data.argmin(this.get)',\n req: ['min'], str: ['values'], idx: 3\n }),\n 'argmax': measure({\n name: 'argmax',\n add: 'if (v > this.max) this.argmax = t;',\n rem: 'if (v >= this.max) this.argmax = null;',\n set: 'this.argmax = this.argmax || cell.data.argmax(this.get)',\n req: ['max'], str: ['values'], idx: 3\n }),\n 'min': measure({\n name: 'min',\n init: 'this.min = +Infinity;',\n add: 'if (v < this.min) this.min = v;',\n rem: 'if (v <= this.min) this.min = NaN;',\n set: 'this.min = (isNaN(this.min) ? cell.data.min(this.get) : this.min)',\n str: ['values'], idx: 4\n }),\n 'max': measure({\n name: 'max',\n init: 'this.max = -Infinity;',\n add: 'if (v > this.max) this.max = v;',\n rem: 'if (v >= this.max) this.max = NaN;',\n set: 'this.max = (isNaN(this.max) ? cell.data.max(this.get) : this.max)',\n str: ['values'], idx: 4\n }),\n 'modeskew': measure({\n name: 'modeskew',\n set: 'this.dev===0 ? 0 : (this.mean - cell.data.q2(this.get)) / Math.sqrt(this.dev/(this.valid-1))',\n req: ['mean', 'stdev', 'median'], idx: 5\n })\n};\n\nfunction measure(base) {\n return function(out) {\n var m = util.extend({init:'', add:'', rem:'', idx:0}, base);\n m.out = out || base.name;\n return m;\n };\n}\n\nfunction resolve(agg, stream) {\n function collect(m, a) {\n function helper(r) { if (!m[r]) collect(m, m[r] = types[r]()); }\n if (a.req) a.req.forEach(helper);\n if (stream && a.str) a.str.forEach(helper);\n return m;\n }\n var map = agg.reduce(\n collect,\n agg.reduce(function(m, a) { return (m[a.name] = a, m); }, {})\n );\n return util.vals(map).sort(function(a, b) { return a.idx - b.idx; });\n}\n\nfunction create(agg, stream, accessor, mutator) {\n var all = resolve(agg, stream),\n ctr = 'this.cell = cell; this.tuple = t; this.valid = 0; this.missing = 0;',\n add = 'if (v==null) this.missing++; if (!this.isValid(v)) return; ++this.valid;',\n rem = 'if (v==null) this.missing--; if (!this.isValid(v)) return; --this.valid;',\n set = 'var t = this.tuple; var cell = this.cell;';\n\n all.forEach(function(a) {\n if (a.idx < 0) {\n ctr = a.init + ctr;\n add = a.add + add;\n rem = a.rem + rem;\n } else {\n ctr += a.init;\n add += a.add;\n rem += a.rem;\n }\n });\n agg.slice()\n .sort(function(a, b) { return a.idx - b.idx; })\n .forEach(function(a) {\n set += 'this.assign(t,\\''+a.out+'\\','+a.set+');';\n });\n set += 'return t;';\n\n /* jshint evil: true */\n ctr = Function('cell', 't', ctr);\n ctr.prototype.assign = mutator;\n ctr.prototype.add = Function('t', 'var v = this.get(t);' + add);\n ctr.prototype.rem = Function('t', 'var v = this.get(t);' + rem);\n ctr.prototype.set = Function(set);\n ctr.prototype.get = accessor;\n ctr.prototype.distinct = require('../stats').count.distinct;\n ctr.prototype.isValid = util.isValid;\n return ctr;\n}\n\ntypes.create = create;\nmodule.exports = types;",
"var util = require('../util');\nvar units = require('../time-units');\nvar EPSILON = 1e-15;\n\nfunction bins(opt) {\n if (!opt) { throw Error(\"Missing binning options.\"); }\n\n // determine range\n var maxb = opt.maxbins || 15,\n base = opt.base || 10,\n logb = Math.log(base),\n div = opt.div || [5, 2], \n min = opt.min,\n max = opt.max,\n span = max - min,\n step, level, minstep, precision, v, i, eps;\n\n if (opt.step) {\n // if step size is explicitly given, use that\n step = opt.step;\n } else if (opt.steps) {\n // if provided, limit choice to acceptable step sizes\n step = opt.steps[Math.min(\n opt.steps.length - 1,\n bisect(opt.steps, span/maxb, 0, opt.steps.length)\n )];\n } else {\n // else use span to determine step size\n level = Math.ceil(Math.log(maxb) / logb);\n minstep = opt.minstep || 0;\n step = Math.max(\n minstep,\n Math.pow(base, Math.round(Math.log(span) / logb) - level)\n );\n \n // increase step size if too many bins\n do { step *= base; } while (Math.ceil(span/step) > maxb);\n\n // decrease step size if allowed\n for (i=0; i<div.length; ++i) {\n v = step / div[i];\n if (v >= minstep && span / v <= maxb) step = v;\n }\n }\n\n // update precision, min and max\n v = Math.log(step);\n precision = v >= 0 ? 0 : ~~(-v / logb) + 1;\n eps = Math.pow(base, -precision - 1);\n min = Math.min(min, Math.floor(min / step + eps) * step);\n max = Math.ceil(max / step) * step;\n\n return {\n start: min,\n stop: max,\n step: step,\n unit: {precision: precision},\n value: value,\n index: index\n };\n}\n\nfunction bisect(a, x, lo, hi) {\n while (lo < hi) {\n var mid = lo + hi >>> 1;\n if (util.cmp(a[mid], x) < 0) { lo = mid + 1; }\n else { hi = mid; }\n }\n return lo;\n}\n\nfunction value(v) {\n return this.step * Math.floor(v / this.step + EPSILON);\n}\n\nfunction index(v) {\n return Math.floor((v - this.start) / this.step + EPSILON);\n}\n\nfunction date_value(v) {\n return this.unit.date(value.call(this, v));\n}\n\nfunction date_index(v) {\n return index.call(this, this.unit.unit(v));\n}\n\nbins.date = function(opt) {\n if (!opt) { throw Error(\"Missing date binning options.\"); }\n\n // find time step, then bin\n var dmin = opt.min,\n dmax = opt.max,\n maxb = opt.maxbins || 20,\n minb = opt.minbins || 4,\n span = (+dmax) - (+dmin),\n unit = opt.unit ? units[opt.unit] : units.find(span, minb, maxb),\n spec = bins({\n min: unit.min != null ? unit.min : unit.unit(dmin),\n max: unit.max != null ? unit.max : unit.unit(dmax),\n maxbins: maxb,\n minstep: unit.minstep,\n steps: unit.step\n });\n\n spec.unit = unit;\n spec.index = date_index;\n if (!opt.raw) spec.value = date_value;\n return spec;\n};\n\nmodule.exports = bins;\n",
"var stats = require('../stats');\nvar type = require('../import/type');\nvar util = require('../util');\nvar gen = require('../generate');\nvar bins = require('./bins');\n\nvar qtype = {\n 'integer': 1,\n 'number': 1,\n 'date': 1\n};\n\nfunction $bin(values, f, opt) {\n opt = options(values, f, opt);\n var b = spec(opt);\n return !b ? (opt.accessor || util.identity) :\n util.$func('bin', b.unit.unit ?\n function(x) { return b.value(b.unit.unit(x)); } :\n function(x) { return b.value(x); }\n )(opt.accessor);\n}\n\nfunction histogram(values, f, opt) {\n opt = options(values, f, opt);\n var b = spec(opt);\n return b ?\n numerical(values, opt.accessor, b) :\n categorical(values, opt.accessor, opt && opt.sort);\n}\n\nfunction spec(opt) {\n var t = opt.type, b = null;\n if (t == null || qtype[t]) {\n if (t === 'integer' && opt.minstep == null) opt.minstep = 1;\n b = (t === 'date') ? bins.date(opt) : bins(opt);\n }\n return b;\n}\n\nfunction options() {\n var a = arguments,\n i = 0,\n values = util.isArray(a[i]) ? a[i++] : null,\n f = util.isFunction(a[i]) || util.isString(a[i]) ? util.$(a[i++]) : null,\n opt = util.extend({}, a[i]);\n \n if (values) {\n opt.type = opt.type || type(values, f);\n if (qtype[opt.type]) {\n var ext = stats.extent(values, f);\n opt = util.extend({min: ext[0], max: ext[1]}, opt);\n }\n }\n if (f) { opt.accessor = f; }\n return opt;\n}\n\nfunction numerical(values, f, b) {\n var h = gen.range(b.start, b.stop + b.step/2, b.step)\n .map(function(v) { return {value: b.value(v), count: 0}; });\n\n for (var i=0, v, j; i<values.length; ++i) {\n v = f ? f(values[i]) : values[i];\n if (util.isValid(v)) {\n j = b.index(v);\n if (j < 0 || j >= h.length || !isFinite(j)) continue;\n h[j].count += 1;\n }\n }\n h.bins = b;\n return h;\n}\n\nfunction categorical(values, f, sort) {\n var u = stats.unique(values, f),\n c = stats.count.map(values, f);\n return u.map(function(k) { return {value: k, count: c[k]}; })\n .sort(util.comparator(sort ? '-count' : '+value'));\n}\n\nmodule.exports = {\n $bin: $bin,\n histogram: histogram\n};",
"var gen = module.exports = {};\n\ngen.repeat = function(val, n) {\n var a = Array(n), i;\n for (i=0; i<n; ++i) a[i] = val;\n return a;\n};\n\ngen.zeros = function(n) {\n return gen.repeat(0, n);\n};\n\ngen.range = function(start, stop, step) {\n if (arguments.length < 3) {\n step = 1;\n if (arguments.length < 2) {\n stop = start;\n start = 0;\n }\n }\n if ((stop - start) / step == Infinity) throw new Error('Infinite range');\n var range = [], i = -1, j;\n if (step < 0) while ((j = start + step * ++i) > stop) range.push(j);\n else while ((j = start + step * ++i) < stop) range.push(j);\n return range;\n};\n\ngen.random = {};\n\ngen.random.uniform = function(min, max) {\n if (max === undefined) {\n max = min === undefined ? 1 : min;\n min = 0;\n }\n var d = max - min;\n var f = function() {\n return min + d * Math.random();\n };\n f.samples = function(n) { return gen.zeros(n).map(f); };\n return f;\n};\n\ngen.random.integer = function(a, b) {\n if (b === undefined) {\n b = a;\n a = 0;\n }\n var d = b - a;\n var f = function() {\n return a + Math.floor(d * Math.random());\n };\n f.samples = function(n) { return gen.zeros(n).map(f); };\n return f;\n};\n\ngen.random.normal = function(mean, stdev) {\n mean = mean || 0;\n stdev = stdev || 1;\n var next;\n var f = function() {\n var x = 0, y = 0, rds, c;\n if (next !== undefined) {\n x = next;\n next = undefined;\n return x;\n }\n do {\n x = Math.random()*2-1;\n y = Math.random()*2-1;\n rds = x*x + y*y;\n } while (rds === 0 || rds > 1);\n c = Math.sqrt(-2*Math.log(rds)/rds); // Box-Muller transform\n next = mean + y*c*stdev;\n return mean + x*c*stdev;\n };\n f.samples = function(n) { return gen.zeros(n).map(f); };\n return f;\n};",
"var util = require('../../util');\nvar d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null);\n\nfunction dsv(data, format) {\n if (data) {\n var h = format.header;\n data = (h ? h.join(format.delimiter) + '\\n' : '') + data;\n }\n return d3.dsv(format.delimiter).parse(data);\n}\n\ndsv.delimiter = function(delim) {\n var fmt = {delimiter: delim};\n return function(data, format) {\n return dsv(data, format ? util.extend(format, fmt) : fmt);\n };\n};\n\nmodule.exports = dsv;",
"var dsv = require('./dsv');\n\nmodule.exports = {\n json: require('./json'),\n topojson: require('./topojson'),\n treejson: require('./treejson'),\n dsv: dsv,\n csv: dsv.delimiter(','),\n tsv: dsv.delimiter('\\t')\n};",
"var util = require('../../util');\n\nmodule.exports = function(data, format) {\n var d = util.isObject(data) && !util.isBuffer(data) ?\n data : JSON.parse(data);\n if (format && format.property) {\n d = util.accessor(format.property)(d);\n }\n return d;\n};\n",
"var json = require('./json');\n\nvar reader = function(data, format) {\n var topojson = reader.topojson;\n if (topojson == null) { throw Error('TopoJSON library not loaded.'); }\n\n var t = json(data, format), obj;\n\n if (format && format.feature) {\n if ((obj = t.objects[format.feature])) {\n return topojson.feature(t, obj).features;\n } else {\n throw Error('Invalid TopoJSON object: ' + format.feature);\n }\n } else if (format && format.mesh) {\n if ((obj = t.objects[format.mesh])) {\n return [topojson.mesh(t, t.objects[format.mesh])];\n } else {\n throw Error('Invalid TopoJSON object: ' + format.mesh);\n }\n } else {\n throw Error('Missing TopoJSON feature or mesh parameter.');\n }\n};\n\nreader.topojson = (typeof window !== \"undefined\" ? window.topojson : typeof global !== \"undefined\" ? global.topojson : null);\nmodule.exports = reader;",
"var json = require('./json');\n\nmodule.exports = function(data, format) {\n data = json(data, format);\n return toTable(data, (format && format.children));\n};\n\nfunction toTable(root, childrenField) {\n childrenField = childrenField || 'children';\n var table = [];\n \n function visit(node) {\n table.push(node);\n var children = node[childrenField];\n if (children) {\n for (var i=0; i<children.length; ++i) {\n visit(children[i], node);\n }\n }\n }\n \n visit(root, null);\n return (table.root = root, table);\n}",
"var util = require('../util');\n\n// Matches absolute URLs with optional protocol\n// https://... file://... //...\nvar protocol_re = /^([A-Za-z]+:)?\\/\\//;\n\n// Special treatment in node.js for the file: protocol\nvar fileProtocol = 'file://';\n\n// Validate and cleanup URL to ensure that it is allowed to be accessed\n// Returns cleaned up URL, or false if access is not allowed\nfunction sanitizeUrl(opt) {\n var url = opt.url;\n if (!url && opt.file) { return fileProtocol + opt.file; }\n\n // In case this is a relative url (has no host), prepend opt.baseURL\n if (opt.baseURL && !protocol_re.test(url)) {\n if (!util.startsWith(url, '/') && opt.baseURL[opt.baseURL.length-1] !== '/') {\n url = '/' + url; // Ensure that there is a slash between the baseURL (e.g. hostname) and url\n }\n url = opt.baseURL + url;\n }\n // relative protocol, starts with '//'\n if (util.isNode && util.startsWith(url, '//')) {\n url = (opt.defaultProtocol || 'http') + ':' + url;\n }\n // If opt.domainWhiteList is set, only allows url, whose hostname\n // * Is the same as the origin (window.location.hostname)\n // * Equals one of the values in the whitelist\n // * Is a proper subdomain of one of the values in the whitelist\n if (opt.domainWhiteList) {\n var domain, origin;\n if (util.isNode) {\n // relative protocol is broken: https://github.com/defunctzombie/node-url/issues/5\n var parts = require('url').parse(url);\n domain = parts.hostname;\n origin = null;\n } else {\n var a = document.createElement('a');\n a.href = url;\n // From http://stackoverflow.com/questions/736513/how-do-i-parse-a-url-into-hostname-and-path-in-javascript\n // IE doesn't populate all link properties when setting .href with a relative URL,\n // however .href will return an absolute URL which then can be used on itself\n // to populate these additional fields.\n if (a.host === '') {\n a.href = a.href;\n }\n domain = a.hostname.toLowerCase();\n origin = window.location.hostname;\n }\n\n if (origin !== domain) {\n var whiteListed = opt.domainWhiteList.some(function(d) {\n var idx = domain.length - d.length;\n return d === domain ||\n (idx > 1 && domain[idx-1] === '.' && domain.lastIndexOf(d) === idx);\n });\n if (!whiteListed) {\n throw 'URL is not whitelisted: ' + url;\n }\n }\n }\n return url;\n}\n\nfunction load(opt, callback) {\n var error = callback || function(e) { throw e; }, url;\n\n try {\n url = load.sanitizeUrl(opt); // enable override\n } catch (err) {\n error(err);\n return;\n }\n\n if (!url) {\n error('Invalid URL: ' + url);\n } else if (!util.isNode) {\n // in browser, use xhr\n return xhr(url, callback);\n } else if (util.startsWith(url, fileProtocol)) {\n // in node.js, if url starts with 'file://', strip it and load from file\n return file(url.slice(fileProtocol.length), callback);\n } else if (url.indexOf('://') < 0) { // TODO better protocol check?\n // if node.js, if no protocol assume file\n return file(url, callback);\n } else {\n // for regular URLs in node.js\n return http(url, callback);\n }\n}\n\nfunction xhrHasResponse(request) {\n var type = request.responseType;\n return type && type !== 'text' ?\n request.response : // null on error\n request.responseText; // '' on error\n}\n\nfunction xhr(url, callback) {\n var async = !!callback;\n var request = new XMLHttpRequest();\n // If IE does not support CORS, use XDomainRequest (copied from d3.xhr)\n if (this.XDomainRequest &&\n !('withCredentials' in request) &&\n /^(http(s)?:)?\\/\\//.test(url)) request = new XDomainRequest();\n\n function respond() {\n var status = request.status;\n if (!status && xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) {\n callback(null, request.responseText);\n } else {\n callback(request, null);\n }\n }\n\n if (async) {\n if ('onload' in request) {\n request.onload = request.onerror = respond;\n } else {\n request.onreadystatechange = function() {\n if (request.readyState > 3) respond();\n };\n }\n }\n \n request.open('GET', url, async);\n request.send();\n \n if (!async && xhrHasResponse(request)) {\n return request.responseText;\n }\n}\n\nfunction file(filename, callback) {\n var fs = require('fs');\n if (!callback) {\n return fs.readFileSync(filename, 'utf8');\n }\n require('fs').readFile(filename, callback);\n}\n\nfunction http(url, callback) {\n if (!callback) {\n return require('sync-request')('GET', url).getBody();\n }\n require('request')(url, function(error, response, body) {\n if (!error && response.statusCode === 200) {\n callback(null, body);\n } else {\n error = error ||\n 'Load failed with response code ' + response.statusCode + '.';\n callback(error, null);\n }\n });\n}\n\nload.sanitizeUrl = sanitizeUrl;\n\nmodule.exports = load;\n",
"var util = require('../util');\nvar type = require('./type');\nvar formats = require('./formats');\n\nfunction read(data, format) {\n var type = (format && format.type) || 'json';\n data = formats[type](data, format);\n if (format && format.parse) parse(data, format.parse);\n return data;\n}\n\nfunction parse(data, types) {\n var cols, parsers, d, i, j, clen, len = data.length;\n\n types = (types==='auto') ? type.inferAll(data) : util.duplicate(types);\n cols = util.keys(types);\n parsers = cols.map(function(c) { return type.parsers[types[c]]; });\n\n for (i=0, clen=cols.length; i<len; ++i) {\n d = data[i];\n for (j=0; j<clen; ++j) {\n d[cols[j]] = parsers[j](d[cols[j]]);\n }\n }\n type.annotation(data, types);\n}\n\nread.formats = formats;\nmodule.exports = read;\n",
"var util = require('../util');\nvar load = require('./load');\nvar read = require('./read');\n\nmodule.exports = util\n .keys(read.formats)\n .reduce(function(out, type) {\n out[type] = function(opt, format, callback) {\n // process arguments\n if (util.isString(opt)) { opt = {url: opt}; }\n if (arguments.length === 2 && util.isFunction(format)) {\n callback = format;\n format = undefined;\n }\n\n // set up read format\n format = util.extend({parse: 'auto'}, format);\n format.type = type;\n\n // load data\n var data = load(opt, callback ? function(error, data) {\n if (error) { callback(error, null); return; }\n try {\n // data loaded, now parse it (async)\n data = read(data, format);\n } catch (e) {\n callback(e, null);\n }\n callback(null, data);\n } : undefined);\n \n // data loaded, now parse it (sync)\n if (data) return read(data, format);\n };\n return out;\n }, {});\n",
"var util = require('../util');\n\nvar TYPES = '__types__';\n\nvar PARSERS = {\n boolean: util.boolean,\n integer: util.number,\n number: util.number,\n date: util.date,\n string: function(x) { return x==='' ? null : x; }\n};\n\nvar TESTS = {\n boolean: function(x) { return x==='true' || x==='false' || util.isBoolean(x); },\n integer: function(x) { return TESTS.number(x) && (x=+x) === ~~x; },\n number: function(x) { return !isNaN(+x) && !util.isDate(x); },\n date: function(x) { return !isNaN(Date.parse(x)); }\n};\n\nfunction annotation(data, types) {\n if (!types) return data && data[TYPES] || null;\n data[TYPES] = types;\n}\n\nfunction type(values, f) {\n f = util.$(f);\n var v, i, n;\n\n // if data array has type annotations, use them\n if (values[TYPES]) {\n v = f(values[TYPES]);\n if (util.isString(v)) return v;\n }\n\n for (i=0, n=values.length; !util.isValid(v) && i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n }\n\n return util.isDate(v) ? 'date' :\n util.isNumber(v) ? 'number' :\n util.isBoolean(v) ? 'boolean' :\n util.isString(v) ? 'string' : null;\n}\n\nfunction typeAll(data, fields) {\n if (!data.length) return;\n fields = fields || util.keys(data[0]);\n return fields.reduce(function(types, f) {\n return (types[f] = type(data, f), types);\n }, {});\n}\n\nfunction infer(values, f) {\n f = util.$(f);\n var i, j, v;\n\n // types to test for, in precedence order\n var types = ['boolean', 'integer', 'number', 'date'];\n\n for (i=0; i<values.length; ++i) {\n // get next value to test\n v = f ? f(values[i]) : values[i];\n // test value against remaining types\n for (j=0; j<types.length; ++j) {\n if (util.isValid(v) && !TESTS[types[j]](v)) {\n types.splice(j, 1);\n j -= 1;\n }\n }\n // if no types left, return 'string'\n if (types.length === 0) return 'string';\n }\n\n return types[0];\n}\n\nfunction inferAll(data, fields) {\n fields = fields || util.keys(data[0]);\n return fields.reduce(function(types, f) {\n types[f] = infer(data, f);\n return types;\n }, {});\n}\n\ntype.annotation = annotation;\ntype.all = typeAll;\ntype.infer = infer;\ntype.inferAll = inferAll;\ntype.parsers = PARSERS;\nmodule.exports = type;",
"var util = require('./util');\n\nvar dl = {\n load: require('./import/load'),\n read: require('./import/read'),\n type: require('./import/type'),\n bins: require('./bins/bins'),\n $bin: require('./bins/histogram').$bin,\n groupby: require('./aggregate/groupby'),\n histogram: require('./bins/histogram').histogram,\n print: require('./print'),\n template: require('./template'),\n timeunits: require('./time-units')\n};\n\nutil.extend(dl, util);\nutil.extend(dl, require('./generate'));\nutil.extend(dl, require('./stats'));\nutil.extend(dl, require('./import/readers'));\n\nmodule.exports = dl;",
"var util = require('./util');\nvar type = require('./import/type');\nvar stats = require('./stats');\nvar template = require('./template');\n\nvar FMT = {\n 'date': '|time:\"%m/%d/%Y %H:%M:%S\"',\n 'number': '|number:\".4f\"',\n 'integer': '|number:\"d\"'\n};\n\nvar POS = {\n 'number': 'left',\n 'integer': 'left'\n};\n\nmodule.exports.table = function(data, opt) {\n opt = util.extend({separator:' ', minwidth: 8, maxwidth: 15}, opt);\n var fields = opt.fields || util.keys(data[0]),\n types = type.all(data);\n\n if (opt.start || opt.limit) {\n var a = opt.start || 0,\n b = opt.limit ? a + opt.limit : data.length;\n data = data.slice(a, b);\n }\n\n // determine char width of fields\n var lens = fields.map(function(name) {\n var format = FMT[types[name]] || '',\n t = template('{{' + name + format + '}}'),\n l = stats.max(data, function(x) { return t(x).length; });\n l = Math.max(Math.min(name.length, opt.minwidth), l);\n return opt.maxwidth > 0 ? Math.min(l, opt.maxwidth) : l;\n });\n\n // print header row\n var head = fields.map(function(name, i) {\n return util.truncate(util.pad(name, lens[i], 'center'), lens[i]);\n }).join(opt.separator);\n\n // build template function for each row\n var tmpl = template(fields.map(function(name, i) {\n return '{{' +\n name +\n (FMT[types[name]] || '') +\n ('|pad:' + lens[i] + ',' + (POS[types[name]] || 'right')) +\n ('|truncate:' + lens[i]) +\n '}}';\n }).join(opt.separator));\n\n // print table\n return head + \"\\n\" + data.map(tmpl).join('\\n');\n};\n\nmodule.exports.summary = function(s) {\n s = s ? s.__summary__ ? s : stats.summary(s) : this;\n var str = [], i, n;\n for (i=0, n=s.length; i<n; ++i) {\n str.push('-- ' + s[i].field + ' --');\n if (s[i].type === 'string' || s[i].distinct < 10) {\n str.push(printCategoricalProfile(s[i]));\n } else {\n str.push(printQuantitativeProfile(s[i]));\n }\n str.push('');\n }\n return str.join('\\n');\n};\n\nfunction printQuantitativeProfile(p) {\n return [\n 'valid: ' + p.valid,\n 'missing: ' + p.missing,\n 'distinct: ' + p.distinct,\n 'min: ' + p.min,\n 'max: ' + p.max,\n 'median: ' + p.median,\n 'mean: ' + p.mean,\n 'stdev: ' + p.stdev,\n 'modeskew: ' + p.modeskew\n ].join('\\n');\n}\n\nfunction printCategoricalProfile(p) {\n var list = [\n 'valid: ' + p.valid,\n 'missing: ' + p.missing,\n 'distinct: ' + p.distinct,\n 'top values: '\n ];\n var u = p.unique;\n var top = util.keys(u)\n .sort(function(a,b) { return u[b] - u[a]; })\n .slice(0, 6)\n .map(function(v) { return ' \\'' + v + '\\' (' + u[v] + ')'; });\n return list.concat(top).join('\\n');\n}",
"var util = require('./util');\nvar type = require('./import/type');\nvar gen = require('./generate');\nvar stats = {};\n\n// Collect unique values.\n// Output: an array of unique values, in first-observed order\nstats.unique = function(values, f, results) {\n f = util.$(f);\n results = results || [];\n var u = {}, v, i, n;\n for (i=0, n=values.length; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (v in u) continue;\n u[v] = 1;\n results.push(v);\n }\n return results;\n};\n\n// Return the length of the input array.\nstats.count = function(values) {\n return values && values.length || 0;\n};\n\n// Count the number of non-null, non-undefined, non-NaN values.\nstats.count.valid = function(values, f) {\n f = util.$(f);\n var v, i, n, valid = 0;\n for (i=0, n=values.length; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (util.isValid(v)) valid += 1;\n }\n return valid;\n};\n\n// Count the number of null or undefined values.\nstats.count.missing = function(values, f) {\n f = util.$(f);\n var v, i, n, count = 0;\n for (i=0, n=values.length; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (v == null) count += 1;\n }\n return count;\n};\n\n// Count the number of distinct values.\n// Null, undefined and NaN are each considered distinct values.\nstats.count.distinct = function(values, f) {\n f = util.$(f);\n var u = {}, v, i, n, count = 0;\n for (i=0, n=values.length; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (v in u) continue;\n u[v] = 1;\n count += 1;\n }\n return count;\n};\n\n// Construct a map from distinct values to occurrence counts.\nstats.count.map = function(values, f) {\n f = util.$(f);\n var map = {}, v, i, n;\n for (i=0, n=values.length; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n map[v] = (v in map) ? map[v] + 1 : 1;\n }\n return map;\n};\n\n// Compute the median of an array of numbers.\nstats.median = function(values, f) {\n if (f) values = values.map(util.$(f));\n values = values.filter(util.isValid).sort(util.cmp);\n return stats.quantile(values, 0.5);\n};\n\n// Computes the quartile boundaries of an array of numbers.\nstats.quartile = function(values, f) {\n if (f) values = values.map(util.$(f));\n values = values.filter(util.isValid).sort(util.cmp);\n var q = stats.quantile;\n return [q(values, 0.25), q(values, 0.50), q(values, 0.75)];\n};\n\n// Compute the quantile of a sorted array of numbers.\n// Adapted from the D3.js implementation.\nstats.quantile = function(values, f, p) {\n if (p === undefined) { p = f; f = util.identity; }\n f = util.$(f);\n var H = (values.length - 1) * p + 1,\n h = Math.floor(H),\n v = +f(values[h - 1]),\n e = H - h;\n return e ? v + e * (f(values[h]) - v) : v;\n};\n\n// Compute the sum of an array of numbers.\nstats.sum = function(values, f) {\n f = util.$(f);\n for (var sum=0, i=0, n=values.length, v; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (util.isValid(v)) sum += v;\n }\n return sum;\n};\n\n// Compute the mean (average) of an array of numbers.\nstats.mean = function(values, f) {\n f = util.$(f);\n var mean = 0, delta, i, n, c, v;\n for (i=0, c=0, n=values.length; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (util.isValid(v)) {\n delta = v - mean;\n mean = mean + delta / (++c);\n }\n }\n return mean;\n};\n\n// Compute the sample variance of an array of numbers.\nstats.variance = function(values, f) {\n f = util.$(f);\n if (!util.isArray(values) || values.length < 2) return 0;\n var mean = 0, M2 = 0, delta, i, c, v;\n for (i=0, c=0; i<values.length; ++i) {\n v = f ? f(values[i]) : values[i];\n if (util.isValid(v)) {\n delta = v - mean;\n mean = mean + delta / (++c);\n M2 = M2 + delta * (v - mean);\n }\n }\n M2 = M2 / (c - 1);\n return M2;\n};\n\n// Compute the sample standard deviation of an array of numbers.\nstats.stdev = function(values, f) {\n return Math.sqrt(stats.variance(values, f));\n};\n\n// Compute the Pearson mode skewness ((median-mean)/stdev) of an array of numbers.\nstats.modeskew = function(values, f) {\n var avg = stats.mean(values, f),\n med = stats.median(values, f),\n std = stats.stdev(values, f);\n return std === 0 ? 0 : (avg - med) / std;\n};\n\n// Find the minimum value in an array.\nstats.min = function(values, f) {\n return stats.extent(values, f)[0];\n};\n\n// Find the maximum value in an array.\nstats.max = function(values, f) {\n return stats.extent(values, f)[1];\n};\n\n// Find the minimum and maximum of an array of values.\nstats.extent = function(values, f) {\n f = util.$(f);\n var a, b, v, i, n = values.length;\n for (i=0; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (util.isValid(v)) { a = b = v; break; }\n }\n for (; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (util.isValid(v)) {\n if (v < a) a = v;\n if (v > b) b = v;\n }\n }\n return [a, b];\n};\n\n// Find the integer indices of the minimum and maximum values.\nstats.extent.index = function(values, f) {\n f = util.$(f);\n var x = -1, y = -1, a, b, v, i, n = values.length;\n for (i=0; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (util.isValid(v)) { a = b = v; x = y = i; break; }\n }\n for (; i<n; ++i) {\n v = f ? f(values[i]) : values[i];\n if (util.isValid(v)) {\n if (v < a) { a = v; x = i; }\n if (v > b) { b = v; y = i; }\n }\n }\n return [x, y];\n};\n\n// Compute the dot product of two arrays of numbers.\nstats.dot = function(values, a, b) {\n var sum = 0, i, v;\n if (!b) {\n if (values.length !== a.length) {\n throw Error('Array lengths must match.');\n }\n for (i=0; i<values.length; ++i) {\n v = values[i] * a[i];\n if (v === v) sum += v;\n }\n } else {\n a = util.$(a);\n b = util.$(b);\n for (i=0; i<values.length; ++i) {\n v = a(values[i]) * b(values[i]);\n if (v === v) sum += v;\n }\n }\n return sum;\n};\n\n// Compute ascending rank scores for an array of values.\n// Ties are assigned their collective mean rank.\nstats.rank = function(values, f) {\n f = util.$(f) || util.identity;\n var a = values.map(function(v, i) {\n return {idx: i, val: f(v)};\n })\n .sort(util.comparator('val'));\n\n var n = values.length,\n r = Array(n),\n tie = -1, p = {}, i, v, mu;\n\n for (i=0; i<n; ++i) {\n v = a[i].val;\n if (tie < 0 && p === v) {\n tie = i - 1;\n } else if (tie > -1 && p !== v) {\n mu = 1 + (i-1 + tie) / 2;\n for (; tie<i; ++tie) r[a[tie].idx] = mu;\n tie = -1;\n }\n r[a[i].idx] = i + 1;\n p = v;\n }\n\n if (tie > -1) {\n mu = 1 + (n-1 + tie) / 2;\n for (; tie<n; ++tie) r[a[tie].idx] = mu;\n }\n\n return r;\n};\n\n// Compute the sample Pearson product-moment correlation of two arrays of numbers.\nstats.cor = function(values, a, b) {\n var fn = b;\n b = fn ? values.map(util.$(b)) : a;\n a = fn ? values.map(util.$(a)) : values;\n\n var dot = stats.dot(a, b),\n mua = stats.mean(a),\n mub = stats.mean(b),\n sda = stats.stdev(a),\n sdb = stats.stdev(b),\n n = values.length;\n\n return (dot - n*mua*mub) / ((n-1) * sda * sdb);\n};\n\n// Compute the Spearman rank correlation of two arrays of values.\nstats.cor.rank = function(values, a, b) {\n var ra = b ? stats.rank(values, util.$(a)) : stats.rank(values),\n rb = b ? stats.rank(values, util.$(b)) : stats.rank(a),\n n = values.length, i, s, d;\n\n for (i=0, s=0; i<n; ++i) {\n d = ra[i] - rb[i];\n s += d * d;\n }\n\n return 1 - 6*s / (n * (n*n-1));\n};\n\n// Compute the distance correlation of two arrays of numbers.\n// http://en.wikipedia.org/wiki/Distance_correlation\nstats.cor.dist = function(values, a, b) {\n var X = b ? values.map(util.$(a)) : values,\n Y = b ? values.map(util.$(b)) : a;\n\n var A = stats.dist.mat(X),\n B = stats.dist.mat(Y),\n n = A.length,\n i, aa, bb, ab;\n\n for (i=0, aa=0, bb=0, ab=0; i<n; ++i) {\n aa += A[i]*A[i];\n bb += B[i]*B[i];\n ab += A[i]*B[i];\n }\n\n return Math.sqrt(ab / Math.sqrt(aa*bb));\n};\n\n// Compute the vector distance between two arrays of numbers.\n// Default is Euclidean (exp=2) distance, configurable via exp argument.\nstats.dist = function(values, a, b, exp) {\n var f = util.isFunction(b) || util.isString(b),\n X = values,\n Y = f ? values : a,\n e = f ? exp : b,\n L2 = e === 2 || e == null,\n n = values.length, s = 0, d, i;\n if (f) {\n a = util.$(a);\n b = util.$(b);\n }\n for (i=0; i<n; ++i) {\n d = f ? (a(X[i])-b(Y[i])) : (X[i]-Y[i]);\n s += L2 ? d*d : Math.pow(Math.abs(d), e);\n }\n return L2 ? Math.sqrt(s) : Math.pow(s, 1/e);\n};\n\n// Construct a mean-centered distance matrix for an array of numbers.\nstats.dist.mat = function(X) {\n var n = X.length,\n m = n*n,\n A = Array(m),\n R = gen.zeros(n),\n M = 0, v, i, j;\n\n for (i=0; i<n; ++i) {\n A[i*n+i] = 0;\n for (j=i+1; j<n; ++j) {\n A[i*n+j] = (v = Math.abs(X[i] - X[j]));\n A[j*n+i] = v;\n R[i] += v;\n R[j] += v;\n }\n }\n\n for (i=0; i<n; ++i) {\n M += R[i];\n R[i] /= n;\n }\n M /= m;\n\n for (i=0; i<n; ++i) {\n for (j=i; j<n; ++j) {\n A[i*n+j] += M - R[i] - R[j];\n A[j*n+i] = A[i*n+j];\n }\n }\n\n return A;\n};\n\n// Compute the Shannon entropy (log base 2) of an array of counts.\nstats.entropy = function(counts, f) {\n f = util.$(f);\n var i, p, s = 0, H = 0, n = counts.length;\n for (i=0; i<n; ++i) {\n s += (f ? f(counts[i]) : counts[i]);\n }\n if (s === 0) return 0;\n for (i=0; i<n; ++i) {\n p = (f ? f(counts[i]) : counts[i]) / s;\n if (p) H += p * Math.log(p);\n }\n return -H / Math.LN2;\n};\n\n// Compute the mutual information between two discrete variables.\n// Returns an array of the form [MI, MI_distance] \n// MI_distance is defined as 1 - I(a,b) / H(a,b).\n// http://en.wikipedia.org/wiki/Mutual_information\nstats.mutual = function(values, a, b, counts) {\n var x = counts ? values.map(util.$(a)) : values,\n y = counts ? values.map(util.$(b)) : a,\n z = counts ? values.map(util.$(counts)) : b;\n\n var px = {},\n py = {},\n n = z.length,\n s = 0, I = 0, H = 0, p, t, i;\n\n for (i=0; i<n; ++i) {\n px[x[i]] = 0;\n py[y[i]] = 0;\n }\n\n for (i=0; i<n; ++i) {\n px[x[i]] += z[i];\n py[y[i]] += z[i];\n s += z[i];\n }\n\n t = 1 / (s * Math.LN2);\n for (i=0; i<n; ++i) {\n if (z[i] === 0) continue;\n p = (s * z[i]) / (px[x[i]] * py[y[i]]);\n I += z[i] * t * Math.log(p);\n H += z[i] * t * Math.log(z[i]/s);\n }\n\n return [I, 1 + I/H];\n};\n\n// Compute the mutual information between two discrete variables.\nstats.mutual.info = function(values, a, b, counts) {\n return stats.mutual(values, a, b, counts)[0];\n};\n\n// Compute the mutual information distance between two discrete variables.\n// MI_distance is defined as 1 - I(a,b) / H(a,b).\nstats.mutual.dist = function(values, a, b, counts) {\n return stats.mutual(values, a, b, counts)[1];\n};\n\n// Compute a profile of summary statistics for a variable.\nstats.profile = function(values, f) {\n var mean = 0,\n valid = 0,\n missing = 0,\n distinct = 0,\n min = null,\n max = null,\n M2 = 0,\n vals = [],\n u = {}, delta, sd, i, v, x;\n\n // compute summary stats\n for (i=0; i<values.length; ++i) {\n v = f ? f(values[i]) : values[i];\n\n // update unique values\n u[v] = (v in u) ? u[v] + 1 : (distinct += 1, 1);\n\n if (v == null) {\n ++missing;\n } else if (util.isValid(v)) {\n // update stats\n x = (typeof v === 'string') ? v.length : v;\n if (min===null || x < min) min = x;\n if (max===null || x > max) max = x;\n delta = x - mean;\n mean = mean + delta / (++valid);\n M2 = M2 + delta * (x - mean);\n vals.push(x);\n }\n }\n M2 = M2 / (valid - 1);\n sd = Math.sqrt(M2);\n\n // sort values for median and iqr\n vals.sort(util.cmp);\n\n return {\n type: type(values, f),\n unique: u,\n count: values.length,\n valid: valid,\n missing: missing,\n distinct: distinct,\n min: min,\n max: max,\n mean: mean,\n stdev: sd,\n median: (v = stats.quantile(vals, 0.5)),\n q1: stats.quantile(vals, 0.25),\n q3: stats.quantile(vals, 0.75),\n modeskew: sd === 0 ? 0 : (mean - v) / sd\n };\n};\n\n// Compute profiles for all variables in a data set.\nstats.summary = function(data, fields) {\n fields = fields || util.keys(data[0]);\n var s = fields.map(function(f) {\n var p = stats.profile(data, util.$(f));\n return (p.field = f, p);\n });\n return (s.__summary__ = true, s);\n};\n\nmodule.exports = stats;",
"var util = require('./util');\nvar d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null);\n\nvar context = {\n formats: [],\n format_map: {},\n truncate: util.truncate,\n pad: util.pad\n};\n\nfunction template(text) {\n var src = source(text, 'd');\n src = 'var __t; return ' + src + ';';\n\n /* jshint evil: true */\n return (new Function('d', src)).bind(context);\n}\n\ntemplate.source = source;\ntemplate.context = context;\nmodule.exports = template;\n\n// clear cache of format objects\n// can *break* prior template functions, so invoke with care\ntemplate.clearFormatCache = function() {\n context.formats = [];\n context.format_map = {};\n};\n\n// Generate source code for a template function.\n// text: the template text\n// variable: the name of the data object variable ('obj' by default)\n// properties: optional hash for collecting all accessed properties\nfunction source(text, variable, properties) {\n variable = variable || 'obj';\n var index = 0;\n var src = '\\'';\n var regex = template_re;\n\n // Compile the template source, escaping string literals appropriately.\n text.replace(regex, function(match, interpolate, offset) {\n src += text\n .slice(index, offset)\n .replace(template_escaper, template_escapeChar);\n index = offset + match.length;\n\n if (interpolate) {\n src += '\\'\\n+((__t=(' +\n template_var(interpolate, variable, properties) +\n '))==null?\\'\\':__t)+\\n\\'';\n }\n\n // Adobe VMs need the match returned to produce the correct offest.\n return match;\n });\n return src + '\\'';\n}\n\nfunction template_var(text, variable, properties) {\n var filters = text.split('|');\n var prop = filters.shift().trim();\n var stringCast = true;\n\n function strcall(fn) {\n fn = fn || '';\n if (stringCast) {\n stringCast = false;\n src = 'String(' + src + ')' + fn;\n } else {\n src += fn;\n }\n return src;\n }\n\n function date() {\n return '(typeof ' + src + '===\"number\"?new Date('+src+'):'+src+')';\n }\n\n if (properties) properties[prop] = 1;\n var src = util.field(prop).map(util.str).join('][');\n src = variable + '[' + src + ']';\n\n for (var i=0; i<filters.length; ++i) {\n var f = filters[i], args = null, pidx, a, b;\n\n if ((pidx=f.indexOf(':')) > 0) {\n f = f.slice(0, pidx);\n args = filters[i].slice(pidx+1).split(',')\n .map(function(s) { return s.trim(); });\n }\n f = f.trim();\n\n switch (f) {\n case 'length':\n strcall('.length');\n break;\n case 'lower':\n strcall('.toLowerCase()');\n break;\n case 'upper':\n strcall('.toUpperCase()');\n break;\n case 'lower-locale':\n strcall('.toLocaleLowerCase()');\n break;\n case 'upper-locale':\n strcall('.toLocaleUpperCase()');\n break;\n case 'trim':\n strcall('.trim()');\n break;\n case 'left':\n a = util.number(args[0]);\n strcall('.slice(0,' + a + ')');\n break;\n case 'right':\n a = util.number(args[0]);\n strcall('.slice(-' + a +')');\n break;\n case 'mid':\n a = util.number(args[0]);\n b = a + util.number(args[1]);\n strcall('.slice(+'+a+','+b+')');\n break;\n case 'slice':\n a = util.number(args[0]);\n strcall('.slice('+ a +\n (args.length > 1 ? ',' + util.number(args[1]) : '') +\n ')');\n break;\n case 'truncate':\n a = util.number(args[0]);\n b = args[1];\n b = (b!=='left' && b!=='middle' && b!=='center') ? 'right' : b;\n src = 'this.truncate(' + strcall() + ',' + a + ',\\'' + b + '\\')';\n break;\n case 'pad':\n a = util.number(args[0]);\n b = args[1];\n b = (b!=='left' && b!=='middle' && b!=='center') ? 'right' : b;\n src = 'this.pad(' + strcall() + ',' + a + ',\\'' + b + '\\')';\n break;\n case 'number':\n a = template_format(args[0], d3.format);\n stringCast = false;\n src = 'this.formats['+a+']('+src+')';\n break;\n case 'time':\n a = template_format(args[0], d3.time.format);\n stringCast = false;\n src = 'this.formats['+a+']('+date()+')';\n break;\n default:\n throw Error('Unrecognized template filter: ' + f);\n }\n }\n\n return src;\n}\n\nvar template_re = /\\{\\{(.+?)\\}\\}|$/g;\n\n// Certain characters need to be escaped so that they can be put into a\n// string literal.\nvar template_escapes = {\n '\\'': '\\'',\n '\\\\': '\\\\',\n '\\r': 'r',\n '\\n': 'n',\n '\\u2028': 'u2028',\n '\\u2029': 'u2029'\n};\n\nvar template_escaper = /\\\\|'|\\r|\\n|\\u2028|\\u2029/g;\n\nfunction template_escapeChar(match) {\n return '\\\\' + template_escapes[match];\n}\n\nfunction template_format(pattern, fmt) {\n if ((pattern[0] === '\\'' && pattern[pattern.length-1] === '\\'') ||\n (pattern[0] === '\"' && pattern[pattern.length-1] === '\"')) {\n pattern = pattern.slice(1, -1);\n } else {\n throw Error('Format pattern must be quoted: ' + pattern);\n }\n if (!context.format_map[pattern]) {\n var f = fmt(pattern);\n var i = context.formats.length;\n context.formats.push(f);\n context.format_map[pattern] = i;\n }\n return context.format_map[pattern];\n}\n",
"var STEPS = [\n [31536e6, 5], // 1-year\n [7776e6, 4], // 3-month\n [2592e6, 4], // 1-month\n [12096e5, 3], // 2-week\n [6048e5, 3], // 1-week\n [1728e5, 3], // 2-day\n [864e5, 3], // 1-day\n [432e5, 2], // 12-hour\n [216e5, 2], // 6-hour\n [108e5, 2], // 3-hour\n [36e5, 2], // 1-hour\n [18e5, 1], // 30-minute\n [9e5, 1], // 15-minute\n [3e5, 1], // 5-minute\n [6e4, 1], // 1-minute\n [3e4, 0], // 30-second\n [15e3, 0], // 15-second\n [5e3, 0], // 5-second\n [1e3, 0] // 1-second\n];\n\nfunction isNumber(d) { return typeof d === 'number'; }\n\nvar entries = [\n {\n type: 'second',\n minstep: 1,\n format: '%Y %b %-d %H:%M:%S.%L',\n date: function(d) {\n return new Date(d * 1e3);\n },\n unit: function(d) {\n return (+d / 1e3);\n }\n },\n {\n type: 'minute',\n minstep: 1,\n format: '%Y %b %-d %H:%M',\n date: function(d) {\n return new Date(d * 6e4);\n },\n unit: function(d) {\n return ~~(+d / 6e4);\n }\n },\n {\n type: 'hour',\n minstep: 1,\n format: '%Y %b %-d %H:00',\n date: function(d) {\n return new Date(d * 36e5);\n },\n unit: function(d) {\n return ~~(+d / 36e5);\n }\n },\n {\n type: 'day',\n minstep: 1,\n step: [1, 7],\n format: '%Y %b %-d',\n date: function(d) {\n return new Date(d * 864e5);\n },\n unit: function(d) {\n return ~~(+d / 864e5);\n }\n },\n {\n type: 'month',\n minstep: 1,\n step: [1, 3, 6],\n format: '%b %Y',\n date: function(d) {\n return new Date(Date.UTC(~~(d / 12), d % 12, 1));\n },\n unit: function(d) {\n if (isNumber(d)) d = new Date(d);\n return 12 * d.getUTCFullYear() + d.getUTCMonth();\n }\n },\n {\n type: 'year',\n minstep: 1,\n format: '%Y',\n date: function(d) {\n return new Date(Date.UTC(d, 0, 1));\n },\n unit: function(d) {\n return (isNumber(d) ? new Date(d) : d).getUTCFullYear();\n }\n }\n];\n\nvar minuteOfHour = {\n type: 'minuteOfHour',\n min: 0,\n max: 59,\n minstep: 1,\n format: '%M',\n date: function(d) {\n return new Date(Date.UTC(1970, 0, 1, 0, d));\n },\n unit: function(d) {\n return (isNumber(d) ? new Date(d) : d).getUTCMinutes();\n }\n};\n\nvar hourOfDay = {\n type: 'hourOfDay',\n min: 0,\n max: 23,\n minstep: 1,\n format: '%H',\n date: function(d) {\n return new Date(Date.UTC(1970, 0, 1, d));\n },\n unit: function(d) {\n return (isNumber(d) ? new Date(d) : d).getUTCHours();\n }\n};\n\nvar dayOfWeek = {\n type: 'dayOfWeek',\n min: 0,\n max: 6,\n step: [1],\n format: '%a',\n date: function(d) {\n return new Date(Date.UTC(1970, 0, 4 + d));\n },\n unit: function(d) {\n return (isNumber(d) ? new Date(d) : d).getUTCDay();\n }\n};\n\nvar dayOfMonth = {\n type: 'dayOfMonth',\n min: 1,\n max: 31,\n step: [1],\n format: '%-d',\n date: function(d) {\n return new Date(Date.UTC(1970, 0, d));\n },\n unit: function(d) {\n return (isNumber(d) ? new Date(d) : d).getUTCDate();\n }\n};\n\nvar monthOfYear = {\n type: 'monthOfYear',\n min: 0,\n max: 11,\n step: [1],\n format: '%b',\n date: function(d) {\n return new Date(Date.UTC(1970, d % 12, 1));\n },\n unit: function(d) {\n return (isNumber(d) ? new Date(d) : d).getUTCMonth();\n }\n};\n\nvar units = {\n 'second': entries[0],\n 'minute': entries[1],\n 'hour': entries[2],\n 'day': entries[3],\n 'month': entries[4],\n 'year': entries[5],\n 'minuteOfHour': minuteOfHour,\n 'hourOfDay': hourOfDay,\n 'dayOfWeek': dayOfWeek,\n 'dayOfMonth': dayOfMonth,\n 'monthOfYear': monthOfYear,\n 'timesteps': entries\n};\n\nunits.find = function(span, minb, maxb) {\n var i, len, bins, step = STEPS[0];\n\n for (i = 1, len = STEPS.length; i < len; ++i) {\n step = STEPS[i];\n if (span > step[0]) {\n bins = span / step[0];\n if (bins > maxb) {\n return entries[STEPS[i - 1][1]];\n }\n if (bins >= minb) {\n return entries[step[1]];\n }\n }\n }\n return entries[STEPS[STEPS.length - 1][1]];\n};\n\nmodule.exports = units;\n",
"var buffer = require('buffer');\nvar units = require('./time-units');\nvar u = module.exports = {};\n\n// where are we?\n\nu.isNode = typeof process !== 'undefined' &&\n typeof process.stderr !== 'undefined';\n\n// utility functions\n\nvar FNAME = '__name__';\n\nu.namedfunc = function(name, f) { return (f[FNAME] = name, f); };\n\nu.name = function(f) { return f==null ? null : f[FNAME]; };\n\nu.identity = function(x) { return x; };\n\nu.true = u.namedfunc('true', function() { return true; });\n\nu.false = u.namedfunc('false', function() { return false; });\n\nu.duplicate = function(obj) {\n return JSON.parse(JSON.stringify(obj));\n};\n\nu.equal = function(a, b) {\n return JSON.stringify(a) === JSON.stringify(b);\n};\n\nu.extend = function(obj) {\n for (var x, name, i=1, len=arguments.length; i<len; ++i) {\n x = arguments[i];\n for (name in x) { obj[name] = x[name]; }\n }\n return obj;\n};\n\nu.length = function(x) {\n return x != null && x.length != null ? x.length : null;\n};\n\nu.keys = function(x) {\n var keys = [], k;\n for (k in x) keys.push(k);\n return keys;\n};\n\nu.vals = function(x) {\n var vals = [], k;\n for (k in x) vals.push(x[k]);\n return vals;\n};\n\nu.toMap = function(list, f) {\n return (f = u.$(f)) ?\n list.reduce(function(obj, x) { return (obj[f(x)] = 1, obj); }, {}) :\n list.reduce(function(obj, x) { return (obj[x] = 1, obj); }, {});\n};\n\nu.keystr = function(values) {\n // use to ensure consistent key generation across modules\n var n = values.length;\n if (!n) return '';\n for (var s=String(values[0]), i=1; i<n; ++i) {\n s += '|' + String(values[i]);\n }\n return s;\n};\n\n// type checking functions\n\nvar toString = Object.prototype.toString;\n\nu.isObject = function(obj) {\n return obj === Object(obj);\n};\n\nu.isFunction = function(obj) {\n return toString.call(obj) === '[object Function]';\n};\n\nu.isString = function(obj) {\n return typeof value === 'string' || toString.call(obj) === '[object String]';\n};\n\nu.isArray = Array.isArray || function(obj) {\n return toString.call(obj) === '[object Array]';\n};\n\nu.isNumber = function(obj) {\n return typeof obj === 'number' || toString.call(obj) === '[object Number]';\n};\n\nu.isBoolean = function(obj) {\n return obj === true || obj === false || toString.call(obj) == '[object Boolean]';\n};\n\nu.isDate = function(obj) {\n return toString.call(obj) === '[object Date]';\n};\n\nu.isValid = function(obj) {\n return obj != null && obj === obj;\n};\n\nu.isBuffer = (buffer.Buffer && buffer.Buffer.isBuffer) || u.false;\n\n// type coercion functions\n\nu.number = function(s) {\n return s == null || s === '' ? null : +s;\n};\n\nu.boolean = function(s) {\n return s == null || s === '' ? null : s==='false' ? false : !!s;\n};\n\nu.date = function(s) {\n return s == null || s === '' ? null : Date.parse(s);\n};\n\nu.array = function(x) {\n return x != null ? (u.isArray(x) ? x : [x]) : [];\n};\n\nu.str = function(x) {\n return u.isArray(x) ? '[' + x.map(u.str) + ']'\n : u.isObject(x) ? JSON.stringify(x)\n : u.isString(x) ? ('\\''+util_escape_str(x)+'\\'') : x;\n};\n\nvar escape_str_re = /(^|[^\\\\])'/g;\n\nfunction util_escape_str(x) {\n return x.replace(escape_str_re, '$1\\\\\\'');\n}\n\n// data access functions\n\nu.field = function(f) {\n return String(f).split('\\\\.')\n .map(function(d) { return d.split('.'); })\n .reduce(function(a, b) {\n if (a.length) { a[a.length-1] += '.' + b.shift(); }\n a.push.apply(a, b);\n return a;\n }, []);\n};\n\nu.accessor = function(f) {\n var s;\n return f==null || u.isFunction(f) ? f :\n u.namedfunc(f, (s = u.field(f)).length > 1 ?\n function(x) { return s.reduce(function(x,f) { return x[f]; }, x); } :\n function(x) { return x[f]; }\n );\n};\n\nu.$ = u.accessor;\n\nu.mutator = function(f) {\n var s;\n return u.isString(f) && (s=u.field(f)).length > 1 ?\n function(x, v) {\n for (var i=0; i<s.length-1; ++i) x = x[s[i]];\n x[s[i]] = v;\n } :\n function(x, v) { x[f] = v; };\n};\n\nu.$func = function(name, op) {\n return function(f) {\n f = u.$(f) || u.identity;\n var n = name + (u.name(f) ? '_'+u.name(f) : '');\n return u.namedfunc(n, function(d) { return op(f(d)); });\n };\n};\n\nu.$valid = u.$func('valid', u.isValid);\nu.$length = u.$func('length', u.length);\nu.$year = u.$func('year', units.year.unit);\nu.$month = u.$func('month', units.monthOfYear.unit);\nu.$date = u.$func('date', units.dayOfMonth.unit);\nu.$day = u.$func('day', units.dayOfWeek.unit);\nu.$hour = u.$func('hour', units.hourOfDay.unit);\nu.$minute = u.$func('minute', units.minuteOfHour.unit);\n\nu.$in = function(f, values) {\n f = u.$(f);\n var map = u.isArray(values) ? u.toMap(values) : values;\n return function(d) { return !!map[f(d)]; };\n};\n\n// comparison / sorting functions\n\nu.comparator = function(sort) {\n var sign = [];\n if (sort === undefined) sort = [];\n sort = u.array(sort).map(function(f) {\n var s = 1;\n if (f[0] === '-') { s = -1; f = f.slice(1); }\n else if (f[0] === '+') { s = +1; f = f.slice(1); }\n sign.push(s);\n return u.accessor(f);\n });\n return function(a,b) {\n var i, n, f, x, y;\n for (i=0, n=sort.length; i<n; ++i) {\n f = sort[i]; x = f(a); y = f(b);\n if (x < y) return -1 * sign[i];\n if (x > y) return sign[i];\n }\n return 0;\n };\n};\n\nu.cmp = function(a, b) {\n if (a < b) {\n return -1;\n } else if (a > b) {\n return 1;\n } else if (a >= b) {\n return 0;\n } else if (a === null) {\n return -1;\n } else if (b === null) {\n return 1;\n }\n return NaN;\n};\n\nu.numcmp = function(a, b) { return a - b; };\n\nu.stablesort = function(array, sortBy, keyFn) {\n var indices = array.reduce(function(idx, v, i) {\n return (idx[keyFn(v)] = i, idx);\n }, {});\n\n array.sort(function(a, b) {\n var sa = sortBy(a),\n sb = sortBy(b);\n return sa < sb ? -1 : sa > sb ? 1\n : (indices[keyFn(a)] - indices[keyFn(b)]);\n });\n\n return array;\n};\n\n\n// string functions\n\n// ES6 compatibility per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith#Polyfill\n// We could have used the polyfill code, but lets wait until ES6 becomes a standard first\nu.startsWith = String.prototype.startsWith ?\n function(string, searchString) {\n return string.startsWith(searchString);\n } :\n function(string, searchString) {\n return string.lastIndexOf(searchString, 0) === 0;\n };\n\nu.pad = function(s, length, pos, padchar) {\n padchar = padchar || \" \";\n var d = length - s.length;\n if (d <= 0) return s;\n switch (pos) {\n case 'left':\n return strrep(d, padchar) + s;\n case 'middle':\n case 'center':\n return strrep(Math.floor(d/2), padchar) +\n s + strrep(Math.ceil(d/2), padchar);\n default:\n return s + strrep(d, padchar);\n }\n};\n\nfunction strrep(n, str) {\n var s = \"\", i;\n for (i=0; i<n; ++i) s += str;\n return s;\n}\n\nu.truncate = function(s, length, pos, word, ellipsis) {\n var len = s.length;\n if (len <= length) return s;\n ellipsis = ellipsis !== undefined ? String(ellipsis) : '\\u2026';\n var l = Math.max(0, length - ellipsis.length);\n\n switch (pos) {\n case 'left':\n return ellipsis + (word ? truncateOnWord(s,l,1) : s.slice(len-l));\n case 'middle':\n case 'center':\n var l1 = Math.ceil(l/2), l2 = Math.floor(l/2);\n return (word ? truncateOnWord(s,l1) : s.slice(0,l1)) +\n ellipsis + (word ? truncateOnWord(s,l2,1) : s.slice(len-l2));\n default:\n return (word ? truncateOnWord(s,l) : s.slice(0,l)) + ellipsis;\n }\n};\n\nfunction truncateOnWord(s, len, rev) {\n var cnt = 0, tok = s.split(truncate_word_re);\n if (rev) {\n s = (tok = tok.reverse())\n .filter(function(w) { cnt += w.length; return cnt <= len; })\n .reverse();\n } else {\n s = tok.filter(function(w) { cnt += w.length; return cnt <= len; });\n }\n return s.length ? s.join('').trim() : tok[0].slice(0, len);\n}\n\nvar truncate_word_re = /([\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u00A0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u2028\\u2029\\u3000\\uFEFF])/;\n",
"module.exports = require('./lib/heap');\n",
"// Generated by CoffeeScript 1.8.0\n(function() {\n var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;\n\n floor = Math.floor, min = Math.min;\n\n\n /*\n Default comparison function to be used\n */\n\n defaultCmp = function(x, y) {\n if (x < y) {\n return -1;\n }\n if (x > y) {\n return 1;\n }\n return 0;\n };\n\n\n /*\n Insert item x in list a, and keep it sorted assuming a is sorted.\n \n If x is already in a, insert it to the right of the rightmost x.\n \n Optional args lo (default 0) and hi (default a.length) bound the slice\n of a to be searched.\n */\n\n insort = function(a, x, lo, hi, cmp) {\n var mid;\n if (lo == null) {\n lo = 0;\n }\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (lo < 0) {\n throw new Error('lo must be non-negative');\n }\n if (hi == null) {\n hi = a.length;\n }\n while (lo < hi) {\n mid = floor((lo + hi) / 2);\n if (cmp(x, a[mid]) < 0) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n return ([].splice.apply(a, [lo, lo - lo].concat(x)), x);\n };\n\n\n /*\n Push item onto heap, maintaining the heap invariant.\n */\n\n heappush = function(array, item, cmp) {\n if (cmp == null) {\n cmp = defaultCmp;\n }\n array.push(item);\n return _siftdown(array, 0, array.length - 1, cmp);\n };\n\n\n /*\n Pop the smallest item off the heap, maintaining the heap invariant.\n */\n\n heappop = function(array, cmp) {\n var lastelt, returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n lastelt = array.pop();\n if (array.length) {\n returnitem = array[0];\n array[0] = lastelt;\n _siftup(array, 0, cmp);\n } else {\n returnitem = lastelt;\n }\n return returnitem;\n };\n\n\n /*\n Pop and return the current smallest value, and add the new item.\n \n This is more efficient than heappop() followed by heappush(), and can be\n more appropriate when using a fixed size heap. Note that the value\n returned may be larger than item! That constrains reasonable use of\n this routine unless written as part of a conditional replacement:\n if item > array[0]\n item = heapreplace(array, item)\n */\n\n heapreplace = function(array, item, cmp) {\n var returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n returnitem = array[0];\n array[0] = item;\n _siftup(array, 0, cmp);\n return returnitem;\n };\n\n\n /*\n Fast version of a heappush followed by a heappop.\n */\n\n heappushpop = function(array, item, cmp) {\n var _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (array.length && cmp(array[0], item) < 0) {\n _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];\n _siftup(array, 0, cmp);\n }\n return item;\n };\n\n\n /*\n Transform list into a heap, in-place, in O(array.length) time.\n */\n\n heapify = function(array, cmp) {\n var i, _i, _j, _len, _ref, _ref1, _results, _results1;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n _ref1 = (function() {\n _results1 = [];\n for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); }\n return _results1;\n }).apply(this).reverse();\n _results = [];\n for (_i = 0, _len = _ref1.length; _i < _len; _i++) {\n i = _ref1[_i];\n _results.push(_siftup(array, i, cmp));\n }\n return _results;\n };\n\n\n /*\n Update the position of the given item in the heap.\n This function should be called every time the item is being modified.\n */\n\n updateItem = function(array, item, cmp) {\n var pos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n pos = array.indexOf(item);\n if (pos === -1) {\n return;\n }\n _siftdown(array, 0, pos, cmp);\n return _siftup(array, pos, cmp);\n };\n\n\n /*\n Find the n largest elements in a dataset.\n */\n\n nlargest = function(array, n, cmp) {\n var elem, result, _i, _len, _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n result = array.slice(0, n);\n if (!result.length) {\n return result;\n }\n heapify(result, cmp);\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n heappushpop(result, elem, cmp);\n }\n return result.sort(cmp).reverse();\n };\n\n\n /*\n Find the n smallest elements in a dataset.\n */\n\n nsmallest = function(array, n, cmp) {\n var elem, i, los, result, _i, _j, _len, _ref, _ref1, _results;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (n * 10 <= array.length) {\n result = array.slice(0, n).sort(cmp);\n if (!result.length) {\n return result;\n }\n los = result[result.length - 1];\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n if (cmp(elem, los) < 0) {\n insort(result, elem, 0, null, cmp);\n result.pop();\n los = result[result.length - 1];\n }\n }\n return result;\n }\n heapify(array, cmp);\n _results = [];\n for (i = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {\n _results.push(heappop(array, cmp));\n }\n return _results;\n };\n\n _siftdown = function(array, startpos, pos, cmp) {\n var newitem, parent, parentpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n newitem = array[pos];\n while (pos > startpos) {\n parentpos = (pos - 1) >> 1;\n parent = array[parentpos];\n if (cmp(newitem, parent) < 0) {\n array[pos] = parent;\n pos = parentpos;\n continue;\n }\n break;\n }\n return array[pos] = newitem;\n };\n\n _siftup = function(array, pos, cmp) {\n var childpos, endpos, newitem, rightpos, startpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n endpos = array.length;\n startpos = pos;\n newitem = array[pos];\n childpos = 2 * pos + 1;\n while (childpos < endpos) {\n rightpos = childpos + 1;\n if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {\n childpos = rightpos;\n }\n array[pos] = array[childpos];\n pos = childpos;\n childpos = 2 * pos + 1;\n }\n array[pos] = newitem;\n return _siftdown(array, startpos, pos, cmp);\n };\n\n Heap = (function() {\n Heap.push = heappush;\n\n Heap.pop = heappop;\n\n Heap.replace = heapreplace;\n\n Heap.pushpop = heappushpop;\n\n Heap.heapify = heapify;\n\n Heap.updateItem = updateItem;\n\n Heap.nlargest = nlargest;\n\n Heap.nsmallest = nsmallest;\n\n function Heap(cmp) {\n this.cmp = cmp != null ? cmp : defaultCmp;\n this.nodes = [];\n }\n\n Heap.prototype.push = function(x) {\n return heappush(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pop = function() {\n return heappop(this.nodes, this.cmp);\n };\n\n Heap.prototype.peek = function() {\n return this.nodes[0];\n };\n\n Heap.prototype.contains = function(x) {\n return this.nodes.indexOf(x) !== -1;\n };\n\n Heap.prototype.replace = function(x) {\n return heapreplace(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pushpop = function(x) {\n return heappushpop(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.heapify = function() {\n return heapify(this.nodes, this.cmp);\n };\n\n Heap.prototype.updateItem = function(x) {\n return updateItem(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.clear = function() {\n return this.nodes = [];\n };\n\n Heap.prototype.empty = function() {\n return this.nodes.length === 0;\n };\n\n Heap.prototype.size = function() {\n return this.nodes.length;\n };\n\n Heap.prototype.clone = function() {\n var heap;\n heap = new Heap();\n heap.nodes = this.nodes.slice(0);\n return heap;\n };\n\n Heap.prototype.toArray = function() {\n return this.nodes.slice(0);\n };\n\n Heap.prototype.insert = Heap.prototype.push;\n\n Heap.prototype.top = Heap.prototype.peek;\n\n Heap.prototype.front = Heap.prototype.peek;\n\n Heap.prototype.has = Heap.prototype.contains;\n\n Heap.prototype.copy = Heap.prototype.clone;\n\n return Heap;\n\n })();\n\n (function(root, factory) {\n if (typeof define === 'function' && define.amd) {\n return define([], factory);\n } else if (typeof exports === 'object') {\n return module.exports = factory();\n } else {\n return root.Heap = factory();\n }\n })(this, function() {\n return Heap;\n });\n\n}).call(this);\n",
"var dl = require('datalib'),\n canvas = require('../render/canvas/index'),\n svg = require('../render/svg-headless/index'),\n View = require('./View'),\n debug = require('../util/debug');\n\nvar HeadlessView = function(width, height, model) {\n View.call(null, width, height, model);\n this._el = \"body\";\n this._type = \"canvas\";\n this._renderers = {canvas: canvas, svg: svg};\n this._canvas = null;\n}\n\nvar prototype = (HeadlessView.prototype = new View());\n\nprototype.renderer = function(type) {\n if(type) this._type = type;\n return View.prototype.renderer.apply(this, arguments);\n};\n\nprototype.canvas = function() {\n return this._canvas;\n};\n\nprototype.canvasAsync = function(callback) {\n var r = this._renderer, view = this;\n \n function wait() {\n if (r.pendingImages() === 0) {\n view.render(); // re-render with all images\n callback(view._canvas);\n } else {\n setTimeout(wait, 10);\n }\n }\n\n // if images loading, poll until ready\n (r.pendingImages() > 0) ? wait() : callback(this._canvas);\n};\n\nprototype.svg = function() {\n return (this._type === \"svg\")\n ? this._renderer.svg()\n : null;\n};\n\nprototype.initialize = function() { \n var w = this._width,\n h = this._height,\n pad = this._padding,\n bg = this._bgcolor;\n\n if (this._viewport) {\n w = this._viewport[0] - (pad ? pad.left + pad.right : 0);\n h = this._viewport[1] - (pad ? pad.top + pad.bottom : 0);\n }\n\n this._renderer = this._renderer || new this._io.Renderer();\n \n if (this._type === \"svg\") {\n this.initSVG(w, h, pad, bg);\n } else {\n this.initCanvas(w, h, pad, bg);\n }\n \n return this;\n};\n\nprototype.initCanvas = function(w, h, pad, bg) {\n var Canvas = (typeof window !== \"undefined\" ? window.canvas : typeof global !== \"undefined\" ? global.canvas : null),\n tw = w + (pad ? pad.left + pad.right : 0),\n th = h + (pad ? pad.top + pad.bottom : 0),\n canvas = this._canvas = dl.isNode ? new Canvas(tw, th) : document.createElement('canvas'),\n ctx = canvas.getContext(\"2d\");\n\n if(!dl.isNode) { // Manually set width/height on DOM elements\n canvas.setAttribute(\"width\", tw);\n canvas.setAttribute(\"height\", th);\n }\n \n // setup canvas context\n ctx.setTransform(1, 0, 0, 1, pad.left, pad.top);\n\n // configure renderer\n this._renderer.context(ctx);\n this._renderer.resize(w, h, pad);\n this._renderer.background(bg);\n};\n\nprototype.initSVG = function(w, h, pad, bg) {\n var tw = w + (pad ? pad.left + pad.right : 0),\n th = h + (pad ? pad.top + pad.bottom : 0);\n \n // configure renderer\n this._renderer.initialize(this._el, tw, th, pad, bg);\n};\n\nmodule.exports = HeadlessView;\n",
"var dl = require('datalib'),\n Graph = require('../dataflow/Graph'), \n Node = require('../dataflow/Node'),\n GroupBuilder = require('../scene/GroupBuilder'),\n changeset = require('../dataflow/changeset'),\n visit = require('../scene/visit');\n\nfunction Model() {\n this._defs = {};\n this._predicates = {};\n this._scene = null;\n\n this._node = null;\n this._builder = null; // Top-level scenegraph builder\n\n this._reset = {axes: false, legends: false};\n\n Graph.prototype.init.call(this);\n};\n\nvar proto = (Model.prototype = new Graph());\n\nproto.defs = function(defs) {\n if (!arguments.length) return this._defs;\n this._defs = defs;\n return this;\n};\n\nproto.width = function(width) {\n if (this._defs) this._defs.width = width;\n if (this._defs && this._defs.marks) this._defs.marks.width = width;\n if (this._scene) this._scene.items[0].width = width;\n this._reset.axes = true;\n return this;\n};\n\nproto.height = function(height) {\n if (this._defs) this._defs.height = height;\n if (this._defs && this._defs.marks) this._defs.marks.height = height;\n if (this._scene) this._scene.items[0].height = height;\n this._reset.axes = true;\n return this;\n};\n\nproto.node = function() {\n return this._node || (this._node = new Node(this));\n};\n\nproto.data = function() {\n var data = Graph.prototype.data.apply(this, arguments);\n if(arguments.length > 1) { // new Datasource\n this.node().addListener(data.pipeline()[0]);\n }\n\n return data;\n};\n\nfunction predicates(name) {\n var m = this, predicates = {};\n if(!dl.isArray(name)) return this._predicates[name];\n name.forEach(function(n) { predicates[n] = m._predicates[n] });\n return predicates;\n}\n\nproto.predicate = function(name, predicate) {\n if(arguments.length === 1) return predicates.call(this, name);\n return (this._predicates[name] = predicate);\n};\n\nproto.predicates = function() { return this._predicates; };\n\nproto.scene = function(renderer) {\n // Some form of user interaction has occured, so update scenegraph.\n if(this._scene && this._scene.updateScenegraph) this._scene.updateScenegraph();\n\n if(!arguments.length) return this._scene;\n if(this._builder) this.node().removeListener(this._builder.disconnect());\n this._builder = new GroupBuilder(this, this._defs.marks, this._scene={});\n this.node().addListener(this._builder.connect());\n var p = this._builder.pipeline();\n p[p.length-1].addListener(renderer);\n return this;\n};\n\nproto.reset = function() {\n if (this._scene && this._reset.axes) {\n visit(this._scene, function(item) {\n if (item.axes) item.axes.forEach(function(axis) { axis.reset(); });\n });\n this._reset.axes = false;\n }\n if (this._scene && this._reset.legends) {\n visit(this._scene, function(item) {\n if (item.legends) item.legends.forEach(function(l) { l.reset(); });\n });\n this._reset.legends = false;\n }\n return this;\n};\n\nproto.addListener = function(l) { this.node().addListener(l); };\nproto.removeListener = function(l) { this.node().removeListener(l); };\n\nproto.fire = function(cs) {\n if(!cs) cs = changeset.create();\n this.propagate(cs, this.node());\n};\n\nmodule.exports = Model;",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n dl = require('datalib'),\n Node = require('../dataflow/Node'),\n parseStreams = require('../parse/streams'),\n canvas = require('../render/canvas/index'),\n svg = require('../render/svg/index'),\n Encoder = require('../scene/Encoder'),\n Transition = require('../scene/Transition'),\n config = require('../util/config'),\n debug = require('../util/debug'),\n changeset = require('../dataflow/changeset');\n\nvar View = function(el, width, height, model) {\n this._el = null;\n this._model = null;\n this._width = this.__width = width || 500;\n this._height = this.__height = height || 300;\n this._bgcolor = null;\n this._autopad = 1;\n this._padding = {top:0, left:0, bottom:0, right:0};\n this._viewport = null;\n this._renderer = null;\n this._handler = null;\n this._streamer = null; // Targeted update for streaming changes\n this._changeset = null;\n this._renderers = {canvas: canvas, svg: svg};\n this._io = canvas;\n this._api = {}; // Stash streaming data API sandboxes.\n};\n\nvar prototype = View.prototype;\n\nprototype.model = function(model) {\n if (!arguments.length) return this._model;\n if (this._model !== model) {\n this._model = model;\n this._streamer = new Node(model);\n this._changeset = changeset.create();\n if (this._handler) this._handler.model(model);\n }\n return this;\n};\n\n// Sandboxed streaming data API\nfunction streaming(src) {\n var view = this,\n ds = this._model.data(src),\n listener = ds.pipeline()[0],\n streamer = this._streamer,\n cs = this._changeset,\n api = {};\n\n if(dl.keys(cs.signals).length > 0) {\n throw \"New signal values are not reflected in the visualization.\" +\n \" Please call view.update() before updating data values.\"\n }\n\n // If we have it stashed, don't create a new closure. \n if(this._api[src]) return this._api[src];\n\n api.insert = function(vals) {\n ds.insert(dl.duplicate(vals)); // Don't pollute the environment\n streamer.addListener(listener);\n cs.data[ds.name()] = 1;\n return api;\n };\n\n api.update = function() {\n streamer.addListener(listener);\n cs.data[ds.name()] = 1;\n return (ds.update.apply(ds, arguments), api);\n };\n\n api.remove = function() {\n streamer.addListener(listener);\n cs.data[ds.name()] = 1;\n return (ds.remove.apply(ds, arguments), api);\n };\n\n api.values = function() { return ds.values() }; \n\n return (this._api[src] = api);\n};\n\nprototype.data = function(data) {\n var v = this;\n if(!arguments.length) return v._model.dataValues();\n else if(dl.isString(data)) return streaming.call(v, data);\n else if(dl.isObject(data)) {\n dl.keys(data).forEach(function(k) {\n var api = streaming.call(v, k);\n data[k](api);\n });\n }\n return this;\n};\n\nprototype.signal = function(name, value) {\n var m = this._model,\n cs = this._changeset,\n streamer = this._streamer,\n setter = name; \n\n if(!arguments.length) return m.signalValues();\n else if(arguments.length == 1 && dl.isString(name)) return m.signalValues(name);\n\n if(dl.keys(cs.data).length > 0) {\n throw \"New data values are not reflected in the visualization.\" +\n \" Please call view.update() before updating signal values.\"\n }\n\n if(arguments.length == 2) {\n setter = {};\n setter[name] = value;\n }\n\n dl.keys(setter).forEach(function(k) {\n streamer.addListener(m.signal(k).value(setter[k]));\n cs.signals[k] = 1;\n cs.reflow = true;\n });\n\n return this;\n};\n\nprototype.width = function(width) {\n if (!arguments.length) return this.__width;\n if (this.__width !== width) {\n this._width = this.__width = width;\n this.initialize();\n if (this._strict) this._autopad = 1;\n }\n return this;\n};\n\nprototype.height = function(height) {\n if (!arguments.length) return this.__height;\n if (this.__height !== height) {\n this._height = this.__height = height;\n this.initialize();\n if (this._strict) this._autopad = 1;\n }\n return this;\n};\n\nprototype.background = function(bgcolor) {\n if (!arguments.length) return this._bgcolor;\n if (this._bgcolor !== bgcolor) {\n this._bgcolor = bgcolor;\n this.initialize();\n }\n return this;\n};\n\nprototype.padding = function(pad) {\n if (!arguments.length) return this._padding;\n if (this._padding !== pad) {\n if (dl.isString(pad)) {\n this._autopad = 1;\n this._padding = {top:0, left:0, bottom:0, right:0};\n this._strict = (pad === \"strict\");\n } else {\n this._autopad = 0;\n this._padding = pad;\n this._strict = false;\n }\n if (this._el) {\n this._renderer.resize(this._width, this._height, pad);\n if(this._handler) this._handler.padding(pad);\n }\n }\n return this;\n};\n\nprototype.autopad = function(opt) {\n if (this._autopad < 1) return this;\n else this._autopad = 0;\n\n var pad = this._padding,\n b = this.model().scene().bounds,\n inset = config.autopadInset,\n l = b.x1 < 0 ? Math.ceil(-b.x1) + inset : 0,\n t = b.y1 < 0 ? Math.ceil(-b.y1) + inset : 0,\n r = b.x2 > this._width ? Math.ceil(+b.x2 - this._width) + inset : 0,\n b = b.y2 > this._height ? Math.ceil(+b.y2 - this._height) + inset : 0;\n pad = {left:l, top:t, right:r, bottom:b};\n\n if (this._strict) {\n this._autopad = 0;\n this._padding = pad;\n this._width = Math.max(0, this.__width - (l+r));\n this._height = Math.max(0, this.__height - (t+b));\n\n this._model.width(this._width)\n .height(this._height).reset();\n\n this.initialize()\n .update({props:\"enter\"}).update({props:\"update\"});\n } else {\n this.padding(pad).update(opt);\n }\n return this;\n};\n\nprototype.viewport = function(size) {\n if (!arguments.length) return this._viewport;\n if (this._viewport !== size) {\n this._viewport = size;\n this.initialize();\n }\n return this;\n};\n\nprototype.renderer = function(type) {\n if (!arguments.length) return this._renderer;\n if (this._renderers[type]) type = this._renderers[type];\n else if (dl.isString(type)) throw new Error(\"Unknown renderer: \" + type);\n else if (!type) throw new Error(\"No renderer specified\");\n\n if (this._io !== type) {\n this._io = type;\n this._renderer = null;\n this.initialize();\n if (this._build) this.render();\n }\n return this;\n};\n\nprototype.initialize = function(el) {\n var v = this, prevHandler,\n w = v._width, h = v._height, pad = v._padding, bg = v._bgcolor;\n\n if (!arguments.length || el === null) {\n el = this._el ? this._el.parentNode : null;\n if(!el) return this; // This View cannot init w/o an\n }\n \n // clear pre-existing container\n d3.select(el).select(\"div.vega\").remove();\n \n // add div container\n this._el = el = d3.select(el)\n .append(\"div\")\n .attr(\"class\", \"vega\")\n .style(\"position\", \"relative\")\n .node();\n if (v._viewport) {\n d3.select(el)\n .style(\"width\", (v._viewport[0] || w)+\"px\")\n .style(\"height\", (v._viewport[1] || h)+\"px\")\n .style(\"overflow\", \"auto\");\n }\n\n // renderer\n v._renderer = (v._renderer || new this._io.Renderer())\n .initialize(el, w, h, pad, bg);\n \n // input handler\n prevHandler = v._handler;\n v._handler = new this._io.Handler()\n .initialize(el, pad, v)\n .model(v._model);\n\n if (prevHandler) {\n prevHandler.handlers().forEach(function(h) {\n v._handler.on(h.type, h.handler);\n });\n } else {\n // Register event listeners for signal stream definitions.\n parseStreams(this);\n }\n \n return this;\n};\n\nfunction build() {\n var v = this;\n v._renderNode = new Node(v._model)\n .router(true);\n\n v._renderNode.evaluate = function(input) {\n debug(input, [\"rendering\"]);\n\n var s = v._model.scene();\n if(input.trans) {\n input.trans.start(function(items) { v._renderer.render(s, items); });\n } else {\n v._renderer.render(s);\n }\n\n // For all updated datasources, finalize their changesets.\n var d, ds;\n for(d in input.data) {\n ds = v._model.data(d);\n if(!ds.revises()) continue;\n changeset.finalize(ds.last());\n }\n\n return input;\n };\n\n return (v._model.scene(v._renderNode), true); \n}\n\nprototype.update = function(opt) { \n opt = opt || {};\n var v = this,\n trans = opt.duration\n ? new Transition(opt.duration, opt.ease)\n : null;\n\n var cs = v._changeset;\n if(trans) cs.trans = trans;\n if(opt.props !== undefined) {\n if(dl.keys(cs.data).length > 0) {\n throw \"New data values are not reflected in the visualization.\" +\n \" Please call view.update() before updating a specified property set.\"\n }\n\n cs.reflow = true;\n cs.request = opt.props;\n }\n\n v._build = v._build || build.call(this);\n\n // If specific items are specified, short-circuit dataflow graph.\n // Else-If there are streaming updates, perform a targeted propagation.\n // Otherwise, reevaluate the entire model (datasources + scene).\n if(opt.items) { \n Encoder.update(this._model, opt.trans, opt.props, opt.items);\n v._renderNode.evaluate(cs);\n } else if(v._streamer.listeners().length) {\n v._model.propagate(cs, v._streamer);\n v._streamer.disconnect();\n } else {\n v._model.fire(cs);\n }\n\n v._changeset = changeset.create();\n\n return v.autopad(opt);\n};\n\nprototype.render = function(items) {\n this._renderer.render(this._model.scene(), items);\n return this;\n};\n\nprototype.on = function() {\n this._handler.on.apply(this._handler, arguments);\n return this;\n};\n\nprototype.onSignal = function(name, handler) {\n this._model.signal(name).on(handler);\n return this;\n};\n\nprototype.off = function() {\n this._handler.off.apply(this._handler, arguments);\n return this;\n};\n\nprototype.offSignal = function(name, handler) {\n this._model.signal(name).off(handler);\n return this;\n};\n\nView.factory = function(model) {\n var HeadlessView = require('./HeadlessView');\n return function(opt) {\n opt = opt || {};\n var defs = model.defs();\n var v = (opt.el ? new View() : new HeadlessView())\n .model(model)\n .renderer(opt.renderer || \"canvas\")\n .width(defs.width)\n .height(defs.height)\n .background(defs.background)\n .padding(defs.padding);\n\n if(opt.el || (!opt.el && v instanceof HeadlessView)) v.initialize(opt.el);\n if(opt.data) v.data(opt.data);\n \n return v;\n }; \n};\n\nmodule.exports = View;\n",
"var Node = require('./Node'),\n changeset = require('./changeset'),\n debug = require('../util/debug'),\n C = require('../util/constants');\n\nfunction Collector(graph) {\n Node.prototype.init.call(this, graph);\n this._data = [];\n return this.router(true)\n .collector(true);\n}\n\nvar proto = (Collector.prototype = new Node());\n\nproto.data = function() { return this._data; }\n\nproto.evaluate = function(input) {\n debug(input, [\"collecting\"]);\n\n if (input.reflow) {\n input = changeset.create(input);\n input.mod = this._data.slice();\n return input;\n }\n\n if (input.rem.length) {\n var ids = input.rem.reduce(function(m,x) { return (m[x._id]=1, m); }, {});\n this._data = this._data.filter(function(x) { return ids[x._id] !== 1; });\n }\n\n if (input.add.length) {\n this._data = this._data.length ? this._data.concat(input.add) : input.add;\n }\n\n if (input.sort) {\n this._data.sort(input.sort);\n }\n\n return input;\n};\n\nmodule.exports = Collector;",
"var dl = require('datalib'),\n changeset = require('./changeset'), \n tuple = require('./tuple'), \n Node = require('./Node'),\n Collector = require('./Collector'),\n debug = require('../util/debug'),\n C = require('../util/constants');\n\nfunction Datasource(graph, name, facet) {\n this._graph = graph;\n this._name = name;\n this._data = [];\n this._source = null;\n this._facet = facet;\n this._input = changeset.create();\n this._output = null; // Output changeset\n\n this._pipeline = null; // Pipeline of transformations.\n this._collector = null; // Collector to materialize output of pipeline\n this._revises = false; // Does any pipeline operator need to track prev?\n};\n\nvar proto = Datasource.prototype;\n\nproto.name = function(name) {\n if(!arguments.length) return this._name;\n return (this._name = name, this);\n};\n\nproto.source = function(src) {\n if(!arguments.length) return this._source;\n return (this._source = this._graph.data(src));\n};\n\nproto.insert = function(d) {\n var prev = this._revises ? null : undefined;\n\n this._input.add = this._input.add\n .concat(dl.array(d).map(function(d) { return tuple.ingest(d, prev); }));\n return this;\n};\n\nproto.remove = function(where) {\n var d = this._data.filter(where);\n this._input.rem = this._input.rem.concat(d);\n return this;\n};\n\nproto.update = function(where, field, func) {\n var mod = this._input.mod,\n ids = tuple.idMap(mod),\n prev = this._revises ? null : undefined; \n\n this._input.fields[field] = 1;\n this._data.filter(where).forEach(function(x) {\n var prev = x[field],\n next = func(x);\n if (prev !== next) {\n tuple.set(x, field, next);\n if(ids[x._id] !== 1) {\n mod.push(x);\n ids[x._id] = 1;\n }\n }\n });\n return this;\n};\n\nproto.values = function(data) {\n if(!arguments.length)\n return this._collector ? this._collector.data() : this._data;\n\n // Replace backing data\n this._input.rem = this._data.slice();\n if (data) { this.insert(data); }\n return this;\n};\n\nfunction set_prev(d) { if(d._prev === undefined) d._prev = C.SENTINEL; }\n\nproto.revises = function(p) {\n if(!arguments.length) return this._revises;\n\n // If we've not needed prev in the past, but a new dataflow node needs it now\n // ensure existing tuples have prev set.\n if(!this._revises && p) {\n this._data.forEach(set_prev);\n this._input.add.forEach(set_prev); // New tuples that haven't yet been merged into _data\n }\n\n this._revises = this._revises || p;\n return this;\n};\n\nproto.last = function() { return this._output; };\n\nproto.fire = function(input) {\n if(input) this._input = input;\n this._graph.propagate(this._input, this._pipeline[0]);\n return this;\n};\n\nproto.pipeline = function(pipeline) {\n var ds = this, n, c;\n if(!arguments.length) return this._pipeline;\n\n if(pipeline.length) {\n // If we have a pipeline, add a collector to the end to materialize\n // the output.\n ds._collector = new Collector(this._graph);\n pipeline.push(ds._collector);\n ds._revises = pipeline.some(function(p) { return p.revises(); });\n }\n\n // Input node applies the datasource's delta, and propagates it to \n // the rest of the pipeline. It receives touches to reflow data.\n var input = new Node(this._graph)\n .router(true)\n .collector(true);\n\n input.evaluate = function(input) {\n debug(input, [\"input\", ds._name]);\n\n var delta = ds._input, \n out = changeset.create(input),\n rem;\n\n // Delta might contain fields updated through API\n dl.keys(delta.fields).forEach(function(f) { out.fields[f] = 1 });\n\n if(input.reflow) {\n out.mod = ds._data.slice();\n } else {\n // update data\n if(delta.rem.length) {\n rem = tuple.idMap(delta.rem);\n ds._data = ds._data\n .filter(function(x) { return rem[x._id] !== 1 });\n }\n\n if(delta.add.length) ds._data = ds._data.concat(delta.add);\n\n // reset change list\n ds._input = changeset.create();\n\n out.add = delta.add; \n out.mod = delta.mod;\n out.rem = delta.rem;\n }\n\n return (out.facet = ds._facet, out);\n };\n\n pipeline.unshift(input);\n\n // Output node captures the last changeset seen by this datasource\n // (needed for joins and builds) and materializes any nested data.\n // If this datasource is faceted, materializes the values in the facet.\n var output = new Node(this._graph)\n .router(true)\n .collector(true);\n\n output.evaluate = function(input) {\n debug(input, [\"output\", ds._name]);\n var output = changeset.create(input, true);\n\n if(ds._facet) {\n ds._facet.values = ds.values();\n input.facet = null;\n }\n\n ds._output = input;\n output.data[ds._name] = 1;\n return output;\n };\n\n pipeline.push(output);\n\n this._pipeline = pipeline;\n this._graph.connect(ds._pipeline);\n return this;\n};\n\nproto.listener = function() { \n var l = new Node(this._graph).router(true),\n dest = this,\n prev = this._revises ? null : undefined;\n\n l.evaluate = function(input) {\n dest._srcMap = dest._srcMap || {}; // to propagate tuples correctly\n var map = dest._srcMap,\n output = changeset.create(input);\n\n output.add = input.add.map(function(t) {\n return (map[t._id] = tuple.derive(t, t._prev !== undefined ? t._prev : prev));\n });\n output.mod = input.mod.map(function(t) { return map[t._id]; });\n output.rem = input.rem.map(function(t) { \n var o = map[t._id];\n map[t._id] = null;\n return o;\n });\n\n return (dest._input = output);\n };\n\n l.addListener(this._pipeline[0]);\n return l;\n};\n\nproto.addListener = function(l) {\n if(l instanceof Datasource) {\n if(this._collector) this._collector.addListener(l.listener());\n else this._pipeline[0].addListener(l.listener());\n } else {\n this._pipeline[this._pipeline.length-1].addListener(l); \n }\n\n return this;\n};\n\nproto.removeListener = function(l) {\n this._pipeline[this._pipeline.length-1].removeListener(l);\n};\n\nproto.listeners = function(ds) {\n return ds \n ? this._collector ? this._collector.listeners() : this._pipeline[0].listeners()\n : this._pipeline[this._pipeline.length-1].listeners();\n};\n\nmodule.exports = Datasource;",
"var dl = require('datalib'),\n Heap = require('heap'),\n Datasource = require('./Datasource'),\n Signal = require('./Signal'),\n changeset = require('./changeset'),\n debug = require('../util/debug'),\n C = require('../util/constants');\n\nfunction Graph() {\n}\n\nvar proto = Graph.prototype;\n\nproto.init = function() {\n this._stamp = 0;\n this._rank = 0;\n\n this._data = {};\n this._signals = {};\n\n this.doNotPropagate = {};\n};\n\nproto.data = function(name, pipeline, facet) {\n var db = this._data;\n if(!arguments.length) return dl.keys(db).map(function(d) { return db[d]; });\n if(arguments.length === 1) return db[name];\n return (db[name] = new Datasource(this, name, facet).pipeline(pipeline));\n};\n\nproto.dataValues = function(names) {\n var graph = this;\n if (!arguments.length) names = dl.keys(this._data);\n if (!dl.isArray(names)) return this._data[names].values();\n return names.reduce(function(db, n) {\n return (db[n] = graph._data[n].values(), db);\n }, {});\n};\n\nfunction signal(name) {\n var m = this, i, len;\n if(!dl.isArray(name)) return this._signals[name];\n return name.map(function(n) { m._signals[n]; });\n}\n\nproto.signal = function(name, init) {\n var m = this;\n if(arguments.length === 1) return signal.call(this, name);\n return (this._signals[name] = new Signal(this, name, init));\n};\n\nproto.signalValues = function(names) {\n var graph = this;\n if(!arguments.length) names = dl.keys(this._signals);\n if(!dl.isArray(names)) return this._signals[names].value();\n return names.reduce(function(sg, n) {\n return (sg[n] = graph._signals[n].value(), sg);\n }, {});\n};\n\nproto.signalRef = function(ref) {\n if(!dl.isArray(ref)) ref = dl.field(ref);\n var value = this.signal(ref.shift()).value();\n if(ref.length > 0) {\n var fn = Function(\"s\", \"return s[\"+ref.map(dl.str).join(\"][\")+\"]\");\n value = fn.call(null, value);\n }\n\n return value;\n};\n\nvar schedule = function(a, b) {\n // If the nodes are equal, propagate the non-reflow pulse first,\n // so that we can ignore subsequent reflow pulses. \n if(a.rank == b.rank) return a.pulse.reflow ? 1 : -1;\n else return a.rank - b.rank; \n};\n\nproto.propagate = function(pulse, node) {\n var v, l, n, p, r, i, len, reflowed;\n\n // new PQ with each propagation cycle so that we can pulse branches\n // of the dataflow graph during a propagation (e.g., when creating\n // a new inline datasource).\n var pq = new Heap(schedule); \n\n if(pulse.stamp) throw \"Pulse already has a non-zero stamp\"\n\n pulse.stamp = ++this._stamp;\n pq.push({ node: node, pulse: pulse, rank: node.rank() });\n\n while (pq.size() > 0) {\n v = pq.pop(), n = v.node, p = v.pulse, r = v.rank, l = n._listeners;\n reflowed = p.reflow && n.last() >= p.stamp;\n\n if(reflowed) continue; // Don't needlessly reflow ops.\n\n // A node's rank might change during a propagation (e.g. instantiating\n // a group's dataflow branch). Re-queue if it has. T\n // TODO: use pq.replace or pq.poppush?\n if(r != n.rank()) {\n debug(p, ['Rank mismatch', r, n.rank()]);\n pq.push({ node: n, pulse: p, rank: n.rank() });\n continue;\n }\n\n p = this.evaluate(p, n);\n\n // Even if we didn't run the node, we still want to propagate \n // the pulse. \n if (p !== this.doNotPropagate) {\n for (i = 0, len = l.length; i < len; i++) {\n pq.push({ node: l[i], pulse: p, rank: l[i]._rank });\n }\n }\n }\n};\n\n// Connect a branch of dataflow nodes. \n// Dependencies get wired to the nearest collector. \nfunction forEachNode(branch, fn) {\n var node, collector, i, len;\n for(i=0, len=branch.length; i<len; ++i) {\n node = branch[i];\n if(node.collector()) collector = node;\n fn(node, collector, i);\n }\n}\n\nproto.connect = function(branch) {\n debug({}, ['connecting']);\n var graph = this;\n forEachNode(branch, function(n, c, i) {\n var data = n.dependency(C.DATA),\n signals = n.dependency(C.SIGNALS);\n\n if(data.length > 0) {\n data.forEach(function(d) { \n graph.data(d)\n .revises(n.revises())\n .addListener(c);\n });\n }\n\n if(signals.length > 0) {\n signals.forEach(function(s) { graph.signal(s).addListener(c); });\n }\n\n if(i > 0) {\n branch[i-1].addListener(branch[i]);\n }\n });\n\n return branch;\n};\n\nproto.disconnect = function(branch) {\n debug({}, ['disconnecting']);\n var graph = this;\n\n forEachNode(branch, function(n, c, i) {\n var data = n.dependency(C.DATA),\n signals = n.dependency(C.SIGNALS);\n\n if(data.length > 0) {\n data.forEach(function(d) { graph.data(d).removeListener(c); });\n }\n\n if(signals.length > 0) {\n signals.forEach(function(s) { graph.signal(s).removeListener(c) });\n }\n\n n.disconnect(); \n });\n\n return branch;\n};\n\nproto.reevaluate = function(pulse, node) {\n var reflowed = !pulse.reflow || (pulse.reflow && node.last() >= pulse.stamp),\n run = !!pulse.add.length || !!pulse.rem.length || node.router();\n run = run || !reflowed;\n return run || node.reevaluate(pulse);\n};\n\nproto.evaluate = function(pulse, node) {\n if(!this.reevaluate(pulse, node)) return pulse;\n pulse = node.evaluate(pulse);\n node.last(pulse.stamp);\n return pulse\n};\n\nmodule.exports = Graph;",
"var dl = require('datalib'),\n C = require('../util/constants'),\n REEVAL = [C.DATA, C.FIELDS, C.SCALES, C.SIGNALS];\n\nvar node_id = 1;\n\nfunction Node(graph) {\n if(graph) this.init(graph);\n return this;\n}\n\nvar proto = Node.prototype;\n\nproto.init = function(graph) {\n this._id = node_id++;\n this._graph = graph;\n this._rank = ++graph._rank; // For topologial sort\n this._stamp = 0; // Last stamp seen\n\n this._listeners = [];\n this._registered = {}; // To prevent duplicate listeners\n\n this._deps = {\n data: [],\n fields: [],\n scales: [],\n signals: [],\n };\n\n this._isRouter = false; // Responsible for propagating tuples, cannot ever be skipped\n this._isCollector = false; // Holds a materialized dataset, pulse to reflow\n this._revises = false; // Does the operator require tuples' previous values? \n return this;\n};\n\nproto.rank = function() { return this._rank; };\n\nproto.last = function(stamp) { \n if(!arguments.length) return this._stamp;\n this._stamp = stamp;\n return this;\n};\n\nproto.dependency = function(type, deps) {\n var d = this._deps[type];\n if(arguments.length === 1) return d;\n if(deps === null) { // Clear dependencies of a certain type\n while(d.length > 0) d.pop();\n } else {\n if(!dl.isArray(deps) && d.indexOf(deps) < 0) d.push(deps);\n else d.push.apply(d, dl.array(deps));\n }\n return this;\n};\n\nproto.router = function(bool) {\n if(!arguments.length) return this._isRouter;\n this._isRouter = !!bool\n return this;\n};\n\nproto.collector = function(bool) {\n if(!arguments.length) return this._isCollector;\n this._isCollector = !!bool;\n return this;\n};\n\nproto.revises = function(bool) {\n if(!arguments.length) return this._revises;\n this._revises = !!bool;\n return this;\n};\n\nproto.listeners = function() {\n return this._listeners;\n};\n\nproto.addListener = function(l) {\n if(!(l instanceof Node)) throw \"Listener is not a Node\";\n if(this._registered[l._id]) return this;\n\n this._listeners.push(l);\n this._registered[l._id] = 1;\n if(this._rank > l._rank) {\n var q = [l];\n while(q.length) {\n var cur = q.splice(0,1)[0];\n cur._rank = ++this._graph._rank;\n q.push.apply(q, cur._listeners);\n }\n }\n\n return this;\n};\n\nproto.removeListener = function (l) {\n var foundSending = false;\n for (var i = 0, len = this._listeners.length; i < len && !foundSending; i++) {\n if (this._listeners[i] === l) {\n this._listeners.splice(i, 1);\n this._registered[l._id] = null;\n foundSending = true;\n }\n }\n \n return foundSending;\n};\n\nproto.disconnect = function() {\n this._listeners = [];\n this._registered = {};\n};\n\nproto.evaluate = function(pulse) { return pulse; }\n\nproto.reevaluate = function(pulse) {\n var node = this, reeval = false;\n return REEVAL.some(function(prop) {\n reeval = reeval || node._deps[prop].some(function(k) { return !!pulse[prop][k] });\n return reeval;\n });\n\n return this;\n};\n\nmodule.exports = Node;",
"var Node = require('./Node'),\n changeset = require('./changeset');\n\nfunction Signal(graph, name, init) {\n Node.prototype.init.call(this, graph);\n this._name = name;\n this._value = init;\n this._handlers = [];\n return this;\n};\n\nvar proto = (Signal.prototype = new Node());\n\nproto.name = function() { return this._name; };\n\nproto.value = function(val) {\n if(!arguments.length) return this._value;\n this._value = val;\n return this;\n};\n\nproto.evaluate = function(input) {\n return input.signals[this._name] ? input : this._graph.doNotPropagate;\n};\n\nproto.fire = function(cs) {\n if(!cs) cs = changeset.create(null, true);\n cs.signals[this._name] = 1;\n this._graph.propagate(cs, this);\n};\n\nproto.on = function(handler) {\n var sg = this,\n node = new Node(this._graph);\n\n node.evaluate = function(input) {\n return (handler(sg.name(), sg.value()), input);\n };\n\n this._handlers.push({ handler: handler, node: node });\n return this.addListener(node);\n};\n\nproto.off = function(handler) {\n var sg = this, h = this._handlers;\n for(var i=h.length; --i>=0;) {\n if(!handler || h[i].handler === handler) {\n sg.removeListener(h.splice(i, 1)[0].node);\n }\n }\n return this;\n};\n\nmodule.exports = Signal;",
"var C = require('../util/constants');\nvar REEVAL = [C.DATA, C.FIELDS, C.SCALES, C.SIGNALS];\n\nfunction create(cs, reflow) {\n var out = {};\n copy(cs, out);\n\n out.add = [];\n out.mod = [];\n out.rem = [];\n\n out.reflow = reflow;\n\n return out;\n}\n\nfunction reset_prev(x) {\n x._prev = (x._prev === undefined) ? undefined : C.SENTINEL;\n}\n\nfunction finalize(cs) {\n for(i=0, len=cs.add.length; i<len; ++i) reset_prev(cs.add[i]);\n for(i=0, len=cs.mod.length; i<len; ++i) reset_prev(cs.mod[i]);\n}\n\nfunction copy(a, b) {\n b.stamp = a ? a.stamp : 0;\n b.sort = a ? a.sort : null;\n b.facet = a ? a.facet : null;\n b.trans = a ? a.trans : null;\n b.request = a ? a.request : null;\n REEVAL.forEach(function(d) { b[d] = a ? a[d] : {}; });\n}\n\nmodule.exports = {\n create: create,\n copy: copy,\n finalize: finalize,\n};",
"var dl = require('datalib'),\n C = require('../util/constants'),\n tuple_id = 1;\n\n// Object.create is expensive. So, when ingesting, trust that the\n// datum is an object that has been appropriately sandboxed from \n// the outside environment. \nfunction ingest(datum, prev) {\n datum = dl.isObject(datum) ? datum : {data: datum};\n datum._id = tuple_id++;\n datum._prev = (prev !== undefined) ? (prev || C.SENTINEL) : undefined;\n return datum;\n}\n\nfunction derive(datum, prev) {\n return ingest(Object.create(datum), prev);\n}\n\n// WARNING: operators should only call this once per timestamp!\nfunction set(t, k, v) {\n var prev = t[k];\n if(prev === v) return;\n set_prev(t, k);\n t[k] = v;\n}\n\nfunction set_prev(t, k) {\n if(t._prev === undefined) return;\n t._prev = (t._prev === C.SENTINEL) ? {} : t._prev;\n t._prev[k] = t[k];\n}\n\nfunction has_prev(t) {\n return t._prev && t._prev !== C.SENTINEL;\n}\n\nfunction reset() { tuple_id = 1; }\n\nfunction idMap(a) {\n return a.reduce(function(m,x) {\n return (m[x._id] = 1, m);\n }, {});\n};\n\nmodule.exports = {\n ingest: ingest,\n derive: derive,\n set: set,\n set_prev: set_prev,\n has_prev: has_prev,\n reset: reset,\n idMap: idMap\n};",
"var dl = require('datalib');\n\nmodule.exports = function(opt) {\n opt = opt || {};\n var constants = opt.constants || require('./constants');\n var functions = (opt.functions || require('./functions'))(codegen);\n var idWhiteList = opt.idWhiteList ? dl.toMap(opt.idWhiteList) : null;\n var idBlackList = opt.idBlackList ? dl.toMap(opt.idBlackList) : null;\n var memberDepth = 0;\n\n // TODO generalize?\n var DATUM = 'd';\n var SIGNAL_PREFIX = 'sg.';\n var signals = {};\n var fields = {};\n\n function codegen_wrap(ast) { \n var retval = {\n fn: codegen(ast),\n signals: dl.keys(signals),\n fields: dl.keys(fields)\n };\n signals = {};\n fields = {};\n return retval;\n }\n\n function codegen(ast) {\n if (ast instanceof String) return ast;\n var generator = CODEGEN_TYPES[ast.type];\n if (generator == null) {\n throw new Error(\"Unsupported type: \" + ast.type);\n }\n return generator(ast);\n }\n\n var CODEGEN_TYPES = {\n \"Literal\": function(n) {\n return n.raw;\n },\n \"Identifier\": function(n) {\n var id = n.name;\n if (memberDepth > 0) {\n return id;\n }\n if (constants.hasOwnProperty(id)) {\n return constants[id];\n }\n if (idWhiteList) {\n if (idWhiteList.hasOwnProperty(id)) {\n return id;\n } else {\n signals[id] = 1;\n return SIGNAL_PREFIX + id; // HACKish...\n }\n }\n if (idBlackList && idBlackList.hasOwnProperty(id)) {\n throw new Error(\"Illegal identifier: \" + id);\n }\n return id;\n },\n \"Program\": function(n) {\n return n.body.map(codegen).join(\"\\n\");\n },\n \"MemberExpression\": function(n) {\n var d = !n.computed;\n var o = codegen(n.object);\n if (d) memberDepth += 1;\n var p = codegen(n.property);\n if (o === DATUM) { fields[p] = 1; } // HACKish...\n if (d) memberDepth -= 1;\n return o + (d ? \".\"+p : \"[\"+p+\"]\");\n },\n \"CallExpression\": function(n) {\n if (n.callee.type !== \"Identifier\") {\n throw new Error(\"Illegal callee type: \" + n.callee.type);\n }\n var callee = n.callee.name;\n var args = n.arguments;\n var fn = functions.hasOwnProperty(callee) && functions[callee];\n if (!fn) throw new Error(\"Unrecognized function: \" + callee);\n return fn instanceof Function\n ? fn(args)\n : fn + \"(\" + args.map(codegen).join(\",\") + \")\";\n },\n \"ArrayExpression\": function(n) {\n return \"[\" + n.elements.map(codegen).join(\",\") + \"]\";\n },\n \"BinaryExpression\": function(n) {\n return \"(\" + codegen(n.left) + n.operator + codegen(n.right) + \")\";\n },\n \"UnaryExpression\": function(n) {\n return \"(\" + n.operator + codegen(n.argument) + \")\";\n },\n \"UpdateExpression\": function(n) {\n return \"(\" + (prefix\n ? n.operator + codegen(n.argument)\n : codegen(n.argument) + n.operator\n ) + \")\";\n },\n \"ConditionalExpression\": function(n) {\n return \"(\" + codegen(n.test)\n + \"?\" + codegen(n.consequent)\n + \":\" + codegen(n.alternate)\n + \")\";\n },\n \"LogicalExpression\": function(n) {\n return \"(\" + codegen(n.left) + n.operator + codegen(n.right) + \")\";\n },\n \"ObjectExpression\": function(n) {\n return \"{\" + n.properties.map(codegen).join(\",\") + \"}\";\n },\n \"Property\": function(n) {\n memberDepth += 1;\n var k = codegen(n.key);\n memberDepth -= 1;\n return k + \":\" + codegen(n.value);\n },\n \"ExpressionStatement\": function(n) {\n return codegen(n.expression);\n }\n };\n \n return codegen_wrap;\n};",
"module.exports = {\n \"NaN\": \"NaN\",\n \"E\": \"Math.E\",\n \"LN2\": \"Math.LN2\",\n \"LN10\": \"Math.LN10\",\n \"LOG2E\": \"Math.LOG2E\",\n \"LOG10E\": \"Math.LOG10E\",\n \"PI\": \"Math.PI\",\n \"SQRT1_2\": \"Math.SQRT1_2\",\n \"SQRT2\": \"Math.SQRT2\"\n};",
"var datalib = require('datalib');\n\nmodule.exports = function(codegen) {\n\n function fncall(name, args, cast, type) {\n var obj = codegen(args[0]);\n if (cast) {\n obj = cast + \"(\" + obj + \")\";\n if (dl.startsWith(cast, \"new \")) obj = \"(\" + obj + \")\";\n }\n return obj + \".\" + name + (type < 0 ? \"\" : type === 0\n ? \"()\"\n : \"(\" + args.slice(1).map(codegen).join(\",\") + \")\");\n }\n \n var DATE = \"new Date\";\n var STRING = \"String\";\n var REGEXP = \"RegExp\";\n\n return {\n // MATH functions\n \"isNaN\": \"isNaN\",\n \"isFinite\": \"isFinite\",\n \"abs\": \"Math.abs\",\n \"acos\": \"Math.acos\",\n \"asin\": \"Math.asin\",\n \"atan\": \"Math.atan\",\n \"atan2\": \"Math.atan2\",\n \"ceil\": \"Math.ceil\",\n \"cos\": \"Math.cos\",\n \"exp\": \"Math.exp\",\n \"floor\": \"Math.floor\",\n \"log\": \"Math.log\",\n \"max\": \"Math.max\",\n \"min\": \"Math.min\",\n \"pow\": \"Math.pow\",\n \"random\": \"Math.random\",\n \"round\": \"Math.round\",\n \"sin\": \"Math.sin\",\n \"sqrt\": \"Math.sqrt\",\n \"tan\": \"Math.tan\",\n\n // DATE functions\n \"now\": \"Date.now\",\n \"datetime\": \"new Date\",\n \"date\": function(args) {\n return fncall(\"getDate\", args, DATE, 0);\n },\n \"day\": function(args) {\n return fncall(\"getDay\", args, DATE, 0);\n },\n \"year\": function(args) {\n return fncall(\"getFullYear\", args, DATE, 0);\n },\n \"month\": function(args) {\n return fncall(\"getMonth\", args, DATE, 0);\n },\n \"hours\": function(args) {\n return fncall(\"getHours\", args, DATE, 0);\n },\n \"minutes\": function(args) {\n return fncall(\"getMinutes\", args, DATE, 0);\n },\n \"seconds\": function(args) {\n return fncall(\"getSeconds\", args, DATE, 0);\n },\n \"milliseconds\": function(args) {\n return fncall(\"getMilliseconds\", args, DATE, 0);\n },\n \"time\": function(args) {\n return fncall(\"getTime\", args, DATE, 0);\n },\n \"timezoneoffset\": function(args) {\n return fncall(\"getTimezoneOffset\", args, DATE, 0);\n },\n \"utcdate\": function(args) {\n return fncall(\"getUTCDate\", args, DATE, 0);\n },\n \"utcday\": function(args) {\n return fncall(\"getUTCDay\", args, DATE, 0);\n },\n \"utcyear\": function(args) {\n return fncall(\"getUTCFullYear\", args, DATE, 0);\n },\n \"utcmonth\": function(args) {\n return fncall(\"getUTCMonth\", args, DATE, 0);\n },\n \"utchours\": function(args) {\n return fncall(\"getUTCHours\", args, DATE, 0);\n },\n \"utcminutes\": function(args) {\n return fncall(\"getUTCMinutes\", args, DATE, 0);\n },\n \"utcseconds\": function(args) {\n return fncall(\"getUTCSeconds\", args, DATE, 0);\n },\n \"utcmilliseconds\": function(args) {\n return fncall(\"getUTCMilliseconds\", args, DATE, 0);\n },\n\n // shared sequence functions\n \"length\": function(args) {\n return fncall(\"length\", args, null, -1);\n },\n \"indexof\": function(args) {\n return fncall(\"indexOf\", args, null);\n },\n \"lastindexof\": function(args) {\n return fncall(\"lastIndexOf\", args, null);\n },\n\n // STRING functions\n \"parseFloat\": \"parseFloat\",\n \"parseInt\": \"parseInt\",\n \"upper\": function(args) {\n return fncall(\"toUpperCase\", args, STRING, 0);\n },\n \"lower\": function(args) {\n return fncall(\"toLowerCase\", args, STRING, 0);\n },\n \"slice\": function(args) {\n return fncall(\"slice\", args, STRING);\n },\n \"substring\": function(args) {\n return fncall(\"substring\", args, STRING);\n },\n\n // REGEXP functions\n \"test\": function(args) {\n return fncall(\"test\", args, REGEXP);\n },\n \n // Control Flow functions\n \"if\": function(args) {\n if (args.length < 3)\n throw new Error(\"Missing arguments to if function.\");\n if (args.length > 3)\n throw new Error(\"Too many arguments to if function.\");\n var a = args.map(codegen);\n return a[0]+\"?\"+a[1]+\":\"+a[2];\n }\n };\n};",
"var parser = require('./parser'),\n codegen = require('./codegen');\n \nmodule.exports = {\n parse: function(input, opt) { return parser.parse(\"(\"+input+\")\", opt); },\n code: function(opt) { return codegen(opt); }\n};\n",
"/*\n The following expression parser is based on Esprima (http://esprima.org/).\n Original header comment and license for Esprima is included here:\n\n Copyright (C) 2013 Ariya Hidayat <[email protected]>\n Copyright (C) 2013 Thaddee Tyl <[email protected]>\n Copyright (C) 2013 Mathias Bynens <[email protected]>\n Copyright (C) 2012 Ariya Hidayat <[email protected]>\n Copyright (C) 2012 Mathias Bynens <[email protected]>\n Copyright (C) 2012 Joost-Wim Boekesteijn <[email protected]>\n Copyright (C) 2012 Kris Kowal <[email protected]>\n Copyright (C) 2012 Yusuke Suzuki <[email protected]>\n Copyright (C) 2012 Arpad Borsos <[email protected]>\n Copyright (C) 2011 Ariya Hidayat <[email protected]>\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\nmodule.exports = (function() {\n 'use strict';\n\n var Token,\n TokenName,\n Syntax,\n PropertyKind,\n Messages,\n Regex,\n source,\n strict,\n index,\n lineNumber,\n lineStart,\n length,\n lookahead,\n state,\n extra;\n\n Token = {\n BooleanLiteral: 1,\n EOF: 2,\n Identifier: 3,\n Keyword: 4,\n NullLiteral: 5,\n NumericLiteral: 6,\n Punctuator: 7,\n StringLiteral: 8,\n RegularExpression: 9\n };\n\n TokenName = {};\n TokenName[Token.BooleanLiteral] = 'Boolean';\n TokenName[Token.EOF] = '<end>';\n TokenName[Token.Identifier] = 'Identifier';\n TokenName[Token.Keyword] = 'Keyword';\n TokenName[Token.NullLiteral] = 'Null';\n TokenName[Token.NumericLiteral] = 'Numeric';\n TokenName[Token.Punctuator] = 'Punctuator';\n TokenName[Token.StringLiteral] = 'String';\n TokenName[Token.RegularExpression] = 'RegularExpression';\n\n Syntax = {\n AssignmentExpression: 'AssignmentExpression',\n ArrayExpression: 'ArrayExpression',\n BinaryExpression: 'BinaryExpression',\n CallExpression: 'CallExpression',\n ConditionalExpression: 'ConditionalExpression',\n ExpressionStatement: 'ExpressionStatement',\n Identifier: 'Identifier',\n Literal: 'Literal',\n LogicalExpression: 'LogicalExpression',\n MemberExpression: 'MemberExpression',\n ObjectExpression: 'ObjectExpression',\n Program: 'Program',\n Property: 'Property',\n UnaryExpression: 'UnaryExpression',\n UpdateExpression: 'UpdateExpression'\n };\n\n PropertyKind = {\n Data: 1,\n Get: 2,\n Set: 4\n };\n\n // Error messages should be identical to V8.\n Messages = {\n UnexpectedToken: 'Unexpected token %0',\n UnexpectedNumber: 'Unexpected number',\n UnexpectedString: 'Unexpected string',\n UnexpectedIdentifier: 'Unexpected identifier',\n UnexpectedReserved: 'Unexpected reserved word',\n UnexpectedEOS: 'Unexpected end of input',\n NewlineAfterThrow: 'Illegal newline after throw',\n InvalidRegExp: 'Invalid regular expression',\n UnterminatedRegExp: 'Invalid regular expression: missing /',\n InvalidLHSInAssignment: 'Invalid left-hand side in assignment',\n InvalidLHSInForIn: 'Invalid left-hand side in for-in',\n MultipleDefaultsInSwitch: 'More than one default clause in switch statement',\n NoCatchOrFinally: 'Missing catch or finally after try',\n UnknownLabel: 'Undefined label \\'%0\\'',\n Redeclaration: '%0 \\'%1\\' has already been declared',\n IllegalContinue: 'Illegal continue statement',\n IllegalBreak: 'Illegal break statement',\n IllegalReturn: 'Illegal return statement',\n StrictModeWith: 'Strict mode code may not include a with statement',\n StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',\n StrictVarName: 'Variable name may not be eval or arguments in strict mode',\n StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',\n StrictParamDupe: 'Strict mode function may not have duplicate parameter names',\n StrictFunctionName: 'Function name may not be eval or arguments in strict mode',\n StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',\n StrictDelete: 'Delete of an unqualified identifier in strict mode.',\n StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',\n AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',\n AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',\n StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',\n StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',\n StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',\n StrictReservedWord: 'Use of future reserved word in strict mode'\n };\n\n // See also tools/generate-unicode-regex.py.\n Regex = {\n NonAsciiIdentifierStart: new RegExp('[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]'),\n NonAsciiIdentifierPart: new RegExp('[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]')\n };\n\n // Ensure the condition is true, otherwise throw an error.\n // This is only to have a better contract semantic, i.e. another safety net\n // to catch a logic error. The condition shall be fulfilled in normal case.\n // Do NOT use this to enforce a certain condition on any user input.\n\n function assert(condition, message) {\n if (!condition) {\n throw new Error('ASSERT: ' + message);\n }\n }\n\n function isDecimalDigit(ch) {\n return (ch >= 0x30 && ch <= 0x39); // 0..9\n }\n\n function isHexDigit(ch) {\n return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;\n }\n\n function isOctalDigit(ch) {\n return '01234567'.indexOf(ch) >= 0;\n }\n\n // 7.2 White Space\n\n function isWhiteSpace(ch) {\n return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) ||\n (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0);\n }\n\n // 7.3 Line Terminators\n\n function isLineTerminator(ch) {\n return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029);\n }\n\n // 7.6 Identifier Names and Identifiers\n\n function isIdentifierStart(ch) {\n return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore)\n (ch >= 0x41 && ch <= 0x5A) || // A..Z\n (ch >= 0x61 && ch <= 0x7A) || // a..z\n (ch === 0x5C) || // \\ (backslash)\n ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch)));\n }\n\n function isIdentifierPart(ch) {\n return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore)\n (ch >= 0x41 && ch <= 0x5A) || // A..Z\n (ch >= 0x61 && ch <= 0x7A) || // a..z\n (ch >= 0x30 && ch <= 0x39) || // 0..9\n (ch === 0x5C) || // \\ (backslash)\n ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch)));\n }\n\n // 7.6.1.2 Future Reserved Words\n\n function isFutureReservedWord(id) {\n switch (id) {\n case 'class':\n case 'enum':\n case 'export':\n case 'extends':\n case 'import':\n case 'super':\n return true;\n default:\n return false;\n }\n }\n\n function isStrictModeReservedWord(id) {\n switch (id) {\n case 'implements':\n case 'interface':\n case 'package':\n case 'private':\n case 'protected':\n case 'public':\n case 'static':\n case 'yield':\n case 'let':\n return true;\n default:\n return false;\n }\n }\n\n // 7.6.1.1 Keywords\n\n function isKeyword(id) {\n if (strict && isStrictModeReservedWord(id)) {\n return true;\n }\n\n // 'const' is specialized as Keyword in V8.\n // 'yield' and 'let' are for compatiblity with SpiderMonkey and ES.next.\n // Some others are from future reserved words.\n\n switch (id.length) {\n case 2:\n return (id === 'if') || (id === 'in') || (id === 'do');\n case 3:\n return (id === 'var') || (id === 'for') || (id === 'new') ||\n (id === 'try') || (id === 'let');\n case 4:\n return (id === 'this') || (id === 'else') || (id === 'case') ||\n (id === 'void') || (id === 'with') || (id === 'enum');\n case 5:\n return (id === 'while') || (id === 'break') || (id === 'catch') ||\n (id === 'throw') || (id === 'const') || (id === 'yield') ||\n (id === 'class') || (id === 'super');\n case 6:\n return (id === 'return') || (id === 'typeof') || (id === 'delete') ||\n (id === 'switch') || (id === 'export') || (id === 'import');\n case 7:\n return (id === 'default') || (id === 'finally') || (id === 'extends');\n case 8:\n return (id === 'function') || (id === 'continue') || (id === 'debugger');\n case 10:\n return (id === 'instanceof');\n default:\n return false;\n }\n }\n\n function skipComment() {\n var ch, start;\n\n start = (index === 0);\n while (index < length) {\n ch = source.charCodeAt(index);\n\n if (isWhiteSpace(ch)) {\n ++index;\n } else if (isLineTerminator(ch)) {\n ++index;\n if (ch === 0x0D && source.charCodeAt(index) === 0x0A) {\n ++index;\n }\n ++lineNumber;\n lineStart = index;\n start = true;\n } else {\n break;\n }\n }\n }\n\n function scanHexEscape(prefix) {\n var i, len, ch, code = 0;\n\n len = (prefix === 'u') ? 4 : 2;\n for (i = 0; i < len; ++i) {\n if (index < length && isHexDigit(source[index])) {\n ch = source[index++];\n code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());\n } else {\n return '';\n }\n }\n return String.fromCharCode(code);\n }\n\n function scanUnicodeCodePointEscape() {\n var ch, code, cu1, cu2;\n\n ch = source[index];\n code = 0;\n\n // At least, one hex digit is required.\n if (ch === '}') {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n while (index < length) {\n ch = source[index++];\n if (!isHexDigit(ch)) {\n break;\n }\n code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());\n }\n\n if (code > 0x10FFFF || ch !== '}') {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n // UTF-16 Encoding\n if (code <= 0xFFFF) {\n return String.fromCharCode(code);\n }\n cu1 = ((code - 0x10000) >> 10) + 0xD800;\n cu2 = ((code - 0x10000) & 1023) + 0xDC00;\n return String.fromCharCode(cu1, cu2);\n }\n\n function getEscapedIdentifier() {\n var ch, id;\n\n ch = source.charCodeAt(index++);\n id = String.fromCharCode(ch);\n\n // '\\u' (U+005C, U+0075) denotes an escaped character.\n if (ch === 0x5C) {\n if (source.charCodeAt(index) !== 0x75) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n ++index;\n ch = scanHexEscape('u');\n if (!ch || ch === '\\\\' || !isIdentifierStart(ch.charCodeAt(0))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n id = ch;\n }\n\n while (index < length) {\n ch = source.charCodeAt(index);\n if (!isIdentifierPart(ch)) {\n break;\n }\n ++index;\n id += String.fromCharCode(ch);\n\n // '\\u' (U+005C, U+0075) denotes an escaped character.\n if (ch === 0x5C) {\n id = id.substr(0, id.length - 1);\n if (source.charCodeAt(index) !== 0x75) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n ++index;\n ch = scanHexEscape('u');\n if (!ch || ch === '\\\\' || !isIdentifierPart(ch.charCodeAt(0))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n id += ch;\n }\n }\n\n return id;\n }\n\n function getIdentifier() {\n var start, ch;\n\n start = index++;\n while (index < length) {\n ch = source.charCodeAt(index);\n if (ch === 0x5C) {\n // Blackslash (U+005C) marks Unicode escape sequence.\n index = start;\n return getEscapedIdentifier();\n }\n if (isIdentifierPart(ch)) {\n ++index;\n } else {\n break;\n }\n }\n\n return source.slice(start, index);\n }\n\n function scanIdentifier() {\n var start, id, type;\n\n start = index;\n\n // Backslash (U+005C) starts an escaped character.\n id = (source.charCodeAt(index) === 0x5C) ? getEscapedIdentifier() : getIdentifier();\n\n // There is no keyword or literal with only one character.\n // Thus, it must be an identifier.\n if (id.length === 1) {\n type = Token.Identifier;\n } else if (isKeyword(id)) {\n type = Token.Keyword;\n } else if (id === 'null') {\n type = Token.NullLiteral;\n } else if (id === 'true' || id === 'false') {\n type = Token.BooleanLiteral;\n } else {\n type = Token.Identifier;\n }\n\n return {\n type: type,\n value: id,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n // 7.7 Punctuators\n\n function scanPunctuator() {\n var start = index,\n code = source.charCodeAt(index),\n code2,\n ch1 = source[index],\n ch2,\n ch3,\n ch4;\n\n switch (code) {\n\n // Check for most common single-character punctuators.\n case 0x2E: // . dot\n case 0x28: // ( open bracket\n case 0x29: // ) close bracket\n case 0x3B: // ; semicolon\n case 0x2C: // , comma\n case 0x7B: // { open curly brace\n case 0x7D: // } close curly brace\n case 0x5B: // [\n case 0x5D: // ]\n case 0x3A: // :\n case 0x3F: // ?\n case 0x7E: // ~\n ++index;\n if (extra.tokenize) {\n if (code === 0x28) {\n extra.openParenToken = extra.tokens.length;\n } else if (code === 0x7B) {\n extra.openCurlyToken = extra.tokens.length;\n }\n }\n return {\n type: Token.Punctuator,\n value: String.fromCharCode(code),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n\n default:\n code2 = source.charCodeAt(index + 1);\n\n // '=' (U+003D) marks an assignment or comparison operator.\n if (code2 === 0x3D) {\n switch (code) {\n case 0x2B: // +\n case 0x2D: // -\n case 0x2F: // /\n case 0x3C: // <\n case 0x3E: // >\n case 0x5E: // ^\n case 0x7C: // |\n case 0x25: // %\n case 0x26: // &\n case 0x2A: // *\n index += 2;\n return {\n type: Token.Punctuator,\n value: String.fromCharCode(code) + String.fromCharCode(code2),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n\n case 0x21: // !\n case 0x3D: // =\n index += 2;\n\n // !== and ===\n if (source.charCodeAt(index) === 0x3D) {\n ++index;\n }\n return {\n type: Token.Punctuator,\n value: source.slice(start, index),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n }\n }\n\n // 4-character punctuator: >>>=\n\n ch4 = source.substr(index, 4);\n\n if (ch4 === '>>>=') {\n index += 4;\n return {\n type: Token.Punctuator,\n value: ch4,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n // 3-character punctuators: === !== >>> <<= >>=\n\n ch3 = ch4.substr(0, 3);\n\n if (ch3 === '>>>' || ch3 === '<<=' || ch3 === '>>=') {\n index += 3;\n return {\n type: Token.Punctuator,\n value: ch3,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n // Other 2-character punctuators: ++ -- << >> && ||\n ch2 = ch3.substr(0, 2);\n\n if ((ch1 === ch2[1] && ('+-<>&|'.indexOf(ch1) >= 0)) || ch2 === '=>') {\n index += 2;\n return {\n type: Token.Punctuator,\n value: ch2,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n // 1-character punctuators: < > = ! + - * % & | ^ /\n\n if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {\n ++index;\n return {\n type: Token.Punctuator,\n value: ch1,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n // 7.8.3 Numeric Literals\n\n function scanHexLiteral(start) {\n var number = '';\n\n while (index < length) {\n if (!isHexDigit(source[index])) {\n break;\n }\n number += source[index++];\n }\n\n if (number.length === 0) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n if (isIdentifierStart(source.charCodeAt(index))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.NumericLiteral,\n value: parseInt('0x' + number, 16),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n function scanOctalLiteral(start) {\n var number = '0' + source[index++];\n while (index < length) {\n if (!isOctalDigit(source[index])) {\n break;\n }\n number += source[index++];\n }\n\n if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.NumericLiteral,\n value: parseInt(number, 8),\n octal: true,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n function scanNumericLiteral() {\n var number, start, ch;\n\n ch = source[index];\n assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),\n 'Numeric literal must start with a decimal digit or a decimal point');\n\n start = index;\n number = '';\n if (ch !== '.') {\n number = source[index++];\n ch = source[index];\n\n // Hex number starts with '0x'.\n // Octal number starts with '0'.\n if (number === '0') {\n if (ch === 'x' || ch === 'X') {\n ++index;\n return scanHexLiteral(start);\n }\n if (isOctalDigit(ch)) {\n return scanOctalLiteral(start);\n }\n\n // decimal number starts with '0' such as '09' is illegal.\n if (ch && isDecimalDigit(ch.charCodeAt(0))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n }\n\n while (isDecimalDigit(source.charCodeAt(index))) {\n number += source[index++];\n }\n ch = source[index];\n }\n\n if (ch === '.') {\n number += source[index++];\n while (isDecimalDigit(source.charCodeAt(index))) {\n number += source[index++];\n }\n ch = source[index];\n }\n\n if (ch === 'e' || ch === 'E') {\n number += source[index++];\n\n ch = source[index];\n if (ch === '+' || ch === '-') {\n number += source[index++];\n }\n if (isDecimalDigit(source.charCodeAt(index))) {\n while (isDecimalDigit(source.charCodeAt(index))) {\n number += source[index++];\n }\n } else {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n }\n\n if (isIdentifierStart(source.charCodeAt(index))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.NumericLiteral,\n value: parseFloat(number),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n // 7.8.4 String Literals\n\n function scanStringLiteral() {\n var str = '', quote, start, ch, code, unescaped, restore, octal = false, startLineNumber, startLineStart;\n startLineNumber = lineNumber;\n startLineStart = lineStart;\n\n quote = source[index];\n assert((quote === '\\'' || quote === '\"'),\n 'String literal must starts with a quote');\n\n start = index;\n ++index;\n\n while (index < length) {\n ch = source[index++];\n\n if (ch === quote) {\n quote = '';\n break;\n } else if (ch === '\\\\') {\n ch = source[index++];\n if (!ch || !isLineTerminator(ch.charCodeAt(0))) {\n switch (ch) {\n case 'u':\n case 'x':\n if (source[index] === '{') {\n ++index;\n str += scanUnicodeCodePointEscape();\n } else {\n restore = index;\n unescaped = scanHexEscape(ch);\n if (unescaped) {\n str += unescaped;\n } else {\n index = restore;\n str += ch;\n }\n }\n break;\n case 'n':\n str += '\\n';\n break;\n case 'r':\n str += '\\r';\n break;\n case 't':\n str += '\\t';\n break;\n case 'b':\n str += '\\b';\n break;\n case 'f':\n str += '\\f';\n break;\n case 'v':\n str += '\\x0B';\n break;\n\n default:\n if (isOctalDigit(ch)) {\n code = '01234567'.indexOf(ch);\n\n // \\0 is not octal escape sequence\n if (code !== 0) {\n octal = true;\n }\n\n if (index < length && isOctalDigit(source[index])) {\n octal = true;\n code = code * 8 + '01234567'.indexOf(source[index++]);\n\n // 3 digits are only allowed when string starts\n // with 0, 1, 2, 3\n if ('0123'.indexOf(ch) >= 0 &&\n index < length &&\n isOctalDigit(source[index])) {\n code = code * 8 + '01234567'.indexOf(source[index++]);\n }\n }\n str += String.fromCharCode(code);\n } else {\n str += ch;\n }\n break;\n }\n } else {\n ++lineNumber;\n if (ch === '\\r' && source[index] === '\\n') {\n ++index;\n }\n lineStart = index;\n }\n } else if (isLineTerminator(ch.charCodeAt(0))) {\n break;\n } else {\n str += ch;\n }\n }\n\n if (quote !== '') {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.StringLiteral,\n value: str,\n octal: octal,\n startLineNumber: startLineNumber,\n startLineStart: startLineStart,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n function testRegExp(pattern, flags) {\n var tmp = pattern,\n value;\n\n if (flags.indexOf('u') >= 0) {\n // Replace each astral symbol and every Unicode code point\n // escape sequence with a single ASCII symbol to avoid throwing on\n // regular expressions that are only valid in combination with the\n // `/u` flag.\n // Note: replacing with the ASCII symbol `x` might cause false\n // negatives in unlikely scenarios. For example, `[\\u{61}-b]` is a\n // perfectly valid pattern that is equivalent to `[a-b]`, but it\n // would be replaced by `[x-b]` which throws an error.\n tmp = tmp\n .replace(/\\\\u\\{([0-9a-fA-F]+)\\}/g, function ($0, $1) {\n if (parseInt($1, 16) <= 0x10FFFF) {\n return 'x';\n }\n throwError({}, Messages.InvalidRegExp);\n })\n .replace(/[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g, 'x');\n }\n\n // First, detect invalid regular expressions.\n try {\n value = new RegExp(tmp);\n } catch (e) {\n throwError({}, Messages.InvalidRegExp);\n }\n\n // Return a regular expression object for this pattern-flag pair, or\n // `null` in case the current environment doesn't support the flags it\n // uses.\n try {\n return new RegExp(pattern, flags);\n } catch (exception) {\n return null;\n }\n }\n\n function scanRegExpBody() {\n var ch, str, classMarker, terminated, body;\n\n ch = source[index];\n assert(ch === '/', 'Regular expression literal must start with a slash');\n str = source[index++];\n\n classMarker = false;\n terminated = false;\n while (index < length) {\n ch = source[index++];\n str += ch;\n if (ch === '\\\\') {\n ch = source[index++];\n // ECMA-262 7.8.5\n if (isLineTerminator(ch.charCodeAt(0))) {\n throwError({}, Messages.UnterminatedRegExp);\n }\n str += ch;\n } else if (isLineTerminator(ch.charCodeAt(0))) {\n throwError({}, Messages.UnterminatedRegExp);\n } else if (classMarker) {\n if (ch === ']') {\n classMarker = false;\n }\n } else {\n if (ch === '/') {\n terminated = true;\n break;\n } else if (ch === '[') {\n classMarker = true;\n }\n }\n }\n\n if (!terminated) {\n throwError({}, Messages.UnterminatedRegExp);\n }\n\n // Exclude leading and trailing slash.\n body = str.substr(1, str.length - 2);\n return {\n value: body,\n literal: str\n };\n }\n\n function scanRegExpFlags() {\n var ch, str, flags, restore;\n\n str = '';\n flags = '';\n while (index < length) {\n ch = source[index];\n if (!isIdentifierPart(ch.charCodeAt(0))) {\n break;\n }\n\n ++index;\n if (ch === '\\\\' && index < length) {\n ch = source[index];\n if (ch === 'u') {\n ++index;\n restore = index;\n ch = scanHexEscape('u');\n if (ch) {\n flags += ch;\n for (str += '\\\\u'; restore < index; ++restore) {\n str += source[restore];\n }\n } else {\n index = restore;\n flags += 'u';\n str += '\\\\u';\n }\n throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');\n } else {\n str += '\\\\';\n throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n } else {\n flags += ch;\n str += ch;\n }\n }\n\n return {\n value: flags,\n literal: str\n };\n }\n\n function scanRegExp() {\n var start, body, flags, value;\n\n lookahead = null;\n skipComment();\n start = index;\n\n body = scanRegExpBody();\n flags = scanRegExpFlags();\n value = testRegExp(body.value, flags.value);\n\n if (extra.tokenize) {\n return {\n type: Token.RegularExpression,\n value: value,\n regex: {\n pattern: body.value,\n flags: flags.value\n },\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n return {\n literal: body.literal + flags.literal,\n value: value,\n regex: {\n pattern: body.value,\n flags: flags.value\n },\n start: start,\n end: index\n };\n }\n\n function collectRegex() {\n var pos, loc, regex, token;\n\n skipComment();\n\n pos = index;\n loc = {\n start: {\n line: lineNumber,\n column: index - lineStart\n }\n };\n\n regex = scanRegExp();\n\n loc.end = {\n line: lineNumber,\n column: index - lineStart\n };\n\n if (!extra.tokenize) {\n // Pop the previous token, which is likely '/' or '/='\n if (extra.tokens.length > 0) {\n token = extra.tokens[extra.tokens.length - 1];\n if (token.range[0] === pos && token.type === 'Punctuator') {\n if (token.value === '/' || token.value === '/=') {\n extra.tokens.pop();\n }\n }\n }\n\n extra.tokens.push({\n type: 'RegularExpression',\n value: regex.literal,\n regex: regex.regex,\n range: [pos, index],\n loc: loc\n });\n }\n\n return regex;\n }\n\n function isIdentifierName(token) {\n return token.type === Token.Identifier ||\n token.type === Token.Keyword ||\n token.type === Token.BooleanLiteral ||\n token.type === Token.NullLiteral;\n }\n\n function advanceSlash() {\n var prevToken,\n checkToken;\n // Using the following algorithm:\n // https://github.com/mozilla/sweet.js/wiki/design\n prevToken = extra.tokens[extra.tokens.length - 1];\n if (!prevToken) {\n // Nothing before that: it cannot be a division.\n return collectRegex();\n }\n if (prevToken.type === 'Punctuator') {\n if (prevToken.value === ']') {\n return scanPunctuator();\n }\n if (prevToken.value === ')') {\n checkToken = extra.tokens[extra.openParenToken - 1];\n if (checkToken &&\n checkToken.type === 'Keyword' &&\n (checkToken.value === 'if' ||\n checkToken.value === 'while' ||\n checkToken.value === 'for' ||\n checkToken.value === 'with')) {\n return collectRegex();\n }\n return scanPunctuator();\n }\n if (prevToken.value === '}') {\n // Dividing a function by anything makes little sense,\n // but we have to check for that.\n if (extra.tokens[extra.openCurlyToken - 3] &&\n extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') {\n // Anonymous function.\n checkToken = extra.tokens[extra.openCurlyToken - 4];\n if (!checkToken) {\n return scanPunctuator();\n }\n } else if (extra.tokens[extra.openCurlyToken - 4] &&\n extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') {\n // Named function.\n checkToken = extra.tokens[extra.openCurlyToken - 5];\n if (!checkToken) {\n return collectRegex();\n }\n } else {\n return scanPunctuator();\n }\n return scanPunctuator();\n }\n return collectRegex();\n }\n if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {\n return collectRegex();\n }\n return scanPunctuator();\n }\n\n function advance() {\n var ch;\n\n skipComment();\n\n if (index >= length) {\n return {\n type: Token.EOF,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: index,\n end: index\n };\n }\n\n ch = source.charCodeAt(index);\n\n if (isIdentifierStart(ch)) {\n return scanIdentifier();\n }\n\n // Very common: ( and ) and ;\n if (ch === 0x28 || ch === 0x29 || ch === 0x3B) {\n return scanPunctuator();\n }\n\n // String literal starts with single quote (U+0027) or double quote (U+0022).\n if (ch === 0x27 || ch === 0x22) {\n return scanStringLiteral();\n }\n\n\n // Dot (.) U+002E can also start a floating-point number, hence the need\n // to check the next character.\n if (ch === 0x2E) {\n if (isDecimalDigit(source.charCodeAt(index + 1))) {\n return scanNumericLiteral();\n }\n return scanPunctuator();\n }\n\n if (isDecimalDigit(ch)) {\n return scanNumericLiteral();\n }\n\n // Slash (/) U+002F can also start a regex.\n if (extra.tokenize && ch === 0x2F) {\n return advanceSlash();\n }\n\n return scanPunctuator();\n }\n\n function collectToken() {\n var loc, token, value, entry;\n\n skipComment();\n loc = {\n start: {\n line: lineNumber,\n column: index - lineStart\n }\n };\n\n token = advance();\n loc.end = {\n line: lineNumber,\n column: index - lineStart\n };\n\n if (token.type !== Token.EOF) {\n value = source.slice(token.start, token.end);\n entry = {\n type: TokenName[token.type],\n value: value,\n range: [token.start, token.end],\n loc: loc\n };\n if (token.regex) {\n entry.regex = {\n pattern: token.regex.pattern,\n flags: token.regex.flags\n };\n }\n extra.tokens.push(entry);\n }\n\n return token;\n }\n\n function lex() {\n var token;\n\n token = lookahead;\n index = token.end;\n lineNumber = token.lineNumber;\n lineStart = token.lineStart;\n\n lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance();\n\n index = token.end;\n lineNumber = token.lineNumber;\n lineStart = token.lineStart;\n\n return token;\n }\n\n function peek() {\n var pos, line, start;\n\n pos = index;\n line = lineNumber;\n start = lineStart;\n lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance();\n index = pos;\n lineNumber = line;\n lineStart = start;\n }\n\n function Position() {\n this.line = lineNumber;\n this.column = index - lineStart;\n }\n\n function SourceLocation() {\n this.start = new Position();\n this.end = null;\n }\n\n function WrappingSourceLocation(startToken) {\n if (startToken.type === Token.StringLiteral) {\n this.start = {\n line: startToken.startLineNumber,\n column: startToken.start - startToken.startLineStart\n };\n } else {\n this.start = {\n line: startToken.lineNumber,\n column: startToken.start - startToken.lineStart\n };\n }\n this.end = null;\n }\n\n function Node() {\n // Skip comment.\n index = lookahead.start;\n if (lookahead.type === Token.StringLiteral) {\n lineNumber = lookahead.startLineNumber;\n lineStart = lookahead.startLineStart;\n } else {\n lineNumber = lookahead.lineNumber;\n lineStart = lookahead.lineStart;\n }\n if (extra.range) {\n this.range = [index, 0];\n }\n if (extra.loc) {\n this.loc = new SourceLocation();\n }\n }\n\n function WrappingNode(startToken) {\n if (extra.range) {\n this.range = [startToken.start, 0];\n }\n if (extra.loc) {\n this.loc = new WrappingSourceLocation(startToken);\n }\n }\n\n WrappingNode.prototype = Node.prototype = {\n\n finish: function () {\n if (extra.range) {\n this.range[1] = index;\n }\n if (extra.loc) {\n this.loc.end = new Position();\n if (extra.source) {\n this.loc.source = extra.source;\n }\n }\n },\n\n finishArrayExpression: function (elements) {\n this.type = Syntax.ArrayExpression;\n this.elements = elements;\n this.finish();\n return this;\n },\n\n finishAssignmentExpression: function (operator, left, right) {\n this.type = Syntax.AssignmentExpression;\n this.operator = operator;\n this.left = left;\n this.right = right;\n this.finish();\n return this;\n },\n\n finishBinaryExpression: function (operator, left, right) {\n this.type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : Syntax.BinaryExpression;\n this.operator = operator;\n this.left = left;\n this.right = right;\n this.finish();\n return this;\n },\n\n finishCallExpression: function (callee, args) {\n this.type = Syntax.CallExpression;\n this.callee = callee;\n this.arguments = args;\n this.finish();\n return this;\n },\n\n finishConditionalExpression: function (test, consequent, alternate) {\n this.type = Syntax.ConditionalExpression;\n this.test = test;\n this.consequent = consequent;\n this.alternate = alternate;\n this.finish();\n return this;\n },\n\n finishExpressionStatement: function (expression) {\n this.type = Syntax.ExpressionStatement;\n this.expression = expression;\n this.finish();\n return this;\n },\n\n finishIdentifier: function (name) {\n this.type = Syntax.Identifier;\n this.name = name;\n this.finish();\n return this;\n },\n\n finishLiteral: function (token) {\n this.type = Syntax.Literal;\n this.value = token.value;\n this.raw = source.slice(token.start, token.end);\n if (token.regex) {\n if (this.raw == '//') {\n this.raw = '/(?:)/';\n }\n this.regex = token.regex;\n }\n this.finish();\n return this;\n },\n\n finishMemberExpression: function (accessor, object, property) {\n this.type = Syntax.MemberExpression;\n this.computed = accessor === '[';\n this.object = object;\n this.property = property;\n this.finish();\n return this;\n },\n\n finishObjectExpression: function (properties) {\n this.type = Syntax.ObjectExpression;\n this.properties = properties;\n this.finish();\n return this;\n },\n\n finishProgram: function (body) {\n this.type = Syntax.Program;\n this.body = body;\n this.finish();\n return this;\n },\n\n finishProperty: function (kind, key, value) {\n this.type = Syntax.Property;\n this.key = key;\n this.value = value;\n this.kind = kind;\n this.finish();\n return this;\n },\n\n finishUnaryExpression: function (operator, argument) {\n this.type = (operator === '++' || operator === '--') ? Syntax.UpdateExpression : Syntax.UnaryExpression;\n this.operator = operator;\n this.argument = argument;\n this.prefix = true;\n this.finish();\n return this;\n }\n };\n\n // Return true if there is a line terminator before the next token.\n\n function peekLineTerminator() {\n var pos, line, start, found;\n\n pos = index;\n line = lineNumber;\n start = lineStart;\n skipComment();\n found = lineNumber !== line;\n index = pos;\n lineNumber = line;\n lineStart = start;\n\n return found;\n }\n\n // Throw an exception\n\n function throwError(token, messageFormat) {\n var error,\n args = Array.prototype.slice.call(arguments, 2),\n msg = messageFormat.replace(\n /%(\\d)/g,\n function (whole, index) {\n assert(index < args.length, 'Message reference must be in range');\n return args[index];\n }\n );\n\n if (typeof token.lineNumber === 'number') {\n error = new Error('Line ' + token.lineNumber + ': ' + msg);\n error.index = token.start;\n error.lineNumber = token.lineNumber;\n error.column = token.start - lineStart + 1;\n } else {\n error = new Error('Line ' + lineNumber + ': ' + msg);\n error.index = index;\n error.lineNumber = lineNumber;\n error.column = index - lineStart + 1;\n }\n\n error.description = msg;\n throw error;\n }\n\n function throwErrorTolerant() {\n try {\n throwError.apply(null, arguments);\n } catch (e) {\n if (extra.errors) {\n extra.errors.push(e);\n } else {\n throw e;\n }\n }\n }\n\n\n // Throw an exception because of the token.\n\n function throwUnexpected(token) {\n if (token.type === Token.EOF) {\n throwError(token, Messages.UnexpectedEOS);\n }\n\n if (token.type === Token.NumericLiteral) {\n throwError(token, Messages.UnexpectedNumber);\n }\n\n if (token.type === Token.StringLiteral) {\n throwError(token, Messages.UnexpectedString);\n }\n\n if (token.type === Token.Identifier) {\n throwError(token, Messages.UnexpectedIdentifier);\n }\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n throwError(token, Messages.UnexpectedReserved);\n } else if (strict && isStrictModeReservedWord(token.value)) {\n throwErrorTolerant(token, Messages.StrictReservedWord);\n return;\n }\n throwError(token, Messages.UnexpectedToken, token.value);\n }\n\n // BooleanLiteral, NullLiteral, or Punctuator.\n throwError(token, Messages.UnexpectedToken, token.value);\n }\n\n // Expect the next token to match the specified punctuator.\n // If not, an exception will be thrown.\n\n function expect(value) {\n var token = lex();\n if (token.type !== Token.Punctuator || token.value !== value) {\n throwUnexpected(token);\n }\n }\n\n /**\n * @name expectTolerant\n * @description Quietly expect the given token value when in tolerant mode, otherwise delegates\n * to <code>expect(value)</code>\n * @param {String} value The value we are expecting the lookahead token to have\n * @since 2.0\n */\n function expectTolerant(value) {\n if (extra.errors) {\n var token = lookahead;\n if (token.type !== Token.Punctuator && token.value !== value) {\n throwErrorTolerant(token, Messages.UnexpectedToken, token.value);\n } else {\n lex();\n }\n } else {\n expect(value);\n }\n }\n\n // Expect the next token to match the specified keyword.\n // If not, an exception will be thrown.\n\n function expectKeyword(keyword) {\n var token = lex();\n if (token.type !== Token.Keyword || token.value !== keyword) {\n throwUnexpected(token);\n }\n }\n\n // Return true if the next token matches the specified punctuator.\n\n function match(value) {\n return lookahead.type === Token.Punctuator && lookahead.value === value;\n }\n\n // Return true if the next token matches the specified keyword\n\n function matchKeyword(keyword) {\n return lookahead.type === Token.Keyword && lookahead.value === keyword;\n }\n\n function consumeSemicolon() {\n var line;\n\n // Catch the very common case first: immediately a semicolon (U+003B).\n if (source.charCodeAt(index) === 0x3B || match(';')) {\n lex();\n return;\n }\n\n line = lineNumber;\n skipComment();\n if (lineNumber !== line) {\n return;\n }\n\n if (lookahead.type !== Token.EOF && !match('}')) {\n throwUnexpected(lookahead);\n }\n }\n\n // Return true if provided expression is LeftHandSideExpression\n\n function isLeftHandSide(expr) {\n return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression;\n }\n\n // 11.1.4 Array Initialiser\n\n function parseArrayInitialiser() {\n var elements = [], node = new Node();\n\n expect('[');\n\n while (!match(']')) {\n if (match(',')) {\n lex();\n elements.push(null);\n } else {\n elements.push(parseAssignmentExpression());\n\n if (!match(']')) {\n expect(',');\n }\n }\n }\n\n lex();\n\n return node.finishArrayExpression(elements);\n }\n\n // 11.1.5 Object Initialiser\n\n function parseObjectPropertyKey() {\n var token, node = new Node();\n\n token = lex();\n\n // Note: This function is called only from parseObjectProperty(), where\n // EOF and Punctuator tokens are already filtered out.\n\n if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {\n if (strict && token.octal) {\n throwErrorTolerant(token, Messages.StrictOctalLiteral);\n }\n return node.finishLiteral(token);\n }\n\n return node.finishIdentifier(token.value);\n }\n\n function parseObjectProperty() {\n var token, key, id, value, param, node = new Node();\n\n token = lookahead;\n\n if (token.type === Token.Identifier) {\n id = parseObjectPropertyKey();\n expect(':');\n value = parseAssignmentExpression();\n return node.finishProperty('init', id, value);\n }\n if (token.type === Token.EOF || token.type === Token.Punctuator) {\n throwUnexpected(token);\n } else {\n key = parseObjectPropertyKey();\n expect(':');\n value = parseAssignmentExpression();\n return node.finishProperty('init', key, value);\n }\n }\n\n function parseObjectInitialiser() {\n var properties = [], token, property, name, key, kind, map = {}, toString = String, node = new Node();\n\n expect('{');\n\n while (!match('}')) {\n property = parseObjectProperty();\n\n if (property.key.type === Syntax.Identifier) {\n name = property.key.name;\n } else {\n name = toString(property.key.value);\n }\n kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;\n\n key = '$' + name;\n if (Object.prototype.hasOwnProperty.call(map, key)) {\n if (map[key] === PropertyKind.Data) {\n if (strict && kind === PropertyKind.Data) {\n throwErrorTolerant({}, Messages.StrictDuplicateProperty);\n } else if (kind !== PropertyKind.Data) {\n throwErrorTolerant({}, Messages.AccessorDataProperty);\n }\n } else {\n if (kind === PropertyKind.Data) {\n throwErrorTolerant({}, Messages.AccessorDataProperty);\n } else if (map[key] & kind) {\n throwErrorTolerant({}, Messages.AccessorGetSet);\n }\n }\n map[key] |= kind;\n } else {\n map[key] = kind;\n }\n\n properties.push(property);\n\n if (!match('}')) {\n expectTolerant(',');\n }\n }\n\n expect('}');\n\n return node.finishObjectExpression(properties);\n }\n\n // 11.1.6 The Grouping Operator\n\n function parseGroupExpression() {\n var expr;\n\n expect('(');\n\n ++state.parenthesisCount;\n\n expr = parseExpression();\n\n expect(')');\n\n return expr;\n }\n\n\n // 11.1 Primary Expressions\n\n var legalKeywords = {\"if\":1, \"this\":1};\n\n function parsePrimaryExpression() {\n var type, token, expr, node;\n\n if (match('(')) {\n return parseGroupExpression();\n }\n\n if (match('[')) {\n return parseArrayInitialiser();\n }\n\n if (match('{')) {\n return parseObjectInitialiser();\n }\n\n type = lookahead.type;\n node = new Node();\n\n if (type === Token.Identifier || legalKeywords[lookahead.value]) {\n expr = node.finishIdentifier(lex().value);\n } else if (type === Token.StringLiteral || type === Token.NumericLiteral) {\n if (strict && lookahead.octal) {\n throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);\n }\n expr = node.finishLiteral(lex());\n } else if (type === Token.Keyword) {\n throw new Error(\"Disabled.\");\n } else if (type === Token.BooleanLiteral) {\n token = lex();\n token.value = (token.value === 'true');\n expr = node.finishLiteral(token);\n } else if (type === Token.NullLiteral) {\n token = lex();\n token.value = null;\n expr = node.finishLiteral(token);\n } else if (match('/') || match('/=')) {\n if (typeof extra.tokens !== 'undefined') {\n expr = node.finishLiteral(collectRegex());\n } else {\n expr = node.finishLiteral(scanRegExp());\n }\n peek();\n } else {\n throwUnexpected(lex());\n }\n\n return expr;\n }\n\n // 11.2 Left-Hand-Side Expressions\n\n function parseArguments() {\n var args = [];\n\n expect('(');\n\n if (!match(')')) {\n while (index < length) {\n args.push(parseAssignmentExpression());\n if (match(')')) {\n break;\n }\n expectTolerant(',');\n }\n }\n\n expect(')');\n\n return args;\n }\n\n function parseNonComputedProperty() {\n var token, node = new Node();\n\n token = lex();\n\n if (!isIdentifierName(token)) {\n throwUnexpected(token);\n }\n\n return node.finishIdentifier(token.value);\n }\n\n function parseNonComputedMember() {\n expect('.');\n\n return parseNonComputedProperty();\n }\n\n function parseComputedMember() {\n var expr;\n\n expect('[');\n\n expr = parseExpression();\n\n expect(']');\n\n return expr;\n }\n\n function parseLeftHandSideExpressionAllowCall() {\n var expr, args, property, startToken, previousAllowIn = state.allowIn;\n\n startToken = lookahead;\n state.allowIn = true;\n expr = parsePrimaryExpression();\n\n for (;;) {\n if (match('.')) {\n property = parseNonComputedMember();\n expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property);\n } else if (match('(')) {\n args = parseArguments();\n expr = new WrappingNode(startToken).finishCallExpression(expr, args);\n } else if (match('[')) {\n property = parseComputedMember();\n expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property);\n } else {\n break;\n }\n }\n state.allowIn = previousAllowIn;\n\n return expr;\n }\n\n function parseLeftHandSideExpression() {\n var expr, property, startToken;\n assert(state.allowIn, 'callee of new expression always allow in keyword.');\n\n startToken = lookahead;\n expr = parsePrimaryExpression();\n\n for (;;) {\n if (match('[')) {\n property = parseComputedMember();\n expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property);\n } else if (match('.')) {\n property = parseNonComputedMember();\n expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property);\n } else {\n break;\n }\n }\n return expr;\n }\n\n // 11.3 Postfix Expressions\n\n function parsePostfixExpression() {\n var expr, token, startToken = lookahead;\n\n expr = parseLeftHandSideExpressionAllowCall();\n\n if (lookahead.type === Token.Punctuator) {\n if ((match('++') || match('--')) && !peekLineTerminator()) {\n throw new Error(\"Disabled.\");\n }\n }\n\n return expr;\n }\n\n // 11.4 Unary Operators\n\n function parseUnaryExpression() {\n var token, expr, startToken;\n\n if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {\n expr = parsePostfixExpression();\n } else if (match('++') || match('--')) {\n throw new Error(\"Disabled.\");\n } else if (match('+') || match('-') || match('~') || match('!')) {\n startToken = lookahead;\n token = lex();\n expr = parseUnaryExpression();\n expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);\n } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {\n throw new Error(\"Disabled.\");\n } else {\n expr = parsePostfixExpression();\n }\n\n return expr;\n }\n\n function binaryPrecedence(token, allowIn) {\n var prec = 0;\n\n if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {\n return 0;\n }\n\n switch (token.value) {\n case '||':\n prec = 1;\n break;\n\n case '&&':\n prec = 2;\n break;\n\n case '|':\n prec = 3;\n break;\n\n case '^':\n prec = 4;\n break;\n\n case '&':\n prec = 5;\n break;\n\n case '==':\n case '!=':\n case '===':\n case '!==':\n prec = 6;\n break;\n\n case '<':\n case '>':\n case '<=':\n case '>=':\n case 'instanceof':\n prec = 7;\n break;\n\n case 'in':\n prec = allowIn ? 7 : 0;\n break;\n\n case '<<':\n case '>>':\n case '>>>':\n prec = 8;\n break;\n\n case '+':\n case '-':\n prec = 9;\n break;\n\n case '*':\n case '/':\n case '%':\n prec = 11;\n break;\n\n default:\n break;\n }\n\n return prec;\n }\n\n // 11.5 Multiplicative Operators\n // 11.6 Additive Operators\n // 11.7 Bitwise Shift Operators\n // 11.8 Relational Operators\n // 11.9 Equality Operators\n // 11.10 Binary Bitwise Operators\n // 11.11 Binary Logical Operators\n\n function parseBinaryExpression() {\n var marker, markers, expr, token, prec, stack, right, operator, left, i;\n\n marker = lookahead;\n left = parseUnaryExpression();\n\n token = lookahead;\n prec = binaryPrecedence(token, state.allowIn);\n if (prec === 0) {\n return left;\n }\n token.prec = prec;\n lex();\n\n markers = [marker, lookahead];\n right = parseUnaryExpression();\n\n stack = [left, token, right];\n\n while ((prec = binaryPrecedence(lookahead, state.allowIn)) > 0) {\n\n // Reduce: make a binary expression from the three topmost entries.\n while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {\n right = stack.pop();\n operator = stack.pop().value;\n left = stack.pop();\n markers.pop();\n expr = new WrappingNode(markers[markers.length - 1]).finishBinaryExpression(operator, left, right);\n stack.push(expr);\n }\n\n // Shift.\n token = lex();\n token.prec = prec;\n stack.push(token);\n markers.push(lookahead);\n expr = parseUnaryExpression();\n stack.push(expr);\n }\n\n // Final reduce to clean-up the stack.\n i = stack.length - 1;\n expr = stack[i];\n markers.pop();\n while (i > 1) {\n expr = new WrappingNode(markers.pop()).finishBinaryExpression(stack[i - 1].value, stack[i - 2], expr);\n i -= 2;\n }\n\n return expr;\n }\n\n // 11.12 Conditional Operator\n\n function parseConditionalExpression() {\n var expr, previousAllowIn, consequent, alternate, startToken;\n\n startToken = lookahead;\n\n expr = parseBinaryExpression();\n\n if (match('?')) {\n lex();\n previousAllowIn = state.allowIn;\n state.allowIn = true;\n consequent = parseAssignmentExpression();\n state.allowIn = previousAllowIn;\n expect(':');\n alternate = parseAssignmentExpression();\n\n expr = new WrappingNode(startToken).finishConditionalExpression(expr, consequent, alternate);\n }\n\n return expr;\n }\n\n // 11.13 Assignment Operators\n\n function parseAssignmentExpression() {\n var oldParenthesisCount, token, expr, right, list, startToken;\n\n oldParenthesisCount = state.parenthesisCount;\n\n startToken = lookahead;\n token = lookahead;\n\n expr = parseConditionalExpression();\n\n return expr;\n }\n\n // 11.14 Comma Operator\n\n function parseExpression() {\n var expr, startToken = lookahead, expressions;\n\n expr = parseAssignmentExpression();\n\n if (match(',')) {\n throw new Error(\"Disabled.\"); // no sequence expressions\n }\n\n return expr;\n }\n\n // 12.4 Expression Statement\n\n function parseExpressionStatement(node) {\n var expr = parseExpression();\n consumeSemicolon();\n return node.finishExpressionStatement(expr);\n }\n\n // 12 Statements\n\n function parseStatement() {\n var type = lookahead.type,\n expr,\n labeledBody,\n key,\n node;\n\n if (type === Token.EOF) {\n throwUnexpected(lookahead);\n }\n\n if (type === Token.Punctuator && lookahead.value === '{') {\n throw new Error(\"Disabled.\"); // block statement\n }\n\n node = new Node();\n\n if (type === Token.Punctuator) {\n switch (lookahead.value) {\n case ';':\n throw new Error(\"Disabled.\"); // empty statement\n case '(':\n return parseExpressionStatement(node);\n default:\n break;\n }\n } else if (type === Token.Keyword) {\n throw new Error(\"Disabled.\"); // keyword\n }\n\n expr = parseExpression();\n consumeSemicolon();\n return node.finishExpressionStatement(expr);\n }\n\n // 14 Program\n\n function parseSourceElement() {\n if (lookahead.type === Token.Keyword) {\n switch (lookahead.value) {\n case 'const':\n case 'let':\n throw new Error(\"Disabled.\");\n case 'function':\n throw new Error(\"Disabled.\");\n default:\n return parseStatement();\n }\n }\n\n if (lookahead.type !== Token.EOF) {\n return parseStatement();\n }\n }\n\n function parseSourceElements() {\n var sourceElement, sourceElements = [], token, directive, firstRestricted;\n\n while (index < length) {\n token = lookahead;\n if (token.type !== Token.StringLiteral) {\n break;\n }\n\n sourceElement = parseSourceElement();\n sourceElements.push(sourceElement);\n if (sourceElement.expression.type !== Syntax.Literal) {\n // this is not directive\n break;\n }\n directive = source.slice(token.start + 1, token.end - 1);\n if (directive === 'use strict') {\n strict = true;\n if (firstRestricted) {\n throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);\n }\n } else {\n if (!firstRestricted && token.octal) {\n firstRestricted = token;\n }\n }\n }\n\n while (index < length) {\n sourceElement = parseSourceElement();\n if (typeof sourceElement === 'undefined') {\n break;\n }\n sourceElements.push(sourceElement);\n }\n return sourceElements;\n }\n\n function parseProgram() {\n var body, node;\n\n skipComment();\n peek();\n node = new Node();\n strict = true; // assume strict\n\n body = parseSourceElements();\n return node.finishProgram(body);\n }\n\n function filterTokenLocation() {\n var i, entry, token, tokens = [];\n\n for (i = 0; i < extra.tokens.length; ++i) {\n entry = extra.tokens[i];\n token = {\n type: entry.type,\n value: entry.value\n };\n if (entry.regex) {\n token.regex = {\n pattern: entry.regex.pattern,\n flags: entry.regex.flags\n };\n }\n if (extra.range) {\n token.range = entry.range;\n }\n if (extra.loc) {\n token.loc = entry.loc;\n }\n tokens.push(token);\n }\n\n extra.tokens = tokens;\n }\n\n function tokenize(code, options) {\n var toString,\n tokens;\n\n toString = String;\n if (typeof code !== 'string' && !(code instanceof String)) {\n code = toString(code);\n }\n\n source = code;\n index = 0;\n lineNumber = (source.length > 0) ? 1 : 0;\n lineStart = 0;\n length = source.length;\n lookahead = null;\n state = {\n allowIn: true,\n labelSet: {},\n inFunctionBody: false,\n inIteration: false,\n inSwitch: false,\n lastCommentStart: -1\n };\n\n extra = {};\n\n // Options matching.\n options = options || {};\n\n // Of course we collect tokens here.\n options.tokens = true;\n extra.tokens = [];\n extra.tokenize = true;\n // The following two fields are necessary to compute the Regex tokens.\n extra.openParenToken = -1;\n extra.openCurlyToken = -1;\n\n extra.range = (typeof options.range === 'boolean') && options.range;\n extra.loc = (typeof options.loc === 'boolean') && options.loc;\n\n if (typeof options.tolerant === 'boolean' && options.tolerant) {\n extra.errors = [];\n }\n\n try {\n peek();\n if (lookahead.type === Token.EOF) {\n return extra.tokens;\n }\n\n lex();\n while (lookahead.type !== Token.EOF) {\n try {\n lex();\n } catch (lexError) {\n if (extra.errors) {\n extra.errors.push(lexError);\n // We have to break on the first error\n // to avoid infinite loops.\n break;\n } else {\n throw lexError;\n }\n }\n }\n\n filterTokenLocation();\n tokens = extra.tokens;\n if (typeof extra.errors !== 'undefined') {\n tokens.errors = extra.errors;\n }\n } catch (e) {\n throw e;\n } finally {\n extra = {};\n }\n return tokens;\n }\n\n function parse(code, options) {\n var program, toString;\n\n toString = String;\n if (typeof code !== 'string' && !(code instanceof String)) {\n code = toString(code);\n }\n\n source = code;\n index = 0;\n lineNumber = (source.length > 0) ? 1 : 0;\n lineStart = 0;\n length = source.length;\n lookahead = null;\n state = {\n allowIn: true,\n labelSet: {},\n parenthesisCount: 0,\n inFunctionBody: false,\n inIteration: false,\n inSwitch: false,\n lastCommentStart: -1\n };\n\n extra = {};\n if (typeof options !== 'undefined') {\n extra.range = (typeof options.range === 'boolean') && options.range;\n extra.loc = (typeof options.loc === 'boolean') && options.loc;\n\n if (extra.loc && options.source !== null && options.source !== undefined) {\n extra.source = toString(options.source);\n }\n\n if (typeof options.tokens === 'boolean' && options.tokens) {\n extra.tokens = [];\n }\n if (typeof options.tolerant === 'boolean' && options.tolerant) {\n extra.errors = [];\n }\n }\n\n try {\n program = parseProgram();\n if (typeof extra.tokens !== 'undefined') {\n filterTokenLocation();\n program.tokens = extra.tokens;\n }\n if (typeof extra.errors !== 'undefined') {\n program.errors = extra.errors;\n }\n } catch (e) {\n throw e;\n } finally {\n extra = {};\n }\n\n return program;\n }\n\n return {\n tokenize: tokenize,\n parse: parse\n };\n\n})();",
"var dl = require('datalib'),\n axs = require('../scene/axis'),\n config = require('../util/config');\n\nvar ORIENT = {\n \"x\": \"bottom\",\n \"y\": \"left\",\n \"top\": \"top\",\n \"bottom\": \"bottom\",\n \"left\": \"left\",\n \"right\": \"right\"\n};\n\nfunction axes(model, spec, axes, group) {\n (spec || []).forEach(function(def, index) {\n axes[index] = axes[index] || axs(model);\n axis(def, index, axes[index], group);\n });\n};\n\nfunction axis(def, index, axis, group) {\n // axis scale\n if (def.scale !== undefined) {\n axis.scale(group.scale(def.scale));\n }\n\n // axis orientation\n axis.orient(def.orient || ORIENT[def.type]);\n // axis offset\n axis.offset(def.offset || 0);\n // axis layer\n axis.layer(def.layer || \"front\");\n // axis grid lines\n axis.grid(def.grid || false);\n // axis title\n axis.title(def.title || null);\n // axis title offset\n axis.titleOffset(def.titleOffset != null\n ? def.titleOffset : config.axis.titleOffset);\n // axis values\n axis.tickValues(def.values || null);\n // axis label formatting\n axis.tickFormat(def.format || null);\n // axis tick subdivision\n axis.tickSubdivide(def.subdivide || 0);\n // axis tick padding\n axis.tickPadding(def.tickPadding || config.axis.padding);\n\n // axis tick size(s)\n var size = [];\n if (def.tickSize !== undefined) {\n for (var i=0; i<3; ++i) size.push(def.tickSize);\n } else {\n var ts = config.axis.tickSize;\n size = [ts, ts, ts];\n }\n if (def.tickSizeMajor != null) size[0] = def.tickSizeMajor;\n if (def.tickSizeMinor != null) size[1] = def.tickSizeMinor;\n if (def.tickSizeEnd != null) size[2] = def.tickSizeEnd;\n if (size.length) {\n axis.tickSize.apply(axis, size);\n }\n\n // axis tick count\n axis.tickCount(def.ticks || config.axis.ticks);\n\n // style properties\n var p = def.properties;\n if (p && p.ticks) {\n axis.majorTickProperties(p.majorTicks\n ? dl.extend({}, p.ticks, p.majorTicks) : p.ticks);\n axis.minorTickProperties(p.minorTicks\n ? dl.extend({}, p.ticks, p.minorTicks) : p.ticks);\n } else {\n axis.majorTickProperties(p && p.majorTicks || {});\n axis.minorTickProperties(p && p.minorTicks || {});\n }\n axis.tickLabelProperties(p && p.labels || {});\n axis.titleProperties(p && p.title || {});\n axis.gridLineProperties(p && p.grid || {});\n axis.domainProperties(p && p.axis || {});\n}\n\nmodule.exports = axes;",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null);\n\nmodule.exports = function parseBg(bg) {\n // return null if input is null or undefined\n if (bg == null) return null;\n // run through d3 rgb to sanity check\n return d3.rgb(bg) + \"\"; \n};",
"var dl = require('datalib'),\n config = require('../util/config'),\n parseTransforms = require('./transforms'),\n parseModify = require('./modify');\n\nvar parseData = function(model, spec, callback) {\n var count = 0;\n\n function loaded(d) {\n return function(error, data) {\n if (error) {\n dl.error(\"LOADING FAILED: \" + d.url + \" \" + error);\n } else {\n model.data(d.name).values(dl.read(data, d.format));\n }\n if (--count === 0) callback();\n }\n }\n\n // process each data set definition\n (spec || []).forEach(function(d) {\n if (d.url) {\n count += 1;\n dl.load(dl.extend({url: d.url}, config.load), loaded(d));\n }\n parseData.datasource(model, d);\n });\n\n if (count === 0) setTimeout(callback, 1);\n return spec;\n};\n\nparseData.datasource = function(model, d) {\n var transform = (d.transform||[]).map(function(t) { return parseTransforms(model, t) }),\n mod = (d.modify||[]).map(function(m) { return parseModify(model, m, d) }),\n ds = model.data(d.name, mod.concat(transform));\n\n if (d.values) {\n ds.values(dl.read(d.values, d.format));\n } else if (d.source) {\n ds.source(d.source)\n .revises(ds.revises()) // If new ds revises, then it's origin must revise too.\n .addListener(ds); // Derived ds will be pulsed by its src rather than the model.\n model.removeListener(ds.pipeline()[0]); \n }\n\n return ds; \n};\n\nmodule.exports = parseData;\n",
"/*\n * Generated by PEG.js 0.8.0.\n *\n * http://pegjs.majda.cz/\n */\n\nfunction peg$subclass(child, parent) {\n function ctor() { this.constructor = child; }\n ctor.prototype = parent.prototype;\n child.prototype = new ctor();\n}\n\nfunction SyntaxError(message, expected, found, offset, line, column) {\n this.message = message;\n this.expected = expected;\n this.found = found;\n this.offset = offset;\n this.line = line;\n this.column = column;\n\n this.name = \"SyntaxError\";\n}\n\npeg$subclass(SyntaxError, Error);\n\nfunction parse(input) {\n var options = arguments.length > 1 ? arguments[1] : {},\n\n peg$FAILED = {},\n\n peg$startRuleFunctions = { start: peg$parsestart },\n peg$startRuleFunction = peg$parsestart,\n\n peg$c0 = peg$FAILED,\n peg$c1 = \",\",\n peg$c2 = { type: \"literal\", value: \",\", description: \"\\\",\\\"\" },\n peg$c3 = function(o, m) { return [o].concat(m) },\n peg$c4 = function(o) { return [o] },\n peg$c5 = \"[\",\n peg$c6 = { type: \"literal\", value: \"[\", description: \"\\\"[\\\"\" },\n peg$c7 = \"]\",\n peg$c8 = { type: \"literal\", value: \"]\", description: \"\\\"]\\\"\" },\n peg$c9 = \">\",\n peg$c10 = { type: \"literal\", value: \">\", description: \"\\\">\\\"\" },\n peg$c11 = function(f1, f2, o) { return {start: f1, end: f2, middle: o}},\n peg$c12 = [],\n peg$c13 = function(s, f) { return (s.filters = f), s },\n peg$c14 = function(s) { return s },\n peg$c15 = null,\n peg$c16 = function(t, e) { return { event: e, target: t } },\n peg$c17 = /^[:a-zA-z0-9_\\-]/,\n peg$c18 = { type: \"class\", value: \"[:a-zA-z0-9_\\\\-]\", description: \"[:a-zA-z0-9_\\\\-]\" },\n peg$c19 = function(s) { return { signal: s.join(\"\") }},\n peg$c20 = \"(\",\n peg$c21 = { type: \"literal\", value: \"(\", description: \"\\\"(\\\"\" },\n peg$c22 = \")\",\n peg$c23 = { type: \"literal\", value: \")\", description: \"\\\")\\\"\" },\n peg$c24 = function(m) { return { stream: m }},\n peg$c25 = \".\",\n peg$c26 = { type: \"literal\", value: \".\", description: \"\\\".\\\"\" },\n peg$c27 = \":\",\n peg$c28 = { type: \"literal\", value: \":\", description: \"\\\":\\\"\" },\n peg$c29 = function(c) { return { type:'class', value: c } },\n peg$c30 = \"#\",\n peg$c31 = { type: \"literal\", value: \"#\", description: \"\\\"#\\\"\" },\n peg$c32 = function(id) { return { type:'id', value: id } },\n peg$c33 = \"mousedown\",\n peg$c34 = { type: \"literal\", value: \"mousedown\", description: \"\\\"mousedown\\\"\" },\n peg$c35 = \"mouseup\",\n peg$c36 = { type: \"literal\", value: \"mouseup\", description: \"\\\"mouseup\\\"\" },\n peg$c37 = \"click\",\n peg$c38 = { type: \"literal\", value: \"click\", description: \"\\\"click\\\"\" },\n peg$c39 = \"dblclick\",\n peg$c40 = { type: \"literal\", value: \"dblclick\", description: \"\\\"dblclick\\\"\" },\n peg$c41 = \"wheel\",\n peg$c42 = { type: \"literal\", value: \"wheel\", description: \"\\\"wheel\\\"\" },\n peg$c43 = \"keydown\",\n peg$c44 = { type: \"literal\", value: \"keydown\", description: \"\\\"keydown\\\"\" },\n peg$c45 = \"keypress\",\n peg$c46 = { type: \"literal\", value: \"keypress\", description: \"\\\"keypress\\\"\" },\n peg$c47 = \"keyup\",\n peg$c48 = { type: \"literal\", value: \"keyup\", description: \"\\\"keyup\\\"\" },\n peg$c49 = \"mousewheel\",\n peg$c50 = { type: \"literal\", value: \"mousewheel\", description: \"\\\"mousewheel\\\"\" },\n peg$c51 = \"mousemove\",\n peg$c52 = { type: \"literal\", value: \"mousemove\", description: \"\\\"mousemove\\\"\" },\n peg$c53 = \"mouseout\",\n peg$c54 = { type: \"literal\", value: \"mouseout\", description: \"\\\"mouseout\\\"\" },\n peg$c55 = \"mouseover\",\n peg$c56 = { type: \"literal\", value: \"mouseover\", description: \"\\\"mouseover\\\"\" },\n peg$c57 = \"mouseenter\",\n peg$c58 = { type: \"literal\", value: \"mouseenter\", description: \"\\\"mouseenter\\\"\" },\n peg$c59 = \"touchstart\",\n peg$c60 = { type: \"literal\", value: \"touchstart\", description: \"\\\"touchstart\\\"\" },\n peg$c61 = \"touchmove\",\n peg$c62 = { type: \"literal\", value: \"touchmove\", description: \"\\\"touchmove\\\"\" },\n peg$c63 = \"touchend\",\n peg$c64 = { type: \"literal\", value: \"touchend\", description: \"\\\"touchend\\\"\" },\n peg$c65 = function(field) { return field },\n peg$c66 = /^['\"a-zA-Z0-9_.><=! \\t\\-]/,\n peg$c67 = { type: \"class\", value: \"['\\\"a-zA-Z0-9_.><=! \\\\t\\\\-]\", description: \"['\\\"a-zA-Z0-9_.><=! \\\\t\\\\-]\" },\n peg$c68 = function(v) { return v.join(\"\") },\n peg$c69 = /^[ \\t\\r\\n]/,\n peg$c70 = { type: \"class\", value: \"[ \\\\t\\\\r\\\\n]\", description: \"[ \\\\t\\\\r\\\\n]\" },\n\n peg$currPos = 0,\n peg$reportedPos = 0,\n peg$cachedPos = 0,\n peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },\n peg$maxFailPos = 0,\n peg$maxFailExpected = [],\n peg$silentFails = 0,\n\n peg$result;\n\n if (\"startRule\" in options) {\n if (!(options.startRule in peg$startRuleFunctions)) {\n throw new Error(\"Can't start parsing from rule \\\"\" + options.startRule + \"\\\".\");\n }\n\n peg$startRuleFunction = peg$startRuleFunctions[options.startRule];\n }\n\n function text() {\n return input.substring(peg$reportedPos, peg$currPos);\n }\n\n function offset() {\n return peg$reportedPos;\n }\n\n function line() {\n return peg$computePosDetails(peg$reportedPos).line;\n }\n\n function column() {\n return peg$computePosDetails(peg$reportedPos).column;\n }\n\n function expected(description) {\n throw peg$buildException(\n null,\n [{ type: \"other\", description: description }],\n peg$reportedPos\n );\n }\n\n function error(message) {\n throw peg$buildException(message, null, peg$reportedPos);\n }\n\n function peg$computePosDetails(pos) {\n function advance(details, startPos, endPos) {\n var p, ch;\n\n for (p = startPos; p < endPos; p++) {\n ch = input.charAt(p);\n if (ch === \"\\n\") {\n if (!details.seenCR) { details.line++; }\n details.column = 1;\n details.seenCR = false;\n } else if (ch === \"\\r\" || ch === \"\\u2028\" || ch === \"\\u2029\") {\n details.line++;\n details.column = 1;\n details.seenCR = true;\n } else {\n details.column++;\n details.seenCR = false;\n }\n }\n }\n\n if (peg$cachedPos !== pos) {\n if (peg$cachedPos > pos) {\n peg$cachedPos = 0;\n peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };\n }\n advance(peg$cachedPosDetails, peg$cachedPos, pos);\n peg$cachedPos = pos;\n }\n\n return peg$cachedPosDetails;\n }\n\n function peg$fail(expected) {\n if (peg$currPos < peg$maxFailPos) { return; }\n\n if (peg$currPos > peg$maxFailPos) {\n peg$maxFailPos = peg$currPos;\n peg$maxFailExpected = [];\n }\n\n peg$maxFailExpected.push(expected);\n }\n\n function peg$buildException(message, expected, pos) {\n function cleanupExpected(expected) {\n var i = 1;\n\n expected.sort(function(a, b) {\n if (a.description < b.description) {\n return -1;\n } else if (a.description > b.description) {\n return 1;\n } else {\n return 0;\n }\n });\n\n while (i < expected.length) {\n if (expected[i - 1] === expected[i]) {\n expected.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n\n function buildMessage(expected, found) {\n function stringEscape(s) {\n function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }\n\n return s\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\x08/g, '\\\\b')\n .replace(/\\t/g, '\\\\t')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\f/g, '\\\\f')\n .replace(/\\r/g, '\\\\r')\n .replace(/[\\x00-\\x07\\x0B\\x0E\\x0F]/g, function(ch) { return '\\\\x0' + hex(ch); })\n .replace(/[\\x10-\\x1F\\x80-\\xFF]/g, function(ch) { return '\\\\x' + hex(ch); })\n .replace(/[\\u0180-\\u0FFF]/g, function(ch) { return '\\\\u0' + hex(ch); })\n .replace(/[\\u1080-\\uFFFF]/g, function(ch) { return '\\\\u' + hex(ch); });\n }\n\n var expectedDescs = new Array(expected.length),\n expectedDesc, foundDesc, i;\n\n for (i = 0; i < expected.length; i++) {\n expectedDescs[i] = expected[i].description;\n }\n\n expectedDesc = expected.length > 1\n ? expectedDescs.slice(0, -1).join(\", \")\n + \" or \"\n + expectedDescs[expected.length - 1]\n : expectedDescs[0];\n\n foundDesc = found ? \"\\\"\" + stringEscape(found) + \"\\\"\" : \"end of input\";\n\n return \"Expected \" + expectedDesc + \" but \" + foundDesc + \" found.\";\n }\n\n var posDetails = peg$computePosDetails(pos),\n found = pos < input.length ? input.charAt(pos) : null;\n\n if (expected !== null) {\n cleanupExpected(expected);\n }\n\n return new SyntaxError(\n message !== null ? message : buildMessage(expected, found),\n expected,\n found,\n pos,\n posDetails.line,\n posDetails.column\n );\n }\n\n function peg$parsestart() {\n var s0;\n\n s0 = peg$parsemerged();\n\n return s0;\n }\n\n function peg$parsemerged() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n s1 = peg$parseordered();\n if (s1 !== peg$FAILED) {\n s2 = peg$parsesep();\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 44) {\n s3 = peg$c1;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c2); }\n }\n if (s3 !== peg$FAILED) {\n s4 = peg$parsesep();\n if (s4 !== peg$FAILED) {\n s5 = peg$parsemerged();\n if (s5 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c3(s1, s5);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseordered();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c4(s1);\n }\n s0 = s1;\n }\n\n return s0;\n }\n\n function peg$parseordered() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 91) {\n s1 = peg$c5;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c6); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parsesep();\n if (s2 !== peg$FAILED) {\n s3 = peg$parsefiltered();\n if (s3 !== peg$FAILED) {\n s4 = peg$parsesep();\n if (s4 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 44) {\n s5 = peg$c1;\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c2); }\n }\n if (s5 !== peg$FAILED) {\n s6 = peg$parsesep();\n if (s6 !== peg$FAILED) {\n s7 = peg$parsefiltered();\n if (s7 !== peg$FAILED) {\n s8 = peg$parsesep();\n if (s8 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 93) {\n s9 = peg$c7;\n peg$currPos++;\n } else {\n s9 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c8); }\n }\n if (s9 !== peg$FAILED) {\n s10 = peg$parsesep();\n if (s10 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 62) {\n s11 = peg$c9;\n peg$currPos++;\n } else {\n s11 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c10); }\n }\n if (s11 !== peg$FAILED) {\n s12 = peg$parsesep();\n if (s12 !== peg$FAILED) {\n s13 = peg$parseordered();\n if (s13 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c11(s3, s7, s13);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parsefiltered();\n }\n\n return s0;\n }\n\n function peg$parsefiltered() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$parsestream();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parsefilter();\n if (s3 !== peg$FAILED) {\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parsefilter();\n }\n } else {\n s2 = peg$c0;\n }\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c13(s1, s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parsestream();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c14(s1);\n }\n s0 = s1;\n }\n\n return s0;\n }\n\n function peg$parsestream() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$parseclass();\n if (s1 === peg$FAILED) {\n s1 = peg$parseid();\n }\n if (s1 === peg$FAILED) {\n s1 = peg$c15;\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseeventType();\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c16(s1, s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = [];\n if (peg$c17.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c18); }\n }\n if (s2 !== peg$FAILED) {\n while (s2 !== peg$FAILED) {\n s1.push(s2);\n if (peg$c17.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c18); }\n }\n }\n } else {\n s1 = peg$c0;\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c19(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 40) {\n s1 = peg$c20;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c21); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parsemerged();\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s3 = peg$c22;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c23); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c24(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n }\n }\n\n return s0;\n }\n\n function peg$parseclass() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 46) {\n s1 = peg$c25;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c26); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parsevalue();\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 58) {\n s3 = peg$c27;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c28); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c29(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseid() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 35) {\n s1 = peg$c30;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c31); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parsevalue();\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 58) {\n s3 = peg$c27;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c28); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c32(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseeventType() {\n var s0;\n\n if (input.substr(peg$currPos, 9) === peg$c33) {\n s0 = peg$c33;\n peg$currPos += 9;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c34); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 7) === peg$c35) {\n s0 = peg$c35;\n peg$currPos += 7;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c36); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 5) === peg$c37) {\n s0 = peg$c37;\n peg$currPos += 5;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c38); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 8) === peg$c39) {\n s0 = peg$c39;\n peg$currPos += 8;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c40); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 5) === peg$c41) {\n s0 = peg$c41;\n peg$currPos += 5;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c42); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 7) === peg$c43) {\n s0 = peg$c43;\n peg$currPos += 7;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c44); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 8) === peg$c45) {\n s0 = peg$c45;\n peg$currPos += 8;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c46); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 5) === peg$c47) {\n s0 = peg$c47;\n peg$currPos += 5;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c48); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 10) === peg$c49) {\n s0 = peg$c49;\n peg$currPos += 10;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c50); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 9) === peg$c51) {\n s0 = peg$c51;\n peg$currPos += 9;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c52); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 8) === peg$c53) {\n s0 = peg$c53;\n peg$currPos += 8;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c54); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 9) === peg$c55) {\n s0 = peg$c55;\n peg$currPos += 9;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c56); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 10) === peg$c57) {\n s0 = peg$c57;\n peg$currPos += 10;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c58); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 10) === peg$c59) {\n s0 = peg$c59;\n peg$currPos += 10;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c60); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 9) === peg$c61) {\n s0 = peg$c61;\n peg$currPos += 9;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c62); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 8) === peg$c63) {\n s0 = peg$c63;\n peg$currPos += 8;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c64); }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n return s0;\n }\n\n function peg$parsefilter() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 91) {\n s1 = peg$c5;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c6); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parsevalue();\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 93) {\n s3 = peg$c7;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c8); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c65(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parsevalue() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n s1 = [];\n if (peg$c66.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c67); }\n }\n if (s2 !== peg$FAILED) {\n while (s2 !== peg$FAILED) {\n s1.push(s2);\n if (peg$c66.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c67); }\n }\n }\n } else {\n s1 = peg$c0;\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c68(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parsesep() {\n var s0, s1;\n\n s0 = [];\n if (peg$c69.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c70); }\n }\n while (s1 !== peg$FAILED) {\n s0.push(s1);\n if (peg$c69.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c70); }\n }\n }\n\n return s0;\n }\n\n peg$result = peg$startRuleFunction();\n\n if (peg$result !== peg$FAILED && peg$currPos === input.length) {\n return peg$result;\n } else {\n if (peg$result !== peg$FAILED && peg$currPos < input.length) {\n peg$fail({ type: \"end\", description: \"end of input\" });\n }\n\n throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);\n }\n}\n\nmodule.exports = {\n SyntaxError: SyntaxError,\n parse: parse\n};",
"var dl = require('datalib'),\n expression = require('../expression');\n\nvar expr = (function() {\n var parse = expression.parse;\n var codegen = expression.code({\n idWhiteList: ['d', 'e', 'i', 'p', 'sg']\n });\n\n return function(expr) { \n var value = codegen(parse(expr));\n value.fn = Function('d', 'e', 'i', 'p', 'sg',\n '\"use strict\"; return (' + value.fn + ');');\n return value;\n };\n})();\n\nexpr.eval = function(graph, fn, d, e, i, p, sg) {\n sg = graph.signalValues(dl.array(sg));\n return fn.call(null, d, e, i, p, sg);\n};\n\nmodule.exports = expr;",
"var dl = require('datalib'),\n config = require('../util/config'),\n C = require('../util/constants');\n\nmodule.exports = function parseInteractors(model, spec, defFactory) {\n var count = 0,\n sg = {}, pd = {}, mk = {},\n signals = [], predicates = [];\n\n function loaded(i) {\n return function(error, data) {\n if (error) {\n dl.error(\"LOADING FAILED: \" + i.url);\n } else {\n var def = dl.isObject(data) ? data : JSON.parse(data);\n interactor(i.name, def);\n }\n if (--count == 0) inject();\n }\n }\n\n function interactor(name, def) {\n sg = {}, pd = {};\n if (def.signals) signals.push.apply(signals, nsSignals(name, def.signals));\n if (def.predicates) predicates.push.apply(predicates, nsPredicates(name, def.predicates));\n nsMarks(name, def.marks);\n }\n\n function inject() {\n if (dl.keys(mk).length > 0) injectMarks(spec.marks);\n spec.signals = dl.array(spec.signals);\n spec.predicates = dl.array(spec.predicates);\n spec.signals.unshift.apply(spec.signals, signals);\n spec.predicates.unshift.apply(spec.predicates, predicates);\n defFactory();\n }\n\n function injectMarks(marks) {\n var m, r, i, len;\n marks = dl.array(marks);\n\n for(i = 0, len = marks.length; i < len; i++) {\n m = marks[i];\n if (r = mk[m.type]) {\n marks[i] = dl.duplicate(r);\n if (m.from) marks[i].from = m.from;\n if (m.properties) {\n [C.ENTER, C.UPDATE, C.EXIT].forEach(function(p) {\n marks[i].properties[p] = dl.extend(r.properties[p], m.properties[p]);\n });\n }\n } else if (m.marks) { // TODO how to override properties of nested marks?\n injectMarks(m.marks);\n }\n } \n }\n\n function ns(n, s) { \n if (dl.isString(s)) {\n return s + \"_\" + n;\n } else {\n dl.keys(s).forEach(function(x) { \n var regex = new RegExp('\\\\b'+x+'\\\\b', \"g\");\n n = n.replace(regex, s[x]) \n });\n return n;\n }\n }\n\n function nsSignals(name, signals) {\n signals = dl.array(signals);\n // Two passes to ns all signals, and then overwrite their definitions\n // in case signal order is important.\n signals.forEach(function(s) { s.name = sg[s.name] = ns(s.name, name); });\n signals.forEach(function(s) {\n (s.streams || []).forEach(function(t) {\n t.type = ns(t.type, sg);\n t.expr = ns(t.expr, sg);\n });\n });\n return signals;\n }\n\n function nsPredicates(name, predicates) {\n predicates = dl.array(predicates);\n predicates.forEach(function(p) {\n p.name = pd[p.name] = ns(p.name, name);\n\n [p.operands, p.range].forEach(function(x) {\n (x || []).forEach(function(o) {\n if (o.signal) o.signal = ns(o.signal, sg);\n else if (o.predicate) nsOperand(o);\n })\n });\n\n }); \n return predicates; \n }\n\n function nsOperand(o) {\n o.predicate = pd[o.predicate];\n dl.keys(o.input).forEach(function(k) {\n var i = o.input[k];\n if (i.signal) i.signal = ns(i.signal, sg);\n });\n }\n\n function nsMarks(name, marks) {\n (marks || []).forEach(function(m) { \n nsProperties(m.properties.enter);\n nsProperties(m.properties.update);\n nsProperties(m.properties.exit);\n mk[ns(m.name, name)] = m; \n });\n }\n\n function nsProperties(propset) {\n dl.keys(propset).forEach(function(k) {\n var p = propset[k];\n if (p.signal) p.signal = ns(p.signal, sg);\n else if (p.rule) {\n p.rule.forEach(function(r) { \n if (r.signal) r.signal = ns(r.signal, sg);\n if (r.predicate) nsOperand(r); \n });\n }\n });\n }\n\n (spec.interactors || []).forEach(function(i) {\n if (i.url) {\n count += 1;\n dl.load(dl.extend({url: i.url}, config.load), loaded(i));\n }\n });\n\n if (count === 0) setTimeout(inject, 1);\n return spec;\n}",
"var lgnd = require('../scene/legend'),\n config = require('../util/config');\n\nfunction legends(model, spec, legends, group) {\n (spec || []).forEach(function(def, index) {\n legends[index] = legends[index] || lgnd(model);\n legend(def, index, legends[index], group);\n });\n};\n\nfunction legend(def, index, legend, group) {\n // legend scales\n legend.size (def.size ? group.scale(def.size) : null);\n legend.shape (def.shape ? group.scale(def.shape) : null);\n legend.fill (def.fill ? group.scale(def.fill) : null);\n legend.stroke(def.stroke ? group.scale(def.stroke) : null);\n\n // legend orientation\n if (def.orient) legend.orient(def.orient);\n\n // legend offset\n if (def.offset != null) legend.offset(def.offset);\n\n // legend title\n legend.title(def.title || null);\n\n // legend values\n legend.values(def.values || null);\n\n // legend label formatting\n legend.format(def.format !== undefined ? def.format : null);\n\n // style properties\n var p = def.properties;\n legend.titleProperties(p && p.title || {});\n legend.labelProperties(p && p.labels || {});\n legend.legendProperties(p && p.legend || {});\n legend.symbolProperties(p && p.symbols || {});\n legend.gradientProperties(p && p.gradient || {});\n}\n\nmodule.exports = legends;",
"var dl = require('datalib'),\n parseProperties = require('./properties');\n\nmodule.exports = function parseMark(model, mark) {\n var props = mark.properties,\n group = mark.marks;\n\n // parse mark property definitions\n dl.keys(props).forEach(function(k) {\n props[k] = parseProperties(model, mark.type, props[k]);\n });\n\n // parse delay function\n if (mark.delay) {\n mark.delay = parseProperties(model, mark.type, {delay: mark.delay});\n }\n\n // recurse if group type\n if (group) {\n mark.marks = group.map(function(g) { return parseMark(model, g); });\n }\n \n return mark;\n};",
"var parseMark = require('./mark');\n\nmodule.exports = function(model, spec, width, height) {\n return {\n type: \"group\",\n width: width,\n height: height,\n scales: spec.scales || [],\n axes: spec.axes || [],\n legends: spec.legends || [],\n marks: (spec.marks || []).map(function(m) { return parseMark(model, m); })\n };\n};",
"var dl = require('datalib'),\n Node = require('../dataflow/Node'),\n tuple = require('../dataflow/tuple'),\n debug = require('../util/debug'),\n C = require('../util/constants');\n\nvar filter = function(field, value, src, dest) {\n for(var i = src.length-1; i >= 0; --i) {\n if(src[i][field] == value)\n dest.push.apply(dest, src.splice(i, 1));\n }\n};\n\nmodule.exports = function parseModify(model, def, ds) {\n var signal = def.signal ? dl.field(def.signal) : null, \n signalName = signal ? signal[0] : null,\n predicate = def.predicate ? model.predicate(def.predicate.name || def.predicate) : null,\n reeval = (predicate === null),\n node = new Node(model).router(def.type === C.CLEAR);\n\n node.evaluate = function(input) {\n if(predicate !== null) { // TODO: predicate args\n var db = model.dataValues(predicate.data||[]);\n reeval = predicate.call(predicate, {}, db, model.signalValues(predicate.signals||[]), model._predicates);\n }\n\n debug(input, [def.type+\"ing\", reeval]);\n if(!reeval) return input;\n\n var datum = {}, \n value = signal ? model.signalRef(def.signal) : null,\n d = model.data(ds.name),\n prev = d.revises() ? null : undefined,\n t = null;\n\n datum[def.field] = value;\n\n // We have to modify ds._data so that subsequent pulses contain\n // our dynamic data. W/o modifying ds._data, only the output\n // collector will contain dynamic tuples. \n if(def.type === C.ADD) {\n t = tuple.ingest(datum, prev);\n input.add.push(t);\n d._data.push(t);\n } else if(def.type === C.REMOVE) {\n filter(def.field, value, input.add, input.rem);\n filter(def.field, value, input.mod, input.rem);\n d._data = d._data.filter(function(x) { return x[def.field] !== value });\n } else if(def.type === C.TOGGLE) {\n var add = [], rem = [];\n filter(def.field, value, input.rem, add);\n filter(def.field, value, input.add, rem);\n filter(def.field, value, input.mod, rem);\n if(add.length == 0 && rem.length == 0) add.push(tuple.ingest(datum));\n\n input.add.push.apply(input.add, add);\n d._data.push.apply(d._data, add);\n input.rem.push.apply(input.rem, rem);\n d._data = d._data.filter(function(x) { return rem.indexOf(x) === -1 });\n } else if(def.type === C.CLEAR) {\n input.rem.push.apply(input.rem, input.add);\n input.rem.push.apply(input.rem, input.mod);\n input.add = [];\n input.mod = [];\n d._data = [];\n } \n\n input.fields[def.field] = 1;\n return input;\n };\n\n if(signalName) node.dependency(C.SIGNALS, signalName);\n if(predicate) node.dependency(C.SIGNALS, predicate.signals);\n \n return node;\n}",
"var dl = require('datalib');\n\nmodule.exports = function parsePadding(pad) {\n if (pad == null) return \"auto\";\n else if (dl.isString(pad)) return pad===\"strict\" ? \"strict\" : \"auto\";\n else if (dl.isObject(pad)) return pad;\n var p = dl.isNumber(pad) ? pad : 20;\n return {top:p, left:p, right:p, bottom:p};\n}",
"var dl = require('datalib');\n\nmodule.exports = function parsePredicate(model, spec) {\n var types = {\n '=': parseComparator,\n '==': parseComparator,\n '!=': parseComparator,\n '>': parseComparator,\n '>=': parseComparator,\n '<': parseComparator,\n '<=': parseComparator,\n 'and': parseLogical,\n '&&': parseLogical,\n 'or': parseLogical,\n '||': parseLogical,\n 'in': parseIn\n };\n\n function parseSignal(signal, signals) {\n var s = dl.field(signal),\n code = \"signals[\"+s.map(dl.str).join(\"][\")+\"]\";\n signals[s.shift()] = 1;\n return code;\n };\n\n function parseOperands(operands) {\n var decl = [], defs = [],\n signals = {}, db = {};\n\n dl.array(operands).forEach(function(o, i) {\n var signal, name = \"o\"+i, def = \"\";\n \n if(o.value !== undefined) def = dl.str(o.value);\n else if(o.arg) def = \"args[\"+dl.str(o.arg)+\"]\";\n else if(o.signal) def = parseSignal(o.signal, signals);\n else if(o.predicate) {\n var ref = o.predicate,\n predName = ref && (ref.name || ref),\n pred = model.predicate(predName),\n p = \"predicates[\"+dl.str(predName)+\"]\";\n\n pred.signals.forEach(function(s) { signals[s] = 1; });\n pred.data.forEach(function(d) { db[d] = 1 });\n\n if(dl.isObject(ref)) {\n dl.keys(ref).forEach(function(k) {\n if(k === \"name\") return;\n var i = ref[k], signal;\n def += \"args[\"+dl.str(k)+\"] = \";\n if(i.signal) def += parseSignal(i.signal, signals);\n else if(i.arg) def += \"args[\"+dl.str(i.arg)+\"]\";\n def+=\", \";\n }); \n } \n\n def+= p+\".call(\"+p+\", args, db, signals, predicates)\";\n }\n\n decl.push(name);\n defs.push(name+\"=(\"+def+\")\");\n });\n\n return {\n code: \"var \" + decl.join(\", \") + \";\\n\" + defs.join(\";\\n\") + \";\\n\",\n signals: dl.keys(signals),\n data: dl.keys(db)\n }\n };\n\n function parseComparator(spec) {\n var ops = parseOperands(spec.operands);\n if(spec.type == '=') spec.type = '==';\n\n return {\n code: ops.code + \"return \" + [\"o0\", \"o1\"].join(spec.type) + \";\",\n signals: ops.signals,\n data: ops.data\n };\n };\n\n function parseLogical(spec) {\n var ops = parseOperands(spec.operands),\n o = [], i = 0, len = spec.operands.length;\n\n while(o.push(\"o\"+i++)<len);\n if(spec.type == 'and') spec.type = '&&';\n else if(spec.type == 'or') spec.type = '||';\n\n return {\n code: ops.code + \"return \" + o.join(spec.type) + \";\",\n signals: ops.signals,\n data: ops.data\n };\n };\n\n function parseIn(spec) {\n var o = [spec.item], code = \"\";\n if(spec.range) o.push.apply(o, spec.range);\n if(spec.scale) {\n code = parseScale(spec.scale, o);\n }\n\n var ops = parseOperands(o);\n code = ops.code + code;\n\n if(spec.data) {\n var field = dl.field(spec.field).map(dl.str);\n code += \"var where = function(d) { return d[\"+field.join(\"][\")+\"] == o0 };\\n\";\n code += \"return db[\"+dl.str(spec.data)+\"].filter(where).length > 0;\";\n } else if(spec.range) {\n // TODO: inclusive/exclusive range?\n // TODO: inverting ordinal scales\n if(spec.scale) code += \"o1 = scale(o1);\\no2 = scale(o2);\\n\";\n code += \"return o1 < o2 ? o1 <= o0 && o0 <= o2 : o2 <= o0 && o0 <= o1\";\n }\n\n return {\n code: code, \n signals: ops.signals, \n data: ops.data.concat(spec.data ? [spec.data] : [])\n };\n };\n\n // Populate ops such that ultimate scale/inversion function will be in `scale` var. \n function parseScale(spec, ops) {\n var code = \"var scale = \", \n idx = ops.length;\n\n if(dl.isString(spec)) {\n ops.push({ value: spec });\n code += \"this.root().scale(o\"+idx+\")\";\n } else if(spec.arg) { // Scale function is being passed as an arg\n ops.push(spec);\n code += \"o\"+idx;\n } else if(spec.name) { // Full scale parameter {name: ..}\n ops.push(dl.isString(spec.name) ? {value: spec.name} : spec.name);\n code += \"(this.isFunction(o\"+idx+\") ? o\"+idx+\" : \";\n if(spec.scope) {\n ops.push(spec.scope);\n code += \"(o\"+(idx+1)+\".scale || this.root().scale)(o\"+idx+\")\";\n } else {\n code += \"this.root().scale(o\"+idx+\")\";\n }\n code += \")\"\n }\n\n if(spec.invert === true) { // Allow spec.invert.arg?\n code += \".invert\"\n }\n\n return code+\";\\n\";\n }\n\n (spec || []).forEach(function(s) {\n var parse = types[s.type](s),\n pred = Function(\"args\", \"db\", \"signals\", \"predicates\", parse.code);\n pred.root = function() { return model.scene().items[0] }; // For global scales\n pred.isFunction = dl.isFunction;\n pred.signals = parse.signals;\n pred.data = parse.data;\n model.predicate(s.name, pred);\n });\n\n return spec;\n}",
"var dl = require('datalib'),\n d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n tuple = require('../dataflow/tuple'),\n config = require('../util/config');\n\nvar DEPS = [\"signals\", \"scales\", \"data\", \"fields\"];\n\nfunction compile(model, mark, spec) {\n var code = \"\",\n names = dl.keys(spec),\n i, len, name, ref, vars = {}, \n deps = {\n signals: {},\n scales: {},\n data: {},\n fields: {},\n reflow: false\n };\n \n code += \"var o = trans ? {} : item;\\n\"\n \n for (i=0, len=names.length; i<len; ++i) {\n ref = spec[name = names[i]];\n code += (i > 0) ? \"\\n \" : \" \";\n if(ref.rule) {\n ref = rule(model, name, ref.rule);\n code += \"\\n \" + ref.code\n } else {\n ref = valueRef(name, ref);\n code += \"this.tpl.set(o, \"+dl.str(name)+\", \"+ref.val+\");\";\n }\n\n vars[name] = true;\n DEPS.forEach(function(p) {\n if(ref[p] != null) dl.array(ref[p]).forEach(function(k) { deps[p][k] = 1 });\n });\n deps.reflow = deps.reflow || ref.reflow;\n }\n\n if (vars.x2) {\n if (vars.x) {\n code += \"\\n if (o.x > o.x2) { \"\n + \"var t = o.x;\"\n + \"this.tpl.set(o, 'x', o.x2);\"\n + \"this.tpl.set(o, 'x2', t); \"\n + \"};\";\n code += \"\\n this.tpl.set(o, 'width', (o.x2 - o.x));\";\n } else if (vars.width) {\n code += \"\\n this.tpl.set(o, 'x', (o.x2 - o.width));\";\n } else {\n code += \"\\n this.tpl.set(o, 'x', o.x2);\"\n }\n }\n\n if (vars.xc) {\n if (vars.width) {\n code += \"\\n this.tpl.set(o, 'x', (o.xc - o.width/2));\";\n } else {\n code += \"\\n this.tpl.set(o, 'x', o.xc);\";\n }\n }\n\n if (vars.y2) {\n if (vars.y) {\n code += \"\\n if (o.y > o.y2) { \"\n + \"var t = o.y;\"\n + \"this.tpl.set(o, 'y', o.y2);\"\n + \"this.tpl.set(o, 'y2', t);\"\n + \"};\";\n code += \"\\n this.tpl.set(o, 'height', (o.y2 - o.y));\";\n } else if (vars.height) {\n code += \"\\n this.tpl.set(o, 'y', (o.y2 - o.height));\";\n } else {\n code += \"\\n this.tpl.set(o, 'y', o.y2);\"\n }\n }\n\n if (vars.yc) {\n if (vars.height) {\n code += \"\\n this.tpl.set(o, 'y', (o.yc - o.height/2));\";\n } else {\n code += \"\\n this.tpl.set(o, 'y', o.yc);\";\n }\n }\n \n if (hasPath(mark, vars)) code += \"\\n item.touch();\";\n code += \"\\n if (trans) trans.interpolate(item, o);\";\n\n try {\n var encoder = Function(\"item\", \"group\", \"trans\", \"db\", \n \"signals\", \"predicates\", code);\n encoder.tpl = tuple;\n encoder.util = dl;\n encoder.d3 = d3; // For color spaces\n return {\n encode: encoder,\n signals: dl.keys(deps.signals),\n scales: dl.keys(deps.scales),\n data: dl.keys(deps.data),\n fields: dl.keys(deps.fields),\n reflow: deps.reflow\n }\n } catch (e) {\n dl.error(e);\n dl.log(code);\n }\n}\n\nfunction hasPath(mark, vars) {\n return vars.path ||\n ((mark===\"area\" || mark===\"line\") &&\n (vars.x || vars.x2 || vars.width ||\n vars.y || vars.y2 || vars.height ||\n vars.tension || vars.interpolate));\n}\n\nfunction rule(model, name, rules) {\n var signals = [], scales = [], db = [],\n inputs = [], code = \"\";\n\n (rules||[]).forEach(function(r, i) {\n var def = r.predicate,\n predName = def && (def.name || def),\n pred = model.predicate(predName),\n p = \"predicates[\"+dl.str(predName)+\"]\",\n input = [], args = name+\"_arg\"+i,\n ref;\n\n if(dl.isObject(def)) {\n dl.keys(def).forEach(function(k) {\n if(k === \"name\") return;\n var ref = valueRef(i, def[k]);\n input.push(dl.str(k)+\": \"+ref.val);\n if(ref.signals) signals.push.apply(signals, dl.array(ref.signals));\n if(ref.scales) scales.push.apply(scales, dl.array(ref.scales));\n });\n }\n\n ref = valueRef(name, r);\n if(ref.signals) signals.push.apply(signals, dl.array(ref.signals));\n if(ref.scales) scales.push.apply(scales, dl.array(ref.scales));\n\n if(predName) {\n signals.push.apply(signals, pred.signals);\n db.push.apply(db, pred.data);\n inputs.push(args+\" = {\"+input.join(', ')+\"}\");\n code += \"if(\"+p+\".call(\"+p+\",\"+args+\", db, signals, predicates)) {\\n\" +\n \" this.tpl.set(o, \"+dl.str(name)+\", \"+ref.val+\");\\n\";\n code += rules[i+1] ? \" } else \" : \" }\";\n } else {\n code += \"{\\n\" + \n \" this.tpl.set(o, \"+dl.str(name)+\", \"+ref.val+\");\\n\"+\n \" }\";\n }\n });\n\n code = \"var \" + inputs.join(\",\\n \") + \";\\n \" + code;\n return {code: code, signals: signals, scales: scales, data: db};\n}\n\nfunction valueRef(name, ref) {\n if (ref == null) return null;\n\n if (name===\"fill\" || name===\"stroke\") {\n if (ref.c) {\n return colorRef(\"hcl\", ref.h, ref.c, ref.l);\n } else if (ref.h || ref.s) {\n return colorRef(\"hsl\", ref.h, ref.s, ref.l);\n } else if (ref.l || ref.a) {\n return colorRef(\"lab\", ref.l, ref.a, ref.b);\n } else if (ref.r || ref.g || ref.b) {\n return colorRef(\"rgb\", ref.r, ref.g, ref.b);\n }\n }\n\n // initialize value\n var val = null, scale = null, \n sgRef = {}, fRef = {}, sRef = {},\n signals = [], fields = [], reflow = false;\n\n if (ref.template !== undefined) {\n val = dl.template.source(ref.template, \"item.datum\");\n }\n\n if (ref.value !== undefined) {\n val = dl.str(ref.value);\n }\n\n if (ref.signal !== undefined) {\n sgRef = dl.field(ref.signal);\n val = \"signals[\"+sgRef.map(dl.str).join(\"][\")+\"]\"; \n signals.push(sgRef.shift());\n }\n\n if(ref.field !== undefined) {\n ref.field = dl.isString(ref.field) ? {datum: ref.field} : ref.field;\n fRef = fieldRef(ref.field);\n val = fRef.val;\n }\n\n if (ref.scale !== undefined) {\n sRef = scaleRef(ref.scale);\n scale = sRef.val;\n\n // run through scale function if val specified.\n // if no val, scale function is predicate arg.\n if(val !== null || ref.band || ref.mult || ref.offset) {\n val = scale + (ref.band ? \".rangeBand()\" : \n \"(\"+(val !== null ? val : \"item.datum.data\")+\")\");\n } else {\n val = scale;\n }\n }\n \n // multiply, offset, return value\n val = \"(\" + (ref.mult?(dl.number(ref.mult)+\" * \"):\"\") + val + \")\"\n + (ref.offset ? \" + \" + dl.number(ref.offset) : \"\");\n\n // Collate dependencies\n return {\n val: val,\n signals: signals.concat(dl.array(fRef.signals)).concat(dl.array(sRef.signals)),\n fields: fields.concat(dl.array(fRef.fields)).concat(dl.array(sRef.fields)),\n scales: ref.scale ? (ref.scale.name || ref.scale) : null, // TODO: connect sRef'd scale?\n reflow: reflow || fRef.reflow || sRef.reflow\n };\n}\n\nfunction colorRef(type, x, y, z) {\n var xx = x ? valueRef(\"\", x) : config.color[type][0],\n yy = y ? valueRef(\"\", y) : config.color[type][1],\n zz = z ? valueRef(\"\", z) : config.color[type][2]\n signals = [], scales = [];\n\n [xx, yy, zz].forEach(function(v) {\n if(v.signals) signals.push.apply(signals, v.signals);\n if(v.scales) scales.push(v.scales);\n });\n\n return {\n val: \"(this.d3.\" + type + \"(\" + [xx.val, yy.val, zz.val].join(\",\") + ') + \"\")',\n signals: signals,\n scales: scales\n };\n}\n\n// {field: {datum: \"foo\"} } -> item.datum.foo\n// {field: {group: \"foo\"} } -> group.foo\n// {field: {parent: \"foo\"} } -> group.datum.foo\nfunction fieldRef(ref) {\n if(dl.isString(ref)) {\n return {val: dl.field(ref).map(dl.str).join(\"][\")};\n } \n\n // Resolve nesting/parent lookups\n var l = ref.level,\n nested = (ref.group || ref.parent) && l,\n scope = nested ? Array(l).join(\"group.mark.\") : \"\",\n r = fieldRef(ref.datum || ref.group || ref.parent || ref.signal),\n val = r.val,\n fields = r.fields || [],\n signals = r.signals || [],\n reflow = r.reflow || false; // Nested fieldrefs trigger full reeval of Encoder.\n\n if(ref.datum) {\n val = \"item.datum[\"+val+\"]\";\n fields.push(ref.datum);\n } else if(ref.group) {\n val = scope+\"group[\"+val+\"]\";\n reflow = true;\n } else if(ref.parent) {\n val = scope+\"group.datum[\"+val+\"]\";\n reflow = true;\n } else if(ref.signal) {\n val = \"signals[\"+val+\"]\";\n signals.push(dl.field(ref.signal)[0]);\n reflow = true;\n }\n\n return {val: val, fields: fields, signals: signals, reflow: reflow};\n}\n\n// {scale: \"x\"}\n// {scale: {name: \"x\"}},\n// {scale: fieldRef}\nfunction scaleRef(ref) {\n var scale = null,\n fr = null;\n\n if(dl.isString(ref)) {\n scale = dl.str(ref);\n } else if(ref.name) {\n scale = dl.isString(ref.name) ? dl.str(ref.name) : (fr = fieldRef(ref.name)).val;\n } else {\n scale = (fr = fieldRef(ref)).val;\n }\n\n scale = \"group.scale(\"+scale+\")\";\n if(ref.invert) scale += \".invert\"; // TODO: ordinal scales\n\n return fr ? (fr.val = scale, fr) : {val: scale};\n}\n\nmodule.exports = compile;",
"var expr = require('./expr'),\n C = require('../util/constants');\n\nfunction parseSignals(model, spec) {\n // process each signal definition\n (spec || []).forEach(function(s) {\n var signal = model.signal(s.name, s.init);\n\n if(s.init && s.init.expr) {\n s.init.expr = expr(s.init.expr);\n signal.value(exprVal(model, s.init));\n }\n\n if(s.expr) {\n s.expr = expr(s.expr);\n signal.evaluate = function(input) {\n var val = exprVal(model, s);\n if(val !== signal.value()) {\n signal.value(val);\n input.signals[s.name] = 1;\n return input;\n }\n return model.doNotPropagate; \n };\n signal.dependency(C.SIGNALS, s.expr.signals);\n s.expr.signals.forEach(function(dep) { model.signal(dep).addListener(signal); });\n }\n });\n\n return spec;\n};\n\nfunction exprVal(model, spec) {\n var e = spec.expr,\n val = expr.eval(model, e.fn, null, null, null, null, e.signals);\n return spec.scale ? scale(model, spec, val) : val;\n}\n\nparseSignals.scale = function scale(model, spec, value) {\n var def = spec.scale,\n name = def.name || def.signal || def,\n scope = def.scope ? model.signalRef(def.scope.signal) : null;\n\n if(!scope || !scope.scale) {\n scope = (scope && scope.mark) ? scope.mark.group : model.scene().items[0];\n }\n\n var scale = scope.scale(name);\n if(!scale) return value;\n return def.invert ? scale.invert(value) : scale(value);\n}\n\nmodule.exports = parseSignals;",
"var dl = require('datalib'),\n Model = require('../core/Model'), \n View = require('../core/View'), \n parseBg = require('../parse/background'),\n parsePadding = require('../parse/padding'),\n parseMarks = require('../parse/marks'),\n parseSignals = require('../parse/signals'),\n parsePredicates = require('../parse/predicates'),\n parseData = require('../parse/data'),\n parseInteractors = require('../parse/interactors');\n\nmodule.exports = function parseSpec(spec, callback, viewFactory) {\n // protect against subsequent spec modification\n spec = dl.duplicate(spec);\n\n viewFactory = viewFactory || View.factory;\n\n var width = spec.width || 500,\n height = spec.height || 500,\n viewport = spec.viewport || null,\n model = new Model();\n\n parseInteractors(model, spec, function() {\n model.defs({\n width: width,\n height: height,\n viewport: viewport,\n background: parseBg(spec.background),\n padding: parsePadding(spec.padding),\n signals: parseSignals(model, spec.signals),\n predicates: parsePredicates(model, spec.predicates),\n marks: parseMarks(model, spec, width, height),\n data: parseData(model, spec.data, function() { callback(viewFactory(model)); })\n });\n });\n}\n",
"var dl = require('datalib'),\n d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n Node = require('../dataflow/Node'),\n parseSignals = require('./signals'),\n changset = require('../dataflow/changeset'),\n selector = require('./events'),\n expr = require('./expr'),\n C = require('../util/constants');\n\nvar START = \"start\", MIDDLE = \"middle\", END = \"end\";\n\nmodule.exports = function(view) {\n var model = view.model(),\n spec = model.defs().signals,\n register = {}, nodes = {};\n\n function signal(sig, selector, exp, spec) {\n var n = new Node(model);\n n.evaluate = function(input) {\n if(!input.signals[selector.signal]) return model.doNotPropagate;\n var val = expr.eval(model, exp.fn, null, null, null, null, exp.signals);\n if(spec.scale) val = parseSignals.scale(model, spec, val);\n\n if(val !== sig.value()) {\n sig.value(val);\n input.signals[sig.name()] = 1;\n input.reflow = true; \n }\n\n return input; \n };\n n.dependency(C.SIGNALS, selector.signal);\n n.addListener(sig);\n model.signal(selector.signal).addListener(n);\n };\n\n function event(sig, selector, exp, spec) {\n var filters = selector.filters || [],\n target = selector.target;\n\n if(target) filters.push(\"i.\"+target.type+\"==\"+dl.str(target.value));\n\n register[selector.event] = register[selector.event] || [];\n register[selector.event].push({\n signal: sig,\n exp: exp,\n filters: filters.map(function(f) { return expr(f); }),\n spec: spec\n });\n\n nodes[selector.event] = nodes[selector.event] || new Node(model);\n nodes[selector.event].addListener(sig);\n };\n\n function orderedStream(sig, selector, exp, spec) {\n var name = sig.name(), \n trueFn = expr(\"true\"),\n s = {};\n\n s[START] = model.signal(name + START, false);\n s[MIDDLE] = model.signal(name + MIDDLE, false);\n s[END] = model.signal(name + END, false);\n\n var router = new Node(model);\n router.evaluate = function(input) {\n if(s[START].value() === true && s[END].value() === false) {\n // TODO: Expand selector syntax to allow start/end signals into stream.\n // Until then, prevent old middles entering stream on new start.\n if(input.signals[name+START]) return model.doNotPropagate;\n\n if(s[MIDDLE].value() !== sig.value()) {\n sig.value(s[MIDDLE].value());\n input.signals[name] = 1;\n }\n\n return input;\n }\n\n if(s[END].value() === true) {\n s[START].value(false);\n s[END].value(false);\n }\n\n return model.doNotPropagate;\n };\n router.addListener(sig);\n\n [START, MIDDLE, END].forEach(function(x) {\n var val = (x == MIDDLE) ? exp : trueFn,\n sp = (x == MIDDLE) ? spec : {};\n\n if(selector[x].event) event(s[x], selector[x], val, sp);\n else if(selector[x].signal) signal(s[x], selector[x], val, sp);\n else if(selector[x].stream) mergedStream(s[x], selector[x].stream, val, sp);\n s[x].addListener(router);\n });\n };\n\n function mergedStream(sig, selector, exp, spec) {\n selector.forEach(function(s) {\n if(s.event) event(sig, s, exp, spec);\n else if(s.signal) signal(sig, s, exp, spec);\n else if(s.start) orderedStream(sig, s, exp, spec);\n else if(s.stream) mergedStream(sig, s.stream, exp, spec);\n });\n };\n\n (spec || []).forEach(function(sig) {\n var signal = model.signal(sig.name);\n if(sig.expr) return; // Cannot have an expr and stream definition.\n\n (sig.streams || []).forEach(function(stream) {\n var sel = selector.parse(stream.type),\n exp = expr(stream.expr);\n mergedStream(signal, sel, exp, stream);\n });\n });\n\n // We register the event listeners all together so that if multiple\n // signals are registered on the same event, they will receive the\n // new value on the same pulse. \n\n // TODO: Filters, time intervals, target selectors\n dl.keys(register).forEach(function(r) {\n var handlers = register[r], \n node = nodes[r];\n\n view.on(r, function(evt, item) {\n var cs = changset.create(null, true),\n pad = view.padding(),\n filtered = false,\n val, h, i, m, d;\n\n evt.preventDefault(); // Stop text selection\n m = d3.mouse((d3.event=evt, view._el)); // Relative position within container\n item = item||{};\n d = item.datum||{};\n var p = {x: m[0] - pad.left, y: m[1] - pad.top};\n\n for(i = 0; i < handlers.length; i++) {\n h = handlers[i];\n filtered = h.filters.some(function(f) {\n return !expr.eval(model, f.fn, d, evt, item, p, f.signals);\n });\n if(filtered) continue;\n \n val = expr.eval(model, h.exp.fn, d, evt, item, p, h.exp.signals); \n if(h.spec.scale) val = parseSignals.scale(model, h.spec, val);\n\n if(val !== h.signal.value()) {\n h.signal.value(val);\n cs.signals[h.signal.name()] = 1;\n }\n }\n\n model.propagate(cs, node);\n });\n })\n};",
"var dl = require('datalib'),\n transforms = require('../transforms/index');\n\nmodule.exports = function parseTransforms(model, def) {\n var tx = new transforms[def.type](model);\n \n // We want to rename output fields before setting any other properties,\n // as subsequent properties may require output to be set (e.g. group by).\n if(def.output) tx.output(def.output);\n\n dl.keys(def).forEach(function(k) {\n if(k === 'type' || k === 'output') return;\n if(k === 'transform' && def.type === 'facet') return;\n tx.param(k, def[k]);\n });\n\n return tx;\n};",
"var dl = require('datalib'),\n d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n marks = require('./marks');\n\nvar handler = function(el, model) {\n this._active = null;\n this._down = null;\n this._handlers = {};\n if (el) this.initialize(el);\n if (model) this.model(model);\n};\n\nvar prototype = handler.prototype;\n\nprototype.initialize = function(el, pad, obj) {\n this._el = d3.select(el).node();\n this._canvas = d3.select(el).select(\"canvas.marks\").node();\n this._padding = pad;\n this._obj = obj || null;\n \n // add event listeners\n var canvas = this._canvas, that = this;\n events.forEach(function(type) {\n canvas.addEventListener(type, function(evt) {\n prototype[type].call(that, evt);\n });\n });\n \n return this;\n};\n\nprototype.padding = function(pad) {\n this._padding = pad;\n return this;\n};\n\nprototype.model = function(model) {\n if (!arguments.length) return this._model;\n this._model = model;\n return this;\n};\n\nprototype.handlers = function() {\n var h = this._handlers;\n return dl.keys(h).reduce(function(a, k) {\n return h[k].reduce(function(a, x) { return (a.push(x), a); }, a);\n }, []);\n};\n\n// setup events\nvar events = [\n \"mouseup\",\n \"dblclick\",\n \"wheel\",\n \"keydown\",\n \"keypress\",\n \"keyup\",\n \"mousewheel\",\n \"touchstart\"\n];\nevents.forEach(function(type) {\n prototype[type] = function(evt) {\n this.fire(type, evt);\n };\n});\nevents.push(\"mousedown\");\nevents.push(\"mousemove\");\nevents.push(\"mouseout\");\nevents.push(\"click\");\nevents.push(\"touchmove\");\nevents.push(\"touchend\");\n\nfunction eventName(name) {\n var i = name.indexOf(\".\");\n return i < 0 ? name : name.slice(0,i);\n}\n\nprototype.touchmove = prototype.mousemove = function(evt) {\n var pad = this._padding,\n b = evt.target.getBoundingClientRect(),\n x = evt.clientX - b.left,\n y = evt.clientY - b.top,\n a = this._active,\n p = this.pick(this._model.scene(), x, y, x-pad.left, y-pad.top);\n\n if (p === a) {\n this.fire(\"mousemove\", evt);\n if(evt.type == \"touchmove\") this.fire(\"touchmove\", evt);\n return;\n } else if (a) {\n this.fire(\"mouseout\", evt);\n if(evt.type == \"touchend\") this.fire(\"touchend\", evt);\n }\n this._active = p;\n if (p) {\n this.fire(\"mouseover\", evt);\n if(evt.type == \"touchstart\") this.fire(\"touchstart\", evt);\n }\n};\n\nprototype.touchend = prototype.mouseout = function(evt) {\n if (this._active) {\n this.fire(\"mouseout\", evt);\n this.fire(\"touchend\", evt);\n }\n this._active = null;\n};\n\nprototype.mousedown = function(evt) {\n this._down = this._active;\n this.fire(\"mousedown\", evt);\n};\n\nprototype.click = function(evt) {\n if (this._down === this._active) {\n this.fire(\"click\", evt);\n this._down = null;\n }\n};\n\n// to keep firefox happy\nprototype.DOMMouseScroll = function(evt) {\n this.fire(\"mousewheel\", evt);\n};\n\n// fire an event\nprototype.fire = function(type, evt) {\n var a = this._active,\n h = this._handlers[type];\n if (h) {\n for (var i=0, len=h.length; i<len; ++i) {\n h[i].handler.call(this._obj, evt, a);\n }\n }\n};\n\n// add an event handler\nprototype.on = function(type, handler) {\n var name = eventName(type),\n h = this._handlers;\n h = h[name] || (h[name] = []);\n h.push({\n type: type,\n handler: handler\n });\n return this;\n};\n\n// remove an event handler\nprototype.off = function(type, handler) {\n var name = eventName(type),\n h = this._handlers[name];\n if (!h) return;\n for (var i=h.length; --i>=0;) {\n if (h[i].type !== type) continue;\n if (!handler || h[i].handler === handler) h.splice(i, 1);\n }\n return this;\n};\n\n// retrieve the current canvas context\nprototype.context = function() {\n return this._canvas.getContext(\"2d\");\n};\n\n// find the scenegraph item at the current mouse position\n// x, y -- the absolute x, y mouse coordinates on the canvas element\n// gx, gy -- the relative coordinates within the current group\nprototype.pick = function(scene, x, y, gx, gy) {\n var g = this.context(),\n marktype = scene.marktype,\n picker = marks.pick[marktype];\n return picker.call(this, g, scene, x, y, gx, gy);\n};\n\nmodule.exports = handler;",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n dl = require('datalib'),\n Bounds = require('../../util/Bounds'),\n config = require('../../util/config'),\n marks = require('./marks');\n\nvar renderer = function() {\n this._ctx = null;\n this._el = null;\n this._bgcolor = null;\n this._imgload = 0;\n};\n\nvar prototype = renderer.prototype;\n\nprototype.initialize = function(el, width, height, pad, bgcolor) {\n this._el = el;\n\n this.background(bgcolor);\n \n if (!el) return this; // early exit if no DOM element\n\n // select canvas element\n var canvas = d3.select(el)\n .selectAll(\"canvas.marks\")\n .data([1]);\n \n // create new canvas element if needed\n canvas.enter()\n .append(\"canvas\")\n .attr(\"class\", \"marks\");\n \n // remove extraneous canvas if needed\n canvas.exit().remove();\n \n return this.resize(width, height, pad);\n};\n\nprototype.background = function(bgcolor) {\n this._bgcolor = bgcolor;\n return this;\n};\n\nprototype.resize = function(width, height, pad) {\n this._width = width;\n this._height = height;\n this._padding = pad;\n \n if (this._el) {\n var canvas = d3.select(this._el).select(\"canvas.marks\");\n\n // initialize canvas attributes\n canvas\n .attr(\"width\", width + pad.left + pad.right)\n .attr(\"height\", height + pad.top + pad.bottom);\n\n // get the canvas graphics context\n var s;\n this._ctx = canvas.node().getContext(\"2d\");\n this._ctx._ratio = (s = scaleCanvas(canvas.node(), this._ctx) || 1);\n this._ctx.setTransform(s, 0, 0, s, s*pad.left, s*pad.top);\n }\n \n initializeLineDash(this._ctx);\n return this;\n};\n\nfunction scaleCanvas(canvas, ctx) {\n // get canvas pixel data\n var devicePixelRatio = window.devicePixelRatio || 1,\n backingStoreRatio = (\n ctx.webkitBackingStorePixelRatio ||\n ctx.mozBackingStorePixelRatio ||\n ctx.msBackingStorePixelRatio ||\n ctx.oBackingStorePixelRatio ||\n ctx.backingStorePixelRatio) || 1,\n ratio = devicePixelRatio / backingStoreRatio;\n\n if (devicePixelRatio !== backingStoreRatio) {\n var w = canvas.width, h = canvas.height;\n // set actual and visible canvas size\n canvas.setAttribute(\"width\", w * ratio);\n canvas.setAttribute(\"height\", h * ratio);\n canvas.style.width = w + 'px';\n canvas.style.height = h + 'px';\n }\n return ratio;\n}\n\nfunction initializeLineDash(ctx) {\n if (ctx.vgLineDash) return; // already set\n\n var NODASH = [];\n if (ctx.setLineDash) {\n ctx.vgLineDash = function(dash) { this.setLineDash(dash || NODASH); };\n ctx.vgLineDashOffset = function(off) { this.lineDashOffset = off; };\n } else if (ctx.webkitLineDash !== undefined) {\n \tctx.vgLineDash = function(dash) { this.webkitLineDash = dash || NODASH; };\n ctx.vgLineDashOffset = function(off) { this.webkitLineDashOffset = off; };\n } else if (ctx.mozDash !== undefined) {\n ctx.vgLineDash = function(dash) { this.mozDash = dash; };\n ctx.vgLineDashOffset = function(off) { /* unsupported */ };\n } else {\n ctx.vgLineDash = function(dash) { /* unsupported */ };\n ctx.vgLineDashOffset = function(off) { /* unsupported */ };\n }\n}\n\nprototype.context = function(ctx) {\n if (ctx) { this._ctx = ctx; return this; }\n else return this._ctx;\n};\n\nprototype.element = function() {\n return this._el;\n};\n\nprototype.pendingImages = function() {\n return this._imgload;\n};\n\nfunction translatedBounds(item, bounds) {\n var b = new Bounds(bounds);\n while ((item = item.mark.group) != null) {\n b.translate(item.x || 0, item.y || 0);\n }\n return b;\n}\n \nfunction getBounds(items) {\n return !items ? null :\n dl.array(items).reduce(function(b, item) {\n return b.union(translatedBounds(item, item.bounds))\n .union(translatedBounds(item, item['bounds:prev']));\n }, new Bounds()); \n}\n\nfunction setBounds(g, bounds) {\n var bbox = null;\n if (bounds) {\n bbox = (new Bounds(bounds)).round();\n g.beginPath();\n g.rect(bbox.x1, bbox.y1, bbox.width(), bbox.height());\n g.clip();\n }\n return bbox;\n}\n\nprototype.render = function(scene, items) {\n var g = this._ctx,\n pad = this._padding,\n w = this._width + pad.left + pad.right,\n h = this._height + pad.top + pad.bottom,\n bb = null, bb2;\n\n // setup\n this._scene = scene;\n g.save();\n bb = setBounds(g, getBounds(items));\n this.clear(-pad.left, -pad.top, w, h);\n\n // render\n this.draw(g, scene, bb);\n\n // render again to handle possible bounds change\n if (items) {\n g.restore();\n g.save();\n bb2 = setBounds(g, getBounds(items));\n if (!bb.encloses(bb2)) {\n this.clear(-pad.left, -pad.top, w, h);\n this.draw(g, scene, bb2);\n }\n }\n \n // takedown\n g.restore();\n this._scene = null;\n};\n\nprototype.draw = function(ctx, scene, bounds) {\n var marktype = scene.marktype,\n renderer = marks.draw[marktype];\n renderer.call(this, ctx, scene, bounds);\n};\n\nprototype.clear = function(x, y, w, h) {\n var g = this._ctx;\n\n g.clearRect(x, y, w, h);\n if (this._bgcolor != null) {\n g.fillStyle = this._bgcolor;\n g.fillRect(x, y, w, h); \n }\n};\n\nprototype.renderAsync = function(scene) {\n // TODO make safe for multiple scene rendering?\n var renderer = this;\n if (renderer._async_id) {\n clearTimeout(renderer._async_id);\n }\n renderer._async_id = setTimeout(function() {\n renderer.render(scene);\n delete renderer._async_id;\n }, 50);\n};\n\nprototype.loadImage = function(uri) {\n var renderer = this,\n scene = renderer._scene,\n image = null, url;\n\n if (dl.isNode) {\n renderer._imgload += 1;\n image = new ((typeof window !== \"undefined\" ? window.canvas : typeof global !== \"undefined\" ? global.canvas : null).Image)();\n dl.load(dl.extend({url: uri}, config.load), function(err, data) {\n renderer._imgload -= 1;\n if (err) { dl.error(err); return; }\n dl.log(\"LOAD IMAGE: \" + uri);\n image.src = data;\n image.loaded = true;\n });\n } else {\n image = new Image();\n url = dl.load.sanitizeUrl(dl.extend({url: uri}, config.load));\n if (!url) { return; }\n renderer._imgload += 1;\n image.onload = function() {\n dl.log(\"LOAD IMAGE: \" + url);\n image.loaded = true;\n renderer._imgload -= 1;\n renderer.renderAsync(scene);\n };\n image.src = url;\n }\n\n return image;\n};\n\nmodule.exports = renderer;",
"module.exports = {\n Handler: require('./Handler'),\n Renderer: require('./Renderer')\n};",
"var Bounds = require('../../util/Bounds'),\n boundsCalc = require('../../util/boundscalc'),\n config = require('../../util/config'),\n path = require('./path');\n\nvar parsePath = path.parse,\n renderPath = path.render,\n halfpi = Math.PI / 2,\n sqrt3 = Math.sqrt(3),\n tan30 = Math.tan(30 * Math.PI / 180),\n tmpBounds = new Bounds();\n\nfunction fontString(o) {\n return (o.fontStyle ? o.fontStyle + \" \" : \"\")\n + (o.fontVariant ? o.fontVariant + \" \" : \"\")\n + (o.fontWeight ? o.fontWeight + \" \" : \"\")\n + (o.fontSize != null ? o.fontSize : config.render.fontSize) + \"px \"\n + (o.font || config.render.font);\n}\n\n// path generators\n\nfunction arcPath(g, o) {\n var x = o.x || 0,\n y = o.y || 0,\n ir = o.innerRadius || 0,\n or = o.outerRadius || 0,\n sa = (o.startAngle || 0) - Math.PI/2,\n ea = (o.endAngle || 0) - Math.PI/2;\n g.beginPath();\n if (ir === 0) g.moveTo(x, y);\n else g.arc(x, y, ir, sa, ea, 0);\n g.arc(x, y, or, ea, sa, 1);\n g.closePath();\n}\n\nfunction areaPath(g, items) {\n var o = items[0],\n m = o.mark,\n p = m.pathCache || (m.pathCache = parsePath(path.area(items)));\n renderPath(g, p);\n}\n\nfunction linePath(g, items) {\n var o = items[0],\n m = o.mark,\n p = m.pathCache || (m.pathCache = parsePath(path.line(items)));\n renderPath(g, p);\n}\n\nfunction pathPath(g, o) {\n if (o.path == null) return;\n var p = o.pathCache || (o.pathCache = parsePath(o.path));\n return renderPath(g, p, o.x, o.y);\n}\n\nfunction symbolPath(g, o) {\n g.beginPath();\n var size = o.size != null ? o.size : 100,\n x = o.x, y = o.y, r, t, rx, ry;\n\n if (o.shape == null || o.shape === \"circle\") {\n r = Math.sqrt(size/Math.PI);\n g.arc(x, y, r, 0, 2*Math.PI, 0);\n g.closePath();\n return;\n }\n\n switch (o.shape) {\n case \"cross\":\n r = Math.sqrt(size / 5) / 2;\n t = 3*r;\n g.moveTo(x-t, y-r);\n g.lineTo(x-r, y-r);\n g.lineTo(x-r, y-t);\n g.lineTo(x+r, y-t);\n g.lineTo(x+r, y-r);\n g.lineTo(x+t, y-r);\n g.lineTo(x+t, y+r);\n g.lineTo(x+r, y+r);\n g.lineTo(x+r, y+t);\n g.lineTo(x-r, y+t);\n g.lineTo(x-r, y+r);\n g.lineTo(x-t, y+r);\n break;\n\n case \"diamond\":\n ry = Math.sqrt(size / (2 * tan30));\n rx = ry * tan30;\n g.moveTo(x, y-ry);\n g.lineTo(x+rx, y);\n g.lineTo(x, y+ry);\n g.lineTo(x-rx, y);\n break;\n\n case \"square\":\n t = Math.sqrt(size);\n r = t / 2;\n g.rect(x-r, y-r, t, t);\n break;\n\n case \"triangle-down\":\n rx = Math.sqrt(size / sqrt3);\n ry = rx * sqrt3 / 2;\n g.moveTo(x, y+ry);\n g.lineTo(x+rx, y-ry);\n g.lineTo(x-rx, y-ry);\n break;\n\n case \"triangle-up\":\n rx = Math.sqrt(size / sqrt3);\n ry = rx * sqrt3 / 2;\n g.moveTo(x, y-ry);\n g.lineTo(x+rx, y+ry);\n g.lineTo(x-rx, y+ry);\n }\n g.closePath();\n}\n\nfunction lineStroke(g, items) {\n var o = items[0],\n lw = o.strokeWidth,\n lc = o.strokeCap;\n g.lineWidth = lw != null ? lw : config.render.lineWidth;\n g.lineCap = lc != null ? lc : config.render.lineCap;\n linePath(g, items);\n}\n\nfunction ruleStroke(g, o) {\n var x1 = o.x || 0,\n y1 = o.y || 0,\n x2 = o.x2 != null ? o.x2 : x1,\n y2 = o.y2 != null ? o.y2 : y1,\n lw = o.strokeWidth,\n lc = o.strokeCap;\n\n g.lineWidth = lw != null ? lw : config.render.lineWidth;\n g.lineCap = lc != null ? lc : config.render.lineCap;\n g.beginPath();\n g.moveTo(x1, y1);\n g.lineTo(x2, y2);\n}\n\n// drawing functions\n\nfunction drawPathOne(path, g, o, items) {\n var fill = o.fill, stroke = o.stroke, opac, lc, lw;\n\n path(g, items);\n\n opac = o.opacity == null ? 1 : o.opacity;\n if (opac == 0 || !fill && !stroke) return;\n\n if (fill) {\n g.globalAlpha = opac * (o.fillOpacity==null ? 1 : o.fillOpacity);\n g.fillStyle = color(g, o, fill);\n g.fill();\n }\n\n if (stroke) {\n lw = (lw = o.strokeWidth) != null ? lw : config.render.lineWidth;\n if (lw > 0) {\n g.globalAlpha = opac * (o.strokeOpacity==null ? 1 : o.strokeOpacity);\n g.strokeStyle = color(g, o, stroke);\n g.lineWidth = lw;\n g.lineCap = (lc = o.strokeCap) != null ? lc : config.render.lineCap;\n g.vgLineDash(o.strokeDash || null);\n g.vgLineDashOffset(o.strokeDashOffset || 0);\n g.stroke();\n }\n }\n}\n\nfunction drawPathAll(path, g, scene, bounds) {\n var i, len, item;\n for (i=0, len=scene.items.length; i<len; ++i) {\n item = scene.items[i];\n if (bounds && !bounds.intersects(item.bounds))\n continue; // bounds check\n drawPathOne(path, g, item, item);\n }\n}\n\nfunction drawRect(g, scene, bounds) {\n if (!scene.items.length) return;\n var items = scene.items,\n o, fill, stroke, opac, lc, lw, x, y, w, h;\n\n for (var i=0, len=items.length; i<len; ++i) {\n o = items[i];\n if (bounds && !bounds.intersects(o.bounds))\n continue; // bounds check\n\n x = o.x || 0;\n y = o.y || 0;\n w = o.width || 0;\n h = o.height || 0;\n\n opac = o.opacity == null ? 1 : o.opacity;\n if (opac == 0) continue;\n\n if (fill = o.fill) {\n g.globalAlpha = opac * (o.fillOpacity==null ? 1 : o.fillOpacity);\n g.fillStyle = color(g, o, fill);\n g.fillRect(x, y, w, h);\n }\n\n if (stroke = o.stroke) {\n lw = (lw = o.strokeWidth) != null ? lw : config.render.lineWidth;\n if (lw > 0) {\n g.globalAlpha = opac * (o.strokeOpacity==null ? 1 : o.strokeOpacity);\n g.strokeStyle = color(g, o, stroke);\n g.lineWidth = lw;\n g.lineCap = (lc = o.strokeCap) != null ? lc : config.render.lineCap;\n g.vgLineDash(o.strokeDash || null);\n g.vgLineDashOffset(o.strokeDashOffset || 0);\n g.strokeRect(x, y, w, h);\n }\n }\n }\n}\n\nfunction drawRule(g, scene, bounds) {\n if (!scene.items.length) return;\n var items = scene.items,\n o, stroke, opac, lc, lw, x1, y1, x2, y2;\n\n for (var i=0, len=items.length; i<len; ++i) {\n o = items[i];\n if (bounds && !bounds.intersects(o.bounds))\n continue; // bounds check\n\n x1 = o.x || 0;\n y1 = o.y || 0;\n x2 = o.x2 != null ? o.x2 : x1;\n y2 = o.y2 != null ? o.y2 : y1;\n\n opac = o.opacity == null ? 1 : o.opacity;\n if (opac == 0) continue;\n \n if (stroke = o.stroke) {\n lw = (lw = o.strokeWidth) != null ? lw : config.render.lineWidth;\n if (lw > 0) {\n g.globalAlpha = opac * (o.strokeOpacity==null ? 1 : o.strokeOpacity);\n g.strokeStyle = color(g, o, stroke);\n g.lineWidth = lw;\n g.lineCap = (lc = o.strokeCap) != null ? lc : config.render.lineCap;\n g.vgLineDash(o.strokeDash || null);\n g.vgLineDashOffset(o.strokeDashOffset || 0);\n g.beginPath();\n g.moveTo(x1, y1);\n g.lineTo(x2, y2);\n g.stroke();\n }\n }\n }\n}\n\nfunction drawImage(g, scene, bounds) {\n if (!scene.items.length) return;\n var renderer = this,\n items = scene.items, o;\n\n for (var i=0, len=items.length; i<len; ++i) {\n o = items[i];\n if (bounds && !bounds.intersects(o.bounds))\n continue; // bounds check\n\n if (!(o.image && o.image.url === o.url)) {\n o.image = renderer.loadImage(o.url);\n o.image.url = o.url;\n }\n\n var x, y, w, h, opac;\n w = o.width || (o.image && o.image.width) || 0;\n h = o.height || (o.image && o.image.height) || 0;\n x = (o.x||0) - (o.align === \"center\"\n ? w/2 : (o.align === \"right\" ? w : 0));\n y = (o.y||0) - (o.baseline === \"middle\"\n ? h/2 : (o.baseline === \"bottom\" ? h : 0));\n\n if (o.image.loaded) {\n g.globalAlpha = (opac = o.opacity) != null ? opac : 1;\n g.drawImage(o.image, x, y, w, h);\n }\n }\n}\n\nfunction drawText(g, scene, bounds) {\n if (!scene.items.length) return;\n var items = scene.items,\n o, fill, stroke, opac, lw, x, y, r, t;\n\n for (var i=0, len=items.length; i<len; ++i) {\n o = items[i];\n if (bounds && !bounds.intersects(o.bounds))\n continue; // bounds check\n\n g.font = fontString(o);\n g.textAlign = o.align || \"left\";\n g.textBaseline = o.baseline || \"alphabetic\";\n\n opac = o.opacity == null ? 1 : o.opacity;\n if (opac == 0) continue;\n\n x = o.x || 0;\n y = o.y || 0;\n if (r = o.radius) {\n t = (o.theta || 0) - Math.PI/2;\n x += r * Math.cos(t);\n y += r * Math.sin(t);\n }\n\n if (o.angle) {\n g.save();\n g.translate(x, y);\n g.rotate(o.angle * Math.PI/180);\n x = o.dx || 0;\n y = o.dy || 0;\n } else {\n x += (o.dx || 0);\n y += (o.dy || 0);\n }\n\n if (fill = o.fill) {\n g.globalAlpha = opac * (o.fillOpacity==null ? 1 : o.fillOpacity);\n g.fillStyle = color(g, o, fill);\n g.fillText(o.text, x, y);\n }\n\n if (stroke = o.stroke) {\n lw = (lw = o.strokeWidth) != null ? lw : 1;\n if (lw > 0) {\n g.globalAlpha = opac * (o.strokeOpacity==null ? 1 : o.strokeOpacity);\n g.strokeStyle = color(g, o, stroke);\n g.lineWidth = lw;\n g.strokeText(o.text, x, y);\n }\n }\n\n if (o.angle) g.restore();\n }\n}\n\nfunction drawAll(pathFunc) {\n return function(g, scene, bounds) {\n drawPathAll(pathFunc, g, scene, bounds);\n }\n}\n\nfunction drawOne(pathFunc) {\n return function(g, scene, bounds) {\n if (!scene.items.length) return;\n if (bounds && !bounds.intersects(scene.items[0].bounds))\n return; // bounds check\n drawPathOne(pathFunc, g, scene.items[0], scene.items);\n }\n}\n\nfunction drawGroup(g, scene, bounds) {\n if (!scene.items.length) return;\n var items = scene.items, group, axes, legends,\n renderer = this, gx, gy, gb, i, n, j, m;\n\n drawRect(g, scene, bounds);\n\n for (i=0, n=items.length; i<n; ++i) {\n group = items[i];\n axes = group.axisItems || [];\n legends = group.legendItems || [];\n gx = group.x || 0;\n gy = group.y || 0;\n\n // render group contents\n g.save();\n g.translate(gx, gy);\n if (group.clip) {\n g.beginPath();\n g.rect(0, 0, group.width || 0, group.height || 0);\n g.clip();\n }\n \n if (bounds) bounds.translate(-gx, -gy);\n \n for (j=0, m=axes.length; j<m; ++j) {\n if (axes[j].def.layer === \"back\") {\n renderer.draw(g, axes[j], bounds);\n }\n }\n for (j=0, m=group.items.length; j<m; ++j) {\n renderer.draw(g, group.items[j], bounds);\n }\n for (j=0, m=axes.length; j<m; ++j) {\n if (axes[j].def.layer !== \"back\") {\n renderer.draw(g, axes[j], bounds);\n }\n }\n for (j=0, m=legends.length; j<m; ++j) {\n renderer.draw(g, legends[j], bounds);\n }\n \n if (bounds) bounds.translate(gx, gy);\n g.restore();\n } \n}\n\nfunction color(g, o, value) {\n return (value.id)\n ? gradient(g, value, o.bounds)\n : value;\n}\n\nfunction gradient(g, p, b) {\n var w = b.width(),\n h = b.height(),\n x1 = b.x1 + p.x1 * w,\n y1 = b.y1 + p.y1 * h,\n x2 = b.x1 + p.x2 * w,\n y2 = b.y1 + p.y2 * h,\n grad = g.createLinearGradient(x1, y1, x2, y2),\n stop = p.stops,\n i, n;\n\n for (i=0, n=stop.length; i<n; ++i) {\n grad.addColorStop(stop[i].offset, stop[i].color);\n }\n return grad;\n}\n\n// hit testing\n\nfunction pickGroup(g, scene, x, y, gx, gy) {\n if (scene.items.length === 0 ||\n scene.bounds && !scene.bounds.contains(gx, gy)) {\n return false;\n }\n var items = scene.items, subscene, group, hit, dx, dy,\n handler = this, i, j;\n\n for (i=items.length; --i>=0;) {\n group = items[i];\n dx = group.x || 0;\n dy = group.y || 0;\n\n g.save();\n g.translate(dx, dy);\n for (j=group.items.length; --j >= 0;) {\n subscene = group.items[j];\n if (subscene.interactive === false) continue;\n hit = handler.pick(subscene, x, y, gx-dx, gy-dy);\n if (hit) {\n g.restore();\n return hit;\n }\n }\n g.restore();\n }\n\n return scene.interactive\n ? pickAll(hitTests.group, g, scene, x, y, gx, gy)\n : false;\n}\n\nfunction pickAll(test, g, scene, x, y, gx, gy) {\n if (!scene.items.length) return false;\n var o, b, i;\n\n if (g._ratio !== 1) {\n x *= g._ratio;\n y *= g._ratio;\n }\n\n for (i=scene.items.length; --i >= 0;) {\n o = scene.items[i]; b = o.bounds;\n // first hit test against bounding box\n if ((b && !b.contains(gx, gy)) || !b) continue;\n // if in bounding box, perform more careful test\n if (test(g, o, x, y, gx, gy)) return o;\n }\n return false;\n}\n\nfunction pickArea(g, scene, x, y, gx, gy) {\n if (!scene.items.length) return false;\n var items = scene.items,\n o, b, i, di, dd, od, dx, dy;\n\n b = items[0].bounds;\n if (b && !b.contains(gx, gy)) return false;\n if (g._ratio !== 1) {\n x *= g._ratio;\n y *= g._ratio;\n }\n if (!hitTests.area(g, items, x, y)) return false;\n return items[0];\n}\n\nfunction pickLine(g, scene, x, y, gx, gy) {\n if (!scene.items.length) return false;\n var items = scene.items,\n o, b, i, di, dd, od, dx, dy;\n\n b = items[0].bounds;\n if (b && !b.contains(gx, gy)) return false;\n if (g._ratio !== 1) {\n x *= g._ratio;\n y *= g._ratio;\n }\n if (!hitTests.line(g, items, x, y)) return false;\n return items[0];\n}\n\nfunction pick(test) {\n return function (g, scene, x, y, gx, gy) {\n return pickAll(test, g, scene, x, y, gx, gy);\n };\n}\n\nfunction textHit(g, o, x, y, gx, gy) {\n if (!o.fontSize) return false;\n if (!o.angle) return true; // bounds sufficient if no rotation\n\n var b = boundsCalc.text(o, tmpBounds, true),\n a = -o.angle * Math.PI / 180,\n cos = Math.cos(a),\n sin = Math.sin(a),\n x = o.x,\n y = o.y,\n px = cos*gx - sin*gy + (x - x*cos + y*sin),\n py = sin*gx + cos*gy + (y - x*sin - y*cos);\n\n return b.contains(px, py);\n}\n\nvar hitTests = {\n text: textHit,\n rect: function(g,o,x,y) { return true; }, // bounds test is sufficient\n image: function(g,o,x,y) { return true; }, // bounds test is sufficient\n group: function(g,o,x,y) { return o.fill || o.stroke; },\n rule: function(g,o,x,y) {\n if (!g.isPointInStroke) return false;\n ruleStroke(g,o); return g.isPointInStroke(x,y);\n },\n line: function(g,s,x,y) {\n if (!g.isPointInStroke) return false;\n lineStroke(g,s); return g.isPointInStroke(x,y);\n },\n arc: function(g,o,x,y) { arcPath(g,o); return g.isPointInPath(x,y); },\n area: function(g,s,x,y) { areaPath(g,s); return g.isPointInPath(x,y); },\n path: function(g,o,x,y) { pathPath(g,o); return g.isPointInPath(x,y); },\n symbol: function(g,o,x,y) { symbolPath(g,o); return g.isPointInPath(x,y); }\n};\n\nmodule.exports = {\n draw: {\n group: drawGroup,\n area: drawOne(areaPath),\n line: drawOne(linePath),\n arc: drawAll(arcPath),\n path: drawAll(pathPath),\n symbol: drawAll(symbolPath),\n rect: drawRect,\n rule: drawRule,\n text: drawText,\n image: drawImage,\n drawOne: drawOne, // expose for extensibility\n drawAll: drawAll // expose for extensibility\n },\n pick: {\n group: pickGroup,\n area: pickArea,\n line: pickLine,\n arc: pick(hitTests.arc),\n path: pick(hitTests.path),\n symbol: pick(hitTests.symbol),\n rect: pick(hitTests.rect),\n rule: pick(hitTests.rule),\n text: pick(hitTests.text),\n image: pick(hitTests.image),\n pickAll: pickAll // expose for extensibility\n }\n};\n",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n Bounds = require('../../util/Bounds');\n\n// Path parsing and rendering code taken from fabric.js -- Thanks!\nvar cmdLength = { m:2, l:2, h:1, v:1, c:6, s:4, q:4, t:2, a:7 },\n re = [/([MLHVCSQTAZmlhvcsqtaz])/g, /###/, /(\\d)-/g, /\\s|,|###/];\n\nfunction parse(path) {\n var result = [],\n currentPath,\n chunks,\n parsed;\n\n // First, break path into command sequence\n path = path.slice().replace(re[0], '###$1').split(re[1]).slice(1);\n\n // Next, parse each command in turn\n for (var i=0, j, chunksParsed, len=path.length; i<len; i++) {\n currentPath = path[i];\n chunks = currentPath.slice(1).trim().replace(re[2],'$1###-').split(re[3]);\n chunksParsed = [currentPath.charAt(0)];\n\n for (var j = 0, jlen = chunks.length; j < jlen; j++) {\n parsed = parseFloat(chunks[j]);\n if (!isNaN(parsed)) {\n chunksParsed.push(parsed);\n }\n }\n\n var command = chunksParsed[0].toLowerCase(),\n commandLength = cmdLength[command];\n\n if (chunksParsed.length - 1 > commandLength) {\n for (var k = 1, klen = chunksParsed.length; k < klen; k += commandLength) {\n result.push([ chunksParsed[0] ].concat(chunksParsed.slice(k, k + commandLength)));\n }\n }\n else {\n result.push(chunksParsed);\n }\n }\n\n return result;\n}\n\nfunction drawArc(g, x, y, coords, bounds, l, t) {\n var rx = coords[0];\n var ry = coords[1];\n var rot = coords[2];\n var large = coords[3];\n var sweep = coords[4];\n var ex = coords[5];\n var ey = coords[6];\n var segs = arcToSegments(ex, ey, rx, ry, large, sweep, rot, x, y);\n for (var i=0; i<segs.length; i++) {\n var bez = segmentToBezier.apply(null, segs[i]);\n g.bezierCurveTo.apply(g, bez);\n bounds.add(bez[0]-l, bez[1]-t);\n bounds.add(bez[2]-l, bez[3]-t);\n bounds.add(bez[4]-l, bez[5]-t);\n }\n}\n\nfunction boundArc(x, y, coords, bounds) {\n var rx = coords[0];\n var ry = coords[1];\n var rot = coords[2];\n var large = coords[3];\n var sweep = coords[4];\n var ex = coords[5];\n var ey = coords[6];\n var segs = arcToSegments(ex, ey, rx, ry, large, sweep, rot, x, y);\n for (var i=0; i<segs.length; i++) {\n var bez = segmentToBezier.apply(null, segs[i]);\n bounds.add(bez[0], bez[1]);\n bounds.add(bez[2], bez[3]);\n bounds.add(bez[4], bez[5]);\n }\n}\n\nvar arcToSegmentsCache = { },\n segmentToBezierCache = { },\n join = Array.prototype.join,\n argsStr;\n\n// Copied from Inkscape svgtopdf, thanks!\nfunction arcToSegments(x, y, rx, ry, large, sweep, rotateX, ox, oy) {\n argsStr = join.call(arguments);\n if (arcToSegmentsCache[argsStr]) {\n return arcToSegmentsCache[argsStr];\n }\n\n var th = rotateX * (Math.PI/180);\n var sin_th = Math.sin(th);\n var cos_th = Math.cos(th);\n rx = Math.abs(rx);\n ry = Math.abs(ry);\n var px = cos_th * (ox - x) * 0.5 + sin_th * (oy - y) * 0.5;\n var py = cos_th * (oy - y) * 0.5 - sin_th * (ox - x) * 0.5;\n var pl = (px*px) / (rx*rx) + (py*py) / (ry*ry);\n if (pl > 1) {\n pl = Math.sqrt(pl);\n rx *= pl;\n ry *= pl;\n }\n\n var a00 = cos_th / rx;\n var a01 = sin_th / rx;\n var a10 = (-sin_th) / ry;\n var a11 = (cos_th) / ry;\n var x0 = a00 * ox + a01 * oy;\n var y0 = a10 * ox + a11 * oy;\n var x1 = a00 * x + a01 * y;\n var y1 = a10 * x + a11 * y;\n\n var d = (x1-x0) * (x1-x0) + (y1-y0) * (y1-y0);\n var sfactor_sq = 1 / d - 0.25;\n if (sfactor_sq < 0) sfactor_sq = 0;\n var sfactor = Math.sqrt(sfactor_sq);\n if (sweep == large) sfactor = -sfactor;\n var xc = 0.5 * (x0 + x1) - sfactor * (y1-y0);\n var yc = 0.5 * (y0 + y1) + sfactor * (x1-x0);\n\n var th0 = Math.atan2(y0-yc, x0-xc);\n var th1 = Math.atan2(y1-yc, x1-xc);\n\n var th_arc = th1-th0;\n if (th_arc < 0 && sweep == 1){\n th_arc += 2*Math.PI;\n } else if (th_arc > 0 && sweep == 0) {\n th_arc -= 2 * Math.PI;\n }\n\n var segments = Math.ceil(Math.abs(th_arc / (Math.PI * 0.5 + 0.001)));\n var result = [];\n for (var i=0; i<segments; i++) {\n var th2 = th0 + i * th_arc / segments;\n var th3 = th0 + (i+1) * th_arc / segments;\n result[i] = [xc, yc, th2, th3, rx, ry, sin_th, cos_th];\n }\n\n return (arcToSegmentsCache[argsStr] = result);\n}\n\nfunction segmentToBezier(cx, cy, th0, th1, rx, ry, sin_th, cos_th) {\n argsStr = join.call(arguments);\n if (segmentToBezierCache[argsStr]) {\n return segmentToBezierCache[argsStr];\n }\n\n var a00 = cos_th * rx;\n var a01 = -sin_th * ry;\n var a10 = sin_th * rx;\n var a11 = cos_th * ry;\n\n var cos_th0 = Math.cos(th0);\n var sin_th0 = Math.sin(th0);\n var cos_th1 = Math.cos(th1);\n var sin_th1 = Math.sin(th1);\n\n var th_half = 0.5 * (th1 - th0);\n var sin_th_h2 = Math.sin(th_half * 0.5);\n var t = (8/3) * sin_th_h2 * sin_th_h2 / Math.sin(th_half);\n var x1 = cx + cos_th0 - t * sin_th0;\n var y1 = cy + sin_th0 + t * cos_th0;\n var x3 = cx + cos_th1;\n var y3 = cy + sin_th1;\n var x2 = x3 + t * sin_th1;\n var y2 = y3 - t * cos_th1;\n\n return (segmentToBezierCache[argsStr] = [\n a00 * x1 + a01 * y1, a10 * x1 + a11 * y1,\n a00 * x2 + a01 * y2, a10 * x2 + a11 * y2,\n a00 * x3 + a01 * y3, a10 * x3 + a11 * y3\n ]);\n}\n\nfunction render(g, path, l, t) {\n var current, // current instruction\n previous = null,\n x = 0, // current x\n y = 0, // current y\n controlX = 0, // current control point x\n controlY = 0, // current control point y\n tempX,\n tempY,\n tempControlX,\n tempControlY,\n bounds = new Bounds();\n if (l == undefined) l = 0;\n if (t == undefined) t = 0;\n\n g.beginPath();\n\n for (var i=0, len=path.length; i<len; ++i) {\n current = path[i];\n\n switch (current[0]) { // first letter\n\n case 'l': // lineto, relative\n x += current[1];\n y += current[2];\n g.lineTo(x + l, y + t);\n bounds.add(x, y);\n break;\n\n case 'L': // lineto, absolute\n x = current[1];\n y = current[2];\n g.lineTo(x + l, y + t);\n bounds.add(x, y);\n break;\n\n case 'h': // horizontal lineto, relative\n x += current[1];\n g.lineTo(x + l, y + t);\n bounds.add(x, y);\n break;\n\n case 'H': // horizontal lineto, absolute\n x = current[1];\n g.lineTo(x + l, y + t);\n bounds.add(x, y);\n break;\n\n case 'v': // vertical lineto, relative\n y += current[1];\n g.lineTo(x + l, y + t);\n bounds.add(x, y);\n break;\n\n case 'V': // verical lineto, absolute\n y = current[1];\n g.lineTo(x + l, y + t);\n bounds.add(x, y);\n break;\n\n case 'm': // moveTo, relative\n x += current[1];\n y += current[2];\n g.moveTo(x + l, y + t);\n bounds.add(x, y);\n break;\n\n case 'M': // moveTo, absolute\n x = current[1];\n y = current[2];\n g.moveTo(x + l, y + t);\n bounds.add(x, y);\n break;\n\n case 'c': // bezierCurveTo, relative\n tempX = x + current[5];\n tempY = y + current[6];\n controlX = x + current[3];\n controlY = y + current[4];\n g.bezierCurveTo(\n x + current[1] + l, // x1\n y + current[2] + t, // y1\n controlX + l, // x2\n controlY + t, // y2\n tempX + l,\n tempY + t\n );\n bounds.add(x + current[1], y + current[2]);\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n x = tempX;\n y = tempY;\n break;\n\n case 'C': // bezierCurveTo, absolute\n x = current[5];\n y = current[6];\n controlX = current[3];\n controlY = current[4];\n g.bezierCurveTo(\n current[1] + l,\n current[2] + t,\n controlX + l,\n controlY + t,\n x + l,\n y + t\n );\n bounds.add(current[1], current[2]);\n bounds.add(controlX, controlY);\n bounds.add(x, y);\n break;\n\n case 's': // shorthand cubic bezierCurveTo, relative\n // transform to absolute x,y\n tempX = x + current[3];\n tempY = y + current[4];\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n g.bezierCurveTo(\n controlX + l,\n controlY + t,\n x + current[1] + l,\n y + current[2] + t,\n tempX + l,\n tempY + t\n );\n bounds.add(controlX, controlY);\n bounds.add(x + current[1], y + current[2]);\n bounds.add(tempX, tempY);\n\n // set control point to 2nd one of this command\n // \"... the first control point is assumed to be the reflection of the second control point on the previous command relative to the current point.\"\n controlX = x + current[1];\n controlY = y + current[2];\n\n x = tempX;\n y = tempY;\n break;\n\n case 'S': // shorthand cubic bezierCurveTo, absolute\n tempX = current[3];\n tempY = current[4];\n // calculate reflection of previous control points\n controlX = 2*x - controlX;\n controlY = 2*y - controlY;\n g.bezierCurveTo(\n controlX + l,\n controlY + t,\n current[1] + l,\n current[2] + t,\n tempX + l,\n tempY + t\n );\n x = tempX;\n y = tempY;\n bounds.add(current[1], current[2]);\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n // set control point to 2nd one of this command\n // \"... the first control point is assumed to be the reflection of the second control point on the previous command relative to the current point.\"\n controlX = current[1];\n controlY = current[2];\n\n break;\n\n case 'q': // quadraticCurveTo, relative\n // transform to absolute x,y\n tempX = x + current[3];\n tempY = y + current[4];\n\n controlX = x + current[1];\n controlY = y + current[2];\n\n g.quadraticCurveTo(\n controlX + l,\n controlY + t,\n tempX + l,\n tempY + t\n );\n x = tempX;\n y = tempY;\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n tempX = current[3];\n tempY = current[4];\n\n g.quadraticCurveTo(\n current[1] + l,\n current[2] + t,\n tempX + l,\n tempY + t\n );\n x = tempX;\n y = tempY;\n controlX = current[1];\n controlY = current[2];\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n break;\n\n case 't': // shorthand quadraticCurveTo, relative\n\n // transform to absolute x,y\n tempX = x + current[1];\n tempY = y + current[2];\n\n if (previous[0].match(/[QqTt]/) === null) {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n else if (previous[0] === 't') {\n // calculate reflection of previous control points for t\n controlX = 2 * x - tempControlX;\n controlY = 2 * y - tempControlY;\n }\n else if (previous[0] === 'q') {\n // calculate reflection of previous control points for q\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n }\n\n tempControlX = controlX;\n tempControlY = controlY;\n\n g.quadraticCurveTo(\n controlX + l,\n controlY + t,\n tempX + l,\n tempY + t\n );\n x = tempX;\n y = tempY;\n controlX = x + current[1];\n controlY = y + current[2];\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n break;\n\n case 'T':\n tempX = current[1];\n tempY = current[2];\n\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n g.quadraticCurveTo(\n controlX + l,\n controlY + t,\n tempX + l,\n tempY + t\n );\n x = tempX;\n y = tempY;\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n break;\n\n case 'a':\n drawArc(g, x + l, y + t, [\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6] + x + l,\n current[7] + y + t\n ], bounds, l, t);\n x += current[6];\n y += current[7];\n break;\n\n case 'A':\n drawArc(g, x + l, y + t, [\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6] + l,\n current[7] + t\n ], bounds, l, t);\n x = current[6];\n y = current[7];\n break;\n\n case 'z':\n case 'Z':\n g.closePath();\n break;\n }\n previous = current;\n }\n return bounds.translate(l, t);\n}\n\nfunction bounds(path, bounds) {\n var current, // current instruction\n previous = null,\n x = 0, // current x\n y = 0, // current y\n controlX = 0, // current control point x\n controlY = 0, // current control point y\n tempX,\n tempY,\n tempControlX,\n tempControlY;\n\n for (var i=0, len=path.length; i<len; ++i) {\n current = path[i];\n\n switch (current[0]) { // first letter\n\n case 'l': // lineto, relative\n x += current[1];\n y += current[2];\n bounds.add(x, y);\n break;\n\n case 'L': // lineto, absolute\n x = current[1];\n y = current[2];\n bounds.add(x, y);\n break;\n\n case 'h': // horizontal lineto, relative\n x += current[1];\n bounds.add(x, y);\n break;\n\n case 'H': // horizontal lineto, absolute\n x = current[1];\n bounds.add(x, y);\n break;\n\n case 'v': // vertical lineto, relative\n y += current[1];\n bounds.add(x, y);\n break;\n\n case 'V': // verical lineto, absolute\n y = current[1];\n bounds.add(x, y);\n break;\n\n case 'm': // moveTo, relative\n x += current[1];\n y += current[2];\n bounds.add(x, y);\n break;\n\n case 'M': // moveTo, absolute\n x = current[1];\n y = current[2];\n bounds.add(x, y);\n break;\n\n case 'c': // bezierCurveTo, relative\n tempX = x + current[5];\n tempY = y + current[6];\n controlX = x + current[3];\n controlY = y + current[4];\n bounds.add(x + current[1], y + current[2]);\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n x = tempX;\n y = tempY;\n break;\n\n case 'C': // bezierCurveTo, absolute\n x = current[5];\n y = current[6];\n controlX = current[3];\n controlY = current[4];\n bounds.add(current[1], current[2]);\n bounds.add(controlX, controlY);\n bounds.add(x, y);\n break;\n\n case 's': // shorthand cubic bezierCurveTo, relative\n // transform to absolute x,y\n tempX = x + current[3];\n tempY = y + current[4];\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n bounds.add(controlX, controlY);\n bounds.add(x + current[1], y + current[2]);\n bounds.add(tempX, tempY);\n\n // set control point to 2nd one of this command\n // \"... the first control point is assumed to be the reflection of the second control point on the previous command relative to the current point.\"\n controlX = x + current[1];\n controlY = y + current[2];\n\n x = tempX;\n y = tempY;\n break;\n\n case 'S': // shorthand cubic bezierCurveTo, absolute\n tempX = current[3];\n tempY = current[4];\n // calculate reflection of previous control points\n controlX = 2*x - controlX;\n controlY = 2*y - controlY;\n x = tempX;\n y = tempY;\n bounds.add(current[1], current[2]);\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n // set control point to 2nd one of this command\n // \"... the first control point is assumed to be the reflection of the second control point on the previous command relative to the current point.\"\n controlX = current[1];\n controlY = current[2];\n\n break;\n\n case 'q': // quadraticCurveTo, relative\n // transform to absolute x,y\n tempX = x + current[3];\n tempY = y + current[4];\n\n controlX = x + current[1];\n controlY = y + current[2];\n\n x = tempX;\n y = tempY;\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n tempX = current[3];\n tempY = current[4];\n\n x = tempX;\n y = tempY;\n controlX = current[1];\n controlY = current[2];\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n break;\n\n case 't': // shorthand quadraticCurveTo, relative\n\n // transform to absolute x,y\n tempX = x + current[1];\n tempY = y + current[2];\n\n if (previous[0].match(/[QqTt]/) === null) {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n else if (previous[0] === 't') {\n // calculate reflection of previous control points for t\n controlX = 2 * x - tempControlX;\n controlY = 2 * y - tempControlY;\n }\n else if (previous[0] === 'q') {\n // calculate reflection of previous control points for q\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n }\n\n tempControlX = controlX;\n tempControlY = controlY;\n\n x = tempX;\n y = tempY;\n controlX = x + current[1];\n controlY = y + current[2];\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n break;\n\n case 'T':\n tempX = current[1];\n tempY = current[2];\n\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n\n x = tempX;\n y = tempY;\n bounds.add(controlX, controlY);\n bounds.add(tempX, tempY);\n break;\n\n case 'a':\n boundArc(x, y, [\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6] + x,\n current[7] + y\n ], bounds);\n x += current[6];\n y += current[7];\n break;\n\n case 'A':\n boundArc(x, y, [\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n current[7]\n ], bounds);\n x = current[6];\n y = current[7];\n break;\n\n case 'z':\n case 'Z':\n break;\n }\n previous = current;\n }\n return bounds;\n}\n\nfunction area(items) {\n var o = items[0];\n var area;\n \n if (o.orient === \"horizontal\") {\n area = d3.svg.area()\n .y(function(d) { return d.y; })\n .x0(function(d) { return d.x; })\n .x1(function(d) { return d.x + d.width; });\n } else {\n area = d3.svg.area()\n .x(function(d) { return d.x; })\n .y1(function(d) { return d.y; })\n .y0(function(d) { return d.y + d.height; });\n }\n \n if (o.interpolate) area.interpolate(o.interpolate);\n if (o.tension != null) area.tension(o.tension);\n return area(items);\n}\n\nfunction line(items) {\n var o = items[0];\n var line = d3.svg.line()\n .x(function(d) { return d.x; })\n .y(function(d) { return d.y; });\n if (o.interpolate) line.interpolate(o.interpolate);\n if (o.tension != null) line.tension(o.tension);\n return line(items);\n}\n\nmodule.exports = {\n parse: parse,\n render: render,\n bounds: bounds,\n area: area,\n line: line\n};",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n dl = require('datalib'),\n config = require('../../util/config'),\n SVGBuilder = require('./svg');\n\nvar renderer = function() {\n this._builder = null;\n};\n\nvar prototype = renderer.prototype;\n\nprototype.initialize = function(el, width, height, pad) {\n this._builder = new SVGBuilder();\n return this.resize(width, height, pad);\n}\n\nprototype.resize = function(width, height, pad) {\n this._width = width;\n this._height = height;\n this._padding = pad || {top:0, left:0, bottom:0, right:0};\n this._autopad = dl.isString(this._padding) ? 1 : 0;\n\n var w = this._width, h = this._height, pad = this._padding;\n \n // (re-)configure builder size\n this._builder.initialize(null, w, h, pad);\n\n return this;\n};\n\nprototype.render = function(scene, items) {\n // headless always draws the entire scene, ignoring items\n this._builder.render(scene);\n return this;\n};\n\nprototype.svg = function() {\n return this._builder.svg();\n};\n\nmodule.exports = renderer;\n",
"module.exports = {\n Renderer: require('./Renderer')\n};\n",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n dl = require('datalib'),\n config = require('../../util/config');\n\nvar renderer = function() {\n this._gid = 0; // group id counter for d3 dom compat\n this._text = {\n head: \"\",\n root: \"\",\n foot: \"\",\n defs: \"\",\n body: \"\"\n };\n this._defs = {\n gradient: {},\n clipping: {}\n };\n};\n\nfunction open(tag, attr, raw) {\n var s = \"<\" + tag;\n if (attr) {\n for (var key in attr) {\n var val = attr[key];\n if (val != null) {\n s += \" \" + key + '=\"' + val + '\"';\n }\n }\n }\n if (raw) s += \" \" + raw;\n return s + \">\";\n}\n\nfunction close(tag) {\n return \"</\" + tag + \">\";\n}\n\nvar prototype = renderer.prototype;\n\nprototype.initialize = function(el, w, h, pad) {\n var t = this._text;\n\n t.head = open('svg', {\n \"class\": 'marks',\n width: w + pad.left + pad.right,\n height: h + pad.top + pad.bottom,\n }, config.svgNamespace);\n\n t.root = open('g', {\n transform: 'translate(' + pad.left + ',' + pad.top + ')'\n });\n\n t.foot = close('g') + close('svg');\n};\n\nprototype.svg = function() {\n var t = this._text;\n return t.head + t.defs + t.root + t.body + t.foot;\n};\n\nprototype.buildDefs = function() {\n var all = this._defs,\n dgrad = dl.keys(all.gradient),\n dclip = dl.keys(all.clipping),\n defs = \"\", grad, clip, i, j;\n\n for (i=0; i<dgrad.length; ++i) {\n var id = dgrad[i],\n def = all.gradient[id],\n stops = def.stops;\n\n defs += open(\"linearGradient\", {\n id: id,\n x1: def.x1,\n x2: def.x2,\n y1: def.y1,\n y2: def.y2\n });\n \n for (j=0; j<stops.length; ++j) {\n defs += open(\"stop\", {\n offset: stops[j].offset,\n \"stop-color\": stops[j].color\n }) + close(\"stop\");\n }\n \n defs += close(\"linearGradient\");\n }\n \n for (i=0; i<dclip.length; ++i) {\n var id = dclip[i],\n def = all.clipping[id];\n\n defs += open(\"clipPath\", {id: id});\n\n defs += open(\"rect\", {\n x: 0,\n y: 0,\n width: def.width,\n height: def.height\n }) + close(\"rect\");\n\n defs += close(\"clipPath\");\n }\n \n if (defs.length > 0) {\n return open(\"defs\") + defs + close(\"defs\");\n } else {\n return \"\"\n }\n return defs;\n};\n\nprototype.render = function(scene) {\n this._gid = 0; // reset the group counter\n this._text.body = this.draw(scene);\n this._text.defs = this.buildDefs();\n};\n\nprototype.draw = function(scene) {\n var meta = MARKS[scene.marktype];\n if (!meta) {\n return; // no known marktype (e.g., an interactor)\n }\n var tag = meta[0],\n attr = meta[1],\n nest = meta[2] || false,\n data = nest ? [scene.items] : scene.items,\n defs = this._defs,\n svg = \"\", i, sty;\n\n var cls = cssClass(scene.def);\n\n // style literals to exactly match the d3 dom\n var styl = null;\n if (cls === 'type-rule' || cls === 'type-path')\n styl = 'style=\"pointer-events: none;\"';\n else if (cls !== 'type-group')\n styl = 'style=\"\"';\n\n svg += open('g', {\n 'id': 'g' + ++this._gid, // d3 dom compat\n 'class': cssClass(scene.def)\n }, styl);\n\n for (i=0; i<data.length; ++i) {\n var sty = tag === 'g' ? null : style(data[i], tag, defs);\n svg += open(tag, attr(data[i], defs), sty);\n if (tag === 'text') svg += escape_text(data[i].text);\n if (tag === 'g') svg += this.drawGroup(data[i]);\n svg += close(tag);\n }\n\n return svg + close('g');\n};\n\nfunction escape_text(s) {\n s = (s == null ? \"\" : String(s));\n return s.replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\nfunction escape_font(s) {\n return String(s).replace(/\\\"/g, \"'\");\n}\n\nvar MARKS = {\n group: ['g', group],\n area: ['path', area, true],\n line: ['path', line, true],\n arc: ['path', arc],\n path: ['path', path],\n symbol: ['path', symbol],\n rect: ['rect', rect],\n rule: ['line', rule],\n text: ['text', text],\n image: ['image', image]\n};\n\nprototype.drawGroup = function(scene) {\n var svg = \"\",\n axes = scene.axisItems || [],\n items = scene.items,\n legends = scene.legendItems || [],\n i, j, m;\n\n svg += group_bg(scene);\n\n for (j=0, m=axes.length; j<m; ++j) {\n if (axes[j].def.layer === \"back\") {\n svg += this.draw(axes[j]);\n }\n }\n for (j=0, m=items.length; j<m; ++j) {\n svg += this.draw(items[j]);\n }\n for (j=0, m=axes.length; j<m; ++j) {\n if (axes[j].def.layer !== \"back\") {\n svg += this.draw(axes[j]);\n }\n }\n for (j=0, m=legends.length; j<m; ++j) {\n svg += this.draw(legends[j]);\n }\n\n return svg;\n};\n\n///\n\nfunction group_bg(o) {\n var w = o.width || 0,\n h = o.height || 0;\n\n var styl = o.mark.interactive === false ?\n 'style=\"pointer-events: none;\"' : \n 'style=\"\"';\n\n return open('rect', {\n 'class': 'background'\n }, styl) + close('rect');\n}\n\nfunction group(o, defs) {\n var x = o.x || 0,\n y = o.y || 0,\n attr = {transform: \"translate(\"+x+\",\"+y+\")\"};\n\n if (o.clip) {\n var c = {width: o.width || 0, height: o.height || 0},\n id = o.clip_id || (o.clip_id = \"clip\" + clip_id++);\n defs.clipping[id] = c;\n attr[\"clip-path\"] = \"url(#\"+id+\")\";\n }\n\n return attr;\n}\n\nfunction arc(o) {\n var x = o.x || 0,\n y = o.y || 0;\n return {\n transform: \"translate(\"+x+\",\"+y+\")\",\n d: arc_path(o)\n };\n}\n\nfunction area(items) {\n if (!items.length) return;\n var o = items[0],\n path = o.orient === \"horizontal\" ? area_path_h : area_path_v;\n path\n .interpolate(o.interpolate || \"linear\")\n .tension(o.tension == null ? 0.7 : o.tension);\n return {d: path(items)};\n}\n\nfunction line(items) {\n if (!items.length) return;\n var o = items[0];\n line_path\n .interpolate(o.interpolate || \"linear\")\n .tension(o.tension == null ? 0.7 : o.tension);\n return {d: line_path(items)};\n}\n\nfunction path(o) {\n var x = o.x || 0,\n y = o.y || 0;\n return {\n transform: \"translate(\"+x+\",\"+y+\")\",\n d: o.path\n };\n}\n\nfunction rect(o) {\n return {\n x: o.x || 0,\n y: o.y || 0,\n width: o.width || 0,\n height: o.height || 0\n };\n}\n\nfunction rule(o) {\n var x1 = o.x || 0,\n y1 = o.y || 0;\n return {\n x1: x1,\n y1: y1,\n x2: o.x2 != null ? o.x2 : x1,\n y2: o.y2 != null ? o.y2 : y1\n };\n}\n\nfunction symbol(o) {\n var x = o.x || 0,\n y = o.y || 0;\n return {\n transform: \"translate(\"+x+\",\"+y+\")\",\n d: symbol_path(o)\n };\n}\n\nfunction image(o) {\n var w = o.width || (o.image && o.image.width) || 0,\n h = o.height || (o.image && o.image.height) || 0,\n x = o.x - (o.align === \"center\"\n ? w/2 : (o.align === \"right\" ? w : 0)),\n y = o.y - (o.baseline === \"middle\"\n ? h/2 : (o.baseline === \"bottom\" ? h : 0)),\n url = config.load.baseURL + o.url;\n \n return {\n \"xlink:href\": url,\n x: x,\n y: y,\n width: w,\n height: h\n };\n}\n\nfunction text(o) {\n var x = o.x || 0,\n y = o.y || 0,\n dx = o.dx || 0,\n dy = o.dy || 0,\n a = o.angle || 0,\n r = o.radius || 0,\n align = textAlign[o.align || \"left\"],\n base = o.baseline===\"top\" ? \".9em\"\n : o.baseline===\"middle\" ? \".35em\" : 0;\n\n if (r) {\n var t = (o.theta || 0) - Math.PI/2;\n x += r * Math.cos(t);\n y += r * Math.sin(t);\n }\n\n return {\n x: x + dx,\n y: y + dy,\n 'text-anchor': align,\n transform: a ? \"rotate(\"+a+\" \"+x+\",\"+y+\")\" : null,\n dy: base ? base : null\n };\n}\n\n///\n\nfunction cssClass(def) {\n var cls = \"type-\" + def.type;\n if (def.name) cls += \" \" + def.name;\n return cls;\n}\n\nfunction x(o) { return o.x || 0; }\nfunction y(o) { return o.y || 0; }\nfunction xw(o) { return o.x + o.width || 0; }\nfunction yh(o) { return o.y + o.height || 0; }\nfunction key(o) { return o.key; }\nfunction size(o) { return o.size==null ? 100 : o.size; }\nfunction shape(o) { return o.shape || \"circle\"; }\n\nvar arc_path = d3.svg.arc(),\n area_path_v = d3.svg.area().x(x).y1(y).y0(yh),\n area_path_h = d3.svg.area().y(y).x0(xw).x1(x),\n line_path = d3.svg.line().x(x).y(y),\n symbol_path = d3.svg.symbol().type(shape).size(size);\n\nvar mark_id = 0,\n clip_id = 0;\n\nvar textAlign = {\n \"left\": \"start\",\n \"center\": \"middle\",\n \"right\": \"end\"\n};\n\nvar styles = {\n \"fill\": \"fill\",\n \"fillOpacity\": \"fill-opacity\",\n \"stroke\": \"stroke\",\n \"strokeWidth\": \"stroke-width\",\n \"strokeOpacity\": \"stroke-opacity\",\n \"strokeCap\": \"stroke-linecap\",\n \"strokeDash\": \"stroke-dasharray\",\n \"strokeDashOffset\": \"stroke-dashoffset\",\n \"opacity\": \"opacity\"\n};\n\nvar styleProps = dl.keys(styles);\n\nfunction style(d, tag, defs) {\n var i, n, prop, name, value,\n o = d.mark ? d : d.length ? d[0] : null;\n if (o === null) return null;\n\n var s = \"\";\n\n if (tag === 'text') {\n s += 'font: ' + fontString(o) + ';';\n }\n \n for (i=0, n=styleProps.length; i<n; ++i) {\n prop = styleProps[i];\n name = styles[prop];\n value = o[prop];\n\n if (value == null) {\n if (name === \"fill\") s += 'fill: none;';\n } else {\n if (value.id) {\n // ensure definition is included\n defs.gradient[value.id] = value;\n value = \"url(\" + window.location.href + \"#\" + value.id + \")\";\n }\n s += (s.length ? ' ' : '') + name + ': ' + value + ';'\n }\n }\n \n // not that we don't exclude blank styles for d3 dom compat\n return 'style=\"'+s+'\"';\n}\n\nfunction fontString(o) {\n var f = (o.fontStyle ? o.fontStyle + \" \" : \"\")\n + (o.fontVariant ? o.fontVariant + \" \" : \"\")\n + (o.fontWeight ? o.fontWeight + \" \" : \"\")\n + (o.fontSize != null ? o.fontSize : config.render.fontSize) + \"px \"\n + (o.font && escape_font(o.font) || config.render.font);\n return f;\n}\n\nmodule.exports = renderer;\n",
"var dl = require('datalib');\n\nvar handler = function(el, model) {\n this._active = null;\n this._handlers = {};\n if (el) this.initialize(el);\n if (model) this.model(model);\n};\n\nfunction svgHandler(handler) {\n var that = this;\n return function(evt) {\n var target = evt.target,\n item = target.__data__;\n\n if (item) item = item.mark ? item : item[0];\n handler.call(that._obj, evt, item);\n };\n}\n\nfunction eventName(name) {\n var i = name.indexOf(\".\");\n return i < 0 ? name : name.slice(0,i);\n}\n\nvar prototype = handler.prototype;\n\nprototype.initialize = function(el, pad, obj) {\n this._el = d3.select(el).node();\n this._svg = d3.select(el).select(\"svg.marks\").node();\n this._padding = pad;\n this._obj = obj || null;\n return this;\n};\n\nprototype.padding = function(pad) {\n this._padding = pad;\n return this;\n};\n\nprototype.model = function(model) {\n if (!arguments.length) return this._model;\n this._model = model;\n return this;\n};\n\nprototype.handlers = function() {\n var h = this._handlers;\n return dl.keys(h).reduce(function(a, k) {\n return h[k].reduce(function(a, x) { return (a.push(x), a); }, a);\n }, []);\n};\n\n// add an event handler\nprototype.on = function(type, handler) {\n var name = eventName(type),\n h = this._handlers,\n dom = d3.select(this._svg).node();\n \n var x = {\n type: type,\n handler: handler,\n svg: svgHandler.call(this, handler)\n };\n h = h[name] || (h[name] = []);\n h.push(x);\n\n dom.addEventListener(name, x.svg);\n return this;\n};\n\n// remove an event handler\nprototype.off = function(type, handler) {\n var name = eventName(type),\n h = this._handlers[name],\n dom = d3.select(this._svg).node();\n if (!h) return;\n for (var i=h.length; --i>=0;) {\n if (h[i].type !== type) continue;\n if (!handler || h[i].handler === handler) {\n dom.removeEventListener(name, h[i].svg);\n h.splice(i, 1);\n }\n }\n return this;\n};\n\nmodule.exports = handler;",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n dl = require('datalib'),\n marks = require('./marks');\n\nvar renderer = function() {\n this._svg = null;\n this._ctx = null;\n this._el = null;\n this._defs = {\n gradient: {},\n clipping: {}\n };\n};\n\nvar prototype = renderer.prototype;\n\nprototype.initialize = function(el, width, height, pad, bgcolor) {\n this._el = el;\n\n // remove any existing svg element\n d3.select(el).select(\"svg.marks\").remove();\n\n // create svg element and initialize attributes\n this._svg = d3.select(el)\n .append(\"svg\")\n .attr(\"class\", \"marks\");\n\n if (bgcolor != null) {\n this._svg.style(\"background-color\", bgcolor);\n }\n \n // set the svg root group\n this._ctx = this._svg.append(\"g\");\n \n return this.resize(width, height, pad);\n};\n\nprototype.resize = function(width, height, pad) {\n this._width = width;\n this._height = height;\n this._padding = pad;\n \n this._svg\n .attr(\"width\", width + pad.left + pad.right)\n .attr(\"height\", height + pad.top + pad.bottom);\n \n this._ctx\n .attr(\"transform\", \"translate(\"+pad.left+\",\"+pad.top+\")\");\n\n return this;\n};\n\nprototype.context = function() {\n return this._ctx;\n};\n\nprototype.element = function() {\n return this._el;\n};\n\nprototype.updateDefs = function() {\n var svg = this._svg,\n all = this._defs,\n dgrad = dl.keys(all.gradient),\n dclip = dl.keys(all.clipping),\n defs = svg.select(\"defs\"), grad, clip;\n\n // get or create svg defs block\n if (dgrad.length===0 && dclip.length==0) { defs.remove(); return; }\n if (defs.empty()) defs = svg.insert(\"defs\", \":first-child\");\n \n grad = defs.selectAll(\"linearGradient\").data(dgrad, dl.identity);\n grad.enter().append(\"linearGradient\").attr(\"id\", dl.identity);\n grad.exit().remove();\n grad.each(function(id) {\n var def = all.gradient[id],\n grd = d3.select(this);\n\n // set gradient coordinates\n grd.attr({x1: def.x1, x2: def.x2, y1: def.y1, y2: def.y2});\n\n // set gradient stops\n stop = grd.selectAll(\"stop\").data(def.stops);\n stop.enter().append(\"stop\");\n stop.exit().remove();\n stop.attr(\"offset\", function(d) { return d.offset; })\n .attr(\"stop-color\", function(d) { return d.color; });\n });\n \n clip = defs.selectAll(\"clipPath\").data(dclip, dl.identity);\n clip.enter().append(\"clipPath\").attr(\"id\", dl.identity);\n clip.exit().remove();\n clip.each(function(id) {\n var def = all.clipping[id],\n cr = d3.select(this).selectAll(\"rect\").data([1]);\n cr.enter().append(\"rect\");\n cr.attr(\"x\", 0)\n .attr(\"y\", 0)\n .attr(\"width\", def.width)\n .attr(\"height\", def.height);\n });\n};\n\nprototype.render = function(scene, items) {\n marks.current = this;\n\n if (items) {\n this.renderItems(dl.array(items));\n } else {\n this.draw(this._ctx, scene, -1);\n }\n this.updateDefs();\n\n delete marks.current;\n};\n\nprototype.renderItems = function(items) {\n var item, node, type, nest, i, n;\n\n for (i=0, n=items.length; i<n; ++i) {\n item = items[i];\n node = item._svg;\n type = item.mark.marktype;\n\n item = marks.nested[type] ? item.mark.items : item;\n marks.update[type].call(node, item);\n marks.style.call(node, item);\n }\n}\n\nprototype.draw = function(ctx, scene, index) {\n var marktype = scene.marktype,\n renderer = marks.draw[marktype];\n renderer.call(this, ctx, scene, index);\n};\n\nmodule.exports = renderer;\n",
"var dl = require('datalib'),\n d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n config = require('../../util/config');\n\nfunction x(o) { return o.x || 0; }\nfunction y(o) { return o.y || 0; }\nfunction xw(o) { return o.x + o.width || 0; }\nfunction yh(o) { return o.y + o.height || 0; }\nfunction key(o) { return o.key; }\nfunction size(o) { return o.size==null ? 100 : o.size; }\nfunction shape(o) { return o.shape || \"circle\"; }\n \nvar arc_path = d3.svg.arc(),\n area_path_v = d3.svg.area().x(x).y1(y).y0(yh),\n area_path_h = d3.svg.area().y(y).x0(xw).x1(x),\n line_path = d3.svg.line().x(x).y(y),\n symbol_path = d3.svg.symbol().type(shape).size(size);\n\nvar mark_id = 0,\n clip_id = 0;\n\nvar textAlign = {\n \"left\": \"start\",\n \"center\": \"middle\",\n \"right\": \"end\"\n};\n\nvar styles = {\n \"fill\": \"fill\",\n \"fillOpacity\": \"fill-opacity\",\n \"stroke\": \"stroke\",\n \"strokeWidth\": \"stroke-width\",\n \"strokeOpacity\": \"stroke-opacity\",\n \"strokeCap\": \"stroke-linecap\",\n \"strokeDash\": \"stroke-dasharray\",\n \"strokeDashOffset\": \"stroke-dashoffset\",\n \"opacity\": \"opacity\"\n};\nvar styleProps = dl.keys(styles);\n\nfunction style(d) {\n var i, n, prop, name, value,\n o = d.mark ? d : d.length ? d[0] : null;\n if (o === null) return;\n\n for (i=0, n=styleProps.length; i<n; ++i) {\n prop = styleProps[i];\n name = styles[prop];\n value = o[prop];\n\n if (value == null) {\n if (name === \"fill\") this.style.setProperty(name, \"none\", null);\n else this.style.removeProperty(name);\n } else {\n if (value.id) {\n // ensure definition is included\n marks.current._defs.gradient[value.id] = value;\n value = \"url(\" + window.location.href + \"#\" + value.id + \")\";\n }\n this.style.setProperty(name, value+\"\", null);\n }\n }\n}\n\nfunction arc(o) {\n var x = o.x || 0,\n y = o.y || 0;\n this.setAttribute(\"transform\", \"translate(\"+x+\",\"+y+\")\");\n this.setAttribute(\"d\", arc_path(o));\n}\n\nfunction area(items) {\n if (!items.length) return;\n var o = items[0],\n path = o.orient === \"horizontal\" ? area_path_h : area_path_v;\n path\n .interpolate(o.interpolate || \"linear\")\n .tension(o.tension == null ? 0.7 : o.tension);\n this.setAttribute(\"d\", path(items));\n}\n\nfunction line(items) {\n if (!items.length) return;\n var o = items[0];\n line_path\n .interpolate(o.interpolate || \"linear\")\n .tension(o.tension == null ? 0.7 : o.tension);\n this.setAttribute(\"d\", line_path(items));\n}\n\nfunction path(o) {\n var x = o.x || 0,\n y = o.y || 0;\n this.setAttribute(\"transform\", \"translate(\"+x+\",\"+y+\")\");\n if (o.path != null) this.setAttribute(\"d\", o.path);\n}\n\nfunction rect(o) {\n this.setAttribute(\"x\", o.x || 0);\n this.setAttribute(\"y\", o.y || 0);\n this.setAttribute(\"width\", o.width || 0);\n this.setAttribute(\"height\", o.height || 0);\n}\n\nfunction rule(o) {\n var x1 = o.x || 0,\n y1 = o.y || 0;\n this.setAttribute(\"x1\", x1);\n this.setAttribute(\"y1\", y1);\n this.setAttribute(\"x2\", o.x2 != null ? o.x2 : x1);\n this.setAttribute(\"y2\", o.y2 != null ? o.y2 : y1);\n}\n\nfunction symbol(o) {\n var x = o.x || 0,\n y = o.y || 0;\n this.setAttribute(\"transform\", \"translate(\"+x+\",\"+y+\")\");\n this.setAttribute(\"d\", symbol_path(o));\n}\n\nfunction image(o) {\n var w = o.width || (o.image && o.image.width) || 0,\n h = o.height || (o.image && o.image.height) || 0,\n x = o.x - (o.align === \"center\"\n ? w/2 : (o.align === \"right\" ? w : 0)),\n y = o.y - (o.baseline === \"middle\"\n ? h/2 : (o.baseline === \"bottom\" ? h : 0)),\n url = dl.load.sanitizeUrl(dl.extend({url: o.url}, config.load));\n \n if (url) {\n this.setAttributeNS(\"http://www.w3.org/1999/xlink\", \"href\", url);\n }\n\n this.setAttribute(\"x\", x);\n this.setAttribute(\"y\", y);\n this.setAttribute(\"width\", w);\n this.setAttribute(\"height\", h);\n}\n \nfunction fontString(o) {\n return (o.fontStyle ? o.fontStyle + \" \" : \"\")\n + (o.fontVariant ? o.fontVariant + \" \" : \"\")\n + (o.fontWeight ? o.fontWeight + \" \" : \"\")\n + (o.fontSize != null ? o.fontSize : config.render.fontSize) + \"px \"\n + (o.font || config.render.font);\n}\n\nfunction text(o) {\n var x = o.x || 0,\n y = o.y || 0,\n dx = o.dx || 0,\n dy = o.dy || 0,\n a = o.angle || 0,\n r = o.radius || 0,\n align = textAlign[o.align || \"left\"],\n base = o.baseline===\"top\" ? \".9em\"\n : o.baseline===\"middle\" ? \".35em\" : 0;\n\n if (r) {\n var t = (o.theta || 0) - Math.PI/2;\n x += r * Math.cos(t);\n y += r * Math.sin(t);\n }\n\n this.setAttribute(\"x\", x + dx);\n this.setAttribute(\"y\", y + dy);\n this.setAttribute(\"text-anchor\", align);\n \n if (a) this.setAttribute(\"transform\", \"rotate(\"+a+\" \"+x+\",\"+y+\")\");\n else this.removeAttribute(\"transform\");\n \n if (base) this.setAttribute(\"dy\", base);\n else this.removeAttribute(\"dy\");\n \n this.textContent = o.text;\n this.style.setProperty(\"font\", fontString(o), null);\n}\n\nfunction group(o) {\n var x = o.x || 0,\n y = o.y || 0;\n this.setAttribute(\"transform\", \"translate(\"+x+\",\"+y+\")\");\n\n if (o.clip) {\n var c = {width: o.width || 0, height: o.height || 0},\n id = o.clip_id || (o.clip_id = \"clip\" + clip_id++);\n marks.current._defs.clipping[id] = c;\n this.setAttribute(\"clip-path\", \"url(#\"+id+\")\");\n }\n}\n\nfunction group_bg(o) {\n var w = o.width || 0,\n h = o.height || 0;\n this.setAttribute(\"width\", w);\n this.setAttribute(\"height\", h);\n}\n\nfunction cssClass(def) {\n var cls = \"type-\" + def.type;\n if (def.name) cls += \" \" + def.name;\n return cls;\n}\n\nfunction draw(tag, attr, nest) {\n return function(g, scene, index) {\n drawMark(g, scene, index, tag, attr, nest);\n };\n}\n\nfunction drawMark(g, scene, index, tag, attr, nest) {\n var data = nest ? [scene.items] : scene.items,\n evts = scene.interactive===false ? \"none\" : null,\n grps = g.node().childNodes,\n notG = (tag !== \"g\"),\n p = (p = grps[index+1]) // +1 to skip group background rect\n ? d3.select(p)\n : g.append(\"g\")\n .attr(\"id\", \"g\"+(++mark_id))\n .attr(\"class\", cssClass(scene.def));\n\n var id = p.attr(\"id\"),\n s = \"#\" + id + \" > \" + tag,\n m = p.selectAll(s).data(data),\n e = m.enter().append(tag);\n\n if (notG) {\n p.style(\"pointer-events\", evts);\n e.each(function(d) {\n if (d.mark) d._svg = this;\n else if (d.length) d[0]._svg = this;\n });\n } else {\n e.append(\"rect\").attr(\"class\",\"background\").style(\"pointer-events\",evts);\n }\n \n m.exit().remove();\n m.each(attr);\n if (notG) m.each(style);\n else p.selectAll(s+\" > rect.background\").each(group_bg).each(style);\n \n return p;\n}\n\nfunction drawGroup(g, scene, index) {\n var p = drawMark(g, scene, index, \"g\", group),\n c = p.node().childNodes, n = c.length, i, j, m;\n \n for (i=0; i<n; ++i) {\n var items = c[i].__data__.items,\n legends = c[i].__data__.legendItems || [],\n axes = c[i].__data__.axisItems || [],\n sel = d3.select(c[i]),\n idx = 0;\n\n for (j=0, m=axes.length; j<m; ++j) {\n if (axes[j].def.layer === \"back\") {\n drawGroup.call(this, sel, axes[j], idx++);\n }\n }\n for (j=0, m=items.length; j<m; ++j) {\n this.draw(sel, items[j], idx++);\n }\n for (j=0, m=axes.length; j<m; ++j) {\n if (axes[j].def.layer !== \"back\") {\n drawGroup.call(this, sel, axes[j], idx++);\n }\n }\n for (j=0, m=legends.length; j<m; ++j) {\n drawGroup.call(this, sel, legends[j], idx++);\n }\n }\n}\n\nvar marks = module.exports = {\n update: {\n group: rect,\n area: area,\n line: line,\n arc: arc,\n path: path,\n symbol: symbol,\n rect: rect,\n rule: rule,\n text: text,\n image: image\n },\n nested: {\n \"area\": true,\n \"line\": true\n },\n style: style,\n draw: {\n group: drawGroup,\n area: draw(\"path\", area, true),\n line: draw(\"path\", line, true),\n arc: draw(\"path\", arc),\n path: draw(\"path\", path),\n symbol: draw(\"path\", symbol),\n rect: draw(\"rect\", rect),\n rule: draw(\"line\", rule),\n text: draw(\"text\", text),\n image: draw(\"image\", image),\n draw: draw // expose for extensibility\n },\n current: null\n};",
"var dl = require('datalib'),\n Node = require('../dataflow/Node'),\n Encoder = require('./Encoder'),\n bounds = require('../util/boundscalc'),\n C = require('../util/constants'),\n debug = require('../util/debug');\n\nfunction Bounder(graph, mark) {\n this._mark = mark;\n return Node.prototype.init.call(this, graph).router(true);\n}\n\nvar proto = (Bounder.prototype = new Node());\n\nproto.evaluate = function(input) {\n debug(input, [\"bounds\", this._mark.marktype]);\n var i, ilen, j, jlen, group, legend;\n hasLegends = this._mark.marktype == C.GROUP \n && dl.array(this._mark.def.legends).length > 0;\n\n bounds.mark(this._mark, null, !hasLegends);\n\n if(hasLegends) {\n for(i=0, ilen=this._mark.items.length; i<ilen; ++i) {\n group = this._mark.items[i];\n group._legendPositions = null;\n for(j=0, jlen=group.legendItems.length; j<jlen; ++j) {\n legend = group.legendItems[j];\n Encoder.update(this._graph, input.trans, \"vg_legendPosition\", legend.items);\n bounds.mark(legend, null, true);\n }\n }\n\n bounds.mark(this._mark, null, true);\n }\n\n input.reflow = true;\n return input;\n};\n\nmodule.exports = Bounder;",
"var dl = require('datalib'),\n Node = require('../dataflow/Node'),\n Encoder = require('./Encoder'),\n Bounder = require('./Bounder'),\n Item = require('./Item'),\n parseData = require('../parse/data'),\n tuple = require('../dataflow/tuple'),\n changeset = require('../dataflow/changeset'),\n debug = require('../util/debug'),\n C = require('../util/constants');\n\nfunction Builder() { \n return arguments.length ? this.init.apply(this, arguments) : this;\n}\n\nvar proto = (Builder.prototype = new Node());\n\nproto.init = function(graph, def, mark, parent, parent_id, inheritFrom) {\n Node.prototype.init.call(this, graph)\n .router(true)\n .collector(true);\n\n this._def = def;\n this._mark = mark;\n this._from = (def.from ? def.from.data : null) || inheritFrom;\n this._ds = dl.isString(this._from) ? graph.data(this._from) : null;\n this._map = {};\n\n this._revises = false; // Should scenegraph items track _prev?\n\n mark.def = def;\n mark.marktype = def.type;\n mark.interactive = !(def.interactive === false);\n mark.items = [];\n\n this._parent = parent;\n this._parent_id = parent_id;\n\n if(def.from && (def.from.mark || def.from.transform || def.from.modify)) {\n inlineDs.call(this);\n }\n\n // Non-group mark builders are super nodes. Encoder and Bounder remain \n // separate operators but are embedded and called by Builder.evaluate.\n this._isSuper = (this._def.type !== C.GROUP); \n this._encoder = new Encoder(this._graph, this._mark);\n this._bounder = new Bounder(this._graph, this._mark);\n\n if(this._ds) { this._encoder.dependency(C.DATA, this._from); }\n\n // Since Builders are super nodes, copy over encoder dependencies\n // (bounder has no registered dependencies).\n this.dependency(C.DATA, this._encoder.dependency(C.DATA));\n this.dependency(C.SCALES, this._encoder.dependency(C.SCALES));\n this.dependency(C.SIGNALS, this._encoder.dependency(C.SIGNALS));\n\n return this;\n};\n\nproto.revises = function(p) {\n if(!arguments.length) return this._revises;\n\n // If we've not needed prev in the past, but a new inline ds needs it now\n // ensure existing items have prev set.\n if(!this._revises && p) {\n this._items.forEach(function(d) { if(d._prev === undefined) d._prev = C.SENTINEL; });\n }\n\n this._revises = this._revises || p;\n return this;\n};\n\n// Reactive geometry and mark-level transformations are handled here \n// because they need their group's data-joined context. \nfunction inlineDs() {\n var from = this._def.from,\n geom = from.mark,\n src, name, spec, sibling, output;\n\n if(geom) {\n name = [\"vg\", this._parent_id, geom].join(\"_\");\n spec = {\n name: name,\n transform: from.transform, \n modify: from.modify\n };\n } else {\n src = this._graph.data(this._from);\n name = [\"vg\", this._from, this._def.type, src.listeners(true).length].join(\"_\");\n spec = {\n name: name,\n source: this._from,\n transform: from.transform,\n modify: from.modify\n };\n }\n\n this._from = name;\n this._ds = parseData.datasource(this._graph, spec);\n var revises = this._ds.revises();\n\n if(geom) {\n sibling = this.sibling(geom).revises(revises);\n if(sibling._isSuper) sibling.addListener(this._ds.listener());\n else sibling._bounder.addListener(this._ds.listener());\n } else {\n // At this point, we have a new datasource but it is empty as\n // the propagation cycle has already crossed the datasources. \n // So, we repulse just this datasource. This should be safe\n // as the ds isn't connected to the scenegraph yet.\n \n var output = this._ds.source().revises(revises).last();\n input = changeset.create(output);\n\n input.add = output.add;\n input.mod = output.mod;\n input.rem = output.rem;\n input.stamp = null;\n this._graph.propagate(input, this._ds.listener());\n }\n}\n\nproto.pipeline = function() {\n return [this];\n};\n\nproto.connect = function() {\n var builder = this;\n\n this._graph.connect(this.pipeline());\n this._encoder.dependency(C.SCALES).forEach(function(s) {\n builder._parent.scale(s).addListener(builder);\n });\n\n if(this._parent) {\n if(this._isSuper) this.addListener(this._parent._collector);\n else this._bounder.addListener(this._parent._collector);\n }\n\n return this;\n};\n\nproto.disconnect = function() {\n var builder = this;\n if(!this._listeners.length) return this;\n\n Node.prototype.disconnect.call(this);\n this._graph.disconnect(this.pipeline());\n this._encoder.dependency(C.SCALES).forEach(function(s) {\n builder._parent.scale(s).removeListener(builder);\n });\n return this;\n};\n\nproto.sibling = function(name) {\n return this._parent.child(name, this._parent_id);\n};\n\nproto.evaluate = function(input) {\n debug(input, [\"building\", this._from, this._def.type]);\n\n var output, fullUpdate, fcs, data;\n\n if(this._ds) {\n output = changeset.create(input);\n\n // We need to determine if any encoder dependencies have been updated.\n // However, the encoder's data source will likely be updated, and shouldn't\n // trigger all items to mod.\n data = dl.duplicate(output.data);\n delete output.data[this._ds.name()];\n fullUpdate = this._encoder.reevaluate(output);\n output.data = data;\n\n // If a scale or signal in the update propset has been updated, \n // send forward all items for reencoding if we do an early return.\n if(fullUpdate) output.mod = this._mark.items.slice();\n\n fcs = this._ds.last();\n if(!fcs) {\n output.reflow = true\n } else if(fcs.stamp > this._stamp) {\n output = joinDatasource.call(this, fcs, this._ds.values(), fullUpdate);\n }\n } else {\n fullUpdate = this._encoder.reevaluate(input);\n data = dl.isFunction(this._def.from) ? this._def.from() : [C.SENTINEL];\n output = joinValues.call(this, input, data, fullUpdate);\n }\n\n output = this._graph.evaluate(output, this._encoder);\n return this._isSuper ? this._graph.evaluate(output, this._bounder) : output;\n};\n\nfunction newItem() {\n var prev = this._revises ? null : undefined,\n item = tuple.ingest(new Item(this._mark), prev);\n\n // For the root node's item\n if(this._def.width) tuple.set(item, \"width\", this._def.width);\n if(this._def.height) tuple.set(item, \"height\", this._def.height);\n return item;\n};\n\nfunction join(data, keyf, next, output, prev, mod) {\n var i, key, len, item, datum, enter;\n\n for(i=0, len=data.length; i<len; ++i) {\n datum = data[i];\n item = keyf ? this._map[key = keyf(datum)] : prev[i];\n enter = item ? false : (item = newItem.call(this), true);\n item.status = enter ? C.ENTER : C.UPDATE;\n item.datum = datum;\n tuple.set(item, \"key\", key);\n this._map[key] = item;\n next.push(item);\n if(enter) output.add.push(item);\n else if(!mod || (mod && mod[datum._id])) output.mod.push(item);\n }\n}\n\nfunction joinDatasource(input, data, fullUpdate) {\n var output = changeset.create(input),\n keyf = keyFunction(this._def.key || \"_id\"),\n add = input.add, \n mod = input.mod, \n rem = input.rem,\n next = [],\n i, key, len, item, datum, enter;\n\n // Build rems first, and put them at the head of the next items\n // Then build the rest of the data values (which won't contain rem).\n // This will preserve the sort order without needing anything extra.\n\n for(i=0, len=rem.length; i<len; ++i) {\n item = this._map[key = keyf(rem[i])];\n item.status = C.EXIT;\n next.push(item);\n output.rem.push(item);\n this._map[key] = null;\n }\n\n join.call(this, data, keyf, next, output, null, tuple.idMap(fullUpdate ? data : mod));\n\n return (this._mark.items = next, output);\n}\n\nfunction joinValues(input, data, fullUpdate) {\n var output = changeset.create(input),\n keyf = keyFunction(this._def.key),\n prev = this._mark.items || [],\n next = [],\n i, key, len, item, datum, enter;\n\n for (i=0, len=prev.length; i<len; ++i) {\n item = prev[i];\n item.status = C.EXIT;\n if (keyf) this._map[item.key] = item;\n }\n \n join.call(this, data, keyf, next, output, prev, fullUpdate ? tuple.idMap(data) : null);\n\n for (i=0, len=prev.length; i<len; ++i) {\n item = prev[i];\n if (item.status === C.EXIT) {\n tuple.set(item, \"key\", keyf ? item.key : this._items.length);\n next.splice(0, 0, item); // Keep item around for \"exit\" transition.\n output.rem.push(item);\n }\n }\n \n return (this._mark.items = next, output);\n};\n\nfunction keyFunction(key) {\n if (key == null) return null;\n var f = dl.array(key).map(dl.accessor);\n return function(d) {\n for (var s=\"\", i=0, n=f.length; i<n; ++i) {\n if (i>0) s += \"|\";\n s += String(f[i](d));\n }\n return s;\n }\n};\n\nmodule.exports = Builder;",
"var dl = require('datalib'),\n Node = require('../dataflow/Node'),\n bounds = require('../util/boundscalc'),\n C = require('../util/constants'),\n debug = require('../util/debug'),\n EMPTY = {};\n\nfunction Encoder(graph, mark) {\n var props = mark.def.properties || {},\n update = props.update;\n\n Node.prototype.init.call(this, graph)\n\n this._mark = mark;\n\n if(update) {\n this.dependency(C.DATA, update.data);\n this.dependency(C.SCALES, update.scales);\n this.dependency(C.SIGNALS, update.signals);\n this.dependency(C.FIELDS, update.fields);\n }\n\n return this;\n}\n\nvar proto = (Encoder.prototype = new Node());\n\nproto.evaluate = function(input) {\n debug(input, [\"encoding\", this._mark.def.type]);\n var graph = this._graph,\n items = this._mark.items,\n props = this._mark.def.properties || {},\n enter = props.enter,\n update = props.update,\n exit = props.exit,\n preds = this._graph.predicates(),\n sg = graph.signalValues(), // For expediency, get all signal values\n db = graph.dataValues(), \n req = input.request,\n i, len, item, prop;\n\n if(req) {\n if(prop = props[req]) {\n for(i=0, len=input.mod.length; i<len; ++i) {\n item = input.mod[i];\n encode.call(this, prop, item, input.trans, db, sg, preds);\n }\n }\n\n return input; // exit early if given request\n }\n\n // Items marked for removal are at the head of items. Process them first.\n for(i=0, len=input.rem.length; i<len; ++i) {\n item = input.rem[i];\n if(update) encode.call(this, update, item, input.trans, db, sg, preds);\n if(exit) encode.call(this, exit, item, input.trans, db, sg, preds); \n if(input.trans && !exit) input.trans.interpolate(item, EMPTY);\n else if(!input.trans) item.remove();\n }\n\n for(i=0, len=input.add.length; i<len; ++i) {\n item = input.add[i];\n if(enter) encode.call(this, enter, item, input.trans, db, sg, preds);\n if(update) encode.call(this, update, item, input.trans, db, sg, preds);\n item.status = C.UPDATE;\n }\n\n if(update) {\n for(i=0, len=input.mod.length; i<len; ++i) {\n item = input.mod[i];\n encode.call(this, update, item, input.trans, db, sg, preds);\n }\n }\n\n return input;\n};\n\nfunction encode(prop, item, trans, db, sg, preds) {\n var enc = prop.encode;\n enc.call(enc, item, item.mark.group||item, trans, db, sg, preds);\n}\n\n// If a specified property set called, or update property set \n// uses nested fieldrefs, reevaluate all items.\nproto.reevaluate = function(pulse) {\n var props = this._mark.def.properties || {},\n update = props.update;\n\n return pulse.request || \n Node.prototype.reevaluate.call(this, pulse) || \n (update ? update.reflow : false);\n};\n\n// Short-circuit encoder if user specifies items\nEncoder.update = function(graph, trans, request, items) {\n items = dl.array(items);\n var preds = graph.predicates(), \n db = graph.dataValues(),\n sg = graph.signalValues(),\n i, len, item, props, prop;\n\n for (i=0, len=items.length; i<len; ++i) {\n item = items[i];\n props = item.mark.def.properties;\n prop = props && props[request];\n if (prop) {\n encode.call(null, prop, item, trans, db, sg, preds);\n bounds.item(item);\n }\n }\n\n};\n\nmodule.exports = Encoder;",
"var dl = require('datalib'),\n Node = require('../dataflow/Node'),\n Collector = require('../dataflow/Collector'),\n Builder = require('./Builder'),\n Scale = require('./Scale'),\n parseAxes = require('../parse/axes'),\n parseLegends = require('../parse/legends'),\n debug = require('../util/debug'),\n C = require('../util/constants');\n\nfunction GroupBuilder() {\n this._children = {};\n this._scaler = null;\n this._recursor = null;\n\n this._scales = {};\n this.scale = scale.bind(this);\n return arguments.length ? this.init.apply(this, arguments) : this;\n}\n\nvar proto = (GroupBuilder.prototype = new Builder());\n\nproto.init = function(graph, def, mark, parent, parent_id, inheritFrom) {\n var builder = this;\n\n this._scaler = new Node(graph);\n\n (def.scales||[]).forEach(function(s) { \n s = builder.scale(s.name, new Scale(graph, s, builder));\n builder._scaler.addListener(s); // Scales should be computed after group is encoded\n });\n\n this._recursor = new Node(graph);\n this._recursor.evaluate = recurse.bind(this);\n\n var scales = (def.axes||[]).reduce(function(acc, x) {\n return (acc[x.scale] = 1, acc);\n }, {});\n\n scales = (def.legends||[]).reduce(function(acc, x) {\n return (acc[x.size || x.shape || x.fill || x.stroke], acc);\n }, scales);\n\n this._recursor.dependency(C.SCALES, dl.keys(scales));\n\n // We only need a collector for up-propagation of bounds calculation,\n // so only GroupBuilders, and not regular Builders, have collectors.\n this._collector = new Collector(graph);\n\n return Builder.prototype.init.apply(this, arguments);\n};\n\nproto.evaluate = function(input) {\n var output = Builder.prototype.evaluate.apply(this, arguments),\n builder = this;\n\n output.add.forEach(function(group) { buildGroup.call(builder, output, group); });\n return output;\n};\n\nproto.pipeline = function() {\n return [this, this._scaler, this._recursor, this._collector, this._bounder];\n};\n\nproto.disconnect = function() {\n var builder = this;\n dl.keys(builder._children).forEach(function(group_id) {\n builder._children[group_id].forEach(function(c) {\n builder._recursor.removeListener(c.builder);\n c.builder.disconnect();\n })\n });\n\n builder._children = {};\n return Builder.prototype.disconnect.call(this);\n};\n\nproto.child = function(name, group_id) {\n var children = this._children[group_id],\n i = 0, len = children.length,\n child;\n\n for(; i<len; ++i) {\n child = children[i];\n if(child.type == C.MARK && child.builder._def.name == name) break;\n }\n\n return child.builder;\n};\n\nfunction recurse(input) {\n var builder = this,\n hasMarks = dl.array(this._def.marks).length > 0,\n hasAxes = dl.array(this._def.axes).length > 0,\n hasLegends = dl.array(this._def.legends).length > 0,\n i, len, group, pipeline, def, inline = false;\n\n for(i=0, len=input.add.length; i<len; ++i) {\n group = input.add[i];\n if(hasMarks) buildMarks.call(this, input, group);\n if(hasAxes) buildAxes.call(this, input, group);\n if(hasLegends) buildLegends.call(this, input, group);\n }\n\n // Wire up new children builders in reverse to minimize graph rewrites.\n for (i=input.add.length-1; i>=0; --i) {\n group = input.add[i];\n for (j=this._children[group._id].length-1; j>=0; --j) {\n c = this._children[group._id][j];\n c.builder.connect();\n pipeline = c.builder.pipeline();\n def = c.builder._def;\n\n // This new child needs to be built during this propagation cycle.\n // We could add its builder as a listener off the _recursor node, \n // but try to inline it if we can to minimize graph dispatches.\n inline = (def.type !== C.GROUP);\n inline = inline && (this._graph.data(c.from) !== undefined); \n inline = inline && (pipeline[pipeline.length-1].listeners().length == 1); // Reactive geom\n c.inline = inline;\n\n if(inline) c.builder.evaluate(input);\n else this._recursor.addListener(c.builder);\n }\n }\n\n for(i=0, len=input.mod.length; i<len; ++i) {\n group = input.mod[i];\n // Remove temporary connection for marks that draw from a source\n if(hasMarks) {\n builder._children[group._id].forEach(function(c) {\n if(c.type == C.MARK && !c.inline && builder._graph.data(c.from) !== undefined ) {\n builder._recursor.removeListener(c.builder);\n }\n });\n }\n\n // Update axes data defs\n if(hasAxes) {\n parseAxes(builder._graph, builder._def.axes, group.axes, group);\n group.axes.forEach(function(a, i) { a.def() });\n }\n\n // Update legend data defs\n if(hasLegends) {\n parseLegends(builder._graph, builder._def.legends, group.legends, group);\n group.legends.forEach(function(l, i) { l.def() });\n } \n }\n\n for(i=0, len=input.rem.length; i<len; ++i) {\n group = input.rem[i];\n // For deleted groups, disconnect their children\n builder._children[group._id].forEach(function(c) { \n builder._recursor.removeListener(c.builder);\n c.builder.disconnect(); \n });\n delete builder._children[group._id];\n }\n\n return input;\n};\n\nfunction scale(name, scale) {\n var group = this;\n if(arguments.length === 2) return (group._scales[name] = scale, scale);\n while(scale == null) {\n scale = group._scales[name];\n group = group.mark ? group.mark.group : group._parent;\n if(!group) break;\n }\n return scale;\n}\n\nfunction buildGroup(input, group) {\n debug(input, [\"building group\", group._id]);\n\n group._scales = group._scales || {}; \n group.scale = scale.bind(group);\n\n group.items = group.items || [];\n this._children[group._id] = this._children[group._id] || [];\n\n group.axes = group.axes || [];\n group.axisItems = group.axisItems || [];\n\n group.legends = group.legends || [];\n group.legendItems = group.legendItems || [];\n}\n\nfunction buildMarks(input, group) {\n debug(input, [\"building marks\", group._id]);\n var marks = this._def.marks,\n listeners = [],\n mark, from, inherit, i, len, m, b;\n\n for(i=0, len=marks.length; i<len; ++i) {\n mark = marks[i];\n from = mark.from || {};\n inherit = \"vg_\"+group.datum._id;\n group.items[i] = {group: group};\n b = (mark.type === C.GROUP) ? new GroupBuilder() : new Builder();\n b.init(this._graph, mark, group.items[i], this, group._id, inherit);\n this._children[group._id].push({ \n builder: b, \n from: from.data || (from.mark ? (\"vg_\" + group._id + \"_\" + from.mark) : inherit), \n type: C.MARK \n });\n }\n}\n\nfunction buildAxes(input, group) {\n var axes = group.axes,\n axisItems = group.axisItems,\n builder = this;\n\n parseAxes(this._graph, this._def.axes, axes, group);\n axes.forEach(function(a, i) {\n var scale = builder._def.axes[i].scale,\n def = a.def(),\n b = null;\n\n axisItems[i] = {group: group, axisDef: def};\n b = (def.type === C.GROUP) ? new GroupBuilder() : new Builder();\n b.init(builder._graph, def, axisItems[i], builder)\n .dependency(C.SCALES, scale);\n builder._children[group._id].push({ builder: b, type: C.AXIS, scale: scale });\n });\n}\n\nfunction buildLegends(input, group) {\n var legends = group.legends,\n legendItems = group.legendItems,\n builder = this;\n\n parseLegends(this._graph, this._def.legends, legends, group);\n legends.forEach(function(l, i) {\n var scale = l.size() || l.shape() || l.fill() || l.stroke(),\n def = l.def(),\n b = null;\n\n legendItems[i] = {group: group, legendDef: def};\n b = (def.type === C.GROUP) ? new GroupBuilder() : new Builder();\n b.init(builder._graph, def, legendItems[i], builder)\n .dependency(C.SCALES, scale);\n builder._children[group._id].push({ builder: b, type: C.LEGEND, scale: scale });\n });\n}\n\nmodule.exports = GroupBuilder;",
"function Item(mark) {\n this.mark = mark;\n}\n\nvar prototype = Item.prototype;\n\nprototype.hasPropertySet = function(name) {\n var props = this.mark.def.properties;\n return props && props[name] != null;\n};\n\nprototype.cousin = function(offset, index) {\n if (offset === 0) return this;\n offset = offset || -1;\n var mark = this.mark,\n group = mark.group,\n iidx = index==null ? mark.items.indexOf(this) : index,\n midx = group.items.indexOf(mark) + offset;\n return group.items[midx].items[iidx];\n};\n\nprototype.sibling = function(offset) {\n if (offset === 0) return this;\n offset = offset || -1;\n var mark = this.mark,\n iidx = mark.items.indexOf(this) + offset;\n return mark.items[iidx];\n};\n\nprototype.remove = function() {\n var item = this,\n list = item.mark.items,\n i = list.indexOf(item);\n if (i >= 0) (i===list.length-1) ? list.pop() : list.splice(i, 1);\n return item;\n};\n\nprototype.touch = function() {\n if (this.pathCache) this.pathCache = null;\n if (this.mark.pathCache) this.mark.pathCache = null;\n};\n\nmodule.exports = Item;",
"var dl = require('datalib'),\n d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n Node = require('../dataflow/Node'),\n Aggregate = require('../transforms/Aggregate'),\n changeset = require('../dataflow/changeset'),\n debug = require('../util/debug'),\n config = require('../util/config'),\n C = require('../util/constants');\n\nvar GROUP_PROPERTY = {width: 1, height: 1};\n\nfunction Scale(graph, def, parent) {\n this._def = def;\n this._parent = parent;\n this._updated = false;\n return Node.prototype.init.call(this, graph);\n}\n\nvar proto = (Scale.prototype = new Node());\n\nproto.evaluate = function(input) {\n var self = this,\n fn = function(group) { scale.call(self, group); };\n\n this._updated = false;\n input.add.forEach(fn);\n input.mod.forEach(fn);\n\n // Scales are at the end of an encoding pipeline, so they should forward a\n // reflow pulse. Thus, if multiple scales update in the parent group, we don't\n // reevaluate child marks multiple times. \n if (this._updated) input.scales[this._def.name] = 1;\n return changeset.create(input, true);\n};\n\n// All of a scale's dependencies are registered during propagation as we parse\n// dataRefs. So a scale must be responsible for connecting itself to dependents.\nproto.dependency = function(type, deps) {\n if (arguments.length == 2) {\n deps = dl.array(deps);\n for(var i=0, len=deps.length; i<len; ++i) {\n this._graph[type == C.DATA ? C.DATA : C.SIGNAL](deps[i])\n .addListener(this._parent);\n }\n }\n\n return Node.prototype.dependency.call(this, type, deps);\n};\n\nfunction scale(group) {\n var name = this._def.name,\n prev = name + \":prev\",\n s = instance.call(this, group.scale(name)),\n m = s.type===C.ORDINAL ? ordinal : quantitative,\n rng = range.call(this, group);\n\n m.call(this, s, rng, group);\n\n group.scale(name, s);\n group.scale(prev, group.scale(prev) || s);\n\n return s;\n}\n\nfunction instance(scale) {\n var type = this._def.type || C.LINEAR;\n if (!scale || type !== scale.type) {\n var ctor = config.scale[type] || d3.scale[type];\n if (!ctor) dl.error(\"Unrecognized scale type: \" + type);\n (scale = ctor()).type = scale.type || type;\n scale.scaleName = this._def.name;\n scale._prev = {};\n }\n return scale;\n}\n\nfunction ordinal(scale, rng, group) {\n var def = this._def,\n prev = scale._prev,\n dataDrivenRange = false,\n pad = def.padding || 0,\n outer = def.outerPadding == null ? pad : def.outerPadding,\n domain, sort, str, refs;\n \n // range pre-processing for data-driven ranges\n if (dl.isObject(def.range) && !dl.isArray(def.range)) {\n dataDrivenRange = true;\n rng = dataRef.call(this, C.RANGE, def.range, scale, group);\n }\n \n // domain\n domain = dataRef.call(this, C.DOMAIN, def.domain, scale, group);\n if (domain && !dl.equal(prev.domain, domain)) {\n scale.domain(domain);\n prev.domain = domain;\n this._updated = true;\n } \n\n // range\n if (dl.equal(prev.range, rng)) return;\n\n // width-defined range\n if (def.bandWidth) {\n var bw = def.bandWidth,\n len = domain.length,\n start = rng[0] || 0,\n space = def.points ? (pad*bw) : (pad*bw*(len-1) + 2*outer);\n rng = [start, start + (bw * len + space)];\n }\n\n str = typeof rng[0] === 'string';\n if (str || rng.length > 2 || rng.length===1 || dataDrivenRange) {\n scale.range(rng); // color or shape values\n } else if (def.points && (def.round || def.round == null)) {\n scale.rangeRoundPoints(rng, pad);\n } else if (def.points) {\n scale.rangePoints(rng, pad);\n } else if (def.round || def.round == null) {\n scale.rangeRoundBands(rng, pad, outer);\n } else {\n scale.rangeBands(rng, pad, outer);\n }\n\n prev.range = rng;\n this._updated = true;\n}\n\nfunction quantitative(scale, rng, group) {\n var def = this._def,\n prev = scale._prev,\n domain, interval;\n\n // domain\n domain = (def.type === C.QUANTILE)\n ? dataRef.call(this, C.DOMAIN, def.domain, scale, group)\n : domainMinMax.call(this, scale, group);\n if (domain && !dl.equal(prev.domain, domain)) {\n scale.domain(domain);\n prev.domain = domain;\n this._updated = true;\n } \n\n // range\n // vertical scales should flip by default, so use XOR here\n if (def.range === \"height\") rng = rng.reverse();\n if (dl.equal(prev.range, rng)) return;\n scale[def.round && scale.rangeRound ? \"rangeRound\" : \"range\"](rng);\n prev.range = rng;\n this._updated = true;\n\n // TODO: Support signals for these properties. Until then, only eval\n // them once.\n if (this._stamp > 0) return;\n if (def.exponent && def.type===C.POWER) scale.exponent(def.exponent);\n if (def.clamp) scale.clamp(true);\n if (def.nice) {\n if (def.type === C.TIME) {\n interval = d3.time[def.nice];\n if (!interval) dl.error(\"Unrecognized interval: \" + interval);\n scale.nice(interval);\n } else {\n scale.nice();\n }\n }\n}\n\nfunction isUniques(scale) { \n return scale.type === C.ORDINAL || scale.type === C.QUANTILE; \n}\n\nfunction getRefs(def) { \n return def.fields || dl.array(def);\n}\n\nfunction getFields(ref, group) {\n return dl.array(ref.field).map(function(f) {\n if (f.parent) return dl.accessor(f.parent)(group.datum)\n return f; // String or {\"signal\"}\n });\n}\n\n// Scale datarefs can be computed over multiple schema types. \n// This function determines the type of aggregator created, and\n// what data is sent to it: values, tuples, or multi-tuples that must\n// be standardized into a consistent schema. \nfunction aggrType(def, scale) {\n var refs = getRefs(def);\n\n // If we're operating over only a single domain, send full tuples\n // through for efficiency (fewer accessor creations/calls)\n if(refs.length == 1 && dl.array(refs[0].field).length == 1) {\n return Aggregate.TYPES.TUPLE;\n }\n\n // With quantitative scales, we only care about min/max.\n if(!isUniques(scale)) return Aggregate.TYPES.VALUE;\n\n // If we don't sort, then we can send values directly to aggrs as well\n if(!def.sort) return Aggregate.TYPES.VALUE;\n\n return Aggregate.TYPES.MULTI;\n}\n\nfunction getCache(which, def, scale, group) {\n var refs = getRefs(def),\n atype = aggrType(def, scale),\n uniques = isUniques(scale),\n sort = def.sort,\n ck = \"_\"+which,\n fields = getFields(refs[0], group),\n i, rlen, j, flen, ref, field;\n\n if(scale[ck]) return scale[ck];\n\n var cache = scale[ck] = new Aggregate(this._graph).type(atype),\n groupby, summarize;\n\n if(uniques) {\n if(atype === Aggregate.TYPES.VALUE) {\n groupby = [{ name: C.GROUPBY, get: dl.identity }];\n summarize = {\"*\": C.COUNT};\n } else if(atype === Aggregate.TYPES.TUPLE) {\n groupby = [{ name: C.GROUPBY, get: dl.$(fields[0]) }];\n summarize = sort ? [{\n name: C.VALUE,\n get: dl.$(ref.sort || sort.field),\n ops: [sort.stat]\n }] : {\"*\": C.COUNT};\n } else { // atype === Aggregate.TYPES.MULTI\n groupby = C.GROUPBY;\n summarize = [{ name: C.VALUE, ops: [sort.stat] }]; \n }\n } else {\n groupby = [];\n summarize = [{\n name: C.VALUE,\n get: (atype == Aggregate.TYPES.TUPLE) ? dl.$(fields[0]) : dl.identity,\n ops: [C.MIN, C.MAX],\n as: [C.MIN, C.MAX]\n }];\n }\n\n cache.param(\"groupby\", groupby)\n .param(\"summarize\", summarize);\n\n return cache;\n}\n\nfunction dataRef(which, def, scale, group) {\n if (def == null) { return []; }\n if (dl.isArray(def)) return def.map(signal.bind(this));\n\n var self = this, graph = this._graph,\n refs = getRefs(def),\n atype = aggrType(def, scale),\n cache = getCache.apply(this, arguments),\n sort = def.sort,\n uniques = isUniques(scale),\n i, rlen, j, flen, ref, fields, field;\n\n for(i=0, rlen=refs.length; i<rlen; ++i) {\n ref = refs[i];\n from = ref.data || \"vg_\"+group.datum._id;\n data = graph.data(from)\n .revises(true)\n .last();\n\n if (data.stamp <= this._stamp) continue;\n\n fields = getFields(ref, group);\n for(j=0, flen=fields.length; j<flen; ++j) {\n field = fields[j];\n\n if(atype === Aggregate.TYPES.VALUE) {\n cache.accessors(null, field);\n } else if(atype === Aggregate.TYPES.MULTI) {\n cache.accessors(field, ref.sort || sort.field);\n } // Else (Tuple-case) is handled by the aggregator accessors by default\n\n cache.evaluate(data);\n }\n\n this.dependency(C.DATA, from);\n cache.dependency(C.SIGNALS).forEach(function(s) { self.dependency(C.SIGNALS, s) });\n }\n\n data = cache.aggr().result();\n if (uniques) {\n if (sort) {\n sort = sort.order.signal ? graph.signalRef(sort.order.signal) : sort.order;\n sort = (sort == C.DESC ? \"-\" : \"+\") + C.VALUE;\n sort = dl.comparator(sort);\n data = data.sort(sort);\n // } else { // \"First seen\" order\n // sort = dl.comparator(\"tpl._id\");\n }\n\n return data.map(function(d) { return d[C.GROUPBY]; });\n } else {\n data = data[0];\n return !dl.isValid(data) ? [] : [data[C.MIN], data[C.MAX]];\n }\n}\n\nfunction signal(v) {\n var s = v.signal, ref;\n if (!s) return v;\n this.dependency(C.SIGNALS, (ref = dl.field(s))[0]);\n return this._graph.signalRef(ref);\n}\n\nfunction domainMinMax(scale, group) {\n var def = this._def,\n domain = [null, null], refs, z;\n\n if (def.domain !== undefined) {\n domain = (!dl.isObject(def.domain)) ? domain :\n dataRef.call(this, C.DOMAIN, def.domain, scale, group);\n }\n\n z = domain.length - 1;\n if (def.domainMin !== undefined) {\n if (dl.isObject(def.domainMin)) {\n if (def.domainMin.signal) {\n domain[0] = signal.call(this, def.domainMin);\n } else {\n domain[0] = dataRef.call(this, C.DOMAIN+C.MIN, def.domainMin, scale, group)[0];\n }\n } else {\n domain[0] = def.domainMin;\n }\n }\n if (def.domainMax !== undefined) {\n if (dl.isObject(def.domainMax)) {\n if (def.domainMax.signal) {\n domain[z] = signal.call(this, def.domainMax);\n } else {\n domain[z] = dataRef.call(this, C.DOMAIN+C.MAX, def.domainMax, scale, group)[1];\n }\n } else {\n domain[z] = def.domainMax;\n }\n }\n if (def.type !== C.LOG && def.type !== C.TIME && (def.zero || def.zero===undefined)) {\n domain[0] = Math.min(0, domain[0]);\n domain[z] = Math.max(0, domain[z]);\n }\n return domain;\n}\n\nfunction range(group) {\n var def = this._def,\n rng = [null, null];\n\n if (def.range !== undefined) {\n if (typeof def.range === 'string') {\n if (GROUP_PROPERTY[def.range]) {\n rng = [0, group[def.range]];\n } else if (config.range[def.range]) {\n rng = config.range[def.range];\n } else {\n dl.error(\"Unrecogized range: \"+def.range);\n return rng;\n }\n } else if (dl.isArray(def.range)) {\n rng = dl.duplicate(def.range).map(signal.bind(this));\n } else if (dl.isObject(def.range)) {\n return null; // early exit\n } else {\n rng = [0, def.range];\n }\n }\n if (def.rangeMin !== undefined) {\n rng[0] = def.rangeMin.signal ? signal.call(this, def.rangeMin) : def.rangeMin;\n }\n if (def.rangeMax !== undefined) {\n rng[rng.length-1] = def.rangeMax.signal ? signal.call(this, def.rangeMax) : def.rangeMax;\n }\n \n if (def.reverse !== undefined) {\n var rev = def.reverse;\n if (dl.isObject(rev)) {\n rev = dl.accessor(rev.field)(group.datum);\n }\n if (rev) rng = rng.reverse();\n }\n \n return rng;\n}\n\nmodule.exports = Scale;",
"var tuple = require('../dataflow/tuple'),\n boundsCalc = require('../util/boundscalc'),\n C = require('../util/constants');\n\nfunction Transition(duration, ease) {\n this.duration = duration || 500;\n this.ease = ease && d3.ease(ease) || d3.ease(\"cubic-in-out\");\n this.updates = {next: null};\n}\n\nvar prototype = Transition.prototype;\n\nvar skip = {\n \"text\": 1,\n \"url\": 1\n};\n\nprototype.interpolate = function(item, values, stamp) {\n var key, curr, next, interp, list = null;\n\n for (key in values) {\n curr = item[key];\n next = values[key]; \n if (curr !== next) {\n if (skip[key] || curr === undefined) {\n // skip interpolation for specific keys or undefined start values\n tuple.set(item, key, next);\n } else if (typeof curr === \"number\" && !isFinite(curr)) {\n // for NaN or infinite numeric values, skip to final value\n tuple.set(item, key, next);\n } else {\n // otherwise lookup interpolator\n interp = d3.interpolate(curr, next);\n interp.property = key;\n (list || (list=[])).push(interp);\n }\n }\n }\n\n if (list === null && item.status === C.EXIT) {\n list = []; // ensure exiting items are included\n }\n\n if (list != null) {\n list.item = item;\n list.ease = item.mark.ease || this.ease;\n list.next = this.updates.next;\n this.updates.next = list;\n }\n return this;\n};\n\nprototype.start = function(callback) {\n var t = this, prev = t.updates, curr = prev.next;\n for (; curr!=null; prev=curr, curr=prev.next) {\n if (curr.item.status === C.EXIT) curr.remove = true;\n }\n t.callback = callback;\n d3.timer(function(elapsed) { return step.call(t, elapsed); });\n};\n\nfunction step(elapsed) {\n var list = this.updates, prev = list, curr = prev.next,\n duration = this.duration,\n item, delay, f, e, i, n, stop = true;\n\n for (; curr!=null; prev=curr, curr=prev.next) {\n item = curr.item;\n delay = item.delay || 0;\n\n f = (elapsed - delay) / duration;\n if (f < 0) { stop = false; continue; }\n if (f > 1) f = 1;\n e = curr.ease(f);\n\n for (i=0, n=curr.length; i<n; ++i) {\n item[curr[i].property] = curr[i](e);\n }\n item.touch();\n boundsCalc.item(item);\n\n if (f === 1) {\n if (curr.remove) item.remove();\n prev.next = curr.next;\n curr = prev;\n } else {\n stop = false;\n }\n }\n\n this.callback();\n return stop;\n};\n\nmodule.exports = Transition;",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n dl = require('datalib'),\n config = require('../util/config'),\n tpl = require('../dataflow/tuple'),\n parseMark = require('../parse/mark');\n\nfunction axs(model) {\n var scale,\n orient = config.axis.orient,\n offset = 0,\n titleOffset = config.axis.titleOffset,\n axisDef = {},\n layer = \"front\",\n grid = false,\n title = null,\n tickMajorSize = config.axis.tickSize,\n tickMinorSize = config.axis.tickSize,\n tickEndSize = config.axis.tickSize,\n tickPadding = config.axis.padding,\n tickValues = null,\n tickFormatString = null,\n tickSubdivide = 0,\n tickCount = config.axis.ticks,\n gridLineStyle = {},\n tickLabelStyle = {},\n majorTickStyle = {},\n minorTickStyle = {},\n titleStyle = {},\n domainStyle = {},\n m = { // Axis marks as references for updates\n gridLines: {},\n majorTicks: {},\n minorTicks: {},\n tickLabels: {},\n domain: {},\n title: {}\n };\n\n var axis = {};\n\n function reset() {\n axisDef.type = null;\n }\n\n function ingest(d) { return {data: d}; };\n\n function getTickFormatString() {\n return tickFormatString || (scale.type === 'log' ? \".1s\" : null);\n }\n \n function buildTickFormat() {\n var fmtStr = getTickFormatString();\n if (scale.tickFormat) {\n return scale.tickFormat(tickCount, fmtStr);\n } else if (fmtStr) {\n return ((scale.type === 'time')\n ? d3.time.format(fmtStr)\n : d3.format(fmtStr));\n } else {\n return String;\n }\n }\n \n function buildTicks(fmt) {\n var ticks = {\n major: tickValues,\n minor: null\n };\n \n if (ticks.major == null) {\n ticks.major = scale.ticks\n ? scale.ticks(tickCount)\n : scale.domain();\n }\n \n ticks.minor = vg_axisSubdivide(scale, ticks.major, tickSubdivide)\n .map(ingest);\n \n ticks.major = ticks.major.map(function(d) {\n return (d = ingest(d), d.label = fmt(d.data), d);\n });\n \n return ticks;\n }\n\n axis.def = function() {\n if(!axisDef.type) axis_def(scale);\n\n var fmt = buildTickFormat();\n var ticks = buildTicks(fmt);\n var tdata = title ? [title].map(ingest) : [];\n\n axisDef.marks[0].from = function() { return grid ? ticks.major : []; };\n axisDef.marks[1].from = function() { return ticks.major; };\n axisDef.marks[2].from = function() { return ticks.minor; };\n axisDef.marks[3].from = axisDef.marks[1].from;\n axisDef.marks[4].from = function() { return [1]; };\n axisDef.marks[5].from = function() { return tdata; };\n axisDef.offset = offset;\n axisDef.orient = orient;\n axisDef.layer = layer;\n return axisDef;\n };\n\n function axis_def(scale) {\n // setup scale mapping\n var newScale, oldScale, range;\n if (scale.type === \"ordinal\") {\n newScale = {scale: scale.scaleName, offset: 0.5 + scale.rangeBand()/2};\n oldScale = newScale;\n } else {\n newScale = {scale: scale.scaleName, offset: 0.5};\n oldScale = {scale: scale.scaleName+\":prev\", offset: 0.5};\n }\n range = vg_axisScaleRange(scale);\n\n // setup axis marks\n dl.extend(m.gridLines, vg_axisTicks());\n dl.extend(m.majorTicks, vg_axisTicks());\n dl.extend(m.minorTicks, vg_axisTicks());\n dl.extend(m.tickLabels, vg_axisTickLabels());\n dl.extend(m.domain, vg_axisDomain());\n dl.extend(m.title, vg_axisTitle());\n m.gridLines.properties.enter.stroke = {value: config.axis.gridColor};\n\n // extend axis marks based on axis orientation\n vg_axisTicksExtend(orient, m.gridLines, oldScale, newScale, Infinity);\n vg_axisTicksExtend(orient, m.majorTicks, oldScale, newScale, tickMajorSize);\n vg_axisTicksExtend(orient, m.minorTicks, oldScale, newScale, tickMinorSize);\n vg_axisLabelExtend(orient, m.tickLabels, oldScale, newScale, tickMajorSize, tickPadding);\n\n vg_axisDomainExtend(orient, m.domain, range, tickEndSize);\n vg_axisTitleExtend(orient, m.title, range, titleOffset); // TODO get offset\n \n // add / override custom style properties\n dl.extend(m.gridLines.properties.update, gridLineStyle);\n dl.extend(m.majorTicks.properties.update, majorTickStyle);\n dl.extend(m.minorTicks.properties.update, minorTickStyle);\n dl.extend(m.tickLabels.properties.update, tickLabelStyle);\n dl.extend(m.domain.properties.update, domainStyle);\n dl.extend(m.title.properties.update, titleStyle);\n\n var marks = [m.gridLines, m.majorTicks, m.minorTicks, m.tickLabels, m.domain, m.title];\n dl.extend(axisDef, {\n type: \"group\",\n interactive: false,\n properties: { \n enter: {\n encode: vg_axisUpdate,\n scales: [scale.scaleName],\n signals: [], data: []\n },\n update: {\n encode: vg_axisUpdate,\n scales: [scale.scaleName],\n signals: [], data: []\n }\n }\n });\n\n axisDef.marks = marks.map(function(m) { return parseMark(model, m); });\n };\n\n axis.scale = function(x) {\n if (!arguments.length) return scale;\n if (scale !== x) { scale = x; reset(); }\n return axis;\n };\n\n axis.orient = function(x) {\n if (!arguments.length) return orient;\n if (orient !== x) {\n orient = x in vg_axisOrients ? x + \"\" : config.axis.orient;\n reset();\n }\n return axis;\n };\n\n axis.title = function(x) {\n if (!arguments.length) return title;\n if (title !== x) { title = x; reset(); }\n return axis;\n };\n\n axis.tickCount = function(x) {\n if (!arguments.length) return tickCount;\n tickCount = x;\n return axis;\n };\n\n axis.tickValues = function(x) {\n if (!arguments.length) return tickValues;\n tickValues = x;\n return axis;\n };\n\n axis.tickFormat = function(x) {\n if (!arguments.length) return tickFormatString;\n if (tickFormatString !== x) {\n tickFormatString = x;\n reset();\n }\n return axis;\n };\n \n axis.tickSize = function(x, y) {\n if (!arguments.length) return tickMajorSize;\n var n = arguments.length - 1,\n major = +x,\n minor = n > 1 ? +y : tickMajorSize,\n end = n > 0 ? +arguments[n] : tickMajorSize;\n\n if (tickMajorSize !== major ||\n tickMinorSize !== minor ||\n tickEndSize !== end) {\n reset();\n }\n\n tickMajorSize = major;\n tickMinorSize = minor;\n tickEndSize = end;\n return axis;\n };\n\n axis.tickSubdivide = function(x) {\n if (!arguments.length) return tickSubdivide;\n tickSubdivide = +x;\n return axis;\n };\n \n axis.offset = function(x) {\n if (!arguments.length) return offset;\n offset = dl.isObject(x) ? x : +x;\n return axis;\n };\n\n axis.tickPadding = function(x) {\n if (!arguments.length) return tickPadding;\n if (tickPadding !== +x) { tickPadding = +x; reset(); }\n return axis;\n };\n\n axis.titleOffset = function(x) {\n if (!arguments.length) return titleOffset;\n if (titleOffset !== +x) { titleOffset = +x; reset(); }\n return axis;\n };\n\n axis.layer = function(x) {\n if (!arguments.length) return layer;\n if (layer !== x) { layer = x; reset(); }\n return axis;\n };\n\n axis.grid = function(x) {\n if (!arguments.length) return grid;\n if (grid !== x) { grid = x; reset(); }\n return axis;\n };\n\n axis.gridLineProperties = function(x) {\n if (!arguments.length) return gridLineStyle;\n if (gridLineStyle !== x) { gridLineStyle = x; }\n return axis;\n };\n\n axis.majorTickProperties = function(x) {\n if (!arguments.length) return majorTickStyle;\n if (majorTickStyle !== x) { majorTickStyle = x; }\n return axis;\n };\n\n axis.minorTickProperties = function(x) {\n if (!arguments.length) return minorTickStyle;\n if (minorTickStyle !== x) { minorTickStyle = x; }\n return axis;\n };\n\n axis.tickLabelProperties = function(x) {\n if (!arguments.length) return tickLabelStyle;\n if (tickLabelStyle !== x) { tickLabelStyle = x; }\n return axis;\n };\n\n axis.titleProperties = function(x) {\n if (!arguments.length) return titleStyle;\n if (titleStyle !== x) { titleStyle = x; }\n return axis;\n };\n\n axis.domainProperties = function(x) {\n if (!arguments.length) return domainStyle;\n if (domainStyle !== x) { domainStyle = x; }\n return axis;\n };\n \n axis.reset = function() { reset(); };\n\n return axis;\n};\n\nvar vg_axisOrients = {top: 1, right: 1, bottom: 1, left: 1};\n\nfunction vg_axisSubdivide(scale, ticks, m) {\n subticks = [];\n if (m && ticks.length > 1) {\n var extent = vg_axisScaleExtent(scale.domain()),\n subticks,\n i = -1,\n n = ticks.length,\n d = (ticks[1] - ticks[0]) / ++m,\n j,\n v;\n while (++i < n) {\n for (j = m; --j > 0;) {\n if ((v = +ticks[i] - j * d) >= extent[0]) {\n subticks.push(v);\n }\n }\n }\n for (--i, j = 0; ++j < m && (v = +ticks[i] + j * d) < extent[1];) {\n subticks.push(v);\n }\n }\n return subticks;\n}\n\nfunction vg_axisScaleExtent(domain) {\n var start = domain[0], stop = domain[domain.length - 1];\n return start < stop ? [start, stop] : [stop, start];\n}\n\nfunction vg_axisScaleRange(scale) {\n return scale.rangeExtent\n ? scale.rangeExtent()\n : vg_axisScaleExtent(scale.range());\n}\n\nvar vg_axisAlign = {\n bottom: \"center\",\n top: \"center\",\n left: \"right\",\n right: \"left\"\n};\n\nvar vg_axisBaseline = {\n bottom: \"top\",\n top: \"bottom\",\n left: \"middle\",\n right: \"middle\"\n};\n\nfunction vg_axisLabelExtend(orient, labels, oldScale, newScale, size, pad) {\n size = Math.max(size, 0) + pad;\n if (orient === \"left\" || orient === \"top\") {\n size *= -1;\n } \n if (orient === \"top\" || orient === \"bottom\") {\n dl.extend(labels.properties.enter, {\n x: oldScale,\n y: {value: size},\n });\n dl.extend(labels.properties.update, {\n x: newScale,\n y: {value: size},\n align: {value: \"center\"},\n baseline: {value: vg_axisBaseline[orient]}\n });\n } else {\n dl.extend(labels.properties.enter, {\n x: {value: size},\n y: oldScale,\n });\n dl.extend(labels.properties.update, {\n x: {value: size},\n y: newScale,\n align: {value: vg_axisAlign[orient]},\n baseline: {value: \"middle\"}\n });\n }\n}\n\nfunction vg_axisTicksExtend(orient, ticks, oldScale, newScale, size) {\n var sign = (orient === \"left\" || orient === \"top\") ? -1 : 1;\n if (size === Infinity) {\n size = (orient === \"top\" || orient === \"bottom\")\n ? {field: {group: \"height\", level: 2}, mult: -sign}\n : {field: {group: \"width\", level: 2}, mult: -sign};\n } else {\n size = {value: sign * size};\n }\n if (orient === \"top\" || orient === \"bottom\") {\n dl.extend(ticks.properties.enter, {\n x: oldScale,\n y: {value: 0},\n y2: size\n });\n dl.extend(ticks.properties.update, {\n x: newScale,\n y: {value: 0},\n y2: size\n });\n dl.extend(ticks.properties.exit, {\n x: newScale,\n }); \n } else {\n dl.extend(ticks.properties.enter, {\n x: {value: 0},\n x2: size,\n y: oldScale\n });\n dl.extend(ticks.properties.update, {\n x: {value: 0},\n x2: size,\n y: newScale\n });\n dl.extend(ticks.properties.exit, {\n y: newScale,\n });\n }\n}\n\nfunction vg_axisTitleExtend(orient, title, range, offset) {\n var mid = ~~((range[0] + range[1]) / 2),\n sign = (orient === \"top\" || orient === \"left\") ? -1 : 1;\n \n if (orient === \"bottom\" || orient === \"top\") {\n dl.extend(title.properties.update, {\n x: {value: mid},\n y: {value: sign*offset},\n angle: {value: 0}\n });\n } else {\n dl.extend(title.properties.update, {\n x: {value: sign*offset},\n y: {value: mid},\n angle: {value: -90}\n });\n }\n}\n\nfunction vg_axisDomainExtend(orient, domain, range, size) {\n var path;\n if (orient === \"top\" || orient === \"left\") {\n size = -1 * size;\n }\n if (orient === \"bottom\" || orient === \"top\") {\n path = \"M\" + range[0] + \",\" + size + \"V0H\" + range[1] + \"V\" + size;\n } else {\n path = \"M\" + size + \",\" + range[0] + \"H0V\" + range[1] + \"H\" + size;\n }\n domain.properties.update.path = {value: path};\n}\n\nfunction vg_axisUpdate(item, group, trans, db, signals, predicates) {\n var o = trans ? {} : item,\n offset = item.mark.def.offset,\n orient = item.mark.def.orient,\n width = group.width,\n height = group.height; // TODO fallback to global w,h?\n\n if (dl.isArray(offset)) {\n var ofx = offset[0],\n ofy = offset[1];\n\n switch (orient) {\n case \"left\": { tpl.set(o, 'x', -ofx); tpl.set(o, 'y', ofy); break; }\n case \"right\": { tpl.set(o, 'x', width + ofx); tpl.set(o, 'y', ofy); break; }\n case \"bottom\": { tpl.set(o, 'x', ofx); tpl.set(o, 'y', height + ofy); break; }\n case \"top\": { tpl.set(o, 'x', ofx); tpl.set(o, 'y', -ofy); break; }\n default: { tpl.set(o, 'x', ofx); tpl.set(o, 'y', ofy); }\n }\n } else {\n if (dl.isObject(offset)) {\n offset = -group.scale(offset.scale)(offset.value);\n }\n\n switch (orient) {\n case \"left\": { tpl.set(o, 'x', -offset); tpl.set(o, 'y', 0); break; }\n case \"right\": { tpl.set(o, 'x', width + offset); tpl.set(o, 'y', 0); break; }\n case \"bottom\": { tpl.set(o, 'x', 0); tpl.set(o, 'y', height + offset); break; }\n case \"top\": { tpl.set(o, 'x', 0); tpl.set(o, 'y', -offset); break; }\n default: { tpl.set(o, 'x', 0); tpl.set(o, 'y', 0); }\n }\n }\n\n if (trans) trans.interpolate(item, o);\n}\n\nfunction vg_axisTicks() {\n return {\n type: \"rule\",\n interactive: false,\n key: \"data\",\n properties: {\n enter: {\n stroke: {value: config.axis.tickColor},\n strokeWidth: {value: config.axis.tickWidth},\n opacity: {value: 1e-6}\n },\n exit: { opacity: {value: 1e-6} },\n update: { opacity: {value: 1} }\n }\n };\n}\n\nfunction vg_axisTickLabels() {\n return {\n type: \"text\",\n interactive: true,\n key: \"data\",\n properties: {\n enter: {\n fill: {value: config.axis.tickLabelColor},\n font: {value: config.axis.tickLabelFont},\n fontSize: {value: config.axis.tickLabelFontSize},\n opacity: {value: 1e-6},\n text: {field: \"label\"}\n },\n exit: { opacity: {value: 1e-6} },\n update: { opacity: {value: 1} }\n }\n };\n}\n\nfunction vg_axisTitle() {\n return {\n type: \"text\",\n interactive: true,\n properties: {\n enter: {\n font: {value: config.axis.titleFont},\n fontSize: {value: config.axis.titleFontSize},\n fontWeight: {value: config.axis.titleFontWeight},\n fill: {value: config.axis.titleColor},\n align: {value: \"center\"},\n baseline: {value: \"middle\"},\n text: {field: \"data\"}\n },\n update: {}\n }\n };\n}\n\nfunction vg_axisDomain() {\n return {\n type: \"path\",\n interactive: false,\n properties: {\n enter: {\n x: {value: 0.5},\n y: {value: 0.5},\n stroke: {value: config.axis.axisColor},\n strokeWidth: {value: config.axis.axisWidth}\n },\n update: {}\n }\n };\n}\n\nmodule.exports = axs;\n",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n dl = require('datalib'),\n parseProperties = require('../parse/properties'),\n parseMark = require('../parse/mark'),\n Gradient = require('../util/Gradient'),\n config = require('../util/config');\n\nfunction lgnd(model) {\n var size = null,\n shape = null,\n fill = null,\n stroke = null,\n spacing = null,\n values = null,\n format = null,\n formatString = null,\n title = undefined,\n orient = \"right\",\n offset = config.legend.offset,\n padding = config.legend.padding,\n legendDef,\n tickArguments = [5],\n legendStyle = {},\n symbolStyle = {},\n gradientStyle = {},\n titleStyle = {},\n labelStyle = {},\n m = { // Legend marks as references for updates\n titles: {},\n symbols: {},\n labels: {},\n gradient: {}\n };\n\n var legend = {},\n legendDef = {};\n\n function reset() { legendDef.type = null; }\n function ingest(d, i) { return {data: d, index: i} }\n\n legend.def = function() {\n var scale = size || shape || fill || stroke;\n \n format = !formatString ? null : ((scale.type === 'time')\n ? d3.time.format(formatString)\n : d3.format(formatString));\n \n if (!legendDef.type) {\n legendDef = (scale===fill || scale===stroke) && !discrete(scale.type)\n ? quantDef(scale)\n : ordinalDef(scale); \n }\n legendDef.orient = orient;\n legendDef.offset = offset;\n legendDef.padding = padding;\n return legendDef;\n };\n\n function discrete(type) {\n return type===\"ordinal\" || type===\"quantize\"\n || type===\"quantile\" || type===\"threshold\";\n }\n\n function ordinalDef(scale) {\n var def = o_legend_def(size, shape, fill, stroke);\n\n // generate data\n var data = (values == null\n ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain())\n : values).map(ingest);\n var fmt = format==null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : String) : format;\n \n // determine spacing between legend entries\n var fs, range, offset, pad=5, domain = d3.range(data.length);\n if (size) {\n range = data.map(function(x) { return Math.sqrt(size(x.data)); });\n offset = d3.max(range);\n range = range.reduce(function(a,b,i,z) {\n if (i > 0) a[i] = a[i-1] + z[i-1]/2 + pad;\n return (a[i] += b/2, a); }, [0]).map(Math.round);\n } else {\n offset = Math.round(Math.sqrt(config.legend.symbolSize));\n range = spacing\n || (fs = labelStyle.fontSize) && (fs.value + pad)\n || (config.legend.labelFontSize + pad);\n range = domain.map(function(d,i) {\n return Math.round(offset/2 + i*range);\n });\n }\n\n // account for padding and title size\n var sz = padding, ts;\n if (title) {\n ts = titleStyle.fontSize;\n sz += 5 + ((ts && ts.value) || config.legend.titleFontSize);\n }\n for (var i=0, n=range.length; i<n; ++i) range[i] += sz;\n \n // build scale for label layout\n var scale = {\n name: \"legend\",\n type: \"ordinal\",\n points: true,\n domain: domain,\n range: range\n };\n \n // update legend def\n var tdata = (title ? [title] : []).map(ingest);\n data.forEach(function(d) {\n d.label = fmt(d.data);\n d.offset = offset;\n });\n def.scales = [ scale ];\n def.marks[0].from = function() { return tdata; };\n def.marks[1].from = function() { return data; };\n def.marks[2].from = def.marks[1].from;\n\n return def;\n }\n\n function o_legend_def(size, shape, fill, stroke) {\n // setup legend marks\n var titles = dl.extend(m.titles, vg_legendTitle()),\n symbols = dl.extend(m.symbols, vg_legendSymbols()),\n labels = dl.extend(m.labels, vg_vLegendLabels());\n\n // extend legend marks\n vg_legendSymbolExtend(symbols, size, shape, fill, stroke);\n \n // add / override custom style properties\n dl.extend(titles.properties.update, titleStyle);\n dl.extend(symbols.properties.update, symbolStyle);\n dl.extend(labels.properties.update, labelStyle);\n\n // padding from legend border\n titles.properties.enter.x.value += padding;\n titles.properties.enter.y.value += padding;\n labels.properties.enter.x.offset += padding + 1;\n symbols.properties.enter.x.offset = padding + 1;\n labels.properties.update.x.offset += padding + 1;\n symbols.properties.update.x.offset = padding + 1;\n\n dl.extend(legendDef, {\n type: \"group\",\n interactive: false,\n properties: {\n enter: parseProperties(model, \"group\", legendStyle),\n vg_legendPosition: {\n encode: vg_legendPosition,\n signals: [], scales:[], data: [], fields: []\n }\n }\n });\n\n legendDef.marks = [titles, symbols, labels].map(function(m) { return parseMark(model, m); });\n return legendDef;\n }\n\n function quantDef(scale) {\n var def = q_legend_def(scale),\n dom = scale.domain(),\n data = dom.map(ingest),\n width = (gradientStyle.width && gradientStyle.width.value) || config.legend.gradientWidth,\n fmt = format==null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : String) : format;\n\n // build scale for label layout\n var layout = {\n name: \"legend\",\n type: scale.type,\n round: true,\n zero: false,\n domain: [dom[0], dom[dom.length-1]],\n range: [padding, width+padding]\n };\n if (scale.type===\"pow\") layout.exponent = scale.exponent();\n \n // update legend def\n var tdata = (title ? [title] : []).map(ingest);\n data.forEach(function(d,i) {\n d.label = fmt(d.data);\n d.align = i==(data.length-1) ? \"right\" : i==0 ? \"left\" : \"center\";\n });\n def.scales = [ layout ];\n def.marks[0].from = function() { return tdata; };\n def.marks[1].from = function() { return [1]; };\n def.marks[2].from = function() { return data; };\n return def;\n }\n \n function q_legend_def(scale) {\n // setup legend marks\n var titles = dl.extend(m.title, vg_legendTitle()),\n gradient = dl.extend(m.gradient, vg_legendGradient()),\n labels = dl.extend(m.labels, vg_hLegendLabels()),\n grad = new Gradient();\n\n // setup color gradient\n var dom = scale.domain(),\n min = dom[0],\n max = dom[dom.length-1],\n f = scale.copy().domain([min, max]).range([0,1]);\n \n var stops = (scale.type !== \"linear\" && scale.ticks)\n ? scale.ticks.call(scale, 15) : dom;\n if (min !== stops[0]) stops.unshift(min);\n if (max !== stops[stops.length-1]) stops.push(max);\n\n for (var i=0, n=stops.length; i<n; ++i) {\n grad.stop(f(stops[i]), scale(stops[i]));\n }\n gradient.properties.enter.fill = {value: grad};\n\n // add / override custom style properties\n dl.extend(titles.properties.update, titleStyle);\n dl.extend(gradient.properties.update, gradientStyle);\n dl.extend(labels.properties.update, labelStyle);\n\n // account for gradient size\n var gp = gradient.properties, gh = gradientStyle.height,\n hh = (gh && gh.value) || gp.enter.height.value;\n labels.properties.enter.y.value = hh;\n labels.properties.update.y.value = hh;\n\n // account for title size as needed\n if (title) {\n var tp = titles.properties, fs = titleStyle.fontSize,\n sz = 4 + ((fs && fs.value) || tp.enter.fontSize.value);\n gradient.properties.enter.y.value += sz;\n labels.properties.enter.y.value += sz;\n gradient.properties.update.y.value += sz;\n labels.properties.update.y.value += sz;\n }\n \n // padding from legend border\n titles.properties.enter.x.value += padding;\n titles.properties.enter.y.value += padding;\n gradient.properties.enter.x.value += padding;\n gradient.properties.enter.y.value += padding;\n labels.properties.enter.y.value += padding;\n gradient.properties.update.x.value += padding;\n gradient.properties.update.y.value += padding;\n labels.properties.update.y.value += padding;\n\n dl.extend(legendDef, {\n type: \"group\",\n interactive: false,\n properties: {\n enter: parseProperties(model, \"group\", legendStyle),\n vg_legendPosition: {\n encode: vg_legendPosition,\n signals: [], scales: [], data: [], fields: []\n }\n }\n });\n\n legendDef.marks = [titles, gradient, labels].map(function(m) { return parseMark(model, m); });\n return legendDef;\n }\n\n legend.size = function(x) {\n if (!arguments.length) return size;\n if (size !== x) { size = x; reset(); }\n return legend;\n };\n\n legend.shape = function(x) {\n if (!arguments.length) return shape;\n if (shape !== x) { shape = x; reset(); }\n return legend;\n };\n\n legend.fill = function(x) {\n if (!arguments.length) return fill;\n if (fill !== x) { fill = x; reset(); }\n return legend;\n };\n \n legend.stroke = function(x) {\n if (!arguments.length) return stroke;\n if (stroke !== x) { stroke = x; reset(); }\n return legend;\n };\n\n legend.title = function(x) {\n if (!arguments.length) return title;\n if (title !== x) { title = x; reset(); }\n return legend;\n };\n\n legend.format = function(x) {\n if (!arguments.length) return formatString;\n if (formatString !== x) {\n formatString = x;\n reset();\n }\n return legend;\n };\n\n legend.spacing = function(x) {\n if (!arguments.length) return spacing;\n if (spacing !== +x) { spacing = +x; reset(); }\n return legend;\n };\n\n legend.orient = function(x) {\n if (!arguments.length) return orient;\n orient = x in vg_legendOrients ? x + \"\" : config.legend.orient;\n return legend;\n };\n\n legend.offset = function(x) {\n if (!arguments.length) return offset;\n offset = +x;\n return legend;\n };\n\n legend.values = function(x) {\n if (!arguments.length) return values;\n values = x;\n return legend;\n };\n\n legend.legendProperties = function(x) {\n if (!arguments.length) return legendStyle;\n legendStyle = x;\n return legend;\n };\n\n legend.symbolProperties = function(x) {\n if (!arguments.length) return symbolStyle;\n symbolStyle = x;\n return legend;\n };\n\n legend.gradientProperties = function(x) {\n if (!arguments.length) return gradientStyle;\n gradientStyle = x;\n return legend;\n };\n\n legend.labelProperties = function(x) {\n if (!arguments.length) return labelStyle;\n labelStyle = x;\n return legend;\n };\n \n legend.titleProperties = function(x) {\n if (!arguments.length) return titleStyle;\n titleStyle = x;\n return legend;\n };\n\n legend.reset = function() { reset(); };\n\n return legend;\n};\n\nvar vg_legendOrients = {right: 1, left: 1};\n\nfunction vg_legendPosition(item, group, trans, db, signals, predicates) {\n var o = trans ? {} : item, gx,\n offset = item.mark.def.offset,\n orient = item.mark.def.orient,\n pad = item.mark.def.padding * 2,\n lw = ~~item.bounds.width() + (item.width ? 0 : pad),\n lh = ~~item.bounds.height() + (item.height ? 0 : pad),\n pos = group._legendPositions || \n (group._legendPositions = {right: 0.5, left: 0.5});\n\n o.x = 0.5;\n o.width = lw;\n o.y = pos[orient];\n pos[orient] += (o.height = lh);\n\n // HACK: use to estimate group bounds during animated transition\n if (!trans && group.bounds) {\n group.bounds.delta = group.bounds.x2 - group.width;\n }\n\n switch (orient) {\n case \"left\": {\n gx = group.bounds ? group.bounds.x1 : 0;\n o.x += gx - offset - lw;\n break;\n };\n case \"right\": {\n gx = group.width;\n if (group.bounds) gx = trans\n ? group.width + group.bounds.delta\n : group.bounds.x2;\n o.x += gx + offset;\n break;\n };\n }\n \n if (trans) trans.interpolate(item, o);\n var enc = item.mark.def.properties.enter.encode;\n enc.call(enc, item, group, trans);\n}\n\nfunction vg_legendSymbolExtend(mark, size, shape, fill, stroke) {\n var e = mark.properties.enter,\n u = mark.properties.update;\n if (size) e.size = u.size = {scale: size.scaleName, field: \"data\"};\n if (shape) e.shape = u.shape = {scale: shape.scaleName, field: \"data\"};\n if (fill) e.fill = u.fill = {scale: fill.scaleName, field: \"data\"};\n if (stroke) e.stroke = u.stroke = {scale: stroke.scaleName, field: \"data\"};\n}\n\nfunction vg_legendTitle() {\n var cfg = config.legend;\n return {\n type: \"text\",\n interactive: false,\n key: \"data\",\n properties: {\n enter: {\n x: {value: 0},\n y: {value: 0},\n fill: {value: cfg.titleColor},\n font: {value: cfg.titleFont},\n fontSize: {value: cfg.titleFontSize},\n fontWeight: {value: cfg.titleFontWeight},\n baseline: {value: \"top\"},\n text: {field: \"data\"},\n opacity: {value: 1e-6}\n },\n exit: { opacity: {value: 1e-6} },\n update: { opacity: {value: 1} }\n }\n };\n}\n\nfunction vg_legendSymbols() {\n var cfg = config.legend;\n return {\n type: \"symbol\",\n interactive: false,\n key: \"data\",\n properties: {\n enter: {\n x: {field: \"offset\", mult: 0.5},\n y: {scale: \"legend\", field: \"index\"},\n shape: {value: cfg.symbolShape},\n size: {value: cfg.symbolSize},\n stroke: {value: cfg.symbolColor},\n strokeWidth: {value: cfg.symbolStrokeWidth},\n opacity: {value: 1e-6}\n },\n exit: { opacity: {value: 1e-6} },\n update: {\n x: {field: \"offset\", mult: 0.5},\n y: {scale: \"legend\", field: \"index\"},\n opacity: {value: 1}\n }\n }\n };\n}\n\nfunction vg_vLegendLabels() {\n var cfg = config.legend;\n return {\n type: \"text\",\n interactive: false,\n key: \"data\",\n properties: {\n enter: {\n x: {field: \"offset\", offset: 5},\n y: {scale: \"legend\", field: \"index\"},\n fill: {value: cfg.labelColor},\n font: {value: cfg.labelFont},\n fontSize: {value: cfg.labelFontSize},\n align: {value: cfg.labelAlign},\n baseline: {value: cfg.labelBaseline},\n text: {field: \"label\"},\n opacity: {value: 1e-6}\n },\n exit: { opacity: {value: 1e-6} },\n update: {\n opacity: {value: 1},\n x: {field: \"offset\", offset: 5},\n y: {scale: \"legend\", field: \"index\"},\n }\n }\n };\n}\n\nfunction vg_legendGradient() {\n var cfg = config.legend;\n return {\n type: \"rect\",\n interactive: false,\n properties: {\n enter: {\n x: {value: 0},\n y: {value: 0},\n width: {value: cfg.gradientWidth},\n height: {value: cfg.gradientHeight},\n stroke: {value: cfg.gradientStrokeColor},\n strokeWidth: {value: cfg.gradientStrokeWidth},\n opacity: {value: 1e-6}\n },\n exit: { opacity: {value: 1e-6} },\n update: {\n x: {value: 0},\n y: {value: 0},\n opacity: {value: 1}\n }\n }\n };\n}\n\nfunction vg_hLegendLabels() {\n var cfg = config.legend;\n return {\n type: \"text\",\n interactive: false,\n key: \"data\",\n properties: {\n enter: {\n x: {scale: \"legend\", field: \"data\"},\n y: {value: 20},\n dy: {value: 2},\n fill: {value: cfg.labelColor},\n font: {value: cfg.labelFont},\n fontSize: {value: cfg.labelFontSize},\n align: {field: \"align\"},\n baseline: {value: \"top\"},\n text: {field: \"label\"},\n opacity: {value: 1e-6}\n },\n exit: { opacity: {value: 1e-6} },\n update: {\n x: {scale: \"legend\", field: \"data\"},\n y: {value: 20},\n opacity: {value: 1}\n }\n }\n };\n}\n\nmodule.exports = lgnd;",
"module.exports = function visit(node, func) {\n var i, n, s, m, items;\n if (func(node)) return true;\n\n var sets = [\"items\", \"axisItems\", \"legendItems\"];\n for (s=0, m=sets.length; s<m; ++s) {\n if (items = node[sets[s]]) {\n for (i=0, n=items.length; i<n; ++i) {\n if (visit(items[i], func)) return true;\n }\n }\n }\n};",
"var dl = require('datalib'),\n Transform = require('./Transform'),\n Facetor = require('./Facetor'),\n tuple = require('../dataflow/tuple'), \n changeset = require('../dataflow/changeset'), \n debug = require('../util/debug'),\n C = require('../util/constants');\n\nfunction Aggregate(graph) {\n Transform.prototype.init.call(this, graph)\n .router(true).revises(true);\n\n Transform.addParameters(this, {\n groupby: {type: \"array<field>\"},\n\n summarize: {\n type: \"custom\", \n set: function(summarize) {\n var i, len, f, fields, name, ops, signals = {};\n if(!dl.isArray(fields = summarize)) { // Object syntax from dl\n fields = [];\n for (name in summarize) {\n ops = dl.array(summarize[name]);\n fields.push({name: name, ops: ops});\n }\n }\n\n for(i=0, len=fields.length; i<len; ++i) {\n f = fields[i];\n if(f.name.signal) signals[f.name.signal] = 1;\n dl.array(f.ops).forEach(function(o){ if(o.signal) signals[o.signal] = 1 });\n }\n\n this._transform._fieldsDef = fields;\n this._transform._aggr = null;\n this._transform.dependency(C.SIGNALS, dl.keys(signals));\n return this._transform;\n }\n }\n });\n\n this._fieldsDef = [];\n this._aggr = null; // dl.Aggregator\n\n this._type = TYPES.TUPLE; \n this._acc = {groupby: dl.true, value: dl.true}\n this._cache = {}; // And cache them as aggregators expect original tuples.\n\n // Aggregator needs a full instantiation of the previous tuple. \n // Cache them to reduce creation costs\n this._prev = {}; \n\n return this;\n}\n\nvar proto = (Aggregate.prototype = new Transform());\n\nvar TYPES = Aggregate.TYPES = {\n VALUE: 1, \n TUPLE: 2, \n MULTI: 3\n};\n\nproto.type = function(type) { \n return (this._type = type, this); \n};\n\nproto.accessors = function(groupby, value) {\n var acc = this._acc;\n acc.groupby = dl.$(groupby) || dl.true;\n acc.value = dl.$(value) || dl.true;\n};\n\nfunction standardize(x) {\n var acc = this._acc;\n if(this._type === TYPES.TUPLE) {\n return x;\n } else if(this._type === TYPES.VALUE) {\n return acc.value(x);\n } else {\n return this._cache[x._id] || (this._cache[x._id] = {\n _id: x._id,\n groupby: acc.groupby(x),\n value: acc.value(x)\n });\n }\n}\n\nproto.aggr = function() {\n if(this._aggr) return this._aggr;\n\n var graph = this._graph,\n groupby = this.param(\"groupby\").field;\n\n var fields = this._fieldsDef.map(function(field) {\n var f = dl.duplicate(field);\n if(field.get) f.get = field.get;\n\n f.name = f.name.signal ? graph.signalRef(f.name.signal) : f.name;\n f.ops = f.ops.signal ? graph.signalRef(f.ops.signal) : dl.array(f.ops).map(function(o) {\n return o.signal ? graph.signalRef(o.signal) : o;\n });\n\n return f;\n });\n\n var aggr = this._aggr = new Facetor()\n .groupby(groupby)\n .stream(true)\n .summarize(fields);\n\n if(this._type !== TYPES.VALUE) aggr.key(\"_id\");\n return aggr;\n};\n\nproto._reset = function(input, output) {\n output.rem.push.apply(output.rem, this.aggr().result());\n this.aggr().clear();\n this._aggr = null;\n};\n\nfunction spoof_prev(x) {\n var prev = this._prev[x._id] || (this._prev[x._id] = Object.create(x));\n return dl.extend(prev, x._prev);\n}\n\nproto.transform = function(input, reset) {\n debug(input, [\"aggregate\"]);\n\n var output = changeset.create(input);\n if(reset) this._reset(input, output);\n\n var t = this,\n tpl = this._type === TYPES.TUPLE, // reduce calls to standardize\n aggr = this.aggr();\n\n input.add.forEach(function(x) {\n aggr._add(tpl ? x : standardize.call(t, x));\n });\n\n input.mod.forEach(function(x) {\n if(reset) {\n aggr._add(tpl ? x : standardize.call(t, x)); // Signal change triggered reflow\n } else if(tuple.has_prev(x)) {\n var prev = spoof_prev.call(t, x);\n aggr._mod(tpl ? x : standardize.call(t, x), \n tpl ? prev : standardize.call(t, prev));\n }\n });\n\n input.rem.forEach(function(x) {\n var y = tuple.has_prev(x) ? spoof_prev.call(t, x) : x;\n aggr._rem(tpl ? y : standardize.call(t, y));\n t._cache[x._id] = t._prev[x._id] = null;\n });\n\n return aggr.changes(input, output);\n}\n\nmodule.exports = Aggregate;",
"var Transform = require('./Transform'),\n Collector = require('../dataflow/Collector');\n\nfunction BatchTransform() {\n}\n\nvar proto = (BatchTransform.prototype = new Transform());\n\nproto.init = function(graph) {\n Transform.prototype.init.call(this, graph);\n this._collector = new Collector(graph);\n return this;\n};\n\nproto.transform = function(input) {\n // Materialize the current datasource.\n // TODO: efficiently share collectors\n this._collector.evaluate(input);\n var data = this._collector.data();\n return this.batchTransform(input, data);\n};\n\nproto.batchTransform = function(input, data) {\n};\n\nmodule.exports = BatchTransform;\n",
"var dl = require('datalib'),\n Transform = require('./Transform'),\n tuple = require('../dataflow/tuple');\n\nfunction Bin(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n field: {type: \"field\"},\n min: {type: \"value\"},\n max: {type: \"value\"},\n step: {type: \"value\"},\n maxbins: {type: \"value\", default: 20}\n });\n\n this._output = {\"bin\": \"bin\"};\n return this;\n}\n\nvar proto = (Bin.prototype = new Transform());\n\nproto.transform = function(input) {\n var transform = this,\n output = this._output.bin;\n \n var b = dl.bins({\n min: this.param(\"min\"),\n max: this.param(\"max\"),\n step: this.param(\"step\"),\n maxbins: this.param(\"maxbins\")\n });\n\n function update(d) {\n var v = transform.param(\"field\").accessor(d);\n v = v == null ? null\n : b.start + b.step * ~~((v - b.start) / b.step);\n tuple.set(d, output, v, input.stamp);\n }\n input.add.forEach(update);\n input.mod.forEach(update);\n input.rem.forEach(update);\n\n return input;\n};\n\nmodule.exports = Bin;\n",
"var Transform = require('./Transform'),\n Collector = require('../dataflow/Collector'),\n debug = require('../util/debug'),\n tuple = require('../dataflow/tuple'),\n changeset = require('../dataflow/changeset');\n\nfunction Cross(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n with: {type: \"data\"},\n diagonal: {type: \"value\", default: \"true\"}\n });\n\n this._output = {\"left\": \"a\", \"right\": \"b\"};\n this._collector = new Collector(graph);\n this._lastRem = null; // Most recent stamp that rem occured. \n this._lastWith = null; // Last time we crossed w/withds.\n this._ids = {};\n this._cache = {};\n\n return this.router(true);\n}\n\nvar proto = (Cross.prototype = new Transform());\n\n// Each cached incoming tuple also has a stamp to track if we need to do\n// lazy filtering of removed tuples.\nfunction cache(x, t) {\n var c = this._cache[x._id] = this._cache[x._id] || {c: [], s: this._stamp};\n c.c.push(t);\n}\n\nfunction add(output, left, wdata, diag, x) {\n var data = left ? wdata : this._collector.data(), // Left tuples cross w/right.\n i = 0, len = data.length,\n prev = x._prev !== undefined ? null : undefined, \n t, y, id;\n\n for(; i<len; ++i) {\n y = data[i];\n id = left ? x._id+\"_\"+y._id : y._id+\"_\"+x._id;\n if(this._ids[id]) continue;\n if(x._id == y._id && !diag) continue;\n\n t = tuple.ingest({}, prev);\n t[this._output.left] = left ? x : y;\n t[this._output.right] = left ? y : x;\n output.add.push(t);\n cache.call(this, x, t);\n cache.call(this, y, t);\n this._ids[id] = 1;\n }\n}\n\nfunction mod(output, left, x) {\n var cross = this,\n c = this._cache[x._id];\n\n if(this._lastRem > c.s) { // Removed tuples haven't been filtered yet\n c.c = c.c.filter(function(y) {\n var t = y[cross._output[left ? \"right\" : \"left\"]];\n return cross._cache[t._id] !== null;\n });\n c.s = this._lastRem;\n }\n\n output.mod.push.apply(output.mod, c.c);\n}\n\nfunction rem(output, x) {\n output.rem.push.apply(output.rem, this._cache[x._id].c);\n this._cache[x._id] = null;\n this._lastRem = this._stamp;\n}\n\nfunction upFields(input, output) {\n if(input.add.length || input.rem.length) {\n output.fields[this._output.left] = 1; \n output.fields[this._output.right] = 1;\n }\n}\n\nproto.transform = function(input) {\n debug(input, [\"crossing\"]);\n\n // Materialize the current datasource. TODO: share collectors\n this._collector.evaluate(input);\n\n var w = this.param(\"with\"),\n diag = this.param(\"diagonal\"),\n selfCross = (!w.name),\n data = this._collector.data(),\n woutput = selfCross ? input : w.source.last(),\n wdata = selfCross ? data : w.source.values(),\n output = changeset.create(input),\n r = rem.bind(this, output); \n\n input.rem.forEach(r);\n input.add.forEach(add.bind(this, output, true, wdata, diag));\n\n if(!selfCross && woutput.stamp > this._lastWith) {\n woutput.rem.forEach(r);\n woutput.add.forEach(add.bind(this, output, false, data, diag));\n woutput.mod.forEach(mod.bind(this, output, false));\n upFields.call(this, woutput, output);\n this._lastWith = woutput.stamp;\n }\n\n // Mods need to come after all removals have been run.\n input.mod.forEach(mod.bind(this, output, true));\n upFields.call(this, input, output);\n\n return output;\n};\n\nmodule.exports = Cross;",
"var Transform = require('./Transform'),\n Aggregate = require('./Aggregate');\n\nfunction Facet(graph) {\n Transform.addParameters(this, {\n transform: {\n type: \"custom\",\n set: function(pipeline) {\n return (this._transform._pipeline = pipeline, this._transform);\n },\n get: function() {\n var parse = require('../parse/transforms'),\n facet = this._transform;\n return facet._pipeline.map(function(t) { return parse(facet._graph, t) });\n } \n }\n });\n\n this._pipeline = [];\n return Aggregate.call(this, graph);\n}\n\nvar proto = (Facet.prototype = Object.create(Aggregate.prototype));\n\nproto.aggr = function() {\n return Aggregate.prototype.aggr.call(this).facet(this);\n};\n\nmodule.exports = Facet;",
"var dl = require('datalib'),\n tuple = require('../dataflow/tuple'),\n changeset = require('../dataflow/changeset'),\n debug = require('../util/debug'),\n C = require('../util/constants');\n\nfunction Facetor() {\n Aggregator.constructor.call(this);\n this._facet = null;\n}\n\nvar Aggregator = dl.groupby();\nvar proto = (Facetor.prototype = Object.create(Aggregator));\n\nproto.facet = function(f) {\n if(!arguments.length) return this._facet;\n return (this._facet = f, this);\n};\n\nproto._ingest = function(t) { \n return tuple.ingest(t, null) \n};\n\nproto._assign = tuple.set;\n\nfunction disconnect_cell(facet) {\n debug({}, [\"deleting cell\", this.tuple._id]);\n var pipeline = this.ds.pipeline();\n facet.removeListener(pipeline[0]);\n facet._graph.disconnect(pipeline);\n}\n\nproto._newcell = function(x) {\n var cell = Aggregator._newcell.call(this, x),\n facet = this._facet,\n tuple = cell.tuple,\n graph, pipeline;\n\n if(this._facet !== null) {\n graph = facet._graph;\n pipeline = facet.param(\"transform\");\n cell.ds = graph.data(\"vg_\"+tuple._id, pipeline, tuple);\n cell.delete = disconnect_cell;\n facet.addListener(pipeline[0]);\n }\n\n return cell;\n};\n\nproto._newtuple = function(x) {\n var t = Aggregator._newtuple.call(this, x);\n if(this._facet !== null) {\n tuple.set(t, \"key\", this._cellkey(x));\n }\n return t;\n};\n\nproto.clear = function() {\n if(this._facet !== null) for (var k in this._cells) {\n this._cells[k].delete(this._facet);\n }\n return Aggregator.clear.call(this);\n};\n\nproto._add = function(x) {\n var cell = this._cell(x);\n Aggregator._add.call(this, x);\n if(this._facet !== null) cell.ds._input.add.push(x);\n};\n\nproto._mod = function(x, prev) {\n var cell0 = this._cell(prev),\n cell1 = this._cell(x);\n\n Aggregator._mod.call(this, x, prev);\n if(this._facet !== null) { // Propagate tuples\n if(cell0 === cell1) {\n cell0.ds._input.mod.push(x);\n } else {\n cell0.ds._input.rem.push(x);\n cell1.ds._input.add.push(x);\n }\n }\n};\n\nproto._rem = function(x) {\n var cell = this._cell(x);\n Aggregator._rem.call(this, x);\n if(this._facet !== null) cell.ds._input.rem.push(x); \n};\n\nproto.changes = function(input, output) {\n var aggr = this._aggr,\n cell, flag, i, k;\n\n for (k in this._cells) {\n cell = this._cells[k];\n flag = cell.flag;\n\n // consolidate collector values\n if (cell.collect) {\n cell.data.values();\n }\n\n // update tuple properties\n for (i=0; i<aggr.length; ++i) {\n cell.aggs[aggr[i].name].set();\n }\n\n // organize output tuples\n if (cell.num <= 0) {\n if (flag === C.MOD_CELL) {\n output.rem.push(cell.tuple);\n }\n if(this._facet !== null) cell.delete(this._facet);\n delete this._cells[k];\n } else {\n if(this._facet !== null) {\n // propagate sort, signals, fields, etc.\n changeset.copy(input, cell.ds._input);\n }\n\n if (flag & C.ADD_CELL) {\n output.add.push(cell.tuple);\n } else if (flag & C.MOD_CELL) {\n output.mod.push(cell.tuple);\n }\n }\n\n cell.flag = 0;\n }\n\n this._rems = false;\n return output;\n};\n\nmodule.exports = Facetor;",
"var Transform = require('./Transform'),\n changeset = require('../dataflow/changeset'), \n expr = require('../parse/expr'),\n debug = require('../util/debug'),\n C = require('../util/constants');\n\nfunction Filter(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, {test: {type: \"expr\"} });\n\n this._skip = {};\n return this;\n}\n\nvar proto = (Filter.prototype = new Transform());\n\nfunction test(x) {\n return expr.eval(this._graph, this.param(\"test\"), \n x, null, null, null, this.dependency(C.SIGNALS));\n};\n\nproto.transform = function(input) {\n debug(input, [\"filtering\"]);\n var output = changeset.create(input),\n skip = this._skip,\n f = this;\n\n input.rem.forEach(function(x) {\n if (skip[x._id] !== 1) output.rem.push(x);\n else skip[x._id] = 0;\n });\n\n input.add.forEach(function(x) {\n if (test.call(f, x)) output.add.push(x);\n else skip[x._id] = 1;\n });\n\n input.mod.forEach(function(x) {\n var b = test.call(f, x),\n s = (skip[x._id] === 1);\n if (b && s) {\n skip[x._id] = 0;\n output.add.push(x);\n } else if (b && !s) {\n output.mod.push(x);\n } else if (!b && s) {\n // do nothing, keep skip true\n } else { // !b && !s\n output.rem.push(x);\n skip[x._id] = 1;\n }\n });\n\n return output;\n};\n\nmodule.exports = Filter;",
"var Transform = require('./Transform'),\n debug = require('../util/debug'), \n tuple = require('../dataflow/tuple'), \n changeset = require('../dataflow/changeset');\n\nfunction Fold(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n fields: {type: \"array<field>\"} \n });\n\n this._output = {key: \"key\", value: \"value\"};\n this._cache = {};\n\n return this.router(true).revises(true);\n}\n\nvar proto = (Fold.prototype = new Transform());\n\nfunction rst(input, output) { \n for(var id in this._cache) output.rem.push.apply(output.rem, this._cache[id]);\n this._cache = {};\n};\n\nfunction get_tuple(x, i, len) {\n var list = this._cache[x._id] || (this._cache[x._id] = Array(len));\n return list[i] || (list[i] = tuple.derive(x, x._prev));\n};\n\nfunction fn(data, fields, accessors, out, stamp) {\n var i = 0, dlen = data.length,\n j, flen = fields.length,\n d, t;\n\n for(; i<dlen; ++i) {\n d = data[i];\n for(j=0; j<flen; ++j) {\n t = get_tuple.call(this, d, j, flen); \n tuple.set(t, this._output.key, fields[j]);\n tuple.set(t, this._output.value, accessors[j](d));\n out.push(t);\n } \n }\n};\n\nproto.transform = function(input, reset) {\n debug(input, [\"folding\"]);\n\n var fold = this,\n on = this.param('fields'),\n output = changeset.create(input);\n\n if(reset) rst.call(this, input, output);\n\n fn.call(this, input.add, on.field, on.accessor, output.add, input.stamp);\n fn.call(this, input.mod, on.field, on.accessor, reset ? output.add : output.mod, input.stamp);\n input.rem.forEach(function(x) {\n output.rem.push.apply(output.rem, fold._cache[x._id]);\n fold._cache[x._id] = null;\n });\n\n // If we're only propagating values, don't mark key/value as updated.\n if(input.add.length || input.rem.length || \n on.field.some(function(f) { return !!input.fields[f]; }))\n output.fields[this._output.key] = 1, output.fields[this._output.value] = 1;\n return output;\n};\n\nmodule.exports = Fold;",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n Transform = require('./Transform'),\n tuple = require('../dataflow/tuple');\n\nfunction Force(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n size: {type: \"array<value>\", default: [500, 500]},\n links: {type: \"data\"},\n linkDistance: {type: \"field|value\", default: 20},\n linkStrength: {type: \"field|value\", default: 1},\n charge: {type: \"field|value\", default: 30},\n chargeDistance: {type: \"field|value\", default: Infinity},\n iterations: {type: \"value\", default: 500},\n friction: {type: \"value\", default: 0.9},\n theta: {type: \"value\", default: 0.8},\n gravity: {type: \"value\", default: 0.1},\n alpha: {type: \"value\", default: 0.1}\n });\n\n this._nodes = [];\n this._links = [];\n this._layout = d3.layout.force();\n\n this._output = {\n \"x\": \"layout_x\",\n \"y\": \"layout_y\",\n \"source\": \"_source\",\n \"target\": \"_target\"\n };\n\n return this;\n}\n\nvar proto = (Force.prototype = new Transform());\n\nproto.transform = function(nodeInput) {\n // get variables\n var linkInput = this.param(\"links\").source.last(),\n layout = this._layout,\n output = this._output,\n nodes = this._nodes,\n links = this._links,\n iter = this.param(\"iterations\");\n\n // process added nodes\n nodeInput.add.forEach(function(n) {\n nodes.push({tuple: n});\n });\n\n // process added edges\n linkInput.add.forEach(function(l) {\n var link = {\n tuple: l,\n source: nodes[l.source],\n target: nodes[l.target]\n };\n tuple.set(l, output.source, link.source.tuple);\n tuple.set(l, output.target, link.target.tuple);\n links.push(link);\n });\n\n // TODO process \"mod\" of edge source or target?\n\n // configure layout\n layout\n .size(this.param(\"size\"))\n .linkDistance(this.param(\"linkDistance\"))\n .linkStrength(this.param(\"linkStrength\"))\n .charge(this.param(\"charge\"))\n .chargeDistance(this.param(\"chargeDistance\"))\n .friction(this.param(\"friction\"))\n .theta(this.param(\"theta\"))\n .gravity(this.param(\"gravity\"))\n .alpha(this.param(\"alpha\"))\n .nodes(nodes)\n .links(links);\n\n // run layout\n layout.start();\n for (var i=0; i<iter; ++i) {\n layout.tick();\n }\n layout.stop();\n\n // copy layout values to nodes\n nodes.forEach(function(n) {\n tuple.set(n.tuple, output.x, n.x);\n tuple.set(n.tuple, output.y, n.y);\n });\n\n // process removed nodes\n if (nodeInput.rem.length > 0) {\n var nodeIds = tuple.idMap(nodeInput.rem);\n this._nodes = nodes.filter(function(n) { return !nodeIds[n.tuple._id]; });\n }\n\n // process removed edges\n if (linkInput.rem.length > 0) {\n var linkIds = tuple.idMap(linkInput.rem);\n this._links = links.filter(function(l) { return !linkIds[l.tuple._id]; });\n }\n\n // return changeset\n nodeInput.fields[output.x] = 1;\n nodeInput.fields[output.y] = 1;\n return nodeInput;\n};\n\nmodule.exports = Force;",
"var Transform = require('./Transform'),\n tuple = require('../dataflow/tuple'), \n expression = require('../parse/expr'),\n debug = require('../util/debug'),\n C = require('../util/constants');\n\nfunction Formula(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n field: {type: \"value\"},\n expr: {type: \"expr\"}\n });\n\n return this;\n}\n\nvar proto = (Formula.prototype = new Transform());\n\nproto.transform = function(input) {\n debug(input, [\"formulating\"]);\n var t = this, \n g = this._graph,\n field = this.param(\"field\"),\n expr = this.param(\"expr\"),\n deps = this.dependency(C.SIGNALS);\n \n function set(x) {\n var val = expression.eval(g, expr, x, null, null, null, deps);\n tuple.set(x, field, val);\n }\n\n input.add.forEach(set);\n \n if (this.reevaluate(input)) {\n input.mod.forEach(set);\n }\n\n input.fields[field] = 1;\n return input;\n};\n\nmodule.exports = Formula;",
"var dl = require('datalib'),\n d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n Transform = require('./Transform'),\n tuple = require('../dataflow/tuple');\n\nfunction Geo(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, Geo.Parameters);\n Transform.addParameters(this, {\n lon: {type: \"field\"},\n lat: {type: \"field\"}\n });\n\n this._output = {\n \"x\": \"layout_x\",\n \"y\": \"layout_y\"\n };\n return this;\n}\n\nvar None\n\nGeo.Parameters = {\n projection: {type: \"value\", default: \"mercator\"},\n center: {type: \"array[value]\"},\n translate: {type: \"array[value]\"},\n rotate: {type: \"array[value]\"},\n scale: {type: \"value\"},\n precision: {type: \"value\"},\n clipAngle: {type: \"value\"},\n clipExtent: {type: \"value\"}\n};\n\nGeo.d3Projection = function() {\n var g = this._graph,\n p = this.param(\"projection\"),\n param = Geo.Parameters,\n proj, name, value;\n\n if (p !== this._mode) {\n this._mode = p;\n this._projection = d3.geo[p]();\n }\n proj = this._projection;\n\n for (name in param) {\n if (name === \"projection\" || !proj[name]) continue;\n value = this.param(name);\n if (value === undefined || (dl.isArray(value) && value.length === 0)) {\n continue;\n }\n if (value !== proj[name]()) {\n proj[name](value);\n }\n }\n\n return proj;\n};\n\nvar proto = (Geo.prototype = new Transform());\n\nproto.transform = function(input) {\n var g = this._graph,\n output = this._output,\n lon = this.param(\"lon\").accessor,\n lat = this.param(\"lat\").accessor,\n proj = Geo.d3Projection.call(this);\n\n function set(t) {\n var ll = [lon(t), lat(t)];\n var xy = proj(ll);\n tuple.set(t, output.x, xy[0]);\n tuple.set(t, output.y, xy[1]);\n }\n\n input.add.forEach(set);\n if (this.reevaluate(input)) {\n input.mod.forEach(set);\n input.rem.forEach(set);\n }\n\n input.fields[output.x] = 1;\n input.fields[output.y] = 1;\n return input;\n};\n\nmodule.exports = Geo;\n",
"var dl = require('datalib'),\n d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n Geo = require('./Geo'),\n Transform = require('./Transform'),\n tuple = require('../dataflow/tuple');\n\nfunction GeoPath(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, Geo.Parameters);\n Transform.addParameters(this, {\n value: {type: \"field\", default: null},\n });\n\n this._output = {\n \"path\": \"layout_path\"\n };\n return this;\n}\n\nvar proto = (GeoPath.prototype = new Transform());\n\nproto.transform = function(input) {\n var output = this._output,\n geojson = this.param(\"value\").accessor || dl.identity,\n proj = Geo.d3Projection.call(this),\n path = d3.geo.path().projection(proj);\n\n function set(t) {\n tuple.set(t, output.path, path(geojson(t)));\n }\n\n input.add.forEach(set);\n if (this.reevaluate(input)) {\n input.mod.forEach(set);\n input.rem.forEach(set);\n }\n\n input.fields[output.path] = 1;\n return input;\n};\n\nmodule.exports = GeoPath;\n",
"var Transform = require('./Transform'),\n tuple = require('../dataflow/tuple');\n\nfunction LinkPath(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n source: {type: \"field\", default: \"_source\"},\n target: {type: \"field\", default: \"_target\"},\n x: {type: \"field\", default: \"layout_x\"},\n y: {type: \"field\", default: \"layout_y\"},\n tension: {type: \"value\", default: 0.2},\n shape: {type: \"value\", default: \"line\"}\n });\n\n this._output = {\"path\": \"layout_path\"};\n return this;\n}\n\nvar proto = (LinkPath.prototype = new Transform());\n\nfunction line(d, source, target, x, y, tension) {\n var s = source(d), sx = x(s), sy = y(s),\n t = target(d), tx = x(t), ty = y(t);\n return \"M\" + sx + \",\" + sy\n + \"L\" + tx + \",\" + ty;\n}\n\nfunction curve(d, source, target, x, y, tension) {\n var s = source(d), sx = x(s), sy = y(s),\n t = target(d), tx = x(t), ty = y(t),\n dx = tx - sx,\n dy = ty - sy,\n ix = tension * (dx + dy),\n iy = tension * (dy - dx);\n return \"M\" + sx + \",\" + sy\n + \"C\" + (sx+ix) + \",\" + (sy+iy)\n + \" \" + (tx+iy) + \",\" + (ty-ix)\n + \" \" + tx + \",\" + ty;\n}\n\nfunction diagonalX(d, source, target, x, y, tension) {\n var s = source(d), sx = x(s), sy = y(s),\n t = target(d), tx = x(t), ty = y(t),\n m = (sx + tx) / 2;\n return \"M\" + sx + \",\" + sy\n + \"C\" + m + \",\" + sy\n + \" \" + m + \",\" + ty\n + \" \" + tx + \",\" + ty;\n}\n\nfunction diagonalY(d, source, target, x, y, tension) {\n var s = source(d), sx = x(s), sy = y(s),\n t = target(d), tx = x(t), ty = y(t),\n m = (sy + ty) / 2;\n return \"M\" + sx + \",\" + sy\n + \"C\" + sx + \",\" + m\n + \" \" + tx + \",\" + m\n + \" \" + tx + \",\" + ty;\n}\n\nvar shapes = {\n line: line,\n curve: curve,\n diagonal: diagonalX,\n diagonalX: diagonalX,\n diagonalY: diagonalY\n};\n\nproto.transform = function(input) {\n var output = this._output,\n shape = shapes[this.param(\"shape\")] || shapes.line,\n source = this.param(\"source\").accessor,\n target = this.param(\"target\").accessor,\n x = this.param(\"x\").accessor,\n y = this.param(\"y\").accessor,\n tension = this.param(\"tension\");\n \n function set(t) {\n var path = shape(t, source, target, x, y, tension)\n tuple.set(t, output.path, path);\n }\n\n input.add.forEach(set);\n if (this.reevaluate(input)) {\n input.mod.forEach(set);\n }\n\n input.fields[output.path] = 1;\n return input;\n};\n\nmodule.exports = LinkPath;",
"var dl = require('datalib'),\n expr = require('../parse/expr'),\n C = require('../util/constants');\n\nvar arrayType = /array/i,\n dataType = /data/i,\n fieldType = /field/i,\n exprType = /expr/i,\n valType = /value/i;\n\nfunction Parameter(name, type, transform) {\n this._name = name;\n this._type = type;\n this._transform = transform;\n\n // If parameter is defined w/signals, it must be resolved\n // on every pulse.\n this._value = [];\n this._accessors = [];\n this._resolution = false;\n this._signals = {};\n}\n\nvar proto = Parameter.prototype;\n\nfunction get() {\n var isArray = arrayType.test(this._type),\n isData = dataType.test(this._type),\n isField = fieldType.test(this._type);\n\n var val = isArray ? this._value : this._value[0],\n acc = isArray ? this._accessors : this._accessors[0];\n\n if(!dl.isValid(acc) && valType.test(this._type)) {\n return val;\n } else {\n return isData ? { name: val, source: acc } :\n isField ? { field: val, accessor: acc } : val;\n }\n};\n\nproto.get = function() {\n var graph = this._transform._graph, \n isData = dataType.test(this._type),\n isField = fieldType.test(this._type),\n s, idx, val;\n\n // If we don't require resolution, return the value immediately.\n if (!this._resolution) return get.call(this);\n\n if (isData) {\n this._accessors = this._value.map(function(v) { return graph.data(v); });\n return get.call(this); // TODO: support signal as dataTypes\n }\n\n for(s in this._signals) {\n idx = this._signals[s];\n val = graph.signalRef(s);\n\n if (isField) {\n this._accessors[idx] = this._value[idx] != val ? \n dl.accessor(val) : this._accessors[idx];\n }\n\n this._value[idx] = val;\n }\n\n return get.call(this);\n};\n\nproto.set = function(value) {\n var p = this,\n isExpr = exprType.test(this._type),\n isData = dataType.test(this._type),\n isField = fieldType.test(this._type);\n\n this._value = dl.array(value).map(function(v, i) {\n if (dl.isString(v)) {\n if (isExpr) {\n var e = expr(v);\n p._transform.dependency(C.FIELDS, e.fields);\n p._transform.dependency(C.SIGNALS, e.signals);\n return e.fn;\n } else if (isField) { // Backwards compatibility\n p._accessors[i] = dl.accessor(v);\n p._transform.dependency(C.FIELDS, v);\n } else if (isData) {\n p._resolution = true;\n p._transform.dependency(C.DATA, v);\n }\n return v;\n } else if (v.value !== undefined) {\n return v.value;\n } else if (v.field !== undefined) {\n p._accessors[i] = dl.accessor(v.field);\n p._transform.dependency(C.FIELDS, v.field);\n return v.field;\n } else if (v.signal !== undefined) {\n p._resolution = true;\n p._signals[v.signal] = i;\n p._transform.dependency(C.SIGNALS, v.signal);\n return v.signal;\n }\n\n return v;\n });\n\n return p._transform;\n};\n\nmodule.exports = Parameter;",
"var dl = require('datalib'),\n d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n Transform = require('./Transform'),\n BatchTransform = require('./BatchTransform'),\n tuple = require('../dataflow/tuple');\n\nfunction Pie(graph) {\n BatchTransform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n value: {type: \"field\", default: null},\n startAngle: {type: \"value\", default: 0},\n endAngle: {type: \"value\", default: 2 * Math.PI},\n sort: {type: \"value\", default: false}\n });\n\n this._output = {\n \"start\": \"layout_start\",\n \"end\": \"layout_end\",\n \"mid\": \"layout_mid\"\n };\n\n return this;\n}\n\nvar proto = (Pie.prototype = new BatchTransform());\n\nfunction ones() { return 1; }\n\nproto.batchTransform = function(input, data) {\n var g = this._graph,\n output = this._output,\n value = this.param(\"value\").accessor || ones,\n start = this.param(\"startAngle\"),\n stop = this.param(\"endAngle\"),\n sort = this.param(\"sort\");\n\n var values = data.map(value),\n a = start,\n k = (stop - start) / d3.sum(values),\n index = dl.range(data.length),\n i, t, v;\n\n if (sort) {\n index.sort(function(a, b) {\n return values[a] - values[b];\n });\n }\n\n for (i=0; i<index.length; ++i) {\n t = data[index[i]];\n v = values[index[i]];\n tuple.set(t, output.start, a);\n tuple.set(t, output.mid, (a + 0.5 * v * k));\n tuple.set(t, output.end, (a += v * k));\n }\n\n input.fields[output.start] = 1;\n input.fields[output.end] = 1;\n input.fields[output.mid] = 1;\n return input;\n};\n\nmodule.exports = Pie;\n",
"var dl = require('datalib'),\n Transform = require('./Transform'),\n expr = require('../parse/expr'),\n debug = require('../util/debug');\n\nfunction Sort(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, {by: {type: \"array<field>\"} });\n return this.router(true);\n}\n\nvar proto = (Sort.prototype = new Transform());\n\nproto.transform = function(input) {\n debug(input, [\"sorting\"]);\n\n if(input.add.length || input.mod.length || input.rem.length) {\n input.sort = dl.comparator(this.param(\"by\").field);\n }\n\n return input;\n};\n\nmodule.exports = Sort;",
"var dl = require('datalib'),\n Transform = require('./Transform'),\n BatchTransform = require('./BatchTransform'),\n tuple = require('../dataflow/tuple');\n\nfunction Stack(graph) {\n BatchTransform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n groupby: {type: \"array<field>\"},\n sortby: {type: \"array<field>\"},\n value: {type: \"field\"},\n offset: {type: \"value\", default: \"zero\"}\n });\n\n this._output = {\n \"start\": \"layout_start\",\n \"end\": \"layout_end\",\n \"mid\": \"layout_mid\"\n };\n return this;\n}\n\nvar proto = (Stack.prototype = new BatchTransform());\n\nproto.batchTransform = function(input, data) {\n var g = this._graph,\n groupby = this.param(\"groupby\").accessor,\n sortby = dl.comparator(this.param(\"sortby\").field),\n value = this.param(\"value\").accessor,\n offset = this.param(\"offset\"),\n output = this._output;\n\n // partition, sum, and sort the stack groups\n var groups = partition(data, groupby, sortby, value);\n\n // compute stack layouts per group\n for (var i=0, max=groups.max; i<groups.length; ++i) {\n var group = groups[i],\n sum = group.sum,\n off = offset===\"center\" ? (max - sum)/2 : 0,\n scale = offset===\"normalize\" ? (1/sum) : 1,\n i, x, a, b = off, v = 0;\n\n // set stack coordinates for each datum in group\n for (j=0; j<group.length; ++j) {\n x = group[j];\n a = b; // use previous value for start point\n v += value(x);\n b = scale * v + off; // compute end point\n tuple.set(x, output.start, a);\n tuple.set(x, output.end, b);\n tuple.set(x, output.mid, 0.5 * (a + b));\n }\n }\n\n input.fields[output.start] = 1;\n input.fields[output.end] = 1;\n input.fields[output.mid] = 1;\n return input;\n};\n\nfunction partition(data, groupby, sortby, value) {\n var groups = [],\n map, i, x, k, g, s, max;\n\n // partition data points into stack groups\n if (groupby == null) {\n groups.push(data.slice());\n } else {\n for (map={}, i=0; i<data.length; ++i) {\n x = data[i];\n k = (groupby.map(function(f) { return f(x); }));\n g = map[k] || (groups.push(map[k] = []), map[k]);\n g.push(x);\n }\n }\n\n // compute sums of groups, sort groups as needed\n for (k=0, max=0; k<groups.length; ++k) {\n g = groups[k];\n for (i=0, s=0; i<g.length; ++i) {\n s += value(g[i]);\n }\n g.sum = s;\n if (s > max) max = s;\n if (sortby != null) g.sort(sortby);\n }\n groups.max = max;\n\n return groups;\n}\n\nmodule.exports = Stack;",
"var Node = require('../dataflow/Node'),\n Parameter = require('./Parameter'),\n C = require('../util/constants');\n\nfunction Transform(graph) {\n if(graph) Node.prototype.init.call(this, graph);\n return this;\n}\n\nTransform.addParameters = function(proto, params) {\n proto._parameters = proto._parameters || {};\n for (var name in params) {\n var p = params[name],\n param = proto._parameters[name] = new Parameter(name, p.type, proto);\n\n if (p.type === 'custom') {\n if (p.set) param.set = p.set.bind(param);\n if (p.get) param.get = p.get.bind(param);\n }\n\n if (p.hasOwnProperty('default')) param.set(p.default);\n }\n};\n\nvar proto = (Transform.prototype = new Node());\n\nproto.param = function(name, value) {\n if(arguments.length === 1) return this._parameters[name].get();\n return this._parameters[name].set(value);\n};\n\nproto.transform = function(input, reset) { return input; };\nproto.evaluate = function(input) {\n // Many transforms store caches that must be invalidated if\n // a signal value has changed. \n var reset = this._stamp < input.stamp && this.dependency(C.SIGNALS).some(function(s) { \n return !!input.signals[s] \n });\n\n return this.transform(input, reset);\n};\n\nproto.output = function(map) {\n for (var key in this._output) {\n if (map[key] !== undefined) {\n this._output[key] = map[key];\n }\n }\n return this;\n};\n\nmodule.exports = Transform;",
"var dl = require('datalib'),\n d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n Transform = require('./Transform'),\n BatchTransform = require('./BatchTransform'),\n tuple = require('../dataflow/tuple');\n\nfunction Treemap(graph) {\n BatchTransform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n // hierarchy parameters\n sort: {type: \"array<field>\", default: [\"-value\"]},\n children: {type: \"field\", default: \"children\"},\n value: {type: \"field\", default: \"value\"},\n // treemap parameters\n size: {type: \"array<value>\", default: [500, 500]},\n round: {type: \"value\", default: true},\n sticky: {type: \"value\", default: false},\n ratio: {type: \"value\", default: 0.5 * (1 + Math.sqrt(5))},\n padding: {type: \"value\", default: null},\n mode: {type: \"value\", default: \"squarify\"}\n });\n\n this._layout = d3.layout.treemap();\n\n this._output = {\n \"x\": \"layout_x\",\n \"y\": \"layout_y\",\n \"width\": \"layout_width\",\n \"height\": \"layout_height\"\n };\n return this;\n}\n\nvar proto = (Treemap.prototype = new BatchTransform());\n\nproto.batchTransform = function(input, data) {\n // get variables\n var layout = this._layout,\n output = this._output;\n\n // configure layout\n layout\n .sort(dl.comparator(this.param(\"sort\").field))\n .children(this.param(\"children\").accessor)\n .value(this.param(\"value\").accessor)\n .size(this.param(\"size\"))\n .round(this.param(\"round\"))\n .sticky(this.param(\"sticky\"))\n .ratio(this.param(\"ratio\"))\n .padding(this.param(\"padding\"))\n .mode(this.param(\"mode\"))\n .nodes(data[0]);\n\n // copy layout values to nodes\n data.forEach(function(n) {\n tuple.set(n, output.x, n.x);\n tuple.set(n, output.y, n.y);\n tuple.set(n, output.width, n.dx);\n tuple.set(n, output.height, n.dy);\n });\n\n // return changeset\n input.fields[output.x] = 1;\n input.fields[output.y] = 1;\n input.fields[output.width] = 1;\n input.fields[output.height] = 1;\n return input;\n};\n\nmodule.exports = Treemap;",
"var dl = require('datalib'),\n Transform = require('./Transform'),\n Collector = require('../dataflow/Collector'),\n debug = require('../util/debug');\n\nfunction Zip(graph) {\n Transform.prototype.init.call(this, graph);\n Transform.addParameters(this, {\n with: {type: \"data\"},\n as: {type: \"value\"},\n key: {type: \"field\", default: \"data\"},\n withKey: {type: \"field\", default: null},\n default: {type: \"value\"}\n });\n\n this._map = {};\n this._collector = new Collector(graph);\n this._lastJoin = 0;\n\n return this.revises(true);\n}\n\nvar proto = (Zip.prototype = new Transform());\n\nfunction mp(k) {\n return this._map[k] || (this._map[k] = []);\n};\n\nproto.transform = function(input) {\n var w = this.param(\"with\"),\n wds = w.source,\n woutput = wds.last(),\n wdata = wds.values(),\n key = this.param(\"key\"),\n withKey = this.param(\"withKey\"),\n as = this.param(\"as\"),\n dflt = this.param(\"default\"),\n map = mp.bind(this),\n rem = {};\n\n debug(input, [\"zipping\", w.name]);\n\n if(withKey.field) {\n if(woutput && woutput.stamp > this._lastJoin) {\n woutput.rem.forEach(function(x) {\n var m = map(withKey.accessor(x));\n if(m[0]) m[0].forEach(function(d) { d[as] = dflt });\n m[1] = null;\n });\n\n woutput.add.forEach(function(x) { \n var m = map(withKey.accessor(x));\n if(m[0]) m[0].forEach(function(d) { d[as] = x });\n m[1] = x;\n });\n \n // Only process woutput.mod tuples if the join key has changed.\n // Other field updates will auto-propagate via prototype.\n if(woutput.fields[withKey.field]) {\n woutput.mod.forEach(function(x) {\n var prev;\n if(!x._prev || (prev = withKey.accessor(x._prev)) === undefined) return;\n var prevm = map(prev);\n if(prevm[0]) prevm[0].forEach(function(d) { d[as] = dflt });\n prevm[1] = null;\n\n var m = map(withKey.accessor(x));\n if(m[0]) m[0].forEach(function(d) { d[as] = x });\n m[1] = x;\n });\n }\n\n this._lastJoin = woutput.stamp;\n }\n \n input.add.forEach(function(x) {\n var m = map(key.accessor(x));\n x[as] = m[1] || dflt;\n (m[0]=m[0]||[]).push(x);\n });\n\n input.rem.forEach(function(x) { \n var k = key.accessor(x);\n (rem[k]=rem[k]||{})[x._id] = 1;\n });\n\n if(input.fields[key.field]) {\n input.mod.forEach(function(x) {\n var prev;\n if(!x._prev || (prev = key.accessor(x._prev)) === undefined) return;\n\n var m = map(key.accessor(x));\n x[as] = m[1] || dflt;\n (m[0]=m[0]||[]).push(x);\n (rem[prev]=rem[prev]||{})[x._id] = 1;\n });\n }\n\n dl.keys(rem).forEach(function(k) { \n var m = map(k);\n if(!m[0]) return;\n m[0] = m[0].filter(function(x) { return rem[k][x._id] !== 1 });\n });\n } else {\n // We only need to run a non-key-join again if we've got any add/rem\n // on input or woutput\n if(input.add.length == 0 && input.rem.length == 0 && \n woutput.add.length == 0 && woutput.rem.length == 0) return input;\n\n // If we don't have a key-join, then we need to materialize both\n // data sources to iterate through them. \n this._collector.evaluate(input);\n\n var data = this._collector.data(), \n wlen = wdata.length, i;\n\n for(i = 0; i < data.length; i++) { data[i][as] = wdata[i%wlen]; }\n }\n\n input.fields[as] = 1;\n return input;\n};\n\nmodule.exports = Zip;",
"module.exports = {\n aggregate: require('./Aggregate'),\n bin: require('./Bin'),\n cross: require('./Cross'),\n linkpath: require('./LinkPath'),\n facet: require('./Facet'),\n filter: require('./Filter'),\n fold: require('./Fold'),\n force: require('./Force'),\n formula: require('./Formula'),\n geo: require('./Geo'),\n geopath: require('./GeoPath'),\n pie: require('./Pie'),\n sort: require('./Sort'),\n stack: require('./Stack'),\n treemap: require('./Treemap'),\n zip: require('./Zip')\n};",
"var bounds = function(b) {\n this.clear();\n if (b) this.union(b);\n};\n\nvar prototype = bounds.prototype;\n\nprototype.clear = function() {\n this.x1 = +Number.MAX_VALUE;\n this.y1 = +Number.MAX_VALUE;\n this.x2 = -Number.MAX_VALUE;\n this.y2 = -Number.MAX_VALUE;\n return this;\n};\n\nprototype.set = function(x1, y1, x2, y2) {\n this.x1 = x1;\n this.y1 = y1;\n this.x2 = x2;\n this.y2 = y2;\n return this;\n};\n\nprototype.add = function(x, y) {\n if (x < this.x1) this.x1 = x;\n if (y < this.y1) this.y1 = y;\n if (x > this.x2) this.x2 = x;\n if (y > this.y2) this.y2 = y;\n return this;\n};\n\nprototype.expand = function(d) {\n this.x1 -= d;\n this.y1 -= d;\n this.x2 += d;\n this.y2 += d;\n return this;\n};\n\nprototype.round = function() {\n this.x1 = Math.floor(this.x1);\n this.y1 = Math.floor(this.y1);\n this.x2 = Math.ceil(this.x2);\n this.y2 = Math.ceil(this.y2);\n return this;\n};\n\nprototype.translate = function(dx, dy) {\n this.x1 += dx;\n this.x2 += dx;\n this.y1 += dy;\n this.y2 += dy;\n return this;\n};\n\nprototype.rotate = function(angle, x, y) {\n var cos = Math.cos(angle),\n sin = Math.sin(angle),\n cx = x - x*cos + y*sin,\n cy = y - x*sin - y*cos,\n x1 = this.x1, x2 = this.x2,\n y1 = this.y1, y2 = this.y2;\n\n return this.clear()\n .add(cos*x1 - sin*y1 + cx, sin*x1 + cos*y1 + cy)\n .add(cos*x1 - sin*y2 + cx, sin*x1 + cos*y2 + cy)\n .add(cos*x2 - sin*y1 + cx, sin*x2 + cos*y1 + cy)\n .add(cos*x2 - sin*y2 + cx, sin*x2 + cos*y2 + cy);\n}\n\nprototype.union = function(b) {\n if (b.x1 < this.x1) this.x1 = b.x1;\n if (b.y1 < this.y1) this.y1 = b.y1;\n if (b.x2 > this.x2) this.x2 = b.x2;\n if (b.y2 > this.y2) this.y2 = b.y2;\n return this;\n};\n\nprototype.encloses = function(b) {\n return b && (\n this.x1 <= b.x1 &&\n this.x2 >= b.x2 &&\n this.y1 <= b.y1 &&\n this.y2 >= b.y2\n );\n};\n\nprototype.intersects = function(b) {\n return b && !(\n this.x2 < b.x1 ||\n this.x1 > b.x2 ||\n this.y2 < b.y1 ||\n this.y1 > b.y2\n );\n};\n\nprototype.contains = function(x, y) {\n return !(\n x < this.x1 ||\n x > this.x2 ||\n y < this.y1 ||\n y > this.y2\n );\n};\n\nprototype.width = function() {\n return this.x2 - this.x1;\n};\n\nprototype.height = function() {\n return this.y2 - this.y1;\n};\n\nmodule.exports = bounds;",
"var vg_gradient_id = 0;\n\nfunction gradient(type) {\n this.id = \"grad_\" + (vg_gradient_id++);\n this.type = type || \"linear\";\n this.stops = [];\n this.x1 = 0;\n this.x2 = 1;\n this.y1 = 0;\n this.y2 = 0;\n};\n\nvar prototype = gradient.prototype;\n\nprototype.stop = function(offset, color) {\n this.stops.push({\n offset: offset,\n color: color\n });\n return this;\n};\n\nmodule.exports = gradient;",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n dl = require('datalib'),\n Bounds = require('../util/Bounds'),\n canvas = require('../render/canvas/path'),\n config = require('./config');\n\nvar parse = canvas.parse,\n boundPath = canvas.bounds,\n areaPath = canvas.area,\n linePath = canvas.line,\n halfpi = Math.PI / 2,\n sqrt3 = Math.sqrt(3),\n tan30 = Math.tan(30 * Math.PI / 180),\n gfx = null;\n\nfunction fontString(o) {\n return (o.fontStyle ? o.fontStyle + \" \" : \"\")\n + (o.fontVariant ? o.fontVariant + \" \" : \"\")\n + (o.fontWeight ? o.fontWeight + \" \" : \"\")\n + (o.fontSize != null ? o.fontSize : config.render.fontSize) + \"px \"\n + (o.font || config.render.font);\n}\n\nfunction context() {\n return gfx || (gfx = (dl.isNode\n ? new ((typeof window !== \"undefined\" ? window.canvas : typeof global !== \"undefined\" ? global.canvas : null))(1,1)\n : d3.select(\"body\").append(\"canvas\")\n .attr(\"class\", \"vega_hidden\")\n .attr(\"width\", 1)\n .attr(\"height\", 1)\n .style(\"display\", \"none\")\n .node())\n .getContext(\"2d\"));\n}\n\nfunction pathBounds(o, path, bounds) {\n if (path == null) {\n bounds.set(0, 0, 0, 0);\n } else {\n boundPath(path, bounds);\n if (o.stroke && o.opacity !== 0 && o.strokeWidth > 0) {\n bounds.expand(o.strokeWidth);\n }\n }\n return bounds;\n}\n\nfunction path(o, bounds) {\n var p = o.path\n ? o.pathCache || (o.pathCache = parse(o.path))\n : null;\n return pathBounds(o, p, bounds);\n}\n\nfunction area(o, bounds) {\n var items = o.mark.items, o = items[0];\n var p = o.pathCache || (o.pathCache = parse(areaPath(items)));\n return pathBounds(items[0], p, bounds);\n}\n\nfunction line(o, bounds) {\n var items = o.mark.items, o = items[0];\n var p = o.pathCache || (o.pathCache = parse(linePath(items)));\n return pathBounds(items[0], p, bounds);\n}\n\nfunction rect(o, bounds) {\n var x = o.x || 0,\n y = o.y || 0,\n w = (x + o.width) || 0,\n h = (y + o.height) || 0;\n bounds.set(x, y, w, h);\n if (o.stroke && o.opacity !== 0 && o.strokeWidth > 0) {\n bounds.expand(o.strokeWidth);\n }\n return bounds;\n}\n\nfunction image(o, bounds) {\n var w = o.width || 0,\n h = o.height || 0,\n x = (o.x||0) - (o.align === \"center\"\n ? w/2 : (o.align === \"right\" ? w : 0)),\n y = (o.y||0) - (o.baseline === \"middle\"\n ? h/2 : (o.baseline === \"bottom\" ? h : 0));\n return bounds.set(x, y, x+w, y+h);\n}\n\nfunction rule(o, bounds) {\n var x1, y1;\n bounds.set(\n x1 = o.x || 0,\n y1 = o.y || 0,\n o.x2 != null ? o.x2 : x1,\n o.y2 != null ? o.y2 : y1\n );\n if (o.stroke && o.opacity !== 0 && o.strokeWidth > 0) {\n bounds.expand(o.strokeWidth);\n }\n return bounds;\n}\n\nfunction arc(o, bounds) {\n var cx = o.x || 0,\n cy = o.y || 0,\n ir = o.innerRadius || 0,\n or = o.outerRadius || 0,\n sa = (o.startAngle || 0) - halfpi,\n ea = (o.endAngle || 0) - halfpi,\n xmin = Infinity, xmax = -Infinity,\n ymin = Infinity, ymax = -Infinity,\n a, i, n, x, y, ix, iy, ox, oy;\n\n var angles = [sa, ea],\n s = sa - (sa%halfpi);\n for (i=0; i<4 && s<ea; ++i, s+=halfpi) {\n angles.push(s);\n }\n\n for (i=0, n=angles.length; i<n; ++i) {\n a = angles[i];\n x = Math.cos(a); ix = ir*x; ox = or*x;\n y = Math.sin(a); iy = ir*y; oy = or*y;\n xmin = Math.min(xmin, ix, ox);\n xmax = Math.max(xmax, ix, ox);\n ymin = Math.min(ymin, iy, oy);\n ymax = Math.max(ymax, iy, oy);\n }\n\n bounds.set(cx+xmin, cy+ymin, cx+xmax, cy+ymax);\n if (o.stroke && o.opacity !== 0 && o.strokeWidth > 0) {\n bounds.expand(o.strokeWidth);\n }\n return bounds;\n}\n\nfunction symbol(o, bounds) {\n var size = o.size != null ? o.size : 100,\n x = o.x || 0,\n y = o.y || 0,\n r, t, rx, ry;\n\n switch (o.shape) {\n case \"cross\":\n r = Math.sqrt(size / 5) / 2;\n t = 3*r;\n bounds.set(x-t, y-r, x+t, y+r);\n break;\n\n case \"diamond\":\n ry = Math.sqrt(size / (2 * tan30));\n rx = ry * tan30;\n bounds.set(x-rx, y-ry, x+rx, y+ry);\n break;\n\n case \"square\":\n t = Math.sqrt(size);\n r = t / 2;\n bounds.set(x-r, y-r, x+r, y+r);\n break;\n\n case \"triangle-down\":\n rx = Math.sqrt(size / sqrt3);\n ry = rx * sqrt3 / 2;\n bounds.set(x-rx, y-ry, x+rx, y+ry);\n break;\n\n case \"triangle-up\":\n rx = Math.sqrt(size / sqrt3);\n ry = rx * sqrt3 / 2;\n bounds.set(x-rx, y-ry, x+rx, y+ry);\n break;\n\n default:\n r = Math.sqrt(size/Math.PI);\n bounds.set(x-r, y-r, x+r, y+r);\n }\n if (o.stroke && o.opacity !== 0 && o.strokeWidth > 0) {\n bounds.expand(o.strokeWidth);\n }\n return bounds;\n}\n\nfunction text(o, bounds, noRotate) {\n var x = (o.x || 0) + (o.dx || 0),\n y = (o.y || 0) + (o.dy || 0),\n h = o.fontSize || config.render.fontSize,\n a = o.align,\n b = o.baseline,\n r = o.radius || 0,\n g = context(), w, t;\n\n g.font = fontString(o);\n g.textAlign = a || \"left\";\n g.textBaseline = b || \"alphabetic\";\n w = g.measureText(o.text || \"\").width;\n\n if (r) {\n t = (o.theta || 0) - Math.PI/2;\n x += r * Math.cos(t);\n y += r * Math.sin(t);\n }\n\n // horizontal\n if (a === \"center\") {\n x = x - (w / 2);\n } else if (a === \"right\") {\n x = x - w;\n } else {\n // left by default, do nothing\n }\n\n /// TODO find a robust solution for heights.\n /// These offsets work for some but not all fonts.\n\n // vertical\n if (b === \"top\") {\n y = y + (h/5);\n } else if (b === \"bottom\") {\n y = y - h;\n } else if (b === \"middle\") {\n y = y - (h/2) + (h/10);\n } else {\n y = y - 4*h/5; // alphabetic by default\n }\n \n bounds.set(x, y, x+w, y+h);\n if (o.angle && !noRotate) {\n bounds.rotate(o.angle*Math.PI/180, o.x||0, o.y||0);\n }\n return bounds.expand(noRotate ? 0 : 1);\n}\n\nfunction group(g, bounds, includeLegends) {\n var axes = g.axisItems || [],\n legends = g.legendItems || [], j, m;\n\n for (j=0, m=axes.length; j<m; ++j) {\n bounds.union(axes[j].bounds);\n }\n for (j=0, m=g.items.length; j<m; ++j) {\n bounds.union(g.items[j].bounds);\n }\n if (includeLegends) {\n for (j=0, m=legends.length; j<m; ++j) {\n bounds.union(legends[j].bounds);\n }\n if (g.width != null && g.height != null) {\n bounds.add(g.width, g.height);\n }\n if (g.x != null && g.y != null) {\n bounds.add(0, 0);\n }\n }\n bounds.translate(g.x||0, g.y||0);\n return bounds;\n}\n\nvar methods = {\n group: group,\n symbol: symbol,\n image: image,\n rect: rect,\n rule: rule,\n arc: arc,\n text: text,\n path: path,\n area: area,\n line: line\n};\n\nfunction itemBounds(item, func, opt) {\n func = func || methods[item.mark.marktype];\n if (!item.bounds_prev) item['bounds:prev'] = new Bounds();\n var b = item.bounds, pb = item['bounds:prev'];\n if (b) pb.clear().union(b);\n item.bounds = func(item, b ? b.clear() : new Bounds(), opt);\n if (!b) pb.clear().union(item.bounds);\n return item.bounds;\n}\n\nfunction markBounds(mark, bounds, opt) {\n bounds = bounds || mark.bounds && mark.bounds.clear() || new Bounds();\n var type = mark.marktype,\n func = methods[type],\n items = mark.items,\n item, i, len;\n \n if (type===\"area\" || type===\"line\") {\n if (items.length) {\n items[0].bounds = func(items[0], bounds);\n }\n } else {\n for (i=0, len=items.length; i<len; ++i) {\n bounds.union(itemBounds(items[i], func, opt));\n }\n }\n mark.bounds = bounds;\n}\n\nmodule.exports = {\n mark: markBounds,\n item: itemBounds,\n text: text,\n group: group\n};",
"var d3 = (typeof window !== \"undefined\" ? window.d3 : typeof global !== \"undefined\" ? global.d3 : null),\n config = {};\n\nconfig.debug = false;\n\nconfig.load = {\n // base url for loading external data files\n // used only for server-side operation\n baseURL: \"\",\n // Allows domain restriction when using data loading via XHR.\n // To enable, set it to a list of allowed domains\n // e.g., ['wikipedia.org', 'eff.org']\n domainWhiteList: false\n};\n\n// version and namepsaces for exported svg\nconfig.svgNamespace =\n 'version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" ' +\n 'xmlns:xlink=\"http://www.w3.org/1999/xlink\"';\n\n// inset padding for automatic padding calculation\nconfig.autopadInset = 5;\n\n// extensible scale lookup table\n// all d3.scale.* instances also supported\nconfig.scale = {\n time: d3.time.scale,\n utc: d3.time.scale.utc\n};\n\n// default rendering settings\nconfig.render = {\n lineWidth: 1,\n lineCap: \"butt\",\n font: \"sans-serif\",\n fontSize: 11\n};\n\n// default axis properties\nconfig.axis = {\n orient: \"bottom\",\n ticks: 10,\n padding: 3,\n axisColor: \"#000\",\n gridColor: \"#d8d8d8\",\n tickColor: \"#000\",\n tickLabelColor: \"#000\",\n axisWidth: 1,\n tickWidth: 1,\n tickSize: 6,\n tickLabelFontSize: 11,\n tickLabelFont: \"sans-serif\",\n titleColor: \"#000\",\n titleFont: \"sans-serif\",\n titleFontSize: 11,\n titleFontWeight: \"bold\",\n titleOffset: 35\n};\n\n// default legend properties\nconfig.legend = {\n orient: \"right\",\n offset: 10,\n padding: 3,\n gradientStrokeColor: \"#888\",\n gradientStrokeWidth: 1,\n gradientHeight: 16,\n gradientWidth: 100,\n labelColor: \"#000\",\n labelFontSize: 10,\n labelFont: \"sans-serif\",\n labelAlign: \"left\",\n labelBaseline: \"middle\",\n labelOffset: 8,\n symbolShape: \"circle\",\n symbolSize: 50,\n symbolColor: \"#888\",\n symbolStrokeWidth: 1,\n titleColor: \"#000\",\n titleFont: \"sans-serif\",\n titleFontSize: 11,\n titleFontWeight: \"bold\"\n};\n\n// default color values\nconfig.color = {\n rgb: [128, 128, 128],\n lab: [50, 0, 0],\n hcl: [0, 0, 50],\n hsl: [0, 0, 0.5]\n};\n\n// default scale ranges\nconfig.range = {\n category10: [\n \"#1f77b4\",\n \"#ff7f0e\",\n \"#2ca02c\",\n \"#d62728\",\n \"#9467bd\",\n \"#8c564b\",\n \"#e377c2\",\n \"#7f7f7f\",\n \"#bcbd22\",\n \"#17becf\"\n ],\n category20: [\n \"#1f77b4\",\n \"#aec7e8\",\n \"#ff7f0e\",\n \"#ffbb78\",\n \"#2ca02c\",\n \"#98df8a\",\n \"#d62728\",\n \"#ff9896\",\n \"#9467bd\",\n \"#c5b0d5\",\n \"#8c564b\",\n \"#c49c94\",\n \"#e377c2\",\n \"#f7b6d2\",\n \"#7f7f7f\",\n \"#c7c7c7\",\n \"#bcbd22\",\n \"#dbdb8d\",\n \"#17becf\",\n \"#9edae5\"\n ],\n shapes: [\n \"circle\",\n \"cross\",\n \"diamond\",\n \"square\",\n \"triangle-down\",\n \"triangle-up\"\n ]\n};\n\nmodule.exports = config;",
"module.exports = {\n ADD_CELL: 1,\n MOD_CELL: 2,\n\n ID: \"_id\",\n\n DATA: \"data\",\n FIELDS: \"fields\",\n SCALES: \"scales\",\n SIGNAL: \"signal\",\n SIGNALS: \"signals\",\n\n GROUP: \"group\",\n\n ENTER: \"enter\",\n UPDATE: \"update\",\n EXIT: \"exit\",\n\n SENTINEL: {\"sentinel\": 1},\n SINGLETON: \"_singleton\",\n\n ADD: \"add\",\n REMOVE: \"remove\",\n TOGGLE: \"toggle\",\n CLEAR: \"clear\",\n\n LINEAR: \"linear\",\n ORDINAL: \"ordinal\",\n LOG: \"log\",\n POWER: \"pow\",\n TIME: \"time\",\n QUANTILE: \"quantile\",\n\n DOMAIN: \"domain\",\n RANGE: \"range\",\n\n MARK: \"mark\",\n AXIS: \"axis\",\n LEGEND: \"legend\",\n\n COUNT: \"count\",\n GROUPBY: \"groupby\",\n MIN: \"min\",\n MAX: \"max\",\n VALUE: \"value\",\n\n SORT: \"sort\",\n ASC: \"asc\",\n DESC: \"desc\"\n};",
"var config = require('./config');\nvar ts;\n\nmodule.exports = function(input, args) {\n if (!config.debug) return;\n var log = Function.prototype.bind.call(console.log, console);\n args.unshift(input.stamp||-1);\n args.unshift(Date.now() - ts);\n if(input.add) args.push(input.add.length, input.mod.length, input.rem.length, !!input.reflow);\n log.apply(console, args);\n ts = Date.now();\n};"
]
}